iso8601 0.8.6 → 0.8.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.dockerignore +7 -0
- data/CHANGELOG.md +7 -2
- data/LICENSE +1 -1
- data/Makefile +6 -12
- data/README.md +19 -12
- data/lib/iso8601/atoms.rb +7 -4
- data/lib/iso8601/version.rb +1 -1
- data/spec/iso8601/atoms_spec.rb +17 -0
- metadata +3 -3
- data/Vagrantfile +0 -41
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da8595f5fe628655a291148485dbd7d24f65688c
|
4
|
+
data.tar.gz: 02f8ad412ea8b17eacbf4b0e9a3758c8f4bdc2c2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e33d0e1b9016a1d5c41bf2b4c582ccbff2fb030e8d373151ac9f2e6fa09aaabb2126c160253c1e126a1ce4a4ffdfa4e607c61b74d09dc926cbabb880c9ddf47b
|
7
|
+
data.tar.gz: 96d0336d8add6e8a91e82ef6d27fa1cfaf9cc1d0b54a010123d9b01d2b161135135a7b03c5d8e74422edb785a0948401a702e82c8c303a93713653dbce87506a
|
data/.dockerignore
ADDED
data/CHANGELOG.md
CHANGED
@@ -1,7 +1,12 @@
|
|
1
|
+
## 0.8.7
|
2
|
+
|
3
|
+
* Make `Atom` comparable with the same kind (thanks @glassbead0).
|
4
|
+
* Fix #18 document interfaces to core date/time classes.
|
5
|
+
|
1
6
|
## 0.8.6
|
2
7
|
|
3
|
-
* Fix #26 operations with Date, DateTime and Time with Duration (
|
4
|
-
* Fix #25 accept time components with timezone and only hour component (
|
8
|
+
* Fix #26 operations with Date, DateTime and Time with Duration (e.g. `ISO8601::DateTime.new('2012-07-07T20:20:20Z') - ISO8601::Duration.new('PT10M')`).
|
9
|
+
* Fix #25 accept time components with timezone and only hour component (e.g. `ISO8601::Time.new('T10+01:00')`).
|
5
10
|
* Fix Docker image for testing and inspecting.
|
6
11
|
|
7
12
|
## 0.8.5
|
data/LICENSE
CHANGED
data/Makefile
CHANGED
@@ -1,25 +1,19 @@
|
|
1
1
|
TAG ?= latest
|
2
2
|
IMAGE_NAME ?= arnau/iso8601
|
3
3
|
IMAGE = $(IMAGE_NAME):$(TAG)
|
4
|
-
ORPHAN_IMAGES = `docker images -f 'dangling=true'`
|
5
4
|
|
6
|
-
build
|
7
|
-
docker build -t $(IMAGE) .
|
8
|
-
|
9
|
-
rmo :
|
10
|
-
docker rmi $(ORPHAN_IMAGES)
|
5
|
+
install: build
|
11
6
|
|
12
|
-
|
13
|
-
docker
|
7
|
+
build:
|
8
|
+
docker build -t $(IMAGE) .
|
14
9
|
|
15
|
-
|
10
|
+
test:
|
16
11
|
docker run -t --rm -v $$(pwd):/usr/src/iso8601 $(IMAGE)
|
17
12
|
|
18
|
-
shell
|
13
|
+
shell:
|
19
14
|
docker run -it --rm -v $$(pwd):/usr/src/iso8601 $(IMAGE) \
|
20
15
|
pry -r ./lib/iso8601
|
21
16
|
|
22
|
-
gem
|
17
|
+
gem:
|
23
18
|
docker run -t --rm -v $$(pwd):/usr/src/iso8601 $(IMAGE) \
|
24
19
|
bundle exec rake build
|
25
|
-
|
data/README.md
CHANGED
@@ -97,6 +97,22 @@ Week dates raise an error when two digit days provied instead of return monday:
|
|
97
97
|
DateTime.new('2014-W15-02') # => #<Date: 2014-04-07 ((2456755j,0s,0n),+0s,2299161j)>
|
98
98
|
|
99
99
|
|
100
|
+
## Compatibility with core classes
|
101
|
+
|
102
|
+
Each ISO8601 class has a method `to_*` to convert to its core equivalent:
|
103
|
+
|
104
|
+
`ISO8601::DateTime#to_datetime` -> `DateTime` (it actually delegates a couple of
|
105
|
+
methods from `DateTime`). Check `lib/iso8601/date_time.rb:13`.
|
106
|
+
|
107
|
+
`ISO8601::Date#to_date` -> `Date` (it actually delegates to a couple of methods
|
108
|
+
from `Date`). Check `lib/iso8601/date.rb:18`
|
109
|
+
|
110
|
+
`ISO8601::Time#to_time` -> `Time` (it actually delegates to a couple of methods
|
111
|
+
from `Time`). Check `lib/iso8601/time.rb:15`
|
112
|
+
|
113
|
+
`ISO8601::Atom#to_f` -> `Float`, `ISO8601::Atom#to_i` -> `Integer`
|
114
|
+
|
115
|
+
|
100
116
|
## Testing
|
101
117
|
|
102
118
|
### Raw
|
@@ -105,23 +121,14 @@ Week dates raise an error when two digit days provied instead of return monday:
|
|
105
121
|
$ bundle install
|
106
122
|
$ bundle exec rspec
|
107
123
|
|
108
|
-
### Docker
|
124
|
+
### Docker
|
109
125
|
|
110
126
|
This way is in an early stage so for now it's only possible to test one Ruby
|
111
127
|
version (currently Ruby 2.2.)
|
112
128
|
|
113
129
|
# Install Docker
|
114
|
-
$ make
|
115
|
-
$ make
|
116
|
-
|
117
|
-
### Vagrant (experimental)
|
118
|
-
|
119
|
-
This way is in an early stage so for now it's only possible to test one Ruby
|
120
|
-
version (currently Ruby 2.2.)
|
121
|
-
|
122
|
-
# Install Vagrant and Virtualbox
|
123
|
-
$ vagrant up mri-2.2
|
124
|
-
|
130
|
+
$ make install
|
131
|
+
$ make test
|
125
132
|
|
126
133
|
## Contributing
|
127
134
|
|
data/lib/iso8601/atoms.rb
CHANGED
@@ -6,6 +6,7 @@ module ISO8601
|
|
6
6
|
#
|
7
7
|
# @abstract
|
8
8
|
class Atom
|
9
|
+
include Comparable
|
9
10
|
##
|
10
11
|
# @param [Numeric] atom The atom value
|
11
12
|
# @param [ISO8601::DateTime, nil] base (nil) The base datetime to compute
|
@@ -55,11 +56,13 @@ module ISO8601
|
|
55
56
|
atom * factor
|
56
57
|
end
|
57
58
|
##
|
58
|
-
# @param [
|
59
|
+
# @param [Atom] other The contrast to compare against
|
59
60
|
#
|
60
|
-
# @return [
|
61
|
-
def
|
62
|
-
|
61
|
+
# @return [-1, 0, 1]
|
62
|
+
def <=>(other)
|
63
|
+
return nil unless other.kind_of?(self.class)
|
64
|
+
|
65
|
+
to_f <=> other.to_f
|
63
66
|
end
|
64
67
|
##
|
65
68
|
# @param [#hash] other The contrast to compare against
|
data/lib/iso8601/version.rb
CHANGED
data/spec/iso8601/atoms_spec.rb
CHANGED
@@ -47,6 +47,23 @@ RSpec.describe ISO8601::Atom do
|
|
47
47
|
expect { ISO8601::Atom.new(1).factor }.to raise_error(NotImplementedError)
|
48
48
|
end
|
49
49
|
end
|
50
|
+
describe '#<=>' do
|
51
|
+
it "should be comparable to atoms of the same type" do
|
52
|
+
expect(ISO8601::Atom.new(1) <=> ISO8601::Atom.new(1)).to eq(0)
|
53
|
+
expect(ISO8601::Atom.new(1) <=> ISO8601::Atom.new(2)).to eq(-1)
|
54
|
+
expect(ISO8601::Atom.new(2) <=> ISO8601::Atom.new(1)).to eq(1)
|
55
|
+
expect(ISO8601::Years.new(2) > ISO8601::Years.new(1)).to be_truthy
|
56
|
+
end
|
57
|
+
it "should not be comparable to different types" do
|
58
|
+
expect(ISO8601::Years.new(1) <=> ISO8601::Months.new(1)).to be_nil
|
59
|
+
expect { ISO8601::Years.new(1) <= 1 }.to raise_error(ArgumentError)
|
60
|
+
expect { ISO8601::Years.new(2) > 1 }.to raise_error(ArgumentError)
|
61
|
+
end
|
62
|
+
it "should be ordered" do
|
63
|
+
expect(ISO8601::Atom.new(5) > ISO8601::Atom.new(4)).to be_truthy
|
64
|
+
expect(ISO8601::Atom.new(5) < ISO8601::Atom.new(4)).to be_falsy
|
65
|
+
end
|
66
|
+
end
|
50
67
|
end
|
51
68
|
|
52
69
|
describe ISO8601::Years do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: iso8601
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Arnau Siches
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-10-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -47,6 +47,7 @@ executables: []
|
|
47
47
|
extensions: []
|
48
48
|
extra_rdoc_files: []
|
49
49
|
files:
|
50
|
+
- ".dockerignore"
|
50
51
|
- ".editorconfig"
|
51
52
|
- ".gitignore"
|
52
53
|
- ".rubocop.yml"
|
@@ -58,7 +59,6 @@ files:
|
|
58
59
|
- Makefile
|
59
60
|
- README.md
|
60
61
|
- Rakefile
|
61
|
-
- Vagrantfile
|
62
62
|
- circle.yml
|
63
63
|
- iso8601.gemspec
|
64
64
|
- lib/iso8601.rb
|
data/Vagrantfile
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
# -*- mode: ruby -*-
|
2
|
-
# vi: set ft=ruby :
|
3
|
-
|
4
|
-
Vagrant.require_version '>= 1.6.0'
|
5
|
-
Vagrant.configure(2) do |config|
|
6
|
-
config.vm.define 'iso8601' do |c|
|
7
|
-
c.vm.box = "coreos-alpha"
|
8
|
-
c.vm.box_version = '>= 561.0.0'
|
9
|
-
c.vm.box_url = "http://alpha.release.core-os.net/amd64-usr/current/coreos_production_vagrant.json"
|
10
|
-
|
11
|
-
c.vm.network :private_network, ip: '10.10.1.100'
|
12
|
-
# Allows dynamic synced folders with docker as it seems Vagrant doesn't
|
13
|
-
# work well with coreOS (?)
|
14
|
-
c.vm.synced_folder '.', '/home/core/share', {
|
15
|
-
id: 'core',
|
16
|
-
nfs: true,
|
17
|
-
mount_options: ['nolock,vers=3,udp']
|
18
|
-
}
|
19
|
-
|
20
|
-
c.vm.provider :virtualbox do |vb|
|
21
|
-
vb.check_guest_additions = false
|
22
|
-
vb.functional_vboxsf = false
|
23
|
-
vb.memory = 1024
|
24
|
-
vb.cpus = 1
|
25
|
-
vb.customize ["modifyvm", :id, "--uart1", "0x3F8", "4"]
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
config.vm.define 'mri-2.2' do |c|
|
30
|
-
c.vm.provider 'docker' do |d|
|
31
|
-
d.vagrant_machine = 'iso8601'
|
32
|
-
d.vagrant_vagrantfile = './Vagrantfile'
|
33
|
-
d.build_dir = '.'
|
34
|
-
d.build_args = ['-t', 'arnau/iso8601:2.2']
|
35
|
-
d.create_args = [
|
36
|
-
'-v', '/home/core/share:/usr/src/iso8601',
|
37
|
-
]
|
38
|
-
d.remains_running = false
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|