executable 1.2.0 → 1.2.1
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/.index +71 -0
- data/.ruby +1 -61
- data/Config.rb +16 -0
- data/{DEMO.rdoc → DEMO.md} +108 -108
- data/{HISTORY.rdoc → HISTORY.md} +16 -4
- data/LICENSE.txt +22 -0
- data/{README.rdoc → README.md} +44 -29
- data/demo/{00_introduction.rdoc → 00_introduction.md} +1 -1
- data/demo/{01_single_command.rdoc → 01_single_command.md} +1 -1
- data/demo/{02_multiple_commands.rdoc → 02_multiple_commands.md} +1 -1
- data/demo/{03_help_text.rdoc → 03_help_text.md} +5 -5
- data/demo/{04_manpage.rdoc → 04_manpage.md} +4 -4
- data/demo/{06_delegate_example.rdoc → 06_delegate_example.md} +1 -1
- data/demo/{07_command_methods.rdoc → 07_command_methods.md} +1 -1
- data/demo/{08_dispatach.rdoc → 08_dispatach.md} +1 -1
- data/demo/{05_optparse_example.rdoc → 09_optparse_example.md} +1 -1
- data/demo/samples/bin/hello +9 -2
- data/lib/executable.rb +1 -1
- data/lib/executable.yml +71 -0
- data/lib/executable/dispatch.rb +1 -1
- data/lib/executable/domain.rb +41 -1
- data/lib/executable/help.rb +10 -7
- data/lib/executable/version.rb +7 -10
- metadata +53 -41
- data/COPYING.rdoc +0 -35
- data/Schedule.reap +0 -17
- data/meta/authors +0 -2
- data/meta/copyrights +0 -3
- data/meta/created +0 -1
- data/meta/description +0 -6
- data/meta/name +0 -1
- data/meta/organization +0 -1
- data/meta/repositories +0 -2
- data/meta/requirements +0 -6
- data/meta/resources +0 -7
- data/meta/summary +0 -1
- data/meta/version +0 -1
    
        data/.index
    ADDED
    
    | @@ -0,0 +1,71 @@ | |
| 1 | 
            +
            ---
         | 
| 2 | 
            +
            type: ruby
         | 
| 3 | 
            +
            revision: 2013
         | 
| 4 | 
            +
            sources:
         | 
| 5 | 
            +
            - var
         | 
| 6 | 
            +
            authors:
         | 
| 7 | 
            +
            - name: 7rans
         | 
| 8 | 
            +
              email: transfire@gmail.com
         | 
| 9 | 
            +
            organizations: []
         | 
| 10 | 
            +
            requirements:
         | 
| 11 | 
            +
            - groups:
         | 
| 12 | 
            +
              - test
         | 
| 13 | 
            +
              development: true
         | 
| 14 | 
            +
              name: qed
         | 
| 15 | 
            +
            - groups:
         | 
| 16 | 
            +
              - test
         | 
| 17 | 
            +
              development: true
         | 
| 18 | 
            +
              name: ae
         | 
| 19 | 
            +
            - groups:
         | 
| 20 | 
            +
              - build
         | 
| 21 | 
            +
              development: true
         | 
| 22 | 
            +
              name: detroit
         | 
| 23 | 
            +
            - groups:
         | 
| 24 | 
            +
              - build
         | 
| 25 | 
            +
              development: true
         | 
| 26 | 
            +
              name: simplecov
         | 
| 27 | 
            +
            conflicts: []
         | 
| 28 | 
            +
            alternatives: []
         | 
| 29 | 
            +
            resources:
         | 
| 30 | 
            +
            - type: home
         | 
| 31 | 
            +
              uri: http://rubyworks.github.com/executable
         | 
| 32 | 
            +
              label: Homepage
         | 
| 33 | 
            +
            - type: code
         | 
| 34 | 
            +
              uri: http://github.com/rubyworks/executable
         | 
| 35 | 
            +
              label: Source Code
         | 
| 36 | 
            +
            - type: bugs
         | 
| 37 | 
            +
              uri: http://github.com/rubyworks/executable/issues
         | 
| 38 | 
            +
              label: Issue Tracker
         | 
| 39 | 
            +
            - type: mail
         | 
| 40 | 
            +
              uri: http://groups.google.com/rubyworks-mailinglist
         | 
| 41 | 
            +
              label: Mailing List
         | 
| 42 | 
            +
            - type: chat
         | 
| 43 | 
            +
              uri: irc://chat.us.freenode.net#rubyworks
         | 
| 44 | 
            +
              label: IRC Channel
         | 
| 45 | 
            +
            repositories:
         | 
| 46 | 
            +
            - name: upstream
         | 
| 47 | 
            +
              scm: git
         | 
| 48 | 
            +
              uri: git://github.com/rubyworks/executable.git
         | 
| 49 | 
            +
            categories: []
         | 
| 50 | 
            +
            paths:
         | 
| 51 | 
            +
              load:
         | 
| 52 | 
            +
              - lib
         | 
| 53 | 
            +
            copyrights:
         | 
| 54 | 
            +
            - holder: Rubyworks
         | 
| 55 | 
            +
              year: '2008'
         | 
| 56 | 
            +
              license: BSD-2-Clause
         | 
| 57 | 
            +
            created: '2008-08-08'
         | 
| 58 | 
            +
            summary: Commandline Object Mapper
         | 
| 59 | 
            +
            version: 1.2.1
         | 
| 60 | 
            +
            name: executable
         | 
| 61 | 
            +
            title: Executable
         | 
| 62 | 
            +
            description: ! 'Think of Executable as a *COM*, a Commandline Object Mapper,
         | 
| 63 | 
            +
             | 
| 64 | 
            +
              in much the same way that ActiveRecord is an ORM,
         | 
| 65 | 
            +
             | 
| 66 | 
            +
              an Object Relational Mapper. A class utilizing Executable
         | 
| 67 | 
            +
             | 
| 68 | 
            +
              can define a complete command line tool using nothing more
         | 
| 69 | 
            +
             | 
| 70 | 
            +
              than Ruby''s own method definitions.'
         | 
| 71 | 
            +
            date: '2012-12-18'
         | 
    
        data/.ruby
    CHANGED
    
    | @@ -1,61 +1 @@ | |
| 1 | 
            -
             | 
| 2 | 
            -
            source:
         | 
| 3 | 
            -
            - meta
         | 
| 4 | 
            -
            authors:
         | 
| 5 | 
            -
            - name: 7rans
         | 
| 6 | 
            -
              email: transfire@gmail.com
         | 
| 7 | 
            -
            copyrights:
         | 
| 8 | 
            -
            - holder: Rubyworks
         | 
| 9 | 
            -
              year: '2008'
         | 
| 10 | 
            -
              license: BSD-2-Clause
         | 
| 11 | 
            -
            replacements: []
         | 
| 12 | 
            -
            alternatives: []
         | 
| 13 | 
            -
            requirements:
         | 
| 14 | 
            -
            - name: qed
         | 
| 15 | 
            -
              groups:
         | 
| 16 | 
            -
              - test
         | 
| 17 | 
            -
              development: true
         | 
| 18 | 
            -
            - name: ae
         | 
| 19 | 
            -
              groups:
         | 
| 20 | 
            -
              - test
         | 
| 21 | 
            -
              development: true
         | 
| 22 | 
            -
            - name: detroit
         | 
| 23 | 
            -
              groups:
         | 
| 24 | 
            -
              - build
         | 
| 25 | 
            -
              development: true
         | 
| 26 | 
            -
            - name: simplecov
         | 
| 27 | 
            -
              groups:
         | 
| 28 | 
            -
              - build
         | 
| 29 | 
            -
              development: true
         | 
| 30 | 
            -
            dependencies: []
         | 
| 31 | 
            -
            conflicts: []
         | 
| 32 | 
            -
            repositories:
         | 
| 33 | 
            -
            - uri: git://github.com/rubyworks/executable.git
         | 
| 34 | 
            -
              scm: git
         | 
| 35 | 
            -
              name: upstream
         | 
| 36 | 
            -
            resources:
         | 
| 37 | 
            -
              home: http://rubyworks.github.com/executable
         | 
| 38 | 
            -
              code: http://github.com/rubyworks/executable
         | 
| 39 | 
            -
              bugs: http://github.com/rubyworks/executable/issues
         | 
| 40 | 
            -
              mail: http://groups.google.com/rubyworks-mailinglist
         | 
