cinesync 0.9.6 → 1.0.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/spec/xml_spec.rb ADDED
@@ -0,0 +1,272 @@
1
+ $: << File.expand_path(File.dirname(__FILE__))
2
+ require 'spec_helper'
3
+
4
+ describe "XML serialization" do
5
+ it "should serialize empty session" do
6
+ s = CineSync::Session.new
7
+ xml = s.to_xml
8
+ xml.should.not.be.empty?
9
+
10
+ doc = REXML::Document.new(xml)
11
+ doc.root.name.should == "session"
12
+ doc.root.namespace.should == CineSync::SessionV3Namespace
13
+ doc.root.attributes["version"].to_i.should == CineSync::SessionV3XMLFileVersion
14
+ doc.root.attributes["sessionFeatures"].should == s.session_features.to_s
15
+ doc.root.attributes["userData"].should.be.nil?
16
+ doc.root.elements["notes"].should.be.nil?
17
+ end
18
+
19
+ it "should fail when writing an invalid session" do
20
+ s = CineSync::Session.new
21
+ s.media << CineSync::MediaFile.new
22
+ s.should.not.be.valid?
23
+ should.raise(Exception) { s.to_xml }
24
+ end
25
+
26
+ it "should load basic session" do
27
+ path = File.join("spec", "v3 files", "v3-basic.csc")
28
+ s = File.open(path) {|f| CineSync::Session.load(f) }
29
+ s.file_version.should == 3
30
+ s.user_data.should == "sessionUserData blah bloo blee"
31
+ s.media.length.should == 3
32
+ s.notes.should == "These are my session notes.\nnewline."
33
+ s.should.be.valid?
34
+
35
+ s.media[0].should.be.valid?
36
+ s.media[0].name.should == "024b_fn_079_v01_1-98.mov"
37
+ s.media[0].locator.path.should == "/Volumes/Scratch/test_files/movies/024b_fn_079_v01_1-98.mov"
38
+ s.media[0].should.not.be.active?
39
+ s.media[0].current_frame.should == 1
40
+ s.media[0].user_data.should == ""
41
+ s.media[0].groups.should == []
42
+
43
+ s.media[1].should.be.valid?
44
+ s.media[1].name.should == "sample_mpeg4.mp4"
45
+ s.media[1].locator.url.to_s.should == "http://example.com/test_files/movies/sample_mpeg4.mp4"
46
+ s.media[1].locator.short_hash.should == "e74db5de61fa5483c541a3a3056f22d158b44ace"
47
+ s.media[1].should.be.active?
48
+ s.media[1].current_frame.should == 65
49
+ s.media[1].user_data.should == ""
50
+ s.media[1].groups.should == []
51
+
52
+ s.media[2].should.be.valid?
53
+ s.media[2].name.should == "Test_MH 2fps.mov"
54
+ s.media[2].locator.short_hash.should == "f9f0c5d3e3e340bcc9486abbb01a71089de9b886"
55
+ s.media[2].should.not.be.active?
56
+ s.media[2].current_frame.should == 1
57
+ s.media[2].user_data.should == "myPrivateInfo"
58
+ s.media[2].groups.should == []
59
+ s.media[2].notes.should == "These notes on the last movie."
60
+ s.media[2].annotations[1].notes.should == "This is a note on the first frame of the last movie."
61
+ s.media[2].annotations[88].notes.should == ""
62
+ end
63
+
64
+ it "should load group movies" do
65
+ path = File.join("spec", "v3 files", "v3-refmovie.csc")
66
+ s = File.open(path) {|f| CineSync::Session.load(f) }
67
+ s.file_version.should == 3
68
+ s.user_data.should == "sessionUserData blah bloo blee"
69
+ s.media.length.should == 3
70
+ s.notes.should == "These are my session notes.\nnewline."
71
+ s.should.be.valid?
72
+
73
+ s.media[0].should.be.valid?
74
+ s.media[0].name.should == "024b_fn_079_v01_1-98.mov"
75
+ s.media[0].locator.path.should == "/Volumes/Scratch/test_files/movies/024b_fn_079_v01_1-98.mov"
76
+ s.media[0].should.not.be.active?
77
+ s.media[0].current_frame.should == 1
78
+ s.media[0].user_data.should == ""
79
+ s.media[0].groups.should == ["myGroup"]
80
+
81
+ s.media[1].should.be.valid?
82
+ s.media[1].name.should == "sample_mpeg4.mp4"
83
+ s.media[1].locator.url.to_s.should == "http://example.com/test_files/movies/sample_mpeg4.mp4"
84
+ s.media[1].locator.short_hash.should == "e74db5de61fa5483c541a3a3056f22d158b44ace"
85
+ s.media[1].should.not.be.active?
86
+ s.media[1].current_frame.should == 1
87
+ s.media[1].user_data.should == ""
88
+ s.media[1].groups.should == []
89
+
90
+ s.media[2].should.be.valid?
91
+ s.media[2].group.should == "myGroup"
92
+ s.media[2].should.not.be.active?
93
+ s.media[2].current_frame.should == 1
94
+ s.media[2].user_data.should == ""
95
+ end
96
+
97
+ it "should load higher version" do
98
+ xml_str = <<-XML
99
+ <?xml version="1.0" encoding="UTF-8" ?>
100
+ <session xmlns="http://www.cinesync.com/ns/session/3.0" version="4" sessionFeatures="standard">
101
+ </session>
102
+ XML
103
+ s = CineSync::Session.load(xml_str, true)
104
+ s.should.not.be.valid?
105
+ s.user_data.should == ""
106
+ s.file_version.should == 4
107
+ s.notes.should == ""
108
+ s.session_features.should == :standard
109
+ end
110
+
111
+ it "should load groups" do
112
+ xml_str = <<-XML
113
+ <?xml version="1.0" encoding="UTF-8" ?>
114
+ <session xmlns="http://www.cinesync.com/ns/session/3.0" version="3" sessionFeatures="standard">
115
+ <group>Group 1</group>
116
+ <group>second&gt;group</group>
117
+ <media userData="media data" currentFrame="12">
118
+ <name>First movie</name>
119
+ <locators><shortHash>f9f0c5d3e3e340bcc9486abbb01a71089de9b886</shortHash></locators>
120
+ <group>Group 1</group>
121
+ </media>
122
+ </session>
123
+ XML
124
+ s = CineSync::Session.load(xml_str)
125
+ s.should.be.valid?
126
+ s.groups.should == ["Group 1", "second>group"]
127
+ s.media[0].current_frame.should == 12
128
+ s.media[0].groups.should == ["Group 1"]
129
+ end
130
+
131
+ it "should load session and media notes" do
132
+ xml_str = <<-XML
133
+ <?xml version="1.0" encoding="UTF-8" ?>
134
+ <session xmlns="http://www.cinesync.com/ns/session/3.0" version="3" sessionFeatures="standard">
135
+ <media userData="media data">
136
+ <name>First movie</name>
137
+ <locators><path>/does/not/exist.mov</path></locators>
138
+ <notes>Media notes that come first in the file</notes>
139
+ </media>
140
+ <notes>session notes</notes>
141
+ </session>
142
+ XML
143
+ s = CineSync::Session.load(xml_str)
144
+ s.notes.should == "session notes"
145
+ s.media[0].current_frame.should == 1
146
+ s.media[0].user_data.should == "media data"
147
+ s.media[0].notes.should == "Media notes that come first in the file"
148
+ end
149
+
150
+ it "should preserve drawing objects" do
151
+ path = File.join("spec", "v3 files", "v3-groups.csc")
152
+ s = File.open(path) {|f| CineSync::Session.load(f) }
153
+ s.file_version.should == 3
154
+ s.notes.should == ""
155
+ s.should.be.valid?
156
+
157
+ mf = s.media[0]
158
+ mf.annotations.length.should == 13
159
+ mf.annotations[1].drawing_objects[0].name.should.satisfy do |tag|
160
+ CineSync::FrameAnnotation::DrawingObjectElements.include? tag
161
+ end
162
+
163
+ doc = REXML::Document.new(s.to_xml)
164
+ doc.root.get_elements("media").length.should == s.media.length
165
+ doc.root.get_elements("group").length.should == s.groups.length
166
+ doc.root.get_elements("media")[0].get_elements("annotation").length.should == 13
167
+ end
168
+
169
+ it "should write basic session" do
170
+ s = CineSync::Session.new
171
+ path = "/path/to/nonexistent/file.mov"
172
+ s.media << CineSync::MediaFile.new(path)
173
+ xml = s.to_xml
174
+ xml.should.not.be.nil?
175
+ xml.should.not.be.empty?
176
+
177
+ doc = REXML::Document.new(xml)
178
+ doc.root.name.should == "session"
179
+ doc.root.attributes["sessionFeatures"].should == s.session_features.to_s
180
+ doc.root.get_elements("media").length.should == 1
181
+ media_elem = doc.root.get_elements("media")[0]
182
+ media_elem.get_elements("groups").length.should == 0
183
+ media_elem.elements[".//locators/path"].text.should == path
184
+ end
185
+
186
+ it "should write short hash locators" do
187
+ s = CineSync::Session.new
188
+ path = "/Volumes/Oyama/Streams/cineSync Test Files/movies/nasa_shuttle_m420p.mov"
189
+ mf = CineSync::MediaFile.new(path)
190
+ s.media << mf
191
+
192
+ doc = REXML::Document.new(s.to_xml)
193
+ media_elem = doc.root.get_elements("media")[0]
194
+ loc_elem = media_elem.get_elements("locators")[0]
195
+ loc_elem.elements["path"].text.should == mf.locator.path
196
+ loc_elem.elements["shortHash"].text.should == mf.locator.short_hash
197
+ loc_elem.elements["url"].should.be.nil?
198
+ end
199
+
200
+ it "should write url locators" do
201
+ s = CineSync::Session.new
202
+ url = "http://example.com/random_file.mov"
203
+ mf = CineSync::MediaFile.new(url)
204
+ s.media << mf
205
+
206
+ doc = REXML::Document.new(s.to_xml)
207
+ media_elem = doc.root.get_elements("media")[0]
208
+ loc_elem = media_elem.get_elements("locators")[0]
209
+ loc_elem.elements["path"].should.be.nil?
210
+ loc_elem.elements["shortHash"].should.be.nil?
211
+ loc_elem.elements["url"].text.should == url
212
+ loc_elem.elements["url"].text.should == String(mf.locator.url)
213
+ end
214
+
215
+ it "should write groups" do
216
+ s = CineSync::Session.new
217
+ s.groups = %w(Draft Final)
218
+ url = "http://example.com/random_file.mov"
219
+ mf = CineSync::MediaFile.new(url)
220
+ mf.groups << "Final"
221
+ s.media << mf
222
+ s.media << CineSync::MediaFile.new("http://example.com/random_file_2.mov")
223
+
224
+ doc = REXML::Document.new(s.to_xml)
225
+ top_groups = doc.root.get_elements("group")
226
+ top_groups.length.should == 2
227
+ top_groups.any? {|g| g.text == "Draft" }.should.be.true?
228
+ top_groups.any? {|g| g.text == "Final" }.should.be.true?
229
+
230
+ media_elems = doc.root.get_elements("media")
231
+ media_elems[0].get_elements("group").length.should == 1
232
+ media_elems[0].get_elements("group")[0].text.should == mf.groups[0]
233
+
234
+ media_elems[1].get_elements("group").should.be.empty?
235
+ end
236
+
237
+ it "should write notes" do
238
+ s = CineSync::Session.new
239
+ s.notes = "asdf"
240
+ mf = CineSync::MediaFile.new("http://example.com/random_file.mov")
241
+ mf.notes = "fancy media notes!"
242
+ s.media << mf
243
+
244
+ doc = REXML::Document.new(s.to_xml)
245
+ doc.root.get_elements("notes")[0].text.should == s.notes
246
+ doc.root.elements["media/notes"].text.should == mf.notes
247
+ end
248
+
249
+ it "should write user data" do
250
+ s = CineSync::Session.new
251
+ s.user_data = "asdf"
252
+ mf = CineSync::MediaFile.new("http://example.com/random_file.mov")
253
+ mf.user_data = '{"id":"1234QWERTY"}'
254
+ s.media << mf
255
+
256
+ doc = REXML::Document.new(s.to_xml)
257
+ doc.root.attributes["userData"].should == s.user_data
258
+ doc.root.get_elements("media")[0].attributes["userData"].should == mf.user_data
259
+ end
260
+
261
+ it "should write frame notes" do
262
+ s = CineSync::Session.new
263
+ mf = CineSync::MediaFile.new("http://example.com/random_file.mov")
264
+ mf.annotations[33].notes = "A note on frame 33"
265
+ s.media << mf
266
+
267
+ doc = REXML::Document.new(s.to_xml)
268
+ ann_elem = doc.elements["session/media/annotation"]
269
+ ann_elem.attributes["frame"].should == "33"
270
+ ann_elem.elements["notes"].text.should == "A note on frame 33"
271
+ end
272
+ end
metadata CHANGED
@@ -3,10 +3,10 @@ name: cinesync
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
+ - 1
6
7
  - 0
