ice_t 0.0.8 → 0.0.9

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: 7c009725229f52d779eb425bacef4333fcb74025
4
- data.tar.gz: 8f8fc915b744889a3bc4aec06bc06832f7f7490f
3
+ metadata.gz: b13f0fe91bed8959c30d2dc2d7efa25ce008d786
4
+ data.tar.gz: e01f4d86a9a77f8c69490419a22333dcd434f81d
5
5
  SHA512:
6
- metadata.gz: af9172f70fa10c41705a4fcca1039d3452f49449310818fc35e99378cfeafe0e518658a702c2b0cb0e35a5cbc69e00c8d5c2afd91410eb76d9e981b040c6d59c
7
- data.tar.gz: e0c3689e2d634f63ee95e9bd20427722401baffd1fdfbca5713307ae4d754e99f736b3772e4efe99002de6bb63b1fd48b2d9634bdc04b225a7fa63bad55eb01f
6
+ metadata.gz: 2a9d5ca8528f1b860948f4e324d59334de0636c7e5ac4aed893113926939f747630673d01a96355e54073ea9c97771278ec5ac0272a9fca3631571878d2f7254
7
+ data.tar.gz: 8bd0331ae1c83baee2ecbab4deec042132eda737b4de778d03aa6f66c004634f0d328552a0ba890c00effb7f726cc8bb5a73de9ef8ede252117293e6cb5755df
data/.coveralls.yaml ADDED
@@ -0,0 +1 @@
1
+ service_name: travis-ci
data/Gemfile CHANGED
@@ -2,3 +2,7 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in ice_t.gemspec
4
4
  gemspec
5
+
6
+ group :development do
7
+ gem 'coveralls', require: false
8
+ end
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
- rule.occurrences(2.days.ago, Time.now) # => Array of times
47
-
48
- IceT::Rule::Daily.new(14).occurrences(1.year.ago, Time.now).first(5)
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
- The Schedule helps on dealing with multiple rules.
56
+ ### Get time occurrences
55
57
 
56
58
  ```ruby
57
- schedule = IceT::Schedule.new(start_time: Time.now, end_time: Time.now + 4.months)
58
- schedule.add_rule my_daily_rule
59
- schedule.add_rule my_monthly_rule
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 your rule:
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
@@ -73,6 +73,9 @@ module IceT
73
73
  }
74
74
  end
75
75
 
76
+ def to_s
77
+ I18n.t "ice_t.each_#{self.class.unit[0..-2]}", count: self.interval
78
+ end
76
79
  end
77
80
  end
78
81
  end
data/lib/ice_t/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module IceT
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.9"
3
3
  end
@@ -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
- hello: world
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
- end
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
- # require 'active_support/all'
4
-
3
+ require 'coveralls'
5
4
  require 'ice_t'
6
5
 
7
- Dir.glob(File.expand_path("spec/support/**/*.rb")).each{ |f| require f }
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.8
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