notation_converter 1.0.1 → 1.0.2

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/notation_converter.rb +6 -18
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f9b03e5bc60070028618a3fd89c8d2ce32e29f68
4
- data.tar.gz: e9144568f17b70f659f9d98a9c1a493af9684e23
3
+ metadata.gz: b056128865a2ddf9fc173d5f016b1a23e2356a62
4
+ data.tar.gz: 27749fdcc1d93251eaa706d191f42cef7aff16c9
5
5
  SHA512:
6
- metadata.gz: 13bea81646c2960965ce9bffac34a769d6b9871c54e7e146af06973eb60f40bb54cf4f75e6bbf3f84f278fdd30c3d6bc1022d95a85b39e046239ad18a9311218
7
- data.tar.gz: 0a9b7d5b9ad4325274944b625cdfc2a450814051b27132eb50bb994cb68f88ef80bca9d8eb6e3778b3508e0650100edc5903b47b0b1184d7c09ec8dbee5eaacd
6
+ metadata.gz: b4fb719731752bf8bb6c7ea3445fdb84662871b6182f69a6bbff6456327b424b3cfdd2acdcdde0041d40949a72aa821b515b2a0ab00f52a3d2fc1cd9b7f15706
7
+ data.tar.gz: 9b3a2cf9a0551508f2c0a2e6c4f2a3765d9576444175c5231eec4f731488515267d792a856a182d8983d34b85d41ed14dc45ee9ee65588cca497e4d83612a4b3
@@ -36,11 +36,11 @@ class NotationConverter
36
36
  # @param to_symbol [Boolean] default false (defines if returned keys will be symbols or strings)
37
37
  # @return [Hash|Array] input converted into the camelCase notation
38
38
  def self.to_camel(input, type = :lower, to_symbol = false)
39
- if type == :upper
40
- to_upper_camel input, to_symbol
41
- else
42
- to_lower_camel input, to_symbol
39
+ conversion_logic = lambda do |k|
40
+ new_k = k.to_s.split('_').map.with_index{ |e, i| (i == 0 && type != :upper) ? e.downcase : (e.slice(0,1).capitalize + e.slice(1..-1)) }.join
41
+ return_val new_k, to_symbol
43
42
  end
43
+ convert_input input, &conversion_logic
44
44
  end
45
45
 
46
46
  # Converts passed input to (Upper) CamelCase notation
@@ -49,13 +49,7 @@ class NotationConverter
49
49
  # @param to_symbol [Boolean] default false (defines if returned keys will be symbols or strings)
50
50
  # @return [Hash|Array] input converted into the (Upper) CamelCase notation
51
51
  def self.to_upper_camel(input, to_symbol = false)
52
-
53
- conversion_logic = lambda do |k|
54
- new_k = k.to_s.split('_').map.with_index{|e, i| e.capitalize }.join
55
- return_val new_k, to_symbol
56
- end
57
- convert_input input, &conversion_logic
58
-
52
+ to_camel input, :upper, to_symbol
59
53
  end
60
54
 
61
55
  # Converts passed input to (lower) camelCase notation
@@ -64,13 +58,7 @@ class NotationConverter
64
58
  # @param to_symbol [Boolean] default false (defines if returned keys will be symbols or strings)
65
59
  # @return [Hash|Array] input converted into the (lower) camelCase notation
66
60
  def self.to_lower_camel(input, to_symbol = false)
67
-
68
- conversion_logic = lambda do |k|
69
- new_k = k.to_s.split('_').map.with_index{|e, i| i == 0 ? e : e.capitalize }.join
70
- return_val new_k, to_symbol
71
- end
72
- convert_input input, &conversion_logic
73
-
61
+ to_camel input, :lower, to_symbol
74
62
  end
75
63
 
76
64
  # Converts passed input to snake_notation
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: notation_converter
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mariusz Karpicki
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-17 00:00:00.000000000 Z
11
+ date: 2017-09-18 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: NotationConverter allows to convert between snake_notation and camelCase
14
14
  notation