timecode 0.1.8 → 0.1.9
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/History.txt +4 -0
- data/SPECS.txt +17 -5
- data/lib/timecode.rb +2 -5
- data/test/test_timecode.rb +15 -3
- metadata +2 -2
data/History.txt
CHANGED
data/SPECS.txt
CHANGED
@@ -1,11 +1,18 @@
|
|
1
1
|
|
2
|
-
== Timecode.new
|
2
|
+
== Timecode.new should
|
3
3
|
* instantiate from int
|
4
4
|
* always coerce FPS to float
|
5
5
|
* create a zero TC with no arguments
|
6
6
|
* accept full string SMPTE timecode as well
|
7
7
|
|
8
|
-
== Timecode.
|
8
|
+
== Timecode.validate_atoms! should
|
9
|
+
* disallow more than 99 hrs
|
10
|
+
* disallow more than 59 minutes
|
11
|
+
* disallow more than 59 seconds
|
12
|
+
* disallow more frames than what the framerate permits
|
13
|
+
* pass validation with usable values
|
14
|
+
|
15
|
+
== Timecode.at should
|
9
16
|
* disallow more than 99 hrs
|
10
17
|
* disallow more than 59 minutes
|
11
18
|
* disallow more than 59 seconds
|
@@ -30,6 +37,11 @@
|
|
30
37
|
== A Timecode of zero should
|
31
38
|
* properly respond to zero?
|
32
39
|
|
40
|
+
== Timecode#to_seconds should
|
41
|
+
* return a float
|
42
|
+
* return the value in seconds
|
43
|
+
* properly roundtrip a value via Timecode.from_seconds
|
44
|
+
|
33
45
|
== An existing Timecode on inspection should
|
34
46
|
* properly present himself via inspect
|
35
47
|
* properly print itself
|
@@ -64,8 +76,7 @@
|
|
64
76
|
|
65
77
|
== Timecode.parse should
|
66
78
|
* handle complete SMPTE timecode
|
67
|
-
* handle
|
68
|
-
* refuse to handle timecode that is out of range for the framerate
|
79
|
+
* handle timecode with fractional seconds
|
69
80
|
* parse a row of numbers as parts of a timecode starting from the right
|
70
81
|
* parse a number with f suffix as frames
|
71
82
|
* parse a number with s suffix as seconds
|
@@ -78,6 +89,7 @@
|
|
78
89
|
* parse timecode with fractional second instead of frames
|
79
90
|
* raise when trying to parse DF timecode
|
80
91
|
* raise on improper format
|
92
|
+
* raise on empty argument
|
81
93
|
|
82
94
|
== Timecode.soft_parse should
|
83
95
|
* parse the timecode
|
@@ -87,4 +99,4 @@
|
|
87
99
|
* parse from a 4x4bits packed 32bit unsigned int
|
88
100
|
* properly convert itself back to 4x4 bits 32bit unsigned int
|
89
101
|
|
90
|
-
|
102
|
+
68 specifications (112 requirements), 0 failures
|
data/lib/timecode.rb
CHANGED
@@ -12,7 +12,7 @@
|
|
12
12
|
# :mapping => [%w(source_tc_frames total), %w(tape_fps fps)]
|
13
13
|
|
14
14
|
class Timecode
|
15
|
-
VERSION = '0.1.
|
15
|
+
VERSION = '0.1.9'
|
16
16
|
|
17
17
|
include Comparable
|
18
18
|
|
@@ -80,9 +80,6 @@ class Timecode
|
|
80
80
|
# Drop frame goodbye
|
81
81
|
if (input =~ DF_TC_RE)
|
82
82
|
raise Error, "We do not support drop-frame TC"
|
83
|
-
# No empty values
|
84
|
-
elsif (input =~ /A(\s+)Z/)
|
85
|
-
raise CannotParse, "Empty timecode"
|
86
83
|
# 00:00:00:00
|
87
84
|
elsif (input =~ COMPLETE_TC_RE)
|
88
85
|
atoms_and_fps = input.scan(COMPLETE_TC_RE).to_a.flatten.map{|e| Integer(e)} + [with_fps]
|
@@ -157,7 +154,7 @@ class Timecode
|
|
157
154
|
# create a timecode from the number of seconds. This is how current time is supplied by
|
158
155
|
# QuickTime and other systems which have non-frame-based timescales
|
159
156
|
def from_seconds(seconds_float, the_fps = DEFAULT_FPS)
|
160
|
-
total_frames = (seconds_float.to_f * the_fps.to_f).
|
157
|
+
total_frames = (seconds_float.to_f * the_fps.to_f).to_i
|
161
158
|
new(total_frames, the_fps)
|
162
159
|
end
|
163
160
|
|
data/test/test_timecode.rb
CHANGED
@@ -44,8 +44,8 @@ context "Timecode.validate_atoms! should" do
|
|
44
44
|
end
|
45
45
|
|
46
46
|
specify "disallow more frames than what the framerate permits" do
|
47
|
-
lambda{ Timecode.validate_atoms!(1,0,
|
48
|
-
lambda{ Timecode.validate_atoms!(1,0,
|
47
|
+
lambda{ Timecode.validate_atoms!(1,0,45,25, 25) }.should.raise(Timecode::RangeError)
|
48
|
+
lambda{ Timecode.validate_atoms!(1,0,45,32, 30) }.should.raise(Timecode::RangeError)
|
49
49
|
end
|
50
50
|
|
51
51
|
specify "pass validation with usable values" do
|
@@ -166,6 +166,13 @@ context "Timecode#to_seconds should" do
|
|
166
166
|
secs = 126.3
|
167
167
|
Timecode.new(fps * secs, fps).to_seconds.should.be.close 126.3, 0.1
|
168
168
|
end
|
169
|
+
|
170
|
+
specify "properly roundtrip a value via Timecode.from_seconds" do
|
171
|
+
secs_in = 19.76
|
172
|
+
from_secs = Timecode.from_seconds(19.76, 25.0)
|
173
|
+
from_secs.total.should.equal 494
|
174
|
+
from_secs.to_seconds.should.be.close(secs_in, 0.001)
|
175
|
+
end
|
169
176
|
end
|
170
177
|
|
171
178
|
context "An existing Timecode on inspection should" do
|
@@ -271,7 +278,7 @@ context "A Timecode used with fractional number of seconds" do
|
|
271
278
|
|
272
279
|
fraction = 7.16
|
273
280
|
tc = Timecode.from_seconds(fraction, 12.5)
|
274
|
-
tc.to_s.should.equal "00:00:07:
|
281
|
+
tc.to_s.should.equal "00:00:07:01"
|
275
282
|
end
|
276
283
|
|
277
284
|
end
|
@@ -310,6 +317,11 @@ context "Timecode.parse should" do
|
|
310
317
|
Timecode.parse(simple_tc).to_s.should.equal(simple_tc)
|
311
318
|
end
|
312
319
|
|
320
|
+
specify "handle timecode with fractional seconds" do
|
321
|
+
tc = Timecode.parse("10:10:10.2", 25)
|
322
|
+
tc.to_s.should.equal "10:10:10:05"
|
323
|
+
end
|
324
|
+
|
313
325
|
specify "parse a row of numbers as parts of a timecode starting from the right" do
|
314
326
|
Timecode.parse("10").should.equal Timecode.new(10)
|
315
327
|
Timecode.parse("210").should.equal Timecode.new(60)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: timecode
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Julik
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-02-
|
12
|
+
date: 2009-02-23 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|