uencode 0.0.2 → 0.0.3

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.
@@ -28,6 +28,10 @@ module UEncode
28
28
  end
29
29
 
30
30
  module RateElement
31
+ ATTRIBUTES = [:numerator, :denominator]
32
+
33
+ include AttrSetting
34
+
31
35
  def to_xml
32
36
  %Q{
33
37
  <#{root_name}>
@@ -36,11 +40,14 @@ module UEncode
36
40
  </#{root_name}>
37
41
  }
38
42
  end
43
+
44
+ def ==(other)
45
+ numerator == other.numerator && denominator == other.denominator
46
+ end
39
47
  end
40
48
 
41
49
  class FrameRate
42
50
  include RateElement
43
- ATTRIBUTES = [:numerator, :denominator]
44
51
 
45
52
  private
46
53
  def root_name; "framerate"; end
@@ -48,7 +55,6 @@ module UEncode
48
55
 
49
56
  class Par < FrameRate
50
57
  include RateElement
51
- ATTRIBUTES = [:numerator, :denominator]
52
58
 
53
59
  private
54
60
  def root_name; "par"; end
@@ -203,6 +209,16 @@ module UEncode
203
209
  @passes = 1
204
210
  @stretch = false
205
211
  end
212
+
213
+ def framerate=(_framerate)
214
+ _framerate = FrameRate.new(_framerate) unless _framerate.instance_of?(FrameRate) || _framerate.nil?
215
+ instance_variable_set :@framerate, _framerate
216
+ end
217
+
218
+ def par=(_par)
219
+ _par = Par.new(_par) unless _par.instance_of?(Par) || _par.nil?
220
+ instance_variable_set :@par, _par
221
+ end
206
222
  end
207
223
 
208
224
  # The audio configs for each Medium
@@ -262,5 +278,5 @@ module UEncode
262
278
  end
263
279
  end
264
280
 
265
- [Size, FrameRate, Crop, VideoOutput, CaptureOutput, Job].each { |klass| klass.send :include, AttrSetting }
281
+ [Size, Crop, VideoOutput, CaptureOutput, Job].each { |klass| klass.send :include, AttrSetting }
266
282
  end
@@ -1,3 +1,3 @@
1
1
  module UEncode
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/lib/uencode.rb CHANGED
@@ -16,7 +16,7 @@ module UEncode
16
16
 
17
17
  module AttrSetting
18
18
  def set_attributes(options)
19
- self.class.const_get("ATTRIBUTES").each { |attr| instance_variable_set(:"@#{attr}", options[attr]) }
19
+ self.class.const_get("ATTRIBUTES").each { |attr| instance_variable_set(:"@#{attr}", options[attr.to_sym] || options[attr.to_s]) }
20
20
  end
21
21
 
22
22
  def initialize(options)
@@ -51,19 +51,20 @@ describe UEncode::Medium do
51
51
  it { medium.video.width.should == 400 }
52
52
 
53
53
  context "from a hash (video parameters)" do
54
- before { medium.configure config }
55
54
  subject { medium.video_config }
56
55
 
56
+ before { medium.configure config }
57
+
57
58
  its(:bitrate) { should == video_config["bitrate"] }
58
59
  its(:codec) { should == video_config["codec"] }
59
60
  its(:cbr) { should == video_config["cbr"] }
60
61
  its(:crop) { should == video_config["crop"] }
61
62
  its(:deinterlace) { should == video_config["deinterlace"] }
62
- its(:framerate) { should == video_config["framerate"] }
63
+ its(:framerate) { should == UEncode::FrameRate.new(video_config["framerate"]) }
63
64
  its(:height) { should == video_config["height"] }
64
65
  its(:keyframe_interval) { should == video_config["keyframe_interval"] }
65
66
  its(:maxbitrate) { should == video_config["maxbitrate"] }
66
- its(:par) { should == video_config["par"] }
67
+ its(:par) { should == UEncode::Par.new(video_config["par"]) }
67
68
  its(:profile) { should == video_config["profile"] }
68
69
  its(:passes) { should == video_config["passes"] }
69
70
  its(:stretch) { should == video_config["stretch"] }
@@ -361,6 +362,26 @@ shared_examples_for "an element that represents a rate number" do
361
362
  end
362
363
  end
363
364
 
365
+ describe UEncode::VideoConfig do
366
+ let(:config) { described_class.new }
367
+
368
+ context "receiving a hash as the framerate" do
369
+ before { config.framerate = {:numerator => 123, :denominator => 345} }
370
+
371
+ it "converts it to a UEncode::FrameRate" do
372
+ config.framerate.should be_an_instance_of(UEncode::FrameRate)
373
+ end
374
+
375
+ it "the framerate has the correct numerator" do
376
+ config.framerate.numerator.should == 123
377
+ end
378
+
379
+ it "the framerate has the correct denominator" do
380
+ config.framerate.denominator.should == 345
381
+ end
382
+ end
383
+ end
384
+
364
385
  describe UEncode::FrameRate do
365
386
  let(:name) { "framerate" }
366
387
  let(:numerator) { 1000 }
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: uencode
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.2
5
+ version: 0.0.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - "C\xC3\xA1ssio Marques"
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-07-07 00:00:00 -03:00
13
+ date: 2011-07-08 00:00:00 -03:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -166,7 +166,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
166
166
  requirements:
167
167
  - - ">="
168
168
  - !ruby/object:Gem::Version
169
- hash: 2924149938077751902
169
+ hash: -2133508719969369294
170
170
  segments:
171
171
  - 0
172
172
  version: "0"
@@ -175,7 +175,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
175
175
  requirements:
176
176
  - - ">="
177
177
  - !ruby/object:Gem::Version
178
- hash: 2924149938077751902
178
+ hash: -2133508719969369294
179
179
  segments:
180
180
  - 0
181
181
  version: "0"