rinne 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -15,6 +15,13 @@ module Rinne
15
15
  def classify(path, filetype = "*")
16
16
  camelize File.basename(path, ".#{filetype}")
17
17
  end
18
+
19
+ def to_snake(str)
20
+ str.gsub(/::/, '/').
21
+ gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
22
+ gsub(/([a-z\d])([A-Z])/,'\1_\2').
23
+ tr("-","_").downcase
24
+ end
18
25
  end
19
26
 
20
27
  end
@@ -1,3 +1,3 @@
1
1
  module Rinne
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -27,6 +27,10 @@ describe Rinne do
27
27
  it 'should file name' do
28
28
  Rinne.classify("foo_bar.rb","rb").should eq("FooBar")
29
29
  end
30
+
31
+ it 'should snake case' do
32
+ Rinne.to_snake("camelCase").should eq("camel_case")
33
+ end
30
34
  end
31
35
 
32
36
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rinne
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
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: 2013-05-30 00:00:00.000000000 Z
12
+ date: 2013-06-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler