docopt 0.0.4 → 0.5.0

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.
@@ -0,0 +1,49 @@
1
+ require 'test/unit'
2
+
3
+ class DocoptTest < Test::Unit::TestCase
4
+ def setup
5
+ $LOAD_PATH << File.dirname(__FILE__)
6
+ load 'example.rb'
7
+ end
8
+
9
+ def get_options(argv=[])
10
+ begin
11
+ Docopt($DOC, { :argv => argv })
12
+ rescue SystemExit => ex
13
+ nil
14
+ end
15
+ end
16
+
17
+ def test_size
18
+ options = get_options(['arg'])
19
+ assert_equal 16, options.size
20
+ end
21
+
22
+ def test_option
23
+ options = get_options(['arg'])
24
+ assert_equal ".svn,CVS,.bzr,.hg,.git", options['--exclude']
25
+ end
26
+
27
+ def test_values
28
+ options = get_options(['arg'])
29
+ assert !options['--help']
30
+ assert !options['-h']
31
+ assert !options['--version']
32
+ assert !options['-v']
33
+ assert !options['--verbose']
34
+ assert !options['--quiet']
35
+ assert !options['-q']
36
+ assert !options['--repeat']
37
+ assert !options['-r']
38
+ assert_equal ".svn,CVS,.bzr,.hg,.git", options['--exclude']
39
+ assert_equal "*.rb", options['--filename']
40
+ assert !options['--select']
41
+ assert !options['--ignore']
42
+ assert !options['--show-source']
43
+ assert !options['--statistics']
44
+ assert !options['--count']
45
+ assert !options['--benchmark']
46
+ assert !options['--testsuite']
47
+ assert !options['--doctest']
48
+ end
49
+ end
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby
2
+ require File.expand_path("../../lib/docopt.rb", __FILE__)
3
+
4
+ require 'json'
5
+
6
+ doc = STDIN.read
7
+
8
+ begin
9
+ puts Docopt::docopt(doc).to_json
10
+ rescue Docopt::Exit => ex
11
+ puts '"user-error"'
12
+ end
metadata CHANGED
@@ -1,35 +1,64 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: docopt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.5.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
8
+ - Blake Williams
8
9
  - Vladimir Keleshev
9
10
  - Alex Speller
11
+ - Nima Johari
10
12
  autorequire:
11
13
  bindir: bin
12
14
  cert_chain: []
13
- date: 2012-06-05 00:00:00.000000000 Z
14
- dependencies: []
15
- description: A command line option parser, that will make you smile. Isn't it awesome
16
- how `optparse` and other option parsers generate help and usage-messages based on
17
- your code?! Hell no! You know what's awesome? It's when the option parser *is*
18
- generated based on the help and usage-message that you write in a docstring!
19
- email: alex@alexspeller.com
15
+ date: 2012-09-01 00:00:00.000000000Z
16
+ dependencies:
17
+ - !ruby/object:Gem::Dependency
18
+ name: json
19
+ requirement: &81987080 !ruby/object:Gem::Requirement
20
+ none: false
21
+ requirements:
22
+ - - ~>
23
+ - !ruby/object:Gem::Version
24
+ version: 1.6.5
25
+ type: :development
26
+ prerelease: false
27
+ version_requirements: *81987080
28
+ description: ! 'Isn''t it awesome how `optparse` and other option parsers generate
29
+ help and usage-messages based on your code?! Hell no!
30
+
31
+ You know what''s awesome? It''s when the option parser *is* generated based on the
32
+ help and usage-message that you write in a docstring! That''s what docopt does!'
33
+ email: code@shabbyrobe.org
20
34
  executables: []
21
35
  extensions: []
22
- extra_rdoc_files: []
36
+ extra_rdoc_files:
37
+ - README.md
38
+ - LICENSE
23
39
  files:
40
+ - Gemfile
41
+ - LICENSE
24
42
  - README.md
25
- - LICENSE-MIT
26
- - example.rb
43
+ - Rakefile
44
+ - docopt.gemspec
45
+ - examples/any_options_example.rb
46
+ - examples/calculator.rb
47
+ - examples/counted_example.rb
48
+ - examples/example_options.rb
49
+ - examples/git_example.rb
50
+ - examples/naval_fate.rb
51
+ - examples/odd_even_example.rb
52
+ - examples/quick_example.rb
27
53
  - lib/docopt.rb
28
- homepage: http://github.com/alexspeller/docopt
54
+ - test/test_docopt.rb
55
+ - test/testee.rb
56
+ homepage: http://github.com/docopt/docopt.rb
29
57
  licenses:
30
58
  - MIT
31
59
  post_install_message:
32
- rdoc_options: []
60
+ rdoc_options:
61
+ - --charset=UTF-8
33
62
  require_paths:
34
63
  - lib
35
64
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -37,17 +66,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
37
66
  requirements:
38
67
  - - ! '>='
39
68
  - !ruby/object:Gem::Version
40
- version: 1.9.2
69
+ version: 1.8.7
41
70
  required_rubygems_version: !ruby/object:Gem::Requirement
42
71
  none: false
43
72
  requirements:
44
73
  - - ! '>='
45
74
  - !ruby/object:Gem::Version
46
- version: 1.8.11
75
+ version: '0'
47
76
  requirements: []
48
77
  rubyforge_project:
49
- rubygems_version: 1.8.23
78
+ rubygems_version: 1.8.17
50
79
  signing_key:
51
- specification_version: 3
80
+ specification_version: 2
52
81
  summary: A command line option parser, that will make you smile.
53
- test_files: []
82
+ test_files:
83
+ - test/test_docopt.rb
data/example.rb DELETED
@@ -1,30 +0,0 @@
1
- $DOC = "Usage: example.py [options] <arguments>...
2
-
3
- Options:
4
- -h --help show this help message and exit
5
- --version show version and exit
6
- -v --verbose print status messages
7
- -q --quiet report only file names
8
- -r --repeat show all occurrences of the same error
9
- --exclude=patterns exclude files or directories which match these comma
10
- separated patterns [default: .svn,CVS,.bzr,.hg,.git]
11
- --filename=patterns when parsing directories, only check filenames matching
12
- these comma separated patterns [default: *.rb]
13
- --select=errors select errors and warnings (e.g. E,W6)
14
- --ignore=errors skip errors and warnings (e.g. E4,W)
15
- --show-source show source code for each error
16
- --statistics count errors and warnings
17
- --count print total number of errors and warnings to standard
18
- error and set exit code to 1 if total is not null
19
- --benchmark measure processing speed
20
- --testsuite=dir run regression tests from dir
21
- --doctest run doctest on myself"
22
-
23
- require 'docopt'
24
-
25
-
26
- if __FILE__ == $0
27
- options = Docopt($DOC, '1.0.0') # parse options based on doc above
28
- puts options.inspect
29
- puts ARGV.inspect
30
- end