iso8601 0.12.3 → 0.13.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: b974875d177ceceff7f8d892867990e27f46718e57d7a8bb0119b8ccbddd77eb
4
- data.tar.gz: 0b4e786f4abde832af5f5ceefb53c2478cffa0c3e8d9e997762ca54787fbf70a
3
+ metadata.gz: 2974ec0c720d241b0a0911daf76b75ed14b3ebd6c7d7281928e378020dfead9c
4
+ data.tar.gz: 6b2259287505b9a2cbc55f45b0f79ba1d997398a415e905372c28736a3a3ac52
5
5
  SHA512:
6
- metadata.gz: e295765af84738b2bc1dc80ad2509a7e8bc065e61e32151ad979eb332cb5afe9b0042dd7072674be8259d985684616e8a0c9890c88cc29eefee9391ffd248924
7
- data.tar.gz: 5ef627990b4f2c1ec2bcb98ec4caddc23928612a6b2895080cdcc84fd8a9295e7ce8564c04303d37b3c3ab934922cf9b1cdf8ced23571777f8c57ab2067a6ac5
6
+ metadata.gz: 5e5eaea339d00bd45c42e0851e2c53690752e845fd032df04f1fd56f459125af1153c1165a6871861e6b7ac7ce9814fdadd4e24081bdcc13aa03a44dd408947f
7
+ data.tar.gz: 6dc46e177556b17d5545e469fd624071db4dfbd914557b6c641b3bfec04e6af295d2f7c024940cb4777f4c78cb88a271c85147efed2a11299154227373c5bcf8
data/README.md CHANGED
@@ -11,8 +11,6 @@ Version 1.0.0 will lock public interfaces.
11
11
 
12
12
  Check the [changelog](https://github.com/arnau/ISO8601/blob/master/CHANGELOG.md) if you are upgrading from an older version.
13
13
 
14
- [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/arnau/ISO8601?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
15
-
16
14
  ISO8601 is a simple implementation of the ISO 8601 (Data elements and
17
15
  interchange formats — Information interchange — Representation of dates and
18
16
  times) standard.
@@ -24,7 +22,7 @@ times) standard.
24
22
 
25
23
  ## Supported versions
26
24
 
27
- * MRI 2.x
25
+ * MRI 2.5, 2.6, 2.7
28
26
 
29
27
  ## Documentation
30
28
 
@@ -48,7 +46,7 @@ Then
48
46
 
49
47
  ```
50
48
  $ bundle install
51
- $ bundle exec rspec
49
+ $ bundle exec rake
52
50
  ```
53
51
 
54
52
  ## Contributing
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'time'
2
4
  require 'forwardable'
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ISO8601
2
4
  module Atomic
3
5
  include Comparable
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ISO8601
2
4
  ##
3
5
  # A Date representation.
@@ -112,6 +114,7 @@ module ISO8601
112
114
  # @param [String] input
113
115
  #
114
116
  # @return [Array<Integer>]
117
+ #
115
118
  # rubocop:disable Metrics/AbcSize
116
119
  def atomize(input)
117
120
  week_date = parse_weekdate(input)
@@ -128,6 +131,7 @@ module ISO8601
128
131
 
129
132
  [year, month, day].compact.map(&:to_i)
130
133
  end
134
+ # rubocop:enable Metrics/AbcSize
131
135
 
132
136
  def parse_weekdate(input)
133
137
  /^([+-]?)\d{4}(-?)W\d{2}(?:\2\d)?$/.match(input)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ISO8601
2
4
  ##
3
5
  # A DateTime representation
@@ -96,6 +98,7 @@ module ISO8601
96
98
  # It enhances the parsing capabilities of the native DateTime.
97
99
  #
98
100
  # @param [String] date_time The ISO representation
101
+ #
99
102
  # rubocop:disable Metrics/AbcSize
100
103
  def parse(date_time)
101
104
  raise(ISO8601::Errors::UnknownPattern, date_time) if date_time.empty?
@@ -111,6 +114,7 @@ module ISO8601
111
114
 
112
115
  ::DateTime.new(*(date_atoms + time_atoms).compact)
113
116
  end
117
+ # rubocop:enable Metrics/AbcSize
114
118
 
115
119
  ##
116
120
  # Validates the date has the right pattern.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ISO8601
2
4
  ##
3
5
  # The Days atom in a {ISO8601::Duration}
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ISO8601
2
4
  ##
3
5
  # A duration representation. When no base is provided, all atoms use an
@@ -21,8 +23,6 @@ module ISO8601
21
23
  # dp = ISO8601::Duration.new('P2Y1MT2H')
22
24
  # di == dp # => true
23
25
  # di == ds # => true
24
- #
25
- # rubocop:disable Metrics/ClassLength
26
26
  class Duration
27
27
  ##
28
28
  # @param [String, Numeric] input The duration pattern
@@ -244,6 +244,7 @@ module ISO8601
244
244
  # @param [Numeric] value The seconds to promote
245
245
  #
246
246
  # @return [ISO8601::Duration]
247
+ #
247
248
  # rubocop:disable Metrics/AbcSize
248
249
  def seconds_to_iso(value)
249
250
  return self.class.new('PT0S') if value.zero?
@@ -263,6 +264,7 @@ module ISO8601
263
264
 
264
265
  self.class.new(date + time)
265
266
  end
267
+ # rubocop:enable Metrics/AbcSize
266
268
 
267
269
  def decompose_atom(value, atom)
268
270
  [atom.class.new((value / atom.factor).to_i), (value % atom.factor)]
@@ -282,6 +284,7 @@ module ISO8601
282
284
  input
283
285
  end
284
286
 
287
+ # rubocop:disable Metrics/AbcSize
285
288
  def valid_pattern?(components)
286
289
  date = [components[:years],
287
290
  components[:months],
@@ -297,6 +300,7 @@ module ISO8601
297
300
 
298
301
  raise(ISO8601::Errors::UnknownPattern, @pattern) if empty
299
302
  end
303
+ # rubocop:enable Metrics/AbcSize
300
304
 
301
305
  def valid_fractions?(values)
302
306
  values = values.reject(&:zero?)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ISO8601
2
4
  ##
3
5
  # Contains all ISO8601-specific errors.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ISO8601
2
4
  ##
3
5
  # The Hours atom in a {ISO8601::Duration}
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ISO8601
2
4
  ##
3
5
  # The Minutes atom in a {ISO8601::Duration}
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ISO8601
2
4
  ##
3
5
  # A Months atom in a {ISO8601::Duration}
@@ -81,5 +83,6 @@ module ISO8601
81
83
 
82
84
  (::Time.utc(year, month) - ::Time.utc(base.year, base.month)) / atom
83
85
  end
86
+ # rubocop:enable Metrics/AbcSize
84
87
  end
85
88
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ISO8601
2
4
  ##
3
5
  # The Seconds atom in a {ISO8601::Duration}
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ISO8601
2
4
  ##
3
5
  # A Time representation
@@ -113,6 +115,7 @@ module ISO8601
113
115
  # @param [String] input
114
116
  #
115
117
  # @return [Array<Integer, Float>]
118
+ #
116
119
  # rubocop:disable Metrics/AbcSize
117
120
  def atomize(input)
118
121
  _, time, zone = parse_timezone(input)
@@ -133,6 +136,7 @@ module ISO8601
133
136
 
134
137
  atoms
135
138
  end
139
+ # rubocop:enable Metrics/AbcSize
136
140
 
137
141
  def require_separator(input)
138
142
  !input.nil?
@@ -164,9 +168,7 @@ module ISO8601
164
168
  _, offset, separator = zone_regexp.match(zone).to_a.compact
165
169
 
166
170
  wrong_pattern = !zone.nil? && offset.nil?
167
- if require_separator
168
- invalid_separators = zone.to_s.match(/^[+-]\d{2}:?\d{2}$/) && (@separator != separator)
169
- end
171
+ invalid_separators = zone.to_s.match(/^[+-]\d{2}:?\d{2}$/) && (@separator != separator) if require_separator
170
172
 
171
173
  !(wrong_pattern || invalid_separators)
172
174
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ISO8601
2
4
  ##
3
5
  # A Time Interval representation.
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ISO8601
2
4
  ##
3
5
  # The gem version
4
- VERSION = '0.12.3'.freeze
6
+ VERSION = '0.13.0'
5
7
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ISO8601
2
4
  ##
3
5
  # A Weeks atom in a {ISO8601::Duration}
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ISO8601
2
4
  ##
3
5
  # A Years atom in a {ISO8601::Duration}
@@ -51,14 +53,17 @@ module ISO8601
51
53
  # the year length.
52
54
  #
53
55
  # @return [Numeric]
56
+ #
54
57
  # rubocop:disable Metrics/AbcSize
55
58
  def to_seconds(base = nil)
56
59
  valid_base?(base)
57
60
  return factor(base) * atom if base.nil?
61
+
58
62
  target = ::Time.new(base.year + atom.to_i, base.month, base.day, base.hour, base.minute, base.second, base.zone)
59
63
 
60
64
  target - base.to_time
61
65
  end
66
+ # rubocop:enable Metrics/AbcSize
62
67
 
63
68
  ##
64
69
  # The atom symbol.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe ISO8601::Date do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe ISO8601::DateTime do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  RSpec.describe ISO8601::Days do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  RSpec.describe ISO8601::Duration do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  RSpec.describe ISO8601::Hours do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  RSpec.describe ISO8601::Minutes do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  RSpec.describe ISO8601::Months do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  RSpec.describe ISO8601::Seconds do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  RSpec.describe ISO8601::TimeInterval do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe ISO8601::Time do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  RSpec.describe ISO8601::Weeks do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  RSpec.describe ISO8601::Years do
@@ -1,4 +1,6 @@
1
- $LOAD_PATH.unshift File.expand_path('..', __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ $LOAD_PATH.unshift File.expand_path(__dir__)
2
4
  require 'iso8601'
3
5
 
4
6
  RSpec.configure do |config|
metadata CHANGED
@@ -1,85 +1,99 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iso8601
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.3
4
+ version: 0.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arnau Siches
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-03 00:00:00.000000000 Z
11
+ date: 2020-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rspec
14
+ name: pry
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '3.9'
19
+ version: 0.13.1
20
20
  type: :development
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: '3.9'
26
+ version: 0.13.1
27
27
  - !ruby/object:Gem::Dependency
28
- name: rubocop
28
+ name: pry-doc
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0.85'
33
+ version: 1.1.0
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0.85'
40
+ version: 1.1.0
41
41
  - !ruby/object:Gem::Dependency
42
- name: rubocop-packaging
42
+ name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 0.1.1
47
+ version: '13.0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 0.1.1
54
+ version: '13.0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: pry
56
+ name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 0.13.1
61
+ version: '3.9'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 0.13.1
68
+ version: '3.9'
69
69
  - !ruby/object:Gem::Dependency
70
- name: pry-doc
70
+ name: rubocop
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 1.1.0
75
+ version: '0.85'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 1.1.0
82
+ version: '0.85'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop-packaging
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 0.1.1
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 0.1.1
83
97
  description: |2
84
98
  ISO8601 is a simple implementation in Ruby of the ISO 8601 (Data elements and
85
99
  interchange formats - Information interchange - Representation of dates
@@ -136,7 +150,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
136
150
  requirements:
137
151
  - - ">="
138
152
  - !ruby/object:Gem::Version
139
- version: 2.0.0
153
+ version: 2.4.0
140
154
  required_rubygems_version: !ruby/object:Gem::Requirement
141
155
  requirements:
142
156
  - - ">="