ice_t 0.0.6 → 0.0.7

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
  SHA1:
3
- metadata.gz: cdf3d09149e3ebfc1e740bc9523814fdfbeadca4
4
- data.tar.gz: 9f1e4c68ce2ed1f6c7b8aa33b22dba3221957e65
3
+ metadata.gz: 481cf81486c0337d36e8d288362cf9f1bcc014af
4
+ data.tar.gz: 714bd7d33b6395a021b5c82ef9899d1bf1d38ff7
5
5
  SHA512:
6
- metadata.gz: 84cf215a1807c44ac151a6bfcdc4d11be647c7256140557e1093ffcf7e671f739fb305adfb1b5c88dce3700ae478d3c61ef0211adff1aa88e542b22097897da3
7
- data.tar.gz: 082bf83e1f43e1d5fea4b9c374d9b3b6f98c3f9b05e7734f1a0c1b5daa5478c110ba2e67ccc36eb31f539b3b45e711b9da8168babc50749fcc1ef21420046d15
6
+ metadata.gz: b1ac6a8250be365dc49f9f1c56de9c6e0031890e2a985fb7f7aa621958ac8a3eb99f23ad2743f3ab844f9435f412d1a25f4eec8897415cf32e7b2c8a263a4172
7
+ data.tar.gz: 1678686562bbd8cf649bd3ac6f94c3b36da118336eef50ac8e04297ddfd4c0d34b8f0af919122d6e4ab53e9d25fffc8bb9e47b449ebc0f16c823cd7f6c222015
data/README.md CHANGED
@@ -80,8 +80,10 @@ schedule = IceT::Schedule.from_json(json)
80
80
  IceT::Rule::Daily.new(1) < IceT::Rule::Monthly.new(1) # => true
81
81
  ```
82
82
 
83
+ ```ruby
83
84
  r2.between?(r1, r3)
84
-
85
+ ```
86
+ IceT::Rule::Daily.new(14).occurrences(1.year.ago, Time.now).first(5)
85
87
 
86
88
 
87
89
  ## License
@@ -1,5 +1,22 @@
1
1
  module IceT
2
2
  module Conversions
3
+ module Rule
4
+
5
+ def self.included(klass)
6
+ klass.extend ClassMethods
7
+ end
8
+
9
+ def to_hash
10
+ self.instance_values.symbolize_keys
11
+ end
12
+
13
+ module ClassMethods
14
+ def from_yaml(yaml_string)
15
+ rule = YAML::load(yaml_string)
16
+ end
17
+ end
18
+ end
19
+
3
20
  module Schedule
4
21
  def from_json(json_string)
5
22
  data = ActiveSupport::JSON.decode(json_string).symbolize_keys
@@ -11,7 +28,7 @@ module IceT
11
28
  schedule = self.new(options)
12
29
 
13
30
  data[:rules]["rules"].each{ |rule|
14
- rule_class = rule['export_class_name']
31
+ rule_class = rule['rule']
15
32
  interval = rule['interval'].to_i
16
33
  at = rule['at']
17
34
  init = if at.nil?
@@ -9,6 +9,8 @@ module IceT
9
9
  end
10
10
  end
11
11
 
12
+ include IceT::Conversions::Rule
13
+
12
14
  attr_reader :interval
13
15
  attr_reader :at
14
16
 
@@ -18,7 +20,7 @@ module IceT
18
20
  interval % 1 != 0
19
21
  @interval = interval
20
22
  @at = at_str
21
- @export_class_name = self.class.name
23
+ @rule = self.class.name
22
24
  self.at = at_str unless @at.nil?
23
25
  end
24
26
 
data/lib/ice_t/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module IceT
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
@@ -101,4 +101,10 @@ describe IceT::Rule::Base do
101
101
  }
102
102
  end
103
103
 
104
+ describe '.from_yaml' do
105
+ let(:rule) { IceT::Rule::Daily.new(42) }
106
+ let(:yaml) { rule.to_yaml }
107
+ it { expect(IceT::Rule::Daily.from_yaml(yaml) == rule ).to be_true }
108
+ end
109
+
104
110
  end
@@ -42,6 +42,10 @@ shared_examples 'a rule' do
42
42
  it { expect(klass.new).to respond_to(:to_yaml) }
43
43
  end
44
44
 
45
+ describe '#to_hash' do
46
+ it { expect(klass.new).to respond_to(:to_hash) }
47
+ end
48
+
45
49
  describe '#@at' do
46
50
  it {expect(klass.new(1, "4pm").at).to eql("4pm")}
47
51
  end
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.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Nennemann