user-choices 1.1.3 → 1.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.
- data/History.txt +7 -0
- data/Manifest.txt +0 -3
- data/Rakefile +52 -13
- data/examples/tutorial/index.html +6 -0
- data/lib/user-choices/builder.rb +29 -0
- data/lib/user-choices/command-line-source.rb +10 -6
- data/lib/user-choices/sources.rb +5 -1
- data/lib/user-choices/version.rb +1 -1
- data/test/arglist-strategy-tests.rb +1 -1
- data/test/builder-tests.rb +148 -86
- data/test/command-line-source-tests.rb +1 -1
- data/test/conversion-tests.rb +1 -1
- data/test/source-tests.rb +12 -3
- data/test/user-choices-slowtests.rb +1 -1
- metadata +4 -15
- data/Rakefile.hoe +0 -24
- data/test/set-standalone-test-paths.rb +0 -5
- data/user-choices.tmproj +0 -170
data/History.txt
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
Version 1.1.4 -- in progress
|
2
|
+
* Enable better command_line documentation: ChoicesBuilder#add_help_line,
|
3
|
+
ChoicesBuilder#section, ChoicesBuilder#section_specific_to_script.
|
4
|
+
* One Rakefile instead of two.
|
5
|
+
* Give up on using extensions/string: too many name conflicts, too hard to
|
6
|
+
avoid. Facets didn't solve the problem.
|
7
|
+
|
1
8
|
Version 1.1.3
|
2
9
|
* Bugfix: PosixCommandLineSource was not uniformly treated as a
|
3
10
|
CommandLineSource.
|
data/Manifest.txt
CHANGED
@@ -3,7 +3,6 @@ LICENSE.txt
|
|
3
3
|
Manifest.txt
|
4
4
|
README.txt
|
5
5
|
Rakefile
|
6
|
-
Rakefile.hoe
|
7
6
|
examples/older/README.txt
|
8
7
|
examples/older/command-line.rb
|
9
8
|
examples/older/default-values.rb
|
@@ -34,7 +33,5 @@ test/arglist-strategy-tests.rb
|
|
34
33
|
test/builder-tests.rb
|
35
34
|
test/command-line-source-tests.rb
|
36
35
|
test/conversion-tests.rb
|
37
|
-
test/set-standalone-test-paths.rb
|
38
36
|
test/source-tests.rb
|
39
37
|
test/user-choices-slowtests.rb
|
40
|
-
user-choices.tmproj
|
data/Rakefile
CHANGED
@@ -1,19 +1,58 @@
|
|
1
|
-
|
2
|
-
#
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# Created by Brian Marick on 2007-07-03.
|
4
|
+
# Copyright (c) 2007. All rights reserved.
|
3
5
|
|
4
|
-
|
6
|
+
require 'hoe'
|
7
|
+
require 'lib/user-choices/version'
|
5
8
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
+
PROJECT='user-choices'
|
10
|
+
THIS_RELEASE=UserChoices::Version
|
11
|
+
ROOT = "svn+ssh://marick@rubyforge.org/var/svn/#{PROJECT}"
|
9
12
|
|
10
|
-
|
11
|
-
|
13
|
+
Hoe.new(PROJECT, THIS_RELEASE) do |p|
|
14
|
+
p.rubyforge_name = PROJECT
|
15
|
+
p.changes = "See History.txt"
|
16
|
+
p.author = "Brian Marick"
|
17
|
+
p.description = "Unified interface to command-line, environment, and configuration files."
|
18
|
+
p.summary = p.description
|
19
|
+
p.email = "marick@exampler.com"
|
20
|
+
p.extra_deps = [['xml-simple', '>= 1.0.11'],
|
21
|
+
['s4t-utils', '>= 1.0.3'],
|
22
|
+
['builder', '>= 2.1.2']] # for testing
|
23
|
+
p.test_globs = "test/**/*tests.rb"
|
24
|
+
p.rdoc_pattern = %r{README.txt|History.txt|lib/user-choices.rb|lib/user-choices/.+\.rb}
|
25
|
+
p.url = "http://user-choices.rubyforge.org"
|
26
|
+
p.remote_rdoc_dir = 'rdoc'
|
27
|
+
end
|
12
28
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
29
|
+
require 's4t-utils/rake-task-helpers'
|
30
|
+
desc "Run fast tests."
|
31
|
+
task 'fast' do
|
32
|
+
S4tUtils.run_particular_tests('test', 'fast')
|
33
|
+
end
|
17
34
|
|
18
|
-
|
35
|
+
desc "Run slow tests."
|
36
|
+
task 'slow' do
|
37
|
+
S4tUtils.run_particular_tests('test', 'slow')
|
38
|
+
end
|
19
39
|
|
40
|
+
desc "Tag release with current version."
|
41
|
+
task 'tag_release' do
|
42
|
+
from = "#{ROOT}/trunk"
|
43
|
+
to = "#{ROOT}/tags/rel-#{THIS_RELEASE}"
|
44
|
+
message = "Release #{THIS_RELEASE}"
|
45
|
+
exec = "svn copy -m '#{message}' #{from} #{to}"
|
46
|
+
puts exec
|
47
|
+
system(exec)
|
48
|
+
end
|
49
|
+
|
50
|
+
desc "Export to ~/tmp/exports/#{PROJECT}"
|
51
|
+
task 'export' do
|
52
|
+
Dir.chdir("#{ENV['HOME']}/tmp/exports") do
|
53
|
+
rm_rf PROJECT
|
54
|
+
exec = "svn export #{ROOT}/trunk #{PROJECT}"
|
55
|
+
puts exec
|
56
|
+
system exec
|
57
|
+
end
|
58
|
+
end
|
@@ -213,6 +213,9 @@ if $0 == __FILE__ <br />
|
|
213
213
|
<p>
|
214
214
|
<b><code>builder.add_source(YamlConfigFileSource, <font style="color: #800020;">:from_file</font>, "filename")</code></b> says that the user choices are in a <a href="http://yaml.org/" title="YAML Ain't Markup Language">YAML</a> file named "filename" in the user's home directory. The home directory is found the same way RubyGems finds it.
|
215
215
|
</p>
|
216
|
+
<p>
|
217
|
+
You can use <b><font style="color: #800020;">:from_complete_path</font></b> if your YAML file isn't in the home directory. In that case, the next argument is a path to the YAML file. It can be either relative or absolute.
|
218
|
+
</p>
|
216
219
|
<p>
|
217
220
|
YAML files should contain a single level of keys and values. The values can be numbers, strings, and arrays of numbers or strings. Here is an acceptable file:
|
218
221
|
</p>
|
@@ -237,6 +240,9 @@ if $0 == __FILE__ <br />
|
|
237
240
|
<dd>
|
238
241
|
<p> <b><code>builder.add_source(XmlConfigFileSource, <font style="color: #800020;">:from_file</font>, "filename")</code></b> says that the user choices are in a XML file named "filename" in the user's home directory. The home directory is found the same way RubyGems finds it.
|
239
242
|
</p>
|
243
|
+
<p>
|
244
|
+
You can use <b><font style="color: #800020;">:from_complete_path</font></b> if your XML file isn't in the home directory. In that case, the next argument is a path to the XML file. It can be either relative or absolute.
|
245
|
+
</p>
|
240
246
|
<p>
|
241
247
|
Here is an acceptable XML file:
|
242
248
|
</p>
|
data/lib/user-choices/builder.rb
CHANGED
@@ -56,6 +56,35 @@ module UserChoices
|
|
56
56
|
@sources << source
|
57
57
|
@command_line_source = source if source_class <= CommandLineSource
|
58
58
|
end
|
59
|
+
|
60
|
+
# Add a single line composed of _string_ to the current position in the
|
61
|
+
# help output.
|
62
|
+
def add_help_line(string)
|
63
|
+
user_claims(@command_line_source) {
|
64
|
+
"Can't use 'add_help_string' when there's no command line source."
|
65
|
+
}
|
66
|
+
@command_line_source.add_help_line(string)
|
67
|
+
end
|
68
|
+
|
69
|
+
# Demarcate a section of help text. It begins with the _description_,
|
70
|
+
# ends with a dashed line.
|
71
|
+
def section(description)
|
72
|
+
add_help_line("... " + description + ":")
|
73
|
+
yield
|
74
|
+
add_help_line("---------------------------------")
|
75
|
+
add_help_line('')
|
76
|
+
end
|
77
|
+
|
78
|
+
# In groups of related commands, there are often choices that apply to
|
79
|
+
# all commands and choices that apply only to this particular command.
|
80
|
+
# Use this to define the latter.
|
81
|
+
def section_specific_to_script
|
82
|
+
section("specific to this script") do
|
83
|
+
yield
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
|
59
88
|
|
60
89
|
# Once sources and choices have been described, this builds and
|
61
90
|
# returns a hash-like object indexed by the choices.
|
@@ -3,7 +3,6 @@ require 's4t-utils'
|
|
3
3
|
require 'user-choices/sources.rb'
|
4
4
|
require 'user-choices/arglist-strategies'
|
5
5
|
include S4tUtils
|
6
|
-
require 'extensions/string'
|
7
6
|
|
8
7
|
module UserChoices # :nodoc
|
9
8
|
|
@@ -92,7 +91,11 @@ module UserChoices # :nodoc
|
|
92
91
|
use_strategy(choice, OneOptionalArg)
|
93
92
|
end
|
94
93
|
|
95
|
-
|
94
|
+
# Add a single line composed of _string_ to the current position in the
|
95
|
+
# help output.
|
96
|
+
def add_help_line(string)
|
97
|
+
@parser.separator(string)
|
98
|
+
end
|
96
99
|
|
97
100
|
|
98
101
|
# Public for testing.
|
@@ -123,10 +126,11 @@ module UserChoices # :nodoc
|
|
123
126
|
def help_banner(banner, *more) # :nodoc:
|
124
127
|
@parser.banner = banner
|
125
128
|
more.each do | line |
|
126
|
-
|
129
|
+
add_help_line(line)
|
127
130
|
end
|
128
|
-
|
129
|
-
|
131
|
+
|
132
|
+
add_help_line ''
|
133
|
+
add_help_line 'Options:'
|
130
134
|
|
131
135
|
@parser.on_tail("-?", "-h", "--help", "Show this message.") do
|
132
136
|
help
|
@@ -155,7 +159,7 @@ module UserChoices # :nodoc
|
|
155
159
|
rescue SystemExit
|
156
160
|
raise
|
157
161
|
rescue Exception => ex
|
158
|
-
message = if ex.message.
|
162
|
+
message = if ex.message.has_exact_prefix?(error_prefix)
|
159
163
|
ex.message
|
160
164
|
else
|
161
165
|
error_prefix + ex.message
|
data/lib/user-choices/sources.rb
CHANGED
@@ -152,7 +152,11 @@ module UserChoices # :nodoc
|
|
152
152
|
class FileSource < AbstractSource # :nodoc:
|
153
153
|
|
154
154
|
def from_file(filename)
|
155
|
-
|
155
|
+
from_complete_path(File.join(S4tUtils.find_home, filename))
|
156
|
+
end
|
157
|
+
|
158
|
+
def from_complete_path(path)
|
159
|
+
@path = path
|
156
160
|
@contents_as_hash = self.read_into_hash
|
157
161
|
@contents_as_hash.each do | external_name, value |
|
158
162
|
sym = external_name.to_inputable_sym
|
data/lib/user-choices/version.rb
CHANGED
@@ -3,12 +3,12 @@
|
|
3
3
|
# Created by Brian Marick on 2007-08-10.
|
4
4
|
# Copyright (c) 2007. All rights reserved.
|
5
5
|
|
6
|
-
load "set-standalone-test-paths.rb" unless $started_from_rakefile
|
7
6
|
require 'test/unit'
|
8
7
|
require 's4t-utils'
|
9
8
|
require 'builder'
|
10
9
|
require 'user-choices/arglist-strategies'
|
11
10
|
include S4tUtils
|
11
|
+
set_test_paths(__FILE__)
|
12
12
|
|
13
13
|
# Since ArglistStrategies were extracted from CommandLineSource, most
|
14
14
|
# of the testing is implicit.
|
data/test/builder-tests.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
load "set-standalone-test-paths.rb" unless $started_from_rakefile
|
2
1
|
require 'test/unit'
|
3
2
|
require 's4t-utils'
|
4
3
|
require 'user-choices'
|
5
4
|
include S4tUtils
|
5
|
+
set_test_paths(__FILE__)
|
6
6
|
|
7
7
|
|
8
8
|
class TestDefaultsAndTypes < Test::Unit::TestCase
|
@@ -445,9 +445,11 @@ class TestCommandLineConstruction < Test::Unit::TestCase
|
|
445
445
|
"Usage: prog [options]",
|
446
446
|
"This is supplemental.")
|
447
447
|
|
448
|
-
b.add_choice(:test) { | command_line |
|
448
|
+
b.add_choice(:test, :type => :boolean) { | command_line |
|
449
449
|
command_line.uses_switch("--test",
|
450
450
|
"Here's text for a switch")
|
451
|
+
}
|
452
|
+
b.add_choice(:renew) { | command_line |
|
451
453
|
command_line.uses_option("-r", "--renew VALUE",
|
452
454
|
"Here's text for an option")
|
453
455
|
}
|
@@ -467,103 +469,163 @@ class TestCommandLineConstruction < Test::Unit::TestCase
|
|
467
469
|
}
|
468
470
|
end
|
469
471
|
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
b.add_choice(:home)
|
479
|
-
choices = b.build
|
480
|
-
assert_equal("e", choices[:e])
|
481
|
-
assert_equal("/Users/marick", choices[:home])
|
482
|
-
}
|
483
|
-
|
484
|
-
end
|
485
|
-
|
486
|
-
|
487
|
-
def test_required_arg_with_type_conversion
|
488
|
-
with_command_args("2") {
|
489
|
-
b = ChoicesBuilder.new
|
490
|
-
b.add_source(CommandLineSource, :usage, "blah")
|
491
|
-
b.add_choice(:e, :type => :integer) { |command_line |
|
492
|
-
command_line.uses_arg
|
493
|
-
}
|
494
|
-
choices = b.build
|
495
|
-
assert_equal(2, choices[:e])
|
496
|
-
}
|
497
|
-
end
|
472
|
+
def test_builder_can_add_separators_to_help_text
|
473
|
+
with_command_args('--help') {
|
474
|
+
output = capturing_stderr do
|
475
|
+
assert_wants_to_exit do
|
476
|
+
b = ChoicesBuilder.new
|
477
|
+
b.add_source(CommandLineSource, :usage,
|
478
|
+
"Usage: prog [options]",
|
479
|
+
"This is supplemental.")
|
498
480
|
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
481
|
+
b.add_help_line("==============")
|
482
|
+
b.add_choice(:test) { | command_line |
|
483
|
+
command_line.uses_switch("--test",
|
484
|
+
"Here's text for a switch")
|
485
|
+
}
|
486
|
+
b.build
|
487
|
+
end
|
488
|
+
end
|
489
|
+
assert(l1 = output.index("This is supplemental"))
|
490
|
+
assert(l2 = output.index(/==============/))
|
491
|
+
assert(l3 = output.index(/--\[no-\]test.*Here's text for a switch/))
|
492
|
+
|
493
|
+
assert(l1 < l2)
|
494
|
+
assert(l2 < l3)
|
495
|
+
}
|
496
|
+
end
|
497
|
+
|
498
|
+
def test_builder_can_group_help_text_in_sections
|
499
|
+
with_command_args('--help') {
|
500
|
+
output = capturing_stderr do
|
501
|
+
assert_wants_to_exit do
|
502
|
+
b = ChoicesBuilder.new
|
503
|
+
b.add_source(CommandLineSource, :usage,
|
504
|
+
"Usage: prog [options]",
|
505
|
+
"This is supplemental.")
|
506
|
+
|
507
|
+
b.section("section head") do
|
508
|
+
b.add_choice(:test) { | command_line |
|
509
|
+
command_line.uses_switch("--test",
|
510
|
+
"Here's text for a switch")
|
511
|
+
}
|
509
512
|
end
|
513
|
+
b.add_choice(:renew) { | command_line |
|
514
|
+
command_line.uses_option("-r", "--renew VALUE",
|
515
|
+
"Here's text for an option")
|
516
|
+
}
|
517
|
+
b.build
|
510
518
|
end
|
511
|
-
|
512
|
-
|
513
|
-
|
519
|
+
end
|
520
|
+
assert(l1 = output.index("This is supplemental"))
|
521
|
+
assert(l2 = output.index(/section head/))
|
522
|
+
assert(l3 = output.index(/--\[no-\]test.*Here's text for a switch/))
|
523
|
+
assert(l4 = output.index(/---------/))
|
524
|
+
assert(l5 = output.index(/Here's text for an option/))
|
514
525
|
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
526
|
+
assert(l1 < l2)
|
527
|
+
assert(l2 < l3)
|
528
|
+
assert(l3 < l4)
|
529
|
+
assert(l4 < l5)
|
530
|
+
}
|
531
|
+
end
|
532
|
+
|
533
|
+
end
|
534
|
+
|
535
|
+
class TestSpecialCases < Test::Unit::TestCase
|
536
|
+
include UserChoices
|
537
|
+
|
538
|
+
def test_environment_choices_can_be_given_prefix_and_mapping
|
539
|
+
with_environment_vars("prefix_e" => "e", "HOME" => '/Users/marick') {
|
540
|
+
b = ChoicesBuilder.new
|
541
|
+
b.add_source(EnvironmentSource, :with_prefix, "prefix_", :mapping, {:home => "HOME" })
|
542
|
+
b.add_choice(:e)
|
543
|
+
b.add_choice(:home)
|
544
|
+
choices = b.build
|
545
|
+
assert_equal("e", choices[:e])
|
546
|
+
assert_equal("/Users/marick", choices[:home])
|
547
|
+
}
|
548
|
+
|
549
|
+
end
|
550
|
+
|
551
|
+
|
552
|
+
def test_required_arg_with_type_conversion
|
553
|
+
with_command_args("2") {
|
554
|
+
b = ChoicesBuilder.new
|
555
|
+
b.add_source(CommandLineSource, :usage, "blah")
|
556
|
+
b.add_choice(:e, :type => :integer) { |command_line |
|
557
|
+
command_line.uses_arg
|
524
558
|
}
|
525
|
-
|
559
|
+
choices = b.build
|
560
|
+
assert_equal(2, choices[:e])
|
561
|
+
}
|
562
|
+
end
|
526
563
|
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
command_line.uses_optional_arg
|
534
|
-
}
|
535
|
-
assert_equal(nil, b.build[:e])
|
564
|
+
def test_required_arg_conversion_prints_right_message
|
565
|
+
with_command_args("b") {
|
566
|
+
b = ChoicesBuilder.new
|
567
|
+
b.add_source(CommandLineSource, :usage, "blah")
|
568
|
+
b.add_choice(:e, :type => :integer) { |command_line |
|
569
|
+
command_line.uses_arg
|
536
570
|
}
|
537
|
-
|
538
|
-
|
571
|
+
output = capturing_stderr do
|
572
|
+
assert_wants_to_exit do
|
573
|
+
b.build
|
574
|
+
end
|
575
|
+
end
|
576
|
+
assert_no_match(/^Error in the command line: Error in the command line: /, output)
|
577
|
+
}
|
539
578
|
end
|
540
579
|
|
580
|
+
def test_optional_arg_with_type_conversion
|
581
|
+
with_command_args('2') {
|
582
|
+
b = ChoicesBuilder.new
|
583
|
+
b.add_source(CommandLineSource, :usage, "blah")
|
584
|
+
b.add_choice(:e, :type => :integer) { |command_line |
|
585
|
+
command_line.uses_optional_arg
|
586
|
+
}
|
587
|
+
choices = b.build
|
588
|
+
assert_equal(2, choices[:e])
|
589
|
+
}
|
590
|
+
end
|
541
591
|
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
assert_equal([
|
551
|
-
|
552
|
-
assert_equal([[:usage, 'arg1', 2]],
|
553
|
-
@builder.message_sends([:usage, 'arg1', 2]))
|
554
|
-
assert_equal([[:msg, 'arg1', 2], [:next, 1]],
|
555
|
-
@builder.message_sends([:msg, 'arg1', 2, :next, 1]))
|
556
|
-
# a common case
|
557
|
-
assert_equal([[:with_prefix, 'p_'], [:mapping, {:home => 'home'}]],
|
558
|
-
@builder.message_sends([:with_prefix, 'p_', :mapping, {:home => 'home'}]))
|
559
|
-
end
|
560
|
-
|
561
|
-
def test_symbol_indices
|
562
|
-
assert_equal([0, 3], @builder.symbol_indices([:foo, 1, 2, :bar, "quux"]))
|
563
|
-
end
|
592
|
+
def test_missing_optional_arg_with_type_conversion_is_OK
|
593
|
+
# The type check applies only if the value is given.
|
594
|
+
with_command_args('') {
|
595
|
+
b = ChoicesBuilder.new
|
596
|
+
b.add_source(CommandLineSource, :usage, "blah")
|
597
|
+
b.add_choice(:e, :type => :integer) { |command_line |
|
598
|
+
command_line.uses_optional_arg
|
599
|
+
}
|
600
|
+
assert_equal(nil, b.build[:e])
|
601
|
+
}
|
564
602
|
end
|
565
603
|
|
604
|
+
end
|
605
|
+
|
566
606
|
|
607
|
+
class TestUtilities < Test::Unit::TestCase
|
608
|
+
include UserChoices
|
609
|
+
|
610
|
+
def setup
|
611
|
+
@builder = ChoicesBuilder.new
|
612
|
+
end
|
567
613
|
|
614
|
+
def test_message_send_splitter
|
615
|
+
assert_equal([[:usage, 'arg']],
|
616
|
+
@builder.message_sends([:usage, 'arg']))
|
617
|
+
assert_equal([[:usage, 'arg1', 2]],
|
618
|
+
@builder.message_sends([:usage, 'arg1', 2]))
|
619
|
+
assert_equal([[:msg, 'arg1', 2], [:next, 1]],
|
620
|
+
@builder.message_sends([:msg, 'arg1', 2, :next, 1]))
|
621
|
+
# a common case
|
622
|
+
assert_equal([[:with_prefix, 'p_'], [:mapping, {:home => 'home'}]],
|
623
|
+
@builder.message_sends([:with_prefix, 'p_', :mapping, {:home => 'home'}]))
|
624
|
+
end
|
625
|
+
|
626
|
+
def test_symbol_indices
|
627
|
+
assert_equal([0, 3], @builder.symbol_indices([:foo, 1, 2, :bar, "quux"]))
|
628
|
+
end
|
568
629
|
end
|
569
630
|
|
631
|
+
|
data/test/conversion-tests.rb
CHANGED
@@ -3,11 +3,11 @@
|
|
3
3
|
# Created by Brian Marick on 2007-08-06.
|
4
4
|
# Copyright (c) 2007. All rights reserved.
|
5
5
|
|
6
|
-
load "set-standalone-test-paths.rb" unless $started_from_rakefile
|
7
6
|
require 'test/unit'
|
8
7
|
require 's4t-utils'
|
9
8
|
require 'user-choices'
|
10
9
|
include S4tUtils
|
10
|
+
set_test_paths(__FILE__)
|
11
11
|
|
12
12
|
|
13
13
|
class TestDefaultsAndTypes < Test::Unit::TestCase
|
data/test/source-tests.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
load "set-standalone-test-paths.rb" unless $started_from_rakefile
|
2
1
|
require 'test/unit'
|
3
2
|
require 's4t-utils'
|
4
3
|
require 'builder'
|
5
4
|
require 'user-choices'
|
6
5
|
include S4tUtils
|
7
|
-
|
6
|
+
set_test_paths(__FILE__)
|
7
|
+
require 'tempfile'
|
8
8
|
|
9
9
|
|
10
10
|
# The general contract of these objects.
|
@@ -312,6 +312,15 @@ class FileSourceTestCase < Test::Unit::TestCase
|
|
312
312
|
assert_equal(53, choices[:maximum])
|
313
313
|
end
|
314
314
|
end
|
315
|
+
|
316
|
+
def test_complete_paths_to_config_file_are_allowed
|
317
|
+
tempfile = Tempfile.new('path-test')
|
318
|
+
tempfile.puts(@some_xml)
|
319
|
+
tempfile.close
|
320
|
+
choices = XmlConfigFileSource.new.from_complete_path(tempfile.path)
|
321
|
+
choices.fill
|
322
|
+
assert_equal('53', choices[:maximum])
|
323
|
+
end
|
315
324
|
|
316
325
|
|
317
326
|
|
@@ -388,7 +397,7 @@ class YamlConfigFileSourceTestCase < Test::Unit::TestCase
|
|
388
397
|
| - a.com
|
389
398
|
| - b.com
|
390
399
|
| list-arg: 1,2, 3
|
391
|
-
".
|
400
|
+
".without_pretty_indentation('|')
|
392
401
|
end
|
393
402
|
|
394
403
|
def test_string_assurance
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
|
|
3
3
|
specification_version: 1
|
4
4
|
name: user-choices
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 1.1.
|
7
|
-
date: 2007-09-
|
6
|
+
version: 1.1.4
|
7
|
+
date: 2007-09-28 00:00:00 -05:00
|
8
8
|
summary: Unified interface to command-line, environment, and configuration files.
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -34,7 +34,6 @@ files:
|
|
34
34
|
- Manifest.txt
|
35
35
|
- README.txt
|
36
36
|
- Rakefile
|
37
|
-
- Rakefile.hoe
|
38
37
|
- examples/older/README.txt
|
39
38
|
- examples/older/command-line.rb
|
40
39
|
- examples/older/default-values.rb
|
@@ -65,16 +64,15 @@ files:
|
|
65
64
|
- test/builder-tests.rb
|
66
65
|
- test/command-line-source-tests.rb
|
67
66
|
- test/conversion-tests.rb
|
68
|
-
- test/set-standalone-test-paths.rb
|
69
67
|
- test/source-tests.rb
|
70
68
|
- test/user-choices-slowtests.rb
|
71
|
-
- user-choices.tmproj
|
72
69
|
test_files:
|
73
70
|
- test/arglist-strategy-tests.rb
|
74
71
|
- test/builder-tests.rb
|
75
72
|
- test/command-line-source-tests.rb
|
76
73
|
- test/conversion-tests.rb
|
77
74
|
- test/source-tests.rb
|
75
|
+
- test/user-choices-slowtests.rb
|
78
76
|
rdoc_options:
|
79
77
|
- --main
|
80
78
|
- README.txt
|
@@ -107,16 +105,7 @@ dependencies:
|
|
107
105
|
requirements:
|
108
106
|
- - ">="
|
109
107
|
- !ruby/object:Gem::Version
|
110
|
-
version: 1.0.
|
111
|
-
version:
|
112
|
-
- !ruby/object:Gem::Dependency
|
113
|
-
name: extensions
|
114
|
-
version_requirement:
|
115
|
-
version_requirements: !ruby/object:Gem::Version::Requirement
|
116
|
-
requirements:
|
117
|
-
- - ">="
|
118
|
-
- !ruby/object:Gem::Version
|
119
|
-
version: 0.6.0
|
108
|
+
version: 1.0.3
|
120
109
|
version:
|
121
110
|
- !ruby/object:Gem::Dependency
|
122
111
|
name: builder
|
data/Rakefile.hoe
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# Created by Brian Marick on 2007-07-03.
|
4
|
-
# Copyright (c) 2007. All rights reserved.
|
5
|
-
|
6
|
-
require 'hoe'
|
7
|
-
require 'lib/user-choices/version'
|
8
|
-
|
9
|
-
Hoe.new("user-choices", UserChoices::Version) do |p|
|
10
|
-
p.rubyforge_name = "user-choices"
|
11
|
-
p.changes = "See History.txt"
|
12
|
-
p.author = "Brian Marick"
|
13
|
-
p.description = "Unified interface to command-line, environment, and configuration files."
|
14
|
-
p.summary = p.description
|
15
|
-
p.email = "marick@exampler.com"
|
16
|
-
p.extra_deps = [['xml-simple', '>= 1.0.11'],
|
17
|
-
['s4t-utils', '>= 1.0.2'],
|
18
|
-
['extensions', '>= 0.6.0'], # for testing
|
19
|
-
['builder', '>= 2.1.2']] # for testing
|
20
|
-
p.test_globs = "test/**/*-tests.rb"
|
21
|
-
p.rdoc_pattern = %r{README.txt|History.txt|lib/user-choices.rb|lib/user-choices/.+\.rb}
|
22
|
-
p.url = "http://user-choices.rubyforge.org"
|
23
|
-
p.remote_rdoc_dir = 'rdoc'
|
24
|
-
end
|
data/user-choices.tmproj
DELETED
@@ -1,170 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
3
|
-
<plist version="1.0">
|
4
|
-
<dict>
|
5
|
-
<key>currentDocument</key>
|
6
|
-
<string>History.txt</string>
|
7
|
-
<key>documents</key>
|
8
|
-
<array>
|
9
|
-
<dict>
|
10
|
-
<key>expanded</key>
|
11
|
-
<true/>
|
12
|
-
<key>name</key>
|
13
|
-
<string>user-choices</string>
|
14
|
-
<key>regexFolderFilter</key>
|
15
|
-
<string>!.*/(\.[^/]*|CVS|_darcs|_MTN|\{arch\}|blib|.*~\.nib|.*\.(framework|app|pbproj|pbxproj|xcode(proj)?|bundle))$</string>
|
16
|
-
<key>selected</key>
|
17
|
-
<true/>
|
18
|
-
<key>sourceDirectory</key>
|
19
|
-
<string></string>
|
20
|
-
</dict>
|
21
|
-
</array>
|
22
|
-
<key>fileHierarchyDrawerWidth</key>
|
23
|
-
<integer>246</integer>
|
24
|
-
<key>metaData</key>
|
25
|
-
<dict>
|
26
|
-
<key>History.txt</key>
|
27
|
-
<dict>
|
28
|
-
<key>caret</key>
|
29
|
-
<dict>
|
30
|
-
<key>column</key>
|
31
|
-
<integer>0</integer>
|
32
|
-
<key>line</key>
|
33
|
-
<integer>10</integer>
|
34
|
-
</dict>
|
35
|
-
<key>firstVisibleColumn</key>
|
36
|
-
<integer>0</integer>
|
37
|
-
<key>firstVisibleLine</key>
|
38
|
-
<integer>0</integer>
|
39
|
-
</dict>
|
40
|
-
<key>lib/user-choices.rb</key>
|
41
|
-
<dict>
|
42
|
-
<key>caret</key>
|
43
|
-
<dict>
|
44
|
-
<key>column</key>
|
45
|
-
<integer>11</integer>
|
46
|
-
<key>line</key>
|
47
|
-
<integer>9</integer>
|
48
|
-
</dict>
|
49
|
-
<key>firstVisibleColumn</key>
|
50
|
-
<integer>0</integer>
|
51
|
-
<key>firstVisibleLine</key>
|
52
|
-
<integer>97</integer>
|
53
|
-
</dict>
|
54
|
-
<key>lib/user-choices/arglist-strategies.rb</key>
|
55
|
-
<dict>
|
56
|
-
<key>caret</key>
|
57
|
-
<dict>
|
58
|
-
<key>column</key>
|
59
|
-
<integer>5</integer>
|
60
|
-
<key>line</key>
|
61
|
-
<integer>160</integer>
|
62
|
-
</dict>
|
63
|
-
<key>firstVisibleColumn</key>
|
64
|
-
<integer>0</integer>
|
65
|
-
<key>firstVisibleLine</key>
|
66
|
-
<integer>111</integer>
|
67
|
-
</dict>
|
68
|
-
<key>lib/user-choices/builder.rb</key>
|
69
|
-
<dict>
|
70
|
-
<key>caret</key>
|
71
|
-
<dict>
|
72
|
-
<key>column</key>
|
73
|
-
<integer>53</integer>
|
74
|
-
<key>line</key>
|
75
|
-
<integer>56</integer>
|
76
|
-
</dict>
|
77
|
-
<key>firstVisibleColumn</key>
|
78
|
-
<integer>0</integer>
|
79
|
-
<key>firstVisibleLine</key>
|
80
|
-
<integer>0</integer>
|
81
|
-
</dict>
|
82
|
-
<key>lib/user-choices/command-line-source.rb</key>
|
83
|
-
<dict>
|
84
|
-
<key>caret</key>
|
85
|
-
<dict>
|
86
|
-
<key>column</key>
|
87
|
-
<integer>31</integer>
|
88
|
-
<key>line</key>
|
89
|
-
<integer>56</integer>
|
90
|
-
</dict>
|
91
|
-
<key>firstVisibleColumn</key>
|
92
|
-
<integer>0</integer>
|
93
|
-
<key>firstVisibleLine</key>
|
94
|
-
<integer>107</integer>
|
95
|
-
</dict>
|
96
|
-
<key>lib/user-choices/sources.rb</key>
|
97
|
-
<dict>
|
98
|
-
<key>caret</key>
|
99
|
-
<dict>
|
100
|
-
<key>column</key>
|
101
|
-
<integer>0</integer>
|
102
|
-
<key>line</key>
|
103
|
-
<integer>0</integer>
|
104
|
-
</dict>
|
105
|
-
<key>firstVisibleColumn</key>
|
106
|
-
<integer>0</integer>
|
107
|
-
<key>firstVisibleLine</key>
|
108
|
-
<integer>0</integer>
|
109
|
-
</dict>
|
110
|
-
<key>lib/user-choices/version.rb</key>
|
111
|
-
<dict>
|
112
|
-
<key>caret</key>
|
113
|
-
<dict>
|
114
|
-
<key>column</key>
|
115
|
-
<integer>18</integer>
|
116
|
-
<key>line</key>
|
117
|
-
<integer>1</integer>
|
118
|
-
</dict>
|
119
|
-
<key>firstVisibleColumn</key>
|
120
|
-
<integer>0</integer>
|
121
|
-
<key>firstVisibleLine</key>
|
122
|
-
<integer>0</integer>
|
123
|
-
</dict>
|
124
|
-
<key>test/builder-tests.rb</key>
|
125
|
-
<dict>
|
126
|
-
<key>caret</key>
|
127
|
-
<dict>
|
128
|
-
<key>column</key>
|
129
|
-
<integer>5</integer>
|
130
|
-
<key>line</key>
|
131
|
-
<integer>83</integer>
|
132
|
-
</dict>
|
133
|
-
<key>firstVisibleColumn</key>
|
134
|
-
<integer>0</integer>
|
135
|
-
<key>firstVisibleLine</key>
|
136
|
-
<integer>138</integer>
|
137
|
-
</dict>
|
138
|
-
<key>test/source-tests.rb</key>
|
139
|
-
<dict>
|
140
|
-
<key>caret</key>
|
141
|
-
<dict>
|
142
|
-
<key>column</key>
|
143
|
-
<integer>25</integer>
|
144
|
-
<key>line</key>
|
145
|
-
<integer>399</integer>
|
146
|
-
</dict>
|
147
|
-
<key>firstVisibleColumn</key>
|
148
|
-
<integer>0</integer>
|
149
|
-
<key>firstVisibleLine</key>
|
150
|
-
<integer>378</integer>
|
151
|
-
</dict>
|
152
|
-
</dict>
|
153
|
-
<key>openDocuments</key>
|
154
|
-
<array>
|
155
|
-
<string>lib/user-choices/command-line-source.rb</string>
|
156
|
-
<string>lib/user-choices/builder.rb</string>
|
157
|
-
<string>test/builder-tests.rb</string>
|
158
|
-
<string>test/source-tests.rb</string>
|
159
|
-
<string>History.txt</string>
|
160
|
-
<string>lib/user-choices.rb</string>
|
161
|
-
<string>lib/user-choices/version.rb</string>
|
162
|
-
<string>lib/user-choices/sources.rb</string>
|
163
|
-
<string>lib/user-choices/arglist-strategies.rb</string>
|
164
|
-
</array>
|
165
|
-
<key>showFileHierarchyDrawer</key>
|
166
|
-
<true/>
|
167
|
-
<key>windowFrame</key>
|
168
|
-
<string>{{8, 0}, {861, 778}}</string>
|
169
|
-
</dict>
|
170
|
-
</plist>
|