ruby-duration 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/lib/duration/mongoid.rb +8 -3
- data/test/duration/test_mongoid.rb +5 -1
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.2
|
data/lib/duration/mongoid.rb
CHANGED
@@ -6,9 +6,14 @@ class Duration
|
|
6
6
|
total
|
7
7
|
end
|
8
8
|
|
9
|
-
def self.set(
|
10
|
-
|
11
|
-
|
9
|
+
def self.set(args)
|
10
|
+
if args.is_a?(Hash)
|
11
|
+
Duration.new(args)
|
12
|
+
elsif args.respond_to?(:to_i)
|
13
|
+
Duration.new(seconds.to_i)
|
14
|
+
else
|
15
|
+
Duration.new(0)
|
16
|
+
end
|
12
17
|
end
|
13
18
|
end
|
14
19
|
|
@@ -14,9 +14,13 @@ class Duration::TestMongoid < MiniTest::Unit::TestCase
|
|
14
14
|
assert_equal zero, Duration.set(nil)
|
15
15
|
end
|
16
16
|
|
17
|
-
def
|
17
|
+
def test_set_seconds
|
18
18
|
assert_equal Duration.new(10), Duration.set("10")
|
19
19
|
assert_equal Duration.new(10), Duration.set(10)
|
20
20
|
end
|
21
21
|
|
22
|
+
def test_set_hash
|
23
|
+
assert_equal Duration.new(:minutes => 1, :seconds => 30), Duration.set(:minutes => 1, :seconds => 30)
|
24
|
+
end
|
25
|
+
|
22
26
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-duration
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 2
|
10
|
+
version: 0.1.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jose Peleteiro
|