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/Rakefile +11 -11
- data/VERSION +1 -1
- data/cinesync.gemspec +43 -8
- data/{Samples → examples}/Export Notes to CSV.rb +0 -0
- data/examples/Start Session.rb +17 -0
- data/lib/cinesync/commands.rb +50 -0
- data/lib/cinesync/event_handler.rb +0 -1
- data/lib/cinesync/frame_annotation.rb +1 -1
- data/lib/cinesync/media_file.rb +7 -2
- data/lib/cinesync/xml.rb +4 -5
- data/lib/cinesync.rb +4 -7
- data/spec/.bacon +0 -0
- data/spec/cinesync_spec.rb +12 -0
- data/spec/event_handler_spec.rb +66 -0
- data/spec/frame_annotation_spec.rb +33 -0
- data/spec/media_file_spec.rb +125 -0
- data/spec/media_locator_spec.rb +68 -0
- data/spec/session_spec.rb +61 -0
- data/spec/small.txt +1 -0
- data/{test/helper.rb → spec/spec_helper.rb} +3 -5
- data/spec/v3 files/corrupt.csc +4 -0
- data/spec/v3 files/v3-Newer v4.csc +4 -0
- data/spec/v3 files/v3-Unsupported.csc +4 -0
- data/spec/v3 files/v3-active first.csc +37 -0
- data/spec/v3 files/v3-active second.csc +37 -0
- data/spec/v3 files/v3-active single.csc +14 -0
- data/spec/v3 files/v3-basic.csc +37 -0
- data/spec/v3 files/v3-groups.csc +728 -0
- data/spec/v3 files/v3-pro.csc +91 -0
- data/spec/v3 files/v3-refmovie.csc +32 -0
- data/spec/v3 files/v3-stereo-anaglyph-off.csc +468 -0
- data/spec/v3 files/v3-stereo-anaglyph.csc +470 -0
- data/spec/v3 files/v3-stereo-interlaced-off.csc +468 -0
- data/spec/v3 files/v3-stereo.csc +95 -0
- data/spec/v3 files/v3-url.csc +15 -0
- data/spec/xml_spec.rb +272 -0
- metadata +46 -11
    
        data/Rakefile
    CHANGED
    
    | @@ -16,7 +16,7 @@ begin | |
| 16 16 | 
             
                gem.authors = ["Jonathon Mah", "Rising Sun Research"]
         | 
| 17 17 | 
             
                gem.add_dependency "activesupport", ">= 2.3"
         | 
| 18 18 | 
             
                gem.add_dependency "andand", ">= 1.3.1"
         | 
| 19 | 
            -
                gem. | 
| 19 | 
            +
                gem.add_development_dependency "bacon", ">= 1.0"
         | 
| 20 20 | 
             
                # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
         | 
| 21 21 | 
             
              end
         | 
| 22 22 | 
             
              Jeweler::GemcutterTasks.new
         | 
| @@ -25,18 +25,18 @@ rescue LoadError | |
| 25 25 | 
             
            end
         | 
| 26 26 |  | 
| 27 27 | 
             
            require 'rake/testtask'
         | 
| 28 | 
            -
            Rake::TestTask.new(: | 
| 29 | 
            -
               | 
| 30 | 
            -
               | 
| 31 | 
            -
               | 
| 28 | 
            +
            Rake::TestTask.new(:spec) do |spec|
         | 
| 29 | 
            +
              spec.libs << 'lib' << 'spec'
         | 
| 30 | 
            +
              spec.pattern = 'spec/**/*_spec.rb'
         | 
| 31 | 
            +
              spec.verbose = true
         | 
| 32 32 | 
             
            end
         | 
| 33 33 |  | 
| 34 34 | 
             
            begin
         | 
| 35 35 | 
             
              require 'rcov/rcovtask'
         | 
| 36 | 
            -
              Rcov::RcovTask.new do | | 
| 37 | 
            -
                 | 
| 38 | 
            -
                 | 
| 39 | 
            -
                 | 
| 36 | 
            +
              Rcov::RcovTask.new do |spec|
         | 
| 37 | 
            +
                spec.libs << 'spec'
         | 
| 38 | 
            +
                spec.pattern = 'spec/**/*_spec.rb'
         | 
| 39 | 
            +
                spec.verbose = true
         | 
| 40 40 | 
             
              end
         | 
| 41 41 | 
             
            rescue LoadError
         | 
| 42 42 | 
             
              task :rcov do
         | 
| @@ -44,9 +44,9 @@ rescue LoadError | |
| 44 44 | 
             
              end
         | 
| 45 45 | 
             
            end
         | 
| 46 46 |  | 
| 47 | 
            -
            task : | 
| 47 | 
            +
            task :spec => :check_dependencies
         | 
| 48 48 |  | 
| 49 | 
            -
            task :default => : | 
| 49 | 
            +
            task :default => :spec
         | 
| 50 50 |  | 
| 51 51 | 
             
            require 'rake/rdoctask'
         | 
| 52 52 | 
             
            Rake::RDocTask.new do |rdoc|
         | 
    
        data/VERSION
    CHANGED
    
    | @@ -1 +1 @@ | |
| 1 | 
            -
            0. | 
| 1 | 
            +
            1.0.1
         | 
    
        data/cinesync.gemspec
    CHANGED
    
    | @@ -5,11 +5,11 @@ | |
| 5 5 |  | 
| 6 6 | 
             
            Gem::Specification.new do |s|
         | 
| 7 7 | 
             
              s.name = %q{cinesync}
         | 
| 8 | 
            -
              s.version = "0. | 
| 8 | 
            +
              s.version = "1.0.1"
         | 
| 9 9 |  | 
| 10 10 | 
             
              s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
         | 
| 11 11 | 
             
              s.authors = ["Jonathon Mah", "Rising Sun Research"]
         | 
| 12 | 
            -
              s.date = %q{2010-05- | 
| 12 | 
            +
              s.date = %q{2010-05-28}
         | 
| 13 13 | 
             
              s.description = %q{      This gem provides a Ruby interface to the cineSync session file format,
         | 
| 14 14 | 
             
                  which is used by cineSync's scripting system. Use it to integrate
         | 
| 15 15 | 
             
                  cineSync into your workflow.
         | 
| @@ -25,12 +25,14 @@ Gem::Specification.new do |s| | |
| 25 25 | 
             
                 "LICENSE",
         | 
| 26 26 | 
             
                 "README.markdown",
         | 
| 27 27 | 
             
                 "Rakefile",
         | 
| 28 | 
            -
                 "Samples/Export Notes to CSV.rb",
         | 
| 29 28 | 
             
                 "VERSION",
         | 
| 30 29 | 
             
                 "cineSync Session v3 Schema.rnc",
         | 
| 31 30 | 
             
                 "cinesync.gemspec",
         | 
| 31 | 
            +
                 "examples/Export Notes to CSV.rb",
         | 
| 32 | 
            +
                 "examples/Start Session.rb",
         | 
| 32 33 | 
             
                 "lib/cinesync.rb",
         | 
| 33 34 | 
             
                 "lib/cinesync/color_grading.rb",
         | 
| 35 | 
            +
                 "lib/cinesync/commands.rb",
         | 
| 34 36 | 
             
                 "lib/cinesync/event_handler.rb",
         | 
| 35 37 | 
             
                 "lib/cinesync/frame_annotation.rb",
         | 
| 36 38 | 
             
                 "lib/cinesync/mask.rb",
         | 
| @@ -43,7 +45,31 @@ Gem::Specification.new do |s| | |
| 43 45 | 
             
                 "lib/cinesync/ui/win32_save_file_dialog.rb",
         | 
| 44 46 | 
             
                 "lib/cinesync/xml.rb",
         | 
| 45 47 | 
             
                 "lib/cinesync/zoom_state.rb",
         | 
| 46 | 
            -
                 " | 
| 48 | 
            +
                 "spec/.bacon",
         | 
| 49 | 
            +
                 "spec/cinesync_spec.rb",
         | 
| 50 | 
            +
                 "spec/event_handler_spec.rb",
         | 
| 51 | 
            +
                 "spec/frame_annotation_spec.rb",
         | 
| 52 | 
            +
                 "spec/media_file_spec.rb",
         | 
| 53 | 
            +
                 "spec/media_locator_spec.rb",
         | 
| 54 | 
            +
                 "spec/session_spec.rb",
         | 
| 55 | 
            +
                 "spec/small.txt",
         | 
| 56 | 
            +
                 "spec/spec_helper.rb",
         | 
| 57 | 
            +
                 "spec/v3 files/corrupt.csc",
         | 
| 58 | 
            +
                 "spec/v3 files/v3-Newer v4.csc",
         | 
| 59 | 
            +
                 "spec/v3 files/v3-Unsupported.csc",
         | 
| 60 | 
            +
                 "spec/v3 files/v3-active first.csc",
         | 
| 61 | 
            +
                 "spec/v3 files/v3-active second.csc",
         | 
| 62 | 
            +
                 "spec/v3 files/v3-active single.csc",
         | 
| 63 | 
            +
                 "spec/v3 files/v3-basic.csc",
         | 
| 64 | 
            +
                 "spec/v3 files/v3-groups.csc",
         | 
| 65 | 
            +
                 "spec/v3 files/v3-pro.csc",
         | 
| 66 | 
            +
                 "spec/v3 files/v3-refmovie.csc",
         | 
| 67 | 
            +
                 "spec/v3 files/v3-stereo-anaglyph-off.csc",
         | 
| 68 | 
            +
                 "spec/v3 files/v3-stereo-anaglyph.csc",
         | 
| 69 | 
            +
                 "spec/v3 files/v3-stereo-interlaced-off.csc",
         | 
| 70 | 
            +
                 "spec/v3 files/v3-stereo.csc",
         | 
| 71 | 
            +
                 "spec/v3 files/v3-url.csc",
         | 
| 72 | 
            +
                 "spec/xml_spec.rb"
         | 
| 47 73 | 
             
              ]
         | 
| 48 74 | 
             
              s.homepage = %q{http://github.com/jmah/cinesync}
         | 
| 49 75 | 
             
              s.rdoc_options = ["--charset=UTF-8"]
         | 
| @@ -51,7 +77,16 @@ Gem::Specification.new do |s| | |
| 51 77 | 
             
              s.rubygems_version = %q{1.3.6}
         | 
| 52 78 | 
             
              s.summary = %q{Library for scripting the cineSync collaborative video review tool}
         | 
| 53 79 | 
             
              s.test_files = [
         | 
| 54 | 
            -
                " | 
| 80 | 
            +
                "spec/cinesync_spec.rb",
         | 
| 81 | 
            +
                 "spec/event_handler_spec.rb",
         | 
| 82 | 
            +
                 "spec/frame_annotation_spec.rb",
         | 
| 83 | 
            +
                 "spec/media_file_spec.rb",
         | 
| 84 | 
            +
                 "spec/media_locator_spec.rb",
         | 
| 85 | 
            +
                 "spec/session_spec.rb",
         | 
| 86 | 
            +
                 "spec/spec_helper.rb",
         | 
| 87 | 
            +
                 "spec/xml_spec.rb",
         | 
| 88 | 
            +
                 "examples/Export Notes to CSV.rb",
         | 
| 89 | 
            +
                 "examples/Start Session.rb"
         | 
| 55 90 | 
             
              ]
         | 
| 56 91 |  | 
| 57 92 | 
             
              if s.respond_to? :specification_version then
         | 
| @@ -61,16 +96,16 @@ Gem::Specification.new do |s| | |
| 61 96 | 
             
                if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
         | 
| 62 97 | 
             
                  s.add_runtime_dependency(%q<activesupport>, [">= 2.3"])
         | 
| 63 98 | 
             
                  s.add_runtime_dependency(%q<andand>, [">= 1.3.1"])
         | 
| 64 | 
            -
                  s. | 
| 99 | 
            +
                  s.add_development_dependency(%q<bacon>, [">= 1.0"])
         | 
| 65 100 | 
             
                else
         | 
| 66 101 | 
             
                  s.add_dependency(%q<activesupport>, [">= 2.3"])
         | 
| 67 102 | 
             
                  s.add_dependency(%q<andand>, [">= 1.3.1"])
         | 
| 68 | 
            -
                  s.add_dependency(%q< | 
| 103 | 
            +
                  s.add_dependency(%q<bacon>, [">= 1.0"])
         | 
| 69 104 | 
             
                end
         | 
| 70 105 | 
             
              else
         | 
| 71 106 | 
             
                s.add_dependency(%q<activesupport>, [">= 2.3"])
         | 
| 72 107 | 
             
                s.add_dependency(%q<andand>, [">= 1.3.1"])
         | 
| 73 | 
            -
                s.add_dependency(%q< | 
| 108 | 
            +
                s.add_dependency(%q<bacon>, [">= 1.0"])
         | 
| 74 109 | 
             
              end
         | 
| 75 110 | 
             
            end
         | 
| 76 111 |  | 
| 
            File without changes
         | 
| @@ -0,0 +1,17 @@ | |
| 1 | 
            +
            #!/usr/bin/ruby
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            require 'rubygems'
         | 
| 4 | 
            +
            require 'cinesync'
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            if ARGV.empty?
         | 
| 7 | 
            +
              $stderr.puts("Usage: #{$0} <file.mov> ...")
         | 
| 8 | 
            +
              exit 1
         | 
| 9 | 
            +
            end
         | 
| 10 | 
            +
             | 
| 11 | 
            +
             | 
| 12 | 
            +
            # Create the session and add media from command-line arguments
         | 
| 13 | 
            +
            session = CineSync::Session.new
         | 
| 14 | 
            +
            session.media = ARGV.map {|path| CineSync::MediaFile.new(path) }
         | 
| 15 | 
            +
             | 
| 16 | 
            +
            # Open the session
         | 
| 17 | 
            +
            CineSync::Commands.open_session!(session)
         | 
| @@ -0,0 +1,50 @@ | |
| 1 | 
            +
            require 'uri'
         | 
| 2 | 
            +
            require 'cgi'
         | 
| 3 | 
            +
            require 'tmpdir'
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            module CineSync
         | 
| 6 | 
            +
              module Commands
         | 
| 7 | 
            +
                class <<self
         | 
| 8 | 
            +
                  def opens_url(*syms)
         | 
| 9 | 
            +
                    syms.each do |sym|
         | 
| 10 | 
            +
                      self.class.send(:define_method, :"#{sym}!") {|*args| CineSync::UI.open_url(send(sym, *args)) }
         | 
| 11 | 
            +
                    end
         | 
| 12 | 
            +
                  end
         | 
| 13 | 
            +
                end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                opens_url :open_session_file, :create_session, :join_session, :run_script
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                def self.open_session_file(path, merge_with_existing = true)
         | 
| 18 | 
            +
                  op = merge_with_existing ? 'merge' : 'replace'
         | 
| 19 | 
            +
                  "cinesync://file/#{op}?path=#{CGI.escape(path)}"
         | 
| 20 | 
            +
                end
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                def self.create_session(username = nil, password = nil)
         | 
| 23 | 
            +
                  "cinesync://session/new" + if username
         | 
| 24 | 
            +
                    "?username=#{CGI.escape(username)}" + if password
         | 
| 25 | 
            +
                      "&password=#{CGI.escape(password)}"
         | 
| 26 | 
            +
                    else '' end
         | 
| 27 | 
            +
                  else '' end
         | 
| 28 | 
            +
                end
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                def self.join_session(session_key)
         | 
| 31 | 
            +
                  "cinesync://session/#{URI.escape(session_key)}"
         | 
| 32 | 
            +
                end
         | 
| 33 | 
            +
             | 
| 34 | 
            +
                def self.run_script(script_name, query = nil)
         | 
| 35 | 
            +
                  "cinesync://script/#{URI.escape(script_name)}#{query ? "?#{query}" : ''}"
         | 
| 36 | 
            +
                end
         | 
| 37 | 
            +
             | 
| 38 | 
            +
             | 
| 39 | 
            +
                opens_url :open_session
         | 
| 40 | 
            +
             | 
| 41 | 
            +
                IllegalFileChars = /[^\w ~!@#\$%&\(\)_\-\+=\[\]\{\}',\.]/
         | 
| 42 | 
            +
             | 
| 43 | 
            +
                def self.open_session(session, name = nil, merge_with_existing = true)
         | 
| 44 | 
            +
                  name ||= "untitled session"
         | 
| 45 | 
            +
                  path = File.join(Dir.tmpdir, name.gsub(IllegalFileChars, '_') + ".csc")
         | 
| 46 | 
            +
                  File.open(path, "w") {|f| f.puts session.to_xml }
         | 
| 47 | 
            +
                  open_session_file(path, merge_with_existing)
         | 
| 48 | 
            +
                end
         | 
| 49 | 
            +
              end
         | 
| 50 | 
            +
            end
         | 
    
        data/lib/cinesync/media_file.rb
    CHANGED
    
    | @@ -100,7 +100,7 @@ module CineSync | |
| 100 100 | 
             
                    maybe_uri = URI::parse(s) rescue nil
         | 
| 101 101 |  | 
| 102 102 | 
             
                    if File.exist? s
         | 
| 103 | 
            -
                      @path = s
         | 
| 103 | 
            +
                      @path = File.expand_path(s)
         | 
| 104 104 | 
             
                      @short_hash = CineSync::short_hash(@path)
         | 
| 105 105 | 
             
                    elsif maybe_uri and maybe_uri.scheme
         | 
| 106 106 | 
             
                      # The argument could be parsed as a URI (use it as a URL)
         | 
| @@ -110,7 +110,12 @@ module CineSync | |
| 110 110 | 
             
                      @short_hash = s
         | 
| 111 111 | 
             
                    else
         | 
| 112 112 | 
             
                      # Finally, assume it's a file path
         | 
| 113 | 
            -
                       | 
| 113 | 
            +
                      if s =~ /^[A-Z]:[\\\/]/
         | 
| 114 | 
            +
                        # Looks like an absolute DOS path; let it through
         | 
| 115 | 
            +
                        @path = s
         | 
| 116 | 
            +
                      else
         | 
| 117 | 
            +
                        @path = File.expand_path(s)
         | 
| 118 | 
            +
                      end
         | 
| 114 119 | 
             
                    end
         | 
| 115 120 | 
             
                  end
         | 
| 116 121 | 
             
                end
         | 
    
        data/lib/cinesync/xml.rb
    CHANGED
    
    | @@ -1,6 +1,5 @@ | |
| 1 1 | 
             
            require 'active_support'
         | 
| 2 2 | 
             
            require 'andand'
         | 
| 3 | 
            -
            require 'builder'
         | 
| 4 3 | 
             
            require 'rexml/document'
         | 
| 5 4 | 
             
            require 'uri'
         | 
| 6 5 |  | 
| @@ -152,7 +151,7 @@ module CineSync | |
| 152 151 | 
             
                    m.notes = elem.elements['notes'].andand.text || ''
         | 
| 153 152 |  | 
| 154 153 | 
             
                    elem.get_elements('annotation').each do |ann_elem|
         | 
| 155 | 
            -
                      FrameAnnotation.load(ann_elem | 
| 154 | 
            +
                      m.annotations << FrameAnnotation.load(ann_elem)
         | 
| 156 155 | 
             
                    end
         | 
| 157 156 |  | 
| 158 157 | 
             
                    # Load optional structures
         | 
| @@ -424,9 +423,9 @@ module CineSync | |
| 424 423 | 
             
                end
         | 
| 425 424 |  | 
| 426 425 |  | 
| 427 | 
            -
                def self.load(elem | 
| 428 | 
            -
                  returning  | 
| 429 | 
            -
                    ann.notes = elem.elements['notes'].andand.text ||  | 
| 426 | 
            +
                def self.load(elem)
         | 
| 427 | 
            +
                  returning self.new(elem.attribute('frame').value.to_i) do |ann|
         | 
| 428 | 
            +
                    ann.notes = elem.elements['notes'].andand.text || ''
         | 
| 430 429 | 
             
                    DrawingObjectElements.each do |obj_name|
         | 
| 431 430 | 
             
                      ann.drawing_objects += elem.get_elements(obj_name)
         | 
| 432 431 | 
             
                    end
         | 
    
        data/lib/cinesync.rb
    CHANGED
    
    | @@ -1,7 +1,3 @@ | |
| 1 | 
            -
            Dir["#{File.dirname(__FILE__)}/vendor/gems/**"].map do |dir|
         | 
| 2 | 
            -
              $: << (File.directory?(lib = "#{dir}/lib") ? lib : dir)
         | 
| 3 | 
            -
            end
         | 
| 4 | 
            -
             | 
| 5 1 | 
             
            require 'cinesync/session'
         | 
| 6 2 | 
             
            require 'cinesync/media_file'
         | 
| 7 3 | 
             
            require 'cinesync/play_range'
         | 
| @@ -11,6 +7,7 @@ require 'cinesync/mask' | |
| 11 7 | 
             
            require 'cinesync/color_grading'
         | 
| 12 8 | 
             
            require 'cinesync/xml'
         | 
| 13 9 | 
             
            require 'cinesync/event_handler'
         | 
| 10 | 
            +
            require 'cinesync/commands'
         | 
| 14 11 | 
             
            require 'cinesync/ui'
         | 
| 15 12 | 
             
            require 'digest'
         | 
| 16 13 |  | 
| @@ -39,8 +36,8 @@ module CineSync | |
| 39 36 | 
             
                end
         | 
| 40 37 | 
             
              end
         | 
| 41 38 |  | 
| 42 | 
            -
              def self.event_handler
         | 
| 43 | 
            -
                session = Session::load( | 
| 44 | 
            -
                yield CineSync::EventHandler.new( | 
| 39 | 
            +
              def self.event_handler(argv = ARGV, stdin = $stdin)
         | 
| 40 | 
            +
                session = Session::load(stdin) rescue nil
         | 
| 41 | 
            +
                yield CineSync::EventHandler.new(argv, session)
         | 
| 45 42 | 
             
              end
         | 
| 46 43 | 
             
            end
         | 
    
        data/spec/.bacon
    ADDED
    
    | 
            File without changes
         | 
| @@ -0,0 +1,12 @@ | |
| 1 | 
            +
            $: << File.expand_path(File.dirname(__FILE__))
         | 
| 2 | 
            +
            require 'spec_helper'
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            describe "cineSync utilities" do
         | 
| 5 | 
            +
              it "correctly hashes big file" do
         | 
| 6 | 
            +
                CineSync.short_hash("/Volumes/Oyama/Streams/cineSync Test Files/movies/nasa_shuttle_m420p.mov").should == "08e5628d51b14278f73f36afebf0506afc2bfcf8"
         | 
| 7 | 
            +
              end
         | 
| 8 | 
            +
             | 
| 9 | 
            +
              it "correctly hashes small file" do
         | 
| 10 | 
            +
                CineSync.short_hash("spec/small.txt").should == '1e40efb84050f92618e2c430742f44254771cf6b'
         | 
| 11 | 
            +
              end
         | 
| 12 | 
            +
            end
         | 
| @@ -0,0 +1,66 @@ | |
| 1 | 
            +
            $: << File.expand_path(File.dirname(__FILE__))
         | 
| 2 | 
            +
            require 'spec_helper'
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            describe "event handler" do
         | 
| 5 | 
            +
              before do
         | 
| 6 | 
            +
                @example_path = File.join("spec", "v3 files", "v3-basic.csc")
         | 
| 7 | 
            +
                @online_args = ["--key=ASDF0000", "--save-format=JPEG", "--save-dir=/tmp/cinesync"]
         | 
| 8 | 
            +
                @offline_args = ["--key=_OFFLINE_", "--save-format=PNG", "--save-dir=/tmp/cinesync"]
         | 
| 9 | 
            +
                @url_args = ["--key=URL1111", "--save-format=JPEG", "--url=cinesync://script/myscript?q=hi"]
         | 
| 10 | 
            +
                @handler_run = false
         | 
| 11 | 
            +
              end
         | 
| 12 | 
            +
             | 
| 13 | 
            +
              it "should load session from stdin" do
         | 
| 14 | 
            +
                File.open(@example_path, "r") do |f|
         | 
| 15 | 
            +
                  CineSync.event_handler(@online_args, f) do |evt|
         | 
| 16 | 
            +
                    evt.session.user_data.should == "sessionUserData blah bloo blee"
         | 
| 17 | 
            +
                    evt.session.media.length.should == 3
         | 
| 18 | 
            +
                    evt.session.notes.should == "These are my session notes.\nnewline."
         | 
| 19 | 
            +
                    evt.session.should.be.valid?
         | 
| 20 | 
            +
                    @handler_run = true
         | 
| 21 | 
            +
                  end
         | 
| 22 | 
            +
                end
         | 
| 23 | 
            +
                @handler_run.should.be.true?
         | 
| 24 | 
            +
              end
         | 
| 25 | 
            +
             | 
| 26 | 
            +
              it "should parse online arguments" do
         | 
| 27 | 
            +
                File.open(@example_path, "r") do |f|
         | 
| 28 | 
            +
                  CineSync.event_handler(@online_args, f) do |evt|
         | 
| 29 | 
            +
                    evt.should.not.be.offline?
         | 
| 30 | 
            +
                    evt.session_key.should == "ASDF0000"
         | 
| 31 | 
            +
                    evt.save_format.should == :jpeg
         | 
| 32 | 
            +
                    evt.save_parent.to_s.should == "/tmp/cinesync"
         | 
| 33 | 
            +
                    evt.url.should.be.nil?
         | 
| 34 | 
            +
                    @handler_run = true
         | 
| 35 | 
            +
                  end
         | 
| 36 | 
            +
                end
         | 
| 37 | 
            +
                @handler_run.should.be.true?
         | 
| 38 | 
            +
              end
         | 
| 39 | 
            +
             | 
| 40 | 
            +
              it "should parse offline arguments" do
         | 
| 41 | 
            +
                File.open(@example_path, "r") do |f|
         | 
| 42 | 
            +
                  CineSync.event_handler(@offline_args, f) do |evt|
         | 
| 43 | 
            +
                    evt.should.be.offline?
         | 
| 44 | 
            +
                    evt.session_key.should.be.nil?
         | 
| 45 | 
            +
                    evt.save_format.should == :png
         | 
| 46 | 
            +
                    evt.save_parent.to_s.should == "/tmp/cinesync"
         | 
| 47 | 
            +
                    evt.url.should.be.nil?
         | 
| 48 | 
            +
                    @handler_run = true
         | 
| 49 | 
            +
                  end
         | 
| 50 | 
            +
                end
         | 
| 51 | 
            +
                @handler_run.should.be.true?
         | 
| 52 | 
            +
              end
         | 
| 53 | 
            +
             | 
| 54 | 
            +
              it "should parse url argument" do
         | 
| 55 | 
            +
                File.open(@example_path, "r") do |f|
         | 
| 56 | 
            +
                  CineSync.event_handler(@url_args, f) do |evt|
         | 
| 57 | 
            +
                    evt.should.not.be.offline?
         | 
| 58 | 
            +
                    evt.session_key.should == "URL1111"
         | 
| 59 | 
            +
                    evt.save_format.should == :jpeg
         | 
| 60 | 
            +
                    evt.url.should == "cinesync://script/myscript?q=hi"
         | 
| 61 | 
            +
                    @handler_run = true
         | 
| 62 | 
            +
                  end
         | 
| 63 | 
            +
                end
         | 
| 64 | 
            +
                @handler_run.should.be.true?
         | 
| 65 | 
            +
              end
         | 
| 66 | 
            +
            end
         | 
| @@ -0,0 +1,33 @@ | |
| 1 | 
            +
            $: << File.expand_path(File.dirname(__FILE__))
         | 
| 2 | 
            +
            require 'spec_helper'
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            describe "frame annotations" do
         | 
| 5 | 
            +
              before do
         | 
| 6 | 
            +
                @obj = CineSync::FrameAnnotation.new(5)
         | 
| 7 | 
            +
              end
         | 
| 8 | 
            +
             | 
| 9 | 
            +
              it "should validate frame number" do
         | 
| 10 | 
            +
                @obj.frame.should == 5
         | 
| 11 | 
            +
                @obj.should.be.valid?
         | 
| 12 | 
            +
                CineSync::FrameAnnotation.new(0).should.not.be.valid? # 1-based, so 0 is invalid
         | 
| 13 | 
            +
                CineSync::FrameAnnotation.new(-5).should.not.be.valid?
         | 
| 14 | 
            +
                CineSync::FrameAnnotation.new("three").should.not.be.valid?
         | 
| 15 | 
            +
              end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
              it "should store notes" do
         | 
| 18 | 
            +
                @obj.notes.should == ""
         | 
| 19 | 
            +
                @obj.notes = "asdf"
         | 
| 20 | 
            +
                @obj.notes.should == "asdf"
         | 
| 21 | 
            +
                @obj.should.be.valid?
         | 
| 22 | 
            +
              end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
              it "should start with no drawing objects" do
         | 
| 25 | 
            +
                @obj.drawing_objects.should.be.empty?
         | 
| 26 | 
            +
              end
         | 
| 27 | 
            +
             | 
| 28 | 
            +
              it "should start in default state" do
         | 
| 29 | 
            +
                @obj.should.be.default?
         | 
| 30 | 
            +
                @obj.notes = "asdf"
         | 
| 31 | 
            +
                @obj.should.not.be.default?
         | 
| 32 | 
            +
              end
         | 
| 33 | 
            +
            end
         | 
| @@ -0,0 +1,125 @@ | |
| 1 | 
            +
            $: << File.expand_path(File.dirname(__FILE__))
         | 
| 2 | 
            +
            require 'spec_helper'
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            shared "single and group movie" do
         | 
| 5 | 
            +
              it "should store user data" do
         | 
| 6 | 
            +
                @obj.user_data.should.not.be.nil?
         | 
| 7 | 
            +
                @obj.user_data.should.be.empty?
         | 
| 8 | 
            +
                @obj.user_data = "My custom data"
         | 
| 9 | 
            +
                @obj.user_data.should == "My custom data"
         | 
| 10 | 
            +
                @obj.should.be.valid?
         | 
| 11 | 
            +
              end
         | 
| 12 | 
            +
             | 
| 13 | 
            +
              it "should have an active property" do
         | 
| 14 | 
            +
                @obj.should.not.be.active?
         | 
| 15 | 
            +
                @obj.active = true
         | 
| 16 | 
            +
                @obj.should.be.active?
         | 
| 17 | 
            +
                @obj.should.be.valid?
         | 
| 18 | 
            +
              end
         | 
| 19 | 
            +
             | 
| 20 | 
            +
              it "should track the current frame" do
         | 
| 21 | 
            +
                @obj.current_frame.should == 1
         | 
| 22 | 
            +
                @obj.current_frame = 99
         | 
| 23 | 
            +
                @obj.current_frame.should == 99
         | 
| 24 | 
            +
                @obj.should.be.valid?
         | 
| 25 | 
            +
             | 
| 26 | 
            +
                @obj.current_frame = -1
         | 
| 27 | 
            +
                @obj.current_frame.should == -1
         | 
| 28 | 
            +
                @obj.should.not.be.valid?
         | 
| 29 | 
            +
              end
         | 
| 30 | 
            +
             | 
| 31 | 
            +
              it "should belong to groups" do
         | 
| 32 | 
            +
                @obj.groups.should.be.empty?
         | 
| 33 | 
            +
                @obj.groups << "My group"
         | 
| 34 | 
            +
                @obj.groups.should.be == ["My group"]
         | 
| 35 | 
            +
              end
         | 
| 36 | 
            +
            end
         | 
| 37 | 
            +
             | 
| 38 | 
            +
             | 
| 39 | 
            +
            describe "cineSync media file" do
         | 
| 40 | 
            +
              before do
         | 
| 41 | 
            +
                @obj = CineSync::MediaFile.new("ftp://ftp.cinesync.com/demo.mov")
         | 
| 42 | 
            +
              end
         | 
| 43 | 
            +
             | 
| 44 | 
            +
              behaves_like "single and group movie"
         | 
| 45 | 
            +
             | 
| 46 | 
            +
              it "should be valid by default" do
         | 
| 47 | 
            +
                @obj.should.be.valid?
         | 
| 48 | 
            +
              end
         | 
| 49 | 
            +
             | 
| 50 | 
            +
              it "should create annotations on demand" do
         | 
| 51 | 
            +
                @obj.annotations.should.be.empty?
         | 
| 52 | 
            +
                ann_on_demand = @obj.annotations[32]
         | 
| 53 | 
            +
                ann_on_demand.should.not.be.nil?
         | 
| 54 | 
            +
                ann_on_demand.notes.should.not.be.nil?
         | 
| 55 | 
            +
                ann_on_demand.notes.should.be.empty?
         | 
| 56 | 
            +
             | 
| 57 | 
            +
                # Check that the instance we have is shared with the annotations hash
         | 
| 58 | 
            +
                ann_on_demand.notes = 'notes on frame 32'
         | 
| 59 | 
            +
                @obj.annotations[32].notes.should == ann_on_demand.notes
         | 
| 60 | 
            +
              end
         | 
| 61 | 
            +
             | 
| 62 | 
            +
              it "should validate annotation frame number" do
         | 
| 63 | 
            +
                ann = @obj.annotations[3]
         | 
| 64 | 
            +
                ann.should.be.valid?
         | 
| 65 | 
            +
                @obj.should.be.valid?
         | 
| 66 | 
            +
             | 
| 67 | 
            +
                ann2 = @obj.annotations[-5]
         | 
| 68 | 
            +
                ann2.should.not.be.valid?
         | 
| 69 | 
            +
                @obj.should.not.be.valid?
         | 
| 70 | 
            +
                @obj.annotations.delete(-5)
         | 
| 71 | 
            +
                @obj.should.be.valid?
         | 
| 72 | 
            +
              end
         | 
| 73 | 
            +
             | 
| 74 | 
            +
              it "should require a locator for validity" do
         | 
| 75 | 
            +
                mf_loc = CineSync::MediaFile.new("/Volumes/Oyama/Streams/cineSync Test Files/movies/nasa_shuttle_m420p.mov")
         | 
| 76 | 
            +
                mf_loc.should.be.valid?
         | 
| 77 | 
            +
                mf_noloc = CineSync::MediaFile.new
         | 
| 78 | 
            +
                mf_noloc.should.not.be.valid?
         | 
| 79 | 
            +
              end
         | 
| 80 | 
            +
             | 
| 81 | 
            +
              it "should get name from locator" do
         | 
| 82 | 
            +
                @obj.name.should == "demo.mov"
         | 
| 83 | 
            +
             | 
| 84 | 
            +
                @obj.name = ""
         | 
| 85 | 
            +
                @obj.name.should.be.empty?
         | 
| 86 | 
            +
                @obj.should.not.be.valid?
         | 
| 87 | 
            +
             | 
| 88 | 
            +
                @obj.name = "custom_name"
         | 
| 89 | 
            +
                @obj.name.should == "custom_name"
         | 
| 90 | 
            +
                @obj.should.be.valid?
         | 
| 91 | 
            +
             | 
| 92 | 
            +
                CineSync::MediaFile.new.name.should == ""
         | 
| 93 | 
            +
              end
         | 
| 94 | 
            +
            end
         | 
| 95 | 
            +
             | 
| 96 | 
            +
             | 
| 97 | 
            +
            describe "group movies" do
         | 
| 98 | 
            +
              before do
         | 
| 99 | 
            +
                @obj = CineSync::GroupMovie.new("grp")
         | 
| 100 | 
            +
              end
         | 
| 101 | 
            +
             | 
| 102 | 
            +
              behaves_like "single and group movie"
         | 
| 103 | 
            +
             | 
| 104 | 
            +
              it "should be based on a group" do
         | 
| 105 | 
            +
                @obj.group.should == "grp"
         | 
| 106 | 
            +
                @obj.should.be.valid?
         | 
| 107 | 
            +
             | 
| 108 | 
            +
                @obj.group = ""
         | 
| 109 | 
            +
                @obj.group.should.be.empty?
         | 
| 110 | 
            +
                @obj.should.not.be.valid?
         | 
| 111 | 
            +
              end
         | 
| 112 | 
            +
             | 
| 113 | 
            +
              it "should accept all files group" do
         | 
| 114 | 
            +
                empty = CineSync::GroupMovie.new("")
         | 
| 115 | 
            +
                empty.group.should == ""
         | 
| 116 | 
            +
                empty.should.not.be.valid?
         | 
| 117 | 
            +
             | 
| 118 | 
            +
                empty.group = CineSync::AllFilesGroup
         | 
| 119 | 
            +
                empty.should.be.valid?
         | 
| 120 | 
            +
              end
         | 
| 121 | 
            +
             | 
| 122 | 
            +
              it "should trigger pro features" do
         | 
| 123 | 
            +
                @obj.should.uses_pro_features?
         | 
| 124 | 
            +
              end
         | 
| 125 | 
            +
            end
         | 
| @@ -0,0 +1,68 @@ | |
| 1 | 
            +
            $: << File.expand_path(File.dirname(__FILE__))
         | 
| 2 | 
            +
            require 'spec_helper'
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            describe "media locators" do
         | 
| 5 | 
            +
              it "should represent empty locators" do
         | 
| 6 | 
            +
                ml = CineSync::MediaLocator.new
         | 
| 7 | 
            +
                ml.should.not.be.valid?
         | 
| 8 | 
            +
                ml.path.should.be.nil?
         | 
| 9 | 
            +
                ml.url.should.be.nil?
         | 
| 10 | 
            +
                ml.short_hash.should.be.nil?
         | 
| 11 | 
            +
              end
         | 
| 12 | 
            +
             | 
| 13 | 
            +
              it "should accept a url location" do
         | 
| 14 | 
            +
                url = "http://example.com/random_file.mov"
         | 
| 15 | 
            +
                ml = CineSync::MediaLocator.new(url)
         | 
| 16 | 
            +
                ml.should.be.valid?
         | 
| 17 | 
            +
                ml.path.should.be.nil?
         | 
| 18 | 
            +
                ml.url.to_s.should == url
         | 
| 19 | 
            +
                ml.short_hash.should.be.nil?
         | 
| 20 | 
            +
             | 
| 21 | 
            +
                ml.url.scheme.should == "http"
         | 
| 22 | 
            +
                ml.url.host.should == "example.com"
         | 
| 23 | 
            +
                ml.url.path.should == "/random_file.mov"
         | 
| 24 | 
            +
              end
         | 
| 25 | 
            +
             | 
| 26 | 
            +
              it "should set short hash for an existing path" do
         | 
| 27 | 
            +
                path = "/Volumes/Oyama/Streams/cineSync Test Files/movies/nasa_shuttle_m420p.mov"
         | 
| 28 | 
            +
                ml = CineSync::MediaLocator.new(path)
         | 
| 29 | 
            +
                ml.should.be.valid?
         | 
| 30 | 
            +
                ml.path.should == path
         | 
| 31 | 
            +
                ml.url.should.be.nil?
         | 
| 32 | 
            +
                ml.short_hash.should == "08e5628d51b14278f73f36afebf0506afc2bfcf8"
         | 
| 33 | 
            +
              end
         | 
| 34 | 
            +
             | 
| 35 | 
            +
              it "should accept path to non-existent file" do
         | 
| 36 | 
            +
                path = "/path/to/nonexistent/file.mov"
         | 
| 37 | 
            +
                ml = CineSync::MediaLocator.new(path)
         | 
| 38 | 
            +
                ml.should.be.valid?
         | 
| 39 | 
            +
                ml.path.should == path
         | 
| 40 | 
            +
                ml.url.should.be.nil?
         | 
| 41 | 
            +
                ml.short_hash.should.be.nil?
         | 
| 42 | 
            +
              end
         | 
| 43 | 
            +
             | 
| 44 | 
            +
              it "should accept dos path" do
         | 
| 45 | 
            +
                path = 'C:\path\to\myMovie.mov'
         | 
| 46 | 
            +
                ml = CineSync::MediaLocator.new(path)
         | 
| 47 | 
            +
                ml.should.be.valid?
         | 
| 48 | 
            +
                ml.path.should == path
         | 
| 49 | 
            +
                ml.url.should.be.nil?
         | 
| 50 | 
            +
                ml.short_hash.should.be.nil?
         | 
| 51 | 
            +
              end
         | 
| 52 | 
            +
             | 
| 53 | 
            +
              it "should accept short hash as locator" do
         | 
| 54 | 
            +
                hash = "08e5628d51b14278f73f36afebf0506afc2bfcf8"
         | 
| 55 | 
            +
                ml = CineSync::MediaLocator.new(hash)
         | 
| 56 | 
            +
                ml.should.be.valid?
         | 
| 57 | 
            +
                ml.path.should.be.nil?
         | 
| 58 | 
            +
                ml.url.should.be.nil?
         | 
| 59 | 
            +
                ml.short_hash.should == hash
         | 
| 60 | 
            +
              end
         | 
| 61 | 
            +
             | 
| 62 | 
            +
              it "should convert relative paths to absolute" do
         | 
| 63 | 
            +
                rel_path = "../nonexist-test.mov"
         | 
| 64 | 
            +
                abs_path = File.expand_path(rel_path)
         | 
| 65 | 
            +
                ml = CineSync::MediaLocator.new(rel_path)
         | 
| 66 | 
            +
                ml.path.should == abs_path
         | 
| 67 | 
            +
              end
         | 
| 68 | 
            +
            end
         |