clive 0.8.1 → 1.0.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.
- data/LICENSE +1 -1
- data/README.md +328 -227
- data/lib/clive.rb +130 -50
- data/lib/clive/argument.rb +170 -0
- data/lib/clive/arguments.rb +139 -0
- data/lib/clive/arguments/parser.rb +210 -0
- data/lib/clive/base.rb +189 -0
- data/lib/clive/command.rb +342 -444
- data/lib/clive/error.rb +66 -0
- data/lib/clive/formatter.rb +57 -141
- data/lib/clive/formatter/colour.rb +37 -0
- data/lib/clive/formatter/plain.rb +172 -0
- data/lib/clive/option.rb +185 -75
- data/lib/clive/option/runner.rb +163 -0
- data/lib/clive/output.rb +141 -16
- data/lib/clive/parser.rb +180 -87
- data/lib/clive/struct_hash.rb +109 -0
- data/lib/clive/type.rb +117 -0
- data/lib/clive/type/definitions.rb +170 -0
- data/lib/clive/type/lookup.rb +23 -0
- data/lib/clive/version.rb +3 -3
- data/spec/clive/a_cli_spec.rb +245 -0
- data/spec/clive/argument_spec.rb +148 -0
- data/spec/clive/arguments/parser_spec.rb +35 -0
- data/spec/clive/arguments_spec.rb +191 -0
- data/spec/clive/command_spec.rb +276 -209
- data/spec/clive/formatter/colour_spec.rb +129 -0
- data/spec/clive/formatter/plain_spec.rb +129 -0
- data/spec/clive/option/runner_spec.rb +92 -0
- data/spec/clive/option_spec.rb +149 -23
- data/spec/clive/output_spec.rb +86 -2
- data/spec/clive/parser_spec.rb +201 -81
- data/spec/clive/struct_hash_spec.rb +82 -0
- data/spec/clive/type/definitions_spec.rb +312 -0
- data/spec/clive/type_spec.rb +107 -0
- data/spec/clive_spec.rb +60 -0
- data/spec/extras/expectations.rb +86 -0
- data/spec/extras/focus.rb +22 -0
- data/spec/helper.rb +35 -0
- metadata +56 -36
- data/lib/clive/bool.rb +0 -67
- data/lib/clive/exceptions.rb +0 -54
- data/lib/clive/flag.rb +0 -199
- data/lib/clive/switch.rb +0 -31
- data/lib/clive/tokens.rb +0 -141
- data/spec/clive/bool_spec.rb +0 -54
- data/spec/clive/flag_spec.rb +0 -117
- data/spec/clive/formatter_spec.rb +0 -108
- data/spec/clive/switch_spec.rb +0 -14
- data/spec/clive/tokens_spec.rb +0 -38
- data/spec/shared_specs.rb +0 -16
- data/spec/spec_helper.rb +0 -12
data/spec/clive/switch_spec.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Clive::Switch do
|
4
|
-
subject { Clive::Switch.new([:n, :names], "A description") { $stdout.puts "hi" } }
|
5
|
-
|
6
|
-
it_behaves_like "an option"
|
7
|
-
|
8
|
-
describe "#run" do
|
9
|
-
it "calls the block" do
|
10
|
-
$stdout.should_receive(:puts).with("hi")
|
11
|
-
subject.run
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
data/spec/clive/tokens_spec.rb
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Clive::Tokens do
|
4
|
-
|
5
|
-
subject { Clive::Tokens.new %w(word --long -sa) }
|
6
|
-
|
7
|
-
|
8
|
-
describe "#array" do
|
9
|
-
it "returns array of strings" do
|
10
|
-
subject.array.should == ["word", "--long", "-s", "-a"]
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
describe "#tokens" do
|
15
|
-
it "returns array of tokens" do
|
16
|
-
subject.tokens.should == [[:word, "word"], [:long, "long"], [:short, "s"], [:short, "a"]]
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
describe "#<<" do
|
21
|
-
subject { Clive::Tokens.new }
|
22
|
-
|
23
|
-
context "when adding token" do
|
24
|
-
it "adds as a string" do
|
25
|
-
subject << [:long, "test"]
|
26
|
-
subject.tokens.should == [[:long, "test"]]
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
context "when adding string" do
|
31
|
-
it "adds normally" do
|
32
|
-
subject << "--test"
|
33
|
-
subject.tokens.should == [[:long, "test"]]
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
end
|
data/spec/shared_specs.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
shared_examples_for "an option" do
|
2
|
-
|
3
|
-
describe "#names" do
|
4
|
-
specify { subject.names.should be_kind_of(Array) }
|
5
|
-
specify { subject.names.each {|i| i.should be_kind_of(String) } }
|
6
|
-
end
|
7
|
-
|
8
|
-
describe "#desc" do
|
9
|
-
specify { subject.desc.should be_kind_of(String) }
|
10
|
-
end
|
11
|
-
|
12
|
-
describe "#block" do
|
13
|
-
specify { subject.block.should be_kind_of(Proc) }
|
14
|
-
end
|
15
|
-
|
16
|
-
end
|