wijet-thor 0.14.6
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +103 -0
- data/LICENSE +20 -0
- data/README.md +307 -0
- data/Thorfile +24 -0
- data/bin/rake2thor +86 -0
- data/bin/thor +6 -0
- data/lib/thor.rb +334 -0
- data/lib/thor/actions.rb +314 -0
- data/lib/thor/actions/create_file.rb +105 -0
- data/lib/thor/actions/create_link.rb +57 -0
- data/lib/thor/actions/directory.rb +93 -0
- data/lib/thor/actions/empty_directory.rb +134 -0
- data/lib/thor/actions/file_manipulation.rb +270 -0
- data/lib/thor/actions/inject_into_file.rb +109 -0
- data/lib/thor/base.rb +579 -0
- data/lib/thor/core_ext/file_binary_read.rb +9 -0
- data/lib/thor/core_ext/hash_with_indifferent_access.rb +75 -0
- data/lib/thor/core_ext/ordered_hash.rb +100 -0
- data/lib/thor/error.rb +30 -0
- data/lib/thor/group.rb +273 -0
- data/lib/thor/invocation.rb +168 -0
- data/lib/thor/parser.rb +4 -0
- data/lib/thor/parser/argument.rb +67 -0
- data/lib/thor/parser/arguments.rb +161 -0
- data/lib/thor/parser/option.rb +120 -0
- data/lib/thor/parser/options.rb +173 -0
- data/lib/thor/rake_compat.rb +66 -0
- data/lib/thor/runner.rb +309 -0
- data/lib/thor/shell.rb +88 -0
- data/lib/thor/shell/basic.rb +290 -0
- data/lib/thor/shell/color.rb +108 -0
- data/lib/thor/shell/html.rb +121 -0
- data/lib/thor/task.rb +114 -0
- data/lib/thor/util.rb +229 -0
- data/lib/thor/version.rb +3 -0
- data/spec/actions/create_file_spec.rb +170 -0
- data/spec/actions/directory_spec.rb +136 -0
- data/spec/actions/empty_directory_spec.rb +98 -0
- data/spec/actions/file_manipulation_spec.rb +310 -0
- data/spec/actions/inject_into_file_spec.rb +135 -0
- data/spec/actions_spec.rb +322 -0
- data/spec/base_spec.rb +269 -0
- data/spec/core_ext/hash_with_indifferent_access_spec.rb +43 -0
- data/spec/core_ext/ordered_hash_spec.rb +115 -0
- data/spec/fixtures/application.rb +2 -0
- data/spec/fixtures/bundle/execute.rb +6 -0
- data/spec/fixtures/bundle/main.thor +1 -0
- data/spec/fixtures/doc/%file_name%.rb.tt +1 -0
- data/spec/fixtures/doc/README +3 -0
- data/spec/fixtures/doc/block_helper.rb +3 -0
- data/spec/fixtures/doc/components/.empty_directory +0 -0
- data/spec/fixtures/doc/config.rb +1 -0
- data/spec/fixtures/group.thor +114 -0
- data/spec/fixtures/invoke.thor +112 -0
- data/spec/fixtures/path with spaces b/data/spec/fixtures/path with → spaces +0 -0
- data/spec/fixtures/script.thor +184 -0
- data/spec/fixtures/task.thor +10 -0
- data/spec/group_spec.rb +178 -0
- data/spec/invocation_spec.rb +100 -0
- data/spec/parser/argument_spec.rb +47 -0
- data/spec/parser/arguments_spec.rb +64 -0
- data/spec/parser/option_spec.rb +202 -0
- data/spec/parser/options_spec.rb +319 -0
- data/spec/rake_compat_spec.rb +68 -0
- data/spec/register_spec.rb +104 -0
- data/spec/runner_spec.rb +210 -0
- data/spec/shell/basic_spec.rb +223 -0
- data/spec/shell/color_spec.rb +41 -0
- data/spec/shell/html_spec.rb +27 -0
- data/spec/shell_spec.rb +47 -0
- data/spec/spec_helper.rb +54 -0
- data/spec/task_spec.rb +74 -0
- data/spec/thor_spec.rb +334 -0
- data/spec/util_spec.rb +163 -0
- metadata +193 -0
data/spec/util_spec.rb
ADDED
@@ -0,0 +1,163 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
module Thor::Util
|
4
|
+
def self.clear_user_home!
|
5
|
+
@@user_home = nil
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
describe Thor::Util do
|
10
|
+
describe "#find_by_namespace" do
|
11
|
+
it "returns 'default' if no namespace is given" do
|
12
|
+
Thor::Util.find_by_namespace('').should == Scripts::MyDefaults
|
13
|
+
end
|
14
|
+
|
15
|
+
it "adds 'default' if namespace starts with :" do
|
16
|
+
Thor::Util.find_by_namespace(':child').should == Scripts::ChildDefault
|
17
|
+
end
|
18
|
+
|
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
|
21
|
+
end
|
22
|
+
|
23
|
+
it "returns a class if it matches the namespace" do
|
24
|
+
Thor::Util.find_by_namespace('app:broken:counter').should == BrokenCounter
|
25
|
+
end
|
26
|
+
|
27
|
+
it "matches classes default namespace" do
|
28
|
+
Thor::Util.find_by_namespace('scripts:my_script').should == Scripts::MyScript
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "#namespace_from_thor_class" do
|
33
|
+
it "replaces constant nesting with task namespacing" do
|
34
|
+
Thor::Util.namespace_from_thor_class("Foo::Bar::Baz").should == "foo:bar:baz"
|
35
|
+
end
|
36
|
+
|
37
|
+
it "snake-cases component strings" do
|
38
|
+
Thor::Util.namespace_from_thor_class("FooBar::BarBaz::BazBoom").should == "foo_bar:bar_baz:baz_boom"
|
39
|
+
end
|
40
|
+
|
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"
|
44
|
+
end
|
45
|
+
|
46
|
+
it "removes Thor::Sandbox namespace" do
|
47
|
+
Thor::Util.namespace_from_thor_class("Thor::Sandbox::Package").should == "package"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe "#namespaces_in_content" do
|
52
|
+
it "returns an array of names of constants defined in the string" do
|
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")
|
56
|
+
end
|
57
|
+
|
58
|
+
it "doesn't put the newly-defined constants in the enclosing namespace" do
|
59
|
+
Thor::Util.namespaces_in_content("class Blat; end")
|
60
|
+
defined?(Blat).should_not be
|
61
|
+
defined?(Thor::Sandbox::Blat).should be
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe "#snake_case" do
|
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"
|
69
|
+
end
|
70
|
+
|
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"
|
74
|
+
end
|
75
|
+
|
76
|
+
it "downcases initial-cap strings" do
|
77
|
+
Thor::Util.snake_case("Foo").should == "foo"
|
78
|
+
end
|
79
|
+
|
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"
|
83
|
+
end
|
84
|
+
|
85
|
+
it "places underscores between multiple capitals" do
|
86
|
+
Thor::Util.snake_case("ABClass").should == "a_b_class"
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
describe "#find_class_and_task_by_namespace" do
|
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]
|
93
|
+
end
|
94
|
+
|
95
|
+
it "returns a Thor class if full namespace matches" do
|
96
|
+
Thor::Util.find_class_and_task_by_namespace("thor").should == [Thor, nil]
|
97
|
+
end
|
98
|
+
|
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"]
|
101
|
+
end
|
102
|
+
|
103
|
+
it "falls back in the namespace:task look up even if a full namespace does not match" do
|
104
|
+
Thor.const_set(:Help, Module.new)
|
105
|
+
Thor::Util.find_class_and_task_by_namespace("thor:help").should == [Thor, "help"]
|
106
|
+
Thor.send :remove_const, :Help
|
107
|
+
end
|
108
|
+
|
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"]
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
describe "#thor_classes_in" do
|
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
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
describe "#user_home" do
|
122
|
+
before(:each) do
|
123
|
+
ENV.stub!(:[])
|
124
|
+
Thor::Util.clear_user_home!
|
125
|
+
end
|
126
|
+
|
127
|
+
it "returns the user path if none variable is set on the environment" do
|
128
|
+
Thor::Util.user_home.should == File.expand_path("~")
|
129
|
+
end
|
130
|
+
|
131
|
+
it "returns the *unix system path if file cannot be expanded and separator does not exist" do
|
132
|
+
File.should_receive(:expand_path).with("~").and_raise(RuntimeError)
|
133
|
+
previous_value = File::ALT_SEPARATOR
|
134
|
+
capture(:stderr){ File.const_set(:ALT_SEPARATOR, false) }
|
135
|
+
Thor::Util.user_home.should == "/"
|
136
|
+
capture(:stderr){ File.const_set(:ALT_SEPARATOR, previous_value) }
|
137
|
+
end
|
138
|
+
|
139
|
+
it "returns the windows system path if file cannot be expanded and a separator exists" do
|
140
|
+
File.should_receive(:expand_path).with("~").and_raise(RuntimeError)
|
141
|
+
previous_value = File::ALT_SEPARATOR
|
142
|
+
capture(:stderr){ File.const_set(:ALT_SEPARATOR, true) }
|
143
|
+
Thor::Util.user_home.should == "C:/"
|
144
|
+
capture(:stderr){ File.const_set(:ALT_SEPARATOR, previous_value) }
|
145
|
+
end
|
146
|
+
|
147
|
+
it "returns HOME/.thor if set" do
|
148
|
+
ENV.stub!(:[]).with("HOME").and_return("/home/user/")
|
149
|
+
Thor::Util.user_home.should == "/home/user/"
|
150
|
+
end
|
151
|
+
|
152
|
+
it "returns path with HOMEDRIVE and HOMEPATH if set" do
|
153
|
+
ENV.stub!(:[]).with("HOMEDRIVE").and_return("D:/")
|
154
|
+
ENV.stub!(:[]).with("HOMEPATH").and_return("Documents and Settings/James")
|
155
|
+
Thor::Util.user_home.should == "D:/Documents and Settings/James"
|
156
|
+
end
|
157
|
+
|
158
|
+
it "returns APPDATA/.thor if set" do
|
159
|
+
ENV.stub!(:[]).with("APPDATA").and_return("/home/user/")
|
160
|
+
Thor::Util.user_home.should == "/home/user/"
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
metadata
ADDED
@@ -0,0 +1,193 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: wijet-thor
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.14.6
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Yehuda Katz
|
9
|
+
- José Valim
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2011-11-20 00:00:00.000000000Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: bundler
|
17
|
+
requirement: &2156605740 !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: *2156605740
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: fakeweb
|
28
|
+
requirement: &2156605260 !ruby/object:Gem::Requirement
|
29
|
+
none: false
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: *2156605260
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: rdoc
|
39
|
+
requirement: &2156604760 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ~>
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '2.5'
|
45
|
+
type: :development
|
46
|
+
prerelease: false
|
47
|
+
version_requirements: *2156604760
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: rake
|
50
|
+
requirement: &2156604180 !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
52
|
+
requirements:
|
53
|
+
- - ! '>='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0.8'
|
56
|
+
type: :development
|
57
|
+
prerelease: false
|
58
|
+
version_requirements: *2156604180
|
59
|
+
- !ruby/object:Gem::Dependency
|
60
|
+
name: rspec
|
61
|
+
requirement: &2156603620 !ruby/object:Gem::Requirement
|
62
|
+
none: false
|
63
|
+
requirements:
|
64
|
+
- - ~>
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '2.1'
|
67
|
+
type: :development
|
68
|
+
prerelease: false
|
69
|
+
version_requirements: *2156603620
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: simplecov
|
72
|
+
requirement: &2156603060 !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0.3'
|
78
|
+
type: :development
|
79
|
+
prerelease: false
|
80
|
+
version_requirements: *2156603060
|
81
|
+
description: A scripting framework that replaces rake, sake and rubigen
|
82
|
+
email:
|
83
|
+
- ruby-thor@googlegroups.com
|
84
|
+
executables:
|
85
|
+
- rake2thor
|
86
|
+
- thor
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files:
|
89
|
+
- CHANGELOG.rdoc
|
90
|
+
- LICENSE
|
91
|
+
- README.md
|
92
|
+
- Thorfile
|
93
|
+
files:
|
94
|
+
- bin/rake2thor
|
95
|
+
- bin/thor
|
96
|
+
- lib/thor.rb
|
97
|
+
- lib/thor/actions.rb
|
98
|
+
- lib/thor/actions/create_file.rb
|
99
|
+
- lib/thor/actions/create_link.rb
|
100
|
+
- lib/thor/actions/directory.rb
|
101
|
+
- lib/thor/actions/empty_directory.rb
|
102
|
+
- lib/thor/actions/file_manipulation.rb
|
103
|
+
- lib/thor/actions/inject_into_file.rb
|
104
|
+
- lib/thor/base.rb
|
105
|
+
- lib/thor/core_ext/file_binary_read.rb
|
106
|
+
- lib/thor/core_ext/hash_with_indifferent_access.rb
|
107
|
+
- lib/thor/core_ext/ordered_hash.rb
|
108
|
+
- lib/thor/error.rb
|
109
|
+
- lib/thor/group.rb
|
110
|
+
- lib/thor/invocation.rb
|
111
|
+
- lib/thor/parser.rb
|
112
|
+
- lib/thor/parser/argument.rb
|
113
|
+
- lib/thor/parser/arguments.rb
|
114
|
+
- lib/thor/parser/option.rb
|
115
|
+
- lib/thor/parser/options.rb
|
116
|
+
- lib/thor/rake_compat.rb
|
117
|
+
- lib/thor/runner.rb
|
118
|
+
- lib/thor/shell.rb
|
119
|
+
- lib/thor/shell/basic.rb
|
120
|
+
- lib/thor/shell/color.rb
|
121
|
+
- lib/thor/shell/html.rb
|
122
|
+
- lib/thor/task.rb
|
123
|
+
- lib/thor/util.rb
|
124
|
+
- lib/thor/version.rb
|
125
|
+
- spec/actions/create_file_spec.rb
|
126
|
+
- spec/actions/directory_spec.rb
|
127
|
+
- spec/actions/empty_directory_spec.rb
|
128
|
+
- spec/actions/file_manipulation_spec.rb
|
129
|
+
- spec/actions/inject_into_file_spec.rb
|
130
|
+
- spec/actions_spec.rb
|
131
|
+
- spec/base_spec.rb
|
132
|
+
- spec/core_ext/hash_with_indifferent_access_spec.rb
|
133
|
+
- spec/core_ext/ordered_hash_spec.rb
|
134
|
+
- spec/fixtures/application.rb
|
135
|
+
- spec/fixtures/bundle/execute.rb
|
136
|
+
- spec/fixtures/bundle/main.thor
|
137
|
+
- spec/fixtures/doc/%file_name%.rb.tt
|
138
|
+
- spec/fixtures/doc/README
|
139
|
+
- spec/fixtures/doc/block_helper.rb
|
140
|
+
- spec/fixtures/doc/components/.empty_directory
|
141
|
+
- spec/fixtures/doc/config.rb
|
142
|
+
- spec/fixtures/group.thor
|
143
|
+
- spec/fixtures/invoke.thor
|
144
|
+
- spec/fixtures/path with spaces
|
145
|
+
- spec/fixtures/script.thor
|
146
|
+
- spec/fixtures/task.thor
|
147
|
+
- spec/group_spec.rb
|
148
|
+
- spec/invocation_spec.rb
|
149
|
+
- spec/parser/argument_spec.rb
|
150
|
+
- spec/parser/arguments_spec.rb
|
151
|
+
- spec/parser/option_spec.rb
|
152
|
+
- spec/parser/options_spec.rb
|
153
|
+
- spec/rake_compat_spec.rb
|
154
|
+
- spec/register_spec.rb
|
155
|
+
- spec/runner_spec.rb
|
156
|
+
- spec/shell/basic_spec.rb
|
157
|
+
- spec/shell/color_spec.rb
|
158
|
+
- spec/shell/html_spec.rb
|
159
|
+
- spec/shell_spec.rb
|
160
|
+
- spec/spec_helper.rb
|
161
|
+
- spec/task_spec.rb
|
162
|
+
- spec/thor_spec.rb
|
163
|
+
- spec/util_spec.rb
|
164
|
+
- CHANGELOG.rdoc
|
165
|
+
- LICENSE
|
166
|
+
- README.md
|
167
|
+
- Thorfile
|
168
|
+
homepage: http://github.com/wycats/thor
|
169
|
+
licenses: []
|
170
|
+
post_install_message:
|
171
|
+
rdoc_options:
|
172
|
+
- --charset=UTF-8
|
173
|
+
require_paths:
|
174
|
+
- lib
|
175
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
176
|
+
none: false
|
177
|
+
requirements:
|
178
|
+
- - ! '>='
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
181
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
182
|
+
none: false
|
183
|
+
requirements:
|
184
|
+
- - ! '>='
|
185
|
+
- !ruby/object:Gem::Version
|
186
|
+
version: 1.3.6
|
187
|
+
requirements: []
|
188
|
+
rubyforge_project:
|
189
|
+
rubygems_version: 1.8.10
|
190
|
+
signing_key:
|
191
|
+
specification_version: 3
|
192
|
+
summary: A scripting framework that replaces rake, sake and rubigen
|
193
|
+
test_files: []
|