lite-ruby 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/Gemfile.lock +5 -5
- data/docs/STRING.md +29 -0
- data/lib/lite/ruby/open_struct.rb +3 -5
- data/lib/lite/ruby/string.rb +26 -1
- data/lib/lite/ruby/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 584c043366fc46d0dd18625a51c1e0af82deeedd1e7a1b4ab7c2370930ec25b8
|
4
|
+
data.tar.gz: c89470cb71fc78bdb60dda1693885ccdd2fdb9b8d40e505b9ef52748345ac04e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1664a08d8db3007c3fb3be9818e03d82a329d2413a48f92d642cc239848a7ee7ee9368564c71f0fad83652ae0fb62584698b15542c159f600c0e9542a6c23c33
|
7
|
+
data.tar.gz: 95aa576daabe9e60cbc2704b53fbcd306c17b17246f09a5cb64dcd0a9f49d8186d4245f10d0d95f28dcd51e6e0b965d014394eaa005f46a4c1d3e948f549b09d
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
+
## [1.0.3] - 2019-07-30
|
10
|
+
### Added
|
11
|
+
- Added String => `non_possessive`
|
12
|
+
- Added String => `possessive`
|
13
|
+
- Added String => `possessive?`
|
14
|
+
|
9
15
|
## [1.0.2] - 2019-07-21
|
10
16
|
### Added
|
11
17
|
- Added Enumerable => `cluster_by`
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
lite-ruby (1.0.
|
4
|
+
lite-ruby (1.0.3)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
@@ -66,7 +66,7 @@ GEM
|
|
66
66
|
rake (>= 0.8.7)
|
67
67
|
thor (>= 0.19.0, < 2.0)
|
68
68
|
rainbow (3.0.0)
|
69
|
-
rake (12.3.
|
69
|
+
rake (12.3.3)
|
70
70
|
rspec (3.8.0)
|
71
71
|
rspec-core (~> 3.8.0)
|
72
72
|
rspec-expectations (~> 3.8.0)
|
@@ -80,16 +80,16 @@ GEM
|
|
80
80
|
diff-lcs (>= 1.2.0, < 2.0)
|
81
81
|
rspec-support (~> 3.8.0)
|
82
82
|
rspec-support (3.8.2)
|
83
|
-
rubocop (0.
|
83
|
+
rubocop (0.73.0)
|
84
84
|
jaro_winkler (~> 1.5.1)
|
85
85
|
parallel (~> 1.10)
|
86
86
|
parser (>= 2.6)
|
87
87
|
rainbow (>= 2.2.2, < 4.0)
|
88
88
|
ruby-progressbar (~> 1.7)
|
89
89
|
unicode-display_width (>= 1.4.0, < 1.7)
|
90
|
-
rubocop-performance (1.4.
|
90
|
+
rubocop-performance (1.4.1)
|
91
91
|
rubocop (>= 0.71.0)
|
92
|
-
rubocop-rspec (1.
|
92
|
+
rubocop-rspec (1.34.0)
|
93
93
|
rubocop (>= 0.60.0)
|
94
94
|
ruby-progressbar (1.10.1)
|
95
95
|
ruby_parser (3.13.1)
|
data/docs/STRING.md
CHANGED
@@ -290,6 +290,15 @@ Returns true if characters are mixedcase.
|
|
290
290
|
'example'.mixedcase? #=> false
|
291
291
|
```
|
292
292
|
|
293
|
+
`non_possessive(!)`
|
294
|
+
------
|
295
|
+
Returns the non-possession of a string.
|
296
|
+
|
297
|
+
```ruby
|
298
|
+
"test's".non_possessive #=> 'test'
|
299
|
+
"tests'".non_possessive #=> 'tests'
|
300
|
+
```
|
301
|
+
|
293
302
|
`ordinal`
|
294
303
|
------
|
295
304
|
Returns the suffix that should be added to a number to denote the position in an ordered sequence such as 1st, 2nd, 3rd, 4th.
|
@@ -338,6 +347,26 @@ Pollutes the space between every letter in a string, so it will be exempt from a
|
|
338
347
|
'test'.pollute('-') #=> 't-e-s-t-'
|
339
348
|
```
|
340
349
|
|
350
|
+
`possessive(!)`
|
351
|
+
------
|
352
|
+
Returns the possession of a string.
|
353
|
+
|
354
|
+
```ruby
|
355
|
+
'test'.possessive #=> "test's"
|
356
|
+
'tests'.possessive #=> "tests'"
|
357
|
+
```
|
358
|
+
|
359
|
+
`possessive?`
|
360
|
+
------
|
361
|
+
Returns if a string is possessive.
|
362
|
+
|
363
|
+
```ruby
|
364
|
+
"test's".possessive? #=> true
|
365
|
+
"tests'".possessive? #=> true
|
366
|
+
'test'.possessive? #=> false
|
367
|
+
'tests'.possessive? #=> false
|
368
|
+
```
|
369
|
+
|
341
370
|
`pop`
|
342
371
|
------
|
343
372
|
Returns the last character of a string.
|
@@ -11,11 +11,9 @@ class OpenStruct
|
|
11
11
|
{}
|
12
12
|
end
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
new_ostruct_member(key)
|
18
|
-
end
|
14
|
+
hash&.each do |key, val|
|
15
|
+
@table[key.to_sym] = val
|
16
|
+
new_ostruct_member(key)
|
19
17
|
end
|
20
18
|
|
21
19
|
yield self if block && block.arity == 1
|
data/lib/lite/ruby/string.rb
CHANGED
@@ -324,6 +324,31 @@ class String
|
|
324
324
|
self[-1]
|
325
325
|
end
|
326
326
|
|
327
|
+
def non_possessive
|
328
|
+
dup.non_possessive!
|
329
|
+
end
|
330
|
+
|
331
|
+
def non_possessive!
|
332
|
+
return self unless possessive?
|
333
|
+
|
334
|
+
chomp!("'s") || chomp!("'") || self
|
335
|
+
end
|
336
|
+
|
337
|
+
def possessive
|
338
|
+
return self if possessive?
|
339
|
+
|
340
|
+
possession = end_with?('s') ? "'" : "'s"
|
341
|
+
"#{self}#{possession}"
|
342
|
+
end
|
343
|
+
|
344
|
+
def possessive!
|
345
|
+
replace(possessive)
|
346
|
+
end
|
347
|
+
|
348
|
+
def possessive?
|
349
|
+
%w['s s'].any? { |pos| end_with?(pos) }
|
350
|
+
end
|
351
|
+
|
327
352
|
def push(string)
|
328
353
|
replace(concat(string))
|
329
354
|
end
|
@@ -514,7 +539,7 @@ class String
|
|
514
539
|
def truncate_words(words_count, options = {})
|
515
540
|
sep = options[:separator] || /\s+/
|
516
541
|
sep = Regexp.escape(sep.to_s) unless sep.is_a(Regexp)
|
517
|
-
return self unless
|
542
|
+
return self unless /\A((?:.+?#{sep}){#{words_count - 1}}.+?)#{sep}.*/m.match?(self)
|
518
543
|
|
519
544
|
"#{::Regexp.last_match(1)}#{options[:omissio] || '...'}"
|
520
545
|
end
|
data/lib/lite/ruby/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lite-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Juan Gomez
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-07-
|
11
|
+
date: 2019-07-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|