vj-sdk 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/.gitignore +4 -0
 - data/LICENSE +20 -0
 - data/README.markdown +0 -0
 - data/README.rdoc +7 -0
 - data/Rakefile +70 -0
 - data/VERSION.yml +4 -0
 - data/lib/core_ext/cgi.rb +12 -0
 - data/lib/core_ext/hash.rb +52 -0
 - data/lib/core_ext/object.rb +15 -0
 - data/lib/core_ext/string.rb +11 -0
 - data/lib/sdk_connection_harness.rb +101 -0
 - data/lib/videojuicer/asset/audio.rb +13 -0
 - data/lib/videojuicer/asset/base.rb +80 -0
 - data/lib/videojuicer/asset/flash.rb +8 -0
 - data/lib/videojuicer/asset/image.rb +10 -0
 - data/lib/videojuicer/asset/text.rb +8 -0
 - data/lib/videojuicer/asset/video.rb +22 -0
 - data/lib/videojuicer/campaign.rb +19 -0
 - data/lib/videojuicer/campaign_policy.rb +116 -0
 - data/lib/videojuicer/criterion/base.rb +56 -0
 - data/lib/videojuicer/criterion/date_range.rb +15 -0
 - data/lib/videojuicer/criterion/geolocation.rb +18 -0
 - data/lib/videojuicer/criterion/request.rb +15 -0
 - data/lib/videojuicer/criterion/time.rb +15 -0
 - data/lib/videojuicer/criterion/week_day.rb +20 -0
 - data/lib/videojuicer/oauth/multipart_helper.rb +96 -0
 - data/lib/videojuicer/oauth/proxy_factory.rb +18 -0
 - data/lib/videojuicer/oauth/request_proxy.rb +280 -0
 - data/lib/videojuicer/presentation.rb +38 -0
 - data/lib/videojuicer/preset.rb +29 -0
 - data/lib/videojuicer/promo/base.rb +72 -0
 - data/lib/videojuicer/resource/base.rb +175 -0
 - data/lib/videojuicer/resource/collection.rb +36 -0
 - data/lib/videojuicer/resource/embeddable.rb +30 -0
 - data/lib/videojuicer/resource/errors.rb +17 -0
 - data/lib/videojuicer/resource/inferrable.rb +141 -0
 - data/lib/videojuicer/resource/property_registry.rb +145 -0
 - data/lib/videojuicer/resource/relationships/belongs_to.rb +39 -0
 - data/lib/videojuicer/resource/types.rb +28 -0
 - data/lib/videojuicer/session.rb +74 -0
 - data/lib/videojuicer/shared/configurable.rb +103 -0
 - data/lib/videojuicer/shared/exceptions.rb +32 -0
 - data/lib/videojuicer/user.rb +43 -0
 - data/lib/videojuicer.rb +110 -0
 - data/spec/assets/audio_spec.rb +25 -0
 - data/spec/assets/flash_spec.rb +24 -0
 - data/spec/assets/image_spec.rb +25 -0
 - data/spec/assets/text_spec.rb +24 -0
 - data/spec/assets/video_spec.rb +25 -0
 - data/spec/belongs_to_spec.rb +45 -0
 - data/spec/campaign_policy_spec.rb +41 -0
 - data/spec/campaign_spec.rb +25 -0
 - data/spec/collection_spec.rb +31 -0
 - data/spec/criterion/date_range_spec.rb +24 -0
 - data/spec/criterion/geolocation_spec.rb +23 -0
 - data/spec/criterion/request_spec.rb +23 -0
 - data/spec/criterion/time_spec.rb +23 -0
 - data/spec/criterion/week_day_spec.rb +23 -0
 - data/spec/files/audio.mp3 +0 -0
 - data/spec/files/empty_file +0 -0
 - data/spec/files/flash.swf +0 -0
 - data/spec/files/image.jpg +0 -0
 - data/spec/files/text.txt +1 -0
 - data/spec/files/video.mov +0 -0
 - data/spec/helpers/be_equal_to.rb +26 -0
 - data/spec/helpers/spec_fixtures.rb +227 -0
 - data/spec/helpers/spec_helper.rb +53 -0
 - data/spec/presentation_spec.rb +25 -0
 - data/spec/preset_spec.rb +30 -0
 - data/spec/promos/audio_spec.rb +23 -0
 - data/spec/promos/image_spec.rb +24 -0
 - data/spec/promos/text_spec.rb +23 -0
 - data/spec/promos/video_spec.rb +23 -0
 - data/spec/property_registry_spec.rb +130 -0
 - data/spec/request_proxy_spec.rb +90 -0
 - data/spec/session_spec.rb +98 -0
 - data/spec/shared/asset_spec.rb +39 -0
 - data/spec/shared/configurable_spec.rb +75 -0
 - data/spec/shared/dependent_spec.rb +40 -0
 - data/spec/shared/embeddable_spec.rb +34 -0
 - data/spec/shared/model_spec.rb +74 -0
 - data/spec/shared/resource_spec.rb +140 -0
 - data/spec/spec.opts +3 -0
 - data/spec/user_spec.rb +42 -0
 - data/spec/videojuicer_spec.rb +122 -0
 - data/tasks/vj-core.rb +72 -0
 - data/vj-sdk.gemspec +168 -0
 - metadata +209 -0
 
| 
         @@ -0,0 +1,103 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            =begin
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
              Configurable is a mixin intended for internal use within the SDK.
         
     | 
| 
      
 4 
     | 
    
         
            +
              
         
     | 
| 
      
 5 
     | 
    
         
            +
              It provides a suite of helper methods to objects that use the scoped configuration
         
     | 
| 
      
 6 
     | 
    
         
            +
              system within the root Videojuicer module.
         
     | 
| 
      
 7 
     | 
    
         
            +
              
         
     | 
| 
      
 8 
     | 
    
         
            +
              Objects that are Configurable have a local configuration, which will always be 
         
     | 
| 
      
 9 
     | 
    
         
            +
              respected, and a shared configuration object which merges the current configuration
         
     | 
| 
      
 10 
     | 
    
         
            +
              scope with the local configuration.
         
     | 
| 
      
 11 
     | 
    
         
            +
              
         
     | 
| 
      
 12 
     | 
    
         
            +
              For instance:
         
     | 
| 
      
 13 
     | 
    
         
            +
              
         
     | 
| 
      
 14 
     | 
    
         
            +
                # Assuming that the Videojuicer default configuration is a simple hash containing {:in_a_scope=>false}
         
     | 
| 
      
 15 
     | 
    
         
            +
              
         
     | 
| 
      
 16 
     | 
    
         
            +
                a_configurable.configure! :foo=>"bar" # config[:foo] will ALWAYS == "bar" for this object.
         
     | 
| 
      
 17 
     | 
    
         
            +
                a_configurable.local_config #=> {:foo=>"bar"}
         
     | 
| 
      
 18 
     | 
    
         
            +
                a_configurable.config #=> {:in_a_scope=>false, :foo=>"bar"}
         
     | 
| 
      
 19 
     | 
    
         
            +
                
         
     | 
| 
      
 20 
     | 
    
         
            +
                # Now let's enter a scope:
         
     | 
| 
      
 21 
     | 
    
         
            +
                Videojuicer.enter_scope :in_a_scope=>true, :foo=>"not bar"
         
     | 
| 
      
 22 
     | 
    
         
            +
                
         
     | 
| 
      
 23 
     | 
    
         
            +
                a_configurable.local_config #=> {:foo=>"bar"}
         
     | 
| 
      
 24 
     | 
    
         
            +
                a_configurable.config #=> {:in_a_scope=>true, :foo=>"bar"}
         
     | 
| 
      
 25 
     | 
    
         
            +
                
         
     | 
| 
      
 26 
     | 
    
         
            +
                # And leave it again..
         
     | 
| 
      
 27 
     | 
    
         
            +
                Videojuicer.exit_scope
         
     | 
| 
      
 28 
     | 
    
         
            +
                
         
     | 
| 
      
 29 
     | 
    
         
            +
                a_configurable.local_config #=> {:foo=>"bar"}
         
     | 
| 
      
 30 
     | 
    
         
            +
                a_configurable.config #=> {:in_a_scope=>false, :foo=>"bar"}
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
            =end
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
            module Videojuicer
         
     | 
| 
      
 35 
     | 
    
         
            +
              module Configurable
         
     | 
| 
      
 36 
     | 
    
         
            +
                
         
     | 
| 
      
 37 
     | 
    
         
            +
                attr_accessor :local_config
         
     | 
| 
      
 38 
     | 
    
         
            +
                
         
     | 
| 
      
 39 
     | 
    
         
            +
                # Sets the local configuration for this Configurable.
         
     | 
| 
      
 40 
     | 
    
         
            +
                # The local configuration will always be respected regardless of the 
         
     | 
| 
      
 41 
     | 
    
         
            +
                # current controller scope.
         
     | 
| 
      
 42 
     | 
    
         
            +
                def configure!(options={})
         
     | 
| 
      
 43 
     | 
    
         
            +
                  self.local_config = options
         
     | 
| 
      
 44 
     | 
    
         
            +
                end
         
     | 
| 
      
 45 
     | 
    
         
            +
                
         
     | 
| 
      
 46 
     | 
    
         
            +
                # Returns the shared configuration, which is the current
         
     | 
| 
      
 47 
     | 
    
         
            +
                # controller scope merged with the local config.
         
     | 
| 
      
 48 
     | 
    
         
            +
                def config
         
     | 
| 
      
 49 
     | 
    
         
            +
                  Videojuicer.current_scope.merge(local_config || {})
         
     | 
| 
      
 50 
     | 
    
         
            +
                end
         
     | 
| 
      
 51 
     | 
    
         
            +
                
         
     | 
| 
      
 52 
     | 
    
         
            +
                # Executes a block of code within the scope of this Configurable's
         
     | 
| 
      
 53 
     | 
    
         
            +
                # local configuration.
         
     | 
| 
      
 54 
     | 
    
         
            +
                #
         
     | 
| 
      
 55 
     | 
    
         
            +
                # This is achieved by pushing the local configuration onto the controller's
         
     | 
| 
      
 56 
     | 
    
         
            +
                # scope stack, executing the given block and then exiting the scope. During
         
     | 
| 
      
 57 
     | 
    
         
            +
                # this procedure the local configuration on this object will remain unchanged.
         
     | 
| 
      
 58 
     | 
    
         
            +
                # 
         
     | 
| 
      
 59 
     | 
    
         
            +
                # Example:
         
     | 
| 
      
 60 
     | 
    
         
            +
                # Videojuicer.configure! :bar=>"baz"
         
     | 
| 
      
 61 
     | 
    
         
            +
                # configurable_a.configure! :foo=>"a"
         
     | 
| 
      
 62 
     | 
    
         
            +
                # configurable_b.configure! :foo=>"b"
         
     | 
| 
      
 63 
     | 
    
         
            +
                # 
         
     | 
| 
      
 64 
     | 
    
         
            +
                # configurable_a.scope do |config|
         
     | 
| 
      
 65 
     | 
    
         
            +
                #   config[:bar] #=> "baz"
         
     | 
| 
      
 66 
     | 
    
         
            +
                #   config[:foo] #=> "a"
         
     | 
| 
      
 67 
     | 
    
         
            +
                #   
         
     | 
| 
      
 68 
     | 
    
         
            +
                #   configurable_b.scope do |config|
         
     | 
| 
      
 69 
     | 
    
         
            +
                #     config[:foo] #=> "b"
         
     | 
| 
      
 70 
     | 
    
         
            +
                #   end
         
     | 
| 
      
 71 
     | 
    
         
            +
                #
         
     | 
| 
      
 72 
     | 
    
         
            +
                #   config[:foo] #=> "a"
         
     | 
| 
      
 73 
     | 
    
         
            +
                # end
         
     | 
| 
      
 74 
     | 
    
         
            +
                def scope(&block)
         
     | 
| 
      
 75 
     | 
    
         
            +
                  Videojuicer.enter_scope local_config
         
     | 
| 
      
 76 
     | 
    
         
            +
                  block_out = block.call(Videojuicer.current_scope)
         
     | 
| 
      
 77 
     | 
    
         
            +
                  Videojuicer.exit_scope
         
     | 
| 
      
 78 
     | 
    
         
            +
                  return block_out
         
     | 
| 
      
 79 
     | 
    
         
            +
                end
         
     | 
| 
      
 80 
     | 
    
         
            +
                
         
     | 
| 
      
 81 
     | 
    
         
            +
                # Retrieves the host from the configuration options.
         
     | 
| 
      
 82 
     | 
    
         
            +
                def host; config[:host]; end
         
     | 
| 
      
 83 
     | 
    
         
            +
                # Retrieves the port from the configuration options.
         
     | 
| 
      
 84 
     | 
    
         
            +
                def port; config[:port]; end
         
     | 
| 
      
 85 
     | 
    
         
            +
                # Retrieves the consumer_key from the configuration options.
         
     | 
| 
      
 86 
     | 
    
         
            +
                def consumer_key; config[:consumer_key]; end
         
     | 
| 
      
 87 
     | 
    
         
            +
                # Retrieves the consumer_secret from the configuration options.
         
     | 
| 
      
 88 
     | 
    
         
            +
                def consumer_secret; config[:consumer_secret]; end
         
     | 
| 
      
 89 
     | 
    
         
            +
                # Retrieves the token from the configuration options.
         
     | 
| 
      
 90 
     | 
    
         
            +
                def token; config[:token]; end
         
     | 
| 
      
 91 
     | 
    
         
            +
                # Retrieves the token_secret from the configuration options.
         
     | 
| 
      
 92 
     | 
    
         
            +
                def token_secret; config[:token_secret]; end
         
     | 
| 
      
 93 
     | 
    
         
            +
                # Retrieves the api_version from the configuration options.
         
     | 
| 
      
 94 
     | 
    
         
            +
                def api_version; config[:api_version]; end
         
     | 
| 
      
 95 
     | 
    
         
            +
                # Retrieves the protocol from the configuration options.
         
     | 
| 
      
 96 
     | 
    
         
            +
                def protocol; config[:protocol]; end
         
     | 
| 
      
 97 
     | 
    
         
            +
                # Retrieves the seed name from the configuration options.
         
     | 
| 
      
 98 
     | 
    
         
            +
                def seed_name; config[:seed_name]; end
         
     | 
| 
      
 99 
     | 
    
         
            +
                # Retrieves the user_id from the configuration options. Master tokens can be used to authenticate as any user.
         
     | 
| 
      
 100 
     | 
    
         
            +
                def user_id; config[:user_id]; end
         
     | 
| 
      
 101 
     | 
    
         
            +
                
         
     | 
| 
      
 102 
     | 
    
         
            +
              end
         
     | 
| 
      
 103 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,32 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module Videojuicer
         
     | 
| 
      
 2 
     | 
    
         
            +
              module Exceptions
         
     | 
| 
      
 3 
     | 
    
         
            +
               
         
     | 
| 
      
 4 
     | 
    
         
            +
                class NotAuthorised < ::StandardError; end
         
     | 
