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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b13f0fe91bed8959c30d2dc2d7efa25ce008d786
4
- data.tar.gz: e01f4d86a9a77f8c69490419a22333dcd434f81d
3
+ metadata.gz: d8e5c60f76bdb1ad7b2049048d09dee5340877f0
4
+ data.tar.gz: 4be987e668b83e626613a8c0645847df609da866
5
5
  SHA512:
6
- metadata.gz: 2a9d5ca8528f1b860948f4e324d59334de0636c7e5ac4aed893113926939f747630673d01a96355e54073ea9c97771278ec5ac0272a9fca3631571878d2f7254
7
- data.tar.gz: 8bd0331ae1c83baee2ecbab4deec042132eda737b4de778d03aa6f66c004634f0d328552a0ba890c00effb7f726cc8bb5a73de9ef8ede252117293e6cb5755df
6
+ metadata.gz: 3b5de3773639ff1a9447b4ad554dd5c5c0ff5f8fae125f3ea52abbe55a931e74bceb26426ad3bfe199fa1f2b7aa9439756247cd370b3f9c98a97d6d40f6d497f
7
+ data.tar.gz: 24b97f276216e3d69c7b8b0eb4b1ca6c868f541cc48ecc63f0eaf210df86e2db2ff31047deabe15815aa8fcf87cb83af0104039a9c557adafe8676270901be0e
@@ -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
@@ -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
@@ -1,3 +1,3 @@
1
1
  module IceT
2
- VERSION = "0.0.9"
2
+ VERSION = "0.0.10"
3
3
  end
data/lib/ice_t.rb CHANGED
@@ -13,7 +13,6 @@ module IceT
13
13
 
14
14
  require 'ice_t/conversions'
15
15
  require 'ice_t/rule'
16
- require 'ice_t/schedule'
17
16
 
18
17
  # module Rule
19
18
  # autoload :Repository, 'ice_t/rule/repository'
data/spec/spec_helper.rb CHANGED
@@ -1,9 +1,9 @@
1
1
  require 'rubygems'
2
2
  require 'bundler/setup'
3
3
  require 'coveralls'
4
+ Coveralls.wear!
4
5
  require 'ice_t'
5
6
 
6
- Coveralls.wear!
7
7
 
8
8
  Dir.glob(File.expand_path("spec/support/**/*.rb")).each{ |f| require f }
9
9
 
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.9
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
@@ -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
@@ -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