bartavelle / language-puppet

A library to work with Puppet manifests, test them and eventually replace everything ruby.
BSD 3-Clause "New" or "Revised" License
51 stars 8 forks source link

Erb error with dirname(file) #121

Closed PierreR closed 9 years ago

PierreR commented 9 years ago

I have got an error in erb templates starting with:

<%= ERB.new(File.read(File.expand_path("_header.erb",File.dirname(file)))).result(binding) -%>
ERROR: (puppet/foreman_testing) no implicit conversion of Float into String
(erb):1:in `dirname'
(erb):1:in `get_binding'
/usr/lib/ruby/2.2.0/erb.rb:863:in `eval'
/usr/lib/ruby/2.2.0/erb.rb:863:in `result'
/home/vagrant/projects/cicd/language-puppet/.cabal-sandbox/share/x86_64-linux-ghc-7.10.1/language-puppet-1.1.3.1/ruby/hrubyerb.rb:107:in `runFromContent'
/home/vagrant/projects/cicd/language-puppet/.cabal-sandbox/share/x86_64-linux-ghc-7.10.1/language-puppet-1.1.3.1/ruby/hrubyerb.rb:102:in `runFromFile'

https://github.com/theforeman/puppet-foreman/blob/master/templates/database.yml.erb#L1

Do you have any idea how I could alleviate the problem ? I don't care if the solution would just ignore this kind of input line from template file ...

bartavelle commented 9 years ago

What's the value of file ?

PierreR commented 9 years ago

Well I don't know (same for binding)... I thought it was some function that Erb recognizes ... I am just trying to use this foreman puppetlabs module (without ignoring it totally) ...

bartavelle commented 9 years ago

I know what bindings is, but not sure about file ... if it's something built in it might be the path ?

PierreR commented 9 years ago

So I have tested it and ´file´ is the absolute path of the template.

bartavelle commented 9 years ago

Just pushed something, does it help ?

PierreR commented 9 years ago

It works fine. Thanks !