Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

To much magic... ({} != Hash.new()) #39

Open
Edgy opened this issue May 10, 2012 · 2 comments
Open

To much magic... ({} != Hash.new()) #39

Edgy opened this issue May 10, 2012 · 2 comments
Labels

Comments

@Edgy
Copy link

Edgy commented May 10, 2012

First off - thank you very much for creating boson. I've found it to be a wonderful tool. Recently I've been upgrading from < 1.0 to 1.2.3. I've noticed that defining "options" as "Hash.new()" does not work.

module Foo
  option :urgent, type: :boolean, default: true
  def say(text, options=Hash.new())
    text.capitalize! if options[:urgent]
    puts text
  end
end

Where as this works:

module Foo
  option :urgent, type: :boolean, default: true
  def say(text, options={})
    text.capitalize! if options[:urgent]
    puts text
  end
end

This was execute with: ruby 1.9.3p125 (2012-02-16 revision 34643) [x86_64-linux]

@cldwalker
Copy link
Owner

Thanks for the bug report. Can you give me the error message and/or stacktrace you're getting?

@Edgy
Copy link
Author

Edgy commented May 10, 2012

Sorry, no error message or exceptions. The options is just an empty hash.

module Foo
  option :urgent, type: :boolean, default: true
  # Does a WTF
  def wtf(argv=Hash.new())
    puts "ARGV: #{argv.inspect}"
  end
end

yields:

$ boson wtf
ARGV: {}

Interestingly...

$ boson wtf -u
ARGV: "-u"
$ boson wtf lalalalalalalala
ARGV: "lalalalalalalala"

Two arguments seems to causes it to bork


Error: undefined method `take_while' for false:FalseClass
Original error: undefined method `take_while' for false:FalseClass
  /home/.rvm/gems/ruby-1.9.3-p125@bb2/gems/boson-1.2.3/lib/boson/command.rb:147:in `incorrect_arg_size?'
  /home/.rvm/gems/ruby-1.9.3-p125@bb2/gems/boson-1.2.3/lib/boson/bare_runner.rb:62:in `allowed_argument_error?'
  /home/.rvm/gems/ruby-1.9.3-p125@bb2/gems/boson-more-0.2.2/lib/boson/science.rb:240:in `allowed_argument_error?'
  /home/.rvm/gems/ruby-1.9.3-p125@bb2/gems/boson-1.2.3/lib/boson/bare_runner.rb:44:in `rescue in execute_command'
  /home/.rvm/gems/ruby-1.9.3-p125@bb2/gems/boson-1.2.3/lib/boson/bare_runner.rb:42:in `execute_command'
  /home/.rvm/gems/ruby-1.9.3-p125@bb2/gems/boson-more-0.2.2/lib/boson/save.rb:174:in `execute_command'
  /home/.rvm/gems/ruby-1.9.3-p125@bb2/gems/boson-more-0.2.2/lib/boson/pipe_runner.rb:24:in `block in execute_command'
  /home/.rvm/gems/ruby-1.9.3-p125@bb2/gems/boson-more-0.2.2/lib/boson/pipe_runner.rb:22:in `each'
  /home/.rvm/gems/ruby-1.9.3-p125@bb2/gems/boson-more-0.2.2/lib/boson/pipe_runner.rb:22:in `inject'
  /home/.rvm/gems/ruby-1.9.3-p125@bb2/gems/boson-more-0.2.2/lib/boson/pipe_runner.rb:22:in `execute_command'
  /home/.rvm/gems/ruby-1.9.3-p125@bb2/gems/boson-more-0.2.2/lib/boson/science.rb:244:in `execute_command'
  /home/.rvm/gems/ruby-1.9.3-p125@bb2/gems/boson-1.2.3/lib/boson/bin_runner.rb:25:in `execute_option_or_command'
  /home/.rvm/gems/ruby-1.9.3-p125@bb2/gems/boson-more-0.2.2/lib/boson/runner_options.rb:67:in `execute_option_or_command'
  /home/.rvm/gems/ruby-1.9.3-p125@bb2/gems/boson-1.2.3/lib/boson/bin_runner.rb:102:in `start'
  /home/.rvm/gems/ruby-1.9.3-p125@bb2/gems/boson-1.2.3/bin/boson:6:in `<top (required)>'
  /home/.rvm/gems/ruby-1.9.3-p125@bb2/bin/boson:19:in `load'
  /home/.rvm/gems/ruby-1.9.3-p125@bb2/bin/boson:19:in `<main>'

Now that I look at the backtrace, it reminded me that I'm also using boson-more and added to my ~/.bosonrc

$ cat ~/.bosonrc 
require 'boson/more'

I hope that helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants