vj-sdk 0.6.4 → 0.6.5

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION.yml CHANGED
@@ -2,4 +2,4 @@
2
2
  :major: 0
3
3
  :build:
4
4
  :minor: 6
5
- :patch: 4
5
+ :patch: 5
@@ -62,7 +62,7 @@ module Videojuicer
62
62
  end
63
63
  define_method "#{type}_assets" do
64
64
  @assets ||= {}
65
- @assets[sym_type] ||= Videojuicer::Asset.const_get(type.capitalize.to_sym).all :id => asset_ids[sym_type].join(',')
65
+ @assets[sym_type] ||= Videojuicer::Asset.const_get(type.capitalize.to_sym).all :id => asset_ids[sym_type].join(',') rescue nil
66
66
  end
67
67
  end
68
68
 
@@ -45,7 +45,8 @@ module Videojuicer
45
45
  def attributes=(arg)
46
46
  raise ArgumentError, "Attributes must be set as a Hash" unless arg.is_a?(Hash)
47
47
  arg.each do |key, value|
48
- self.send("#{key}=", value)
48
+ #set any attributes, ignoring all those that are invalid
49
+ self.send("#{key}=", value) rescue invalid_attributes[key] = value
49
50
  end
50
51
  end
51
52
 
@@ -122,6 +123,7 @@ module Videojuicer
122
123
  def coerce_value(key, value)
123
124
  return value unless value
124
125
  klass = self.class.attributes[key][:class]
126
+
125
127
  if value.is_a?(String) and value.any?
126
128
  # In-built types
127
129
  if klass.kind_of?(Videojuicer::Resource::Types::Base)
@@ -160,6 +162,10 @@ module Videojuicer
160
162
  attrs
161
163
  end
162
164
 
165
+ def invalid_attributes
166
+ @invalid_attributes ||= {}
167
+ end
168
+
163
169
  module SingletonMethods
164
170
 
165
171
  # Registers an attribute using a datamapper-style syntax.
@@ -74,7 +74,7 @@ module Videojuicer
74
74
  include FixtureHelper
75
75
  set_attribute_proc {{
76
76
  :name => /\w+/.gen,
77
- :target_type => "com.videojuicer.core.Presentation"
77
+ :insert_domain => "com.videojuicer.asset"
78
78
  }}
79
79
  end
80
80
 
@@ -56,10 +56,17 @@ describe Videojuicer::Presentation do
56
56
  end
57
57
 
58
58
  it "should also fetch assets" do
59
- @presentation.document_content = "{% video %}{% id 1 %}{% endvideo %}"
59
+ id = Videojuicer::Asset::Video.first.id
60
+ @presentation.document_content = "{% video %}{% id #{id} %}{% endvideo %}"
60
61
  @presentation.asset_ids
61
62
  @presentation.video_assets.first.should_not == nil
62
- @presentation.video_assets.first.id.should == 1
63
+ @presentation.video_assets.first.id.should == id
64
+ end
65
+
66
+ it "should should return nil when there are not assets of that type" do
67
+ @presentation.document_content = "<img src=\"/my-image.png\"/>"
68
+ @presentation.asset_ids
69
+ @presentation.video_assets.should == nil
63
70
  end
64
71
 
65
72
  it "should return the image asset" do
@@ -69,9 +76,10 @@ describe Videojuicer::Presentation do
69
76
  end
70
77
 
71
78
  it "should also take a block and pass the image_asset to that block" do
72
- @presentation.image_asset_id = Videojuicer::Asset::Image.first.id
79
+ id = Videojuicer::Asset::Image.first.id
80
+ @presentation.image_asset_id = id
73
81
  @presentation.image_asset do |image|
74
- image.id.should == 1
82
+ image.id.should == id
75
83
  end
76
84
  end
77
85
 
@@ -37,11 +37,20 @@ describe Videojuicer::Resource::PropertyRegistry do
37
37
 
38
38
  property :date, DateTime
39
39
  end