| 41 | 
            -
              chat: irc://chat.us.freenode.net#rubyworks
         | 
| 42 | 
            -
            extra: {}
         | 
| 43 | 
            -
            load_path:
         | 
| 44 | 
            -
            - lib
         | 
| 45 | 
            -
            revision: 0
         | 
| 46 | 
            -
            created: '2008-08-08'
         | 
| 47 | 
            -
            summary: Commandline Object Mapper
         | 
| 48 | 
            -
            version: 1.2.0
         | 
| 49 | 
            -
            name: executable
         | 
| 50 | 
            -
            title: Executable
         | 
| 51 | 
            -
            description: ! 'Think of Executable as a *COM*, a Commandline Object Mapper,
         | 
| 52 | 
            -
             | 
| 53 | 
            -
              in much the same way that ActiveRecord is an ORM,
         | 
| 54 | 
            -
             | 
| 55 | 
            -
              an Object Relational Mapper. A class utilizing Executable
         | 
| 56 | 
            -
             | 
| 57 | 
            -
              can define a complete command line tool using nothing more
         | 
| 58 | 
            -
             | 
| 59 | 
            -
              than Ruby''s own method definitions.'
         | 
| 60 | 
            -
            organization: rubyworks
         | 
| 61 | 
            -
            date: '2012-01-31'
         | 
| 1 | 
            +
            ruby 1.9.3p327 (2012-11-10 revision 37606) [x86_64-linux]
         | 
    
        data/Config.rb
    ADDED
    
    | @@ -0,0 +1,16 @@ | |
| 1 | 
            +
            #!/usr/bin/env ruby
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            # Code coverage.
         | 
| 4 | 
            +
            profile :cov do
         | 
| 5 | 
            +
             | 
| 6 | 
            +
              # Setup QED.
         | 
| 7 | 
            +
              config :qed do
         | 
| 8 | 
            +
                require 'simplecov'
         | 
| 9 | 
            +
                SimpleCov.start do
         | 
| 10 | 
            +
                  coverage_dir 'log/coverage'
         | 
| 11 | 
            +
                  add_filter "/demo/"
         | 
| 12 | 
            +
                  #add_group "RSpec", "lib/assay/rspec.rb"
         | 
| 13 | 
            +
                end
         | 
| 14 | 
            +
              end
         | 
| 15 | 
            +
             | 
| 16 | 
            +
            end
         | 
    
        data/{DEMO.rdoc → DEMO.md}
    RENAMED
    
    | @@ -301,6 +301,114 @@ method will automatically find the manpage and display it. | |
| 301 301 |  | 
| 302 302 |  | 
| 303 303 |  | 
| 304 | 
            +
            = Subclass Example
         | 
| 305 | 
            +
             | 
| 306 | 
            +
            Lets say we have a class that we would like to work with on
         | 
| 307 | 
            +
            the command line, but want to keep the class itself unchanaged
         | 
| 308 | 
            +
            without mixin.
         | 
| 309 | 
            +
             | 
| 310 | 
            +
                class Hello
         | 
| 311 | 
            +
                  attr_accessor :name
         | 
| 312 | 
            +
             | 
| 313 | 
            +
                  def initialize(name="World")
         | 
| 314 | 
            +
                    @name = name
         | 
| 315 | 
            +
                  end
         | 
| 316 | 
            +
             | 
| 317 | 
            +
                  def hello
         | 
| 318 | 
            +
                    @output = "Hello, #{name}!"
         | 
| 319 | 
            +
                  end
         | 
| 320 | 
            +
             | 
| 321 | 
            +
                  def output
         | 
| 322 | 
            +
                    @output
         | 
| 323 | 
            +
                  end
         | 
| 324 | 
            +
                end
         | 
| 325 | 
            +
             | 
| 326 | 
            +
            Rather then including Exectuable in the class directly, we can
         | 
| 327 | 
            +
            create a subclass and use it instead.
         | 
| 328 | 
            +
             | 
| 329 | 
            +
                class HelloCommand < Hello
         | 
| 330 | 
            +
                  include Executable
         | 
| 331 | 
            +
             | 
| 332 | 
            +
                  def call(*args)
         | 
| 333 | 
            +
                    hello
         | 
| 334 | 
            +
                  end
         | 
| 335 | 
            +
                end
         | 
| 336 | 
            +
             | 
| 337 | 
            +
            Now we can execute the command perfectly well.
         | 
| 338 | 
            +
             | 
| 339 | 
            +
                cmd = HelloCommand.execute(['hello', '--name=Fred'])
         | 
| 340 | 
            +
                cmd.output.assert == "Hello, Fred!"
         | 
| 341 | 
            +
             | 
| 342 | 
            +
            And the original class remains undisturbed.
         | 
| 343 | 
            +
             | 
| 344 | 
            +
             | 
| 345 | 
            +
            = README Example
         | 
| 346 | 
            +
             | 
| 347 | 
            +
            This is the example used in the documentation.
         | 
| 348 | 
            +
             | 
| 349 | 
            +
                class Example
         | 
| 350 | 
            +
                  include Executable
         | 
| 351 | 
            +
             | 
| 352 | 
            +
                  attr_switch :quiet
         | 
| 353 | 
            +
             | 
| 354 | 
            +
                  def bread(*args)
         | 
| 355 | 
            +
                    ["bread", quiet?, *args]
         | 
| 356 | 
            +
                  end
         | 
| 357 | 
            +
             | 
| 358 | 
            +
                  def butter(*args)
         | 
| 359 | 
            +
                    ["butter", quiet?, *args]
         | 
| 360 | 
            +
                  end
         | 
| 361 | 
            +
             | 
| 362 | 
            +
                  # Route call to methods.
         | 
| 363 | 
            +
                  def call(name, *args)
         | 
| 364 | 
            +
                    meth = public_method(name)
         | 
| 365 | 
            +
                    meth.call(*args)
         | 
| 366 | 
            +
                  end
         | 
| 367 | 
            +
                end
         | 
| 368 | 
            +
             | 
| 369 | 
            +
            Use a subcommand and an argument.
         | 
| 370 | 
            +
             | 
| 371 | 
            +
                c, a = Example.parse(['butter', 'yum'])
         | 
| 372 | 
            +
                r = c.call(*a)
         | 
| 373 | 
            +
                r.assert == ["butter", nil, "yum"]
         | 
| 374 | 
            +
             | 
| 375 | 
            +
            A subcommand and a boolean option.
         | 
| 376 | 
            +
             | 
| 377 | 
            +
                c, a = Example.parse(['bread', '--quiet'])
         | 
| 378 | 
            +
                r = c.call(*a)
         | 
| 379 | 
            +
                r.assert == ["bread", true]
         | 
| 380 | 
            +
             | 
| 381 | 
            +
             | 
| 382 | 
            +
            == Legacy/Dispath
         | 
| 383 | 
            +
             | 
| 384 | 
            +
            The Dispatch mixin, which is also called Legacy b/c this is how older
         | 
| 385 | 
            +
            version of Executable worked, provides Executable with a `#call` method
         | 
| 386 | 
            +
            that automatically routes the to a method given by the first argument.
         | 
| 387 | 
            +
             | 
| 388 | 
            +
              class DispatchExample < Executable::Command
         | 
| 389 | 
            +
                include Legacy
         | 
| 390 | 
            +
             | 
| 391 | 
            +
                attr :result
         | 
| 392 | 
            +
             | 
| 393 | 
            +
                def foo
         | 
| 394 | 
            +
                  @result = :foo
         | 
| 395 | 
            +
                end
         | 
| 396 | 
            +
             | 
| 397 | 
            +
                def bar
         | 
| 398 | 
            +
                  @result = :bar
         | 
| 399 | 
            +
                end
         | 
| 400 | 
            +
             | 
| 401 | 
            +
              end
         | 
| 402 | 
            +
             | 
| 403 | 
            +
            Now when we invoke the command, the 
         | 
| 404 | 
            +
             | 
| 405 | 
            +
              eg = DispatchExample.run('foo')
         | 
| 406 | 
            +
              eg.result.assert == :foo
         | 
| 407 | 
            +
             | 
| 408 | 
            +
              eg = DispatchExample.run('bar')
         | 
| 409 | 
            +
              eg.result.assert == :bar
         | 
| 410 | 
            +
             | 
| 411 | 
            +
             | 
| 304 412 | 
             
            == OptionParser Example
         | 