| 
      
 5 
     | 
    
         
            +
                
         
     | 
| 
      
 6 
     | 
    
         
            +
                # Raised when a method requiring instance-specific data from the remote API
         
     | 
| 
      
 7 
     | 
    
         
            +
                # is called on an object that does not exist remotely.
         
     | 
| 
      
 8 
     | 
    
         
            +
                class NoResource < ::RuntimeError; end
         
     | 
| 
      
 9 
     | 
    
         
            +
                
         
     | 
| 
      
 10 
     | 
    
         
            +
                # Raised when a record cannot be saved because it has attributes that are well rubbish.
         
     | 
| 
      
 11 
     | 
    
         
            +
                class InvalidRecord < ::RuntimeError; end
         
     | 
| 
      
 12 
     | 
    
         
            +
                
         
     | 
| 
      
 13 
     | 
    
         
            +
                # Raised when a request is completely buggered by the remote API.
         
     | 
| 
      
 14 
     | 
    
         
            +
                class RemoteApplicationError < ::StandardError; end
         
     | 
| 
      
 15 
     | 
    
         
            +
                
         
     | 
| 
      
 16 
     | 
    
         
            +
                # Raised when the remote resource refuses to carry out an action.
         
     | 
| 
      
 17 
     | 
    
         
            +
                class Forbidden < ::StandardError; end
         
     | 
| 
      
 18 
     | 
    
         
            +
                
         
     | 
| 
      
 19 
     | 
    
         
            +
                # Raised when status is 401
         
     | 
| 
      
 20 
     | 
    
         
            +
                class Unauthenticated < ::StandardError; end
         
     | 
| 
      
 21 
     | 
    
         
            +
                
         
     | 
| 
      
 22 
     | 
    
         
            +
                # Raised when status is 406
         
     | 
| 
      
 23 
     | 
    
         
            +
                class NotAcceptable < ::StandardError; end
         
     | 
| 
      
 24 
     | 
    
         
            +
                
         
     | 
| 
      
 25 
     | 
    
         
            +
                # Raised when status is 411
         
     | 
| 
      
 26 
     | 
    
         
            +
                class ContentLengthRequired < ::StandardError; end
         
     | 
| 
      
 27 
     | 
    
         
            +
                
         
     | 
| 
      
 28 
     | 
    
         
            +
                # Raised on an unclassified exception
         
     | 
| 
      
 29 
     | 
    
         
            +
                class UnhandledHTTPStatus < ::StandardError; end
         
     | 
| 
      
 30 
     | 
    
         
            +
                
         
     | 
| 
      
 31 
     | 
    
         
            +
              end
         
     | 
| 
      
 32 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,43 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module Videojuicer
         
     | 
| 
      
 2 
     | 
    
         
            +
              class User
         
     | 
| 
      
 3 
     | 
    
         
            +
                include Videojuicer::Resource
         
     | 
| 
      
 4 
     | 
    
         
            +
                include Videojuicer::Exceptions
         
     | 
| 
      
 5 
     | 
    
         
            +
                
         
     | 
| 
      
 6 
     | 
    
         
            +
                property :name, String
         
     | 
| 
      
 7 
     | 
    
         
            +
                property :login, String
         
     | 
| 
      
 8 
     | 
    
         
            +
                property :email, String
         
     | 
| 
      
 9 
     | 
    
         
            +
                property :password, String
         
     | 
| 
      
 10 
     | 
    
         
            +
                property :password_confirmation, String
         
     | 
| 
      
 11 
     | 
    
         
            +
                property :created_at, DateTime
         
     | 
| 
      
 12 
     | 
    
         
            +
                property :updated_at, DateTime
         
     | 
| 
      
 13 
     | 
    
         
            +
                
         
     | 
| 
      
 14 
     | 
    
         
            +
                # Authenticates the given login and password and returns
         
     | 
| 
      
 15 
     | 
    
         
            +
                # a user if the details are correct. Requires a Master token.
         
     | 
| 
      
 16 
     | 
    
         
            +
                def self.authenticate(login, password)
         
     | 
| 
      
 17 
     | 
    
         
            +
                  proxy = Videojuicer::OAuth::RequestProxy.new
         
     | 
| 
      
 18 
     | 
    
         
            +
                  begin
         
     | 
| 
      
 19 
     | 
    
         
            +
                    jobj = JSON.parse(proxy.get("/users/authenticate.json", :login=>login, :password=>password).body)
         
     | 
| 
      
 20 
     | 
    
         
            +
                    o = new(:id=>jobj["id"])
         
     | 
| 
      
 21 
     | 
    
         
            +
                    o.reload
         
     | 
| 
      
 22 
     | 
    
         
            +
                    return o
         
     | 
| 
      
 23 
     | 
    
         
            +
                  rescue NoResource =>e
         
     | 
| 
      
 24 
     | 
    
         
            +
                    return nil
         
     | 
| 
      
 25 
     | 
    
         
            +
                  end
         
     | 
| 
      
 26 
     | 
    
         
            +
                end
         
     | 
| 
      
 27 
     | 
    
         
            +
                
         
     | 
| 
      
 28 
     | 
    
         
            +
                # Manage virtual attributes that are not sent back to the API
         
     | 
| 
      
 29 
     | 
    
         
            +
                attr_accessor :roles
         
     | 
| 
      
 30 
     | 
    
         
            +
                def has_role?(symbol)
         
     | 
| 
      
 31 
     | 
    
         
            +
                  roles.include?(symbol.to_s)
         
     | 
| 
      
 32 
     | 
    
         
            +
                end
         
     | 
| 
      
 33 
     | 
    
         
            +
                
         
     | 
| 
      
 34 
     | 
    
         
            +
                def add_role(*symbols)
         
     | 
| 
      
 35 
     | 
    
         
            +
                  symbols.each {|r| proxy_for(config).post(resource_path(:add_role), :role=>r) }
         
     | 
| 
      
 36 
     | 
    
         
            +
                end
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
                def remove_role(*symbols)
         
     | 
| 
      
 39 
     | 
    
         
            +
                  symbols.each {|r| proxy_for(config).post(resource_path(:remove_role), :role=>r) }
         
     | 
| 
      
 40 
     | 
    
         
            +
                end
         
     | 
| 
      
 41 
     | 
    
         
            +
                
         
     | 
| 
      
 42 
     | 
    
         
            +
              end
         
     | 
| 
      
 43 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/videojuicer.rb
    ADDED
    
    | 
         @@ -0,0 +1,110 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            $:.unshift File.dirname(__FILE__)     # For use/testing when no gem is installed
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            # Gem and stdlib dependencies
         
     | 
| 
      
 4 
     | 
    
         
            +
            require 'rubygems'
         
     | 
| 
      
 5 
     | 
    
         
            +
            require 'cgi'
         
     | 
| 
      
 6 
     | 
    
         
            +
            require 'json'
         
     | 
| 
      
 7 
     | 
    
         
            +
            require 'hmac-sha1'
         
     | 
| 
      
 8 
     | 
    
         
            +
            require 'net/http'
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
            # Core ext
         
     | 
| 
      
 11 
     | 
    
         
            +
            require 'core_ext/hash'
         
     | 
| 
      
 12 
     | 
    
         
            +
            require 'core_ext/string'
         
     | 
| 
      
 13 
     | 
    
         
            +
            require 'core_ext/object'
         
     | 
| 
      
 14 
     | 
    
         
            +
            require 'core_ext/cgi'
         
     | 
| 
      
 15 
     | 
    
         
            +
            # Core mixins
         
     | 
