rory 0.3.11 → 0.3.12

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.
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
@@ -1,3 +1,3 @@
1
1
  module Rory
2
- VERSION = '0.3.11'
2
+ VERSION = '0.3.12'
3
3
  end
@@ -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.11
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-05 00:00:00.000000000 Z
12
+ date: 2014-03-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack