ruby_core_extensions 0.0.1 → 0.4.0

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.
Files changed (48) hide show
  1. checksums.yaml +5 -5
  2. data/.github/dependabot.yml +6 -0
  3. data/.github/workflows/release.yml +59 -0
  4. data/.github/workflows/ruby.yml +24 -0
  5. data/.gitignore +2 -0
  6. data/.rubocop.yml +21 -0
  7. data/.ruby-version +1 -0
  8. data/CHANGELOG.md +32 -0
  9. data/README.md +35 -22
  10. data/Rakefile +1 -1
  11. data/gemfiles/rails60.gemfile +6 -0
  12. data/gemfiles/rails61.gemfile +6 -0
  13. data/gemfiles/rails70.gemfile +6 -0
  14. data/lib/ruby_core_extensions/array.rb +1 -10
  15. data/lib/ruby_core_extensions/class.rb +0 -3
  16. data/lib/ruby_core_extensions/compact/array.rb +1 -2
  17. data/lib/ruby_core_extensions/compact/hash.rb +3 -4
  18. data/lib/ruby_core_extensions/enumerable.rb +0 -3
  19. data/lib/ruby_core_extensions/file.rb +0 -1
  20. data/lib/ruby_core_extensions/hash.rb +3 -15
  21. data/lib/ruby_core_extensions/kernel.rb +0 -2
  22. data/lib/ruby_core_extensions/numeric.rb +0 -2
  23. data/lib/ruby_core_extensions/object.rb +5 -7
  24. data/lib/ruby_core_extensions/recursive/array.rb +42 -44
  25. data/lib/ruby_core_extensions/recursive/hash.rb +14 -17
  26. data/lib/ruby_core_extensions/recursive/object.rb +8 -4
  27. data/lib/ruby_core_extensions/recursive.rb +0 -5
  28. data/lib/ruby_core_extensions/string.rb +8 -9
  29. data/lib/ruby_core_extensions/version.rb +1 -1
  30. data/lib/ruby_core_extensions.rb +1 -4
  31. data/ruby_core_extensions.gemspec +6 -6
  32. data/spec/array_spec.rb +33 -12
  33. data/spec/compact_spec.rb +13 -13
  34. data/spec/enumerable_spec.rb +13 -9
  35. data/spec/filename_spec.rb +0 -1
  36. data/spec/hash_spec.rb +41 -30
  37. data/spec/object_spec.rb +4 -5
  38. data/spec/string_spec.rb +3 -1
  39. data/spec/support/coverage.rb +2 -28
  40. metadata +19 -33
  41. data/.travis.yml +0 -14
  42. data/gemfiles/rails3.gemfile +0 -11
  43. data/gemfiles/rails4.gemfile +0 -11
  44. data/lib/ruby_core_extensions/recursive/big_decimal.rb +0 -5
  45. data/lib/ruby_core_extensions/recursive/date.rb +0 -8
  46. data/lib/ruby_core_extensions/recursive/date_time.rb +0 -8
  47. data/lib/ruby_core_extensions/recursive/fixnum.rb +0 -7
  48. data/lib/ruby_core_extensions/recursive/time.rb +0 -8
@@ -1,8 +1,3 @@
1
1
  require 'ruby_core_extensions/recursive/array'
2
- require 'ruby_core_extensions/recursive/big_decimal'
3
- require 'ruby_core_extensions/recursive/date'
4
- require 'ruby_core_extensions/recursive/date_time'
5
- require 'ruby_core_extensions/recursive/fixnum'
6
2
  require 'ruby_core_extensions/recursive/hash'
7
3
  require 'ruby_core_extensions/recursive/object'
8
- require 'ruby_core_extensions/recursive/time'
@@ -1,8 +1,8 @@
1
1
  class String
2
2
  def proper_underscore
3
- self.titleize.gsub(" ","").underscore
3
+ self.titleize.gsub(" ", "").underscore
4
4
  end
5
-
5
+
6
6
  # Generate a phonetic code - which is the same for similar sounding names
7
7
  def phonetic_code
8
8
  # Currently using 'metaphone' which is more accurate than soundex
@@ -11,7 +11,7 @@ class String
11
11
 
12
12
  # Solr requires numbers and letters to be separated
