thor 0.16.0 → 0.17.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. data/.rspec +1 -0
  2. data/.travis.yml +2 -1
  3. data/CHANGELOG.rdoc +8 -0
  4. data/Gemfile +12 -8
  5. data/lib/thor.rb +79 -10
  6. data/lib/thor/actions.rb +13 -13
  7. data/lib/thor/actions/directory.rb +29 -10
  8. data/lib/thor/actions/file_manipulation.rb +8 -2
  9. data/lib/thor/base.rb +24 -11
  10. data/lib/thor/core_ext/hash_with_indifferent_access.rb +5 -0
  11. data/lib/thor/group.rb +5 -5
  12. data/lib/thor/parser/options.rb +63 -25
  13. data/lib/thor/rake_compat.rb +3 -2
  14. data/lib/thor/runner.rb +1 -1
  15. data/lib/thor/shell/basic.rb +16 -16
  16. data/lib/thor/shell/color.rb +9 -9
  17. data/lib/thor/shell/html.rb +9 -9
  18. data/lib/thor/task.rb +2 -2
  19. data/lib/thor/version.rb +1 -1
  20. data/spec/actions/create_file_spec.rb +30 -30
  21. data/spec/actions/create_link_spec.rb +12 -12
  22. data/spec/actions/directory_spec.rb +34 -27
  23. data/spec/actions/empty_directory_spec.rb +16 -16
  24. data/spec/actions/file_manipulation_spec.rb +62 -50
  25. data/spec/actions/inject_into_file_spec.rb +18 -18
  26. data/spec/actions_spec.rb +56 -56
  27. data/spec/base_spec.rb +69 -69
  28. data/spec/core_ext/hash_with_indifferent_access_spec.rb +19 -14
  29. data/spec/core_ext/ordered_hash_spec.rb +29 -29
  30. data/spec/exit_condition_spec.rb +3 -3
  31. data/spec/fixtures/preserve/script.sh +3 -0
  32. data/spec/fixtures/script.thor +5 -0
  33. data/spec/group_spec.rb +55 -55
  34. data/spec/invocation_spec.rb +26 -26
  35. data/spec/parser/argument_spec.rb +12 -12
  36. data/spec/parser/arguments_spec.rb +12 -12
  37. data/spec/parser/option_spec.rb +47 -47
  38. data/spec/parser/options_spec.rb +137 -72
  39. data/spec/rake_compat_spec.rb +11 -11
  40. data/spec/register_spec.rb +70 -8
  41. data/spec/runner_spec.rb +38 -38
  42. data/spec/shell/basic_spec.rb +49 -37
  43. data/spec/shell/color_spec.rb +13 -13
  44. data/spec/shell/html_spec.rb +3 -3
  45. data/spec/shell_spec.rb +7 -7
  46. data/spec/spec_helper.rb +4 -0
  47. data/spec/task_spec.rb +11 -11
  48. data/spec/thor_spec.rb +161 -91
  49. data/spec/util_spec.rb +42 -42
  50. data/thor.gemspec +1 -7
  51. metadata +8 -118
  52. data/lib/thor/core_ext/dir_escape.rb +0 -0
data/spec/util_spec.rb CHANGED
@@ -9,112 +9,112 @@ end
9
9
  describe Thor::Util do
10
10
  describe "#find_by_namespace" do
11
11
  it "returns 'default' if no namespace is given" do
12
- Thor::Util.find_by_namespace('').should == Scripts::MyDefaults
12
+ expect(Thor::Util.find_by_namespace('')).to eq(Scripts::MyDefaults)
13
13
  end
14
14
 
15
15
  it "adds 'default' if namespace starts with :" do
16
- Thor::Util.find_by_namespace(':child').should == Scripts::ChildDefault
16
+ expect(Thor::Util.find_by_namespace(':child')).to eq(Scripts::ChildDefault)
17
17
  end
18
18
 
19
19
  it "returns nil if the namespace can't be found" do