40
+
41
+ class ::InvalidAttributeRegistry
42
+
43
+ include Videojuicer::Resource::PropertyRegistry
44
+
45
+ property :foo, String
46
+ end
47
+
40
48
  end
41
49
  before(:each) do
42
50
  @example_registry = ::FooAttributeRegistry.new
43
51
  @example_private_prop_registry = ::PrivatePropertyRegistry.new
44
52
  @date_registry = ::DateRegistry.new
53
+
45
54
  end
46
55
 
47
56
  it "registers an attribute with a type at the class scope" do
@@ -150,5 +159,15 @@ describe Videojuicer::Resource::PropertyRegistry do
150
159
  created.name.should == "name set"
151
160
  created.email.should == "gooooo"
152
161
  end
162
+
163
+ it "allows you to set arbitrary attributes" do
164
+ lambda { ::InvalidAttributeRegistry.new({:bar => 'bar'}) }.should_not raise_error(NoMethodError)
165
+ end
166
+
167
+ it "should store invalid attributes in a separate hash" do
168
+ invalid = ::InvalidAttributeRegistry.new({:bar => 'bar'})
169
+ invalid.invalid_attributes.should_not == {}
170
+ end
171
+
153
172
  end
154
173
  end
data/vj-sdk.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{vj-sdk}
8
- s.version = "0.6.4"
8
+ s.version = "0.6.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["danski", "thejohnny", "knowtheory", "sixones", "btab"]
12
- s.date = %q{2010-08-13}
12
+ s.date = %q{2010-08-24}
13
13
  s.email = %q{dan@videojuicer.com}
14
14
  s.extra_rdoc_files = [
15
15
  "LICENSE",
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vj-sdk
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 13
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 6
9
- - 4
10
- version: 0.6.4
9
+ - 5
10
+ version: 0.6.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - danski
@@ -19,12 +19,11 @@ autorequire:
19
19
  bindir: bin
20
20
  cert_chain: []
21
21
 
22
- date: 2010-08-13 00:00:00 +01:00
22
+ date: 2010-08-24 00:00:00 +01:00
23
23
  default_executable:
24
24
  dependencies:
25
25
  - !ruby/object:Gem::Dependency
26
26
  prerelease: false
27
- name: json
28
27
  version_requirements: &id001 !ruby/object:Gem::Requirement
29
28
  none: false
30
29
  requirements:
@@ -35,11 +34,11 @@ dependencies:
35
34
  - 1
36
35
  - 0
37
36
  version: "1.0"
37
+ name: json
38
38
  requirement: *id001
39
39
  type: :runtime
40
40
  - !ruby/object:Gem::Dependency
41
41
  prerelease: false
42
- name: ruby-hmac
43
42
  version_requirements: &id002 !ruby/object:Gem::Requirement
44
43
  none: false
45
44
  requirements:
@@ -51,11 +50,11 @@ dependencies:
51
50
  - 3
52
51
  - 2
53
52
  version: 0.3.2
53
+ name: ruby-hmac
54
54
  requirement: *id002
55
55
  type: :runtime
56
56
  - !ruby/object:Gem::Dependency
57
57
  prerelease: false
58
- name: mash
59
58
  version_requirements: &id003 !ruby/object:Gem::Requirement
60
59
  none: false
61
60
  requirements:
@@ -67,11 +66,11 @@ dependencies:
67
66
  - 0
68
67
  - 3
69
68
  version: 0.0.3
69
+ name: mash
70
70
  requirement: *id003
71
71
  type: :runtime
72
72
  - !ruby/object:Gem::Dependency
73
73
  prerelease: false
74
- name: liquid
75
74
  version_requirements: &id004 !ruby/object:Gem::Requirement
76
75
  none: false
77
76
  requirements:
@@ -83,6 +82,7 @@ dependencies:
83
82
  - 0
84
83
  - 0
85
84
  version: 2.0.0
85
+ name: liquid
86
86
  requirement: *id004
87
87
  type: :runtime
88
88
  description: