lite-ruby 1.0.0 → 1.0.1
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/Gemfile.lock +1 -1
- data/README.md +7 -14
- data/docs/STRING.md +8 -0
- data/docs/STRUCT.md +24 -0
- data/docs/TIME.md +8 -0
- data/lib/generators/lite/ruby/templates/install.rb +3 -11
- data/lib/lite/ruby.rb +4 -5
- data/lib/lite/ruby/configuration.rb +4 -15
- data/lib/lite/ruby/string.rb +8 -0
- data/lib/lite/ruby/struct.rb +13 -0
- data/lib/lite/ruby/time.rb +10 -0
- data/lib/lite/ruby/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ebfe63ca0039bd6f048350883e4561c313c846cdd223bcb1bc08e19d3203c8ff
|
4
|
+
data.tar.gz: 2b0cec21a13746667b3afaba2936f33928b8d9c368efd13a88312de8c54f2341
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 26e0c61e5539fd9b9691c62ec69bf942e79f08a2cc3d571a09ad337572c406637098ad0f86b50aaf5a40c138109c1898134c2a206cb09e1039c559a932c97b67
|
7
|
+
data.tar.gz: 47643cd5b5026e8e8edad9291d4528dc4739ffb1be2406713eb0b384f95e9bf39f0701540b74033067dbf8db77b24e5c02bcae8dbe639c956e77cbcaa35e3528
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
+
## [1.0.1] - 2019-07-12
|
10
|
+
### Added
|
11
|
+
- Added String => `acronym`
|
12
|
+
- Added Struct extensions
|
13
|
+
- Added Time => `elapse`
|
14
|
+
# Changed
|
15
|
+
- Configuration
|
16
|
+
|
9
17
|
## [1.0.0] - 2019-07-12
|
10
18
|
### Added
|
11
19
|
- Initial project version
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -37,17 +37,9 @@ Or install it yourself as:
|
|
37
37
|
|
38
38
|
```ruby
|
39
39
|
Lite::Ruby.configure do |config|
|
40
|
-
config.
|
41
|
-
|
42
|
-
|
43
|
-
config.hash = true
|
44
|
-
config.integer = true
|
45
|
-
config.kernel = true
|
46
|
-
config.numeric = true
|
47
|
-
config.object = true
|
48
|
-
config.range = true
|
49
|
-
config.string = true
|
50
|
-
config.time = true
|
40
|
+
config.monkey_patches = %w[
|
41
|
+
array date enumerable hash integer kernel numeric object range string struct time
|
42
|
+
]
|
51
43
|
end
|
52
44
|
```
|
53
45
|
|
@@ -63,15 +55,16 @@ end
|
|
63
55
|
* [Object](https://github.com/drexed/lite-ruby/blob/master/docs/OBJECT.md)
|
64
56
|
* [Range](https://github.com/drexed/lite-ruby/blob/master/docs/RANGE.md)
|
65
57
|
* [String](https://github.com/drexed/lite-ruby/blob/master/docs/STRING.md)
|
58
|
+
* [Struct](https://github.com/drexed/lite-ruby/blob/master/docs/STRUCT.md)
|
66
59
|
* [Time](https://github.com/drexed/lite-ruby/blob/master/docs/TIME.md)
|
67
60
|
|
68
61
|
## 3rd-party
|
69
62
|
|
70
63
|
The following are highly recommended 3rd-party extensions to supplement your workflow:
|
71
64
|
|
72
|
-
* **
|
73
|
-
* **
|
74
|
-
* **
|
65
|
+
* **Performance:** Escape Utils - https://github.com/brianmario/escape_utils
|
66
|
+
* **Performance:** Fast Blank - https://github.com/SamSaffron/fast_blank
|
67
|
+
* **Extensions:** Facets - https://github.com/rubyworks/facets
|
75
68
|
|
76
69
|
## Port
|
77
70
|
|
data/docs/STRING.md
CHANGED
data/docs/STRUCT.md
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# Struct
|
2
|
+
|
3
|
+
`attributes`
|
4
|
+
------
|
5
|
+
Returns the key values of the assigned struct.
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
person = Struct.new(:name, :age)
|
9
|
+
person.new('bob', 60)
|
10
|
+
|
11
|
+
person.attributes #=> { name: 'bob', age: 60 }
|
12
|
+
```
|
13
|
+
|
14
|
+
`replace`
|
15
|
+
------
|
16
|
+
Replaces values provided within the hash.
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
person = Struct.new(:name, :age)
|
20
|
+
person.new('bob', 60)
|
21
|
+
|
22
|
+
person.replace(name: 'tom', age: 28)
|
23
|
+
preson.name #=> 'tom'
|
24
|
+
```
|
data/docs/TIME.md
CHANGED
@@ -84,3 +84,11 @@ Converts a `time` object to a predefined format.
|
|
84
84
|
```ruby
|
85
85
|
Time.now.stamp(:datetime) #=> 'January 09, 2014 02:31 pm'
|
86
86
|
```
|
87
|
+
|
88
|
+
`elapse`
|
89
|
+
------
|
90
|
+
Returns the amount of time taken to execute a block.
|
91
|
+
|
92
|
+
```ruby
|
93
|
+
Time.elapse { sleep 1 } #=> 1.00005465
|
94
|
+
```
|
@@ -1,15 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
Lite::Ruby.configure do |config|
|
4
|
-
config.
|
5
|
-
|
6
|
-
|
7
|
-
config.hash = true
|
8
|
-
config.integer = true
|
9
|
-
config.kernel = true
|
10
|
-
config.numeric = true
|
11
|
-
config.object = true
|
12
|
-
config.range = true
|
13
|
-
config.string = true
|
14
|
-
config.time = true
|
4
|
+
config.monkey_patches = %w[
|
5
|
+
array date enumerable hash integer kernel numeric object range string struct time
|
6
|
+
]
|
15
7
|
end
|
data/lib/lite/ruby.rb
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
require
|
3
|
+
%w[version configuration].each do |filename|
|
4
|
+
require "lite/ruby/#{filename}"
|
5
|
+
end
|
5
6
|
|
6
7
|
%w[date time].each do |filename|
|
7
8
|
require "lite/ruby/helpers/#{filename}_helper"
|
8
9
|
end
|
9
10
|
|
10
|
-
|
11
|
-
next unless Lite::Ruby.configuration.send(filename)
|
12
|
-
|
11
|
+
Lite::Ruby.configuration.monkey_patches.each do |filename|
|
13
12
|
require "lite/ruby/#{filename}"
|
14
13
|
end
|
15
14
|
|
@@ -5,24 +5,13 @@ module Lite
|
|
5
5
|
|
6
6
|
class Configuration
|
7
7
|
|
8
|
-
attr_accessor :
|
9
|
-
:string, :time
|
8
|
+
attr_accessor :monkey_patches
|
10
9
|
|
11
|
-
# rubocop:disable Metrics/MethodLength
|
12
10
|
def initialize
|
13
|
-
@
|
14
|
-
|
15
|
-
|
16
|
-
@hash = true
|
17
|
-
@integer = true
|
18
|
-
@kernel = true
|
19
|
-
@numeric = true
|
20
|
-
@object = true
|
21
|
-
@range = true
|
22
|
-
@string = true
|
23
|
-
@time = true
|
11
|
+
@monkey_patches = %w[
|
12
|
+
array date enumerable hash integer kernel numeric object range string struct time
|
13
|
+
]
|
24
14
|
end
|
25
|
-
# rubocop:enable Metrics/MethodLength
|
26
15
|
|
27
16
|
end
|
28
17
|
|
data/lib/lite/ruby/string.rb
CHANGED
@@ -32,6 +32,14 @@ class String
|
|
32
32
|
'Ÿ' => 'Y', 'Ź' => 'Z', 'ź' => 'z', 'Ż' => 'Z', 'ż' => 'z', 'Ž' => 'Z', 'ž' => 'z'
|
33
33
|
}.freeze
|
34
34
|
|
35
|
+
def acronym
|
36
|
+
gsub(/(([a-zA-Z0-9])([a-zA-Z0-9])*)./, '\\2')
|
37
|
+
end
|
38
|
+
|
39
|
+
def acronym!
|
40
|
+
replace(acronym)
|
41
|
+
end
|
42
|
+
|
35
43
|
def any?(*keys)
|
36
44
|
keys.any? { |key| include?(key) }
|
37
45
|
end
|
data/lib/lite/ruby/time.rb
CHANGED
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.1
|
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-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -154,6 +154,7 @@ files:
|
|
154
154
|
- docs/OBJECT.md
|
155
155
|
- docs/RANGE.md
|
156
156
|
- docs/STRING.md
|
157
|
+
- docs/STRUCT.md
|
157
158
|
- docs/TIME.md
|
158
159
|
- lib/generators/lite/ruby/install_generator.rb
|
159
160
|
- lib/generators/lite/ruby/templates/install.rb
|
@@ -171,6 +172,7 @@ files:
|
|
171
172
|
- lib/lite/ruby/object.rb
|
172
173
|
- lib/lite/ruby/range.rb
|
173
174
|
- lib/lite/ruby/string.rb
|
175
|
+
- lib/lite/ruby/struct.rb
|
174
176
|
- lib/lite/ruby/time.rb
|
175
177
|
- lib/lite/ruby/version.rb
|
176
178
|
- lite-ruby.gemspec
|