s0nspark-choice 0.1.4

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,5 @@
1
+
2
+ lib_path = File.expand_path(File.dirname(__FILE__) + "/../lib")
3
+ $LOAD_PATH.unshift lib_path unless $LOAD_PATH.include?(lib_path)
4
+
5
+ require 'test/unit'
@@ -0,0 +1,104 @@
1
+
2
+ require File.join(File.expand_path(File.dirname(__FILE__)), 'test_helper')
3
+
4
+ require "choice"
5
+
6
+ class TestWriter < Test::Unit::TestCase
7
+
8
+ def setup
9
+ Choice.reset!
10
+ end
11
+
12
+ HELP_OUT = ''
13
+ def test_help
14
+ song = Choice::Option.new do
15
+ short '-s'
16
+ long '--song=SONG'
17
+ cast String
18
+ desc 'Your favorite GNR song.'
19
+ desc '(Default: MyMichelle)'
20
+ default 'MyMichelle'
21
+ end
22
+ dude = Choice::Option.new do
23
+ short '-d'
24
+ long '--dude=DUDE'
25
+ cast String
26
+ desc 'Your favorite GNR dude.'
27
+ desc '(Default: Slash)'
28
+ default 'Slash'
29
+ end
30
+
31
+ options = [[:song, song], [:dude, dude]]
32
+ args = { :banner => "Welcome to the jungle",
33
+ :header => [""],
34
+ :options => options,
35
+ :footer => ["", "Wake up."] }
36
+
37
+ help_string = <<-HELP
38
+ Welcome to the jungle
39
+
40
+ -s, --song=SONG Your favorite GNR song.
41
+ (Default: MyMichelle)
42
+ -d, --dude=DUDE Your favorite GNR dude.
43
+ (Default: Slash)
44
+
45
+ Wake up.
46
+ HELP
47
+
48
+ Choice::Writer.help(args, HELP_OUT, true)
49
+
50
+ assert_equal help_string, HELP_OUT
51
+ end
52
+
53
+ BANNER_OUT = ''
54
+ def test_banner
55
+ media = Choice::Option.new do
56
+ short '-m'
57
+ long '--media=MEDIA'
58
+ end
59
+ rom = Choice::Option.new do
60
+ short '-r'
61
+ long '--rom=ROM'
62
+ end
63
+
64
+ options = [[:media, media], [:rom, rom]]
65
+ args = { :header => [""],
66
+ :options => options }
67
+
68
+ help_string = <<-HELP
69
+ Usage: #{program} [-mr]
70
+
71
+ -m, --media=MEDIA
72
+ -r, --rom=ROM
73
+ HELP
74
+
75
+ Choice::Writer.help(args, BANNER_OUT, true)
76
+
77
+ assert_equal help_string, BANNER_OUT
78
+ end
79
+
80
+ SPILLOVER_OUT = ''
81
+ def test_desc_spillover
82
+ toolong = Choice::Option.new do
83
+ long '--thisisgonnabewaytoolongiswear=STRING'
84
+ desc 'Way too long, boy wonder.'
85
+ end
86
+
87
+ options = [[:toolong, toolong]]
88
+
89
+ help_string = <<-HELP
90
+ Usage: #{program}
91
+ --thisisgonnabewaytoolongiswear=STRING
92
+ Way too long, boy wonder.
93
+ HELP
94
+
95
+
96
+ Choice::Writer.help({:options => options}, SPILLOVER_OUT, true)
97
+
98
+ assert_equal help_string, SPILLOVER_OUT
99
+ end
100
+
101
+ def program
102
+ if (/(\/|\\)/ =~ $0) then File.basename($0) else $0 end
103
+ end
104
+ end
metadata ADDED
@@ -0,0 +1,69 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: s0nspark-choice
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.4
5
+ platform: ruby
6
+ authors:
7
+ - Tim Ferrell
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-04-03 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description:
17
+ email: s0nspark@gmail.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - README.rdoc
24
+ - LICENSE
25
+ files:
26
+ - README.rdoc
27
+ - lib/choice
28
+ - lib/choice/lazyhash.rb
29
+ - lib/choice/option.rb
30
+ - lib/choice/parser.rb
31
+ - lib/choice/version.rb
32
+ - lib/choice/writer.rb
33
+ - lib/choice.rb
34
+ - test/choice_test.rb
35
+ - test/lazyhash_test.rb
36
+ - test/option_test.rb
37
+ - test/parser_test.rb
38
+ - test/test_helper.rb
39
+ - test/writer_test.rb
40
+ - LICENSE
41
+ has_rdoc: true
42
+ homepage: http://github.com/s0nspark/choice
43
+ post_install_message:
44
+ rdoc_options:
45
+ - --inline-source
46
+ - --charset=UTF-8
47
+ require_paths:
48
+ - lib
49
+ required_ruby_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: "0"
54
+ version:
55
+ required_rubygems_version: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: "0"
60
+ version:
61
+ requirements: []
62
+
63
+ rubyforge_project:
64
+ rubygems_version: 1.2.0
65
+ signing_key:
66
+ specification_version: 2
67
+ summary: TODO
68
+ test_files: []
69
+