lite-ruby 1.1.3 → 1.1.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7713f3546f3dd3a4c172e10e7aa332869d2d294ec312795d6d1f2492dea5d8ff
4
- data.tar.gz: df391d0705345f9c881a897bbdd3505655812b887b3e85e3ef9a0124a83c22c9
3
+ metadata.gz: b5cc9dd9687e74df36b99aef11ca0b804161e5bf63b96872e1aa04974127c0fe
4
+ data.tar.gz: 784f195955ead892563a881ecccbb548f5faf95057c12408c7f94619a9fe182a
5
5
  SHA512:
6
- metadata.gz: 66b6cce96af1d4f3125a73086791a08e911e43473e9c2cb02c54b47c3e9e1e08876cb351619831fe5a465e58fe700e3db22c61ef6fcea3f6566d3bf433fc3a1a
7
- data.tar.gz: ee3c87ee3db742a29f975a28aeffeac7877143df46a74a80dc123dc3d8ec687cf507d8a1150c6852753d575b503c0bd087a55efee1cd89061cf714313edd86ef
6
+ metadata.gz: '093d15a0c4579fcd4230de82edf2d78975a30b12e7e9a63ea2d7d0cc29832a019add61192eea7a6bcb65c6018d22e411cb2bee6dcee4bc169da5b3f5063a80be'
7
+ data.tar.gz: 8ddcdfdd7059f5cb9d54b64f4598b9dc0747e9f3d8f1e49c865b4477369cad0c414ac89be4eb9e7d87b4e9d9a04d75de745fd61fef71c8defd880bf566e85a56
data/.rubocop.yml CHANGED
@@ -1,5 +1,6 @@
1
1
  require:
2
2
  - rubocop-performance
3
+ - rubocop-rake
3
4
  - rubocop-rspec
4
5
  AllCops:
5
6
  TargetRubyVersion: 2.7
data/CHANGELOG.md CHANGED
@@ -6,6 +6,30 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [1.1.8] - 2021-07-05
10
+ ### Changed
11
+ - Linter fixes
12
+
13
+ ## [1.1.7] - 2021-03-04
14
+ ### Added
15
+ - Added Integer => `SQL_SMALLINT`
16
+ - Added Integer => `SQL_INTEGER`
17
+ - Added Integer => `SQL_BIGINT`
18
+
19
+ ## [1.1.6] - 2021-02-17
20
+ ### Added
21
+ - Added Time => `monotonic`
22
+ ### Changed
23
+ - Time `elapse` to use monotonic time
24
+
25
+ ## [1.1.5] - 2021-02-16
26
+ ### Added
27
+ - Added Array => `divergence`
28
+
29
+ ## [1.1.4] - 2020-11-19
30
+ ### Changed
31
+ - Object `array?` coerce ARGV check from nil to string
32
+
9
33
  ## [1.1.3] - 2020-11-18
10
34
  ### Changed
11
35
  - Object `array?` does not clash with PG gem
data/Gemfile.lock CHANGED
@@ -1,56 +1,58 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lite-ruby (1.1.3)
4
+ lite-ruby (1.1.8)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- actionpack (6.0.3.4)
10
- actionview (= 6.0.3.4)
11
- activesupport (= 6.0.3.4)
12
- rack (~> 2.0, >= 2.0.8)
9
+ actionpack (6.1.3.2)
10
+ actionview (= 6.1.3.2)
11
+ activesupport (= 6.1.3.2)
12
+ rack (~> 2.0, >= 2.0.9)
13
13
  rack-test (>= 0.6.3)
14
14
  rails-dom-testing (~> 2.0)
15
15
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
16
- actionview (6.0.3.4)
17
- activesupport (= 6.0.3.4)
16
+ actionview (6.1.3.2)
17
+ activesupport (= 6.1.3.2)
18
18
  builder (~> 3.1)
19
19
  erubi (~> 1.4)
20
20
  rails-dom-testing (~> 2.0)
