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.
Files changed (52) hide show
  1. data/LICENSE +1 -1
  2. data/README.md +328 -227
  3. data/lib/clive.rb +130 -50
  4. data/lib/clive/argument.rb +170 -0
  5. data/lib/clive/arguments.rb +139 -0
  6. data/lib/clive/arguments/parser.rb +210 -0
  7. data/lib/clive/base.rb +189 -0
  8. data/lib/clive/command.rb +342 -444
  9. data/lib/clive/error.rb +66 -0
  10. data/lib/clive/formatter.rb +57 -141
  11. data/lib/clive/formatter/colour.rb +37 -0
  12. data/lib/clive/formatter/plain.rb +172 -0
  13. data/lib/clive/option.rb +185 -75
  14. data/lib/clive/option/runner.rb +163 -0
  15. data/lib/clive/output.rb +141 -16
  16. data/lib/clive/parser.rb +180 -87
  17. data/lib/clive/struct_hash.rb +109 -0
  18. data/lib/clive/type.rb +117 -0
  19. data/lib/clive/type/definitions.rb +170 -0
  20. data/lib/clive/type/lookup.rb +23 -0
  21. data/lib/clive/version.rb +3 -3
  22. data/spec/clive/a_cli_spec.rb +245 -0
  23. data/spec/clive/argument_spec.rb +148 -0
  24. data/spec/clive/arguments/parser_spec.rb +35 -0
  25. data/spec/clive/arguments_spec.rb +191 -0
  26. data/spec/clive/command_spec.rb +276 -209
  27. data/spec/clive/formatter/colour_spec.rb +129 -0
  28. data/spec/clive/formatter/plain_spec.rb +129 -0
  29. data/spec/clive/option/runner_spec.rb +92 -0
  30. data/spec/clive/option_spec.rb +149 -23
  31. data/spec/clive/output_spec.rb +86 -2
  32. data/spec/clive/parser_spec.rb +201 -81
  33. data/spec/clive/struct_hash_spec.rb +82 -0
  34. data/spec/clive/type/definitions_spec.rb +312 -0
  35. data/spec/clive/type_spec.rb +107 -0
  36. data/spec/clive_spec.rb +60 -0
  37. data/spec/extras/expectations.rb +86 -0
  38. data/spec/extras/focus.rb +22 -0
  39. data/spec/helper.rb +35 -0
  40. metadata +56 -36
  41. data/lib/clive/bool.rb +0 -67
  42. data/lib/clive/exceptions.rb +0 -54
  43. data/lib/clive/flag.rb +0 -199
  44. data/lib/clive/switch.rb +0 -31
  45. data/lib/clive/tokens.rb +0 -141
  46. data/spec/clive/bool_spec.rb +0 -54
  47. data/spec/clive/flag_spec.rb +0 -117
  48. data/spec/clive/formatter_spec.rb +0 -108
  49. data/spec/clive/switch_spec.rb +0 -14
  50. data/spec/clive/tokens_spec.rb +0 -38
  51. data/spec/shared_specs.rb +0 -16
  52. data/spec/spec_helper.rb +0 -12
@@ -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
@@ -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
@@ -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
@@ -1,12 +0,0 @@
1
- if RUBY_VERSION >= "1.9"
2
- require 'duvet'
3
- Duvet.start :filter => 'clive/lib'
4
- end
5
-
6
- require 'rspec'
7
- require 'clive'
8
- require 'shared_specs'
9
-
10
- RSpec.configure do |config|
11
- config.color_enabled = true
12
- end