| 305 413 |  | 
| 306 414 | 
             
            This example mimics the one given in optparse.rb documentation.
         | 
| @@ -454,114 +562,6 @@ Ensure extension begins with dot and inplace is set to true. | |
| 454 562 | 
             
               cli.options.inplace.assert == true
         | 
| 455 563 |  | 
| 456 564 |  | 
| 457 | 
            -
            = Subclass Example
         | 
| 458 | 
            -
             | 
| 459 | 
            -
            Lets say we have a class that we would like to work with on
         | 
| 460 | 
            -
            the command line, but want to keep the class itself unchanaged
         | 
| 461 | 
            -
            without mixin.
         | 
| 462 | 
            -
             | 
| 463 | 
            -
                class Hello
         | 
| 464 | 
            -
                  attr_accessor :name
         | 
| 465 | 
            -
             | 
| 466 | 
            -
                  def initialize(name="World")
         | 
| 467 | 
            -
                    @name = name
         | 
| 468 | 
            -
                  end
         | 
| 469 | 
            -
             | 
| 470 | 
            -
                  def hello
         | 
| 471 | 
            -
                    @output = "Hello, #{name}!"
         | 
| 472 | 
            -
                  end
         | 
| 473 | 
            -
             | 
| 474 | 
            -
                  def output
         | 
| 475 | 
            -
                    @output
         | 
| 476 | 
            -
                  end
         | 
| 477 | 
            -
                end
         | 
| 478 | 
            -
             | 
| 479 | 
            -
            Rather then including Exectuable in the class directly, we can
         | 
| 480 | 
            -
            create a subclass and use it instead.
         | 
| 481 | 
            -
             | 
| 482 | 
            -
                class HelloCommand < Hello
         | 
| 483 | 
            -
                  include Executable
         | 
| 484 | 
            -
             | 
| 485 | 
            -
                  def call(*args)
         | 
| 486 | 
            -
                    hello
         | 
| 487 | 
            -
                  end
         | 
| 488 | 
            -
                end
         | 
| 489 | 
            -
             | 
| 490 | 
            -
            Now we can execute the command perfectly well.
         | 
| 491 | 
            -
             | 
| 492 | 
            -
                cmd = HelloCommand.execute(['hello', '--name=Fred'])
         | 
| 493 | 
            -
                cmd.output.assert == "Hello, Fred!"
         | 
| 494 | 
            -
             | 
| 495 | 
            -
            And the original class remains undisturbed.
         | 
| 496 | 
            -
             | 
| 497 | 
            -
             | 
| 498 | 
            -
            = README Example
         | 
| 499 | 
            -
             | 
| 500 | 
            -
            This is the example used in the documentation.
         | 
| 501 | 
            -
             | 
| 502 | 
            -
                class Example
         | 
| 503 | 
            -
                  include Executable
         | 
| 504 | 
            -
             | 
| 505 | 
            -
                  attr_switch :quiet
         | 
| 506 | 
            -
             | 
| 507 | 
            -
                  def bread(*args)
         | 
| 508 | 
            -
                    ["bread", quiet?, *args]
         | 
| 509 | 
            -
                  end
         | 
| 510 | 
            -
             | 
| 511 | 
            -
                  def butter(*args)
         | 
| 512 | 
            -
                    ["butter", quiet?, *args]
         | 
| 513 | 
            -
                  end
         | 
| 514 | 
            -
             | 
| 515 | 
            -
                  # Route call to methods.
         | 
| 516 | 
            -
                  def call(name, *args)
         | 
| 517 | 
            -
                    meth = public_method(name)
         | 
| 518 | 
            -
                    meth.call(*args)
         | 
| 519 | 
            -
                  end
         | 
| 520 | 
            -
                end
         | 
| 521 | 
            -
             | 
| 522 | 
            -
            Use a subcommand and an argument.
         | 
| 523 | 
            -
             | 
| 524 | 
            -
                c, a = Example.parse(['butter', 'yum'])
         | 
| 525 | 
            -
                r = c.call(*a)
         | 
| 526 | 
            -
                r.assert == ["butter", nil, "yum"]
         | 
| 527 | 
            -
             | 
| 528 | 
            -
            A subcommand and a boolean option.
         | 
| 529 | 
            -
             | 
| 530 | 
            -
                c, a = Example.parse(['bread', '--quiet'])
         | 
| 531 | 
            -
                r = c.call(*a)
         | 
| 532 | 
            -
                r.assert == ["bread", true]
         | 
| 533 | 
            -
             | 
| 534 | 
            -
             | 
| 535 | 
            -
            == Legacy/Dispath
         | 
| 536 | 
            -
             | 
| 537 | 
            -
            The Dispatch mixin, which is also called Legacy b/c this is how older
         | 
| 538 | 
            -
            version of Executable worked, provides Executable with a `#call` method
         | 
| 539 | 
            -
            that automatically routes the to a method given by the first argument.
         | 
| 540 | 
            -
             | 
| 541 | 
            -
              class DispatchExample < Executable::Command
         | 
| 542 | 
            -
                include Legacy
         | 
| 543 | 
            -
             | 
| 544 | 
            -
                attr :result
         | 
| 545 | 
            -
             | 
| 546 | 
            -
                def foo
         | 
| 547 | 
            -
                  @result = :foo
         | 
| 548 | 
            -
                end
         | 
| 549 | 
            -
             | 
| 550 | 
            -
                def bar
         | 
| 551 | 
            -
                  @result = :bar
         | 
| 552 | 
            -
                end
         | 
| 553 | 
            -
             | 
| 554 | 
            -
              end
         | 
| 555 | 
            -
             | 
| 556 | 
            -
            Now when we invoke the command, the 
         | 
| 557 | 
            -
             | 
| 558 | 
            -
              eg = DispatchExample.run('foo')
         | 
| 559 | 
            -
              eg.result.assert == :foo
         | 
| 560 | 
            -
             | 
| 561 | 
            -
              eg = DispatchExample.run('bar')
         | 
| 562 | 
            -
              eg.result.assert == :bar
         | 
| 563 | 
            -
             | 
| 564 | 
            -
             | 
| 565 565 |  | 
| 566 566 |  | 
| 567 567 |  | 
    
        data/{HISTORY.rdoc → HISTORY.md}
    RENAMED
    
    | @@ -1,6 +1,18 @@ | |
| 1 | 
            -
             | 
| 1 | 
            +
            # RELEASE HISTORY
         | 
| 2 2 |  | 
| 3 | 
            -
             | 
| 3 | 
            +
            ## 1.2.1 / 2012-12-19
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            This release imporves the help output and manpage lookup
         | 
| 6 | 
            +
            as well as a few helpful additions the the API.
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            Changes:
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            * Improve manpage lookup.
         | 
| 11 | 
            +
            * Improve overall help output.
         | 
| 12 | 
            +
            * Add alias_switch and alias_accessor helpers.
         | 
| 13 | 
            +
             | 
| 14 | 
            +
             | 
| 15 | 
            +
            ## 1.2.0 / 2012-01-31
         | 
| 4 16 |  | 
| 5 17 | 
             
            Version 1.2.0 is complete rewrite of Executable. Actually it was decided that
         | 
| 6 18 | 
             
            the old design was too simplistic in it design concept, so another library
         | 
| @@ -20,7 +32,7 @@ Changes: | |
| 20 32 | 
             
            * Supports manpage look-up and display.
         | 
| 21 33 |  | 
| 22 34 |  | 
| 23 | 
            -
             | 
| 35 | 
            +
            ## 1.1.0 / 2011-04-21
         | 
| 24 36 |  | 
| 25 37 | 
             
            This release simplifies Executable, removing the #option_missing method
         | 
| 26 38 | 
             
            and using the standard #method_missing callback instead. Along with this
         | 
| @@ -44,7 +56,7 @@ Changes: | |
| 44 56 | 
             
              * The #method_missing callback takes the value of the option being set.
         | 
| 45 57 |  | 
| 46 58 |  | 
| 47 | 
            -
             | 
| 59 | 
            +
            ## 1.0.0 / 2011-04-15
         | 
| 48 60 |  | 
| 49 61 | 
             
            This is the initialize release of Executable (as a stand alone project).
         | 
| 50 62 | 
             
            Executable is a mixin that can turn any class into an commandline interface.
         | 
    
        data/LICENSE.txt
    ADDED
    
    | @@ -0,0 +1,22 @@ | |
