easy_time 0.2.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 81e4762bb54961cecadb64214a5a72264145187d621bca1ed38175c4c73c1efe
4
- data.tar.gz: d78614033f17422a6e8fad9a3127aec448e442f755f26e2587df0e22505d91d4
3
+ metadata.gz: d4f0fb3fb88ee686970dd45f050f0552c21a5cbfa172d47a4e6efcdf49d315a1
4
+ data.tar.gz: bfd9fd1bf295831fa16c9aede647b3f8390af002937542a60b332893bf03f817
5
5
  SHA512:
6
- metadata.gz: 9f188b204b034fbdfada4745f300e9852b433e1bcb34470d9b68f5a3cd1a3733ffb7df01286039c366669c8efd3e94db2bb80165b39687e2628109f14b19605e
7
- data.tar.gz: 1c7d9d47438f6867515a23e9c576d8679e16ff04073ac27688655ed6ea7e6dfea959473d783e745f150cb6724ed2a44923f20f14619373c1373cba8e81c3119b
6
+ metadata.gz: 00bc14c61c2759891507a8b777708b5fd667353adbcff8255c91870f85d6479fabef87fad4f30bd47d8ead3459173ae979f767b958e20f809fe6d455f6c08bcc
7
+ data.tar.gz: 1468b0315071178981d7013485c6dca6304a6165d4372c632f722644e3b1864de0c825a1d6356cda2fef07048dbbff0bfc6f0f2ed57f77c2d542778a3df7ec03
data/.circleci/config.yml CHANGED
@@ -1,11 +1,11 @@
1
1
  version: 2.1
2
2
  orbs:
3
- ruby: circleci/ruby@0.1.2
3
+ ruby: circleci/ruby@2.1.0
4
4
 
5
5
  defaults: &DEFAULTS
6
6
  resource_class: small
7
7
  docker:
8
- - image: circleci/ruby:2.5
8
+ - image: cimg/ruby:2.7.8
9
9
 
10
10
  environment:
11
11
  BUNDLE_JOBS: 3
@@ -17,7 +17,7 @@ defaults: &DEFAULTS
17
17
  jobs:
18
18
  build:
19
19
  docker:
20
- - image: circleci/ruby:2.6.3-stretch-node
20
+ - image: cimg/ruby:2.7.8
21
21
  executor: ruby/default
22
22
  steps:
23
23
  - checkout
@@ -31,7 +31,7 @@ jobs:
31
31
 
32
32
  - run:
33
33
  name: Install bundler
34
- command: gem install bundler
34
+ command: gem install bundler -v 2.4.22
35
35
 
36
36
  - run:
37
37
  name: Check bundle version
@@ -93,7 +93,7 @@ jobs:
93
93
 
94
94
  - run:
95
95
  name: Install bundler
96
- command: gem install bundler
96
+ command: gem install bundler -v 2.4.22
97
97
 
98
98
  - run:
99
99
  name: set the bundle path
@@ -114,9 +114,9 @@ jobs:
114
114
  bundle exec rake clean
115
115
  bundle exec rake build
116
116
 
117
- #- deploy:
118
- # name: Release and push
119
- # command: bundle exec gem push
117
+ - deploy:
118
+ name: Release and push
119
+ command: bundle exec rake release
120
120
 
121
121
  workflows:
122
122
  version: 2
@@ -129,4 +129,3 @@ workflows:
129
129
  filters:
130
130
  branches:
131
131
  only: master
132
-
data/.rubocop.yml CHANGED
@@ -5,6 +5,9 @@ Metrics/AbcSize:
5
5
  Metrics/CyclomaticComplexity:
6
6
  Enabled: false
7
7
 
8
+ Metrics/BlockLength:
9
+ Enabled: false
10
+
8
11
  Metrics/MethodLength:
9
12
  Enabled: false
10
13
 
@@ -18,10 +21,17 @@ Metrics/ClassLength:
18
21
  Layout/ExtraSpacing:
19
22
  Enabled: false
20
23
 
24
+ Layout/HashAlignment:
25
+ Exclude:
26
+ - 'Guardfile'
27
+
21
28
  Layout/LineLength:
22
29
  Enabled: false
23
30
 
24
- Layout/SpacingAroundOperators:
31
+ Layout/SpaceAroundOperators:
32
+ Enabled: false
33
+
34
+ Layout/SpaceInsideArrayLiteralBrackets:
25
35
  Enabled: false
26
36
 
27
37
  # Styles
@@ -36,3 +46,18 @@ Style/StringLiterals:
36
46
 
37
47
  Style/RescueModifier:
38
48
  Enabled: false
49
+
50
+ Style/TrailingCommaInArrayLiteral:
51
+ Enabled: false
52
+
53
+ Style/FrozenStringLiteralComment:
54
+ Exclude:
55
+ - 'bin/*'
56
+
57
+ # Lint
58
+ Lint/ConstantDefinitionInBlock:
59
+ Enabled: false
60
+
61
+ # Naming
62
+ Naming/BinaryOperatorParameterName:
63
+ Enabled: false
data/CHANGELOG.md ADDED
@@ -0,0 +1,24 @@
1
+ # Change Log for EasyTime
2
+
3
+ ## [1.0.0] - 2024-02-26
4
+
5
+ ### Changed
6
+
7
+ Changed `convert` to use a named `coerce:` keyword parameter.
8
+ Updated and modernized the specs.
9
+ Rubocop complaints satisfied.
10
+ Bypassed '/specs/' for SimplCov
11
+
12
+ ###
13
+
14
+ ## [0.2.2] - 2024-01-18
15
+
16
+ ### Added
17
+ This `CHANGELOG.md` file
18
+
19
+ ### Changed
20
+ Added `activesupport` to the development dependencies in the gemspec
21
+
22
+ Updated the `initializer` method to not use the "presence" method.
23
+
24
+ Updated several gems to their latest versions.
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source "https://rubygems.org"
2
4
 
3
5
  # Specify your gem's dependencies in easy_time.gemspec
data/Gemfile.lock CHANGED
@@ -1,37 +1,46 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- easy_time (0.2.1)
4
+ easy_time (1.0.0)
5
5
  activesupport
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- activesupport (6.0.2.2)
10
+ activesupport (7.1.3)
11
+ base64
12
+ bigdecimal
11
13
  concurrent-ruby (~> 1.0, >= 1.0.2)
12
- i18n (>= 0.7, < 2)
13
- minitest (~> 5.1)
14
- tzinfo (~> 1.1)
15
- zeitwerk (~> 2.2)
16
- ast (2.4.0)
14
+ connection_pool (>= 2.2.5)
15
+ drb
16
+ i18n (>= 1.6, < 2)
17
+ minitest (>= 5.1)
18
+ mutex_m
19
+ tzinfo (~> 2.0)
20
+ ast (2.4.2)
21
+ base64 (0.2.0)
22
+ bigdecimal (3.1.6)
17
23
  builder (3.2.4)
18
24
  byebug (11.1.3)
19
- coderay (1.1.2)
20
- concurrent-ruby (1.1.6)
21
- diff-lcs (1.3)
22
- docile (1.3.2)
23
- ffi (1.12.2)
24
- formatador (0.2.5)
25
- fuubar (2.5.0)
25
+ coderay (1.1.3)
26
+ concurrent-ruby (1.2.3)
27
+ connection_pool (2.4.1)
28
+ diff-lcs (1.5.0)
29
+ docile (1.4.0)
30
+ drb (2.2.0)
31
+ ruby2_keywords
32
+ ffi (1.16.3)
33
+ formatador (1.1.0)
34
+ fuubar (2.5.1)
26
35
  rspec-core (~> 3.0)
27
36
  ruby-progressbar (~> 1.4)
28
- guard (2.16.2)
37
+ guard (2.18.1)
29
38
  formatador (>= 0.2.4)
30
39
  listen (>= 2.7, < 4.0)
31
40
  lumberjack (>= 1.0.12, < 2.0)
32
41
  nenv (~> 0.1)
33
42
  notiffany (~> 0.0)
34
- pry (>= 0.9.12)
43
+ pry (>= 0.13.0)
35
44
  shellany (~> 0.0)
36
45
  thor (>= 0.18.1)
37
46
  guard-compat (1.2.1)
@@ -42,80 +51,95 @@ GEM
42
51
  guard-yard (2.2.1)
43
52
  guard (>= 1.1.0)
44
53
  yard (>= 0.7.0)
45
- i18n (1.8.2)
54
+ i18n (1.14.1)
46
55
  concurrent-ruby (~> 1.0)
47
- jaro_winkler (1.5.4)
48
- listen (3.2.1)
56
+ json (2.7.1)
57
+ language_server-protocol (3.17.0.3)
58
+ listen (3.8.0)
49
59
  rb-fsevent (~> 0.10, >= 0.10.3)
50
60
  rb-inotify (~> 0.9, >= 0.9.10)
51
- lumberjack (1.2.4)
61
+ lumberjack (1.2.10)
52
62
  method_source (1.0.0)
53
- minitest (5.14.0)
63
+ minitest (5.21.2)
64
+ mutex_m (0.2.0)
54
65
  nenv (0.3.0)
55
66
  notiffany (0.1.3)
56
67
  nenv (~> 0.1)
57
68
  shellany (~> 0.0)
58
- parallel (1.19.1)
59
- parser (2.7.1.1)
60
- ast (~> 2.4.0)
61
- pry (0.13.1)
69
+ parallel (1.24.0)
70
+ parser (3.3.0.4)
71
+ ast (~> 2.4.1)
72
+ racc
73
+ pry (0.14.2)
62
74
  coderay (~> 1.1)
63
75
  method_source (~> 1.0)
64
- pry-byebug (3.9.0)
76
+ pry-byebug (3.10.1)
65
77
  byebug (~> 11.0)
66
- pry (~> 0.13.0)
67
- rainbow (3.0.0)
68
- rake (13.0.1)
69
- rb-fsevent (0.10.3)
78
+ pry (>= 0.13, < 0.15)
79
+ racc (1.7.3)
80
+ rainbow (3.1.1)
81
+ rake (13.1.0)
82
+ rb-fsevent (0.11.2)
70
83
  rb-inotify (0.10.1)
71
84
  ffi (~> 1.0)
72
- redcarpet (3.5.0)
73
- rexml (3.2.4)
74
- rspec (3.9.0)
75
- rspec-core (~> 3.9.0)
76
- rspec-expectations (~> 3.9.0)
77
- rspec-mocks (~> 3.9.0)
78
- rspec-core (3.9.1)
79
- rspec-support (~> 3.9.1)
80
- rspec-expectations (3.9.1)
85
+ redcarpet (3.6.0)
86
+ regexp_parser (2.9.0)
87
+ rexml (3.2.6)
88
+ rspec (3.12.0)
89
+ rspec-core (~> 3.12.0)
90
+ rspec-expectations (~> 3.12.0)
91
+ rspec-mocks (~> 3.12.0)
92
+ rspec-core (3.12.2)
93
+ rspec-support (~> 3.12.0)
94
+ rspec-expectations (3.12.3)
81
95
  diff-lcs (>= 1.2.0, < 2.0)
82
- rspec-support (~> 3.9.0)
83
- rspec-mocks (3.9.1)
96
+ rspec-support (~> 3.12.0)
97
+ rspec-mocks (3.12.6)
84
98
  diff-lcs (>= 1.2.0, < 2.0)
85
- rspec-support (~> 3.9.0)
86
- rspec-support (3.9.2)
99
+ rspec-support (~> 3.12.0)
100
+ rspec-support (3.12.1)
87
101
  rspec_junit (4.0.4)
88
102
  builder (>= 3.2.2)
89
103
  rspec (>= 3.3.0)
90
- rspec_junit_formatter (0.4.1)
104
+ rspec_junit_formatter (0.6.0)
91
105
  rspec-core (>= 2, < 4, != 2.12.0)
92
- rubocop (0.82.0)
93
- jaro_winkler (~> 1.5.1)
106
+ rubocop (1.60.1)
107
+ json (~> 2.3)
108
+ language_server-protocol (>= 3.17.0)
94
109
  parallel (~> 1.10)
95
- parser (>= 2.7.0.1)
110
+ parser (>= 3.3.0.2)
96
111
  rainbow (>= 2.2.2, < 4.0)
97
- rexml
112
+ regexp_parser (>= 1.8, < 3.0)
113
+ rexml (>= 3.2.5, < 4.0)
114
+ rubocop-ast (>= 1.30.0, < 2.0)
98
115
  ruby-progressbar (~> 1.7)
99
- unicode-display_width (>= 1.4.0, < 2.0)
100
- ruby-progressbar (1.10.1)
116
+ unicode-display_width (>= 2.4.0, < 3.0)
117
+ rubocop-ast (1.30.0)
118
+ parser (>= 3.2.1.0)
119
+ rubocop-rake (0.6.0)
120
+ rubocop (~> 1.0)
121
+ ruby-progressbar (1.13.0)
122
+ ruby2_keywords (0.0.5)
101
123
  shellany (0.0.1)
102
- simplecov (0.18.5)
124
+ simplecov (0.22.0)
103
125
  docile (~> 1.1)
104
126
  simplecov-html (~> 0.11)
105
- simplecov-html (0.12.2)
127
+ simplecov_json_formatter (~> 0.1)
128
+ simplecov-html (0.12.3)
129
+ simplecov_json_formatter (0.1.4)
106
130
  terminal-notifier-guard (1.7.0)
107
- thor (1.0.1)
108
- thread_safe (0.3.6)
109
- tzinfo (1.2.7)
110
- thread_safe (~> 0.1)
111
- unicode-display_width (1.7.0)
112
- yard (0.9.24)
113
- zeitwerk (2.3.0)
131
+ thor (1.3.0)
132
+ tzinfo (2.0.6)
133
+ concurrent-ruby (~> 1.0)
134
+ unicode-display_width (2.5.0)
135
+ yard (0.9.34)
114
136
 
115
137
  PLATFORMS
116
138
  ruby
139
+ x86_64-linux
117
140
 
118
141
  DEPENDENCIES
142
+ activesupport (>= 6.1.4)
119
143
  bundler (~> 2.1.4)
120
144
  easy_time!
121
145
  fuubar (>= 2.5.0)
@@ -129,6 +153,7 @@ DEPENDENCIES
129
153
  rspec_junit
130
154
  rspec_junit_formatter
131
155
  rubocop (>= 0.82.0)
156
+ rubocop-rake
132
157
  simplecov
133
158
  terminal-notifier-guard
134
159
  yard (>= 0.9.24)
data/Guardfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Guardfile for easy_time gem
2
4
 
3
5
  begin
@@ -30,6 +32,6 @@ guard :rspec,
30
32
  end
31
33
 
32
34
  guard 'yard' do
33
- watch(%r{lib\/.+\.rb})
35
+ watch(%r{lib/.+\.rb})
34
36
  watch('README.md')
35
37
  end
data/README.md CHANGED
@@ -15,10 +15,10 @@ Well, then, give EasyTime a try!
15
15
 
16
16
  `EasyTime` accepts most of the well-known date and time objects, including
17
17
  `RFC2822`, `HTTPDate`, `XMLSchema`, `ISO8601`, as well as
18
- ActiveSupport::TimeWithZone strings and provides comparisons that have an
18
+ `ActiveSupport::TimeWithZone` strings and provides comparisons that have an
19
19
  adjustable tolerance. With `EasyTime` methods, you can reliably compare two
20
20
  timestamps and determine which one is "newer", "older" or the "same" withing
21
- a configurable tolerance. The default comparison tolerance is 1.minute.
21
+ a configurable tolerance. The default comparison tolerance is `1.minute`.
22
22
 
23
23
  In other words, if you have a time-stamp from an `ActiveRecord` object that is
24
24
  a few seconds different from a related object obtained from a 3rd-party system,
@@ -135,8 +135,8 @@ A `String` value is parsed with the `convert` method.
135
135
 
136
136
  #### Time Strings
137
137
 
138
- Most modern time format strings are recognized: ISO8601, RFD2822, HTTPDate,
139
- XMLSchema, and even some natural date and time formats. Many systems use an
138
+ Most modern time format strings are recognized: `ISO8601`, `RFD2822`, `HTTPDate`,
139
+ `XMLSchema`, and even some natural date and time formats. Many systems use an
140
140
  [ISO8601](https://en.wikipedia.org/wiki/ISO_8601) string, which has date, time,
141
141
  and timezone components, with each variant having some variations.
142
142
 
@@ -204,9 +204,9 @@ applied across all instances of the class.
204
204
 
205
205
  ### EasyTime Instance Methods
206
206
 
207
- Once a `EasyTime` value has been created, it is basically a wrapped `Time` value
208
- where the comparison methods are overridden in order to apply the comparison
209
- tolerance value.
207
+ Once an `EasyTime` value has been created, it is basically a wrapped `Time`
208
+ value where the comparison methods are overridden in order to apply the
209
+ comparison tolerance value.
210
210
 
211
211
  These are the instance methods:
212
212
 
@@ -318,9 +318,9 @@ simple to review the gem API documentation:
318
318
 
319
319
  ## Contributing
320
320
 
321
- If you wish to contribute, please fork the repo, create a new branch for your suggested
322
- improvement, and create a pull request based off of your forked repo branch. Please do
323
- not make changes in the version.
321
+ If you wish to contribute, please fork the repo, create a new branch for your
322
+ suggested improvement, and create a pull request based off of your forked repo
323
+ branch. Please do not make changes in the version.
324
324
 
325
325
  Bug reports and pull requests are welcome on GitHub at https://github.com/aks/easy_time.
326
326
 
data/Rakefile CHANGED
@@ -1,8 +1,13 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "bundler/gem_tasks"
2
4
  require "rspec/core/rake_task"
5
+ require "rubocop-rake"
6
+ require "rubocop/rake_task"
3
7
  require 'yard'
4
8
 
5
9
  RSpec::Core::RakeTask.new(:spec)
10
+ RuboCop::RakeTask.new
6
11
 
7
12
  namespace :spec do
8
13
  desc "run tests with code coverage"
@@ -11,9 +16,19 @@ namespace :spec do
11
16
  end
12
17
  end
13
18
 
19
+ task default: %i[spec rubocop]
20
+ task build: %i[bundle:add_linux]
21
+ task install: %i[build spec bundle:add_linux]
22
+ task release: %i[build spec install bundle:add_linux]
23
+
24
+ namespace :bundle do
25
+ desc 'add linux platform to Gemfile.lock'
26
+ task :add_linux do
27
+ sh 'bundle lock --add-platform x86_64-linux'
28
+ end
29
+ end
30
+
14
31
  YARD::Rake::YardocTask.new do |t|
15
32
  t.options += ['--title', "EasyTime #{EasyTime::VERSION} Documentation"]
16
33
  t.stats_options = ['--list-undoc']
17
34
  end
18
-
19
- task :default => :spec
data/easy_time.gemspec CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'lib/easy_time/version'
2
4
 
3
5
  Gem::Specification.new do |spec|
@@ -6,7 +8,7 @@ Gem::Specification.new do |spec|
6
8
  spec.authors = ["Alan Stebbens"]
7
9
  spec.email = ["aks@stebbens.org"]
8
10
 
9
- spec.summary = %q{Easy auto-conversion of most date and time values with tolerant-comparisons}
11
+ spec.summary = "Easy auto-conversion of most date and time values with tolerant-comparisons"
10
12
  spec.description =
11
13
  <<~'DESC'
12
14
 
@@ -26,9 +28,11 @@ Gem::Specification.new do |spec|
26
28
  DESC
27
29
  spec.homepage = 'https://github.com/aks/easy_time'
28
30
  spec.license = "MIT"
29
- spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
31
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.7")
30
32
 
31
33
  spec.metadata["allowed_push_host"] = "https://rubygems.org"
34
+ # spec.metadata["allowed_push_host"] = "https://rubygems.pkg.github.com/aks"
35
+ spec.metadata["github_repo"] = "ssh://github.com/aks/easy_time"
32
36
 
33
37
  spec.metadata["homepage_uri"] = spec.homepage
34
38
  spec.metadata["source_code_uri"] = "https://github.com/aks/easy_time"
@@ -36,13 +40,14 @@ Gem::Specification.new do |spec|
36
40
 
37
41
  # Specify which files should be added to the gem when it is released.
38
42
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
39
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
43
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
40
44
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
41
45
  end
42
46
  spec.bindir = "bin"
43
47
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
44
48
  spec.require_paths = ["lib"]
45
49
 
50
+ spec.add_development_dependency "activesupport", ">= 6.1.4"
46
51
  spec.add_development_dependency "bundler", "~> 2.1.4"
47
52
  spec.add_development_dependency "fuubar", ">= 2.5.0"
48
53
  spec.add_development_dependency "guard"
@@ -50,11 +55,12 @@ Gem::Specification.new do |spec|
50
55
  spec.add_development_dependency "guard-yard"
51
56
  spec.add_development_dependency "pry-byebug"
52
57
  spec.add_development_dependency "rake"
58
+ spec.add_development_dependency "redcarpet"
53
59
  spec.add_development_dependency "rspec"
54
60
  spec.add_development_dependency "rspec_junit"
55
61
  spec.add_development_dependency "rspec_junit_formatter"
56
- spec.add_development_dependency "redcarpet"
57
62
  spec.add_development_dependency "rubocop", ">= 0.82.0"
63
+ spec.add_development_dependency "rubocop-rake"
58
64
  spec.add_development_dependency "simplecov"
59
65
  spec.add_development_dependency "terminal-notifier-guard" if /Darwin/.match?(`uname -a`.strip)
60
66
  spec.add_development_dependency "yard", ">= 0.9.24"
@@ -41,7 +41,7 @@ class EasyTime
41
41
  # various kinds of date and time values
42
42
  # @param coerce [Boolean] if true, coerce the `arg` into a Time object _(default: true)_
43
43
  # @return [Time]
44
- def convert(arg, coerce = true)
44
+ def convert(arg, coerce: true)
45
45
  case arg
46
46
  when String
47
47
  parse_string(arg) # parse the string value into an EasyTime object
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class EasyTime
2
- VERSION = "0.2.1"
4
+ VERSION = "1.0.0"
3
5
  end
data/lib/easy_time.rb CHANGED
@@ -138,7 +138,6 @@ class EasyTime
138
138
  compare(time1, time2, tolerance: tolerance).zero?
139
139
  end
140
140
 
141
-
142
141
  # @overload between?(time1, t_min, t_max, tolerance: nil)
143
142
  # @param time1 [Date,Time,DateTime,EasyTime,Duration,String,Array<Integer>] a time value
144
143
  # @param t_min [Date,Time,DateTime,EasyTime,Duration,String,Array<Integer>] the minimum time
@@ -150,7 +149,7 @@ class EasyTime
150
149
  # @param time_range [Range] a range `(t_min..t_max)` of time values
151
150
  # @return [Boolean] true if `time_range.min <= time1 <= time_range.max`, using tolerant comparisons
152
151
 
153
- def between?(time1, t_arg, t_max=nil, tolerance: nil)
152
+ def between?(time1, t_arg, t_max = nil, tolerance: nil)
154
153
  if t_arg.is_a?(Range)
155
154
  t_min = t_arg.min
156
155
  t_max = t_arg.max
@@ -221,13 +220,13 @@ class EasyTime
221
220
  end
222
221
  end
223
222
 
224
- def respond_to_missing?(symbol, include_all=false)
223
+ def respond_to_missing?(symbol, include_all = false)
225
224
  Time.respond_to?(symbol, include_all)
226
225
  end
227
226
 
228
227
  # @param value [Anything] value to test as a time-like object
229
228
  # @return [Boolean] true if value is one the known Time classes, or responds to :acts_like_time?
230
- def is_a_time?(value)
229
+ def a_time?(value)
231
230
  case value
232
231
  when Integer, ActiveSupport::Duration
233
232
  false
@@ -237,6 +236,7 @@ class EasyTime
237
236
  value.respond_to?(:acts_like_time?) && value.acts_like_time?
238
237
  end
239
238
  end
239
+ alias is_a_time? a_time?
240
240
  end
241
241
 
242
242
  attr_accessor :time
@@ -246,7 +246,7 @@ class EasyTime
246
246
  delegate :to_s, :inspect, to: :time
247
247
 
248
248
  def initialize(*time, tolerance: nil)
249
- @time = time.presence && convert(time.size == 1 ? time.first : time)
249
+ @time = time.size.nonzero? && convert(time.size == 1 ? time.first : time)
250
250
  @comparison_tolerance = tolerance
251
251
  end
252
252
 
@@ -318,7 +318,7 @@ class EasyTime
318
318
  # @return [Integer] one of [-1, 0, 1] or nil
319
319
 
320
320
  def <=>(other)
321
- diff = self - other # note: this has a side-effect of setting @other_time
321
+ diff = self - other # NOTE: this has a side-effect of setting @other_time
322
322
  if diff && diff.to_i.abs <= comparison_tolerance.to_i
323
323
  0
324
324
  elsif diff
@@ -362,7 +362,7 @@ class EasyTime
362
362
  # a date/time value, a duration, or an Integer
363
363
  # @return [EasyTime,Integer] updated time _(time - duration)_ or duration _(time - time)_
364
364
  def -(other)
365
- @other_time = convert(other, false)
365
+ @other_time = convert(other, coerce: false)
366
366
  if is_a_time?(other_time)
367
367
  time - other_time
368
368
  elsif other_time
@@ -376,8 +376,8 @@ class EasyTime
376
376
 
377
377
  private
378
378
 
379
- def convert(datetime, coerce = true)
380
- self.class.convert(datetime, coerce)
379
+ def convert(datetime, coerce: true)
380
+ self.class.convert(datetime, coerce: coerce)
381
381
  end
382
382
 
383
383
  # intercept any time methods so they can wrap the time-like result in a new EasyTime object.
@@ -390,13 +390,14 @@ class EasyTime
390
390
  end
391
391
  end
392
392
 
393
- def respond_to_missing?(symbol, include_all=false)
393
+ def respond_to_missing?(symbol, include_all = false)
394
394
  time.respond_to?(symbol, include_all)
395
395
  end
396
396
 
397
- def is_a_time?(value)
397
+ def a_time?(value)
398
398
  self.class.is_a_time?(value)
399
399
  end
400
+ alias is_a_time? a_time?
400
401
  end
401
402
 
402
403
  # Extend the known date and time classes _(including EasyTime itself!)_
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: easy_time
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alan Stebbens
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-27 00:00:00.000000000 Z
11
+ date: 2024-02-27 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 6.1.4
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 6.1.4
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: bundler
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -109,7 +123,7 @@ dependencies:
109
123
  - !ruby/object:Gem::Version
110
124
  version: '0'
111
125
  - !ruby/object:Gem::Dependency
112
- name: rspec
126
+ name: redcarpet
113
127
  requirement: !ruby/object:Gem::Requirement
114
128
  requirements:
115
129
  - - ">="
@@ -123,7 +137,7 @@ dependencies:
123
137
  - !ruby/object:Gem::Version
124
138
  version: '0'
125
139
  - !ruby/object:Gem::Dependency
126
- name: rspec_junit
140
+ name: rspec
127
141
  requirement: !ruby/object:Gem::Requirement
128
142
  requirements:
129
143
  - - ">="
@@ -137,7 +151,7 @@ dependencies:
137
151
  - !ruby/object:Gem::Version
138
152
  version: '0'
139
153
  - !ruby/object:Gem::Dependency
140
- name: rspec_junit_formatter
154
+ name: rspec_junit
141
155
  requirement: !ruby/object:Gem::Requirement
142
156
  requirements:
143
157
  - - ">="
@@ -151,7 +165,7 @@ dependencies:
151
165
  - !ruby/object:Gem::Version
152
166
  version: '0'
153
167
  - !ruby/object:Gem::Dependency
154
- name: redcarpet
168
+ name: rspec_junit_formatter
155
169
  requirement: !ruby/object:Gem::Requirement
156
170
  requirements:
157
171
  - - ">="
@@ -178,6 +192,20 @@ dependencies:
178
192
  - - ">="
179
193
  - !ruby/object:Gem::Version
180
194
  version: 0.82.0
195
+ - !ruby/object:Gem::Dependency
196
+ name: rubocop-rake
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - ">="
200
+ - !ruby/object:Gem::Version
201
+ version: '0'
202
+ type: :development
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - ">="
207
+ - !ruby/object:Gem::Version
208
+ version: '0'
181
209
  - !ruby/object:Gem::Dependency
182
210
  name: simplecov
183
211
  requirement: !ruby/object:Gem::Requirement
@@ -263,6 +291,7 @@ files:
263
291
  - ".rubocop.yml"
264
292
  - ".travis.yml"
265
293
  - ".yardopts"
294
+ - CHANGELOG.md
266
295
  - Gemfile
267
296
  - Gemfile.lock
268
297
  - Guardfile
@@ -280,9 +309,10 @@ licenses:
280
309
  - MIT
281
310
  metadata:
282
311
  allowed_push_host: https://rubygems.org
312
+ github_repo: ssh://github.com/aks/easy_time
283
313
  homepage_uri: https://github.com/aks/easy_time
284
314
  source_code_uri: https://github.com/aks/easy_time
285
- post_install_message:
315
+ post_install_message:
286
316
  rdoc_options: []
287
317
  require_paths:
288
318
  - lib
@@ -290,15 +320,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
290
320
  requirements:
291
321
  - - ">="
292
322
  - !ruby/object:Gem::Version
293
- version: 2.3.0
323
+ version: '2.7'
294
324
  required_rubygems_version: !ruby/object:Gem::Requirement
295
325
  requirements:
296
326
  - - ">="
297
327
  - !ruby/object:Gem::Version
298
328
  version: '0'
299
329
  requirements: []
300
- rubygems_version: 3.1.2
301
- signing_key:
330
+ rubygems_version: 3.1.6
331
+ signing_key:
302
332
  specification_version: 4
303
333
  summary: Easy auto-conversion of most date and time values with tolerant-comparisons
304
334
  test_files: []
335
+ ...