snake_camel 0.2.0 → 1.1.1

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
- SHA1:
3
- metadata.gz: 87b2c2d56313835f2cda5993ccc8053b3d47ef7d
4
- data.tar.gz: 026f016ae292ab0e6b152d936ac549d22118a0ad
2
+ SHA256:
3
+ metadata.gz: db78351fbce7944edc5febac6a4d68ef7d9a9274e075bd424e0c52c76c98952c
4
+ data.tar.gz: bdb2b264b0ef548822f6fd6923e2a4badfe4c841740421d62b11d485cdb8f1e7
5
5
  SHA512:
6
- metadata.gz: 3a7aaf0c91edf2b95867d62581355c8ef3e7621d47eb826f42573d4f5e5962adfa8912ef1c08592a1f48f1c817ecfbada5eb5bdc9e27619992e8ec0338ebef0a
7
- data.tar.gz: d10bfa7d94e1f59add5adb9755b70260db9da6cdd051865375ac018ca33cdb834164046df8b31d0f8e0265b4e6ec18136984d833d75e4e59d5cdf7d5573eb366
6
+ metadata.gz: e2fdfe9a3b032cf59aed771bcc4b966a83c94ddd98719e31b8af46e1d840dfce5593c0aae26c287b44d49e72ec46d3b7d15dcf38a476cece78cdd3f210920845
7
+ data.tar.gz: 52949bf02e112b5dfcaa7af29377dc609505839873349090a7f9545d60127060b97c40bb6eee34aced96ed5805e964668d74e2e9e7bab55f6f2609e17f13d7dd
data/.gitignore CHANGED
@@ -9,4 +9,5 @@
9
9
  /tmp/
10
10
  /.DS_Store/