| 1 | 
            +
            BSD-2-Clause License
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            Redistribution and use in source and binary forms, with or without
         | 
| 4 | 
            +
            modification, are permitted provided that the following conditions are met:
         | 
| 5 | 
            +
             | 
| 6 | 
            +
               1. Redistributions of source code must retain the above copyright notice,
         | 
| 7 | 
            +
                  this list of conditions and the following disclaimer.
         | 
| 8 | 
            +
             | 
| 9 | 
            +
               2. Redistributions in binary form must reproduce the above copyright
         | 
| 10 | 
            +
                  notice, this list of conditions and the following disclaimer in the
         | 
| 11 | 
            +
                  documentation and/or other materials provided with the distribution.
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
         | 
| 14 | 
            +
            INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
         | 
| 15 | 
            +
            FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
         | 
| 16 | 
            +
            COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
         | 
| 17 | 
            +
            INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
         | 
| 18 | 
            +
            NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR  SERVICES; LOSS OF USE,
         | 
| 19 | 
            +
            DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
         | 
| 20 | 
            +
            OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
         | 
| 21 | 
            +
            NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
         | 
| 22 | 
            +
            EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
         | 
    
        data/{README.rdoc → README.md}
    RENAMED
    
    | @@ -1,14 +1,10 @@ | |
| 1 | 
            -
             | 
| 1 | 
            +
            [Website](http://rubyworks.github.com/executable) |
         | 
| 2 | 
            +
            [Report Issue](http://github.com/rubyworks/executable/features) |
         | 
| 3 | 
            +
            [Source Code](http://github.com/rubyworks/executable)
         | 
| 4 | 
            +
            ( [](http://travis-ci.org/rubyworks/indexer) )
         | 
| 2 5 |  | 
| 3 | 
            -
            {Website}[http://rubyworks.github.com/executable] |
         | 
| 4 | 
            -
            {Source Code}[http://github.com/rubyworks/executable] |
         | 
| 5 | 
            -
            {Report Issue}[http://github.com/rubyworks/executable/features] |
         | 
| 6 | 
            -
            {#rubyworks}[irc://irc.freenode.org/rubyworks]
         | 
| 7 6 |  | 
| 8 | 
            -
             | 
| 9 | 
            -
             | 
| 10 | 
            -
             | 
| 11 | 
            -
            == DESCRIPTION
         | 
| 7 | 
            +
            # Executable
         | 
| 12 8 |  | 
| 13 9 | 
             
            Executable is to the commandline, what ActiveRecord is the database. 
         | 
| 14 10 | 
             
            You can think of Executable as a *COM*, a Command-line Object Mapper,
         | 
| @@ -18,7 +14,7 @@ a complete command line tool using nothing more than Ruby's standard | |
| 18 14 | 
             
            syntax. No special DSL is required. 
         | 
| 19 15 |  | 
| 20 16 |  | 
| 21 | 
            -
             | 
| 17 | 
            +
            ## Features
         | 
| 22 18 |  | 
| 23 19 | 
             
            * Easy to use, just mixin or subclass.
         | 
| 24 20 | 
             
            * Define #call to control the command procedure.
         | 
| @@ -28,18 +24,13 @@ syntax. No special DSL is required. | |
| 28 24 | 
             
            * Generate help in plain text or markdown.
         | 
| 29 25 |  | 
| 30 26 |  | 
| 31 | 
            -
             | 
| 27 | 
            +
            ## Limitations
         | 
| 32 28 |  | 
| 33 29 | 
             
            * Ruby 1.9+ only.
         | 
| 34 30 | 
             
            * Help doesn't handle aliases well (yet).
         | 
| 35 31 |  | 
| 36 32 |  | 
| 37 | 
            -
             | 
| 38 | 
            -
             | 
| 39 | 
            -
            Please see HISTORY.rdoc file.
         | 
| 40 | 
            -
             | 
| 41 | 
            -
             | 
| 42 | 
            -
            == SYNOPSIS
         | 
| 33 | 
            +
            ## Instructions
         | 
| 43 34 |  | 
| 44 35 | 
             
            CLIs can be built by using a Executable as a mixin, or by subclassing 
         | 
| 45 36 | 
             
            `Executable::Command`. Methods seemlessly handle command-line options.
         | 
| @@ -48,13 +39,14 @@ methods (those ending in '?') modify them to be boolean switches. | |
| 48 39 |  | 
| 49 40 | 
             
            For example, here is a simple "Hello, World!" commandline tool.
         | 
| 50 41 |  | 
| 42 | 
            +
            ```ruby
         | 
| 51 43 | 
             
                require 'executable'
         | 
| 52 44 |  | 
| 53 45 | 
             
                class HelloCommand
         | 
| 54 46 | 
             
                  include Executable
         | 
| 55 47 |  | 
| 56 48 | 
             
                  # Say it in uppercase?
         | 
| 57 | 
            -
                  def  | 
| 49 | 
            +
                  def loud=(bool)
         | 
| 58 50 | 
             
                    @loud = bool
         | 
| 59 51 | 
             
                  end
         | 
| 60 52 |  | 
| @@ -78,17 +70,21 @@ For example, here is a simple "Hello, World!" commandline tool. | |
| 78 70 | 
             
                    puts str
         | 
| 79 71 | 
             
                  end
         | 
| 80 72 | 
             
                end
         | 
| 73 | 
            +
            ```
         | 
| 81 74 |  | 
| 82 75 | 
             
            To make the command available on the command line, add an executable
         | 
| 83 | 
            -
            to your project  | 
| 76 | 
            +
            to your project calling the #execute or #run methods.
         | 
| 84 77 |  | 
| 78 | 
            +
            ```ruby
         | 
| 85 79 | 
             
                #!usr/bin/env ruby
         | 
| 86 80 | 
             
                require 'hello.rb'
         | 
| 87 81 | 
             
                HelloCommand.run
         | 
| 82 | 
            +
            ```
         | 
| 88 83 |  | 
| 89 84 | 
             
            If we named this file `hello`, set its execute flag and made it available
         | 
| 90 85 | 
             
            on our systems $PATH, then:
         | 
| 91 86 |  | 
| 87 | 
            +
            ```
         | 
| 92 88 | 
             
                $ hello
         | 
| 93 89 | 
             
                Hello, World!
         | 
| 94 90 |  | 
| @@ -97,9 +93,11 @@ on our systems $PATH, then: | |
| 97 93 |  | 
| 98 94 | 
             
                $ hello --loud John
         | 
| 99 95 | 
             
                HELLO, JOHN!
         | 
| 96 | 
            +
            ```
         | 
| 100 97 |  | 
| 101 98 | 
             
            Executable can also generate help text for commands.
         | 
| 102 99 |  | 
| 100 | 
            +
            ```
         | 
| 103 101 | 
             
                $ hello --help
         | 
| 104 102 | 
             
                USAGE: hello [options]
         | 
| 105 103 |  | 
| @@ -107,38 +105,55 @@ Executable can also generate help text for commands. | |
| 107 105 |  | 
| 108 106 | 
             
                --loud      Say it in uppercase?
         | 
| 109 107 | 
             
                --help      Show this message
         | 
| 108 | 
            +
            ```
         | 
| 110 109 |  | 
| 111 110 | 
             
            If you look back at the class definition you can see it's pulling
         | 
| 112 111 | 
             
            comments from the source to provide descriptions. It pulls the 
         | 
| 113 | 
            -
            description the command itself from the `#call` method.
         | 
| 112 | 
            +
            description for the command itself from the `#call` method.
         | 
| 114 113 |  | 
| 115 114 | 
             
            Basic help like this is fine for personal tools, but for public facing
         | 
| 116 115 | 
             
            production applications it is desirable to utilize manpages. To this end,
         | 
| 117 116 | 
             
            Executable provides Markdown formatted help as well. We can access this,
         | 
| 118 117 | 
             
            for example, via `HelloCommand.help.markdown`. The idea with this is that
         | 
| 119 118 | 
             
            we can save the output to `man/hello.ronn` or copy it the top of our `bin/`
         | 
| 120 | 
            -
            file, edit it to perfection and then use tools such a  | 
| 121 | 
            -
             | 
| 119 | 
            +
            file, edit it to perfection and then use tools such a [ronn](https://github.com/rtomayko/ronn),
         | 
| 120 | 
            +
            [binman](https://github.com/sunaku/binman) or [md2man](https://github.com/sunaku/md2man)
         | 
| 122 121 | 
             
            to generate the manpages. What's particularly cool about Executable,
         | 
| 123 122 | 
             
            is that once we have a manpage in the standard `man/` location in our project,
         | 
| 124 123 | 
             
            the `#show_help` method will use it instead of the plain text.
         | 
| 125 124 |  | 
| 126 | 
            -
            For a more detail example see  | 
| 127 | 
            -
            and  | 
| 125 | 
            +
            For a more detail example see [QED](demo.html)
         | 
| 126 | 
            +
            and [API](http://rubydoc.info/gems/executable/frames) documentation.
         | 
| 128 127 |  | 
| 129 128 |  | 
| 130 | 
            -
             | 
| 129 | 
            +
            ## Installation
         | 
| 131 130 |  | 
| 132 131 | 
             
            Install with RubyGems in the usual fashion.
         | 
| 133 132 |  | 
| 133 | 
            +
            ```
         | 
| 134 134 | 
             
                $ gem install executable
         | 
| 135 | 
            +
            ```
         | 
| 136 | 
            +
             | 
| 137 | 
            +
            ## CONTRIBUTING
         | 
| 138 | 
            +
             | 
| 139 | 
            +
            Executable is a Rubyworks project. As such we largely use in house tools
         | 
| 140 | 
            +
            for development.
         | 
| 141 | 
            +
             | 
| 142 | 
            +
            ### Testing
         | 
| 143 | 
            +
             | 
| 144 | 
            +
            QED and Microtest are being used for this project.
         | 
| 145 | 
            +
             | 
| 146 | 
            +
            ### Getting In Touch
         | 
| 147 | 
            +
             | 
| 148 | 
            +
            * [#rubyworks](irc://irc.freenode.org/rubyworks)
         | 
| 135 149 |  | 
| 136 150 |  | 
| 137 | 
            -
             | 
| 151 | 
            +
            ## Copyrights
         | 
| 138 152 |  | 
| 139 | 
            -
             | 
| 153 | 
            +
            Executable is copyrighted open source software.
         | 
| 140 154 |  | 
| 141 | 
            -
             | 
| 155 | 
            +
                Copyright (c) 2008 Rubyworks (BSD-2-Clause License)
         | 
| 142 156 |  | 
| 143 | 
            -
             | 
| 157 | 
            +
            It can be distributed and modified in accordance with the *BSD-2-Clause* license.
         | 
| 144 158 |  | 
| 159 | 
            +
            See LICENSE.txt for details.
         | 
| @@ -1,4 +1,4 @@ | |
| 1 | 
            -
             | 
| 1 | 
            +
            ## Command Help
         | 
| 2 2 |  | 
| 3 3 | 
             
            Executable Commands can generate help output. It does this by extracting
         | 
| 4 4 | 
             
            the commenst associated with the option methods. A description of the
         | 
| @@ -62,7 +62,7 @@ The help output, | |
| 62 62 |  | 
| 63 63 | 
             
            should be clearly laid out as follows:
         | 
| 64 64 |  | 
| 65 | 
            -
                Usage:  | 
| 65 | 
            +
                Usage: my c1 [options...] [subcommand]
         | 
| 66 66 |  | 
| 67 67 | 
             
                This does c1.
         | 
| 68 68 |  | 
| @@ -81,12 +81,12 @@ The help feature can also output ronn-style markdown, | |
| 81 81 |  | 
| 82 82 | 
             
            should be clearly laid out as follows:
         | 
| 83 83 |  | 
| 84 | 
            -
                 | 
| 85 | 
            -
                 | 
| 84 | 
            +
                my-c1(1) - This does c1.
         | 
| 85 | 
            +
                ========================
         | 
| 86 86 |  | 
| 87 87 | 
             
                ## SYNOPSIS
         | 
| 88 88 |  | 
| 89 | 
            -
                ` | 
| 89 | 
            +
                `my c1` [options...] [subcommand]
         | 
| 90 90 |  | 
| 91 91 | 
             
                ## DESCRIPTION
         | 
| 92 92 |  | 
| @@ -1,14 +1,14 @@ | |
| 1 | 
            -
             | 
| 1 | 
            +
            ### Manpages
         | 
| 2 2 |  | 
| 3 3 | 
             
            If a man page is available for a given command using the #show_help
         | 
| 4 4 | 
             
            method will automatically find the manpage and display it.
         | 
| 5 5 |  | 
| 6 6 | 
             
                sample = File.dirname(__FILE__) + '/samples'
         | 
| 7 7 |  | 
| 8 | 
            -
                 | 
| 9 | 
            -
             | 
| 10 | 
            -
                manpage = Hello.cli.manpage
         | 
| 8 | 
            +
                manpage = `ruby #{sample}/bin/hello --manpage`.strip
         | 
| 11 9 |  | 
| 12 10 | 
             
                manpage.assert == sample + '/man/hello.1'
         | 
| 13 11 |  | 
| 12 | 
            +
            Note: Would rather use #load for this, but without a `.rb` on
         | 
| 13 | 
            +
            the `hello` file, it doesn't seem possible.
         | 
| 14 14 |  | 
    
        data/demo/samples/bin/hello
    CHANGED
    
    | @@ -1,10 +1,10 @@ | |
| 1 | 
            -
            #!/usr/bin/env
         | 
| 1 | 
            +
            #!/usr/bin/env ruby
         | 
| 2 2 |  | 
| 3 3 | 
             
            require 'executable'
         | 
| 4 4 |  | 
| 5 5 | 
             
            class Hello < Executable::Command
         | 
| 6 6 | 
             
              # Say it in uppercase?
         | 
| 7 | 
            -
              def  | 
| 7 | 
            +
              def loud=(bool)
         | 
| 8 8 | 
             
                @loud = bool
         | 
| 9 9 | 
             
              end
         | 
| 10 10 |  | 
| @@ -27,5 +27,12 @@ class Hello < Executable::Command | |
| 27 27 | 
             
                str  = str.upcase if loud?
         | 
| 28 28 | 
             
                puts str
         | 
| 29 29 | 
             
              end
         | 
| 30 | 
            +
             | 
| 31 | 
            +
              # Where's the manpage?
         | 
| 32 | 
            +
              def manpage!
         | 
| 33 | 
            +
                puts cli.manpage
         | 
| 34 | 
            +
                exit
         | 
| 35 | 
            +
              end
         | 
| 30 36 | 
             
            end
         | 
| 31 37 |  | 
| 38 | 
            +
            Hello.execute
         | 
    
        data/lib/executable.rb
    CHANGED
    
    | @@ -22,7 +22,7 @@ module Executable | |
| 22 22 |  | 
| 23 23 | 
             
              #
         | 
| 24 24 | 
             
              # Default initializer, simply takes a hash of settings
         | 
| 25 | 
            -
              # to set attributes via writer methods. Not  | 
| 25 | 
            +
              # to set attributes via writer methods. Not existant
         | 
| 26 26 | 
             
              # attributes are simply ignored.
         | 
| 27 27 | 
             
              #
         | 
| 28 28 | 
             
              def initialize(settings={})
         | 
    
        data/lib/executable.yml
    ADDED
    
    | @@ -0,0 +1,71 @@ | |
| 1 | 
            +
            ---
         | 
| 2 | 
            +
            type: ruby
         | 
| 3 | 
            +
            revision: 2013
         | 
| 4 | 
            +
            sources:
         | 
| 5 | 
            +
            - var
         | 
| 6 | 
            +
            authors:
         | 
| 7 | 
            +
            - name: 7rans
         | 
| 8 | 
            +
              email: transfire@gmail.com
         | 
| 9 | 
            +
            organizations: []
         | 
| 10 | 
            +
            requirements:
         | 
| 11 | 
            +
            - groups:
         | 
| 12 | 
            +
              - test
         | 
| 13 | 
            +
              development: true
         | 
| 14 | 
            +
              name: qed
         | 
| 15 | 
            +
            - groups:
         | 
| 16 | 
            +
              - test
         | 
| 17 | 
            +
              development: true
         | 
| 18 | 
            +
              name: ae
         | 
| 19 | 
            +
            - groups:
         | 
| 20 | 
            +
              - build
         | 
| 21 | 
            +
              development: true
         | 
| 22 | 
            +
              name: detroit
         | 
| 23 | 
            +
            - groups:
         | 
| 24 | 
            +
              - build
         | 
| 25 | 
            +
              development: true
         | 
| 26 | 
            +
              name: simplecov
         | 
| 27 | 
            +
            conflicts: []
         | 
| 28 | 
            +
            alternatives: []
         | 
| 29 | 
            +
            resources:
         | 
| 30 | 
            +
            - type: home
         | 
| 31 | 
            +
              uri: http://rubyworks.github.com/executable
         | 
| 32 | 
            +
              label: Homepage
         | 
| 33 | 
            +
            - type: code
         | 
| 34 | 
            +
              uri: http://github.com/rubyworks/executable
         | 
| 35 | 
            +
              label: Source Code
         | 
| 36 | 
            +
            - type: bugs
         | 
| 37 | 
            +
              uri: http://github.com/rubyworks/executable/issues
         | 
| 38 | 
            +
              label: Issue Tracker
         | 
| 39 | 
            +
            - type: mail
         | 
| 40 | 
            +
              uri: http://groups.google.com/rubyworks-mailinglist
         | 
| 41 | 
            +
              label: Mailing List
         | 
| 42 | 
            +
            - type: chat
         | 
| 43 | 
            +
              uri: irc://chat.us.freenode.net#rubyworks
         | 
| 44 | 
            +
              label: IRC Channel
         | 
| 45 | 
            +
            repositories:
         | 
| 46 | 
            +
            - name: upstream
         | 
| 47 | 
            +
              scm: git
         | 
| 48 | 
            +
              uri: git://github.com/rubyworks/executable.git
         | 
| 49 | 
            +
            categories: []
         | 
| 50 | 
            +
            paths:
         | 
| 51 | 
            +
              load:
         | 
| 52 | 
            +
              - lib
         | 
| 53 | 
            +
            copyrights:
         | 
| 54 | 
            +
            - holder: Rubyworks
         | 
| 55 | 
            +
              year: '2008'
         | 
| 56 | 
            +
              license: BSD-2-Clause
         | 
| 57 | 
            +
            created: '2008-08-08'
         | 
| 58 | 
            +
            summary: Commandline Object Mapper
         | 
| 59 | 
            +
            version: 1.2.1
         | 
| 60 | 
            +
            name: executable
         | 
| 61 | 
            +
            title: Executable
         | 
| 62 | 
            +
            description: ! 'Think of Executable as a *COM*, a Commandline Object Mapper,
         | 
| 63 | 
            +
             | 
| 64 | 
            +
              in much the same way that ActiveRecord is an ORM,
         | 
| 65 | 
            +
             | 
| 66 | 
            +
              an Object Relational Mapper. A class utilizing Executable
         | 
| 67 | 
            +
             | 
| 68 | 
            +
              can define a complete command line tool using nothing more
         | 
| 69 | 
            +
             | 
| 70 | 
            +
              than Ruby''s own method definitions.'
         | 
| 71 | 
            +
            date: '2012-12-18'
         | 
    
        data/lib/executable/dispatch.rb
    CHANGED
    
    | @@ -2,7 +2,7 @@ module Executable | |
| 2 2 |  | 
| 3 3 | 
             
              # Variation of Executable which provides basic compatibility with
         | 
| 4 4 | 
             
              # previous versions of Executable. It provides a call method that
         | 
| 5 | 
            -
              # automatically dispatches to  | 
| 5 | 
            +
              # automatically dispatches to public methods.
         | 
| 6 6 | 
             
              #
         | 
| 7 7 | 
             
              # Among other uses, Dispatch can be useful for dropping into any class
         | 
| 8 8 | 
             
              # as a quick and dirty way to work with it on the command line.
         | 
    
        data/lib/executable/domain.rb
    CHANGED
    
    | @@ -3,6 +3,28 @@ module Executable | |
| 3 3 | 
             
              #
         | 
| 4 4 | 
             
              module Domain
         | 
| 5 5 |  | 
| 6 | 
            +
                #
         | 
| 7 | 
            +
                def usage_name
         | 
| 8 | 
            +
                  list = []
         | 
| 9 | 
            +
                  ancestors.each do |ancestor|
         | 
| 10 | 
            +
                    break if Executable == ancestor
         | 
| 11 | 
            +
                    list.unshift calculate_command_name(ancestor).to_s.strip
         | 
| 12 | 
            +
                  end
         | 
| 13 | 
            +
                  list.reject{|n| n.empty?}.join(" ")
         | 
| 14 | 
            +
                end
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                #
         | 
| 17 | 
            +
                def calculate_command_name(ancestor)
         | 
| 18 | 
            +
                  if ancestor.methods(false).include?(:command_name)
         | 
| 19 | 
            +
                    command_name.to_s
         | 
| 20 | 
            +
                  else
         | 
| 21 | 
            +
                    cname = ancestor.name.sub(/\#\<.*?\>\:\:/,'').split('::').last.downcase
         | 
| 22 | 
            +
                    cname.chomp('command').chomp('cli')
         | 
| 23 | 
            +
                  end
         | 
| 24 | 
            +
                end
         | 
| 25 | 
            +
             | 
| 26 | 
            +
                private :calculate_command_name
         | 
| 27 | 
            +
             | 
| 6 28 | 
             
                #
         | 
| 7 29 | 
             
                # Helper method for creating switch attributes.
         | 
| 8 30 | 
             
                #
         | 
| @@ -26,6 +48,22 @@ module Executable | |
| 26 48 | 
             
                  }
         | 
| 27 49 | 
             
                end
         | 
| 28 50 |  | 
| 51 | 
            +
                #
         | 
| 52 | 
            +
                # 
         | 
| 53 | 
            +
                #
         | 
| 54 | 
            +
                def alias_switch(name, origin)
         | 
| 55 | 
            +
                  alias_method "#{name}=", "#{origin}="
         | 
| 56 | 
            +
                  alias_method "#{name}?", "#{origin}?"
         | 
| 57 | 
            +
                end
         | 
| 58 | 
            +
             | 
| 59 | 
            +
                #
         | 
| 60 | 
            +
                #
         | 
| 61 | 
            +
                #
         | 
| 62 | 
            +
                def alias_accessor(name, origin)
         | 
| 63 | 
            +
                  alias_method "#{name}=", "#{origin}="
         | 
| 64 | 
            +
                  alias_method "#{name}",  "#{origin}"
         | 
| 65 | 
            +
                end
         | 
| 66 | 
            +
             | 
| 29 67 | 
             
                #
         | 
| 30 68 | 
             
                # Inspection method. This must be redefined b/c #to_s is overridden.
         | 
| 31 69 | 
             
                #
         | 
| @@ -93,7 +131,9 @@ module Executable | |
| 93 131 | 
             
                    consts.inject({}) do |h, c|
         | 
| 94 132 | 
             
                      c = const_get(c)
         | 
| 95 133 | 
             
                      if Class === c && Executable > c
         | 
| 96 | 
            -
                        n = c.name.split('::').last | 
| 134 | 
            +
                        n = c.name.split('::').last
         | 
| 135 | 
            +
                        n = n.chomp('Command').chomp('CLI')
         | 
| 136 | 
            +
                        n = n.downcase
         | 
| 97 137 | 
             
                        h[n] = c
         | 
| 98 138 | 
             
                      end
         | 
| 99 139 | 
             
                      h
         | 
    
        data/lib/executable/help.rb
    CHANGED
    
    | @@ -63,10 +63,7 @@ module Executable | |
| 63 63 | 
             
                # @method name(text=nil)
         | 
| 64 64 | 
             
                #
         | 
| 65 65 | 
             
                section(:name) do
         | 
| 66 | 
            -
                   | 
| 67 | 
            -
                  str.chomp!('command')
         | 
| 68 | 
            -
                  str.chomp!('cli')
         | 
| 69 | 
            -
                  str
         | 
| 66 | 
            +
                  cli_class.usage_name
         | 
| 70 67 | 
             
                end
         | 
| 71 68 |  | 
| 72 69 | 
             
                #
         | 
| @@ -122,7 +119,7 @@ module Executable | |
| 122 119 | 
             
                #
         | 
| 123 120 | 
             
                # Show help.
         | 
| 124 121 | 
             
                #
         | 
| 125 | 
            -
                # @todo man-pages will probably fail on Windows
         | 
| 122 | 
            +
                # @todo man-pages will probably fail on Windows.
         | 
| 126 123 | 
             
                #
         | 
| 127 124 | 
             
                def show_help(hint=nil)
         | 
| 128 125 | 
             
                  if file = manpage(hint)
         | 
| @@ -132,6 +129,9 @@ module Executable | |
| 132 129 | 
             
                  end
         | 
| 133 130 | 
             
                end
         | 
| 134 131 |  | 
| 132 | 
            +
                #
         | 
| 133 | 
            +
                alias :show :show_help
         | 
| 134 | 
            +
             | 
| 135 135 | 
             
                #
         | 
| 136 136 | 
             
                def show_manpage(file)
         | 
| 137 137 | 
             
                  #exec "man #{file}"
         | 
| @@ -155,8 +155,10 @@ module Executable | |
| 155 155 | 
             
                      dir = File.dirname(file)
         | 
| 156 156 | 
             
                    end
         | 
| 157 157 |  | 
| 158 | 
            +
                    man_name = name.gsub(/\s+/, '-') + '.1'
         | 
| 159 | 
            +
             | 
| 158 160 | 
             
                    if dir
         | 
| 159 | 
            -
                      glob = "man/{man1/,}#{ | 
| 161 | 
            +
                      glob = "man/{man1/,}#{man_name}"
         | 
| 160 162 | 
             
                      lookup(glob, dir)
         | 
| 161 163 | 
             
                    else
         | 
| 162 164 | 
             
                      nil
         | 
| @@ -216,10 +218,11 @@ module Executable | |
| 216 218 | 
             
                def markdown
         | 
| 217 219 | 
             
                  commands = text_subcommands
         | 
| 218 220 | 
             
                  options  = text_options
         | 
| 221 | 
            +
                  dashname = name.sub(/\s+/, '-')
         | 
| 219 222 |  | 
| 220 223 | 
             
                  s = []
         | 
| 221 224 |  | 
| 222 | 
            -
                  h = "#{ | 
| 225 | 
            +
                  h = "#{dashname}(1) - #{text_description}"
         | 
| 223 226 | 
             
                  s << h + "\n" + ("=" * h.size)
         | 
| 224 227 |  | 
| 225 228 | 
             
                  s << "## SYNOPSIS"
         | 
    
        data/lib/executable/version.rb
    CHANGED
    
    | @@ -4,20 +4,17 @@ module Exectuable | |
| 4 4 | 
             
              DIRECTORY = File.dirname(__FILE__)
         | 
| 5 5 |  | 
| 6 6 | 
             
              #
         | 
| 7 | 
            -
              def self. | 
| 8 | 
            -
                 | 
| 9 | 
            -
                  require 'yaml'
         | 
| 10 | 
            -
                  YAML.load(File.new(DIRECTORY + '/version.yml'))
         | 
| 11 | 
            -
                )
         | 
| 7 | 
            +
              def self.const_missing(name)
         | 
| 8 | 
            +
                index[name.to_s.downcase] || super(name)
         | 
| 12 9 | 
             
              end
         | 
| 13 10 |  | 
| 14 11 | 
             
              #
         | 
| 15 | 
            -
              def self. | 
| 16 | 
            -
                 | 
| 12 | 
            +
              def self.index
         | 
| 13 | 
            +
                @index ||= (
         | 
| 14 | 
            +
                  require 'yaml'
         | 
| 15 | 
            +
                  YAML.load(File.new(DIRECTORY + '/../executable.yml'))
         | 
| 16 | 
            +
                )
         | 
| 17 17 | 
             
              end
         | 
| 18 18 |  | 
| 19 | 
            -
              # because Ruby 1.8~ gets in the way
         | 
| 20 | 
            -
              remove_const(:VERSION) if const_defined?(:VERSION)
         | 
| 21 | 
            -
             | 
| 22 19 | 
             
            end
         | 
| 23 20 |  | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: executable
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 1.2. | 
| 4 | 
            +
              version: 1.2.1
         | 
| 5 5 | 
             
              prerelease: 
         | 
| 6 6 | 
             
            platform: ruby
         | 
| 7 7 | 
             
            authors:
         | 
| @@ -9,11 +9,11 @@ authors: | |
| 9 9 | 
             
            autorequire: 
         | 
| 10 10 | 
             
            bindir: bin
         | 
| 11 11 | 
             
            cert_chain: []
         | 
| 12 | 
            -
            date: 2012- | 
| 12 | 
            +
            date: 2012-12-19 00:00:00.000000000 Z
         | 
| 13 13 | 
             
            dependencies:
         | 
| 14 14 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 15 15 | 
             
              name: qed
         | 
| 16 | 
            -
              requirement:  | 
| 16 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 17 17 | 
             
                none: false
         | 
| 18 18 | 
             
                requirements:
         | 
| 19 19 | 
             
                - - ! '>='
         | 
| @@ -21,10 +21,15 @@ dependencies: | |
| 21 21 | 
             
                    version: '0'
         | 
| 22 22 | 
             
              type: :development
         | 
| 23 23 | 
             
              prerelease: false
         | 
| 24 | 
            -
              version_requirements:  | 
| 24 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 25 | 
            +
                none: false
         | 
| 26 | 
            +
                requirements:
         | 
| 27 | 
            +
                - - ! '>='
         | 
| 28 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 29 | 
            +
                    version: '0'
         | 
| 25 30 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 26 31 | 
             
              name: ae
         | 
| 27 | 
            -
              requirement:  | 
| 32 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 28 33 | 
             
                none: false
         | 
| 29 34 | 
             
                requirements:
         | 
| 30 35 | 
             
                - - ! '>='
         | 
| @@ -32,10 +37,15 @@ dependencies: | |
| 32 37 | 
             
                    version: '0'
         | 
| 33 38 | 
             
              type: :development
         | 
| 34 39 | 
             
              prerelease: false
         | 
| 35 | 
            -
              version_requirements:  | 
| 40 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 41 | 
            +
                none: false
         | 
| 42 | 
            +
                requirements:
         | 
| 43 | 
            +
                - - ! '>='
         | 
| 44 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 45 | 
            +
                    version: '0'
         | 
| 36 46 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 37 47 | 
             
              name: detroit
         | 
| 38 | 
            -
              requirement:  | 
| 48 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 39 49 | 
             
                none: false
         | 
| 40 50 | 
             
                requirements:
         | 
| 41 51 | 
             
                - - ! '>='
         | 
| @@ -43,10 +53,15 @@ dependencies: | |
| 43 53 | 
             
                    version: '0'
         | 
| 44 54 | 
             
              type: :development
         | 
| 45 55 | 
             
              prerelease: false
         | 
| 46 | 
            -
              version_requirements:  | 
| 56 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 57 | 
            +
                none: false
         | 
| 58 | 
            +
                requirements:
         | 
| 59 | 
            +
                - - ! '>='
         | 
| 60 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 61 | 
            +
                    version: '0'
         | 
| 47 62 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 48 63 | 
             
              name: simplecov
         | 
| 49 | 
            -
              requirement:  | 
| 64 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 50 65 | 
             
                none: false
         | 
| 51 66 | 
             
                requirements:
         | 
| 52 67 | 
             
                - - ! '>='
         | 
| @@ -54,7 +69,12 @@ dependencies: | |
| 54 69 | 
             
                    version: '0'
         | 
| 55 70 | 
             
              type: :development
         | 
| 56 71 | 
             
              prerelease: false
         | 
| 57 | 
            -
              version_requirements:  | 
| 72 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 73 | 
            +
                none: false
         | 
| 74 | 
            +
                requirements:
         | 
| 75 | 
            +
                - - ! '>='
         | 
| 76 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 77 | 
            +
                    version: '0'
         | 
| 58 78 | 
             
            description: ! 'Think of Executable as a *COM*, a Commandline Object Mapper,
         | 
| 59 79 |  | 
| 60 80 | 
             
              in much the same way that ActiveRecord is an ORM,
         | 
| @@ -69,22 +89,23 @@ email: | |
| 69 89 | 
             
            executables: []
         | 
| 70 90 | 
             
            extensions: []
         | 
| 71 91 | 
             
            extra_rdoc_files:
         | 
| 72 | 
            -
            -  | 
| 73 | 
            -
            -  | 
| 74 | 
            -
            - README. | 
| 75 | 
            -
            -  | 
| 92 | 
            +
            - LICENSE.txt
         | 
| 93 | 
            +
            - HISTORY.md
         | 
| 94 | 
            +
            - README.md
         | 
| 95 | 
            +
            - DEMO.md
         | 
| 76 96 | 
             
            files:
         | 
| 97 | 
            +
            - .index
         | 
| 77 98 | 
             
            - .ruby
         | 
| 78 99 | 
             
            - .yardopts
         | 
| 79 | 
            -
            - demo/00_introduction. | 
| 80 | 
            -
            - demo/01_single_command. | 
| 81 | 
            -
            - demo/02_multiple_commands. | 
| 82 | 
            -
            - demo/03_help_text. | 
| 83 | 
            -
            - demo/04_manpage. | 
| 84 | 
            -
            - demo/ | 
| 85 | 
            -
            - demo/ | 
| 86 | 
            -
            - demo/ | 
| 87 | 
            -
            - demo/ | 
| 100 | 
            +
            - demo/00_introduction.md
         | 
| 101 | 
            +
            - demo/01_single_command.md
         | 
| 102 | 
            +
            - demo/02_multiple_commands.md
         | 
| 103 | 
            +
            - demo/03_help_text.md
         | 
| 104 | 
            +
            - demo/04_manpage.md
         | 
| 105 | 
            +
            - demo/06_delegate_example.md
         | 
| 106 | 
            +
            - demo/07_command_methods.md
         | 
| 107 | 
            +
            - demo/08_dispatach.md
         | 
| 108 | 
            +
            - demo/09_optparse_example.md
         | 
| 88 109 | 
             
            - demo/applique/ae.rb
         | 
| 89 110 | 
             
            - demo/applique/compare.rb
         | 
| 90 111 | 
             
            - demo/applique/exec.rb
         | 
| @@ -101,23 +122,13 @@ files: | |
| 101 122 | 
             
            - lib/executable/utils.rb
         | 
| 102 123 | 
             
            - lib/executable/version.rb
         | 
| 103 124 | 
             
            - lib/executable.rb
         | 
| 104 | 
            -
            -  | 
| 105 | 
            -
            - meta/copyrights
         | 
| 106 | 
            -
            - meta/created
         | 
| 107 | 
            -
            - meta/description
         | 
| 108 | 
            -
            - meta/name
         | 
| 109 | 
            -
            - meta/organization
         | 
| 110 | 
            -
            - meta/repositories
         | 
| 111 | 
            -
            - meta/requirements
         | 
| 112 | 
            -
            - meta/resources
         | 
| 113 | 
            -
            - meta/summary
         | 
| 114 | 
            -
            - meta/version
         | 
| 125 | 
            +
            - lib/executable.yml
         | 
| 115 126 | 
             
            - test/test_executable.rb
         | 
| 116 | 
            -
            -  | 
| 117 | 
            -
            -  | 
| 118 | 
            -
            -  | 
| 119 | 
            -
            -  | 
| 120 | 
            -
            -  | 
| 127 | 
            +
            - LICENSE.txt
         | 
| 128 | 
            +
            - HISTORY.md
         | 
| 129 | 
            +
            - README.md
         | 
| 130 | 
            +
            - DEMO.md
         | 
| 131 | 
            +
            - Config.rb
         | 
| 121 132 | 
             
            homepage: http://rubyworks.github.com/executable
         | 
| 122 133 | 
             
            licenses:
         | 
| 123 134 | 
             
            - BSD-2-Clause
         | 
| @@ -139,8 +150,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 139 150 | 
             
                  version: '0'
         | 
| 140 151 | 
             
            requirements: []
         | 
| 141 152 | 
             
            rubyforge_project: 
         | 
| 142 | 
            -
            rubygems_version: 1.8. | 
| 153 | 
            +
            rubygems_version: 1.8.23
         | 
| 143 154 | 
             
            signing_key: 
         | 
| 144 155 | 
             
            specification_version: 3
         | 
| 145 156 | 
             
            summary: Commandline Object Mapper
         | 
| 146 | 
            -
            test_files: | 
| 157 | 
            +
            test_files:
         | 
| 158 | 
            +
            - test/test_executable.rb
         | 
    
        data/COPYING.rdoc
    DELETED
    
    | @@ -1,35 +0,0 @@ | |
| 1 | 
            -
            = COPYRIGHT
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            == NOTICES
         | 
| 4 | 
            -
             | 
| 5 | 
            -
            === Executable
         | 
| 6 | 
            -
             | 
| 7 | 
            -
            Copyright:: (c) 2012 Rubyworks. All rights reserved.
         | 
| 8 | 
            -
            License::   (r) BSD-2-Clause
         | 
| 9 | 
            -
            Website::   http://rubyworks.github.com/assay
         | 
| 10 | 
            -
             | 
| 11 | 
            -
             | 
| 12 | 
            -
            == LICENSES
         | 
| 13 | 
            -
             | 
| 14 | 
            -
            === BSD-2-Clause License
         | 
| 15 | 
            -
             | 
| 16 | 
            -
                Redistribution and use in source and binary forms, with or without
         | 
| 17 | 
            -
                modification, are permitted provided that the following conditions are met:
         | 
| 18 | 
            -
             | 
| 19 | 
            -
                   1. Redistributions of source code must retain the above copyright notice,
         | 
| 20 | 
            -
                      this list of conditions and the following disclaimer.
         | 
| 21 | 
            -
             | 
| 22 | 
            -
                   2. Redistributions in binary form must reproduce the above copyright
         | 
| 23 | 
            -
                      notice, this list of conditions and the following disclaimer in the
         | 
| 24 | 
            -
                      documentation and/or other materials provided with the distribution.
         | 
| 25 | 
            -
             | 
| 26 | 
            -
                THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
         | 
| 27 | 
            -
                INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
         | 
| 28 | 
            -
                FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
         | 
| 29 | 
            -
                COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
         | 
| 30 | 
            -
                INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
         | 
| 31 | 
            -
                NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR  SERVICES; LOSS OF USE,
         | 
| 32 | 
            -
                DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
         | 
| 33 | 
            -
                OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
         | 
| 34 | 
            -
                NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
         | 
| 35 | 
            -
                EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
         | 
    
        data/Schedule.reap
    DELETED
    
    | @@ -1,17 +0,0 @@ | |
| 1 | 
            -
            task :default => [:test]
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            desc "run unit tests (needs rubytest)"
         | 
| 4 | 
            -
            task :test do
         | 
| 5 | 
            -
              sh "rubytest -Ilib test/*.rb"
         | 
| 6 | 
            -
            end
         | 
| 7 | 
            -
             | 
| 8 | 
            -
            desc "render README.rdoc to web/readme.html (need malt)"
         | 
| 9 | 
            -
            task :readme do
         | 
| 10 | 
            -
              sh "malt README.rdoc > web/readme.html"
         | 
| 11 | 
            -
            end
         | 
| 12 | 
            -
             | 
| 13 | 
            -
            # if `README.rdoc` changes generate `web/readme.html`.
         | 
| 14 | 
            -
            file 'README.rdoc' do
         | 
| 15 | 
            -
              sh "malt README.rdoc > web/readme.html"
         | 
| 16 | 
            -
            end
         | 
| 17 | 
            -
             | 
    
        data/meta/authors
    DELETED
    
    
    
        data/meta/copyrights
    DELETED
    
    
    
        data/meta/created
    DELETED
    
    | @@ -1 +0,0 @@ | |
| 1 | 
            -
            2008-08-08
         | 
    
        data/meta/description
    DELETED
    
    | @@ -1,6 +0,0 @@ | |
| 1 | 
            -
            Think of Executable as a *COM*, a Commandline Object Mapper,
         | 
| 2 | 
            -
            in much the same way that ActiveRecord is an ORM,
         | 
| 3 | 
            -
            an Object Relational Mapper. A class utilizing Executable
         | 
| 4 | 
            -
            can define a complete command line tool using nothing more
         | 
| 5 | 
            -
            than Ruby's own method definitions.
         | 
| 6 | 
            -
             | 
    
        data/meta/name
    DELETED
    
    | @@ -1 +0,0 @@ | |
| 1 | 
            -
            executable
         | 
    
        data/meta/organization
    DELETED
    
    | @@ -1 +0,0 @@ | |
| 1 | 
            -
            rubyworks
         | 
    
        data/meta/repositories
    DELETED
    
    
    
        data/meta/requirements
    DELETED
    
    
    
        data/meta/resources
    DELETED
    
    
    
        data/meta/summary
    DELETED
    
    | @@ -1 +0,0 @@ | |
| 1 | 
            -
            Commandline Object Mapper
         | 
    
        data/meta/version
    DELETED
    
    | @@ -1 +0,0 @@ | |
| 1 | 
            -
            1.2.0
         |