date_discreter 0.0.2 → 0.0.3.beta1

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: f535be8df5bbbf5faea7894c3b2eea4f1050a39a
4
- data.tar.gz: 365e388a011e14bc50f2c35dfad8f3f19f3cbb72
3
+ metadata.gz: 08b1e9e401eb5048c61c147ba71e213589042b09
4
+ data.tar.gz: 809198432ff914a2a907292af9ebb62ece49ab7d
5
5
  SHA512:
6
- metadata.gz: 6e7eaf9c54bab9a6293edbe01e97fcd6b1f5de6e98032045a249df4ada3a259168b2016e3f2366448ce8cc08a599ae13b4ce3e3adadfb1cf0528637e3433c3d0
7
- data.tar.gz: 74866613c34da2ebf406d0da7b474c036fab991d594ac9b569bc7a651dd81b682aa1bbeaa098183c7cd2132016fb2ce2ac26ed9c350270e991c08ad24cc5baff
6
+ metadata.gz: 83f00776f0cab14f5cc9da0b8aba1086088b5225a6fa12cbc9b509c94d8add9b3fc2e5d0915ee0f60d95120aeb10f5f8aeb3942a052b506ca336012aaff483c4
7
+ data.tar.gz: a660a7331487a2c70122b12a1cda8102050a078514aabf1654a758675651789f88d7591d0fcb8161d675ad41d51156b14dee71978ce675983673d15286429247
@@ -26,7 +26,8 @@ module DateDiscreter
26
26
  end
27
27
 
28
28
  def discrete_times(target_times, degree)
29
- raise ArgumentError, "specify at least 2 elems" if target_times.length < 2
29
+ return [] if target_times.length < 2
30
+
30
31
  sorted = target_times.sort
31
32
  cursor, range_upper = sorted[0], sorted[-1]
32
33
  filledup = []
@@ -1,3 +1,3 @@
1
1
  module DateDiscreter
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3.beta1"
3
3
  end
@@ -1,4 +1,10 @@
1
1
  describe DateDiscreter do
2
+ let(:single_months) do
3
+ [
4
+ to_time("2013-10-01 00:00:00"),
5
+ ]
6
+ end
7
+
2
8
  let(:continuous_months) do
3
9
  [
4
10
  to_time("2013-10-01 00:00:00"),
@@ -18,6 +24,12 @@ describe DateDiscreter do
18
24
  ]
19
25
  end
20
26
 
27
+ let(:single_days) do
28
+ [
29
+ to_time("2013-10-02 00:00:00"),
30
+ ]
31
+ end
32
+
21
33
  let(:continuous_days) do
22
34
  [
23
35
  to_time("2013-10-01 00:00:00"),
@@ -37,6 +49,12 @@ describe DateDiscreter do
37
49
  ]
38
50
  end
39
51
 
52
+ let(:single_hours) do
53
+ [
54
+ to_time("2013-10-02 01:00:00"),
55
+ ]
56
+ end
57
+
40
58
  let(:continuous_hours) do
41
59
  [
42
60
  to_time("2013-10-01 00:00:00"),
@@ -94,6 +112,26 @@ describe DateDiscreter do
94
112
  it{ should eq [to_date("2013-11-01")] }
95
113
  end
96
114
  end
115
+
116
+ context "with empty" do
117
+ let(:months){ [] }
118
+
119
+ it{ should eq [] }
120
+ end
121
+
122
+ context "with 1 element" do
123
+ context "with time array" do
124
+ let(:months){ single_months }
125
+
126
+ it{ should eq [] }
127
+ end
128
+
129
+ context "with date array" do
130
+ let(:months){ single_months.map(&:to_date) }
131
+
132
+ it{ should eq [] }
133
+ end
134
+ end
97
135
  end
98
136
 
99
137
  describe "#discrete_days" do
@@ -126,6 +164,26 @@ describe DateDiscreter do
126
164
  it{ should eq [to_date("2013-10-03")] }
127
165
  end
128
166
  end
167
+
168
+ context "with empty" do
169
+ let(:days){ [] }
170
+
171
+ it{ should eq [] }
172
+ end
173
+
174
+ context "with 1 element" do
175
+ context "with time array" do
176
+ let(:days){ single_days }
177
+
178
+ it{ should eq [] }
179
+ end
180
+
181
+ context "with date array" do
182
+ let(:days){ single_days.map(&:to_date) }
183
+
184
+ it{ should eq [] }
185
+ end
186
+ end
129
187
  end
130
188
 
131
189
  describe "#discrete_hours" do
@@ -148,6 +206,26 @@ describe DateDiscreter do
148
206
 
149
207
  it{ should eq [to_time("2013-10-01 02:00:00"), to_time("2013-10-01 03:00:00")] }
150
208
  end
209
+
210
+ context "with empty" do
211
+ let(:hours){ [] }
212
+
213
+ it{ should eq [] }
214
+ end
215
+
216
+ context "with 1 element" do
217
+ context "with time array" do
218
+ let(:hours){ single_hours }
219
+
220
+ it{ should eq [] }
221
+ end
222
+
223
+ context "with date array" do
224
+ let(:hours){ single_hours.map(&:to_date) }
225
+
226
+ it{ should eq [] }
227
+ end
228
+ end
151
229
  end
152
230
 
153
231
  describe "#continuous_months?" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: date_discreter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3.beta1
5
5
  platform: ruby
6
6
  authors:
7
7
  - sue445
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-17 00:00:00.000000000 Z
11
+ date: 2015-11-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -161,9 +161,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
161
161
  version: '0'
162
162
  required_rubygems_version: !ruby/object:Gem::Requirement
163
163
  requirements:
164
- - - ">="
164
+ - - ">"
165
165
  - !ruby/object:Gem::Version
166
- version: '0'
166
+ version: 1.3.1
167
167
  requirements: []
168
168
  rubyforge_project:
169
169
  rubygems_version: 2.4.5.1