20
- Thor::Util.find_by_namespace('thor:core_ext:ordered_hash').should be_nil
20
+ expect(Thor::Util.find_by_namespace('thor:core_ext:ordered_hash')).to be_nil
21
21
  end
22
22
 
23
23
  it "returns a class if it matches the namespace" do
24
- Thor::Util.find_by_namespace('app:broken:counter').should == BrokenCounter
24
+ expect(Thor::Util.find_by_namespace('app:broken:counter')).to eq(BrokenCounter)
25
25
  end
26
26
 
27
27
  it "matches classes default namespace" do
28
- Thor::Util.find_by_namespace('scripts:my_script').should == Scripts::MyScript
28
+ expect(Thor::Util.find_by_namespace('scripts:my_script')).to eq(Scripts::MyScript)
29
29
  end
30
30
  end
31
31
 
32
32
  describe "#namespace_from_thor_class" do
33
33
  it "replaces constant nesting with task namespacing" do
34
- Thor::Util.namespace_from_thor_class("Foo::Bar::Baz").should == "foo:bar:baz"
34
+ expect(Thor::Util.namespace_from_thor_class("Foo::Bar::Baz")).to eq("foo:bar:baz")
35
35
  end
36
36
 
37
37
  it "snake-cases component strings" do
38
- Thor::Util.namespace_from_thor_class("FooBar::BarBaz::BazBoom").should == "foo_bar:bar_baz:baz_boom"
38
+ expect(Thor::Util.namespace_from_thor_class("FooBar::BarBaz::BazBoom")).to eq("foo_bar:bar_baz:baz_boom")
39
39
  end
40
40
 
41
41
  it "accepts class and module objects" do
42
- Thor::Util.namespace_from_thor_class(Thor::CoreExt::OrderedHash).should == "thor:core_ext:ordered_hash"
43
- Thor::Util.namespace_from_thor_class(Thor::Util).should == "thor:util"
42
+ expect(Thor::Util.namespace_from_thor_class(Thor::CoreExt::OrderedHash)).to eq("thor:core_ext:ordered_hash")
43
+ expect(Thor::Util.namespace_from_thor_class(Thor::Util)).to eq("thor:util")
44
44
  end
45
45
 
46
46
  it "removes Thor::Sandbox namespace" do
47
- Thor::Util.namespace_from_thor_class("Thor::Sandbox::Package").should == "package"
47
+ expect(Thor::Util.namespace_from_thor_class("Thor::Sandbox::Package")).to eq("package")
48
48
  end
49
49
  end
50
50
 
51
51
  describe "#namespaces_in_content" do
52
52
  it "returns an array of names of constants defined in the string" do
53
53
  list = Thor::Util.namespaces_in_content("class Foo; class Bar < Thor; end; end; class Baz; class Bat; end; end")
54
- list.should include("foo:bar")
55
- list.should_not include("bar:bat")
54
+ expect(list).to include("foo:bar")
55
+ expect(list).not_to include("bar:bat")
56
56
  end
57
57
 
58
58
  it "doesn't put the newly-defined constants in the enclosing namespace" do
59
59
  Thor::Util.namespaces_in_content("class Blat; end")
60
- defined?(Blat).should_not be
61
- defined?(Thor::Sandbox::Blat).should be
60
+ expect(defined?(Blat)).not_to be
61
+ expect(defined?(Thor::Sandbox::Blat)).to be
62
62
  end
63
63
  end
64
64
 
65
65
  describe "#snake_case" do
66
66
  it "preserves no-cap strings" do
67
- Thor::Util.snake_case("foo").should == "foo"
68
- Thor::Util.snake_case("foo_bar").should == "foo_bar"
67
+ expect(Thor::Util.snake_case("foo")).to eq("foo")
68
+ expect(Thor::Util.snake_case("foo_bar")).to eq("foo_bar")
69
69
  end
70
70
 
