user-choices 1.1.5 → 1.1.6
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -1
- data/Rakefile +7 -61
- data/examples/tutorial/css/main.css +1 -1
- data/examples/tutorial/index.html +23 -1
- data/lib/user-choices/conversions.rb +12 -1
- data/lib/user-choices/version.rb +1 -1
- data/test/conversion-tests.rb +17 -2
- metadata +3 -3
data/History.txt
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
Version 1.1.6
|
2
|
+
* Allow a :string type conversion (user request). It does nothing.
|
3
|
+
|
1
4
|
Version 1.1.5
|
2
5
|
* Improved example files so that they don't include old S4TUtils load-path
|
3
6
|
setting. Not needed by the people who'll use them.
|
@@ -41,4 +44,4 @@ Version 1.1.0
|
|
41
44
|
* A tutorial.
|
42
45
|
|
43
46
|
Version 1.0.0
|
44
|
-
* Version from _Everyday Scripting with Ruby_
|
47
|
+
* Version from _Everyday Scripting with Ruby_
|
data/Rakefile
CHANGED
@@ -4,13 +4,11 @@
|
|
4
4
|
# Copyright (c) 2007. All rights reserved.
|
5
5
|
|
6
6
|
require 'hoe'
|
7
|
-
|
7
|
+
$:.unshift(File.join(Dir.pwd, "lib"))
|
8
|
+
require 'user-choices/version'
|
8
9
|
|
9
10
|
PROJECT='user-choices'
|
10
11
|
THIS_RELEASE=UserChoices::Version
|
11
|
-
ROOT = "svn+ssh://marick@rubyforge.org/var/svn/#{PROJECT}"
|
12
|
-
ALL_EXPORTS="#{ENV['HOME']}/tmp/exports"
|
13
|
-
PROJECT_EXPORTS = "#{ALL_EXPORTS}/#{PROJECT}"
|
14
12
|
|
15
13
|
|
16
14
|
Hoe.new(PROJECT, THIS_RELEASE) do |p|
|
@@ -40,60 +38,8 @@ task 'slow' do
|
|
40
38
|
S4tUtils.run_particular_tests('test', 'slow')
|
41
39
|
end
|
42
40
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
end
|
49
|
-
|
50
|
-
desc "Upload all the web pages"
|
51
|
-
task 'upload_pages' do | task |
|
52
|
-
assert_in_exports task.name
|
53
|
-
exec = "scp -r examples/tutorial/* marick@rubyforge.org:/var/www/gforge-projects/#{PROJECT}/"
|
54
|
-
puts exec
|
55
|
-
system(exec)
|
56
|
-
end
|
57
|
-
|
58
|
-
desc "Tag release with current version."
|
59
|
-
task 'tag_release' do
|
60
|
-
from = "#{ROOT}/trunk"
|
61
|
-
to = "#{ROOT}/tags/rel-#{THIS_RELEASE}"
|
62
|
-
message = "Release #{THIS_RELEASE}"
|
63
|
-
exec = "svn copy -m '#{message}' #{from} #{to}"
|
64
|
-
puts exec
|
65
|
-
system(exec)
|
66
|
-
end
|
67
|
-
|
68
|
-
desc "Export to ~/tmp/exports/#{PROJECT}"
|
69
|
-
task 'export' do
|
70
|
-
Dir.chdir(ALL_EXPORTS) do
|
71
|
-
rm_rf PROJECT
|
72
|
-
exec = "svn export #{ROOT}/trunk #{PROJECT}"
|
73
|
-
puts exec
|
74
|
-
system exec
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
def step(name)
|
79
|
-
STDOUT.puts "** #{name} **"
|
80
|
-
STDOUT.puts `rake #{name}`
|
81
|
-
STDOUT.print 'OK? > '
|
82
|
-
exit if STDIN.readline =~ /[nN]/
|
83
|
-
end
|
84
|
-
|
85
|
-
desc "Complete release of everything - asks for confirmation after steps"
|
86
|
-
# Because in Ruby 1.8.6, Rake doesn't notice subtask failures.
|
87
|
-
task 'release_everything' do
|
88
|
-
step 'check_manifest'
|
89
|
-
step 'test'
|
90
|
-
step 'export'
|
91
|
-
Dir.chdir("#{ALL_EXPORTS}/#{PROJECT}") do
|
92
|
-
puts "Working in #{Dir.pwd}"
|
93
|
-
step 'upload_pages'
|
94
|
-
step 'publish_docs'
|
95
|
-
ENV['VERSION'] = THIS_RELEASE
|
96
|
-
step 'release'
|
97
|
-
end
|
98
|
-
step 'tag_release'
|
99
|
-
end
|
41
|
+
require 's4t-utils/hoelike'
|
42
|
+
HoeLike.new(:project => PROJECT, :this_release => THIS_RELEASE,
|
43
|
+
:login => "marick@rubyforge.org",
|
44
|
+
:web_site_root => 'examples/tutorial',
|
45
|
+
:export_root => "#{S4tUtils.find_home}/tmp/exports")
|
@@ -24,6 +24,7 @@
|
|
24
24
|
<li id="current"><a href="index.html">Home</a></li>
|
25
25
|
<li><a href="http://user-choices.rubyforge.org/rdoc/">RDoc</a></li>
|
26
26
|
<li><a href="http://rubyforge.org/frs/?group_id=4192">Download</a></li>
|
27
|
+
<li><a href="http://rubyforge.org/mail/?group_id=4192">Mailing Lists</a></li>
|
27
28
|
</ul>
|
28
29
|
</div>
|
29
30
|
</div>
|
@@ -340,8 +341,19 @@ if $0 == __FILE__ <br />
|
|
340
341
|
<h3><a name="keywordargs"/>3.1 Keyword arguments for <code>add_choice</code></a></h3>
|
341
342
|
<ul>
|
342
343
|
<li><p>
|
343
|
-
The <b><font style="color: #800020;">:type</font></b>
|
344
|
+
The <b><font style="color: #800020;">:type</font></b>
|
345
|
+
keyword describes type checking and conversion that
|
346
|
+
should be done. If no <font
|
347
|
+
style="color: #800020;">:type</font> argument is
|
348
|
+
given, the choice stays a string.
|
344
349
|
</p>
|
350
|
+
|
351
|
+
<p>
|
352
|
+
Default choices are handled generously. Suppose a particular
|
353
|
+
choice is to be an integer. You can specify the default value as
|
354
|
+
either the string <code>"1"</code> (in which case it will be converted to an
|
355
|
+
integer) or the integer <code>1</code> (in which case it will be left alone).
|
356
|
+
</p>
|
345
357
|
|
346
358
|
<p>
|
347
359
|
A <code>StandardError</code> is raised if the conversion can't be done.
|
@@ -360,6 +372,14 @@ if $0 == __FILE__ <br />
|
|
360
372
|
Convert the string into either <code>true</code> or <code>false</code>. The string must be one of "true" or "false" (case-insensitive).
|
361
373
|
</p></dd>
|
362
374
|
|
375
|
+
<dt><font style="color: #800020;">:type</font>
|
376
|
+
=> <i>:string</i></dt>
|
377
|
+
<dd><p>
|
378
|
+
Leave the string alone. Since that's
|
379
|
+
the default behavior, this case is only for
|
380
|
+
convenience.
|
381
|
+
</p></dd>
|
382
|
+
|
363
383
|
<dt><font style="color: #800020;">:type</font> => <b><font style="color: #800020;">[:string]</font></b></dt>
|
364
384
|
|
365
385
|
<dd><p>
|
@@ -371,6 +391,8 @@ if $0 == __FILE__ <br />
|
|
371
391
|
The value chosen must be one of the given strings. There's no conversion.
|
372
392
|
</p></dd>
|
373
393
|
|
394
|
+
|
395
|
+
|
374
396
|
</dl>
|
375
397
|
</li>
|
376
398
|
|
@@ -36,7 +36,18 @@ module UserChoices
|
|
36
36
|
def convert(value); value; end # Some conversions are just for error-checking
|
37
37
|
def does_length_check?; false; end
|
38
38
|
end
|
39
|
-
|
39
|
+
|
40
|
+
class NoOpConversion < Conversion # :nodoc:
|
41
|
+
def self.described_by?(conversion_tag)
|
42
|
+
conversion_tag == :string
|
43
|
+
end
|
44
|
+
|
45
|
+
def description; "a string"; end
|
46
|
+
def suitable?(actual); true; end
|
47
|
+
def convert(value); value; end
|
48
|
+
end
|
49
|
+
|
50
|
+
|
40
51
|
class ConversionToInteger < Conversion # :nodoc:
|
41
52
|
def self.described_by?(conversion_tag)
|
42
53
|
conversion_tag == :integer
|
data/lib/user-choices/version.rb
CHANGED
data/test/conversion-tests.rb
CHANGED
@@ -21,10 +21,11 @@ class TestDefaultsAndTypes < Test::Unit::TestCase
|
|
21
21
|
Conversion.record_for(["one", "two"], start)
|
22
22
|
Conversion.record_for({:length => 1}, start)
|
23
23
|
Conversion.record_for({:length => 1..2}, start)
|
24
|
+
Conversion.record_for(:string, start)
|
24
25
|
|
25
26
|
assert_equal([ConversionToInteger, ConversionToBoolean,
|
26
27
|
SplittingConversion, ChoiceCheckingConversion,
|
27
|
-
ExactLengthConversion, RangeLengthConversion],
|
28
|
+
ExactLengthConversion, RangeLengthConversion, NoOpConversion],
|
28
29
|
start.collect { |c| c.class })
|
29
30
|
end
|
30
31
|
|
@@ -33,7 +34,21 @@ class TestDefaultsAndTypes < Test::Unit::TestCase
|
|
33
34
|
Conversion.record_for(nil, start)
|
34
35
|
assert_equal([], start)
|
35
36
|
end
|
36
|
-
|
37
|
+
|
38
|
+
def test_string_conversion_checking
|
39
|
+
nop = Conversion.for(:string)
|
40
|
+
assert_true(nop.suitable?("hello"))
|
41
|
+
assert_true(nop.suitable?(1)) # Truly does no checking.
|
42
|
+
assert_equal('a string', nop.description)
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_string_conversion
|
46
|
+
nop = Conversion.for(:string)
|
47
|
+
assert_equal("12", nop.convert("12"))
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
|
37
52
|
def test_integer_conversion_checking
|
38
53
|
c2i = Conversion.for(:integer)
|
39
54
|
assert_true(c2i.suitable?("034"))
|
metadata
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.9.
|
2
|
+
rubygems_version: 0.9.4
|
3
3
|
specification_version: 1
|
4
4
|
name: user-choices
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 1.1.
|
7
|
-
date: 2007-
|
6
|
+
version: 1.1.6
|
7
|
+
date: 2007-11-19 00:00:00 -06:00
|
8
8
|
summary: Unified interface to command-line, environment, and configuration files.
|
9
9
|
require_paths:
|
10
10
|
- lib
|