utils 0.72.1 → 0.73.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.
- checksums.yaml +4 -4
- data/bin/classify +14 -4
- data/lib/utils/version.rb +1 -1
- data/utils.gemspec +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 73c5e8bc5534a979765da614e9cd17d41b671c26afcfb9c076e905c5c1be9c47
|
4
|
+
data.tar.gz: d33ed0e92ece3d6d2ba1612857f7caf9a69014f95d6f1646b768421a503985c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 470d6b5f8f769b8489c540b904f0679a2862cb5b78d46a56af353e3d2bdb39e7c2b54edaa5e0e2e11532f5aa05f8f42c823db31e15eafd624ca89be1dcff3cea
|
7
|
+
data.tar.gz: 5bc7f3d4881245c01d19595dbf9afd89735d22ec3f6e69daa6d33230c41ac724dcd32889e9eda573bc3e281d713cbc4f41c95a7ab6d84c2e00d9bd53d8092a39
|
data/bin/classify
CHANGED
@@ -53,7 +53,8 @@ end
|
|
53
53
|
def underscore(string)
|
54
54
|
string = path_shifter(string, n: $opts[?n], separator: '::')
|
55
55
|
string = Tins::StringUnderscore.instance_method(:underscore).bind(string).()
|
56
|
-
$opts[?
|
56
|
+
$opts[?S] and string = string.sub(/_spec\z/, '')
|
57
|
+
$opts[?s] and string = string.sub(/(\.rb)?\z/, '.rb')
|
57
58
|
string
|
58
59
|
end
|
59
60
|
|
@@ -83,7 +84,8 @@ end
|
|
83
84
|
# @return [ String ] the camelized string result
|
84
85
|
def camelize(string)
|
85
86
|
string = path_shifter(string, n: $opts[?n])
|
86
|
-
string = string.
|
87
|
+
string = string.sub(/#{Regexp.quote(File.extname(string))}\z/, '')
|
88
|
+
$opts[?S] and string = string.sub(/_spec\z/, '')
|
87
89
|
string.camelize
|
88
90
|
end
|
89
91
|
|
@@ -153,6 +155,7 @@ def usage
|
|
153
155
|
-n NUMBER the number of module namespaces to skip from the left
|
154
156
|
-b return right most module namespace
|
155
157
|
-s adds .rb suffix to foo/bar_baz.rb if necessary
|
158
|
+
-S remove _spec / Spec suffixes if applicable
|
156
159
|
-p SEPARATOR used for declassification
|
157
160
|
-h display this help
|
158
161
|
|
@@ -169,6 +172,10 @@ def usage
|
|
169
172
|
classify -p . -d Foo::Bar::Baz ⇢ foo.bar.baz
|
170
173
|
classify -p : -d Foo::Bar::Baz ⇢ foo:bar:baz
|
171
174
|
classify -n 1 lib/foo/bar ⇢ Foo::Bar
|
175
|
+
classify -S foo/bar_spec.rb ⇢ Foo::Bar
|
176
|
+
classify -S Foo::BarBazSpec ⇢ Foo::BarBaz
|
177
|
+
classify -d -S Foo::BarSpec ⇢ foo/bar
|
178
|
+
|
172
179
|
|
173
180
|
With this configuration in .utilsrc:
|
174
181
|
classify do
|
@@ -186,11 +193,12 @@ def usage
|
|
186
193
|
exit 0
|
187
194
|
end
|
188
195
|
|
189
|
-
$opts = go 'dtn:
|
196
|
+
$opts = go 'dtn:bsSp:h'
|
190
197
|
|
191
198
|
$opts[?h] and usage
|
192
199
|
string = ARGV.shift or fail "need a class/filepath/filename"
|
193
200
|
string = Term::ANSIColor.uncolor string
|
201
|
+
string = string.chomp
|
194
202
|
|
195
203
|
config = Utils::ConfigFile.new
|
196
204
|
config.configure_from_paths
|
@@ -221,7 +229,9 @@ print(
|
|
221
229
|
end
|
222
230
|
else
|
223
231
|
if camelcase?(string)
|
224
|
-
path_shifter(string, separator: '::', n: $opts[?n])
|
232
|
+
string = path_shifter(string, separator: '::', n: $opts[?n])
|
233
|
+
$opts[?S] and string = string.sub(/Spec\z/, '')
|
234
|
+
string
|
225
235
|
else
|
226
236
|
camelize string
|
227
237
|
end
|
data/lib/utils/version.rb
CHANGED
data/utils.gemspec
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: utils 0.
|
2
|
+
# stub: utils 0.73.0 ruby lib
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "utils".freeze
|
6
|
-
s.version = "0.
|
6
|
+
s.version = "0.73.0".freeze
|
7
7
|
|
8
8
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
9
9
|
s.require_paths = ["lib".freeze]
|