Skip to content

config file problem: local_variables not being loaded on ruby 1.9.x #3

@victorhg

Description

@victorhg

Hello,
I'm using ruby 1.9.1-p376 and have tried this with 1.9.2

The project is configured fine, but when I execute

victorhg$ inploy setup
/Users/victorhg/.rvm/gems/ruby-1.9.1-p376/gems/inploy-1.6.0/lib/inploy/dsl.rb:48:in `remote_run': undefined method `each' for nil:NilClass (NoMethodError)
from /Users/victorhg/.rvm/gems/ruby-1.9.1-p376/gems/inploy-1.6.0/lib/inploy/deploy.rb:48:in `remote_setup'
from /Users/victorhg/.rvm/gems/ruby-1.9.1-p376/gems/inploy-1.6.0/lib/inploy/cli.rb:9:in `execute'
from /Users/victorhg/.rvm/gems/ruby-1.9.1-p376/gems/inploy-1.6.0/bin/inploy:7:in `<top (required)>'
from /Users/victorhg/.rvm/gems/ruby-1.9.1-p376/bin/inploy:19:in `load'
from /Users/victorhg/.rvm/gems/ruby-1.9.1-p376/bin/inploy:19:in `<main>'

Here's my config/deploy.rb file:

template = :rails3
application = "myProject"
repository = 'git@github.com:user/project.git'
hosts = ['server']

path = '/var/www/'
user = 'rails'

Explaining the problem:

Well, because of the change on how eval method handles local variables, we cannot have something like this on ruby 1.9:

eval "variable = 1"
print variable

The way inploy handles the configuration parameters is not working (at least for me). Here is the problem in the code:

inploy/deploy.rb:27

def configure
    if file = configuration_file
      deploy = self
      eval file.read
      local_variables.each do |variable
        send "#{variable}=", eval(variable) rescue nil
      end
    end
  end

When executing eval file.read the variables are not created as local variables, but only as local variables inside the eval scope. To solve this, I had to change the config/deploy file to created instance variables:

@template = :rails3
@application = "myProject"
@repository = 'git@github.com:user/project.git'
@hosts = ['server']

@path = '/var/www/'
@user = 'rails'

Maybe there's a better way to make it work... or I would be really glad to hear that it's just some stupid mistake I did....

thank you...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions