Bug fix suggestion

0 views
Skip to first unread message

Marcus Martin

unread,
Mar 30, 2010, 9:35:31 PM3/30/10
to project...@googlegroups.com
Luke,

I would like to suggest that tool_task.rb line 778 be patched. I have hit several issues where the default projects do not work because the default rake file provides a string where an array is expected. This will allow for either argument to be used. Does this fit within the intended use of sprout? (Also, is there a more efficient way to do this? Still new to ruby.)

Marcus

    def prepare
      super
      usr = User.new
      path = nil
      if value.respond_to?("each_index")
        value.each_index do |index|
            path = value[index]
            value[index] = usr.clean_path path
        end
      else
          path = value
          value = usr.clean_path path
      end
    end

Luke Bayes

unread,
Mar 31, 2010, 12:55:36 PM3/31/10
to project...@googlegroups.com
Hey Marcus,

Thanks for the suggestion, and I'm in complete agreement that the tasks that expect arrays should do something different from what they do today when provided a string value.

What I've been meaning to do though, is to dig into the accessor, and throw some kind of much more helpful error message at the point of contact.

My concern with accepting string assignments, is that it's too easy to do this:

    tool_task :foo do |t|
      t.source_path = 'a'
      t.source_path = 'b'
      t.source_path = 'c'
      t.source_path = 'd'
   end

In this example, you would only receive the source_path 'd', and each of the previous assignments would be ignored. This seems much more difficult to figure out. With my proposal, the previous example would throw an error message that looks something like:

Error in rakefile.rb at line 2: the source_path property is an Array, not a String. It looks like you may have used the assignment operator (=) where the append operator (<<) was expected.

Does anyone else want to weigh in on this?

Thanks,

Luke
 


--
You received this message because you are subscribed to the Google Groups "ProjectSprouts" group.
To post to this group, send email to project...@googlegroups.com
To unsubscribe from this group, send email to projectsprout...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/projectsprouts?hl=en
 
For other info you can visit our project at: http://projectsprouts.org, or on Github at: http://github.com/lukebayes/project-sprouts

Stefan Simroth

unread,
Apr 5, 2010, 11:54:22 AM4/5/10
to ProjectSprouts
Hi Luke,

I'd be in favor of the explicit and helpful error message!
When the error message gives already the fix, it should also be easy
to resolve for someone who's new to ruby.
And having an array with only one element serves the same purpose as
having a single String property.

Stefan

Marcus Martin

unread,
Apr 7, 2010, 11:22:48 AM4/7/10
to project...@googlegroups.com
I am also okay with an error message.

To unsubscribe, reply using "remove me" as the subject.

Reply all
Reply to author
Forward
0 new messages