21
21
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
22
- activesupport (6.0.3.4)
22
+ activesupport (6.1.3.2)
23
23
  concurrent-ruby (~> 1.0, >= 1.0.2)
24
- i18n (>= 0.7, < 2)
25
- minitest (~> 5.1)
26
- tzinfo (~> 1.1)
27
- zeitwerk (~> 2.2, >= 2.2.2)
28
- ast (2.4.1)
24
+ i18n (>= 1.6, < 2)
25
+ minitest (>= 5.1)
26
+ tzinfo (~> 2.0)
27
+ zeitwerk (~> 2.3)
28
+ ast (2.4.2)
29
29
  builder (3.2.4)
30
30
  colorize (0.8.1)
31
- concurrent-ruby (1.1.7)
31
+ concurrent-ruby (1.1.8)
32
32
  crass (1.0.6)
33
33
  diff-lcs (1.4.4)
34
34
  erubi (1.10.0)
35
- fasterer (0.8.3)
35
+ fasterer (0.9.0)
36
36
  colorize (~> 0.7)
37
37
  ruby_parser (>= 3.14.1)
38
38
  generator_spec (0.9.4)
39
39
  activesupport (>= 3.0.0)
40
40
  railties (>= 3.0.0)
41
- i18n (1.8.5)
41
+ i18n (1.8.10)
42
42
  concurrent-ruby (~> 1.0)
43
- loofah (2.7.0)
43
+ loofah (2.9.1)
44
44
  crass (~> 1.0.2)
45
45
  nokogiri (>= 1.5.9)
46
46
  method_source (1.0.0)
47
- mini_portile2 (2.4.0)
48
- minitest (5.14.2)
49
- nokogiri (1.10.10)
50
- mini_portile2 (~> 2.4.0)
51
- parallel (1.20.0)
52
- parser (2.7.2.0)
47
+ mini_portile2 (2.5.1)
48
+ minitest (5.14.4)
49
+ nokogiri (1.11.3)
50
+ mini_portile2 (~> 2.5.0)
51
+ racc (~> 1.4)
52
+ parallel (1.20.1)
53
+ parser (3.0.1.1)
53
54
  ast (~> 2.4.1)
55
+ racc (1.5.2)
54
56
  rack (2.2.3)
55
57
  rack-test (1.1.0)
56
58
  rack (>= 1.0, < 3)
@@ -59,56 +61,57 @@ GEM
59
61
  nokogiri (>= 1.6)
60
62
  rails-html-sanitizer (1.3.0)
61
63
  loofah (~> 2.3)
62
- railties (6.0.3.4)
63
- actionpack (= 6.0.3.4)
64
- activesupport (= 6.0.3.4)
64
+ railties (6.1.3.2)
65
+ actionpack (= 6.1.3.2)
66
+ activesupport (= 6.1.3.2)
65
67
  method_source
66
68
  rake (>= 0.8.7)
67
- thor (>= 0.20.3, < 2.0)
69
+ thor (~> 1.0)
68
70
  rainbow (3.0.0)
69
- rake (13.0.1)
70
- regexp_parser (1.8.2)
71
- rexml (3.2.4)
71
+ rake (13.0.3)
72
+ regexp_parser (2.1.1)
73
+ rexml (3.2.5)
72
74
  rspec (3.10.0)
73
75
  rspec-core (~> 3.10.0)
74
76
  rspec-expectations (~> 3.10.0)
75
77
  rspec-mocks (~> 3.10.0)
76
- rspec-core (3.10.0)
78
+ rspec-core (3.10.1)
77
79
  rspec-support (~> 3.10.0)
78
- rspec-expectations (3.10.0)
80
+ rspec-expectations (3.10.1)
79
81
  diff-lcs (>= 1.2.0, < 2.0)
80
82
  rspec-support (~> 3.10.0)
81
- rspec-mocks (3.10.0)
83
+ rspec-mocks (3.10.2)
82
84
  diff-lcs (>= 1.2.0, < 2.0)
