strings-case 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +19 -2
- data/LICENSE.txt +1 -1
- data/README.md +231 -131
- data/lib/strings/case/acronyms.rb +111 -0
- data/lib/strings/case/configuration.rb +55 -0
- data/lib/strings/case/extensions.rb +56 -6
- data/lib/strings/case/version.rb +4 -4
- data/lib/strings/case.rb +232 -133
- metadata +17 -41
- data/Rakefile +0 -8
- data/spec/perf/parsecase_spec.rb +0 -22
- data/spec/spec_helper.rb +0 -39
- data/spec/unit/camelcase_spec.rb +0 -51
- data/spec/unit/constcase_spec.rb +0 -44
- data/spec/unit/extensions_spec.rb +0 -75
- data/spec/unit/headercase_spec.rb +0 -50
- data/spec/unit/kebabcase_spec.rb +0 -48
- data/spec/unit/pascalcase_spec.rb +0 -51
- data/spec/unit/pathcase_spec.rb +0 -51
- data/spec/unit/sentencecase_spec.rb +0 -51
- data/spec/unit/snakecase_spec.rb +0 -51
- data/spec/unit/titlecase_spec.rb +0 -51
- data/strings-case.gemspec +0 -32
- data/tasks/console.rake +0 -11
- data/tasks/coverage.rake +0 -11
- data/tasks/spec.rake +0 -34
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 321f95c3ae804e7b64eddc3566fcec63b3be6e5f81804cc236cc4187ff1fcc59
|
4
|
+
data.tar.gz: 7aee26f0af7f322b9c54b3c7e672849e050290de91c3b604be512a5ed7a839ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f1e29519c62ae22f61797bf59f65c76fef22e7b6050db7a6bdec4c74c13495b9d61d2fcc4b9f51710c089a0923dc9c6ca10e6bdd52d56ca34075aca730be508f
|
7
|
+
data.tar.gz: bc754e29be3e76326de7da906d214abe7299e20a51ef5837996bf0cd8a1e20f03b127900e2e3de9fccae6ca546ae83bde277c6b9bf9e474597602a2efd7c668f
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,21 @@
|
|
1
1
|
# Change log
|
2
2
|
|
3
|
+
## [v0.4.0] - 2023-11-19
|
4
|
+
|
5
|
+
### Added
|
6
|
+
* Add the ability to configure acronyms on an instance
|
7
|
+
|
8
|
+
### Changed
|
9
|
+
* Change Strings::Case to be a class to allow instantiation
|
10
|
+
* Change all conversions to apply acronyms configured on an instance
|
11
|
+
* Change all conversions to preserve non-alphanumeric characters
|
12
|
+
* Change all conversions to allow for one-letter words
|
13
|
+
* Change gemspec to only package the source files and documentation
|
14
|
+
* Change parsecase method to improve performance
|
15
|
+
* Change extensions to require core library when loaded
|
16
|
+
* Change Strings::Case class to hide constants
|
17
|
+
* Change Strings::Case class to hide instance method
|
18
|
+
|
3
19
|
## [v0.3.0] - 2019-12-07
|
4
20
|
|
5
21
|
### Added
|
@@ -17,6 +33,7 @@
|
|
17
33
|
|
18
34
|
* Initial implementation and release
|
19
35
|
|
20
|
-
[v0.
|
36
|
+
[v0.4.0]: https://github.com/piotrmurach/strings-case/compare/v0.3.0...v0.4.0
|
37
|
+
[v0.3.0]: https://github.com/piotrmurach/strings-case/compare/v0.2.0...v0.3.0
|
21
38
|
[v0.2.0]: https://github.com/piotrmurach/strings-case/compare/v0.1.0...v0.2.0
|
22
|
-
[v0.1.0]: https://github.com/piotrmurach/strings-case/compare/v0.1.0
|
39
|
+
[v0.1.0]: https://github.com/piotrmurach/strings-case/compare/03679ef...v0.1.0
|
data/LICENSE.txt
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
The MIT License (MIT)
|
2
2
|
|
3
|
-
Copyright (c) 2019 Piotr Murach
|
3
|
+
Copyright (c) 2019 Piotr Murach (piotrmurach.com)
|
4
4
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
data/README.md
CHANGED
@@ -5,45 +5,35 @@
|
|
5
5
|
# Strings::Case
|
6
6
|
|
7
7
|
[![Gem Version](https://badge.fury.io/rb/strings-case.svg)][gem]
|
8
|
-
[![
|
8
|
+
[![Actions CI](https://github.com/piotrmurach/strings-case/actions/workflows/ci.yml/badge.svg)][gh_actions_ci]
|
9
9
|
[![Build status](https://ci.appveyor.com/api/projects/status/yr87c96wxp1cw2ep?svg=true)][appveyor]
|
10
10
|
[![Maintainability](https://api.codeclimate.com/v1/badges/7938258c4af196a19843/maintainability)][codeclimate]
|
11
11
|
[![Coverage Status](https://coveralls.io/repos/github/piotrmurach/strings-case/badge.svg?branch=master)][coverage]
|
12
|
-
[![Inline docs](http://inch-ci.org/github/piotrmurach/strings-case.svg?branch=master)][inchpages]
|
13
12
|
|
14
13
|
[gem]: http://badge.fury.io/rb/strings-case
|
15
|
-
[
|
14
|
+
[gh_actions_ci]: https://github.com/piotrmurach/strings-case/actions/workflows/ci.yml
|
16
15
|
[appveyor]: https://ci.appveyor.com/project/piotrmurach/strings-case
|
17
16
|
[codeclimate]: https://codeclimate.com/github/piotrmurach/strings-case/maintainability
|
18
17
|
[coverage]: https://coveralls.io/github/piotrmurach/strings-case?branch=master
|
19
|
-
[inchpages]: http://inch-ci.org/github/piotrmurach/strings-case
|
20
18
|
|
21
19
|
> Convert strings to different cases.
|
22
20
|
|
23
|
-
**Strings::Case** provides string case conversions for
|
21
|
+
**Strings::Case** provides string case conversions for
|
22
|
+
[Strings](https://github.com/piotrmurach/strings) utilities.
|
24
23
|
|
25
|
-
##
|
26
|
-
|
27
|
-
Popular solutions that deal with transforming string cases work well in simple cases.(Sorry ;-) With more complex strings you may get unexpected results:
|
28
|
-
|
29
|
-
```ruby
|
30
|
-
ActiveSupport::Inflector.underscore("supports IPv6 on iOS?")
|
31
|
-
# => "supports i_pv6 on i_os?"
|
32
|
-
```
|
33
|
-
|
34
|
-
In contrast, `Strings::Case` aims to be able to transform any string to expected case:
|
24
|
+
## Features
|
35
25
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
26
|
+
* No monkey-patching String class
|
27
|
+
* Convert strings to many common cases
|
28
|
+
* Support for Unicode characters
|
29
|
+
* Preserve acronyms
|
40
30
|
|
41
31
|
## Installation
|
42
32
|
|
43
33
|
Add this line to your application's Gemfile:
|
44
34
|
|
45
35
|
```ruby
|
46
|
-
gem
|
36
|
+
gem "strings-case"
|
47
37
|
```
|
48
38
|
|
49
39
|
And then execute:
|
@@ -54,218 +44,307 @@ Or install it yourself as:
|
|
54
44
|
|
55
45
|
$ gem install strings-case
|
56
46
|
|
57
|
-
|
58
|
-
## Features
|
59
|
-
|
60
|
-
* No monkey-patching String class
|
61
|
-
* Converts any string to specified case
|
62
|
-
* Supports Unicode characters
|
63
|
-
* Provides many common case transformations
|
64
|
-
* Allows to preserve casing of acronyms
|
65
|
-
|
66
47
|
## Contents
|
67
48
|
|
68
49
|
* [1. Usage](#1-usage)
|
69
50
|
* [2. API](#2-api)
|
70
|
-
* [2.1
|
71
|
-
* [2.2
|
72
|
-
* [2.3
|
73
|
-
* [2.4
|
74
|
-
* [2.5
|
75
|
-
* [2.6
|
76
|
-
* [2.7
|
77
|
-
* [2.8
|
78
|
-
* [2.9
|
51
|
+
* [2.1 configure](#21-configure)
|
52
|
+
* [2.2 camelcase](#22-camelcase)
|
53
|
+
* [2.3 constcase](#23-constcase)
|
54
|
+
* [2.4 headercase](#24-headercase)
|
55
|
+
* [2.5 kebabcase \| dashcase](#25-kebabcase--dashcase)
|
56
|
+
* [2.6 pascalcase](#26-pascalcase)
|
57
|
+
* [2.7 pathcase](#27-pathcase)
|
58
|
+
* [2.8 sentencecase](#28-sentencecase)
|
59
|
+
* [2.9 snakecase \| underscore](#29-snakecase--underscore)
|
60
|
+
* [2.10 titlecase](#210-titlecase)
|
79
61
|
* [3. Extending String class](#3-extending-string-class)
|
80
62
|
|
81
63
|
## 1. Usage
|
82
64
|
|
83
|
-
|
65
|
+
Start by creating an instance of the `Strings::Case` class:
|
84
66
|
|
85
67
|
```ruby
|
86
|
-
Strings::Case.
|
68
|
+
strings = Strings::Case.new
|
69
|
+
```
|
70
|
+
|
71
|
+
Then, use one of many case conversion methods, for example,
|
72
|
+
the `snakecase` method:
|
73
|
+
|
74
|
+
```ruby
|
75
|
+
strings.snakecase("FooBarBaz")
|
87
76
|
# => "foo_bar_baz"
|
88
|
-
|
77
|
+
```
|
89
78
|
|
90
|
-
|
79
|
+
As a convenience, case conversion methods are also available on class:
|
91
80
|
|
92
81
|
```ruby
|
93
|
-
Strings::Case.snakecase("
|
94
|
-
# => "
|
82
|
+
Strings::Case.snakecase("FooBarBaz")
|
83
|
+
# => "foo_bar_baz"
|
95
84
|
```
|
96
85
|
|
97
|
-
|
86
|
+
Case conversion methods will transform any string into an expected case:
|
98
87
|
|
99
88
|
```ruby
|
100
|
-
|
89
|
+
strings.snakecase("supports IPv6 on iOS?")
|
90
|
+
# => "supports_i_pv6_on_i_os"
|
91
|
+
```
|
92
|
+
|
93
|
+
The methods also support converting Unicode characters:
|
94
|
+
|
95
|
+
```ruby
|
96
|
+
strings.snakecase("ЗдравствуйтеПривет")
|
101
97
|
# => "здравствуйте_привет"
|
102
98
|
```
|
103
99
|
|
104
|
-
|
100
|
+
To preserve acronyms for all case conversions, configure them once
|
101
|
+
on an instance:
|
102
|
+
|
103
|
+
```ruby
|
104
|
+
strings.configure do |config|
|
105
|
+
config.acronym "IPv6"
|
106
|
+
config.acronym "iOS"
|
107
|
+
end
|
108
|
+
```
|
109
|
+
|
110
|
+
This will preserve acronyms for any case conversion method:
|
111
|
+
|
112
|
+
```ruby
|
113
|
+
strings.snakecase("supports IPv6 on iOS?")
|
114
|
+
# => "supports_ipv6_on_ios"
|
115
|
+
```
|
116
|
+
|
117
|
+
Or, use the `acronyms` keyword in a case conversion method:
|
118
|
+
|
119
|
+
```ruby
|
120
|
+
strings.snakecase("supports IPv6 on iOS?", acronyms: %w[IPv6 iOS])
|
121
|
+
# => "supports_ipv6_on_ios"
|
122
|
+
```
|
105
123
|
|
106
|
-
|
107
|
-
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
124
|
+
Here is a quick summary of available case conversions:
|
125
|
+
|
126
|
+
| Case Type | Result |
|
127
|
+
| ----------------------------- | --------------- |
|
128
|
+
| `camelcase("foo bar baz")` | `"fooBarBaz"` |
|
129
|
+
| `constcase("foo bar baz")` | `"FOO_BAR_BAZ"` |
|
130
|
+
| `headercase("foo bar baz")` | `"Foo-Bar-Baz"` |
|
131
|
+
| `kebabcase("foo bar baz")` | `"foo-bar-baz"` |
|
132
|
+
| `pascalcase("foo bar baz")` | `"FooBarBaz"` |
|
133
|
+
| `pathcase("foo bar baz")` | `"foo/bar/baz"` |
|
134
|
+
| `sentencecase("foo bar baz")` | `"Foo bar baz"` |
|
135
|
+
| `snakecase("foo bar baz")` | `"foo_bar_baz"` |
|
136
|
+
| `titlecase("foo bar baz")` | `"Foo Bar Baz"` |
|
117
137
|
|
118
138
|
## 2. API
|
119
139
|
|
120
|
-
### 2.1
|
140
|
+
### 2.1 configure
|
141
|
+
|
142
|
+
Use the `acronyms` keyword at initialization to add acronyms for all
|
143
|
+
case conversions.
|
121
144
|
|
122
|
-
|
145
|
+
For example, to add `HTTP` and `XML` acronyms:
|
123
146
|
|
124
147
|
```ruby
|
125
|
-
Strings::Case.
|
126
|
-
# => "httpResponseCode"
|
148
|
+
strings = Strings::Case.new(acronyms: %w[HTTP XML])
|
127
149
|
```
|
128
150
|
|
129
|
-
|
151
|
+
After initialization, use the `configure` method to add acronyms
|
152
|
+
in a block with the `acronym` method:
|
130
153
|
|
131
154
|
```ruby
|
132
|
-
|
133
|
-
|
155
|
+
strings.configure do |config|
|
156
|
+
config.acronym "HTTP"
|
157
|
+
config.acronym "XML"
|
158
|
+
|
159
|
+
# or config.acronym "HTTP", "XML"
|
160
|
+
end
|
134
161
|
```
|
135
162
|
|
136
|
-
|
163
|
+
Or, use the `configure` method with the `acronyms` keyword:
|
137
164
|
|
138
|
-
|
165
|
+
```ruby
|
166
|
+
strings.configure(acronyms: %w[HTTP XML])
|
167
|
+
```
|
168
|
+
|
169
|
+
This will result in a conversion preserving acronyms:
|
139
170
|
|
140
171
|
```ruby
|
141
|
-
|
142
|
-
# => "
|
172
|
+
strings.camelcase("xml_http_request")
|
173
|
+
# => "XMLHTTPRequest"
|
143
174
|
```
|
144
175
|
|
145
|
-
### 2.
|
176
|
+
### 2.2 camelcase
|
146
177
|
|
147
|
-
|
178
|
+
Use the `camelcase` method to convert a string into a camel case. It will
|
179
|
+
lowercase first and capitalise all remaining words, joining them by
|
180
|
+
removing any space. For example:
|
148
181
|
|
149
182
|
```ruby
|
150
|
-
|
151
|
-
# => "
|
183
|
+
strings.camelcase("PostgreSQL adapter")
|
184
|
+
# => "postgreSqlAdapter"
|
152
185
|
```
|
153
186
|
|
154
|
-
|
187
|
+
Use the `acronyms` keyword to preserve acronyms:
|
155
188
|
|
156
189
|
```ruby
|
157
|
-
|
158
|
-
# => "
|
190
|
+
strings.camelcase("PostgreSQL adapter", acronyms: ["PostgreSQL"])
|
191
|
+
# => "PostgreSQLAdapter"
|
159
192
|
```
|
160
|
-
### 2.4 kebabcase | dashcase
|
161
193
|
|
162
|
-
|
194
|
+
### 2.3 constcase
|
195
|
+
|
196
|
+
Use the `constcase` method to convert a string into a constant case. It will
|
197
|
+
uppercase all words and separate them with an underscore `_`. For example:
|
163
198
|
|
164
199
|
```ruby
|
165
|
-
|
166
|
-
# => "
|
200
|
+
strings.constcase("PostgreSQL adapter")
|
201
|
+
# => "POSTGRE_SQL_ADAPTER"
|
167
202
|
```
|
168
203
|
|
169
|
-
|
204
|
+
Use the `acronyms` keyword to preserve acronyms:
|
170
205
|
|
171
206
|
```ruby
|
172
|
-
|
207
|
+
strings.constcase("PostgreSQL adapter", acronyms: ["PostgreSQL"])
|
208
|
+
# => "POSTGRESQL_ADAPTER"
|
209
|
+
```
|
173
210
|
|
174
|
-
|
211
|
+
### 2.4 headercase
|
212
|
+
|
213
|
+
Use the `headercase` method to convert a string into a header case. It will
|
214
|
+
capitalise all words and separate them with a hyphen `-`. For example:
|
215
|
+
|
216
|
+
```ruby
|
217
|
+
strings.headercase("PostgreSQL adapter")
|
218
|
+
# => "Postgre-Sql-Adapter"
|
175
219
|
```
|
176
220
|
|
177
|
-
|
221
|
+
Use the `acronyms` keyword to preserve acronyms:
|
178
222
|
|
179
|
-
|
223
|
+
```ruby
|
224
|
+
strings.headercase("PostgreSQL adapter", acronyms: ["PostgreSQL"])
|
225
|
+
# => "PostgreSQL-Adapter"
|
226
|
+
```
|
227
|
+
|
228
|
+
### 2.5 kebabcase | dashcase
|
229
|
+
|
230
|
+
Use the `kebabcase` or `dashcase` method to convert a string into a kebab case.
|
231
|
+
It will lowercase all words and separate them with a dash `-` like a words
|
232
|
+
kebab on a skewer. For example:
|
180
233
|
|
181
234
|
```ruby
|
182
|
-
|
183
|
-
# => "
|
235
|
+
strings.kebabcase("PostgreSQL adapter")
|
236
|
+
# => "postgre-sql-adapter"
|
184
237
|
```
|
185
238
|
|
186
|
-
|
239
|
+
Use the `acronyms` keyword to preserve acronyms:
|
187
240
|
|
188
241
|
```ruby
|
189
|
-
|
190
|
-
# => "
|
242
|
+
strings.dashcase("PostgreSQL adapter", acronyms: ["PostgreSQL"])
|
243
|
+
# => "postgresql-adapter"
|
191
244
|
```
|
192
245
|
|
193
|
-
### 2.6
|
246
|
+
### 2.6 pascalcase
|
194
247
|
|
195
|
-
|
248
|
+
Use the `pascalcase` method to convert a string into a Pascal case. It will
|
249
|
+
capitalise all words and join them by removing any space. For example:
|
196
250
|
|
197
251
|
```ruby
|
198
|
-
|
199
|
-
# => "
|
200
|
-
|
252
|
+
strings.pascalcase("PostgreSQL adapter")
|
253
|
+
# => "PostgreSqlAdapter"
|
254
|
+
```
|
201
255
|
|
202
|
-
|
256
|
+
Use the `acronyms` keyword to preserve acronyms:
|
203
257
|
|
204
258
|
```ruby
|
205
|
-
|
206
|
-
# => "
|
259
|
+
strings.pascalcase("PostgreSQL adapter", acronyms: ["PostgreSQL"])
|
260
|
+
# => "PostgreSQLAdapter"
|
207
261
|
```
|
208
262
|
|
209
|
-
|
263
|
+
### 2.7 pathcase
|
264
|
+
|
265
|
+
Use the `pathcase` to convert a string into a path case. It will lowercase
|
266
|
+
all words and join them with a forward slash `/`. For example:
|
210
267
|
|
211
268
|
```ruby
|
212
|
-
|
213
|
-
# => "
|
269
|
+
strings.pathcase("PostgreSQL adapter")
|
270
|
+
# => "postgre/sql/adapter"
|
214
271
|
```
|
215
272
|
|
216
|
-
|
273
|
+
Use the `acronyms` keyword to preserve acronyms:
|
217
274
|
|
218
|
-
|
275
|
+
```ruby
|
276
|
+
strings.pathcase("PostgreSQL adapter", acronyms: ["PostgreSQL"])
|
277
|
+
# => "postgresql/adapter"
|
278
|
+
```
|
279
|
+
|
280
|
+
Use the `separator` keyword to change the default forward slash `/` path
|
281
|
+
separator. For example, to use backslash `\` as a path separator:
|
219
282
|
|
220
283
|
```ruby
|
221
|
-
|
222
|
-
# => "
|
284
|
+
strings.pathcase("PostgreSQL adapter", separator: "\\")
|
285
|
+
# => "postgre\\sql\\adapter"
|
223
286
|
```
|
224
287
|
|
225
|
-
|
288
|
+
### 2.8 sentencecase
|
289
|
+
|
290
|
+
Use the `sentencecase` to convert a string into a sentence case. It will
|
291
|
+
capitalise first and lowercase all remaining words, separating them with
|
292
|
+
space. For example:
|
226
293
|
|
227
294
|
```ruby
|
228
|
-
|
229
|
-
# => "
|
295
|
+
strings.sentencecase("PostgreSQL adapter")
|
296
|
+
# => "Postgre sql adapter"
|
230
297
|
```
|
231
298
|
|
232
|
-
|
299
|
+
Use the `acronyms` keyword to preserve acronyms:
|
233
300
|
|
234
|
-
|
301
|
+
```ruby
|
302
|
+
strings.sentencecase("PostgreSQL adapter", acronyms: ["PostgreSQL"])
|
303
|
+
# => "PostgreSQL adapter"
|
304
|
+
```
|
305
|
+
|
306
|
+
### 2.9 snakecase | underscore
|
307
|
+
|
308
|
+
Use the `snakecase` or `underscore` method to convert a string into
|
309
|
+
a snake case. It will lowercase all words and separate them with
|
310
|
+
an underscore `_`. For example:
|
235
311
|
|
236
312
|
```ruby
|
237
|
-
|
238
|
-
# => "
|
313
|
+
strings.snakecase("PostgreSQL adapter")
|
314
|
+
# => "postgre_sql_adapter"
|
239
315
|
```
|
240
316
|
|
241
|
-
|
317
|
+
Use the `acronyms` keyword to preserve acronyms:
|
242
318
|
|
243
319
|
```ruby
|
244
|
-
|
245
|
-
# => "
|
320
|
+
strings.underscore("PostgreSQL adapter", acronyms: ["PostgreSQL"])
|
321
|
+
# => "postgresql_adapter"
|
246
322
|
```
|
247
323
|
|
248
|
-
### 2.
|
324
|
+
### 2.10 titlecase
|
249
325
|
|
250
|
-
|
326
|
+
Use `titlecase` to convert a string into a title case. It will capitalise all
|
327
|
+
words and separate them with space. For example:
|
251
328
|
|
252
329
|
```ruby
|
253
|
-
|
254
|
-
# => "
|
330
|
+
strings.titlecase("PostgreSQL adapter")
|
331
|
+
# => "Postgre Sql Adapter"
|
255
332
|
```
|
256
333
|
|
257
|
-
|
334
|
+
Use the `acronyms` keyword to preserve acronyms:
|
258
335
|
|
259
336
|
```ruby
|
260
|
-
|
261
|
-
# => "
|
337
|
+
strings.titlecase("PostgreSQL adapter", acronyms: ["PostgreSQL"])
|
338
|
+
# => "PostgreSQL Adapter"
|
262
339
|
```
|
263
340
|
|
264
341
|
## 3. Extending String class
|
265
342
|
|
266
|
-
|
343
|
+
Polluting core Ruby classes globally may have unintended consequences.
|
344
|
+
Instead, consider adding the required methods to the `String` class
|
345
|
+
using refinements.
|
267
346
|
|
268
|
-
For example,
|
347
|
+
For example, to extend the `String` class with only the `snakecase` method:
|
269
348
|
|
270
349
|
```ruby
|
271
350
|
module MyStringExt
|
@@ -277,7 +356,8 @@ module MyStringExt
|
|
277
356
|
end
|
278
357
|
```
|
279
358
|
|
280
|
-
Then
|
359
|
+
Then using refinement will make the `snakecase` method available
|
360
|
+
for any string:
|
281
361
|
|
282
362
|
```ruby
|
283
363
|
using MyStringExt
|
@@ -286,31 +366,51 @@ using MyStringExt
|
|
286
366
|
# => "foo_bar_baz"
|
287
367
|
```
|
288
368
|
|
289
|
-
|
369
|
+
Load `Strings::Case::Extensions` refinement to extend the `String` class
|
370
|
+
with all case conversion methods:
|
290
371
|
|
291
372
|
```ruby
|
292
373
|
require "strings/case/extensions"
|
293
374
|
|
294
375
|
using Strings::Case::Extensions
|
376
|
+
|
377
|
+
"foo bar baz".camelcase
|
378
|
+
# => "fooBarBaz"
|
379
|
+
|
380
|
+
"foo bar baz".snakecase
|
381
|
+
# => "foo_bar_baz"
|
295
382
|
```
|
296
383
|
|
297
384
|
## Development
|
298
385
|
|
299
|
-
After checking out the repo, run `bin/setup` to install dependencies.
|
386
|
+
After checking out the repo, run `bin/setup` to install dependencies.
|
387
|
+
Then, run `rake spec` to run the tests. You can also run `bin/console`
|
388
|
+
for an interactive prompt that will allow you to experiment.
|
300
389
|
|
301
|
-
To install this gem onto your local machine, run `bundle exec rake install`.
|
390
|
+
To install this gem onto your local machine, run `bundle exec rake install`.
|
391
|
+
To release a new version, update the version number in `version.rb`, and
|
392
|
+
then run `bundle exec rake release`, which will create a git tag for
|
393
|
+
the version, push git commits and tags, and push the `.gem` file to
|
394
|
+
[rubygems.org](https://rubygems.org).
|
302
395
|
|
303
396
|
## Contributing
|
304
397
|
|
305
|
-
Bug reports and pull requests are welcome on GitHub at
|
398
|
+
Bug reports and pull requests are welcome on GitHub at
|
399
|
+
https://github.com/piotrmurach/strings-case. This project is intended to be
|
400
|
+
a safe, welcoming space for collaboration, and contributors are expected
|
401
|
+
to adhere to the [Contributor Covenant](http://contributor-covenant.org)
|
402
|
+
code of conduct.
|
306
403
|
|
307
404
|
## License
|
308
405
|
|
309
|
-
The gem is available as open source under the terms of the
|
406
|
+
The gem is available as open source under the terms of the
|
407
|
+
[MIT License](https://opensource.org/licenses/MIT).
|
310
408
|
|
311
409
|
## Code of Conduct
|
312
410
|
|
313
|
-
Everyone interacting in the Strings::Case project’s codebases, issue trackers,
|
411
|
+
Everyone interacting in the Strings::Case project’s codebases, issue trackers,
|
412
|
+
chat rooms and mailing lists is expected to follow the
|
413
|
+
[code of conduct](https://github.com/piotrmurach/strings-case/blob/master/CODE_OF_CONDUCT.md).
|
314
414
|
|
315
415
|
## Copyright
|
316
416
|
|