71
71
  it "downcases all-caps strings" do
72
- Thor::Util.snake_case("FOO").should == "foo"
73
- Thor::Util.snake_case("FOO_BAR").should == "foo_bar"
72
+ expect(Thor::Util.snake_case("FOO")).to eq("foo")
73
+ expect(Thor::Util.snake_case("FOO_BAR")).to eq("foo_bar")
74
74
  end
75
75
 
76
76
  it "downcases initial-cap strings" do
77
- Thor::Util.snake_case("Foo").should == "foo"
77
+ expect(Thor::Util.snake_case("Foo")).to eq("foo")
78
78
  end
79
79
 
80
80
  it "replaces camel-casing with underscores" do
81
- Thor::Util.snake_case("FooBarBaz").should == "foo_bar_baz"
82
- Thor::Util.snake_case("Foo_BarBaz").should == "foo_bar_baz"
81
+ expect(Thor::Util.snake_case("FooBarBaz")).to eq("foo_bar_baz")
82
+ expect(Thor::Util.snake_case("Foo_BarBaz")).to eq("foo_bar_baz")
83
83
  end
84
84
 
85
85
  it "places underscores between multiple capitals" do
86
- Thor::Util.snake_case("ABClass").should == "a_b_class"
86
+ expect(Thor::Util.snake_case("ABClass")).to eq("a_b_class")
87
87
  end
88
88
  end
89
89
 
90
90
  describe "#find_class_and_task_by_namespace" do
91
91
  it "returns a Thor::Group class if full namespace matches" do
92
- Thor::Util.find_class_and_task_by_namespace("my_counter").should == [MyCounter, nil]
92
+ expect(Thor::Util.find_class_and_task_by_namespace("my_counter")).to eq([MyCounter, nil])
93
93
  end
94
94
 
95
95
  it "returns a Thor class if full namespace matches" do
96
- Thor::Util.find_class_and_task_by_namespace("thor").should == [Thor, nil]
96
+ expect(Thor::Util.find_class_and_task_by_namespace("thor")).to eq([Thor, nil])
97
97
  end
98
98
 
99
99
  it "returns a Thor class and the task name" do
100
- Thor::Util.find_class_and_task_by_namespace("thor:help").should == [Thor, "help"]
100
+ expect(Thor::Util.find_class_and_task_by_namespace("thor:help")).to eq([Thor, "help"])
101
101
  end
102
102
 
103
103
  it "falls back in the namespace:task look up even if a full namespace does not match" do
104
104
  Thor.const_set(:Help, Module.new)
105
- Thor::Util.find_class_and_task_by_namespace("thor:help").should == [Thor, "help"]
105
+ expect(Thor::Util.find_class_and_task_by_namespace("thor:help")).to eq([Thor, "help"])
106
106
  Thor.send :remove_const, :Help
107
107
  end
108
108
 
109
109
  it "falls back on the default namespace class if nothing else matches" do
110
- Thor::Util.find_class_and_task_by_namespace("test").should == [Scripts::MyDefaults, "test"]
110
+ expect(Thor::Util.find_class_and_task_by_namespace("test")).to eq([Scripts::MyDefaults, "test"])
111
111
  end
112
112
  end
113
113
 
114
114
  describe "#thor_classes_in" do
115
115
  it "returns thor classes inside the given class" do
116
- Thor::Util.thor_classes_in(MyScript).should == [MyScript::AnotherScript]
117
- Thor::Util.thor_classes_in(MyScript::AnotherScript).should be_empty
116
+ expect(Thor::Util.thor_classes_in(MyScript)).to eq([MyScript::AnotherScript])
117
+ expect(Thor::Util.thor_classes_in(MyScript::AnotherScript)).to be_empty
118
118
  end
119
119
  end
120
120
 
@@ -125,14 +125,14 @@ describe Thor::Util do
125
125
  end
126
126
 
127
127
  it "returns the user path if none variable is set on the environment" do
128
- Thor::Util.user_home.should == File.expand_path("~")
128
+ expect(Thor::Util.user_home).to eq(File.expand_path("~"))
129
129
  end
130
130
 
131
131
  it "returns the *unix system path if file cannot be expanded and separator does not exist" do
132
132
  File.should_receive(:expand_path).with("~").and_raise(RuntimeError)
133
133
  previous_value = File::ALT_SEPARATOR
134
134
  capture(:stderr){ File.const_set(:ALT_SEPARATOR, false) }
135
- Thor::Util.user_home.should == "/"
135
+ expect(Thor::Util.user_home).to eq("/")
136
136
  capture(:stderr){ File.const_set(:ALT_SEPARATOR, previous_value) }
137
137
  end
138
138
 
@@ -140,24 +140,24 @@ describe Thor::Util do
140
140
  File.should_receive(:expand_path).with("~").and_raise(RuntimeError)
141
141
  previous_value = File::ALT_SEPARATOR
142
142
  capture(:stderr){ File.const_set(:ALT_SEPARATOR, true) }
143
- Thor::Util.user_home.should == "C:/"
143
+ expect(Thor::Util.user_home).to eq("C:/")
144
144
  capture(:stderr){ File.const_set(:ALT_SEPARATOR, previous_value) }
145
145
  end
146
146
 
147
147
  it "returns HOME/.thor if set" do
148
148
  ENV.stub!(:[]).with("HOME").and_return("/home/user/")
149
- Thor::Util.user_home.should == "/home/user/"
149
+ expect(Thor::Util.user_home).to eq("/home/user/")
150
150
  end
151
151
 
152
152
  it "returns path with HOMEDRIVE and HOMEPATH if set" do
153
153
  ENV.stub!(:[]).with("HOMEDRIVE").and_return("D:/")
154
154
  ENV.stub!(:[]).with("HOMEPATH").and_return("Documents and Settings/James")
155
- Thor::Util.user_home.should == "D:/Documents and Settings/James"
155
+ expect(Thor::Util.user_home).to eq("D:/Documents and Settings/James")
156
156
  end
157
157
 
158
158
  it "returns APPDATA/.thor if set" do
159
159
  ENV.stub!(:[]).with("APPDATA").and_return("/home/user/")
160
- Thor::Util.user_home.should == "/home/user/"
160
+ expect(Thor::Util.user_home).to eq("/home/user/")
161
161
  end
162
162
  end
163
163
 
@@ -170,27 +170,27 @@ describe Thor::Util do
170
170
  it "escapes globs in path" do
171
171
  ENV.stub!(:[]).with("HOME").and_return("/home/user{1}/")
172
172
  Dir.should_receive(:[]).with("/home/user\\{1\\}/.thor/*").and_return([])
173
- Thor::Util.thor_root_glob.should == []
173
+ expect(Thor::Util.thor_root_glob).to eq([])
174
174
  end
175
175
  end
176
176
 
177
177
  describe "#globs_for" do
178
178
  it "escapes globs in path" do
179
- Thor::Util.globs_for("/home/apps{1}").should == [
179
+ expect(Thor::Util.globs_for("/home/apps{1}")).to eq([
180
180
  "/home/apps\\{1\\}/Thorfile",
181
181
  "/home/apps\\{1\\}/*.thor",
182
182
  "/home/apps\\{1\\}/tasks/*.thor",
183
183
  "/home/apps\\{1\\}/lib/tasks/*.thor"
184
- ]
184
+ ])
185
185
  end
186
186
  end
187
187
 
188
188
  describe "#escape_globs" do
189
189
  it "escapes ? * { } [ ] glob characters" do
