ice_t 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.coveralls.yaml +1 -0
- data/Gemfile +4 -0
- data/README.md +14 -23
- data/lib/ice_t/rule/base.rb +3 -0
- data/lib/ice_t/version.rb +1 -1
- data/lib/locales/de.yml +23 -0
- data/lib/locales/en.yml +21 -1
- data/spec/rules/daily_rule_spec.rb +16 -1
- data/spec/rules/hourly_rule_spec.rb +16 -0
- data/spec/rules/minutely_rule_spec.rb +16 -0
- data/spec/rules/monthly_rule_spec.rb +16 -0
- data/spec/rules/secondly_rule_spec.rb +16 -0
- data/spec/rules/weekly_rule_spec.rb +16 -0
- data/spec/rules/yearly_rule_spec.rb +16 -0
- data/spec/spec_helper.rb +3 -3
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b13f0fe91bed8959c30d2dc2d7efa25ce008d786
|
4
|
+
data.tar.gz: e01f4d86a9a77f8c69490419a22333dcd434f81d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a9d5ca8528f1b860948f4e324d59334de0636c7e5ac4aed893113926939f747630673d01a96355e54073ea9c97771278ec5ac0272a9fca3631571878d2f7254
|
7
|
+
data.tar.gz: 8bd0331ae1c83baee2ecbab4deec042132eda737b4de778d03aa6f66c004634f0d328552a0ba890c00effb7f726cc8bb5a73de9ef8ede252117293e6cb5755df
|
data/.coveralls.yaml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
service_name: travis-ci
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -4,6 +4,7 @@
|
|
4
4
|
[![Code Climate](https://codeclimate.com/github/XORwell/ice_t.png)](https://codeclimate.com/github/XORwell/ice_t)
|
5
5
|
[![Build Status](https://travis-ci.org/XORwell/ice_t.png)](https://travis-ci.org/XORwell/ice_t)
|
6
6
|
[![Dependency Status](https://gemnasium.com/XORwell/ice_t.png)](https://gemnasium.com/XORwell/ice_t)
|
7
|
+
[![Coverage Status](https://coveralls.io/repos/XORwell/ice_t/badge.png)](https://coveralls.io/r/XORwell/ice_t)
|
7
8
|
|
8
9
|
IceT is a ruby library for handling repeated events.
|
9
10
|
|
@@ -39,32 +40,31 @@ rule = IceT::Rule::Yearly.new(42) # => every 42 years
|
|
39
40
|
rule = IceT::Rule::Secondly.new # => every second
|
40
41
|
```
|
41
42
|
|
42
|
-
|
43
|
-
### Get time occurrences
|
43
|
+
### Rule in words (i18n)
|
44
44
|
|
45
45
|
```ruby
|
46
|
-
|
47
|
-
|
48
|
-
|
46
|
+
# I18n.locale = :en
|
47
|
+
rule = IceT::Rule::Daily.new(14)
|
48
|
+
rule.to_s # => "every 14 days"
|
49
49
|
|
50
|
+
# I18n.locale = :de
|
51
|
+
rule = IceT::Rule::Daily.new(14)
|
52
|
+
rule.to_s # => "alle 14 Tage"
|
50
53
|
```
|
51
54
|
|
52
|
-
### Schedule
|
53
55
|
|
54
|
-
|
56
|
+
### Get time occurrences
|
55
57
|
|
56
58
|
```ruby
|
57
|
-
|
58
|
-
|
59
|
-
|
59
|
+
rule.occurrences(2.days.ago, Time.now) # => Array of times
|
60
|
+
|
61
|
+
IceT::Rule::Daily.new(14).occurrences(1.year.ago, Time.now).first(5)
|
60
62
|
|
61
|
-
schedule.rules # => Array of rules
|
62
|
-
schedule.occurrences # => Merged occurrences
|
63
63
|
```
|
64
64
|
|
65
65
|
### Persistence
|
66
66
|
|
67
|
-
Store and restore
|
67
|
+
Store and restore the rule:
|
68
68
|
|
69
69
|
```ruby
|
70
70
|
|
@@ -86,16 +86,7 @@ restored = IceT::Rule::Base.from_hash(hash)
|
|
86
86
|
```
|
87
87
|
|
88
88
|
|
89
|
-
|
90
|
-
Store and restore your Schedule:
|
91
|
-
|
92
|
-
```ruby
|
93
|
-
json = schedule.to_json
|
94
|
-
schedule = IceT::Schedule.from_json(json)
|
95
|
-
```
|
96
|
-
|
97
|
-
|
98
|
-
### Comparisons and sorting
|
89
|
+
### Comparison and sorting
|
99
90
|
|
100
91
|
```ruby
|
101
92
|
IceT::Rule::Daily.new(1) < IceT::Rule::Monthly.new(1) # => true
|
data/lib/ice_t/rule/base.rb
CHANGED
data/lib/ice_t/version.rb
CHANGED
data/lib/locales/de.yml
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
de:
|
2
|
+
ice_t:
|
3
|
+
each_second:
|
4
|
+
one: sekündlich
|
5
|
+
other: alle %{count} Sekunden
|
6
|
+
each_minute:
|
7
|
+
one: minütlich
|
8
|
+
other: alle %{count} Minuten
|
9
|
+
each_hour:
|
10
|
+
one: stündlich
|
11
|
+
other: alle %{count} Stunden
|
12
|
+
each_day:
|
13
|
+
one: täglich
|
14
|
+
other: alle %{count} Tage
|
15
|
+
each_week:
|
16
|
+
one: wöchentlich
|
17
|
+
other: alle %{count} Wochen
|
18
|
+
each_month:
|
19
|
+
one: monatlich
|
20
|
+
other: alle %{count} Monate
|
21
|
+
each_year:
|
22
|
+
one: jährlich
|
23
|
+
other: alle %{count} Jahre
|
data/lib/locales/en.yml
CHANGED
@@ -1,3 +1,23 @@
|
|
1
1
|
en:
|
2
2
|
ice_t:
|
3
|
-
|
3
|
+
each_second:
|
4
|
+
one: secondly
|
5
|
+
other: every %{count} seconds
|
6
|
+
each_minute:
|
7
|
+
one: minutely
|
8
|
+
other: every %{count} minutes
|
9
|
+
each_hour:
|
10
|
+
one: hourly
|
11
|
+
other: every %{count} hours
|
12
|
+
each_day:
|
13
|
+
one: daily
|
14
|
+
other: every %{count} days
|
15
|
+
each_week:
|
16
|
+
one: weekly
|
17
|
+
other: every %{count} weeks
|
18
|
+
each_month:
|
19
|
+
one: monthly
|
20
|
+
other: every %{count} months
|
21
|
+
each_year:
|
22
|
+
one: yearly
|
23
|
+
other: every %{count} years
|
@@ -3,4 +3,19 @@ require 'spec_helper'
|
|
3
3
|
describe IceT::Rule::Daily do
|
4
4
|
let(:klass) { IceT::Rule::Daily }
|
5
5
|
it_behaves_like "a rule"
|
6
|
-
|
6
|
+
|
7
|
+
describe 'i18n' do
|
8
|
+
let(:rule_01) { IceT::Rule::Daily.new(1) }
|
9
|
+
let(:rule_03) { IceT::Rule::Daily.new(3) }
|
10
|
+
context 'english' do
|
11
|
+
before { I18n.locale = :en }
|
12
|
+
it { expect(rule_01.to_s).to eql('daily') }
|
13
|
+
it { expect(rule_03.to_s).to eql('every 3 days') }
|
14
|
+
end
|
15
|
+
context 'german' do
|
16
|
+
before { I18n.locale = :de }
|
17
|
+
it { expect(rule_01.to_s).to eql('täglich') }
|
18
|
+
it { expect(rule_03.to_s).to eql('alle 3 Tage') }
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -3,4 +3,20 @@ require 'spec_helper'
|
|
3
3
|
describe IceT::Rule::Hourly do
|
4
4
|
let(:klass) { IceT::Rule::Hourly }
|
5
5
|
it_behaves_like "a rule"
|
6
|
+
|
7
|
+
describe 'i18n' do
|
8
|
+
let(:rule_01) { IceT::Rule::Hourly.new(1) }
|
9
|
+
let(:rule_03) { IceT::Rule::Hourly.new(3) }
|
10
|
+
context 'english' do
|
11
|
+
before { I18n.locale = :en }
|
12
|
+
it { expect(rule_01.to_s).to eql('hourly') }
|
13
|
+
it { expect(rule_03.to_s).to eql('every 3 hours') }
|
14
|
+
end
|
15
|
+
context 'german' do
|
16
|
+
before { I18n.locale = :de }
|
17
|
+
it { expect(rule_01.to_s).to eql('stündlich') }
|
18
|
+
it { expect(rule_03.to_s).to eql('alle 3 Stunden') }
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
6
22
|
end
|
@@ -3,4 +3,20 @@ require 'spec_helper'
|
|
3
3
|
describe IceT::Rule::Minutely do
|
4
4
|
let(:klass) { IceT::Rule::Minutely }
|
5
5
|
it_behaves_like "a rule"
|
6
|
+
|
7
|
+
describe 'i18n' do
|
8
|
+
let(:rule_01) { IceT::Rule::Minutely.new(1) }
|
9
|
+
let(:rule_03) { IceT::Rule::Minutely.new(3) }
|
10
|
+
context 'english' do
|
11
|
+
before { I18n.locale = :en }
|
12
|
+
it { expect(rule_01.to_s).to eql('minutely') }
|
13
|
+
it { expect(rule_03.to_s).to eql('every 3 minutes') }
|
14
|
+
end
|
15
|
+
context 'german' do
|
16
|
+
before { I18n.locale = :de }
|
17
|
+
it { expect(rule_01.to_s).to eql('minütlich') }
|
18
|
+
it { expect(rule_03.to_s).to eql('alle 3 Minuten') }
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
6
22
|
end
|
@@ -3,4 +3,20 @@ require 'spec_helper'
|
|
3
3
|
describe IceT::Rule::Monthly do
|
4
4
|
let(:klass) { IceT::Rule::Monthly }
|
5
5
|
it_behaves_like "a rule"
|
6
|
+
|
7
|
+
describe 'i18n' do
|
8
|
+
let(:rule_01) { IceT::Rule::Monthly.new(1) }
|
9
|
+
let(:rule_03) { IceT::Rule::Monthly.new(3) }
|
10
|
+
context 'english' do
|
11
|
+
before { I18n.locale = :en }
|
12
|
+
it { expect(rule_01.to_s).to eql('monthly') }
|
13
|
+
it { expect(rule_03.to_s).to eql('every 3 months') }
|
14
|
+
end
|
15
|
+
context 'german' do
|
16
|
+
before { I18n.locale = :de }
|
17
|
+
it { expect(rule_01.to_s).to eql('monatlich') }
|
18
|
+
it { expect(rule_03.to_s).to eql('alle 3 Monate') }
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
6
22
|
end
|
@@ -3,4 +3,20 @@ require 'spec_helper'
|
|
3
3
|
describe IceT::Rule::Secondly do
|
4
4
|
let(:klass) { IceT::Rule::Secondly }
|
5
5
|
it_behaves_like "a rule"
|
6
|
+
|
7
|
+
describe 'i18n' do
|
8
|
+
let(:rule_01) { IceT::Rule::Secondly.new(1) }
|
9
|
+
let(:rule_03) { IceT::Rule::Secondly.new(3) }
|
10
|
+
context 'english' do
|
11
|
+
before { I18n.locale = :en }
|
12
|
+
it { expect(rule_01.to_s).to eql('secondly') }
|
13
|
+
it { expect(rule_03.to_s).to eql('every 3 seconds') }
|
14
|
+
end
|
15
|
+
context 'german' do
|
16
|
+
before { I18n.locale = :de }
|
17
|
+
it { expect(rule_01.to_s).to eql('sekündlich') }
|
18
|
+
it { expect(rule_03.to_s).to eql('alle 3 Sekunden') }
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
6
22
|
end
|
@@ -3,4 +3,20 @@ require 'spec_helper'
|
|
3
3
|
describe IceT::Rule::Weekly do
|
4
4
|
let(:klass) { IceT::Rule::Weekly }
|
5
5
|
it_behaves_like "a rule"
|
6
|
+
|
7
|
+
describe 'i18n' do
|
8
|
+
let(:rule_01) { IceT::Rule::Weekly.new(1) }
|
9
|
+
let(:rule_03) { IceT::Rule::Weekly.new(3) }
|
10
|
+
context 'english' do
|
11
|
+
before { I18n.locale = :en }
|
12
|
+
it { expect(rule_01.to_s).to eql('weekly') }
|
13
|
+
it { expect(rule_03.to_s).to eql('every 3 weeks') }
|
14
|
+
end
|
15
|
+
context 'german' do
|
16
|
+
before { I18n.locale = :de }
|
17
|
+
it { expect(rule_01.to_s).to eql('wöchentlich') }
|
18
|
+
it { expect(rule_03.to_s).to eql('alle 3 Wochen') }
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
6
22
|
end
|
@@ -3,4 +3,20 @@ require 'spec_helper'
|
|
3
3
|
describe IceT::Rule::Yearly do
|
4
4
|
let(:klass) { IceT::Rule::Yearly }
|
5
5
|
it_behaves_like "a rule"
|
6
|
+
|
7
|
+
describe 'i18n' do
|
8
|
+
let(:rule_01) { IceT::Rule::Yearly.new(1) }
|
9
|
+
let(:rule_03) { IceT::Rule::Yearly.new(3) }
|
10
|
+
context 'english' do
|
11
|
+
before { I18n.locale = :en }
|
12
|
+
it { expect(rule_01.to_s).to eql('yearly') }
|
13
|
+
it { expect(rule_03.to_s).to eql('every 3 years') }
|
14
|
+
end
|
15
|
+
context 'german' do
|
16
|
+
before { I18n.locale = :de }
|
17
|
+
it { expect(rule_01.to_s).to eql('jährlich') }
|
18
|
+
it { expect(rule_03.to_s).to eql('alle 3 Jahre') }
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
6
22
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'bundler/setup'
|
3
|
-
|
4
|
-
|
3
|
+
require 'coveralls'
|
5
4
|
require 'ice_t'
|
6
5
|
|
7
|
-
|
6
|
+
Coveralls.wear!
|
8
7
|
|
8
|
+
Dir.glob(File.expand_path("spec/support/**/*.rb")).each{ |f| require f }
|
9
9
|
|
10
10
|
RSpec.configure do |config|
|
11
11
|
config.color_enabled = true
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ice_t
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christian Nennemann
|
@@ -73,6 +73,7 @@ executables: []
|
|
73
73
|
extensions: []
|
74
74
|
extra_rdoc_files: []
|
75
75
|
files:
|
76
|
+
- .coveralls.yaml
|
76
77
|
- .gitignore
|
77
78
|
- .travis.yml
|
78
79
|
- CHANGELOG.md
|
@@ -99,6 +100,7 @@ files:
|
|
99
100
|
- lib/ice_t/schedule.rb
|
100
101
|
- lib/ice_t/time_helper.rb
|
101
102
|
- lib/ice_t/version.rb
|
103
|
+
- lib/locales/de.yml
|
102
104
|
- lib/locales/en.yml
|
103
105
|
- spec/exceptions_spec.rb
|
104
106
|
- spec/rules/base_spec.rb
|