7
- - 9
8
- - 6
9
- version: 0.9.6
8
+ - 1
9
+ version: 1.0.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jonathon Mah
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-05-08 00:00:00 +09:30
18
+ date: 2010-05-28 00:00:00 +09:30
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -46,17 +46,17 @@ dependencies:
46
46
  type: :runtime
47
47
  version_requirements: *id002
48
48
  - !ruby/object:Gem::Dependency
49
- name: builder
49
+ name: bacon
50
50
  prerelease: false
51
51
  requirement: &id003 !ruby/object:Gem::Requirement
52
52
  requirements:
53
53
  - - ">="
54
54
  - !ruby/object:Gem::Version
55
55
  segments:
56
- - 2
57
56
  - 1
58
- version: "2.1"
59
- type: :runtime
57
+ - 0
58
+ version: "1.0"
59
+ type: :development
60
60
  version_requirements: *id003
61
61
  description: " This gem provides a Ruby interface to the cineSync session file format,\n which is used by cineSync's scripting system. Use it to integrate\n cineSync into your workflow.\n"
62
62
  email:
@@ -75,12 +75,14 @@ files:
75
75
  - LICENSE
76
76
  - README.markdown
77
77
  - Rakefile
78
- - Samples/Export Notes to CSV.rb
79
78
  - VERSION
