doodle 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +11 -0
- data/lib/doodle.rb +7 -0
- data/lib/doodle/app.rb +8 -3
- data/lib/doodle/version.rb +1 -1
- metadata +1 -1
    
        data/History.txt
    CHANGED
    
    | @@ -1,3 +1,14 @@ | |
| 1 | 
            +
            == 0.2.2 / 2009-03-02
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            - Features:
         | 
| 4 | 
            +
              - added obj.doodle.keys method
         | 
| 5 | 
            +
              - added more examples to website
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            == 0.2.1 / 2009-03-02
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            - Bug fixes:
         | 
| 10 | 
            +
              - Doodle::App not displaying help text
         | 
| 11 | 
            +
             | 
| 1 12 | 
             
            == 0.2.0 / 2009-02-08
         | 
| 2 13 | 
             
            - Features:
         | 
| 3 14 | 
             
              - object.doodle.values for easy access to array of attribute values
         | 
    
        data/lib/doodle.rb
    CHANGED
    
    | @@ -404,6 +404,13 @@ class Doodle | |
| 404 404 | 
             
                  attributes(tf).map{ |k, a| @this.send(k)}
         | 
| 405 405 | 
             
                end
         | 
| 406 406 |  | 
| 407 | 
            +
                # returns array of attribute names
         | 
| 408 | 
            +
                # - if tf == true, returns all inherited attribute names (default)
         | 
| 409 | 
            +
                # - if tf == false, returns only those attribute names defined in current object
         | 
| 410 | 
            +
                def keys(tf = true)
         | 
| 411 | 
            +
                  attributes(tf).keys
         | 
| 412 | 
            +
                end
         | 
| 413 | 
            +
             | 
| 407 414 | 
             
                # return class level attributes
         | 
| 408 415 | 
             
                def class_attributes
         | 
| 409 416 | 
             
                  attrs = Doodle::OrderedHash.new
         | 
    
        data/lib/doodle/app.rb
    CHANGED
    
    | @@ -27,6 +27,8 @@ require 'pp' | |
| 27 27 | 
             
            class Doodle
         | 
| 28 28 | 
             
              # command line option handling DSL implemented using Doodle
         | 
| 29 29 | 
             
              class App < Doodle
         | 
| 30 | 
            +
                class HelpExit < ::Exception
         | 
| 31 | 
            +
                end
         | 
| 30 32 | 
             
                # specialised classes for handling attributes
         | 
| 31 33 |  | 
| 32 34 | 
             
                # replace the full directory path with ./ where appropriate
         | 
| @@ -251,6 +253,8 @@ class Doodle | |
| 251 253 |  | 
| 252 254 | 
             
                  # use this to include 'standard' flags: help (-h, --help), verbose (-v, --verbose) and debug (-d, --debug)
         | 
| 253 255 | 
             
                  def std_flags
         | 
| 256 | 
            +
                    # FIXME: this is bogus
         | 
| 257 | 
            +
                    m = method(:help_text)
         | 
| 254 258 | 
             
                    boolean :help, :flag => "h", :doc => "display this help"
         | 
| 255 259 | 
             
                    boolean :verbose, :flag => "v", :doc => "verbose output"
         | 
| 256 260 | 
             
                    boolean :debug, :flag => "D", :doc => "turn on debugging"
         | 
| @@ -261,13 +265,14 @@ class Doodle | |
| 261 265 | 
             
                  # call App.run to start your application (calls instance.run)
         | 
| 262 266 | 
             
                  def run(argv = ARGV)
         | 
| 263 267 | 
             
                    begin
         | 
| 264 | 
            -
                       | 
| 265 | 
            -
                      if  | 
| 268 | 
            +
                      # cheating
         | 
| 269 | 
            +
                      if argv.include?('-h') or argv.include?('--help')
         | 
| 266 270 | 
             
                        puts help_text
         | 
| 267 271 | 
             
                      else
         | 
| 272 | 
            +
                        app = from_argv(argv)
         | 
| 268 273 | 
             
                        app.run
         | 
| 269 274 | 
             
                      end
         | 
| 270 | 
            -
                    rescue  | 
| 275 | 
            +
                    rescue Exception => e
         | 
| 271 276 | 
             
                      if exit_status == 0
         | 
| 272 277 | 
             
                        exit_status 1
         | 
| 273 278 | 
             
                      end
         | 
    
        data/lib/doodle/version.rb
    CHANGED