timecode 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +5 -0
- data/Manifest.txt +1 -2
- data/SPECS.txt +7 -1
- data/lib/timecode.rb +7 -7
- data/test/test_timecode.rb +26 -0
- metadata +2 -3
- data/timecode.gemspec +0 -38
data/History.txt
CHANGED
data/Manifest.txt
CHANGED
data/SPECS.txt
CHANGED
@@ -51,8 +51,14 @@
|
|
51
51
|
* disallow more frames than what the framerate permits
|
52
52
|
* propery accept usable values
|
53
53
|
|
54
|
+
== A custom Timecode descendant should
|
55
|
+
* properly classify on parse
|
56
|
+
* properly classify on at
|
57
|
+
* properly classify on calculations
|
58
|
+
|
54
59
|
== Timecode.parse() should
|
55
60
|
* handle complete SMPTE timecode
|
61
|
+
* handle complete SMPTE timecode via new
|
56
62
|
* refuse to handle timecode that is out of range for the framerate
|
57
63
|
* parse a row of numbers as parts of a timecode starting from the right
|
58
64
|
* parse a number with f suffix as frames
|
@@ -71,4 +77,4 @@
|
|
71
77
|
* parse from a 4x4bits packed 32bit unsigned int
|
72
78
|
* properly convert itself back to 4x4 bits 32bit unsigned int
|
73
79
|
|
74
|
-
|
80
|
+
52 specifications (87 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.6'
|
16
16
|
|
17
17
|
include Comparable
|
18
18
|
|
@@ -252,29 +252,29 @@ class Timecode
|
|
252
252
|
# add number of frames (or another timecode) to this one
|
253
253
|
def +(arg)
|
254
254
|
if (arg.is_a?(Timecode) && framerate_in_delta(arg.fps, @fps))
|
255
|
-
|
255
|
+
self.class.new(@total+arg.total, @fps)
|
256
256
|
elsif (arg.is_a?(Timecode))
|
257
257
|
raise WrongFramerate, "You are calculating timecodes with different framerates"
|
258
258
|
else
|
259
|
-
|
259
|
+
self.class.new(@total + arg, @fps)
|
260
260
|
end
|
261
261
|
end
|
262
262
|
|
263
263
|
# Subtract a number of frames
|
264
264
|
def -(arg)
|
265
265
|
if (arg.is_a?(Timecode) && framerate_in_delta(arg.fps, @fps))
|
266
|
-
|
266
|
+
self.class.new(@total-arg.total, @fps)
|
267
267
|
elsif (arg.is_a?(Timecode))
|
268
268
|
raise WrongFramerate, "You are calculating timecodes with different framerates"
|
269
269
|
else
|
270
|
-
|
270
|
+
self.class.new(@total-arg, @fps)
|
271
271
|
end
|
272
272
|
end
|
273
273
|
|
274
274
|
# Multiply the timecode by a number
|
275
275
|
def *(arg)
|
276
276
|
raise RangeError, "Timecode multiplier cannot be negative" if (arg < 0)
|
277
|
-
|
277
|
+
self.class.new(@total*arg.to_i, @fps)
|
278
278
|
end
|
279
279
|
|
280
280
|
# Get the next frame
|
@@ -285,7 +285,7 @@ class Timecode
|
|
285
285
|
# Get the number of times a passed timecode fits into this time span (if performed with Timecode) or
|
286
286
|
# a Timecode that multiplied by arg will give this one
|
287
287
|
def /(arg)
|
288
|
-
arg.is_a?(Timecode) ? (@total / arg.total) :
|
288
|
+
arg.is_a?(Timecode) ? (@total / arg.total) : self.class.new(@total /arg, @fps)
|
289
289
|
end
|
290
290
|
|
291
291
|
# Timecodes can be compared to each other
|
data/test/test_timecode.rb
CHANGED
@@ -219,6 +219,32 @@ context "Timecode.at() should" do
|
|
219
219
|
end
|
220
220
|
end
|
221
221
|
|
222
|
+
context "A custom Timecode descendant should" do
|
223
|
+
class CustomTC < Timecode; end
|
224
|
+
|
225
|
+
specify "properly classify on parse" do
|
226
|
+
CustomTC.parse("001").should.be.kind_of CustomTC
|
227
|
+
end
|
228
|
+
|
229
|
+
specify "properly classify on at" do
|
230
|
+
CustomTC.at(10,10,10,10).should.be.kind_of CustomTC
|
231
|
+
end
|
232
|
+
|
233
|
+
specify "properly classify on calculations" do
|
234
|
+
computed = CustomTC.parse("10h") + Timecode.new(10)
|
235
|
+
computed.should.be.kind_of CustomTC
|
236
|
+
|
237
|
+
computed = CustomTC.parse("10h") - Timecode.new(10)
|
238
|
+
computed.should.be.kind_of CustomTC
|
239
|
+
|
240
|
+
computed = CustomTC.parse("10h") * 5
|
241
|
+
computed.should.be.kind_of CustomTC
|
242
|
+
|
243
|
+
computed = CustomTC.parse("10h") / 5
|
244
|
+
computed.should.be.kind_of CustomTC
|
245
|
+
end
|
246
|
+
|
247
|
+
end
|
222
248
|
|
223
249
|
context "Timecode.parse() should" do
|
224
250
|
|
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.6
|
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-01-
|
12
|
+
date: 2009-01-28 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -52,7 +52,6 @@ files:
|
|
52
52
|
- Rakefile
|
53
53
|
- lib/timecode.rb
|
54
54
|
- test/test_timecode.rb
|
55
|
-
- timecode.gemspec
|
56
55
|
has_rdoc: true
|
57
56
|
homepage: http://wiretap.rubyforge.org/timecode
|
58
57
|
post_install_message:
|
data/timecode.gemspec
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
|
-
Gem::Specification.new do |s|
|
4
|
-
s.name = %q{timecode}
|
5
|
-
s.version = "0.1.5"
|
6
|
-
|
7
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
-
s.authors = ["Julik"]
|
9
|
-
s.date = %q{2009-01-18}
|
10
|
-
s.description = %q{Value class for SMPTE timecode information}
|
11
|
-
s.email = ["me@julik.nl"]
|
12
|
-
s.extra_rdoc_files = ["History.txt", "Manifest.txt", "README.txt", "SPECS.txt"]
|
13
|
-
s.files = ["History.txt", "Manifest.txt", "README.txt", "SPECS.txt", "Rakefile", "lib/timecode.rb", "test/test_timecode.rb", "timecode.gemspec"]
|
14
|
-
s.has_rdoc = true
|
15
|
-
s.homepage = %q{http://wiretap.rubyforge.org/timecode}
|
16
|
-
s.rdoc_options = ["--main", "README.txt"]
|
17
|
-
s.require_paths = ["lib"]
|
18
|
-
s.rubyforge_project = %q{guerilla-di}
|
19
|
-
s.rubygems_version = %q{1.3.1}
|
20
|
-
s.summary = %q{Value class for SMPTE timecode information}
|
21
|
-
s.test_files = ["test/test_timecode.rb"]
|
22
|
-
|
23
|
-
if s.respond_to? :specification_version then
|
24
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
25
|
-
s.specification_version = 2
|
26
|
-
|
27
|
-
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
28
|
-
s.add_runtime_dependency(%q<test-spec>, [">= 0"])
|
29
|
-
s.add_development_dependency(%q<hoe>, [">= 1.8.2"])
|
30
|
-
else
|
31
|
-
s.add_dependency(%q<test-spec>, [">= 0"])
|
32
|
-
s.add_dependency(%q<hoe>, [">= 1.8.2"])
|
33
|
-
end
|
34
|
-
else
|
35
|
-
s.add_dependency(%q<test-spec>, [">= 0"])
|
36
|
-
s.add_dependency(%q<hoe>, [">= 1.8.2"])
|
37
|
-
end
|
38
|
-
end
|