rubikon 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +12 -11
- data/Rakefile +4 -2
- data/lib/core_ext/object.rb +43 -0
- data/lib/core_ext/string.rb +8 -0
- data/lib/rubikon/application/base.rb +8 -9
- data/lib/rubikon/application/class_methods.rb +4 -2
- data/lib/rubikon/application/dsl_methods.rb +75 -62
- data/lib/rubikon/application/instance_methods.rb +106 -20
- data/lib/rubikon/application/sandbox.rb +70 -0
- data/lib/rubikon/command.rb +67 -23
- data/lib/rubikon/flag.rb +0 -8
- data/lib/rubikon/has_arguments.rb +182 -0
- data/lib/rubikon/option.rb +2 -9
- data/lib/rubikon/parameter.rb +16 -52
- data/lib/rubikon/progress_bar.rb +1 -1
- data/lib/rubikon.rb +11 -2
- data/samples/helloworld/hello_world.rb +69 -0
- data/test/{application_tests.rb → test_application.rb} +43 -5
- data/test/{command_tests.rb → test_command.rb} +19 -28
- data/test/{flag_tests.rb → test_flag.rb} +7 -5
- data/test/test_has_arguments.rb +99 -0
- data/test/test_helper.rb +1 -0
- data/test/test_option.rb +32 -0
- data/test/test_parameter.rb +21 -0
- data/test/{progress_bar_tests.rb → test_progress_bar.rb} +1 -1
- data/test/{throbber_tests.rb → test_throbber.rb} +3 -9
- data/test/testapps.rb +60 -1
- metadata +39 -17
- data/test/option_tests.rb +0 -75
data/test/option_tests.rb
DELETED
@@ -1,75 +0,0 @@
|
|
1
|
-
# This code is free software; you can redistribute it and/or modify it under
|
2
|
-
# the terms of the new BSD License.
|
3
|
-
#
|
4
|
-
# Copyright (c) 2010, Sebastian Staudt
|
5
|
-
|
6
|
-
require 'test_helper'
|
7
|
-
|
8
|
-
class FlagTests < Test::Unit::TestCase
|
9
|
-
|
10
|
-
context 'A Rubikon option' do
|
11
|
-
|
12
|
-
should 'be a Parameter' do
|
13
|
-
assert Option.included_modules.include?(Parameter)
|
14
|
-
assert Option.new(:test).is_a?(Parameter)
|
15
|
-
end
|
16
|
-
|
17
|
-
should 'call its code block if it is activated' do
|
18
|
-
block_run = false
|
19
|
-
option = Option.new :test do
|
20
|
-
block_run = true
|
21
|
-
end
|
22
|
-
option.active!
|
23
|
-
assert option.active?
|
24
|
-
assert block_run
|
25
|
-
end
|
26
|
-
|
27
|
-
should 'have arguments' do
|
28
|
-
option = Option.new :test
|
29
|
-
assert option.respond_to?(:arg_count)
|
30
|
-
assert option.respond_to?(:args)
|
31
|
-
end
|
32
|
-
|
33
|
-
should 'only have required arguments if argument count is > 0' do
|
34
|
-
option = Option.new :test, 2
|
35
|
-
assert !option.args_full?
|
36
|
-
assert option.more_args?
|
37
|
-
option << 'argument'
|
38
|
-
assert_equal %w{argument}, option.args
|
39
|
-
assert_raise MissingArgumentError do
|
40
|
-
option.check_args
|
41
|
-
end
|
42
|
-
option << 'argument'
|
43
|
-
assert option.args_full?
|
44
|
-
assert !option.more_args?
|
45
|
-
assert_equal %w{argument argument}, option.args
|
46
|
-
assert_raise ExtraArgumentError do
|
47
|
-
option << 'argument'
|
48
|
-
end
|
49
|
-
assert_equal %w{argument argument}, option.args
|
50
|
-
end
|
51
|
-
|
52
|
-
should 'have required and optional arguments if argument count is < 0' do
|
53
|
-
option = Option.new :test, -1
|
54
|
-
assert !option.args_full?
|
55
|
-
assert option.more_args?
|
56
|
-
assert_raise MissingArgumentError do
|
57
|
-
option.check_args
|
58
|
-
end
|
59
|
-
option << 'argument'
|
60
|
-
assert option.args_full?
|
61
|
-
assert option.more_args?
|
62
|
-
assert_equal %w{argument}, option.args
|
63
|
-
end
|
64
|
-
|
65
|
-
should 'only have optional arguments if argument count is 0' do
|
66
|
-
option = Option.new :test, 0
|
67
|
-
assert option.args_full?
|
68
|
-
assert option.more_args?
|
69
|
-
option << 'argument'
|
70
|
-
assert_equal %w{argument}, option.args
|
71
|
-
end
|
72
|
-
|
73
|
-
end
|
74
|
-
|
75
|
-
end
|