13
13
  def separate_numbers_and_letters
14
- gsub(/[a-z][0-9]|[0-9][a-z]/i){ |s| s[0].chr + ' ' + s[1].chr }
14
+ gsub(/[a-z][0-9]|[0-9][a-z]/i) { |s| s[0].chr + ' ' + s[1].chr }
15
15
  end
16
16
 
17
17
  # convert newlines to breaks
@@ -42,13 +42,13 @@ class String
42
42
  words = split(' ')
43
43
 
44
44
  # Return first letter of <limit> words
45
- return words.first(limit).map{|w| w.chars.first}.join if (words.size * 2 - 1) >= limit
45
+ return words.first(limit).map { |w| w.chars.first }.join if (words.size * 2 - 1) >= limit
46
46
 
47
47
  spaces = words.size - 1
48
48
  word_char_min = (limit - spaces) / words.size
49
49
  word_char_max = word_char_min + 1
50
50
 
51
- words = words.map{|word| word[0..(word_char_max - 1)]}
51
+ words = words.map { |word| word[0..(word_char_max - 1)] }
52
52
 
53
53
  words.reverse.each.with_index do |word, index|
54
54
  letters_to_remove = words.join(' ').size - limit
@@ -60,19 +60,18 @@ class String
60
60
  end
61
61
 
62
62
  # Replace word
63
- words[words.size - index - 1] = word[0..(letters_to_keep - 1)]
63
+ words[words.size - index - 1] = word[0..(letters_to_keep - 1)]
64
64
 
65
65
  break if last_case
66
66
  end
67
67
 
68
68
  words.join(' ')
69
69
  end
70
-
71
-
70
+
71
+
72
72
  def to_bool
73
73
  return true if self == true || self =~ (/(true|t|yes|y|1)$/i)
74
74
  return false if self == false || self.blank? || self =~ (/(false|f|no|n|0)$/i)
75
75
  raise ArgumentError.new("invalid value for Boolean: \"#{self}\"")
76
76
  end
77
77
  end
78
-
@@ -1,3 +1,3 @@
1
1
  module RubyCoreExtensions
2
- VERSION = '0.0.1'
2
+ VERSION = '0.4.0'
3
3
  end
@@ -1,8 +1,5 @@
1
1
  module RubyCoreExtensions
2
- require 'active_support/version'
3
- if ActiveSupport::VERSION::MAJOR > 2
4
- require 'active_support/dependencies/autoload'
5
- end
2
+ require "active_support"
6
3
  require 'active_support/core_ext'
7
4
 
8
5
  require 'ruby_core_extensions/array'
@@ -1,4 +1,5 @@
1
1
  # coding: utf-8
