nostradamus 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/nostradamus/version.rb +1 -1
- data/lib/nostradamus.rb +6 -2
- data/spec/nostradamus/nostradamus_spec.rb +12 -0
- metadata +1 -1
data/lib/nostradamus/version.rb
CHANGED
data/lib/nostradamus.rb
CHANGED
@@ -5,11 +5,15 @@ module Nostradamus
|
|
5
5
|
SECONDS_REGEX = /[0-9]*:[0-9]*:([0-9]*)/
|
6
6
|
|
7
7
|
def parse(human_time)
|
8
|
-
|
8
|
+
if human_time
|
9
|
+
convert(human_time, :to => :seconds)
|
10
|
+
end
|
9
11
|
end
|
10
12
|
|
11
13
|
def humanize(seconds, format = nil)
|
12
|
-
|
14
|
+
if seconds
|
15
|
+
convert(seconds, :to => :human_time, :format => format)
|
16
|
+
end
|
13
17
|
end
|
14
18
|
|
15
19
|
private
|
@@ -9,6 +9,12 @@ describe Nostradamus do
|
|
9
9
|
described_class.parse("12:15").should eq 44100
|
10
10
|
described_class.parse("12:15:15").should eq 44115
|
11
11
|
end
|
12
|
+
|
13
|
+
it "should not raise error without value" do
|
14
|
+
expect {
|
15
|
+
described_class.parse(nil)
|
16
|
+
}.to_not raise_error
|
17
|
+
end
|
12
18
|
end
|
13
19
|
|
14
20
|
context "seconds to human time" do
|
@@ -18,5 +24,11 @@ describe Nostradamus do
|
|
18
24
|
described_class.humanize(44115).should eq "12:15:15"
|
19
25
|
described_class.humanize(44115, :short).should eq "12:15"
|
20
26
|
end
|
27
|
+
|
28
|
+
it "should not raise error without value" do
|
29
|
+
expect {
|
30
|
+
described_class.humanize(nil)
|
31
|
+
}.to_not raise_error
|
32
|
+
end
|
21
33
|
end
|
22
34
|
end
|