| 
      
 16 
     | 
    
         
            +
            require 'videojuicer/shared/exceptions'
         
     | 
| 
      
 17 
     | 
    
         
            +
            require 'videojuicer/shared/configurable'
         
     | 
| 
      
 18 
     | 
    
         
            +
            # Authentication and authorisation
         
     | 
| 
      
 19 
     | 
    
         
            +
            require 'videojuicer/oauth/request_proxy'
         
     | 
| 
      
 20 
     | 
    
         
            +
            require 'videojuicer/oauth/proxy_factory'
         
     | 
| 
      
 21 
     | 
    
         
            +
            # Resource handling
         
     | 
| 
      
 22 
     | 
    
         
            +
            require 'videojuicer/resource/embeddable'
         
     | 
| 
      
 23 
     | 
    
         
            +
            require 'videojuicer/resource/types'
         
     | 
| 
      
 24 
     | 
    
         
            +
            require 'videojuicer/resource/relationships/belongs_to'
         
     | 
| 
      
 25 
     | 
    
         
            +
            require 'videojuicer/resource/errors'
         
     | 
| 
      
 26 
     | 
    
         
            +
            require 'videojuicer/resource/collection'
         
     | 
| 
      
 27 
     | 
    
         
            +
            require 'videojuicer/resource/inferrable'
         
     | 
| 
      
 28 
     | 
    
         
            +
            require 'videojuicer/resource/property_registry'
         
     | 
| 
      
 29 
     | 
    
         
            +
            require 'videojuicer/resource/base'
         
     | 
| 
      
 30 
     | 
    
         
            +
            require 'videojuicer/session'
         
     | 
| 
      
 31 
     | 
    
         
            +
            # Frontend models
         
     | 
| 
      
 32 
     | 
    
         
            +
            require 'videojuicer/user'
         
     | 
| 
      
 33 
     | 
    
         
            +
            require 'videojuicer/campaign'
         
     | 
| 
      
 34 
     | 
    
         
            +
            require 'videojuicer/campaign_policy'
         
     | 
| 
      
 35 
     | 
    
         
            +
            require 'videojuicer/presentation'
         
     | 
| 
      
 36 
     | 
    
         
            +
            require 'videojuicer/asset/audio'
         
     | 
| 
      
 37 
     | 
    
         
            +
            require 'videojuicer/asset/flash'
         
     | 
| 
      
 38 
     | 
    
         
            +
            require 'videojuicer/asset/image'
         
     | 
| 
      
 39 
     | 
    
         
            +
            require 'videojuicer/asset/text'
         
     | 
| 
      
 40 
     | 
    
         
            +
            require 'videojuicer/asset/video'
         
     | 
| 
      
 41 
     | 
    
         
            +
            require 'videojuicer/promo/base'
         
     | 
| 
      
 42 
     | 
    
         
            +
            require 'videojuicer/criterion/date_range'
         
     | 
| 
      
 43 
     | 
    
         
            +
            require 'videojuicer/criterion/geolocation'
         
     | 
| 
      
 44 
     | 
    
         
            +
            require 'videojuicer/criterion/request'
         
     | 
| 
      
 45 
     | 
    
         
            +
            require 'videojuicer/criterion/time'
         
     | 
| 
      
 46 
     | 
    
         
            +
            require 'videojuicer/criterion/week_day'
         
     | 
| 
      
 47 
     | 
    
         
            +
            require 'videojuicer/promo/base'
         
     | 
| 
      
 48 
     | 
    
         
            +
            require 'videojuicer/preset'
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
            module Videojuicer
         
     | 
| 
      
 51 
     | 
    
         
            +
              
         
     | 
| 
      
 52 
     | 
    
         
            +
              DEFAULTS = {
         
     | 
| 
      
 53 
     | 
    
         
            +
                :consumer_key     => nil,
         
     | 
| 
      
 54 
     | 
    
         
            +
                :consumer_secret  => nil,
         
     | 
| 
      
 55 
     | 
    
         
            +
                :token            => nil,
         
     | 
| 
      
 56 
     | 
    
         
            +
                :token_secret     => nil,
         
     | 
| 
      
 57 
     | 
    
         
            +
                :api_version      => nil,
         
     | 
| 
      
 58 
     | 
    
         
            +
                :seed_name        => nil,
         
     | 
| 
      
 59 
     | 
    
         
            +
                :user_id          => nil,
         
     | 
| 
      
 60 
     | 
    
         
            +
                :protocol         => "http",
         
     | 
| 
      
 61 
     | 
    
         
            +
                :host             => "api.videojuicer.com",
         
     | 
| 
      
 62 
     | 
    
         
            +
                :port             => 80
         
     | 
| 
      
 63 
     | 
    
         
            +
              }.freeze
         
     | 
| 
      
 64 
     | 
    
         
            +
             
     | 
| 
      
 65 
     | 
    
         
            +
              @default_options = {}
         
     | 
| 
      
 66 
     | 
    
         
            +
              @scope_stack = []
         
     | 
| 
      
 67 
     | 
    
         
            +
              
         
     | 
| 
      
 68 
     | 
    
         
            +
              class << self
         
     | 
| 
      
 69 
     | 
    
         
            +
             
     | 
| 
      
 70 
     | 
    
         
            +
                def scopes
         
     | 
| 
      
 71 
     | 
    
         
            +
                  ([default_options]+@scope_stack).compact
         
     | 
| 
      
 72 
     | 
    
         
            +
                end
         
     | 
| 
      
 73 
     | 
    
         
            +
                
         
     | 
| 
      
 74 
     | 
    
         
            +
                def in_scope?
         
     | 
| 
      
 75 
     | 
    
         
            +
                  !@scope_stack.empty?
         
     | 
| 
      
 76 
     | 
    
         
            +
                end
         
     | 
| 
      
 77 
     | 
    
         
            +
                
         
     | 
| 
      
 78 
     | 
    
         
            +
                def current_scope
         
     | 
| 
      
 79 
     | 
    
         
            +
                  scopes.last
         
     | 
| 
      
 80 
     | 
    
         
            +
                end
         
     | 
| 
      
 81 
     | 
    
         
            +
                
         
     | 
| 
      
 82 
     | 
    
         
            +
                def enter_scope(config)
         
     | 
| 
      
 83 
     | 
    
         
            +
                  @scope_stack.push current_scope.merge(config)
         
     | 
| 
      
 84 
     | 
    
         
            +
                end
         
     | 
| 
      
 85 
     | 
    
         
            +
                
         
     | 
| 
      
 86 
     | 
    
         
            +
                def exit_scope
         
     | 
| 
      
 87 
     | 
    
         
            +
                  @scope_stack.pop
         
     | 
| 
      
 88 
     | 
    
         
            +
                end
         
     | 
| 
      
 89 
     | 
    
         
            +
                
         
     | 
| 
      
 90 
     | 
    
         
            +
                def exit_all!
         
     | 
| 
      
 91 
     | 
    
         
            +
                  @scope_stack = []
         
     | 
| 
      
 92 
     | 
    
         
            +
                end
         
     | 
| 
      
 93 
     | 
    
         
            +
                
         
     | 
| 
      
 94 
     | 
    
         
            +
                def [](key)
         
     | 
| 
      
 95 
     | 
    
         
            +
                  @default_options[key]
         
     | 
| 
      
 96 
     | 
    
         
            +
                end
         
     | 
| 
      
 97 
     | 
    
         
            +
                
         
     | 
| 
      
 98 
     | 
    
         
            +
                def configure!(options={})
         
     | 
| 
      
 99 
     | 
    
         
            +
                  @default_options = DEFAULTS.merge(@default_options.merge(options))
         
     | 
