intact_case 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +23 -0
- data/README.md +50 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/intact_case.gemspec +33 -0
- data/lib/intact_case/modules.rb +268 -0
- data/lib/intact_case/version.rb +3 -0
- data/lib/intact_case.rb +5 -0
- metadata +102 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c442c08b6d97048564ccc099f9156259db55496a
|
4
|
+
data.tar.gz: f9fcfbf4d9b3147c3b4e1f029a9a4e00c7f5048b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3bff45e27e7a2b7eb140010a60d26bc59dd8615db95361256e77511bfca94d4f7b3e4b728e7b8aea401284bfd6db2a59291f7bc5f7dc1d29b4d9bdab0a35be2d
|
7
|
+
data.tar.gz: 14a4ee350ca69901716d03820ac0d130ea0e34a8b169f5912bedf58a39e1281b5c7740f6ac7916b4f15977fc08e1c02d49de74135c76041373cee979a16550a4
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
4
|
+
|
5
|
+
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
|
6
|
+
|
7
|
+
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
8
|
+
|
9
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
10
|
+
|
11
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
12
|
+
|
13
|
+
This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Intact Case : Natural interconversion for camelCase and snake_case with acronym.
|
4
|
+
Copyright (c) 2015 Stew Eucen (http://lab.kochlein.com)
|
5
|
+
|
6
|
+
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
|
+
of this software and associated documentation files (the "Software"), to deal
|
9
|
+
in the Software without restriction, including without limitation the rights
|
10
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11
|
+
copies of the Software, and to permit persons to whom the Software is
|
12
|
+
furnished to do so, subject to the following conditions:
|
13
|
+
|
14
|
+
The above copyright notice and this permission notice shall be included in
|
15
|
+
all copies or substantial portions of the Software.
|
16
|
+
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
20
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
23
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# Intact Case for Ruby
|
2
|
+
|
3
|
+
## What's Intact Case
|
4
|
+
|
5
|
+
Intact Case is the rules for interconverting naturally camelCase|StudlyCaps and snake_case which include acronym.
|
6
|
+
|
7
|
+
camelCase / StudlyCaps|snake_case
|
8
|
+
----|----
|
9
|
+
camelCase|camel_case
|
10
|
+
SnakeCase|snake_case
|
11
|
+
PHPUnit|php__unit
|
12
|
+
getUTCDay|get_utc__day
|
13
|
+
|
14
|
+
This library can interconvert camelCase|StudlyCaps and hyphenated string.
|
15
|
+
|
16
|
+
## Installation
|
17
|
+
|
18
|
+
Add this line to your application's Gemfile:
|
19
|
+
|
20
|
+
```ruby
|
21
|
+
gem 'intact_case'
|
22
|
+
```
|
23
|
+
|
24
|
+
And then execute:
|
25
|
+
|
26
|
+
$ bundle
|
27
|
+
|
28
|
+
Or install it yourself as:
|
29
|
+
|
30
|
+
$ gem install intact_case
|
31
|
+
|
32
|
+
## Usage
|
33
|
+
|
34
|
+
When you use this library, you must understand rules of Intact Case.
|
35
|
+
|
36
|
+
If you want to see more information, please see [IntactCase](http://lab.kochlein.com/IntactCase).
|
37
|
+
|
38
|
+
## Development
|
39
|
+
|
40
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
41
|
+
|
42
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
43
|
+
|
44
|
+
## Contributing
|
45
|
+
|
46
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/StewEucen/intact-case-ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
|
47
|
+
|
48
|
+
## License
|
49
|
+
|
50
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "intact_case"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/intact_case.gemspec
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'intact_case/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "intact_case"
|
8
|
+
spec.version = IntactCase::VERSION
|
9
|
+
spec.authors = ["Stew Eucen"]
|
10
|
+
spec.email = ["stew.eucen@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Reversible convertor for camelCase and snake_case which has acronyms.}
|
13
|
+
spec.description = %q{When camelCase has acronyms, can convert it to snake_case, however it can not be converted to original camelCase with intact acronyms. Rules of Intact Case is the solution for this problem.}
|
14
|
+
spec.homepage = "http://lab.kochlein.com/IntactCase"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
18
|
+
# delete this section to allow pushing this gem to any host.
|
19
|
+
if spec.respond_to?(:metadata)
|
20
|
+
### spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
|
21
|
+
else
|
22
|
+
raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
23
|
+
end
|
24
|
+
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
26
|
+
spec.bindir = "exe"
|
27
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
|
+
spec.require_paths = ["lib"]
|
29
|
+
|
30
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
31
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
32
|
+
spec.add_development_dependency "rspec"
|
33
|
+
end
|
@@ -0,0 +1,268 @@
|
|
1
|
+
#
|
2
|
+
# Intact Case for Ruby
|
3
|
+
# Interconverting camelCase and snake_case which include acronym.
|
4
|
+
#
|
5
|
+
# @author StewEucen
|
6
|
+
# @copyright Copyright (c) 2015 Stew Eucen (http://lab.kochlein.com)
|
7
|
+
# @license http://www.opensource.org/licenses/mit-license.php MIT License
|
8
|
+
#
|
9
|
+
# @link http://lab.kochlein.com/IntactCase
|
10
|
+
# @since File available since Release 1.0.0
|
11
|
+
# @version 1.0.0
|
12
|
+
#
|
13
|
+
module StewEucen
|
14
|
+
# Name space of Stew Eucen's Acts
|
15
|
+
module Acts
|
16
|
+
# Name space of Intact Case
|
17
|
+
module IntactCase
|
18
|
+
|
19
|
+
#
|
20
|
+
# Methods to include into String class.
|
21
|
+
#
|
22
|
+
# @author StewEucen
|
23
|
+
# @example Include into String class.
|
24
|
+
# String.send :include, StewEucen::Acts::IntactCase::String
|
25
|
+
# @since Release 1.0.0
|
26
|
+
#
|
27
|
+
module String
|
28
|
+
|
29
|
+
#
|
30
|
+
# Convert compound words to camelCase from delimiterized.
|
31
|
+
#
|
32
|
+
# @author StewEucen
|
33
|
+
# @example delimiterized to camelCase.
|
34
|
+
# 'snake_case'.camelize #=> 'snakeCase'
|
35
|
+
# 'get_utc__day'.camelize #=> 'getUTCDay'
|
36
|
+
# 'ui__view'.camelize #=> 'ui_View'
|
37
|
+
# 'xml__html__request'.camelize #=> 'xml_HTMLRequest'
|
38
|
+
# @param [string] delimiter Delimiter.
|
39
|
+
# @return [string] camelCase String.
|
40
|
+
# @since Release 1.0.0
|
41
|
+
#
|
42
|
+
def camelize(delimiter = '_')
|
43
|
+
d = Regexp.escape(delimiter)
|
44
|
+
|
45
|
+
camel_head = "^([a-z]{2,}#{d})(?:#{d}|$)" # can not use (?![a-z]) because (?:)
|
46
|
+
capitalize = "(?<=#{d})([a-z])"
|
47
|
+
rear_acronym = "(?!^)([a-z]+)#{d}(?![a-z])"
|
48
|
+
cut_delimiter = "(?<=^|[a-z]{2})#{d}|#{d}(?=[a-z]{2,}(?:#{d}[a-z]|$))"
|
49
|
+
|
50
|
+
cases_pattern = /#{camel_head}|#{capitalize}|#{rear_acronym}|#{cut_delimiter}/
|
51
|
+
self.gsub(cases_pattern) { "#{$1}" + "#{$2}#{$3}".upcase }
|
52
|
+
end
|
53
|
+
|
54
|
+
#
|
55
|
+
# Convert compound words to StudlyCaps from delimiterized string.
|
56
|
+
#
|
57
|
+
# @author StewEucen
|
58
|
+
# @example delimiterized to StudlyCaps.
|
59
|
+
# 'snake_case'.studly_caps #=> 'SnakeCase'
|
60
|
+
# 'get_utc__day'.studly_caps #=> 'GetUTCDay'
|
61
|
+
# 'ui__view'.studly_caps #=> 'UIView'
|
62
|
+
# 'xml__html__request'.studly_caps #=> 'XML_HTMLRequest'
|
63
|
+
# @param [string] delimiter Delimiter.
|
64
|
+
# @return [string] StudlyCaps string.
|
65
|
+
# @since Release 1.0.0
|
66
|
+
#
|
67
|
+
def studly_caps(delimiter = '_')
|
68
|
+
((self.start_with?(delimiter) ? '' : delimiter) + self).camel_case(delimiter)
|
69
|
+
end
|
70
|
+
|
71
|
+
#
|
72
|
+
# Convert compound words connected by a delimiter from camelCase|StudlyCaps.
|
73
|
+
#
|
74
|
+
# @author StewEucen
|
75
|
+
# @example camelCase|StudlyCaps to delimiterized.
|
76
|
+
# 'camelCase'.delimiterize #=> 'camel_case'
|
77
|
+
# 'StudlyCaps'.delimiterize('_', true) #=> '_studly_caps'
|
78
|
+
# 'chainCase'.delimiterize('-') #=> 'chain-case'
|
79
|
+
# 'getUTCDay'.delimiterize #=> 'get_utc__day'
|
80
|
+
# 'UIView'.delimiterize #=> 'ui__view'
|
81
|
+
# 'XML_HTMLRequest'.delimiterize #=> 'xml__html__request'
|
82
|
+
# @param [string] delimiter Concatenate tokens with between delimiter.
|
83
|
+
# @param [boolean] as_vendor_prefix Treat as vendor-prefix (CSS).
|
84
|
+
# @return [string] Delimiterized compound words.
|
85
|
+
# @since Release 1.0.0
|
86
|
+
#
|
87
|
+
def delimiterize(delimiter = '_', as_vendor_prefix = false)
|
88
|
+
d = Regexp.escape(delimiter)
|
89
|
+
|
90
|
+
before_acronym = "(?:^[a-z]{2,}#{d}|[a-z])(?=[A-Z](?![a-z]))"
|
91
|
+
after_acronym = "[A-Z]{2,}(?![a-z])"
|
92
|
+
before_capital = "(?!^)(?=[A-Z][a-z])"
|
93
|
+
p = /#{before_acronym}|#{after_acronym}|#{before_capital}/;
|
94
|
+
|
95
|
+
head_delimiter = as_vendor_prefix && /^[A-Z]/ =~ self ? delimiter : ''
|
96
|
+
head_delimiter + self.gsub(p) { $& + delimiter }.downcase
|
97
|
+
end
|
98
|
+
|
99
|
+
#
|
100
|
+
# Hyphenate compound words from camelCase|StudlyCaps.
|
101
|
+
#
|
102
|
+
# @author StewEucen
|
103
|
+
# @example camelCase|StudlyCaps to hyphenated string.
|
104
|
+
# 'chainCase'.hyphenated #=> 'chain-case'
|
105
|
+
# 'VendorPrefix'.hyphenated(true) #=> '-vendor-prefix'
|
106
|
+
# 'camelCase'.hyphenated(true) #=> 'camel-case'
|
107
|
+
# @param [boolean] as_vendor_prefix Treat as vendor-prefix (CSS).
|
108
|
+
# @return [string] Hyphenated string.
|
109
|
+
# @since Release 1.0.0
|
110
|
+
#
|
111
|
+
def hyphenated(as_vendor_prefix = false)
|
112
|
+
self.delimiterize('-', as_vendor_prefix)
|
113
|
+
end
|
114
|
+
|
115
|
+
#
|
116
|
+
# Explode compound words to tokens.
|
117
|
+
#
|
118
|
+
# @author StewEucen
|
119
|
+
# @example Tokens from compound words.
|
120
|
+
# 'camelCase'.tokenize #=> ['Camel', 'Case']
|
121
|
+
# 'camelCase'.tokenize('_', true) #=> ['camel', 'Case']
|
122
|
+
# 'StudlyCaps'.tokenize #=> ['Studly', 'Caps']
|
123
|
+
# 'snake_case'.tokenize #=> ['snake', 'case']
|
124
|
+
# 'get_utc__day'.tokenize #=> ['get', 'utc_', 'day']
|
125
|
+
# @param [string] delimiter Delimiter.
|
126
|
+
# @param [boolean] raw_first Keep raw first word in tokens for camelCase.
|
127
|
+
# @return [array] Tokens except delimiter between acronym.
|
128
|
+
# @see _tokenize_from_camelized, _tokenize_from_delimiterized
|
129
|
+
# @since Release 1.0.0
|
130
|
+
#
|
131
|
+
def tokenize(delimiter = '_', raw_first = false)
|
132
|
+
if /[A-Z]/ =~ self then
|
133
|
+
_tokenize_from_camelized(delimiter, raw_first)
|
134
|
+
else
|
135
|
+
_tokenize_from_delimiterized(delimiter)
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
private
|
140
|
+
|
141
|
+
#
|
142
|
+
# Tokenize compound words from camelCase|StudlyCaps.
|
143
|
+
#
|
144
|
+
# @author StewEucen
|
145
|
+
# @param [string] delimiter Delimiter between acronym.
|
146
|
+
# @param [boolean] raw_first Keep raw first word in tokens for camelCase.
|
147
|
+
# @return [array] Tokens except delimiter between acronym.
|
148
|
+
# @since Release 1.0.0
|
149
|
+
#
|
150
|
+
def _tokenize_from_camelized(delimiter, raw_first)
|
151
|
+
d = Regexp.escape(delimiter)
|
152
|
+
p = /(?:[A-Z]+|[A-Z]?(?:[a-z]{2,}#{d}?|[a-z]))(?![a-z])/;
|
153
|
+
# (?: : token body
|
154
|
+
# [A-Z]+ : acronym
|
155
|
+
# | : or
|
156
|
+
# [A-Z]?(?:[a-z]{2,}#{d}?|[a-z]) : usual word|first in camelCase|
|
157
|
+
# )
|
158
|
+
# (?![a-z]) : break word same as (?=[A-Z]|_|$)
|
159
|
+
tokens = self.scan(p)
|
160
|
+
|
161
|
+
# Upcase for acronym of first word in camelCase.
|
162
|
+
tokens[0] = tokens[0].studly_caps(delimiter) unless raw_first
|
163
|
+
|
164
|
+
tokens
|
165
|
+
end
|
166
|
+
|
167
|
+
#
|
168
|
+
# Tokenize compound words from delimiterized.
|
169
|
+
#
|
170
|
+
# @author StewEucen
|
171
|
+
# @param [string] delimiter Delimiter.
|
172
|
+
# @return [array] Tokens except delimiter between acronym.
|
173
|
+
# @since Release 1.0.0
|
174
|
+
#
|
175
|
+
def _tokenize_from_delimiterized(delimiter)
|
176
|
+
d = Regexp.escape(delimiter)
|
177
|
+
p = /[a-z]+#{d}?(?![a-z])/
|
178
|
+
|
179
|
+
self.scan(p).compact
|
180
|
+
end
|
181
|
+
|
182
|
+
public
|
183
|
+
|
184
|
+
#
|
185
|
+
# Capitalize first word in compound words.
|
186
|
+
# When first word is acronym, convert it to StudlyCaps.
|
187
|
+
#
|
188
|
+
# @author StewEucen
|
189
|
+
# @example StudlyCaps from camelCase
|
190
|
+
# 'camelCase'.uc_first #=> 'CamelCase'
|
191
|
+
# 'xml_HTMLRequest'.uc_first #=> 'XML_HTMLRequest'
|
192
|
+
# @param [string] delimiter Delimiter after acronym.
|
193
|
+
# @return [string] StudlyCaps (= capitalized camelCase).
|
194
|
+
# @since Release 1.0.0
|
195
|
+
#
|
196
|
+
def uc_first(delimiter = '_')
|
197
|
+
self.delimiterize(delimiter).studly_caps(delimiter)
|
198
|
+
end
|
199
|
+
|
200
|
+
#
|
201
|
+
# Uncapitalize first word in compound words.
|
202
|
+
# When first word is acronym, convert it to delimiterized string.
|
203
|
+
#
|
204
|
+
# @author StewEucen
|
205
|
+
# @example camelCase from StudlyCaps
|
206
|
+
# 'StudlyCaps'.lc_first #=> 'studlyCaps'
|
207
|
+
# 'UIView'.lc_first #=> 'ui_View'
|
208
|
+
# @param [string] delimiter Delimiter after acronym.
|
209
|
+
# @return [string] camelCase (= uncapitalized StudlyCaps).
|
210
|
+
# @since Release 1.0.0
|
211
|
+
#
|
212
|
+
def lc_first(delimiter = '_')
|
213
|
+
self.delimiterize(delimiter).camelize(delimiter)
|
214
|
+
end
|
215
|
+
|
216
|
+
#
|
217
|
+
# a.k.a.
|
218
|
+
#
|
219
|
+
alias_infos = {
|
220
|
+
camelize: [:nerd_caps, :camel_case],
|
221
|
+
studly_caps: [:pascal_case],
|
222
|
+
delimiterize: [:snake_case, :underscored],
|
223
|
+
hyphenated: [:train_case, :chain_case, :kebab_case, :spinal_case],
|
224
|
+
}
|
225
|
+
|
226
|
+
alias_infos.each_pair do |origin_name, alias_names|
|
227
|
+
alias_names.each { |alias_name| alias_method alias_name, origin_name }
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
231
|
+
#
|
232
|
+
# Methods to include into Array class.
|
233
|
+
#
|
234
|
+
# @author StewEucen
|
235
|
+
# @example Include into String class.
|
236
|
+
# Array.send :include, StewEucen::Acts::IntactCase::Array
|
237
|
+
# @since Release 1.0.0
|
238
|
+
#
|
239
|
+
module Array
|
240
|
+
|
241
|
+
#
|
242
|
+
# Concatenate tokens (camelCase/StudlyCaps/snake_case).
|
243
|
+
#
|
244
|
+
# @author StewEucen
|
245
|
+
# @example tokens from snake_case
|
246
|
+
# ['camel', 'Case'].compound #=> 'camelCase'
|
247
|
+
# ['Studly', 'Caps'].compound #=> 'StudlyCaps'
|
248
|
+
# ['XML', 'HTML', 'Request'].compound #=> 'XML_HTMLRequest'
|
249
|
+
# ['get', 'utc_', 'day'].compound #=> 'get_utc__day'
|
250
|
+
# ['', 'webkit', 'flex'].compound('-') #=> '-webkit-flex'
|
251
|
+
# @param [string] delimiter Delimiter between acronym.
|
252
|
+
# @return [string] camelCase/StudlyCaps/snake_case.
|
253
|
+
# @since Release 1.0.0
|
254
|
+
#
|
255
|
+
def compound(delimiter = '_')
|
256
|
+
compounded = self.join(delimiter)
|
257
|
+
# When snake_case.
|
258
|
+
return compounded if /[A-Z]/ !~ compounded
|
259
|
+
|
260
|
+
d = Regexp.escape(delimiter)
|
261
|
+
p = /(?<=.[a-z])#{d}|(?<!#{d})#{d}(?=[A-Z][a-z])/
|
262
|
+
compounded.gsub(p, '')
|
263
|
+
end
|
264
|
+
end
|
265
|
+
|
266
|
+
end
|
267
|
+
end
|
268
|
+
end
|
data/lib/intact_case.rb
ADDED
metadata
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: intact_case
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Stew Eucen
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-07-14 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.10'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.10'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: When camelCase has acronyms, can convert it to snake_case, however it
|
56
|
+
can not be converted to original camelCase with intact acronyms. Rules of Intact
|
57
|
+
Case is the solution for this problem.
|
58
|
+
email:
|
59
|
+
- stew.eucen@gmail.com
|
60
|
+
executables: []
|
61
|
+
extensions: []
|
62
|
+
extra_rdoc_files: []
|
63
|
+
files:
|
64
|
+
- ".gitignore"
|
65
|
+
- ".rspec"
|
66
|
+
- ".travis.yml"
|
67
|
+
- CODE_OF_CONDUCT.md
|
68
|
+
- Gemfile
|
69
|
+
- LICENSE.txt
|
70
|
+
- README.md
|
71
|
+
- Rakefile
|
72
|
+
- bin/console
|
73
|
+
- bin/setup
|
74
|
+
- intact_case.gemspec
|
75
|
+
- lib/intact_case.rb
|
76
|
+
- lib/intact_case/modules.rb
|
77
|
+
- lib/intact_case/version.rb
|
78
|
+
homepage: http://lab.kochlein.com/IntactCase
|
79
|
+
licenses:
|
80
|
+
- MIT
|
81
|
+
metadata: {}
|
82
|
+
post_install_message:
|
83
|
+
rdoc_options: []
|
84
|
+
require_paths:
|
85
|
+
- lib
|
86
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
requirements: []
|
97
|
+
rubyforge_project:
|
98
|
+
rubygems_version: 2.4.8
|
99
|
+
signing_key:
|
100
|
+
specification_version: 4
|
101
|
+
summary: Reversible convertor for camelCase and snake_case which has acronyms.
|
102
|
+
test_files: []
|