birarda / logan

ruby gem to communicate with new Basecamp API
MIT License
16 stars 19 forks source link

`blank?` is missing #18

Open stevesparks opened 9 years ago

stevesparks commented 9 years ago

I have some code that creates a Logan client, and inserts some todos. If I do not need Rails, then when I go to create my todo, I get the following:

irb(main):003:0> target = @client.project_by_name("Test Project")
=> #<Logan::Project:0x007fa1c2b414d0 @id=6949038, @name="Test Project">
irb(main):004:0> team = {}
=> {}
irb(main):005:0>  @client.generate_todolist(target, team, iteration_id: 1)
Writing into project "Test Project"
Saving list "Iteration 1 Recurring Todos"
Creating unassigned todo: Communicate any training, vacations, or other time off to the client
NoMethodError: undefined method `blank?' for nil:NilClass
    from /Users/barbecuesteve/.gem/ruby/2.1.1/gems/logan-0.1.1/lib/logan/todo.rb:22:in `post_json'
    from /Users/barbecuesteve/.gem/ruby/2.1.1/gems/logan-0.1.1/lib/logan/todolist.rb:92:in `create_todo'
...
irb(main):006:0> 

I find that I can make this error go away by either requiring rails, or by simply adding that method from the source:

class Object
  def blank?
    respond_to?(:empty?) ? !!empty? : !self
  end
end

Please address.

birarda commented 9 years ago

Oh geez, my bad. Fixing now.

stevesparks commented 9 years ago

:+1:

birarda commented 9 years ago

okay, pushed 0.1.2 that removes calls to blank?

stevesparks commented 9 years ago

I saw that. And then like an idiot I ran gem update instead of gem update logan. Going for a coffee, will let you know. >.<

stevesparks commented 9 years ago

Yep, nailed it!! Thanks!

stevesparks commented 9 years ago

Geez, now it tells me that empty? is missing:

NoMethodError: undefined method `empty?' for #<Logan::Person:0x007fa466c4de18>
    from /Users/barbecuesteve/.gem/ruby/2.1.1/gems/logan-0.1.2/lib/logan/todo.rb:22:in `post_json'
    from /Users/barbecuesteve/.gem/ruby/2.1.1/gems/logan-0.1.2/lib/logan/todolist.rb:92:in `create_todo'
    from maker.rb:126:in `copy_todo_to_list'
...
birarda commented 9 years ago

Taking a look - seems odd since I thought the whole point was that blank was rails specific but empty is not.

birarda commented 9 years ago

Oh, duh. Pushing a fix now

birarda commented 9 years ago

Okay - 0.1.3 is pushed that fixes this. Let me know if still busted!

bdunlap commented 8 years ago

this is back in 0.2.2, see line 25 of logan/todo.rb

bdunlap commented 8 years ago

My mistake, I looked again and saw that you didn't remove the call to blank in 2ebd2fb but just removed it from the default code path. Somehow my code just triggered it at line 25 though.

birarda commented 8 years ago

@bdunlap thanks for highlighting that - was reintroduced with a PR from a contributor.

I'll re-open to fix this.

bdunlap commented 8 years ago

great thanks!

RobertDeRose commented 8 years ago

@birarda any word on a fix for this?