11
11
  /*.gem/
12
-
12
+ /*.gemspec
13
+ /*.idea
data/README.md CHANGED
@@ -19,9 +19,7 @@ Or install it yourself as:
19
19
  $ gem install snake_camel
20
20
 
21
21
 
22
- ## Usage
23
-
24
- ### Available methods:
22
+ ## Methods
25
23
 
26
24
  - snakecase
27
25
 
@@ -31,6 +29,12 @@ Or install it yourself as:
31
29
 
32
30
  - camelcase!
33
31
 
32
+ - constant_name ('hello/world_sup' #=> Hello::WorldSup)
33
+
34
+ - path_name ('Hello::WorldSup #=> hello/world_sup')
35
+
36
+
37
+ ## Usage
34
38
 
35
39
  You have several ways to use it, it's pretty simple. Choose one, based on your need!
36
40
 
@@ -54,23 +58,23 @@ require 'snake_camel/instance_methods'
54
58
  foo = 'FooBar'
55
59
  foo.extend SnakeCamel::InstanceMethods
56
60
 
57
- foo.snakecase #=> foo_bar
61
+ foo.snakecase #=> 'foo_bar'
58
62
 
59
63
  or
60
64
 
61
65
  foo = 'foo_bar'
62
66
  foo.extend SnakeCamel::InstanceMethods
63
67
 
64
- foo.camelcase #=> FooBar
68
+ foo.camelcase #=> 'FooBar'
65
69
  ```
66
70
  - And you can use it like a regular method:
67
71
 
68
72
  ```ruby
69
73
  require 'snake_camel/methods'
70
74
 
71
- SnakeCamel::Methods.snakecase('FooBar') #=> foo_bar
75
+ SnakeCamel::Methods.snakecase('FooBar') #=> 'foo_bar'
72
76
 
73
- SnakeCamel::Methods.camelcase('foo_bar') #=> FooBar
77
+ SnakeCamel::Methods.camelcase('foo_bar') #=> 'FooBar'
74
78
  ```
75
79
 
76
80
 
@@ -19,5 +19,13 @@ module SnakeCamel
19
19
  SnakeCamel::Methods.camelcase!(self)
20
20
  end
21
21
 
22
+ def constant_name
23
+ SnakeCamel::Methods.constant_name(self)
24
+ end
25
+
26
+ def path_name
27
+ SnakeCamel::Methods.path_name(self)
28
+ end
29
+
22
30
  end
23
31
  end
@@ -1,4 +1,3 @@
1
-
2
1
  module SnakeCamel
3
2
  module Methods
4
3
  extend self
@@ -12,12 +11,21 @@ module SnakeCamel
12
11
  end
13
12
 
14
13
  def camelcase(string)
15
- string.to_s.split('_').each { |e| e.capitalize! }.join
14
+ string.to_s.split('_').map(&:capitalize).join
16
15
  end
17
16
 
18
17
  def camelcase!(string)
19
18
  string.replace(camelcase(string))
20
19
  end
21
20
 
21
+ def constant_name(string)
22
+ string.split(File::Separator).map { |part| camelcase(part) }.join('::')
23
+ end
24
+
25
+ def path_name(camelcase_string)
26
+ return snakecase(camelcase_string).insert(0, File::Separator) unless camelcase_string.match(/::/)
27
+ camelcase_string.split("::").map { |part| snakecase(part) }.join(File::Separator)
28
+ end
29
+
22
30
  end
23
- end
31
+ end
@@ -1,3 +1,3 @@
1
1
  module SnakeCamel
2
- VERSION = "0.2.0"
2
+ VERSION = "1.1.1"
3
3
  end
data/snake_camel.gemspec CHANGED
@@ -9,8 +9,8 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ["Balint Bejczi"]
10
10
  spec.email = ["bejczi.balint@gmail.com"]
11
11
 
12
- spec.summary = %q{conversation between CamelCase and snake_case}
13
- spec.description = %q{converts CamelCase to snake_case and backwardss}
12
+ spec.summary = %q{converion between CamelCase and snake_case}
13
+ spec.description = %q{converts CamelCase to snake_case and backwards}
14
14
  spec.homepage = 'https://github.com/bejczib/snake_camel'
15
15
  spec.license = "MIT"
16
16
 
@@ -19,9 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
20
  spec.require_paths = ["lib"]
21
21
 
22
- spec.add_development_dependency "bundler", "~> 1.11"
23
- spec.add_development_dependency "rake", "~> 10.0"
22
+ spec.add_development_dependency "bundler", ">= 2.2.10"
23
+ spec.add_development_dependency "rake", ">= 12.3.3"
24
24
  spec.add_development_dependency "rspec", "~> 3.0"
25
25
  end
26
-
27
-
metadata CHANGED
@@ -1,43 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: snake_camel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Balint Bejczi
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-04-11 00:00:00.000000000 Z
11
+ date: 2021-09-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '1.11'
19
+ version: 2.2.10
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '1.11'
26
+ version: 2.2.10
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
33
+ version: 12.3.3
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '10.0'
40
+ version: 12.3.3
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -52,7 +52,7 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.0'
55
- description: converts CamelCase to snake_case and backwardss
55
+ description: converts CamelCase to snake_case and backwards
56
56
  email:
57
57
  - bejczi.balint@gmail.com
58
58
  executables: []
@@ -79,7 +79,7 @@ homepage: https://github.com/bejczib/snake_camel
79
79
  licenses:
80
80
  - MIT
81
81
  metadata: {}
82
- post_install_message:
82
+ post_install_message:
83
83
  rdoc_options: []
84
84
  require_paths:
85
85
  - lib
@@ -94,9 +94,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
94
94
  - !ruby/object:Gem::Version
95
95
  version: '0'
96
96
  requirements: []
97
- rubyforge_project:
98
- rubygems_version: 2.5.1
99
- signing_key:
97
+ rubygems_version: 3.0.4
98
+ signing_key:
100
99
  specification_version: 4
101
- summary: conversation between CamelCase and snake_case
100
+ summary: converion between CamelCase and snake_case
102
101
  test_files: []