carbon_date 0.1.0 → 0.1.1

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
  SHA1:
3
- metadata.gz: ae908e3fff96f810d6da2d667dd5d4bb4b36375f
4
- data.tar.gz: 03f87e6676aeefeb7e518b098a3dfa8b45fcff50
3
+ metadata.gz: 15ca7832b179451649cfe8cbf847532875ba167b
4
+ data.tar.gz: 8131707b3b7d297ead922c9cde6ef1caf0186d17
5
5
  SHA512:
6
- metadata.gz: a85737f07ef57b1899fbc2d0edaec40b4d40d44789dc58e01358940d70229f0839ce582a15926f1f00c627475dfeb3de5f9be3336a19bce6554447cd133c0d42
7
- data.tar.gz: 9fff56dc1df8ac528547df5b6aa70202704fecdaa985f92e3c8f0bd67576630a5b742773595b8fe3fa918728d92128e0b63b12fe74554dc7c20f146a40604963
6
+ metadata.gz: 3fef630e9f37ff2d13d51f97d84e6cfe07d8d841ce645f22adc6686650d4250ab377f7eccddae5d5ad5e66b1e19db6aa858a0048944331eac0ceef372b408b96
7
+ data.tar.gz: 3117e099d4ae329636dfe80f9d7c0f203657be0112bd4584d30993076d8f870855ad9744267e7f8b1c3d476e4c5b75dca8d8d30fac3d041c5a1846f68bc2fa83
data/README.md CHANGED
@@ -1,22 +1,25 @@
1
+ [![Gem Version](http://img.shields.io/gem/v/carbon_date.svg?style=flat-square)](https://rubygems.org/gems/carbon_date)
2
+ [![License](http://img.shields.io/:license-mit-blue.svg?style=flat-square)](http://bradleymarques.mit-license.org)
3
+
1
4
  # CarbonDate
2
5
 
3
- CarbonDate is a Ruby gem that models (pre)historic dates with (im)precision. Dates are modelled according to the [Gregorian Calendar](https://en.wikipedia.org/wiki/Gregorian_calendar), and can have the following precision:
4
-
5
- 0. billion_years
6
- 1. hundred_million_years
7
- 2. ten_million_years
8
- 3. million_years
9
- 4. hundred_thousand_years
10
- 5. ten_thousand_years
11
- 6. millennium
12
- 7. century
13
- 8. decade
14
- 9. year
15
- 10. month
16
- 11. day
17
- 12. hour
18
- 13. minute
19
- 14. second
6
+ CarbonDate is a Ruby gem that models (pre)historic dates with (im)precision. Dates are modelled according to the [Gregorian Calendar](https://en.wikipedia.org/wiki/Gregorian_calendar), and can have one of the following precisions:
7
+
8
+ + billion years;
9
+ + hundred million years;
10
+ + ten million years;
11
+ + million years;
12
+ + hundred thousand years;
13
+ + ten thousand years;
14
+ + millennium;
15
+ + century;
16
+ + decade;
17
+ + year;
18
+ + month;
19
+ + day;
20
+ + hour;
21
+ + minute;
22
+ + or second.
20
23
 
21
24
  ## Installation
22
25
 
data/carbon_date.gemspec CHANGED
@@ -35,6 +35,7 @@ Gem::Specification.new do |spec|
35
35
  spec.add_development_dependency 'm', '>= 1.5.0', '~> 1.5.0'
36
36
  spec.add_development_dependency 'pry', '~> 0.10.3', '>= 0.10.3'
37
37
  spec.add_development_dependency 'rdoc', '~> 4.2.2', '>= 4.2.2'
38
+ spec.add_development_dependency 'mocha', '~> 1.1.0', '>= 1.1.0'
38
39
 
39
40
  spec.add_dependency 'activesupport', '~> 4.2.6', '>= 4.2.6'
40
41
  end
@@ -114,18 +114,18 @@ module CarbonDate
114
114
  ##
115
115
  # Sets the minute with validation
116
116
  #
117
- # Raises ArgumentError unless in the range (0..60)
117
+ # Raises ArgumentError unless in the range (0..59)
118
118
  def minute=(value)
119
- raise ArgumentError.new "Invalid minute #{value}" unless (0..60).include? value
119
+ raise ArgumentError.new "Invalid minute #{value}" unless (0..59).include? value
120
120
  @minute = value
121
121
  end
122
122
 
123
123
  ##
124
124
  # Sets the second with validation
125
125
  #
126
- # Raises ArgumentError unless in the range (0..60)
126
+ # Raises ArgumentError unless in the range (0..59)
127
127
  def second=(value)
128
- raise ArgumentError.new "Invalid second #{value}" unless (0..60).include? value
128
+ raise ArgumentError.new "Invalid second #{value}" unless (0..59).include? value
129
129
  @second = value
130
130
  end
131
131
 
@@ -137,7 +137,7 @@ module CarbonDate
137
137
  # +string+ -> the iso8601 datetime in the form +1989-03-23T23:11:08Z
138
138
  # +precision_level+ -> an integer between 0 and 14 (see CarbonDate::Date::PRECISION)
139
139
  def self.iso8601(string, precision_level)
140
- p = PRECISION.find { |p| p[:level] == precision_level}
140
+ p = PRECISION.find { |x| x[:level] == precision_level}
141
141
  raise ArgumentError.new("Invalid precision level #{precision_level}") unless p
142
142
  # If there is an initial '-' symbol on the year, it needs to be treateded differenty than the other '-'.
143
143
  # Example: -0500-01-01 is the 1st January 500 BCE
@@ -147,7 +147,7 @@ module CarbonDate
147
147
  else
148
148
  bce = false
149
149
  end
150
- d = string.split('T').map { |x| x.split /[-:]/ }.flatten.map(&:to_i)
150
+ d = string.split('T').map { |x| x.split(/[-:]/) }.flatten.map(&:to_i)
151
151
  year = bce ? -d[0] : d[0]
152
152
  CarbonDate::Date.new(year, d[1], d[2], d[3], d[4], d[5], precision: p[:symbol])
153
153
  end
@@ -1,3 +1,3 @@
1
1
  module CarbonDate
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: carbon_date
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bradley Marques
@@ -164,6 +164,26 @@ dependencies:
164
164
  - - ">="
165
165
  - !ruby/object:Gem::Version
166
166
  version: 4.2.2
167
+ - !ruby/object:Gem::Dependency
168
+ name: mocha
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - "~>"
172
+ - !ruby/object:Gem::Version
173
+ version: 1.1.0
174
+ - - ">="
175
+ - !ruby/object:Gem::Version
176
+ version: 1.1.0
177
+ type: :development
178
+ prerelease: false
179
+ version_requirements: !ruby/object:Gem::Requirement
180
+ requirements:
181
+ - - "~>"
182
+ - !ruby/object:Gem::Version
183
+ version: 1.1.0
184
+ - - ">="
185
+ - !ruby/object:Gem::Version
186
+ version: 1.1.0
167
187
  - !ruby/object:Gem::Dependency
168
188
  name: activesupport
169
189
  requirement: !ruby/object:Gem::Requirement