2
+
2
3
  lib = File.expand_path('../lib', __FILE__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
5
  require 'ruby_core_extensions/version'
@@ -19,14 +20,13 @@ Gem::Specification.new do |spec|
19
20
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
21
  spec.require_paths = ["lib"]
21
22
 
22
- spec.add_dependency 'activesupport', '>= 2.0'
23
+ spec.add_dependency 'activesupport', '>= 6.0'
23
24
  spec.add_dependency 'tzinfo'
24
25
 
25
- spec.add_development_dependency "bundler", "~> 1.3"
26
+ spec.add_development_dependency "bundler", "~> 2"
26
27
  spec.add_development_dependency "rake"
27
28
  spec.add_development_dependency 'rspec'
28
- spec.add_development_dependency 'simplecov'
29
- spec.add_development_dependency 'simplecov-rcov'
30
- spec.add_development_dependency 'coveralls'
31
- spec.add_development_dependency 'travis'
29
+ spec.add_development_dependency 'coverage-kit'
30
+ spec.add_development_dependency 'pry-byebug'
31
+ spec.add_development_dependency 'rubocop-rails'
32
32
  end
data/spec/array_spec.rb CHANGED
@@ -1,10 +1,21 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Array do
4
-
5
4
  it "should allow converting all values to strings recursively" do
6
- @now = Time.now
7
- expect([1, 2, @now, [3, 4]].stringify_values_recursively).to eq ['1', '2', @now.to_s, ['3', '4']]
5
+ to_s_class = Class.new do
6
+ def to_s
7
+ 'Myself'
8
+ end
9
+ end
10
+ stringify_values_recursively_class = Class.new do
11
+ def stringify_values_recursively
12
+ 'Special'
13
+ end
14
+ end
15
+ now = Time.now
16
+ array = [1, 2, now, [3, 4], to_s_class.new, stringify_values_recursively_class.new]
17
+ output = ['1', '2', now.to_s, %w[3 4], 'Myself', 'Special']
18
+ expect(array.stringify_values_recursively).to eq output
8
19
  end
9
20
 
10
21
  it "should allow removing all blank values" do
@@ -14,30 +25,40 @@ describe Array do
14
25
  end
15
26
 
16
27
  it "should allow removing all blank values recursively" do
17
- a = [1, 2, [" Kan", {}], nil, {:a => "", :b => {}}, ["garoos", " "]]
28
+ a = [1, 2, [" Kan", {}], nil, { a: "", b: {} }, ["garoos", " "]]
18
29
  a.recursive_compact_blank!
19
30
  expect(a.join).to eq "12 Kangaroos"
20
31
  end
21
32
 
22
33
  it "should allow verifying if all elements are blank recursively" do
23
- expect(['',nil,[nil,['']]]).to be_recursive_blank
24
- expect(['',nil,[nil,['',1]]]).to_not be_recursive_blank
34
+ expect(['', nil, [nil, ['']]]).to be_recursive_blank
35
+ expect(['', nil, [nil, ['', 1]]]).to_not be_recursive_blank
25
36
  end
26
37
 
27
38
  it "should allow converting to hash given a key" do
28
- expect([1,2,3].hash_by(:ordinalize)).to eq({'1st' => 1, "2nd" => 2, "3rd" => 3})
29
- expect([1,2,3].hash_by(:ordinalize, :to_s)).to eq({'1st' => '1', "2nd" => '2', "3rd" => '3'})
30
- expect([1,2,3].hash_by(:ordinalize){ |v| v + 1 }).to eq({'1st' => 2, "2nd" => 3, "3rd" => 4})
31
- expect([1,2,3].hash_by{|k| k * 2}).to eq({2 => 1, 4 => 2, 6 => 3})
39
+ expect([1, 2, 3].hash_by(:ordinalize)).to eq({ '1st' => 1, "2nd" => 2, "3rd" => 3 })
40
+ expect([1, 2, 3].hash_by(:ordinalize, :to_s)).to eq(
41
+ { '1st' => '1', "2nd" => '2', "3rd" => '3' }
42
+ )
43
+ expect([1, 2, 3].hash_by(:ordinalize) { |v| v + 1 }).to eq(
44
+ { '1st' => 2, "2nd" => 3, "3rd" => 4 }
45
+ )
46
+ expect([1, 2, 3].hash_by { |k| k * 2 }).to eq({ 2 => 1, 4 => 2, 6 => 3 })
47
+ end
48
+
49
+ it "#hash_by_id" do
50
+ one = double(id: 1, name: 'One')
51
+ two = double(id: 2, name: 'Two')
52
+ expect([one, two].hash_by_id).to eq(1 => one, 2 => two)
32
53
  end
33
54
 
34
55
  it "should allow executing blocks recursively" do
35
- array = [1,[2,3],[4,[5,6],7,[8]],9,[[10]]]
56
+ array = [1, [2, 3], [4, [5, 6], 7, [8]], 9, [[10]]]
36
57
  result = []
37
58
  array.recursively do |e|
38
59
  result << e unless e.is_a?(Array)
39
60
  end
40
- expect(result).to eq [1,2,3,4,5,6,7,8,9,10]
61
+ expect(result).to eq [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
41
62
  end
42
63
 
43
64
  it '#intersects?' do
data/spec/compact_spec.rb CHANGED
@@ -6,11 +6,11 @@ describe Array, 'compact' do
6
6
  end
7
7
 
8
8
  it 'should recursive compact blank' do
9
- a = [1, nil, {:a => nil, :b => 2}]
9
+ a = [1, nil, { a: nil, b: 2 }]
10
10
  a.recursive_compact_blank!
11
- expect(a).to eq [1, {:b => 2}]
11
+ expect(a).to eq [1, { b: 2 }]
12
12
 
13
- b = [1, nil, {:a => nil}]
13
+ b = [1, nil, { a: nil }]
14
14
  b.recursive_compact_blank!
15
15
  expect(b).to eq [1]
16
16
  end
@@ -18,32 +18,32 @@ end
18
18
 
19
19
  describe Hash, 'compact' do
20
20
  it 'should compact' do
21
- expect({:a => 1, :b => nil}.compact).to eq({:a => 1})
21
+ expect({ a: 1, b: nil }.compact).to eq({ a: 1 })
22
22
  end
23
23
 
24
24
  it 'should compact!' do
25
- a = {:a => 1, :b => nil}
25
+ a = { a: 1, b: nil }
26
26
  a.compact!
27
- expect(a).to eq({:a => 1})
27
+ expect(a).to eq({ a: 1 })
28
28
  end
29
29
 
30
30
  it 'should compact blank' do
31
- expect({:a => 1, :b => ''}.compact_blank).to eq({:a => 1})
31
+ expect({ a: 1, b: '' }.compact_blank).to eq({ a: 1 })
32
32
  end
33
33
 
34
34
  it 'should compact blank!' do
35
- a = {:a => 1, :b => ''}
35
+ a = { a: 1, b: '' }
36
36
  a.compact_blank!
37
- expect(a).to eq({:a => 1})
37
+ expect(a).to eq({ a: 1 })
38
38
  end
39
39
 
40
40
  it 'should recursive compact blank!' do
41
- a = {:a => 1, :b => {:c => 1, :d => ''}}
41
+ a = { a: 1, b: { c: 1, d: '' } }
42
42
  a.recursive_compact_blank!
43
- expect(a).to eq({:a => 1, :b => {:c => 1}})
43
+ expect(a).to eq({ a: 1, b: { c: 1 } })
44
44
 
45
- a = {:a => 1, :b => {:c => [], :d => ''}}
45
+ a = { a: 1, b: { c: [], d: '' } }
46
46
  a.recursive_compact_blank!
47
- expect(a).to eq({:a => 1})
47
+ expect(a).to eq({ a: 1 })
48
48
  end
49
49
  end
@@ -1,24 +1,28 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Enumerable do
4
-
5
- it 'should allow mapping elements of the collection to hashes associating method names to the returned values for each method' do
6
- expect([1,2,3].map_methods(:to_s,:to_f)).to eq [{:to_s => '1', :to_f => 1.0}, {:to_s => '2', :to_f => 2.0}, {:to_s => '3', :to_f => 3.0}]
4
+
5
+ it 'allow mapping elements to hashes with method names of the returned values for each method' do
6
+ expect([1, 2, 3].map_methods(:to_s, :to_f)).to eq(
7
+ [{ to_s: '1', to_f: 1.0 }, { to_s: '2', to_f: 2.0 }, { to_s: '3', to_f: 3.0 }]
8
+ )
7
9
  end
8
10
 
9
11
 
10
12
  context 'when detecting and returning the block value' do
11
- it { expect([1,2,3].detect_and_return { |number| number.even? && number * number }).to eq 4 }
12
- it { expect([1,3,5].detect_and_return { |number| number.even? && number * number }).to be nil }
13
+ it { expect([1, 2, 3].detect_and_return { |number| number.even? && number * number }).to eq 4 }
14
+ it { expect([1, 3, 5].detect_and_return { |number|
15
+ number.even? && number * number }).to be nil
16
+ }
13
17
  end
14
18
 
15
19
 
16
20
  it 'should allow selecting by attribute' do
17
- one = double(:name => 'one', :type => 'odd')
18
- two = double(:name => 'two', :type => 'even')
19
- thr = double(:name => 'thr', :type => 'odd')
21
+ one = double(name: 'one', type: 'odd')
22
+ two = double(name: 'two', type: 'even')
23
+ thr = double(name: 'thr', type: 'odd')
20
24
  expect([one, two, thr].select_by_attr(:type, 'odd')).to eq [one, thr]
21
25
  expect([one, two, thr].select_by_attr(:type, 'even')).to eq [two]
22
26
  end
23
-
27
+
24
28
  end
@@ -14,4 +14,3 @@ describe File do
14
14
  File.safe_name(from)
15
15
  end
16
16
  end
17
-
data/spec/hash_spec.rb CHANGED
@@ -3,14 +3,21 @@ require 'spec_helper'
3
3
  describe Hash do
4
4
 
5
5
  before do
6
- @sub_array1 = [3, BigDecimal('4'), Date.new(2000, 1, 1), DateTime.new(2000, 1, 1, 0, 0, 0), {:f => 5}]
7
- @sub_array2 = [3, BigDecimal('4'), Date.new(2000, 1, 1), DateTime.new(2000, 1, 1, 0, 0, 0), {'f' => 5}]
8
- @hash1 = {:a => 1, :b => {:c => 2}, :d => 'test', :e => @sub_array1}
9
- @hash2 = {'a' => 1, 'b' => {'c' => 2}, :d => 'test', 'e' => @sub_array2}
6
+ @sub_array1 = [3, BigDecimal('4'), Date.new(2000, 1, 1),
7
+ DateTime.new(2000, 1, 1, 0, 0, 0), { f: 5 }]
8
+ @sub_array2 = [3, BigDecimal('4'), Date.new(2000, 1, 1),
9
+ DateTime.new(2000, 1, 1, 0, 0, 0), { 'f' => 5 }]
10
+ @hash1 = { a: 1, b: { c: 2 }, d: 'test', e: @sub_array1 }
11
+ @hash2 = { 'a' => 1, 'b' => { 'c' => 2 }, :d => 'test', 'e' => @sub_array2 }
10
12
  end
11
13
 
12
14
  it "should allow converting all values to strings recursively" do
13
- expect(@hash1.stringify_values_recursively).to eq({:a => "1", :b => {:c => "2"}, :d => "test", :e => ["3", '4.0', "2000-01-01", '2000-01-01T00:00:00+00:00', {:f => "5"}]})
15
+ expect(@hash1.stringify_values_recursively).to eq(
16
+ {
17
+ a: "1", b: { c: "2" }, d: "test",
18
+ e: ["3", '4.0', "2000-01-01", '2000-01-01T00:00:00+00:00', { f: "5" }]
19
+ }
20
+ )
14
21
  end
15
22
 
16
23
  it "should allow converting all keys to symbols recursively" do
@@ -18,29 +25,33 @@ describe Hash do
18
25
  end
19
26
 
20
27
  it "should allow converting keys" do
21
- expect(@hash1.convert_keys(&:to_s)).to eq({"a" => 1, "b" => {:c => 2}, "d" => "test", "e" => @sub_array1})
28
+ expect(@hash1.convert_keys(&:to_s)).to eq(
29
+ { "a" => 1, "b" => { c: 2 }, "d" => "test", "e" => @sub_array1 }
30
+ )
22
31
  end
23
32
 
24
33
  it "should allow converting values" do
25
- expect(@hash1.convert_values(&:to_s)).to eq({:a => "1", :b => {:c => 2}, :d => "test", :e => @sub_array1})
34
+ expect(@hash1.convert_values(&:to_s)).to eq({ a: "1", b: { c: 2 }, d: "test", e: @sub_array1 })
26
35
  end
27
-
36
+
28
37
  it "should allow converting values only for specific keys" do
29
- expect(@hash1.convert_values(:d, :e, &:to_s)).to eq({:a => 1, :b => {:c => 2}, :d => "test", :e => @sub_array1})
38
+ expect(@hash1.convert_values(:d, :e, &:to_s)).to eq(
39
+ { a: 1, b: { c: 2 }, d: "test", e: @sub_array1 }
40
+ )
30
41
  end
31
42
 
32
43
  it "should allow making indifferent access recursively" do
33
44
  expect(@hash1.make_indifferent_access_recursively['b']['c']).to eq 2
34
45
  expect(@hash1.make_indifferent_access_recursively['e'][4]['f']).to eq 5
35
46
  end
36
-
47
+
37
48
  it "should allow executing blocks recursively" do
38
- hash = {:a => 1, :b => {:a => 2}, :c => {:a => 3, :b => 4, :c => {:a => 5}}}
49
+ hash = { a: 1, b: { a: 2 }, c: { a: 3, b: 4, c: { a: 5 } } }
39
50
  result = []
40
- hash.recursively do |k,v|
51
+ hash.recursively do |k, v|
41
52
  result << v unless v.is_a?(Hash)
42
- end
43
- expect(result.sort).to eq [1,2,3,4,5] # Ruby 1.8.7 doesn't order hash keys
53
+ end
54
+ expect(result.sort).to eq [1, 2, 3, 4, 5] # Ruby 1.8.7 doesn't order hash keys
44
55
  end
45
56
 
46
57
  end
@@ -49,36 +60,36 @@ end
49
60
  describe Hash do
50
61
 
51
62
  it 'should allow removing all nil values and return a new hash' do
52
- expect({:a => 1, :b => nil}.compact).to eq({:a => 1})
63
+ expect({ a: 1, b: nil }.compact).to eq({ a: 1 })
53
64
  end
54
65
 
55
66
  it 'should allow removing all nil values' do
56
- a = {:a => 1, :b => nil}
67
+ a = { a: 1, b: nil }
57
68
  a.compact!
58
- expect(a).to eq({:a => 1})
69
+ expect(a).to eq({ a: 1 })
59
70
  end
60
71
 
61
72
  it 'should allow removing all nil values and return a new hash' do
62
- expect({:a => 1, :b => ''}.compact_blank).to eq({:a => 1})
73
+ expect({ a: 1, b: '' }.compact_blank).to eq({ a: 1 })
63
74
  end
64
75
 
65
76
  it 'should allow removing all blank values' do
66
- a = {:a => 1, :b => ''}
77
+ a = { a: 1, b: '' }
67
78
  a.compact_blank!
68
- expect(a).to eq({:a => 1})
79
+ expect(a).to eq({ a: 1 })
69
80
  end
70
81
 
71
82
  it 'should allow removing all blank values recursively' do
72
- a = {:a => 1, :b => {:c => 1, :d => '', :e => []}}
83
+ a = { a: 1, b: { c: 1, d: '', e: [] } }
73
84
  a.recursive_compact_blank!
74
- expect(a).to eq({:a => 1, :b => {:c => 1}})
85
+ expect(a).to eq({ a: 1, b: { c: 1 } })
75
86
  end
76
87
 
77
88
  it 'should allow extracting subsets' do
78
- a = {:a => 1, :b => 2, :c => 3}
89
+ a = { a: 1, b: 2, c: 3 }
79
90
  b = a.extract!(:a, :c)
80
- expect(b).to eq({:a => 1, :c => 3})
81
- expect(a).to eq({:b => 2})
91
+ expect(b).to eq({ a: 1, c: 3 })
92
+ expect(a).to eq({ b: 2 })
82
93
  end
83
94
 
84
95
  end
@@ -86,22 +97,22 @@ end
86
97
 
87
98
  describe Hash, '#map_key_value' do
88
99
 
89
- subject { {'1' => '2', 3 => 4} }
100
+ subject { { '1' => '2', 3 => 4 } }
90
101
 
91
102
  it 'should map key' do
92
- expect(subject.map_key(:to_i)).to eq({1 => '2', 3 => 4})
103
+ expect(subject.map_key(:to_i)).to eq({ 1 => '2', 3 => 4 })
93
104
  end
94
105
 
95
106
  it 'should map value' do
96
- expect(subject.map_value(:to_i)).to eq({'1' => 2, 3 => 4})
107
+ expect(subject.map_value(:to_i)).to eq({ '1' => 2, 3 => 4 })
97
108
  end
98
109
 
99
110
  it 'should map key and value' do
100
- expect(subject.map_key_value(:to_i, :to_i)).to eq({1 => 2, 3 => 4})
111
+ expect(subject.map_key_value(:to_i, :to_i)).to eq({ 1 => 2, 3 => 4 })
101
112
  end
102
113
 
103
114
  it 'should map key and value if value not specified' do
104
- expect(subject.map_key_value(:to_i)).to eq({1 => 2, 3 => 4})
115
+ expect(subject.map_key_value(:to_i)).to eq({ 1 => 2, 3 => 4 })
105
116
  end
106
117
 
107
118
  end
data/spec/object_spec.rb CHANGED
@@ -26,14 +26,13 @@ describe Object do
26
26
  class ReadyError < StandardError; end
27
27
 
28
28
  class BooleanizeTest
29
-
30
29
  attr_accessor :ready
31
30
 
32
31
  def verify!
33
- fail ArgumentError, "Ready should be a boolean" unless ready.is_a?(TrueClass) || ready.is_a?(FalseClass)
32
+ fail ArgumentError, "Ready should be a boolean" unless ready.is_a?(TrueClass) ||
33
+ ready.is_a?(FalseClass)
34
34
  fail ReadyError, "Not ready" unless ready
35
35
  end
36
-
37
36
  end
38
37
 
39
38
 
@@ -42,8 +41,8 @@ describe Object do
42
41
  end
43
42
 
44
43
 
45
- it "should allow defining methods that will return boolean depending on the execution of another method" do
46
- expect { @object.booleanize(:verify!, :rescue => ReadyError) }.to_not raise_error
44
+ it "allows defining methods that return boolean depending on the execution of another method" do
45
+ expect { @object.booleanize(:verify!, rescue: ReadyError) }.to_not raise_error
47
46
  expect { @object.verify? }.to raise_error(ArgumentError, 'Ready should be a boolean')
48
47
  @object.ready = false
49
48
  expect { @object.verify? }.to_not raise_error
data/spec/string_spec.rb CHANGED
@@ -1,7 +1,9 @@
1
1
  describe String do
2
2
 
3
3
  it "should convert to underscore replacing spaces with underscores" do
4
- expect("CamelCase UPPERCASE to be_Converted".proper_underscore).to eq "camel_case_uppercase_to_be_converted"
4
+ expect("CamelCase UPPERCASE to be_Converted".proper_underscore).to eq(
5
+ "camel_case_uppercase_to_be_converted"
6
+ )
5
7
  end
6
8
 
7
9
  it 'should separate numbers and letters' do
@@ -1,29 +1,3 @@
1
- MINIMUM_COVERAGE = 87
1
+ require 'coverage/kit'
2
2
 
3
- unless ENV['COVERAGE'] == 'off'
4
- require 'simplecov'
5
- require 'simplecov-rcov'
6
- require 'coveralls'
7
- Coveralls.wear!
8
-
9
- SimpleCov.formatters = [
10
- SimpleCov::Formatter::RcovFormatter,
11
- Coveralls::SimpleCov::Formatter
12
- ]
13
- SimpleCov.start do
14
- add_filter '/vendor/'
15
- add_filter '/spec/'
16
- add_filter '/lib/error_handling/'
17
- add_group 'lib', 'lib'
18
- end
19
- SimpleCov.at_exit do
20
- SimpleCov.result.format!
21
- percent = SimpleCov.result.covered_percent
22
- unless percent >= MINIMUM_COVERAGE
23
- puts '*' * 80
24
- puts "Coverage must be above #{MINIMUM_COVERAGE}%. It is #{format('%.2f', percent)}%"
25
- puts '*' * 80
26
- Kernel.exit(1)
27
- end
28
- end
29
- end
3
+ Coverage::Kit.setup(minimum_coverage: 88.5)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_core_extensions
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Noack
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-06-17 00:00:00.000000000 Z
12
+ date: 2022-01-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - ">="
19
19
  - !ruby/object:Gem::Version
20
- version: '2.0'
20
+ version: '6.0'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - ">="
26
26
  - !ruby/object:Gem::Version
27
- version: '2.0'
27
+ version: '6.0'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: tzinfo
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -45,14 +45,14 @@ dependencies:
45
45
  requirements:
46
46
  - - "~>"
47
47
  - !ruby/object:Gem::Version
48
- version: '1.3'
48
+ version: '2'
49
49
  type: :development
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
53
  - - "~>"
54
54
  - !ruby/object:Gem::Version
55
- version: '1.3'
55
+ version: '2'
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: rake
58
58
  requirement: !ruby/object:Gem::Requirement
@@ -82,7 +82,7 @@ dependencies:
82
82
  - !ruby/object:Gem::Version
83
83
  version: '0'
84
84
  - !ruby/object:Gem::Dependency
85
- name: simplecov
85
+ name: coverage-kit
86
86
  requirement: !ruby/object:Gem::Requirement
87
87
  requirements:
88
88
  - - ">="
@@ -96,7 +96,7 @@ dependencies:
96
96
  - !ruby/object:Gem::Version
97
97
  version: '0'
98
98
  - !ruby/object:Gem::Dependency
99
- name: simplecov-rcov
99
+ name: pry-byebug
100
100
  requirement: !ruby/object:Gem::Requirement
101
101
  requirements:
102
102
  - - ">="
@@ -110,21 +110,7 @@ dependencies:
110
110
  - !ruby/object:Gem::Version
111
111
  version: '0'
112
112
  - !ruby/object:Gem::Dependency
113
- name: coveralls
114
- requirement: !ruby/object:Gem::Requirement
115
- requirements:
116
- - - ">="
117
- - !ruby/object:Gem::Version
118
- version: '0'
119
- type: :development
120
- prerelease: false
121
- version_requirements: !ruby/object:Gem::Requirement
122
- requirements:
123
- - - ">="
124
- - !ruby/object:Gem::Version
125
- version: '0'
126
- - !ruby/object:Gem::Dependency
127
- name: travis
113
+ name: rubocop-rails
128
114
  requirement: !ruby/object:Gem::Requirement
129
115
  requirements:
130
116
  - - ">="
@@ -143,15 +129,21 @@ executables: []
143
129
  extensions: []
144
130
  extra_rdoc_files: []
145
131
  files:
132
+ - ".github/dependabot.yml"
133
+ - ".github/workflows/release.yml"
134
+ - ".github/workflows/ruby.yml"
146
135
  - ".gitignore"
147
136
  - ".rspec"
148
- - ".travis.yml"
137
+ - ".rubocop.yml"
138
+ - ".ruby-version"
139
+ - CHANGELOG.md
149
140
  - Gemfile
150
141
  - LICENSE
151
142
  - README.md
152
143
  - Rakefile
153
- - gemfiles/rails3.gemfile
154
- - gemfiles/rails4.gemfile
144
+ - gemfiles/rails60.gemfile
145
+ - gemfiles/rails61.gemfile
146
+ - gemfiles/rails70.gemfile
155
147
  - lib/ruby_core_extensions.rb
156
148
  - lib/ruby_core_extensions/array.rb
157
149
  - lib/ruby_core_extensions/class.rb
@@ -166,13 +158,8 @@ files:
166
158
  - lib/ruby_core_extensions/object.rb
167
159
  - lib/ruby_core_extensions/recursive.rb
168
160
  - lib/ruby_core_extensions/recursive/array.rb
169
- - lib/ruby_core_extensions/recursive/big_decimal.rb
170
- - lib/ruby_core_extensions/recursive/date.rb
171
- - lib/ruby_core_extensions/recursive/date_time.rb
172
- - lib/ruby_core_extensions/recursive/fixnum.rb
173
161
  - lib/ruby_core_extensions/recursive/hash.rb
174
162
  - lib/ruby_core_extensions/recursive/object.rb
175
- - lib/ruby_core_extensions/recursive/time.rb
176
163
  - lib/ruby_core_extensions/string.rb
177
164
  - lib/ruby_core_extensions/version.rb
178
165
  - ruby_core_extensions.gemspec
@@ -206,8 +193,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
206
193
  - !ruby/object:Gem::Version
207
194
  version: '0'
208
195
  requirements: []
209
- rubyforge_project:
210
- rubygems_version: 2.4.8
196
+ rubygems_version: 3.3.3
211
197
  signing_key:
212
198
  specification_version: 4
213
199
  summary: Set of extensions to core ruby libraries used by TravelLink Technology.
data/.travis.yml DELETED
@@ -1,14 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.3.0
4
- script: bundle exec rake spec
5
- gemfile:
6
- - gemfiles/rails3.gemfile
7
- - gemfiles/rails4.gemfile
8
- notifications:
9
- email:
10
- - support@travellink.com.au
11
- flowdock:
12
- secure: IK3CyMRa++LNdooemZJBZSNdwUiKpVdXZUz9exYIkj3La/EJDOy+kqV2NzYdqRht2BGHHiRsVn3hVqySDDuv9jxBHTZgM0v/pQ4kT8JZqi7fDb36axf3M6Y2VJyrJ0S/9BbHqLE95B4NXQ30ctLCSfQNbp9sOn2EwP3DZS9KJks=
13
- sudo: false
14
- cache: bundler