83
85
  rspec-support (~> 3.10.0)
84
- rspec-support (3.10.0)
85
- rubocop (1.3.1)
86
+ rspec-support (3.10.2)
87
+ rubocop (1.14.0)
86
88
  parallel (~> 1.10)
87
- parser (>= 2.7.1.5)
89
+ parser (>= 3.0.0.0)
88
90
  rainbow (>= 2.2.2, < 4.0)
89
- regexp_parser (>= 1.8)
91
+ regexp_parser (>= 1.8, < 3.0)
90
92
  rexml
91
- rubocop-ast (>= 1.1.1)
93
+ rubocop-ast (>= 1.5.0, < 2.0)
92
94
  ruby-progressbar (~> 1.7)
93
- unicode-display_width (>= 1.4.0, < 2.0)
94
- rubocop-ast (1.1.1)
95
- parser (>= 2.7.1.5)
96
- rubocop-performance (1.9.0)
97
- rubocop (>= 0.90.0, < 2.0)
95
+ unicode-display_width (>= 1.4.0, < 3.0)
96
+ rubocop-ast (1.5.0)
97
+ parser (>= 3.0.1.1)
98
+ rubocop-performance (1.11.3)
99
+ rubocop (>= 1.7.0, < 2.0)
98
100
  rubocop-ast (>= 0.4.0)
99
- rubocop-rspec (2.0.0)
101
+ rubocop-rake (0.5.1)
102
+ rubocop
103
+ rubocop-rspec (2.3.0)
100
104
  rubocop (~> 1.0)
101
105
  rubocop-ast (>= 1.1.0)
102
- ruby-progressbar (1.10.1)
103
- ruby_parser (3.15.0)
106
+ ruby-progressbar (1.11.0)
107
+ ruby_parser (3.15.1)
104
108
  sexp_processor (~> 4.9)
105
- sexp_processor (4.15.1)
106
- thor (1.0.1)
107
- thread_safe (0.3.6)
108
- tzinfo (1.2.8)
109
- thread_safe (~> 0.1)
110
- unicode-display_width (1.7.0)
111
- zeitwerk (2.4.1)
109
+ sexp_processor (4.15.2)
110
+ thor (1.1.0)
111
+ tzinfo (2.0.4)
112
+ concurrent-ruby (~> 1.0)
113
+ unicode-display_width (2.0.0)
114
+ zeitwerk (2.4.2)
112
115
 
113
116
  PLATFORMS
114
117
  ruby
@@ -122,7 +125,8 @@ DEPENDENCIES
122
125
  rspec
123
126
  rubocop
124
127
  rubocop-performance
128
+ rubocop-rake
125
129
  rubocop-rspec
126
130
 
127
131
  BUNDLED WITH
128
- 2.1.4
132
+ 2.2.17
data/docs/ARRAY.md CHANGED
@@ -137,6 +137,14 @@ Moves a given value to the tail of array.
137
137
  [1, 2, 2, 3].demote!(4) #=> [1, 2, 2, 3]
138
138
  ```
139
139
 
140
+ `divergence`
141
+ ------
142
+ Returns a list of elements not found in either array.
143
+
144
+ ```ruby
145
+ [1, 2, 2].divergence([2, 3, 4]) #=> [1, 3, 4]
146
+ ```
147
+
140
148
  `denillify(!)`
141
149
  ------
142
150
  Converts `nil` into a given value.
data/docs/TIME.md CHANGED
@@ -35,6 +35,14 @@ Converts a `time` object to `strftime` it using a human readable string.
35
35
  Time.now.format('month_name day, year hour:minute ampm') #=> 'January 09, 2014 02:31 pm'
36
36
  ```
37
37
 
38
+ `monotonic`
39
+ ------
40
+ Returns the monotonic time.
41
+
42
+ ```ruby
43
+ Time.monotonic #=> 5834550.444132
44
+ ```
45
+
38
46
  `stamp` aka `to_format`
39
47
  ------