80
79
  - cineSync Session v3 Schema.rnc
81
80
  - cinesync.gemspec
81
+ - examples/Export Notes to CSV.rb
82
+ - examples/Start Session.rb
82
83
  - lib/cinesync.rb
83
84
  - lib/cinesync/color_grading.rb
85
+ - lib/cinesync/commands.rb
84
86
  - lib/cinesync/event_handler.rb
85
87
  - lib/cinesync/frame_annotation.rb
86
88
  - lib/cinesync/mask.rb
@@ -93,7 +95,31 @@ files:
93
95
  - lib/cinesync/ui/win32_save_file_dialog.rb
94
96
  - lib/cinesync/xml.rb
95
97
  - lib/cinesync/zoom_state.rb
96
- - test/helper.rb
98
+ - spec/.bacon
99
+ - spec/cinesync_spec.rb
100
+ - spec/event_handler_spec.rb
101
+ - spec/frame_annotation_spec.rb
102
+ - spec/media_file_spec.rb
103
+ - spec/media_locator_spec.rb
104
+ - spec/session_spec.rb
105
+ - spec/small.txt
106
+ - spec/spec_helper.rb
107
+ - spec/v3 files/corrupt.csc
108
+ - spec/v3 files/v3-Newer v4.csc
109
+ - spec/v3 files/v3-Unsupported.csc
110
+ - spec/v3 files/v3-active first.csc
111
+ - spec/v3 files/v3-active second.csc
112
+ - spec/v3 files/v3-active single.csc
113
+ - spec/v3 files/v3-basic.csc
114
+ - spec/v3 files/v3-groups.csc
115
+ - spec/v3 files/v3-pro.csc
116
+ - spec/v3 files/v3-refmovie.csc
117
+ - spec/v3 files/v3-stereo-anaglyph-off.csc
118
+ - spec/v3 files/v3-stereo-anaglyph.csc
119
+ - spec/v3 files/v3-stereo-interlaced-off.csc
120
+ - spec/v3 files/v3-stereo.csc
121
+ - spec/v3 files/v3-url.csc
122
+ - spec/xml_spec.rb
97
123
  has_rdoc: true
98
124
  homepage: http://github.com/jmah/cinesync
99
125
  licenses: []
@@ -125,4 +151,13 @@ signing_key:
125
151
  specification_version: 3
126
152
  summary: Library for scripting the cineSync collaborative video review tool
127
153
  test_files:
128
- - test/helper.rb
154
+ - spec/cinesync_spec.rb
155
+ - spec/event_handler_spec.rb
156
+ - spec/frame_annotation_spec.rb
157
+ - spec/media_file_spec.rb
158
+ - spec/media_locator_spec.rb
159
+ - spec/session_spec.rb
160
+ - spec/spec_helper.rb
161
+ - spec/xml_spec.rb
162
+ - examples/Export Notes to CSV.rb
163
+ - examples/Start Session.rb