190
- Thor::Util.escape_globs("apps?").should == "apps\\?"
191
- Thor::Util.escape_globs("apps*").should == "apps\\*"
192
- Thor::Util.escape_globs("apps {1}").should == "apps \\{1\\}"
193
- Thor::Util.escape_globs("apps [1]").should == "apps \\[1\\]"
190
+ expect(Thor::Util.escape_globs("apps?")).to eq("apps\\?")
191
+ expect(Thor::Util.escape_globs("apps*")).to eq("apps\\*")
192
+ expect(Thor::Util.escape_globs("apps {1}")).to eq("apps \\{1\\}")
193
+ expect(Thor::Util.escape_globs("apps [1]")).to eq("apps \\[1\\]")
194
194
  end
195
195
  end
196
196
  end
data/thor.gemspec CHANGED
@@ -2,13 +2,6 @@
2
2
  require File.expand_path('../lib/thor/version', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
- s.add_development_dependency 'bundler', '~> 1.0'
6
- s.add_development_dependency 'fakeweb', '~> 1.3'
7
- s.add_development_dependency 'rake', '~> 0.9'
8
- s.add_development_dependency 'rdoc', '~> 3.9'
9
- s.add_development_dependency 'rspec', '~> 2.3'
10
- s.add_development_dependency 'simplecov', '~> 0.4'
11
- s.add_development_dependency 'childlabor'
12
5
  s.authors = ['Yehuda Katz', 'José Valim']
13
6
  s.description = %q{A scripting framework that replaces rake, sake and rubigen}
14
7
  s.email = 'ruby-thor@googlegroups.com'
@@ -16,6 +9,7 @@ Gem::Specification.new do |s|
16
9
  s.extra_rdoc_files = ['CHANGELOG.rdoc', 'LICENSE.md', 'README.md', 'Thorfile']
17
10
  s.files = `git ls-files`.split("\n")
18
11
  s.homepage = 'http://whatisthor.com/'
12
+ s.licenses = ['MIT']
19
13
  s.name = 'thor'
20
14
  s.rdoc_options = ['--charset=UTF-8']
21
15
  s.require_paths = ['lib']
metadata CHANGED
@@ -1,8 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.0
5
4
  prerelease:
5
+ version: 0.17.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Yehuda Katz
@@ -10,120 +10,8 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-08-14 00:00:00.000000000 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
16
- name: bundler
17
- requirement: !ruby/object:Gem::Requirement
18
- none: false
19
- requirements:
20
- - - ~>
21
- - !ruby/object:Gem::Version
22
- version: '1.0'
23
- type: :development
24
- prerelease: false
25
- version_requirements: !ruby/object:Gem::Requirement
26
- none: false
27
- requirements:
28
- - - ~>
29
- - !ruby/object:Gem::Version
30
- version: '1.0'
31
- - !ruby/object:Gem::Dependency
32
- name: fakeweb
33
- requirement: !ruby/object:Gem::Requirement
34
- none: false
35
- requirements:
36
- - - ~>
37
- - !ruby/object:Gem::Version
38
- version: '1.3'
39
- type: :development
40
- prerelease: false
41
- version_requirements: !ruby/object:Gem::Requirement
42
- none: false
43
- requirements:
44
- - - ~>
45
- - !ruby/object:Gem::Version
46
- version: '1.3'
47
- - !ruby/object:Gem::Dependency
48
- name: rake
49
- requirement: !ruby/object:Gem::Requirement
50
- none: false
51
- requirements:
52
- - - ~>
53
- - !ruby/object:Gem::Version
54
- version: '0.9'
55
- type: :development
56
- prerelease: false
57
- version_requirements: !ruby/object:Gem::Requirement
58
- none: false
59
- requirements:
60
- - - ~>
61
- - !ruby/object:Gem::Version
62
- version: '0.9'
63
- - !ruby/object:Gem::Dependency
64
- name: rdoc
65
- requirement: !ruby/object:Gem::Requirement
66
- none: false
67
- requirements:
68
- - - ~>
69
- - !ruby/object:Gem::Version
70
- version: '3.9'
71
- type: :development
72
- prerelease: false
73
- version_requirements: !ruby/object:Gem::Requirement
74
- none: false
75
- requirements:
76
- - - ~>
77
- - !ruby/object:Gem::Version
78
- version: '3.9'
79
- - !ruby/object:Gem::Dependency
80
- name: rspec
81
- requirement: !ruby/object:Gem::Requirement
82
- none: false
83
- requirements:
84
- - - ~>
85
- - !ruby/object:Gem::Version
86
- version: '2.3'
87
- type: :development
88
- prerelease: false
89
- version_requirements: !ruby/object:Gem::Requirement
90
- none: false
91
- requirements:
92
- - - ~>
93
- - !ruby/object:Gem::Version
94
- version: '2.3'
95
- - !ruby/object:Gem::Dependency
96
- name: simplecov
97
- requirement: !ruby/object:Gem::Requirement
98
- none: false
99
- requirements:
100
- - - ~>
101
- - !ruby/object:Gem::Version
102
- version: '0.4'
103
- type: :development
104
- prerelease: false
105
- version_requirements: !ruby/object:Gem::Requirement
106
- none: false
107
- requirements:
108
- - - ~>
109
- - !ruby/object:Gem::Version
110
- version: '0.4'
111
- - !ruby/object:Gem::Dependency
112
- name: childlabor
113
- requirement: !ruby/object:Gem::Requirement
114
- none: false
115
- requirements:
116
- - - ! '>='
117
- - !ruby/object:Gem::Version
118
- version: '0'
119
- type: :development
120
- prerelease: false
121
- version_requirements: !ruby/object:Gem::Requirement
122
- none: false
123
- requirements:
124
- - - ! '>='
125
- - !ruby/object:Gem::Version
126
- version: '0'
13
+ date: 2013-01-24 00:00:00.000000000 Z
14
+ dependencies: []
127
15
  description: A scripting framework that replaces rake, sake and rubigen
128
16
  email: ruby-thor@googlegroups.com
129
17
  executables:
@@ -156,7 +44,6 @@ files:
156
44
  - lib/thor/actions/file_manipulation.rb
157
45
  - lib/thor/actions/inject_into_file.rb
158
46
  - lib/thor/base.rb
159
- - lib/thor/core_ext/dir_escape.rb
160
47
  - lib/thor/core_ext/file_binary_read.rb
161
48
  - lib/thor/core_ext/hash_with_indifferent_access.rb
162
49
  - lib/thor/core_ext/ordered_hash.rb
@@ -203,6 +90,7 @@ files:
203
90
  - spec/fixtures/group.thor
204
91
  - spec/fixtures/invoke.thor
205
92
  - spec/fixtures/path with spaces
93
+ - spec/fixtures/preserve/script.sh
206
94
  - spec/fixtures/script.thor
207
95
  - spec/fixtures/task.thor
208
96
  - spec/group_spec.rb
@@ -224,7 +112,8 @@ files:
224
112
  - spec/util_spec.rb
225
113
  - thor.gemspec
226
114
  homepage: http://whatisthor.com/
227
- licenses: []
115
+ licenses:
116
+ - MIT
228
117
  post_install_message:
229
118
  rdoc_options:
230
119
  - --charset=UTF-8
@@ -244,7 +133,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
244
133
  version: 1.3.6
245
134
  requirements: []
246
135
  rubyforge_project:
247
- rubygems_version: 1.8.23
136
+ rubygems_version: 1.8.24
248
137
  signing_key:
249
138
  specification_version: 3
250
139
  summary: A scripting framework that replaces rake, sake and rubigen
@@ -275,6 +164,7 @@ test_files:
275
164
  - spec/fixtures/group.thor
276
165
  - spec/fixtures/invoke.thor
277
166
  - spec/fixtures/path with spaces
167
+ - spec/fixtures/preserve/script.sh
278
168
  - spec/fixtures/script.thor
279
169
  - spec/fixtures/task.thor
280
170
  - spec/group_spec.rb
File without changes