40
48
  Converts a `time` object to a predefined format.
@@ -147,6 +147,10 @@ if Lite::Ruby.configuration.monkey_patches.include?('array')
147
147
  replace(denillify(identity))
148
148
  end
149
149
 
150
+ def divergence(other)
151
+ (self - other) | (other - self)
152
+ end
153
+
150
154
  def duplicates(minimum = 2)
151
155
  hash = Hash.new(0)
152
156
  each { |val| hash[val] += 1 }
@@ -57,11 +57,9 @@ if Lite::Ruby.configuration.monkey_patches.include?('enumerable')
57
57
  found_count > num ? false : num == found_count
58
58
  end
59
59
 
60
- # rubocop:disable Style/CaseEquality
61
60
  def excase?(object)
62
- none? { |val| object === val }
61
+ none?(object)
63
62
  end
64
- # rubocop:enable Style/CaseEquality
65
63
 
66
64
  def expand
67
65
  map { |val| val.is_a?(Enumerable) ? val.expand : val }
@@ -79,11 +77,9 @@ if Lite::Ruby.configuration.monkey_patches.include?('enumerable')
79
77
  each_with_object(Hash.new(0)) { |val, hash| hash[val] += 1 }
80
78
  end
81
79
 
82
- # rubocop:disable Style/CaseEquality
83
80
  def incase?(object)
84
- any? { |val| object === val }
81
+ any?(object)
85
82
  end
86
- # rubocop:enable Style/CaseEquality
87
83
 
88
84
  # rubocop:disable Metrics/MethodLength
89
85
  def interpose(sep, &block)
@@ -312,7 +312,7 @@ if Lite::Ruby.configuration.monkey_patches.include?('hash')
312
312
  end
313
313
 
314
314
  def shuffle
315
- Hash[to_a.sample(size)]
315
+ to_a.sample(size).to_h
316
316
  end
317
317
 
318
318
  def shuffle!
@@ -5,7 +5,7 @@ if Lite::Ruby.configuration.monkey_patches.include?('date')
5
5
  module Ruby
6
6
  module DateHelper
7
7
 
