timecode 0.2.0 → 0.2.1

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 CHANGED
@@ -1,3 +1,7 @@
1
+ === 0.2.1 / 2010-05-11
2
+
3
+ * Add Timecode#coerce and Timecode#adjacent_to?
4
+
1
5
  === 0.2.0 / 2009-02-26
2
6
 
3
7
  * Properly handle integers starting with 0 in Tiecode.parse (zef)
data/Manifest.txt CHANGED
File without changes
data/README.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  = timecode
2
2
 
3
- * http://guerilla-di.rubyforge.org/timecode
3
+ * http://guerilla-di.org/timecode
4
4
 
5
5
  == DESCRIPTION:
6
6
 
data/Rakefile CHANGED
@@ -2,10 +2,11 @@ require 'rubygems'
2
2
  require 'hoe'
3
3
  require './lib/timecode.rb'
4
4
 
5
- Hoe.new('timecode', Timecode::VERSION) do |p|
5
+ Hoe.spec('timecode') do |p|
6
+ p.version = Timecode::VERSION
6
7
  p.developer('Julik', 'me@julik.nl')
7
8
  p.extra_deps.reject! {|e| e[0] == 'hoe' }
8
- p.extra_deps << 'test-spec'
9
+ p.extra_deps << ['test-spec', '>=0']
9
10
  p.rubyforge_name = 'guerilla-di'
10
11
  p.remote_rdoc_dir = 'timecode'
11
12
  end
data/SPECS.txt CHANGED
@@ -26,6 +26,7 @@
26
26
  * report that the framerates are in delta
27
27
  * validate equality based on delta
28
28
  * report total as it's to_i
29
+ * coerce itself to int
29
30
  * support hours
30
31
  * support minutes
31
32
  * support seconds
@@ -37,6 +38,9 @@
37
38
  == A Timecode of zero should
38
39
  * properly respond to zero?
39
40
 
41
+ == Timecode.from_seconds should
42
+ * properly process this specific case for a float framerate
43
+
40
44
  == Timecode#to_seconds should
41
45
  * return a float
42
46
  * return the value in seconds
@@ -46,12 +50,17 @@
46
50
  * properly present himself via inspect
47
51
  * properly print itself
48
52
 
49
- == An existing Timecode used within ranges should
50
- * properly provide successive value that is one frame up
51
- * work as a range member
53
+ == An existing Timecode compared by adjacency
54
+ * properly detect an adjacent timecode to the left
55
+ * properly detect an adjacent timecode to the right
52
56
 
53
57
  == A Timecode on conversion should
54
58
  * copy itself with a different framerate
59
+ * copy itself with a different framerate
60
+
61
+ == An existing Timecode used within ranges should
62
+ * properly provide successive value that is one frame up
63
+ * work as a range member
55
64
 
56
65
  == A Timecode on calculations should
57
66
  * support addition
@@ -100,4 +109,4 @@
100
109
  * parse from a 4x4bits packed 32bit unsigned int
101
110
  * properly convert itself back to 4x4 bits 32bit unsigned int
102
111
 
103
- 69 specifications (113 requirements), 0 failures
112
+ 74 specifications (118 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.2.0'
15
+ VERSION = '0.2.1'
16
16
 
17
17
  include Comparable
18
18
 
@@ -170,6 +170,20 @@ class Timecode
170
170
  end
171
171
  end
172
172
 
173
+ def coerce(to)
174
+ me = case to
175
+ when String
176
+ to_s
177
+ when Integer
178
+ to_i
179
+ when Float
180
+ to_f
181
+ else
182
+ self
183
+ end
184
+ [me, to]
185
+ end
186
+
173
187
  # is the timecode at 00:00:00:00
174
188
  def zero?
175
189
  @total.zero?
@@ -258,6 +272,12 @@ class Timecode
258
272
  end
259
273
  end
260
274
 
275
+ # Tells whether the passes timecode is immediately to the left or to the right of that one
276
+ # with a 1 frame difference
277
+ def adjacent_to?(another)
278
+ (self.succ == another) || (another.succ == self)
279
+ end
280
+
261
281
  # Subtract a number of frames
262
282
  def -(arg)
263
283
  if (arg.is_a?(Timecode) && framerate_in_delta(arg.fps, @fps))
@@ -106,6 +106,10 @@ context "An existing Timecode should" do
106
106
  Timecode.new(10).to_i.should.equal(10)
107
107
  end
108
108
 
109
+ specify "coerce itself to int" do
110
+ (10 + Timecode.new(2)).should.equal 12
111
+ end
112
+
109
113
  specify "support hours" do
110
114
  @five_seconds.should.respond_to :hours
111
115
  @five_seconds.hours.should.equal 0
@@ -194,6 +198,25 @@ context "An existing Timecode on inspection should" do
194
198
  end
195
199
  end
196
200
 
201
+ context "An existing Timecode compared by adjacency" do
202
+ specify "properly detect an adjacent timecode to the left" do
203
+ Timecode.new(10).should.be.adjacent_to(Timecode.new(9))
204
+ end
205
+
206
+ specify "properly detect an adjacent timecode to the right" do
207
+ Timecode.new(10).should.be.adjacent_to(Timecode.new(11))
208
+ end
209
+
210
+ end
211
+
212
+ context "A Timecode on conversion should" do
213
+ specify "copy itself with a different framerate" do
214
+ tc = Timecode.new(40,25)
215
+ at24 = tc.convert(24)
216
+ at24.total.should.equal 40
217
+ end
218
+ end
219
+
197
220
  context "An existing Timecode used within ranges should" do
198
221
  specify "properly provide successive value that is one frame up" do
199
222
  Timecode.new(10).succ.total.should.equal 11
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.2.0
4
+ version: 0.2.1
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-08-29 00:00:00 +02:00
12
+ date: 2010-05-11 00:00:00 +02:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -22,6 +22,16 @@ dependencies:
22
22
  - !ruby/object:Gem::Version
23
23
  version: "0"
24
24
  version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: rubyforge
27
+ type: :development
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 2.0.4
34
+ version:
25
35
  - !ruby/object:Gem::Dependency
26
36
  name: hoe
27
37
  type: :development
@@ -30,7 +40,7 @@ dependencies:
30
40
  requirements:
31
41
  - - ">="
32
42
  - !ruby/object:Gem::Version
33
- version: 1.8.3
43
+ version: 2.6.0
34
44
  version:
35
45
  description: Value class for SMPTE timecode information
36
46
  email:
@@ -53,7 +63,9 @@ files:
53
63
  - lib/timecode.rb
54
64
  - test/test_timecode.rb
55
65
  has_rdoc: true
56
- homepage: http://guerilla-di.rubyforge.org/timecode
66
+ homepage: http://guerilla-di.org/timecode
67
+ licenses: []
68
+
57
69
  post_install_message:
58
70
  rdoc_options:
59
71
  - --main
@@ -75,9 +87,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
75
87
  requirements: []
76
88
 
77
89
  rubyforge_project: guerilla-di
78
- rubygems_version: 1.3.1
90
+ rubygems_version: 1.3.5
79
91
  signing_key:
80
- specification_version: 2
92
+ specification_version: 3
81
93
  summary: Value class for SMPTE timecode information
82
94
  test_files:
83
95
  - test/test_timecode.rb