ice_t 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ice_t/conversions.rb +0 -32
- data/lib/ice_t/rule/base.rb +2 -1
- data/lib/ice_t/version.rb +1 -1
- data/lib/ice_t.rb +0 -1
- data/spec/spec_helper.rb +1 -1
- metadata +1 -4
- data/lib/ice_t/schedule.rb +0 -62
- data/spec/schedule_spec.rb +0 -84
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d8e5c60f76bdb1ad7b2049048d09dee5340877f0
|
4
|
+
data.tar.gz: 4be987e668b83e626613a8c0645847df609da866
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3b5de3773639ff1a9447b4ad554dd5c5c0ff5f8fae125f3ea52abbe55a931e74bceb26426ad3bfe199fa1f2b7aa9439756247cd370b3f9c98a97d6d40f6d497f
|
7
|
+
data.tar.gz: 24b97f276216e3d69c7b8b0eb4b1ca6c868f541cc48ecc63f0eaf210df86e2db2ff31047deabe15815aa8fcf87cb83af0104039a9c557adafe8676270901be0e
|
data/lib/ice_t/conversions.rb
CHANGED
@@ -23,12 +23,6 @@
|
|
23
23
|
|
24
24
|
module IceT
|
25
25
|
module Conversions
|
26
|
-
# module Helper
|
27
|
-
# module_function
|
28
|
-
# def recursive_instance_values(object)
|
29
|
-
# end
|
30
|
-
# end
|
31
|
-
|
32
26
|
module Common
|
33
27
|
module InstanceMethods
|
34
28
|
end
|
@@ -64,31 +58,5 @@ module IceT
|
|
64
58
|
end
|
65
59
|
end
|
66
60
|
end
|
67
|
-
|
68
|
-
module Schedule
|
69
|
-
|
70
|
-
def self.included(klass)
|
71
|
-
klass.extend ClassMethods
|
72
|
-
end
|
73
|
-
|
74
|
-
module ClassMethods
|
75
|
-
def from_yaml(yaml_string)
|
76
|
-
YAML::load(yaml_string)
|
77
|
-
end
|
78
|
-
|
79
|
-
def from_json(json_string)
|
80
|
-
return unless json_string
|
81
|
-
data = ActiveSupport::JSON.decode(json_string).symbolize_keys
|
82
|
-
schedule = self.new(start_time: data[:start_time].to_time, end_time: data[:end_time].to_time)
|
83
|
-
data[:rules]["rules"].each{ |rule|
|
84
|
-
schedule.add_rule(
|
85
|
-
IceT::Rule::Base.from_json(rule.to_json)
|
86
|
-
)
|
87
|
-
}
|
88
|
-
schedule
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
61
|
end
|
94
62
|
end
|
data/lib/ice_t/rule/base.rb
CHANGED
@@ -46,7 +46,6 @@ module IceT
|
|
46
46
|
|
47
47
|
include Comparable
|
48
48
|
def <=>(other)
|
49
|
-
return unless other.class.respond_to?(:to_i)
|
50
49
|
if self.class == other.class
|
51
50
|
case
|
52
51
|
when self.interval == other.interval
|
@@ -64,6 +63,8 @@ module IceT
|
|
64
63
|
+1
|
65
64
|
end
|
66
65
|
end
|
66
|
+
rescue
|
67
|
+
nil
|
67
68
|
end
|
68
69
|
|
69
70
|
def occurrences(start_time, end_time)
|
data/lib/ice_t/version.rb
CHANGED
data/lib/ice_t.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
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.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christian Nennemann
|
@@ -97,7 +97,6 @@ files:
|
|
97
97
|
- lib/ice_t/rule/secondly.rb
|
98
98
|
- lib/ice_t/rule/weekly.rb
|
99
99
|
- lib/ice_t/rule/yearly.rb
|
100
|
-
- lib/ice_t/schedule.rb
|
101
100
|
- lib/ice_t/time_helper.rb
|
102
101
|
- lib/ice_t/version.rb
|
103
102
|
- lib/locales/de.yml
|
@@ -112,7 +111,6 @@ files:
|
|
112
111
|
- spec/rules/secondly_rule_spec.rb
|
113
112
|
- spec/rules/weekly_rule_spec.rb
|
114
113
|
- spec/rules/yearly_rule_spec.rb
|
115
|
-
- spec/schedule_spec.rb
|
116
114
|
- spec/spec_helper.rb
|
117
115
|
- spec/support/shared_examples/rule_example.rb
|
118
116
|
homepage: https://github.com/XORwell/ice_t
|
@@ -150,6 +148,5 @@ test_files:
|
|
150
148
|
- spec/rules/secondly_rule_spec.rb
|
151
149
|
- spec/rules/weekly_rule_spec.rb
|
152
150
|
- spec/rules/yearly_rule_spec.rb
|
153
|
-
- spec/schedule_spec.rb
|
154
151
|
- spec/spec_helper.rb
|
155
152
|
- spec/support/shared_examples/rule_example.rb
|
data/lib/ice_t/schedule.rb
DELETED
@@ -1,62 +0,0 @@
|
|
1
|
-
#--
|
2
|
-
# Copyright (c) 2013 Christian Nennemann
|
3
|
-
#
|
4
|
-
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
-
# a copy of this software and associated documentation files (the
|
6
|
-
# "Software"), to deal in the Software without restriction, including
|
7
|
-
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
-
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
-
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
-
# the following conditions:
|
11
|
-
#
|
12
|
-
# The above copyright notice and this permission notice shall be
|
13
|
-
# included in all copies or substantial portions of the Software.
|
14
|
-
#
|
15
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
-
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
-
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
-
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
-
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
-
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
-
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
-
#++
|
23
|
-
|
24
|
-
require 'forwardable'
|
25
|
-
|
26
|
-
module IceT
|
27
|
-
class Schedule
|
28
|
-
|
29
|
-
extend Forwardable
|
30
|
-
def_delegator :@rules, :add, :add_rule
|
31
|
-
def_delegator :@rules, :remove, :remove_rule
|
32
|
-
def_delegator :@rules, :rules, :rules
|
33
|
-
|
34
|
-
include IceT::Conversions::Schedule
|
35
|
-
|
36
|
-
attr_reader :start_time
|
37
|
-
attr_reader :end_time
|
38
|
-
|
39
|
-
def initialize(opts={})
|
40
|
-
opts = {
|
41
|
-
start_time: nil,
|
42
|
-
end_time: nil
|
43
|
-
}.merge(opts)
|
44
|
-
@start_time = opts[:start_time]
|
45
|
-
@end_time = opts[:end_time]
|
46
|
-
|
47
|
-
@rules = IceT::Rule::Repository.new
|
48
|
-
end
|
49
|
-
|
50
|
-
def occurrences
|
51
|
-
return [] if @rules.empty?
|
52
|
-
|
53
|
-
# TODO: better error message
|
54
|
-
fail('this needs start_time and end_time') if @start_time.nil? && @end_time.nil?
|
55
|
-
|
56
|
-
@rules.collect{ |rule|
|
57
|
-
rule.occurrences(@start_time, @end_time)
|
58
|
-
}.flatten
|
59
|
-
end
|
60
|
-
|
61
|
-
end
|
62
|
-
end
|
data/spec/schedule_spec.rb
DELETED
@@ -1,84 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe IceT::Schedule do
|
4
|
-
let!(:klass) { IceT::Schedule }
|
5
|
-
let!(:start_time) { Time.now }
|
6
|
-
let!(:end_time) { Time.now + 2.months }
|
7
|
-
let!(:schedule) { IceT::Schedule.new(start_time: start_time, end_time: end_time) }
|
8
|
-
let!(:daily_rule) { IceT::Rule::Daily.new(1) }
|
9
|
-
let!(:monthly_rule) { IceT::Rule::Monthly.new(1) }
|
10
|
-
let(:repo) { schedule.instance_variable_get(:@rules) }
|
11
|
-
|
12
|
-
describe '#add_rule' do
|
13
|
-
it "delegates to repository.add" do
|
14
|
-
expect(repo).to receive(:add).with(daily_rule)
|
15
|
-
schedule.add_rule(daily_rule)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
describe '#remove_rule' do
|
20
|
-
it "delegates to repository.remove" do
|
21
|
-
expect(repo).to receive(:remove).with(daily_rule)
|
22
|
-
schedule.remove_rule(daily_rule)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
describe '#rules' do
|
27
|
-
it "delegates to repository.rules" do
|
28
|
-
expect(repo).to receive(:rules)
|
29
|
-
schedule.rules
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
describe '#to_json' do
|
34
|
-
it { expect(subject).to respond_to(:to_json) }
|
35
|
-
it { expect(subject.to_json).to be_an(String) }
|
36
|
-
end
|
37
|
-
|
38
|
-
describe '#to_yaml' do
|
39
|
-
it { expect(subject).to respond_to(:to_yaml) }
|
40
|
-
it { expect(subject.to_json).to be_an(String) }
|
41
|
-
end
|
42
|
-
|
43
|
-
describe '::from_json' do
|
44
|
-
context "the created object" do
|
45
|
-
before do
|
46
|
-
schedule.add_rule(daily_rule)
|
47
|
-
schedule.add_rule(monthly_rule)
|
48
|
-
end
|
49
|
-
let(:json) { schedule.to_json }
|
50
|
-
let(:object) { IceT::Schedule.from_json(json) }
|
51
|
-
|
52
|
-
it "is a Schedule" do
|
53
|
-
expect(object).to be_an(IceT::Schedule)
|
54
|
-
end
|
55
|
-
it "contains the same rules as before" do
|
56
|
-
expect(object.rules.map(&:to_json)).to eql(schedule.rules.map(&:to_json))
|
57
|
-
end
|
58
|
-
|
59
|
-
[:start_time, :end_time].each { |time|
|
60
|
-
it "does have the same #{time} as before" do
|
61
|
-
expect(object.send(time).to_i).to eql(eval("#{time}").to_i)
|
62
|
-
end
|
63
|
-
}
|
64
|
-
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
describe '#to_hash' do
|
69
|
-
it "does respond_to :to_hash" do
|
70
|
-
pending "Conversions::Helper.recursive_instance_values"
|
71
|
-
expect(subject).to respond_to(:to_hash)
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
describe '::from_yaml' do
|
76
|
-
it { expect(subject).to respond_to(:to_yaml) }
|
77
|
-
it "does contain same values as before" do
|
78
|
-
pending "serialize Rule::Repository" do
|
79
|
-
expect(IceT::Schedule.from_yaml(schedule.to_yaml) == schedule).to be_true
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
end
|