8
- DATE_STAMPS ||= {
8
+ DATE_STAMPS = {
9
9
  weekday: '%d',
10
10
  weekday_blank: '%_d',
11
11
  weekday_padded: '%d',
@@ -41,7 +41,7 @@ if Lite::Ruby.configuration.monkey_patches.include?('date')
41
41
  date_abbr: '%b %-d, %Y',
42
42
  date_iso: '%Y-%m-%d'
43
43
  }.freeze
44
- DATE_UNITS ||= {
44
+ DATE_UNITS = {
45
45
  w: 'u',
46
46
  weekday: 'u',
47
47
  ww: 'w',
@@ -5,7 +5,7 @@ if Lite::Ruby.configuration.monkey_patches.include?('time')
5
5
  module Ruby
6
6
  module TimeHelper
7
7
 
8
- TIME_STAMPS ||= {
8
+ TIME_STAMPS = {
9
9
  hour: '%H',
10
10
  hour_blank: '%k',
11
11
  hour_padded: '%H',
@@ -3,11 +3,15 @@
3
3
  if Lite::Ruby.configuration.monkey_patches.include?('integer')
4
4
  class Integer
5
5
 
6
- ROMAN_NUMERALS ||= {
7
- M: 1000, CM: 900, D: 500, CD: 400, C: 100, XC: 90, L: 50, XL: 40, X: 10, IX: 9, V: 5, IV: 4,
8
- I: 1
6
+ ROMAN_NUMERALS = {
7
+ M: 1000, CM: 900, D: 500, CD: 400, C: 100, XC: 90, L: 50,
8
+ XL: 40, X: 10, IX: 9, V: 5, IV: 4, I: 1
9
9
  }.freeze
10
10
 
11
+ SQL_SMALLINT = 32_767
12
+ SQL_INTEGER = 2_147_483_647
13
+ SQL_BIGINT = 9_223_372_036_854_775_807
14
+
11
15
  def bit(bit)
12
16
  if bit.negative?
13
17
  mask = (1 << ~bit)
@@ -5,14 +5,17 @@ if Lite::Ruby.configuration.monkey_patches.include?('object')
5
5
 
6
6
  class Object
7
7
 
8
- FALSE_VALUES ||= %w[
8
+ FALSE_VALUES = %w[
9
9
  0 f false n no off
10
10
  ].freeze
11
- TRUE_VALUES ||= %w[
11
+ TRUE_VALUES = %w[
12
12
  1 t true y yes on
13
13
  ].freeze
14
14
 
15
- unless defined?(PG) && ARGV.first.start_with?('db:')
15
+ # NOTE: There is a class between the PG gem and the `array?` method.
16
+ # We only need to skip this on migrations since that action
17
+ # happens on a seperate runtime.
18
+ unless defined?(PG) && ARGV.first.to_s.start_with?('db:')
16
19
  def array?
17
20
  is_a?(Array)
18
21
  end
@@ -5,7 +5,7 @@ if Lite::Ruby.configuration.monkey_patches.include?('string')
5
5
 
6
6
  class String
7
7
 
8
- TRANSLITERATIONS ||= {
8
+ TRANSLITERATIONS = {
9
9
  'À' => 'A', 'Á' => 'A', 'Â' => 'A', 'Ã' => 'A', 'Ä' => 'A', 'Å' => 'A', 'Æ' => 'Ae',
10
10
  'Ç' => 'C', 'È' => 'E', 'É' => 'E', 'Ê' => 'E', 'Ë' => 'E', 'Ì' => 'I', 'Í' => 'I',
11
11
  'Î' => 'I', 'Ï' => 'I', 'Ð' => 'D', 'Ñ' => 'N', 'Ò' => 'O', 'Ó' => 'O', 'Ô' => 'O',
@@ -9,15 +9,19 @@ if Lite::Ruby.configuration.monkey_patches.include?('time')
9
9
  class << self
10
10
 
11
11
  def elapse(verbose: false)
12
- started_at = now.to_f
12
+ started_at = monotonic
13
13
  yield
14
- ended_at = now.to_f
14
+ ended_at = monotonic
15
15
  runtime = ended_at - started_at
16
16
  return runtime unless verbose
17
17
 
18
18
  { started_at: started_at, ended_at: ended_at, runtime: runtime }
19
19
  end
20
20
 
21
+ def monotonic
22
+ Process.clock_gettime(Process::CLOCK_MONOTONIC)
23
+ end
24
+
21
25
  end
22
26
 
23
27
  private
@@ -3,7 +3,7 @@
3
3
  module Lite
4
4
  module Ruby
5
5
 
6
- VERSION ||= '1.1.3'
6
+ VERSION = '1.1.8'
7
7
 
8
8
  end
9
9
  end
data/lite-ruby.gemspec CHANGED
@@ -44,5 +44,6 @@ Gem::Specification.new do |spec|
44
44
  spec.add_development_dependency 'rspec'
45
45
  spec.add_development_dependency 'rubocop'
46
46
  spec.add_development_dependency 'rubocop-performance'
47
+ spec.add_development_dependency 'rubocop-rake'
47
48
  spec.add_development_dependency 'rubocop-rspec'
48
49
  end
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.1.3
4
+ version: 1.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juan Gomez
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-11-19 00:00:00.000000000 Z
11
+ date: 2021-05-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -108,6 +108,20 @@ dependencies:
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rubocop-rake
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: rubocop-rspec
113
127
  requirement: !ruby/object:Gem::Requirement
@@ -208,7 +222,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
208
222
  - !ruby/object:Gem::Version
209
223
  version: '0'
210
224
  requirements: []
211
- rubygems_version: 3.1.4
225
+ rubygems_version: 3.2.17
212
226
  signing_key:
213
227
  specification_version: 4
214
228
  summary: Collection of useful Ruby methods for its primitive classes