dm_ruby_extensions 1.0.8 → 1.5.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.
- checksums.yaml +5 -5
- data/.github/workflow/ci.yml +41 -0
- data/.gitignore +0 -3
- data/.rubocop.yml +26 -0
- data/.ruby-version +1 -0
- data/Gemfile +5 -1
- data/README.md +3 -1
- data/Rakefile +6 -4
- data/bin/console +18 -0
- data/dm_ruby_extensions.gemspec +15 -12
- data/lib/dm_ruby_extensions/extend_array.rb +9 -8
- data/lib/dm_ruby_extensions/extend_date.rb +7 -8
- data/lib/dm_ruby_extensions/extend_datetime.rb +6 -7
- data/lib/dm_ruby_extensions/extend_false.rb +2 -3
- data/lib/dm_ruby_extensions/extend_hash.rb +36 -28
- data/lib/dm_ruby_extensions/extend_integer.rb +6 -5
- data/lib/dm_ruby_extensions/extend_nil.rb +11 -11
- data/lib/dm_ruby_extensions/extend_numeric.rb +5 -5
- data/lib/dm_ruby_extensions/extend_string.rb +68 -65
- data/lib/dm_ruby_extensions/extend_time.rb +4 -5
- data/lib/dm_ruby_extensions/extend_true.rb +2 -3
- data/lib/dm_ruby_extensions/version.rb +3 -1
- data/lib/dm_ruby_extensions.rb +15 -12
- data/spec/extensions/array_spec.rb +13 -12
- data/spec/extensions/date_spec.rb +8 -7
- data/spec/extensions/datetime_spec.rb +8 -7
- data/spec/extensions/false_spec.rb +3 -4
- data/spec/extensions/hash_spec.rb +20 -17
- data/spec/extensions/integer_spec.rb +3 -3
- data/spec/extensions/nil_spec.rb +7 -7
- data/spec/extensions/numeric_spec.rb +3 -3
- data/spec/extensions/string_spec.rb +50 -39
- data/spec/extensions/time_spec.rb +4 -3
- data/spec/extensions/true_spec.rb +3 -4
- data/spec/spec_helper.rb +45 -44
- metadata +14 -11
@@ -1,12 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
require 'dm_ruby_extensions'
|
3
5
|
|
4
6
|
describe String do
|
5
|
-
|
6
7
|
describe 'to_s_default' do
|
7
|
-
specify { expect('foobar'.to_s_default).to eq 'foobar'}
|
8
|
-
specify { expect(''.to_s_default).to eq 'n/a'}
|
9
|
-
specify { expect(''.to_s_default('--')).to eq '--'}
|
8
|
+
specify { expect('foobar'.to_s_default).to eq 'foobar' }
|
9
|
+
specify { expect(''.to_s_default).to eq 'n/a' }
|
10
|
+
specify { expect(''.to_s_default('--')).to eq '--' }
|
10
11
|
end
|
11
12
|
|
12
13
|
describe 'as_boolean' do
|
@@ -18,17 +19,17 @@ describe String do
|
|
18
19
|
end
|
19
20
|
|
20
21
|
describe 'as_css_size' do
|
21
|
-
specify { expect('50'.as_css_size).to eq '50px'}
|
22
|
-
specify { expect(''.as_css_size).to eq ''}
|
23
|
-
specify { expect('50px'.as_css_size).to eq '50px'}
|
24
|
-
specify { expect('50%'.as_css_size).to eq '50%'}
|
25
|
-
specify { expect('50em'.as_css_size).to eq '50em'}
|
26
|
-
specify { expect('auto'.as_css_size).to eq 'auto'}
|
27
|
-
specify { expect('inherit'.as_css_size).to eq 'inherit'}
|
22
|
+
specify { expect('50'.as_css_size).to eq '50px' }
|
23
|
+
specify { expect(''.as_css_size).to eq '' }
|
24
|
+
specify { expect('50px'.as_css_size).to eq '50px' }
|
25
|
+
specify { expect('50%'.as_css_size).to eq '50%' }
|
26
|
+
specify { expect('50em'.as_css_size).to eq '50em' }
|
27
|
+
specify { expect('auto'.as_css_size).to eq 'auto' }
|
28
|
+
specify { expect('inherit'.as_css_size).to eq 'inherit' }
|
28
29
|
end
|
29
|
-
|
30
|
+
|
30
31
|
describe 'sql_wildcard' do
|
31
|
-
specify { expect('foobar'.sql_wildcard).to eq '%foobar%'}
|
32
|
+
specify { expect('foobar'.sql_wildcard).to eq '%foobar%' }
|
32
33
|
end
|
33
34
|
|
34
35
|
describe 'replace_non_alphanumeric' do
|
@@ -37,9 +38,9 @@ describe String do
|
|
37
38
|
end
|
38
39
|
|
39
40
|
describe 'sanitize_filename' do
|
40
|
-
specify { expect('foobar.doc'.sanitize_filename).to eq 'foobar.doc'}
|
41
|
-
specify { expect('/user/home/foobar.doc'.sanitize_filename).to eq 'foobar.doc'}
|
42
|
-
specify { expect('/user/home/f9o o(b+a^r.d*c'.sanitize_filename).to eq 'f9o_o_b_a_r.d_c'}
|
41
|
+
specify { expect('foobar.doc'.sanitize_filename).to eq 'foobar.doc' }
|
42
|
+
specify { expect('/user/home/foobar.doc'.sanitize_filename).to eq 'foobar.doc' }
|
43
|
+
specify { expect('/user/home/f9o o(b+a^r.d*c'.sanitize_filename).to eq 'f9o_o_b_a_r.d_c' }
|
43
44
|
end
|
44
45
|
|
45
46
|
describe 'expand_url' do
|
@@ -57,7 +58,9 @@ describe String do
|
|
57
58
|
end
|
58
59
|
|
59
60
|
describe 'smart_titlecase' do
|
60
|
-
specify
|
61
|
+
specify do
|
62
|
+
expect('a sample title and text: a treatsie'.smart_titlecase).to eq 'A Sample Title and Text: A Treatsie'
|
63
|
+
end
|
61
64
|
end
|
62
65
|
|
63
66
|
describe 'smart_capitalize' do
|
@@ -67,33 +70,42 @@ describe String do
|
|
67
70
|
end
|
68
71
|
|
69
72
|
describe 'smart_truncate' do
|
70
|
-
specify
|
71
|
-
|
72
|
-
|
73
|
+
specify do
|
74
|
+
expect('One time. Two times. 3 times. 4 times.'.smart_truncate(sentences: 3))
|
75
|
+
.to eq 'One time. Two times. 3 times...'
|
76
|
+
end
|
77
|
+
specify do
|
78
|
+
expect('one two three and four five six and seven and yet another eight'.smart_truncate(words: 6))
|
79
|
+
.to eq 'one two three and four five...'
|
80
|
+
end
|
81
|
+
specify do
|
82
|
+
expect('one two three and four five six and seven and yet another eight'.smart_truncate)
|
83
|
+
.to eq 'one two three and four five six and seven and yet another...'
|
84
|
+
end
|
73
85
|
end
|
74
86
|
|
75
87
|
describe 'name_case' do
|
76
88
|
before :each do
|
77
89
|
@proper_names = [
|
78
|
-
|
79
|
-
"O'Callaghan",
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
90
|
+
'Keith', 'Leigh-Williams', 'McCarthy',
|
91
|
+
"O'Callaghan", 'St. John', 'von Streit',
|
92
|
+
'van Dyke', 'Van', 'ap Llwyd Dafydd',
|
93
|
+
'al Fahd', 'Al',
|
94
|
+
'el Grecco',
|
95
|
+
'ben Gurion', 'Ben',
|
96
|
+
'da Vinci',
|
97
|
+
'di Caprio', 'du Pont', 'de Legate',
|
98
|
+
'del Crond', 'der Sind', 'van der Post',
|
99
|
+
'von Trapp', 'la Poisson', 'le Figaro',
|
100
|
+
'Mack Knife', 'Dougal MacDonald',
|
89
101
|
# Mac exceptions
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
102
|
+
'Machin', 'Machlin', 'Machar',
|
103
|
+
'Mackle', 'Macklin', 'Mackie',
|
104
|
+
'Macquarie', 'Machado', 'Macevicius',
|
105
|
+
'Maciulis', 'Macias', 'MacMurdo',
|
94
106
|
# Roman numerals
|
95
|
-
|
96
|
-
|
107
|
+
'Henry VIII', 'Louis III', 'Louis XIV',
|
108
|
+
'Charles II', 'Fred XLIX'
|
97
109
|
]
|
98
110
|
end
|
99
111
|
|
@@ -109,6 +121,5 @@ describe String do
|
|
109
121
|
proper_cased = 'Iñtërnâtiônàlizætiøn'
|
110
122
|
expect(proper_cased.downcase.name_case).to eq proper_cased
|
111
123
|
end
|
112
|
-
|
113
124
|
end
|
114
|
-
end
|
125
|
+
end
|
@@ -1,16 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
require 'dm_ruby_extensions'
|
3
5
|
|
4
6
|
describe Time do
|
5
|
-
|
6
7
|
describe 'localize' do
|
7
8
|
it 'localize the date based on the format' do
|
8
9
|
I18n.enforce_available_locales = false
|
9
10
|
I18n.locale = :en
|
10
|
-
time = Time.parse(
|
11
|
+
time = Time.parse('2012-11-23 08:35 utc')
|
11
12
|
expect(time.localize).to eq 'Fri, 23 Nov 2012 08:35:00 +0000'
|
12
13
|
expect(time.localize(format: :short)).to eq '23 Nov 08:35'
|
13
14
|
expect(time.localize('%b %Y')).to eq 'Nov 2012'
|
14
15
|
end
|
15
16
|
end
|
16
|
-
end
|
17
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'pry-byebug'
|
1
4
|
# This file was generated by the `rails generate rspec:install` command. Conventionally, all
|
2
5
|
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
6
|
# The generated `.rspec` file contains `--require spec_helper` which will cause this
|
@@ -38,48 +41,46 @@ RSpec.configure do |config|
|
|
38
41
|
mocks.verify_partial_doubles = true
|
39
42
|
end
|
40
43
|
|
41
|
-
# The settings below are suggested to provide a good initial experience
|
42
|
-
# with RSpec, but feel free to customize to your heart's content.
|
43
|
-
|
44
|
-
#
|
45
|
-
#
|
46
|
-
#
|
47
|
-
#
|
48
|
-
config.
|
49
|
-
|
50
|
-
|
51
|
-
#
|
52
|
-
#
|
53
|
-
# - http://
|
54
|
-
# - http://
|
55
|
-
#
|
56
|
-
|
57
|
-
|
58
|
-
#
|
59
|
-
#
|
60
|
-
#
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
#
|
69
|
-
#
|
70
|
-
#
|
71
|
-
|
72
|
-
|
73
|
-
#
|
74
|
-
#
|
75
|
-
#
|
76
|
-
#
|
77
|
-
|
78
|
-
|
79
|
-
#
|
80
|
-
#
|
81
|
-
#
|
82
|
-
#
|
83
|
-
Kernel.srand config.seed
|
84
|
-
=end
|
44
|
+
# The settings below are suggested to provide a good initial experience
|
45
|
+
# with RSpec, but feel free to customize to your heart's content.
|
46
|
+
# # These two settings work together to allow you to limit a spec run
|
47
|
+
# # to individual examples or groups you care about by tagging them with
|
48
|
+
# # `:focus` metadata. When nothing is tagged with `:focus`, all examples
|
49
|
+
# # get run.
|
50
|
+
# config.filter_run :focus
|
51
|
+
# config.run_all_when_everything_filtered = true
|
52
|
+
#
|
53
|
+
# # Limits the available syntax to the non-monkey patched syntax that is recommended.
|
54
|
+
# # For more details, see:
|
55
|
+
# # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
|
56
|
+
# # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
57
|
+
# # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
|
58
|
+
# config.disable_monkey_patching!
|
59
|
+
#
|
60
|
+
# # Many RSpec users commonly either run the entire suite or an individual
|
61
|
+
# # file, and it's useful to allow more verbose output when running an
|
62
|
+
# # individual spec file.
|
63
|
+
# if config.files_to_run.one?
|
64
|
+
# # Use the documentation formatter for detailed output,
|
65
|
+
# # unless a formatter has already been configured
|
66
|
+
# # (e.g. via a command-line flag).
|
67
|
+
# config.default_formatter = 'doc'
|
68
|
+
# end
|
69
|
+
#
|
70
|
+
# # Print the 10 slowest examples and example groups at the
|
71
|
+
# # end of the spec run, to help surface which specs are running
|
72
|
+
# # particularly slow.
|
73
|
+
# config.profile_examples = 10
|
74
|
+
#
|
75
|
+
# # Run specs in random order to surface order dependencies. If you find an
|
76
|
+
# # order dependency and want to debug it, you can fix the order by providing
|
77
|
+
# # the seed, which is printed after each run.
|
78
|
+
# # --seed 1234
|
79
|
+
# config.order = :random
|
80
|
+
#
|
81
|
+
# # Seed global randomization in this process using the `--seed` CLI option.
|
82
|
+
# # Setting this allows you to use `--seed` to deterministically reproduce
|
83
|
+
# # test failures related to randomization by passing the same `--seed` value
|
84
|
+
# # as the one that triggered the failure.
|
85
|
+
# Kernel.srand config.seed
|
85
86
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dm_ruby_extensions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brett Walker
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-06-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '6.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '6.0'
|
27
27
|
description: Ruby base class extensions
|
28
28
|
email:
|
29
29
|
- github@digitalmoksha.com
|
@@ -31,13 +31,17 @@ executables: []
|
|
31
31
|
extensions: []
|
32
32
|
extra_rdoc_files: []
|
33
33
|
files:
|
34
|
+
- ".github/workflow/ci.yml"
|
34
35
|
- ".gitignore"
|
35
36
|
- ".rspec"
|
37
|
+
- ".rubocop.yml"
|
38
|
+
- ".ruby-version"
|
36
39
|
- ".travis.yml"
|
37
40
|
- Gemfile
|
38
41
|
- LICENSE
|
39
42
|
- README.md
|
40
43
|
- Rakefile
|
44
|
+
- bin/console
|
41
45
|
- dm_ruby_extensions.gemspec
|
42
46
|
- lib/dm_ruby_extensions.rb
|
43
47
|
- lib/dm_ruby_extensions/extend_array.rb
|
@@ -68,24 +72,23 @@ homepage: https://github.com/digitalmoksha/dm_ruby_extensions
|
|
68
72
|
licenses:
|
69
73
|
- MIT
|
70
74
|
metadata: {}
|
71
|
-
post_install_message:
|
75
|
+
post_install_message:
|
72
76
|
rdoc_options: []
|
73
77
|
require_paths:
|
74
78
|
- lib
|
75
79
|
required_ruby_version: !ruby/object:Gem::Requirement
|
76
80
|
requirements:
|
77
|
-
- - "
|
81
|
+
- - "~>"
|
78
82
|
- !ruby/object:Gem::Version
|
79
|
-
version: '0'
|
83
|
+
version: '3.0'
|
80
84
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
85
|
requirements:
|
82
86
|
- - ">="
|
83
87
|
- !ruby/object:Gem::Version
|
84
88
|
version: '0'
|
85
89
|
requirements: []
|
86
|
-
|
87
|
-
|
88
|
-
signing_key:
|
90
|
+
rubygems_version: 3.4.10
|
91
|
+
signing_key:
|
89
92
|
specification_version: 4
|
90
93
|
summary: Simple Ruby base class extensions
|
91
94
|
test_files:
|