| 
      
 100 
     | 
    
         
            +
                end
         
     | 
| 
      
 101 
     | 
    
         
            +
             
     | 
| 
      
 102 
     | 
    
         
            +
                def unconfigure!
         
     | 
| 
      
 103 
     | 
    
         
            +
                  @default_options = DEFAULTS
         
     | 
| 
      
 104 
     | 
    
         
            +
                end
         
     | 
| 
      
 105 
     | 
    
         
            +
             
     | 
| 
      
 106 
     | 
    
         
            +
                def default_options
         
     | 
| 
      
 107 
     | 
    
         
            +
                  @default_options
         
     | 
| 
      
 108 
     | 
    
         
            +
                end
         
     | 
| 
      
 109 
     | 
    
         
            +
              end # class << self
         
     | 
| 
      
 110 
     | 
    
         
            +
            end # module Videojuicer
         
     | 
| 
         @@ -0,0 +1,25 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require File.join(File.dirname(__FILE__), "..", "helpers",  "spec_helper")
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            describe Videojuicer::Asset::Audio do
         
     | 
| 
      
 4 
     | 
    
         
            +
              
         
     | 
| 
      
 5 
     | 
    
         
            +
              before(:all) do
         
     | 
| 
      
 6 
     | 
    
         
            +
                @klass = Videojuicer::Asset::Audio
         
     | 
| 
      
 7 
     | 
    
         
            +
                @preset_params = {:derived_type => "Audio", :file_format => "mp3"}
         
     | 
| 
      
 8 
     | 
    
         
            +
                configure_test_settings
         
     | 
| 
      
 9 
     | 
    
         
            +
              end
         
     | 
| 
      
 10 
     | 
    
         
            +
              
         
     | 
| 
      
 11 
     | 
    
         
            +
              describe "instantiation" do
         
     | 
| 
      
 12 
     | 
    
         
            +
                it_should_behave_like "a configurable"
         
     | 
| 
      
 13 
     | 
    
         
            +
              end
         
     | 
| 
      
 14 
     | 
    
         
            +
              
         
     | 
| 
      
 15 
     | 
    
         
            +
              describe "general interface:" do
         
     | 
| 
      
 16 
     | 
    
         
            +
                before(:all) do
         
     | 
| 
      
 17 
     | 
    
         
            +
                  @singular_name = "asset"
         
     | 
| 
      
 18 
     | 
    
         
            +
                  @plural_name = "assets/audio"
         
     | 
| 
      
 19 
     | 
    
         
            +
                end
         
     | 
| 
      
 20 
     | 
    
         
            +
                
         
     | 
| 
      
 21 
     | 
    
         
            +
                it_should_behave_like "a RESTFUL resource model"
         
     | 
| 
      
 22 
     | 
    
         
            +
              end
         
     | 
| 
      
 23 
     | 
    
         
            +
              
         
     | 
| 
      
 24 
     | 
    
         
            +
              it_should_behave_like "an asset"
         
     | 
| 
      
 25 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,24 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require File.join(File.dirname(__FILE__), "..", "helpers",  "spec_helper")
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            describe Videojuicer::Asset::Flash do
         
     | 
| 
      
 4 
     | 
    
         
            +
              
         
     | 
| 
      
 5 
     | 
    
         
            +
              before(:all) do
         
     | 
| 
      
 6 
     | 
    
         
            +
                @klass = Videojuicer::Asset::Flash
         
     | 
| 
      
 7 
     | 
    
         
            +
                configure_test_settings
         
     | 
| 
      
 8 
     | 
    
         
            +
              end
         
     | 
| 
      
 9 
     | 
    
         
            +
              
         
     | 
| 
      
 10 
     | 
    
         
            +
              describe "instantiation" do
         
     | 
| 
      
 11 
     | 
    
         
            +
                it_should_behave_like "a configurable"
         
     | 
| 
      
 12 
     | 
    
         
            +
              end
         
     | 
| 
      
 13 
     | 
    
         
            +
              
         
     | 
| 
      
 14 
     | 
    
         
            +
              describe "general interface:" do
         
     | 
| 
      
 15 
     | 
    
         
            +
                before(:all) do
         
     | 
| 
      
 16 
     | 
    
         
            +
                  @singular_name = "asset"
         
     | 
| 
      
 17 
     | 
    
         
            +
                  @plural_name = "assets/flash"
         
     | 
| 
      
 18 
     | 
    
         
            +
                end
         
     | 
| 
      
 19 
     | 
    
         
            +
                
         
     | 
| 
      
 20 
     | 
    
         
            +
                it_should_behave_like "a RESTFUL resource model"
         
     | 
| 
      
 21 
     | 
    
         
            +
              end
         
     | 
| 
      
 22 
     | 
    
         
            +
              
         
     | 
| 
      
 23 
     | 
    
         
            +
              it_should_behave_like "an asset"
         
     | 
| 
      
 24 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,25 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require File.join(File.dirname(__FILE__), "..", "helpers",  "spec_helper")
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            describe Videojuicer::Asset::Image do
         
     | 
| 
      
 4 
     | 
    
         
            +
              
         
     | 
| 
      
 5 
     | 
    
         
            +
              before(:all) do
         
     | 
| 
      
 6 
     | 
    
         
            +
                @klass = Videojuicer::Asset::Image
         
     | 
| 
      
 7 
     | 
    
         
            +
                @preset_params = {:derived_type => "Image", :file_format => "png"}
         
     | 
| 
      
 8 
     | 
    
         
            +
                configure_test_settings
         
     | 
| 
      
 9 
     | 
    
         
            +
              end
         
     | 
| 
      
 10 
     | 
    
         
            +
              
         
     | 
| 
      
 11 
     | 
    
         
            +
              describe "instantiation" do
         
     | 
| 
      
 12 
     | 
    
         
            +
                it_should_behave_like "a configurable"
         
     | 
| 
      
 13 
     | 
    
         
            +
              end
         
     | 
| 
      
 14 
     | 
    
         
            +
              
         
     | 
| 
      
 15 
     | 
    
         
            +
              describe "general interface:" do
         
     | 
| 
      
 16 
     | 
    
         
            +
                before(:all) do
         
     | 
| 
      
 17 
     | 
    
         
            +
                  @singular_name = "asset"
         
     | 
| 
      
 18 
     | 
    
         
            +
                  @plural_name = "assets/image"
         
     | 
| 
      
 19 
     | 
    
         
            +
                end
         
     | 
| 
      
 20 
     | 
    
         
            +
                
         
     | 
| 
      
 21 
     | 
    
         
            +
                it_should_behave_like "a RESTFUL resource model"
         
     | 
| 
      
 22 
     | 
    
         
            +
              end
         
     | 
| 
      
 23 
     | 
    
         
            +
              
         
     | 
| 
      
 24 
     | 
    
         
            +
              it_should_behave_like "an asset"
         
     | 
| 
      
 25 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,24 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require File.join(File.dirname(__FILE__), "..", "helpers",  "spec_helper")
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            describe Videojuicer::Asset::Text do
         
     | 
| 
      
 4 
     | 
    
         
            +
              
         
     | 
| 
      
 5 
     | 
    
         
            +
              before(:all) do
         
     | 
| 
      
 6 
     | 
    
         
            +
                @klass = Videojuicer::Asset::Text
         
     | 
| 
      
 7 
     | 
    
         
            +
                configure_test_settings
         
     | 
| 
      
 8 
     | 
    
         
            +
              end
         
     | 
| 
      
 9 
     | 
    
         
            +
              
         
     | 
| 
      
 10 
     | 
    
         
            +
              describe "instantiation" do
         
     | 
| 
      
 11 
     | 
    
         
            +
                it_should_behave_like "a configurable"
         
     | 
| 
      
 12 
     | 
    
         
            +
              end
         
     | 
| 
      
 13 
     | 
    
         
            +
              
         
     | 
| 
      
 14 
     | 
    
         
            +
              describe "general interface:" do
         
     | 
| 
      
 15 
     | 
    
         
            +
                before(:all) do
         
     | 
| 
      
 16 
     | 
    
         
            +
                  @singular_name = "asset"
         
     | 
| 
      
 17 
     | 
    
         
            +
                  @plural_name = "assets/text"
         
     | 
| 
      
 18 
     | 
    
         
            +
                end
         
     | 
| 
      
 19 
     | 
    
         
            +
                
         
     | 
| 
      
 20 
     | 
    
         
            +
                it_should_behave_like "a RESTFUL resource model"
         
     | 
| 
      
 21 
     | 
    
         
            +
              end
         
     | 
| 
      
 22 
     | 
    
         
            +
              
         
     | 
| 
      
 23 
     | 
    
         
            +
              it_should_behave_like "an asset"
         
     | 
| 
      
 24 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,25 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require File.join(File.dirname(__FILE__), "..", "helpers",  "spec_helper")
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            describe Videojuicer::Asset::Video do
         
     | 
| 
      
 4 
     | 
    
         
            +
              
         
     | 
| 
      
 5 
     | 
    
         
            +
              before(:all) do
         
     | 
| 
      
 6 
     | 
    
         
            +
                @klass = Videojuicer::Asset::Video
         
     | 
| 
      
 7 
     | 
    
         
            +
                @preset_params = {:derived_type => "Video", :file_format => "mp4"}
         
     | 
| 
      
 8 
     | 
    
         
            +
                configure_test_settings
         
     | 
| 
      
 9 
     | 
    
         
            +
              end
         
     | 
| 
      
 10 
     | 
    
         
            +
              
         
     | 
| 
      
 11 
     | 
    
         
            +
              describe "instantiation" do
         
     | 
| 
      
 12 
     | 
    
         
            +
                it_should_behave_like "a configurable"
         
     | 
| 
      
 13 
     | 
    
         
            +
              end
         
     | 
| 
      
 14 
     | 
    
         
            +
              
         
     | 
| 
      
 15 
     | 
    
         
            +
              describe "general interface:" do
         
     | 
| 
      
 16 
     | 
    
         
            +
                before(:all) do
         
     | 
| 
      
 17 
     | 
    
         
            +
                  @singular_name = "asset"
         
     | 
| 
      
 18 
     | 
    
         
            +
                  @plural_name = "assets/video"
         
     | 
| 
      
 19 
     | 
    
         
            +
                end
         
     | 
| 
      
 20 
     | 
    
         
            +
                
         
     | 
| 
      
 21 
     | 
    
         
            +
                it_should_behave_like "a RESTFUL resource model"
         
     | 
| 
      
 22 
     | 
    
         
            +
              end
         
     | 
| 
      
 23 
     | 
    
         
            +
              
         
     | 
| 
      
 24 
     | 
    
         
            +
              it_should_behave_like "an asset"
         
     | 
| 
      
 25 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,45 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require File.join(File.dirname(__FILE__), "helpers", "spec_helper")
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            describe Videojuicer::Resource::Relationships::BelongsTo do
         
     | 
| 
      
 4 
     | 
    
         
            +
              
         
     | 
| 
      
 5 
     | 
    
         
            +
              after(:all) do
         
     | 
| 
      
 6 
     | 
    
         
            +
                Videojuicer.exit_scope
         
     | 
| 
      
 7 
     | 
    
         
            +
              end
         
     | 
| 
      
 8 
     | 
    
         
            +
              
         
     | 
| 
      
 9 
     | 
    
         
            +
              before(:all) do
         
     | 
| 
      
 10 
     | 
    
         
            +
                configure_test_settings
         
     | 
| 
      
 11 
     | 
    
         
            +
                Videojuicer.enter_scope :seed_name => fixtures.seed.name, 
         
     | 
| 
      
 12 
     | 
    
         
            +
                                        :consumer_key=>fixtures["write-master"].consumer.consumer_key,
         
     | 
| 
      
 13 
     | 
    
         
            +
                                        :consumer_secret=>fixtures["write-master"].consumer.consumer_secret,
         
     | 
| 
      
 14 
     | 
    
         
            +
                                        :token=>fixtures["write-master"].authorized_token.oauth_token,
         
     | 
| 
      
 15 
     | 
    
         
            +
                                        :token_secret=>fixtures["write-master"].authorized_token.oauth_token_secret
         
     | 
| 
      
 16 
     | 
    
         
            +
                
         
     | 
| 
      
 17 
     | 
    
         
            +
                @user = Videojuicer::User.first
         
     | 
| 
      
 18 
     | 
    
         
            +
                @user.should be_kind_of(Videojuicer::User)
         
     | 
| 
      
 19 
     | 
    
         
            +
                
         
     | 
| 
      
 20 
     | 
    
         
            +
                class ::BelongsToExample
         
     | 
| 
      
 21 
     | 
    
         
            +
                  include Videojuicer::Resource
         
     | 
| 
      
 22 
     | 
    
         
            +
                  
         
     | 
| 
      
 23 
     | 
    
         
            +
                  property :user_id, Integer
         
     | 
| 
      
 24 
     | 
    
         
            +
                  belongs_to :user, :class=>Videojuicer::User
         
     | 
| 
      
 25 
     | 
    
         
            +
                end
         
     | 
| 
      
 26 
     | 
    
         
            +
                
         
     | 
| 
      
 27 
     | 
    
         
            +
                @example = ::BelongsToExample.new
         
     | 
| 
      
 28 
     | 
    
         
            +
                @example.user_id = @user.id
         
     | 
| 
      
 29 
     | 
    
         
            +
              end
         
     | 
| 
      
 30 
     | 
    
         
            +
              
         
     | 
| 
      
 31 
     | 
    
         
            +
              it "retrieves the user" do
         
     | 
| 
      
 32 
     | 
    
         
            +
                @example.user.id.should == @user.id
         
     | 
| 
      
 33 
     | 
    
         
            +
              end
         
     | 
| 
      
 34 
     | 
    
         
            +
              
         
     | 
| 
      
 35 
     | 
    
         
            +
              it "returns nil when the user_id is nonsense" do
         
     | 
| 
      
 36 
     | 
    
         
            +
                bad_example = ::BelongsToExample.new(:user_id=>9900000000)
         
     | 
| 
      
 37 
     | 
    
         
            +
                bad_example.user.should be_nil
         
     | 
| 
      
 38 
     | 
    
         
            +
              end
         
     | 
| 
      
 39 
     | 
    
         
            +
              
         
     | 
| 
      
 40 
     | 
    
         
            +
              it "sets the user" do
         
     | 
| 
      
 41 
     | 
    
         
            +
                @example.user = @user
         
     | 
| 
      
 42 
     | 
    
         
            +
                @example.user_id.should == @user.id
         
     | 
| 
      
 43 
     | 
    
         
            +
              end
         
     | 
| 
      
 44 
     | 
    
         
            +
              
         
     | 
| 
      
 45 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,41 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require File.join(File.dirname(__FILE__), "helpers", "spec_helper")
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            describe Videojuicer::Campaign::CampaignPolicy do
         
     | 
| 
      
 4 
     | 
    
         
            +
              
         
     | 
| 
      
 5 
     | 
    
         
            +
              before(:all) do
         
     | 
| 
      
 6 
     | 
    
         
            +
                @klass = Videojuicer::Campaign::CampaignPolicy
         
     | 
| 
      
 7 
     | 
    
         
            +
                configure_test_settings
         
     | 
| 
      
 8 
     | 
    
         
            +
              end
         
     | 
| 
      
 9 
     | 
    
         
            +
              
         
     | 
| 
      
 10 
     | 
    
         
            +
              describe "instantiation" do
         
     | 
| 
      
 11 
     | 
    
         
            +
                it_should_behave_like "a configurable"
         
     | 
| 
      
 12 
     | 
    
         
            +
              end
         
     | 
| 
      
 13 
     | 
    
         
            +
              
         
     | 
| 
      
 14 
     | 
    
         
            +
              describe "general interface:" do
         
     | 
| 
      
 15 
     | 
    
         
            +
                before(:all) do
         
     | 
| 
      
 16 
     | 
    
         
            +
                  @singular_name = "campaign_policy"
         
     | 
| 
      
 17 
     | 
    
         
            +
                  @plural_name = "campaign_policies"
         
     | 
| 
      
 18 
     | 
    
         
            +
                  @fixed_attributes = [:campaign_id]
         
     | 
| 
      
 19 
     | 
    
         
            +
                end
         
     | 
| 
      
 20 
     | 
    
         
            +
                
         
     | 
| 
      
 21 
     | 
    
         
            +
                it_should_behave_like "a RESTFUL resource model"
         
     | 
| 
      
 22 
     | 
    
         
            +
              end
         
     | 
| 
      
 23 
     | 
    
         
            +
              
         
     | 
| 
      
 24 
     | 
    
         
            +
              describe "adding policies" do
         
     | 
| 
      
 25 
     | 
    
         
            +
              
         
     | 
| 
      
 26 
     | 
    
         
            +
              end
         
     | 
| 
      
 27 
     | 
    
         
            +
              
         
     | 
| 
      
 28 
     | 
    
         
            +
              describe "removing policies" do
         
     | 
| 
      
 29 
     | 
    
         
            +
              
         
     | 
| 
      
 30 
     | 
    
         
            +
              end
         
     | 
| 
      
 31 
     | 
    
         
            +
              
         
     | 
| 
      
 32 
     | 
    
         
            +
              describe "adding promos" do
         
     | 
| 
      
 33 
     | 
    
         
            +
              
         
     | 
| 
      
 34 
     | 
    
         
            +
              end
         
     | 
| 
      
 35 
     | 
    
         
            +
              
         
     | 
| 
      
 36 
     | 
    
         
            +
              describe "removing promos" do
         
     | 
| 
      
 37 
     | 
    
         
            +
              
         
     | 
| 
      
 38 
     | 
    
         
            +
              end
         
     | 
| 
      
 39 
     | 
    
         
            +
              
         
     | 
| 
      
 40 
     | 
    
         
            +
              
         
     | 
| 
      
 41 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,25 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require File.join(File.dirname(__FILE__), "helpers", "spec_helper")
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            describe Videojuicer::Campaign do
         
     | 
| 
      
 4 
     | 
    
         
            +
              
         
     | 
| 
      
 5 
     | 
    
         
            +
              before(:all) do
         
     | 
| 
      
 6 
     | 
    
         
            +
                @klass = Videojuicer::Campaign
         
     | 
| 
      
 7 
     | 
    
         
            +
                configure_test_settings
         
     | 
| 
      
 8 
     | 
    
         
            +
              end
         
     | 
| 
      
 9 
     | 
    
         
            +
              
         
     | 
| 
      
 10 
     | 
    
         
            +
              describe "instantiation" do
         
     | 
| 
      
 11 
     | 
    
         
            +
                it_should_behave_like "a configurable"
         
     | 
| 
      
 12 
     | 
    
         
            +
              end
         
     | 
| 
      
 13 
     | 
    
         
            +
              
         
     | 
| 
      
 14 
     | 
    
         
            +
              describe "general interface:" do
         
     | 
| 
      
 15 
     | 
    
         
            +
                before(:all) do
         
     | 
| 
      
 16 
     | 
    
         
            +
                  string_mash = (("A".."z").to_a + ("a".."z").to_a)
         
     | 
| 
      
 17 
     | 
    
         
            +
                  @singular_name = "campaign"
         
     | 
| 
      
 18 
     | 
    
         
            +
                  @plural_name = "campaigns"
         
     | 
| 
      
 19 
     | 
    
         
            +
                end
         
     | 
| 
      
 20 
     | 
    
         
            +
                
         
     | 
| 
      
 21 
     | 
    
         
            +
                it_should_behave_like "a RESTFUL resource model"
         
     | 
| 
      
 22 
     | 
    
         
            +
              end
         
     | 
| 
      
 23 
     | 
    
         
            +
              
         
     | 
| 
      
 24 
     | 
    
         
            +
              
         
     | 
| 
      
 25 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,31 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require File.join(File.dirname(__FILE__), "helpers", "spec_helper")
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            describe Videojuicer::Resource::Collection do
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
              before(:all) do
         
     | 
| 
      
 6 
     | 
    
         
            +
                @objects = [:foo]*100
         
     | 
| 
      
 7 
     | 
    
         
            +
                @collection = Videojuicer::Resource::Collection.new(@objects[0..9], 155, 17, 10)
         
     | 
| 
      
 8 
     | 
    
         
            +
              end
         
     | 
| 
      
 9 
     | 
    
         
            +
              
         
     | 
| 
      
 10 
     | 
    
         
            +
              it "is instantiated correctly" do    
         
     | 
| 
      
 11 
     | 
    
         
            +
                @collection.should be_kind_of(Videojuicer::Resource::Collection)
         
     | 
| 
      
 12 
     | 
    
         
            +
                @collection.total.should == 155
         
     | 
| 
      
 13 
     | 
    
         
            +
                @collection.offset.should == 17
         
     | 
| 
      
 14 
     | 
    
         
            +
                @collection.limit.should == 10
         
     | 
| 
      
 15 
     | 
    
         
            +
              end
         
     | 
| 
      
 16 
     | 
    
         
            +
              
         
     | 
| 
      
 17 
     | 
    
         
            +
              it "can count the number of pages" do
         
     | 
| 
      
 18 
     | 
    
         
            +
                @collection.page_count.should == 16
         
     | 
| 
      
 19 
     | 
    
         
            +
              end
         
     | 
| 
      
 20 
     | 
    
         
            +
              
         
     | 
| 
      
 21 
     | 
    
         
            +
              it "can tell the current page" do
         
     | 
| 
      
 22 
     | 
    
         
            +
                @collection.page_number.should == 2
         
     | 
| 
      
 23 
     | 
    
         
            +
              end
         
     | 
| 
      
 24 
     | 
    
         
            +
              
         
     | 
| 
      
 25 
     | 
    
         
            +
              it "pagination copes with a nil limit" do
         
     | 
| 
      
 26 
     | 
    
         
            +
                collection = Videojuicer::Resource::Collection.new(@objects[0..9], 155, 17, nil)
         
     | 
| 
      
 27 
     | 
    
         
            +
                collection.page_count.should == 1
         
     | 
| 
      
 28 
     | 
    
         
            +
                collection.page_number.should == 1
         
     | 
| 
      
 29 
     | 
    
         
            +
              end
         
     | 
| 
      
 30 
     | 
    
         
            +
              
         
     | 
| 
      
 31 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,24 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require File.join(File.dirname(__FILE__), "..", "helpers", "spec_helper")
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            describe Videojuicer::Criterion::DateRange do
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
               before(:all) do
         
     | 
| 
      
 6 
     | 
    
         
            +
                @klass = Videojuicer::Criterion::DateRange
         
     | 
| 
      
 7 
     | 
    
         
            +
                configure_test_settings
         
     | 
| 
      
 8 
     | 
    
         
            +
              end
         
     | 
| 
      
 9 
     | 
    
         
            +
              
         
     | 
| 
      
 10 
     | 
    
         
            +
              describe "instantiation" do
         
     | 
| 
      
 11 
     | 
    
         
            +
                it_should_behave_like "a configurable"
         
     | 
| 
      
 12 
     | 
    
         
            +
              end
         
     | 
| 
      
 13 
     | 
    
         
            +
              
         
     | 
| 
      
 14 
     | 
    
         
            +
              describe "general interface:" do
         
     | 
| 
      
 15 
     | 
    
         
            +
                before(:all) do
         
     | 
| 
      
 16 
     | 
    
         
            +
                  @singular_name = "criterion"
         
     | 
| 
      
 17 
     | 
    
         
            +
                  @plural_name = "criteria/date_range"
         
     | 
| 
      
 18 
     | 
    
         
            +
                end
         
     | 
| 
      
 19 
     | 
    
         
            +
                
         
     | 
| 
      
 20 
     | 
    
         
            +
                it_should_behave_like "a dependent non-resource object"
         
     | 
| 
      
 21 
     | 
    
         
            +
              end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
            end
         
     | 
| 
      
 24 
     | 
    
         
            +
              
         
     | 
| 
         @@ -0,0 +1,23 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require File.join(File.dirname(__FILE__), "..", "helpers", "spec_helper")
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            describe Videojuicer::Criterion::Geolocation do
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
               before(:all) do
         
     | 
| 
      
 6 
     | 
    
         
            +
                @klass = Videojuicer::Criterion::Geolocation
         
     | 
| 
      
 7 
     | 
    
         
            +
                configure_test_settings
         
     | 
| 
      
 8 
     | 
    
         
            +
              end
         
     | 
| 
      
 9 
     | 
    
         
            +
              
         
     | 
| 
      
 10 
     | 
    
         
            +
              describe "instantiation" do
         
     | 
| 
      
 11 
     | 
    
         
            +
                it_should_behave_like "a configurable"
         
     | 
| 
      
 12 
     | 
    
         
            +
              end
         
     | 
| 
      
 13 
     | 
    
         
            +
              
         
     | 
| 
      
 14 
     | 
    
         
            +
              describe "general interface:" do
         
     | 
| 
      
 15 
     | 
    
         
            +
                before(:all) do
         
     | 
| 
      
 16 
     | 
    
         
            +
                  @singular_name = "criterion"
         
     | 
| 
      
 17 
     | 
    
         
            +
                  @plural_name = "criteria/geolocation"
         
     | 
| 
      
 18 
     | 
    
         
            +
                end
         
     | 
| 
      
 19 
     | 
    
         
            +
                
         
     | 
| 
      
 20 
     | 
    
         
            +
                it_should_behave_like "a dependent non-resource object"
         
     | 
| 
      
 21 
     | 
    
         
            +
              end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,23 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require File.join(File.dirname(__FILE__), "..", "helpers", "spec_helper")
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            describe Videojuicer::Criterion::Request do
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
               before(:all) do
         
     | 
| 
      
 6 
     | 
    
         
            +
                @klass = Videojuicer::Criterion::Request
         
     | 
| 
      
 7 
     | 
    
         
            +
                configure_test_settings
         
     | 
| 
      
 8 
     | 
    
         
            +
              end
         
     | 
| 
      
 9 
     | 
    
         
            +
              
         
     | 
| 
      
 10 
     | 
    
         
            +
              describe "instantiation" do
         
     | 
| 
      
 11 
     | 
    
         
            +
                it_should_behave_like "a configurable"
         
     | 
| 
      
 12 
     | 
    
         
            +
              end
         
     | 
| 
      
 13 
     | 
    
         
            +
              
         
     | 
| 
      
 14 
     | 
    
         
            +
              describe "general interface:" do
         
     | 
| 
      
 15 
     | 
    
         
            +
                before(:all) do
         
     | 
| 
      
 16 
     | 
    
         
            +
                  @singular_name = "criterion"
         
     | 
| 
      
 17 
     | 
    
         
            +
                  @plural_name = "criteria/request"
         
     | 
| 
      
 18 
     | 
    
         
            +
                end
         
     | 
| 
      
 19 
     | 
    
         
            +
                
         
     | 
| 
      
 20 
     | 
    
         
            +
                it_should_behave_like "a dependent non-resource object"
         
     | 
| 
      
 21 
     | 
    
         
            +
              end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,23 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require File.join(File.dirname(__FILE__), "..", "helpers", "spec_helper")
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            describe Videojuicer::Criterion::Time do
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
               before(:all) do
         
     | 
| 
      
 6 
     | 
    
         
            +
                @klass = Videojuicer::Criterion::Time
         
     | 
| 
      
 7 
     | 
    
         
            +
                configure_test_settings
         
     | 
| 
      
 8 
     | 
    
         
            +
              end
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
              describe "instantiation" do
         
     | 
| 
      
 11 
     | 
    
         
            +
                it_should_behave_like "a configurable"
         
     | 
| 
      
 12 
     | 
    
         
            +
              end
         
     | 
| 
      
 13 
     | 
    
         
            +
              
         
     | 
| 
      
 14 
     | 
    
         
            +
              describe "general interface:" do
         
     | 
| 
      
 15 
     | 
    
         
            +
                before(:all) do
         
     | 
| 
      
 16 
     | 
    
         
            +
                  @singular_name = "criterion"
         
     | 
| 
      
 17 
     | 
    
         
            +
                  @plural_name = "criteria/time"
         
     | 
| 
      
 18 
     | 
    
         
            +
                end
         
     | 
| 
      
 19 
     | 
    
         
            +
                
         
     | 
| 
      
 20 
     | 
    
         
            +
                it_should_behave_like "a dependent non-resource object"
         
     | 
| 
      
 21 
     | 
    
         
            +
              end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,23 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require File.join(File.dirname(__FILE__), "..", "helpers", "spec_helper")
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            describe Videojuicer::Criterion::WeekDay do
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
               before(:all) do
         
     | 
| 
      
 6 
     | 
    
         
            +
                @klass = Videojuicer::Criterion::WeekDay
         
     | 
| 
      
 7 
     | 
    
         
            +
                configure_test_settings
         
     | 
| 
      
 8 
     | 
    
         
            +
              end
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
              describe "instantiation" do
         
     | 
| 
      
 11 
     | 
    
         
            +
                it_should_behave_like "a configurable"
         
     | 
| 
      
 12 
     | 
    
         
            +
              end
         
     | 
| 
      
 13 
     | 
    
         
            +
              
         
     | 
| 
      
 14 
     | 
    
         
            +
              describe "general interface:" do
         
     | 
| 
      
 15 
     | 
    
         
            +
                before(:all) do
         
     | 
| 
      
 16 
     | 
    
         
            +
                  @singular_name = "criterion"
         
     | 
| 
      
 17 
     | 
    
         
            +
                  @plural_name = "criteria/week_day"
         
     | 
| 
      
 18 
     | 
    
         
            +
                end
         
     | 
| 
      
 19 
     | 
    
         
            +
                
         
     | 
| 
      
 20 
     | 
    
         
            +
                it_should_behave_like "a dependent non-resource object"
         
     | 
| 
      
 21 
     | 
    
         
            +
              end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
            end
         
     | 
| 
         Binary file 
     | 
| 
         
            File without changes
         
     |