thor 0.18.0 → 0.18.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +3 -0
- data/lib/thor/actions/empty_directory.rb +3 -19
- data/lib/thor/base.rb +12 -3
- data/lib/thor/error.rb +0 -4
- data/lib/thor/version.rb +1 -1
- data/spec/actions/empty_directory_spec.rb +10 -11
- data/spec/base_spec.rb +0 -4
- metadata +3 -5
data/CHANGELOG.md
CHANGED
@@ -97,28 +97,12 @@ class Thor
|
|
97
97
|
#
|
98
98
|
# user.rb
|
99
99
|
#
|
100
|
-
# The method referenced
|
101
|
-
# get the exception with the corresponding error message.
|
100
|
+
# The method referenced can be either public or private.
|
102
101
|
#
|
103
102
|
def convert_encoded_instructions(filename)
|
104
103
|
filename.gsub(/%(.*?)%/) do |initial_string|
|
105
|
-
|
106
|
-
|
107
|
-
end
|
108
|
-
|
109
|
-
# Calls `base`'s public method `sym`.
|
110
|
-
# Returns:: result of `base.sym` or `nil` if `sym` wasn't found in
|
111
|
-
# `base`
|
112
|
-
# Raises:: Thor::PrivateMethodEncodedError if `sym` references
|
113
|
-
# a private method.
|
114
|
-
def call_public_method(sym)
|
115
|
-
if base.respond_to?(sym)
|
116
|
-
base.send(sym)
|
117
|
-
elsif base.respond_to?(sym, true)
|
118
|
-
raise Thor::PrivateMethodEncodedError,
|
119
|
-
"Method #{base.class}##{sym} should be public, not private"
|
120
|
-
else
|
121
|
-
nil
|
104
|
+
method = $1.strip
|
105
|
+
base.respond_to?(method, true) ? base.send(method) : initial_string
|
122
106
|
end
|
123
107
|
end
|
124
108
|
|
data/lib/thor/base.rb
CHANGED
@@ -119,6 +119,18 @@ class Thor
|
|
119
119
|
end
|
120
120
|
|
121
121
|
module ClassMethods
|
122
|
+
def attr_reader(*) #:nodoc:
|
123
|
+
no_commands { super }
|
124
|
+
end
|
125
|
+
|
126
|
+
def attr_writer(*) #:nodoc:
|
127
|
+
no_commands { super }
|
128
|
+
end
|
129
|
+
|
130
|
+
def attr_accessor(*) #:nodoc:
|
131
|
+
no_commands { super }
|
132
|
+
end
|
133
|
+
|
122
134
|
# If you want to raise an error for unknown options, call check_unknown_options!
|
123
135
|
# This is disabled by default to allow dynamic invocations.
|
124
136
|
def check_unknown_options!
|
@@ -578,9 +590,6 @@ class Thor
|
|
578
590
|
# Return if it's not a public instance method
|
579
591
|
return unless public_method_defined?(meth.to_sym)
|
580
592
|
|
581
|
-
# Return if attr_* added the method
|
582
|
-
return if caller.first.to_s[/`attr_(reader|writer|accessor)'/]
|
583
|
-
|
584
593
|
return if @no_commands || !create_command(meth)
|
585
594
|
|
586
595
|
is_thor_reserved_word?(meth, :command)
|
data/lib/thor/error.rb
CHANGED
data/lib/thor/version.rb
CHANGED
@@ -107,6 +107,16 @@ describe Thor::Actions::EmptyDirectory do
|
|
107
107
|
expect(@action.send(:convert_encoded_instructions, "%file_name%.txt")).to eq("expected.txt")
|
108
108
|
end
|
109
109
|
|
110
|
+
it "accepts and executes a private %\w+% encoded instruction" do
|
111
|
+
@action.base.extend Module.new {
|
112
|
+
private
|
113
|
+
def private_file_name
|
114
|
+
"expected"
|
115
|
+
end
|
116
|
+
}
|
117
|
+
expect(@action.send(:convert_encoded_instructions, "%private_file_name%.txt")).to eq("expected.txt")
|
118
|
+
end
|
119
|
+
|
110
120
|
it "ignores an 'illegal' %\w+% encoded instruction" do
|
111
121
|
expect(@action.send(:convert_encoded_instructions, "%some_name%.txt")).to eq("%some_name%.txt")
|
112
122
|
end
|
@@ -114,17 +124,6 @@ describe Thor::Actions::EmptyDirectory do
|
|
114
124
|
it "ignores incorrectly encoded instruction" do
|
115
125
|
expect(@action.send(:convert_encoded_instructions, "%some.name%.txt")).to eq("%some.name%.txt")
|
116
126
|
end
|
117
|
-
|
118
|
-
it "raises an error if the instruction refers to a private method" do
|
119
|
-
module PrivExt
|
120
|
-
private
|
121
|
-
def private_file_name
|
122
|
-
"something_hidden"
|
123
|
-
end
|
124
|
-
end
|
125
|
-
@action.base.extend(PrivExt)
|
126
|
-
expect { @action.send(:convert_encoded_instructions, "%private_file_name%.txt") }.to raise_error Thor::PrivateMethodEncodedError
|
127
|
-
end
|
128
127
|
end
|
129
128
|
end
|
130
129
|
end
|
data/spec/base_spec.rb
CHANGED
@@ -287,9 +287,5 @@ describe Thor::Base do
|
|
287
287
|
expect(capture(:stderr){ MyScript.start(["some_attribute"]) }).to match(/Could not find/)
|
288
288
|
expect(capture(:stderr){ MyScript.start(["some_attribute=", "foo"]) }).to match(/Could not find/)
|
289
289
|
end
|
290
|
-
|
291
|
-
it "respects visibility" do
|
292
|
-
expect(MyScript.public_instance_methods).to_not include(:private_attribute)
|
293
|
-
end
|
294
290
|
end
|
295
291
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: thor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.18.
|
4
|
+
version: 0.18.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-03-
|
13
|
+
date: 2013-03-30 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|
@@ -132,9 +132,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
132
132
|
- - ! '>='
|
133
133
|
- !ruby/object:Gem::Version
|
134
134
|
version: '0'
|
135
|
-
segments:
|
136
|
-
- 0
|
137
|
-
hash: 1077930939435781644
|
138
135
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
139
136
|
none: false
|
140
137
|
requirements:
|
@@ -196,3 +193,4 @@ test_files:
|
|
196
193
|
- spec/subcommand_spec.rb
|
197
194
|
- spec/thor_spec.rb
|
198
195
|
- spec/util_spec.rb
|
196
|
+
has_rdoc:
|