rory 0.3.11 → 0.3.12
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/rory/support.rb +8 -0
- data/lib/rory/version.rb +1 -1
- data/spec/lib/rory/support_spec.rb +18 -0
- metadata +2 -2
data/lib/rory/support.rb
CHANGED
@@ -16,6 +16,14 @@ module Rory
|
|
16
16
|
}
|
17
17
|
end
|
18
18
|
|
19
|
+
def tokenize(string)
|
20
|
+
return nil if string.nil?
|
21
|
+
string = string.to_s.gsub(/&/, ' and ').
|
22
|
+
gsub(/[ \/]+/, '_').
|
23
|
+
gsub(/([a-z\d])([A-Z])/,'\1_\2').
|
24
|
+
downcase
|
25
|
+
end
|
26
|
+
|
19
27
|
def require_all_files_in_directory(path)
|
20
28
|
Dir[Pathname.new(path).join('**', '*.rb')].each do |file|
|
21
29
|
require file
|
data/lib/rory/version.rb
CHANGED
@@ -46,4 +46,22 @@ describe Rory::Support do
|
|
46
46
|
).should == OrigamiDeliveryMan::UnderWhere::Skippy
|
47
47
|
end
|
48
48
|
end
|
49
|
+
|
50
|
+
describe '.tokenize' do
|
51
|
+
it 'creates snake_case version of string' do
|
52
|
+
described_class.tokenize('Albus Dumbledore & his_friend').should == 'albus_dumbledore_and_his_friend'
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'uncamelizes' do
|
56
|
+
described_class.tokenize('thisStrangeJavalikeWord').should == 'this_strange_javalike_word'
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'returns nil if given nil' do
|
60
|
+
described_class.tokenize(nil).should be_nil
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'also handles symbols' do
|
64
|
+
described_class.tokenize(:yourFaceIsNice).should == 'your_face_is_nice'
|
65
|
+
end
|
66
|
+
end
|
49
67
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rory
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.12
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-03-
|
12
|
+
date: 2014-03-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rack
|