snake_camel 0.1.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7853eb333c3d17c5fd00795dac8006cda730454f
4
- data.tar.gz: 1cd0e5bcc96c602d0c55b0544143daaa20186055
3
+ metadata.gz: 87b2c2d56313835f2cda5993ccc8053b3d47ef7d
4
+ data.tar.gz: 026f016ae292ab0e6b152d936ac549d22118a0ad
5
5
  SHA512:
6
- metadata.gz: 50fbc847a1bb40c6c65a40c6ddc4c96f4fa1efe97cde5ccdb1728b164adef52249ed40443032c21a7030705b969991ced4aadb6e4bedb5d801fad815134aba06
7
- data.tar.gz: 03ca58c8105b36805a24291567b2609c87255d9596ca7c9c8f9a79e4691e571bc550bbc944d39985c04bc1b3a912d23b5419121ef5966919af71e3e298eddfd9
6
+ metadata.gz: 3a7aaf0c91edf2b95867d62581355c8ef3e7621d47eb826f42573d4f5e5962adfa8912ef1c08592a1f48f1c817ecfbada5eb5bdc9e27619992e8ec0338ebef0a
7
+ data.tar.gz: d10bfa7d94e1f59add5adb9755b70260db9da6cdd051865375ac018ca33cdb834164046df8b31d0f8e0265b4e6ec18136984d833d75e4e59d5cdf7d5573eb366
data/README.md CHANGED
@@ -21,9 +21,20 @@ Or install it yourself as:
21
21
 
22
22
  ## Usage
23
23
 
24
+ ### Available methods:
25
+
26
+ - snakecase
27
+
28
+ - snakecase!
29
+
30
+ - camelcase
31
+
32
+ - camelcase!
33
+
34
+
24
35
  You have several ways to use it, it's pretty simple. Choose one, based on your need!
25
36
 
26
- - If you don't care about the 'how':
37
+ - If you don't care about what's under the hood:
27
38
 
28
39
  ```ruby
29
40
  require 'snake_camel'
@@ -62,6 +73,7 @@ SnakeCamel::Methods.snakecase('FooBar') #=> foo_bar
62
73
  SnakeCamel::Methods.camelcase('foo_bar') #=> FooBar
63
74
  ```
64
75
 
76
+
65
77
  ## Creator's notes
66
78
 
67
79
  I know there are other gems that provide the same functionality as SnakeCamel, but I want to create something more gentle, more simple.
@@ -7,8 +7,17 @@ module SnakeCamel
7
7
  SnakeCamel::Methods.snakecase(self)
8
8
  end
9
9
 
10
+ def snakecase!
11
+ SnakeCamel::Methods.snakecase!(self)
12
+ end
13
+
10
14
  def camelcase
11
15
  SnakeCamel::Methods.camelcase(self)
12
16
  end
17
+
18
+ def camelcase!
19
+ SnakeCamel::Methods.camelcase!(self)
20
+ end
21
+
13
22
  end
14
23
  end
@@ -3,13 +3,21 @@ module SnakeCamel
3
3
  module Methods
4
4
  extend self
5
5
 
6
+ def snakecase!(string)
7
+ string.replace(string.to_s.gsub(/([a-z\d])([A-Z])/, '\1_\2').downcase)
8
+ end
9
+
6
10
  def snakecase(string)
7
- string.to_s.gsub(/([a-z\d])([A-Z])/, '\1_\2').downcase
11
+ snakecase!(string.dup)
8
12
  end
9
13
 
10
14
  def camelcase(string)
11
15
  string.to_s.split('_').each { |e| e.capitalize! }.join
12
16
  end
13
17
 
18
+ def camelcase!(string)
19
+ string.replace(camelcase(string))
20
+ end
21
+
14
22
  end
15
23
  end
@@ -1,3 +1,3 @@
1
1
  module SnakeCamel
2
- VERSION = "0.1.3"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: snake_camel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Balint Bejczi