honkster-encosion 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
4
+ </project>
5
+
@@ -0,0 +1,9 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="RUBY_MODULE" version="4">
3
+ <component name="NewModuleRootManager">
4
+ <content url="file://$MODULE_DIR$" />
5
+ <orderEntry type="inheritedJdk" />
6
+ <orderEntry type="sourceFolder" forTests="false" />
7
+ </component>
8
+ </module>
9
+
data/.idea/misc.xml ADDED
@@ -0,0 +1,243 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="DBNavigator.Project.ConnectionManager">
4
+ <connections />
5
+ </component>
6
+ <component name="DBNavigator.Project.DataEditorManager">
7
+ <record-editor-column-sorting value="INDEXED" />
8
+ </component>
9
+ <component name="DBNavigator.Project.DatabaseBrowserManager">
10
+ <autoscroll-to-editor value="false" />
11
+ <autoscroll-from-editor value="false" />
12
+ </component>
13
+ <component name="DBNavigator.Project.MethodExecutionManager">
14
+ <group-history-entries value="false" />
15
+ <method-browser />
16
+ <execution-inputs />
17
+ </component>
18
+ <component name="DBNavigator.Project.Settings">
19
+ <dataset-editor-settings>
20
+ <autopopup-text-editor active="true" active-if-empty="false" data-length-threshold="100" delay="1000" />
21
+ <values-list-popup>
22
+ <active-for-primary-keys value="false" />
23
+ <threshold-upper-limit value="1000" />
24
+ </values-list-popup>
25
+ <general>
26
+ <fetch-block-size value="100" />
27
+ <fetch-timeout value="20" />
28
+ <trim-whitespaces value="true" />
29
+ <convert-empty-strings-to-null value="true" />
30
+ <select-content-on-cell-edit value="true" />
31
+ </general>
32
+ <filters>
33
+ <prompt-filter-dialog value="true" />
34
+ <default-filter-type value="BASIC" />
35
+ </filters>
36
+ <lob-content-types text-length-threshold="300">
37
+ <content-type name="Text" enabled="true" />
38
+ <content-type name="XML" enabled="true" />
39
+ <content-type name="DTD" enabled="true" />
40
+ <content-type name="HTML" enabled="true" />
41
+ <content-type name="XHTML" enabled="true" />
42
+ <content-type name="CSS" enabled="true" />
43
+ <content-type name="SQL" enabled="true" />
44
+ <content-type name="PL/SQL" enabled="true" />
45
+ <content-type name="JavaScript" enabled="true" />
46
+ </lob-content-types>
47
+ </dataset-editor-settings>
48
+ <code-completion-settings>
49
+ <filters>
50
+ <basic-filter>
51
+ <filter-element type="RESERVED_WORD" id="keyword" selected="true" />
52
+ <filter-element type="RESERVED_WORD" id="function" selected="false" />
53
+ <filter-element type="RESERVED_WORD" id="parameter" selected="false" />
54
+ <filter-element type="RESERVED_WORD" id="datatype" selected="true" />
55
+ <filter-element type="OBJECT" id="schema" selected="true" />
56
+ <filter-element type="OBJECT" id="user" selected="true" />
57
+ <user-schema>
58
+ <filter-element type="OBJECT" id="table" selected="true" />
59
+ <filter-element type="OBJECT" id="view" selected="true" />
60
+ <filter-element type="OBJECT" id="materialized view" selected="true" />
61
+ <filter-element type="OBJECT" id="index" selected="true" />
62
+ <filter-element type="OBJECT" id="constraint" selected="true" />
63
+ <filter-element type="OBJECT" id="trigger" selected="true" />
64
+ <filter-element type="OBJECT" id="synonym" selected="false" />
65
+ <filter-element type="OBJECT" id="sequence" selected="true" />
66
+ <filter-element type="OBJECT" id="procedure" selected="true" />
67
+ <filter-element type="OBJECT" id="function" selected="true" />
68
+ <filter-element type="OBJECT" id="package" selected="true" />
69
+ <filter-element type="OBJECT" id="type" selected="true" />
70
+ <filter-element type="OBJECT" id="dimension" selected="true" />
71
+ <filter-element type="OBJECT" id="cluster" selected="true" />
72
+ <filter-element type="OBJECT" id="dblink" selected="true" />
73
+ </user-schema>
74
+ <public-schema>
75
+ <filter-element type="OBJECT" id="table" selected="false" />
76
+ <filter-element type="OBJECT" id="view" selected="false" />
77
+ <filter-element type="OBJECT" id="materialized view" selected="false" />
78
+ <filter-element type="OBJECT" id="index" selected="false" />
79
+ <filter-element type="OBJECT" id="constraint" selected="false" />
80
+ <filter-element type="OBJECT" id="trigger" selected="false" />
81
+ <filter-element type="OBJECT" id="synonym" selected="false" />
82
+ <filter-element type="OBJECT" id="sequence" selected="false" />
83
+ <filter-element type="OBJECT" id="procedure" selected="false" />
84
+ <filter-element type="OBJECT" id="function" selected="false" />
85
+ <filter-element type="OBJECT" id="package" selected="false" />
86
+ <filter-element type="OBJECT" id="type" selected="false" />
87
+ <filter-element type="OBJECT" id="dimension" selected="false" />
88
+ <filter-element type="OBJECT" id="cluster" selected="false" />
89
+ <filter-element type="OBJECT" id="dblink" selected="false" />
90
+ </public-schema>
91
+ <any-schema>
92
+ <filter-element type="OBJECT" id="table" selected="true" />
93
+ <filter-element type="OBJECT" id="view" selected="true" />
94
+ <filter-element type="OBJECT" id="materialized view" selected="true" />
95
+ <filter-element type="OBJECT" id="index" selected="true" />
96
+ <filter-element type="OBJECT" id="constraint" selected="true" />
97
+ <filter-element type="OBJECT" id="trigger" selected="true" />
98
+ <filter-element type="OBJECT" id="synonym" selected="true" />
99
+ <filter-element type="OBJECT" id="sequence" selected="true" />
100
+ <filter-element type="OBJECT" id="procedure" selected="true" />
101
+ <filter-element type="OBJECT" id="function" selected="true" />
102
+ <filter-element type="OBJECT" id="package" selected="true" />
103
+ <filter-element type="OBJECT" id="type" selected="true" />
104
+ <filter-element type="OBJECT" id="dimension" selected="true" />
105
+ <filter-element type="OBJECT" id="cluster" selected="true" />
106
+ <filter-element type="OBJECT" id="dblink" selected="true" />
107
+ </any-schema>
108
+ </basic-filter>
109
+ <smart-filter>
110
+ <filter-element type="RESERVED_WORD" id="keyword" selected="true" />
111
+ <filter-element type="RESERVED_WORD" id="function" selected="true" />
112
+ <filter-element type="RESERVED_WORD" id="parameter" selected="true" />
113
+ <filter-element type="RESERVED_WORD" id="datatype" selected="true" />
114
+ <filter-element type="OBJECT" id="schema" selected="true" />
115
+ <filter-element type="OBJECT" id="user" selected="true" />
116
+ <user-schema>
117
+ <filter-element type="OBJECT" id="table" selected="true" />
118
+ <filter-element type="OBJECT" id="view" selected="true" />
119
+ <filter-element type="OBJECT" id="materialized view" selected="true" />
120
+ <filter-element type="OBJECT" id="index" selected="true" />
121
+ <filter-element type="OBJECT" id="constraint" selected="true" />
122
+ <filter-element type="OBJECT" id="trigger" selected="true" />
123
+ <filter-element type="OBJECT" id="synonym" selected="true" />
124
+ <filter-element type="OBJECT" id="sequence" selected="true" />
125
+ <filter-element type="OBJECT" id="procedure" selected="true" />
126
+ <filter-element type="OBJECT" id="function" selected="true" />
127
+ <filter-element type="OBJECT" id="package" selected="true" />
128
+ <filter-element type="OBJECT" id="type" selected="true" />
129
+ <filter-element type="OBJECT" id="dimension" selected="true" />
130
+ <filter-element type="OBJECT" id="cluster" selected="true" />
131
+ <filter-element type="OBJECT" id="dblink" selected="true" />
132
+ </user-schema>
133
+ <public-schema>
134
+ <filter-element type="OBJECT" id="table" selected="true" />
135
+ <filter-element type="OBJECT" id="view" selected="true" />
136
+ <filter-element type="OBJECT" id="materialized view" selected="true" />
137
+ <filter-element type="OBJECT" id="index" selected="true" />
138
+ <filter-element type="OBJECT" id="constraint" selected="true" />
139
+ <filter-element type="OBJECT" id="trigger" selected="true" />
140
+ <filter-element type="OBJECT" id="synonym" selected="true" />
141
+ <filter-element type="OBJECT" id="sequence" selected="true" />
142
+ <filter-element type="OBJECT" id="procedure" selected="true" />
143
+ <filter-element type="OBJECT" id="function" selected="true" />
144
+ <filter-element type="OBJECT" id="package" selected="true" />
145
+ <filter-element type="OBJECT" id="type" selected="true" />
146
+ <filter-element type="OBJECT" id="dimension" selected="true" />
147
+ <filter-element type="OBJECT" id="cluster" selected="true" />
148
+ <filter-element type="OBJECT" id="dblink" selected="true" />
149
+ </public-schema>
150
+ <any-schema>
151
+ <filter-element type="OBJECT" id="table" selected="true" />
152
+ <filter-element type="OBJECT" id="view" selected="true" />
153
+ <filter-element type="OBJECT" id="materialized view" selected="true" />
154
+ <filter-element type="OBJECT" id="index" selected="true" />
155
+ <filter-element type="OBJECT" id="constraint" selected="true" />
156
+ <filter-element type="OBJECT" id="trigger" selected="true" />
157
+ <filter-element type="OBJECT" id="synonym" selected="true" />
158
+ <filter-element type="OBJECT" id="sequence" selected="true" />
159
+ <filter-element type="OBJECT" id="procedure" selected="true" />
160
+ <filter-element type="OBJECT" id="function" selected="true" />
161
+ <filter-element type="OBJECT" id="package" selected="true" />
162
+ <filter-element type="OBJECT" id="type" selected="true" />
163
+ <filter-element type="OBJECT" id="dimension" selected="true" />
164
+ <filter-element type="OBJECT" id="cluster" selected="true" />
165
+ <filter-element type="OBJECT" id="dblink" selected="true" />
166
+ </any-schema>
167
+ </smart-filter>
168
+ </filters>
169
+ <sorting enabled="false">
170
+ <sorting-element type="RESERVED_WORD" id="keyword" />
171
+ <sorting-element type="RESERVED_WORD" id="datatype" />
172
+ <sorting-element type="OBJECT" id="column" />
173
+ <sorting-element type="OBJECT" id="table" />
174
+ <sorting-element type="OBJECT" id="view" />
175
+ <sorting-element type="OBJECT" id="materialized view" />
176
+ <sorting-element type="OBJECT" id="index" />
177
+ <sorting-element type="OBJECT" id="constraint" />
178
+ <sorting-element type="OBJECT" id="trigger" />
179
+ <sorting-element type="OBJECT" id="synonym" />
180
+ <sorting-element type="OBJECT" id="sequence" />
181
+ <sorting-element type="OBJECT" id="procedure" />
182
+ <sorting-element type="OBJECT" id="function" />
183
+ <sorting-element type="OBJECT" id="package" />
184
+ <sorting-element type="OBJECT" id="type" />
185
+ <sorting-element type="OBJECT" id="dimension" />
186
+ <sorting-element type="OBJECT" id="cluster" />
187
+ <sorting-element type="OBJECT" id="dblink" />
188
+ <sorting-element type="OBJECT" id="schema" />
189
+ <sorting-element type="RESERVED_WORD" id="function" />
190
+ <sorting-element type="RESERVED_WORD" id="parameter" />
191
+ </sorting>
192
+ </code-completion-settings>
193
+ <execution-engine-settings />
194
+ <ddl-file-settings>
195
+ <extensions>
196
+ <mapping file-type-id="VIEW" extensions="vw" />
197
+ <mapping file-type-id="TRIGGER" extensions="trg" />
198
+ <mapping file-type-id="PROCEDURE" extensions="prc" />
199
+ <mapping file-type-id="FUNCTION" extensions="fnc" />
200
+ <mapping file-type-id="PACKAGE" extensions="pkg" />
201
+ <mapping file-type-id="PACKAGE_SPEC" extensions="pks" />
202
+ <mapping file-type-id="PACKAGE_BODY" extensions="pkb" />
203
+ <mapping file-type-id="TYPE" extensions="tpe" />
204
+ <mapping file-type-id="TYPE_SPEC" extensions="tps" />
205
+ <mapping file-type-id="TYPE_BODY" extensions="tpb" />
206
+ </extensions>
207
+ <general>
208
+ <statement-postfix value="/" />
209
+ <lookup-ddl-files value="true" />
210
+ <create-ddl-files value="false" />
211
+ </general>
212
+ </ddl-file-settings>
213
+ <general-settings>
214
+ <regional-settings>
215
+ <date-format value="MEDIUM" />
216
+ <number-format value="UNGROUPED" />
217
+ <locale value="SYSTEM_DEFAULT" />
218
+ </regional-settings>
219
+ </general-settings>
220
+ </component>
221
+ <component name="DependencyValidationManager">
222
+ <option name="SKIP_IMPORT_STATEMENTS" value="false" />
223
+ </component>
224
+ <component name="ProjectDetails">
225
+ <option name="projectName" value="honkster-encosion" />
226
+ </component>
227
+ <component name="ProjectRootManager" version="2" project-jdk-name="Ruby SDK 1.8.7 (/usr/local/bin/ruby)" project-jdk-type="RUBY_SDK" />
228
+ <component name="SvnConfiguration">
229
+ <option name="USER" value="" />
230
+ <option name="PASSWORD" value="" />
231
+ <option name="LAST_MERGED_REVISION" />
232
+ <option name="UPDATE_RUN_STATUS" value="false" />
233
+ <option name="MERGE_DRY_RUN" value="false" />
234
+ <option name="MERGE_DIFF_USE_ANCESTRY" value="true" />
235
+ <option name="UPDATE_LOCK_ON_DEMAND" value="false" />
236
+ <option name="IGNORE_SPACES_IN_MERGE" value="false" />
237
+ <option name="DETECT_NESTED_COPIES" value="false" />
238
+ <option name="IGNORE_SPACES_IN_ANNOTATE" value="true" />
239
+ <option name="SHOW_MERGE_SOURCES_IN_ANNOTATE" value="true" />
240
+ <myIsUseDefaultProxy>false</myIsUseDefaultProxy>
241
+ </component>
242
+ </project>
243
+
data/.idea/modules.xml ADDED
@@ -0,0 +1,9 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/honkster-encosion.iml" filepath="$PROJECT_DIR$/.idea/honkster-encosion.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
9
+
data/.idea/vcs.xml ADDED
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="" vcs="" />
5
+ <mapping directory="$PROJECT_DIR$" vcs="Git" />
6
+ </component>
7
+ </project>
8
+
data/README.rdoc CHANGED
@@ -83,3 +83,4 @@ And of course the video file itself. Just give :file a File object.
83
83
 
84
84
  * Implement the remaining Video write methods: update_video, delete_video, share_video, add_image
85
85
  * Implement the Playlist API read/write methods
86
+ * Implement new features for the iPhone encodings
data/Rakefile CHANGED
@@ -4,7 +4,7 @@ require 'rake'
4
4
  begin
5
5
  require 'jeweler'
6
6
  Jeweler::Tasks.new do |gem|
7
- gem.name = "encosion"
7
+ gem.name = "honkster-encosion"
8
8
  gem.summary = %q{Ruby library for working with the Brightcove API}
9
9
  gem.email = "cannikinn@gmail.com"
10
10
  gem.homepage = "http://github.com/cannikin/encosion"
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.1
1
+ 0.3.2
@@ -1,12 +1,15 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
1
4
  # -*- encoding: utf-8 -*-
2
5
 
3
6
  Gem::Specification.new do |s|
4
7
  s.name = %q{honkster-encosion}
5
- s.version = "0.3.1"
8
+ s.version = "0.3.2"
6
9
 
7
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
- s.authors = ["Rob Cameron"]
9
- s.date = %q{2009-11-09}
11
+ s.authors = ["Rob Cameron", "Mason Glaves"]
12
+ s.date = %q{2010-04-07}
10
13
  s.email = %q{cannikinn@gmail.com}
11
14
  s.extra_rdoc_files = [
12
15
  "LICENSE",
@@ -15,11 +18,16 @@ Gem::Specification.new do |s|
15
18
  s.files = [
16
19
  ".document",
17
20
  ".gitignore",
21
+ ".idea/encodings.xml",
22
+ ".idea/honkster-encosion.iml",
23
+ ".idea/misc.xml",
24
+ ".idea/modules.xml",
25
+ ".idea/vcs.xml",
18
26
  "LICENSE",
19
27
  "README.rdoc",
20
28
  "Rakefile",
21
29
  "VERSION",
22
- "encosion.gemspec",
30
+ "honkster-encosion.gemspec",
23
31
  "lib/encosion.rb",
24
32
  "lib/encosion/base.rb",
25
33
  "lib/encosion/cue_point.rb",
@@ -32,10 +40,10 @@ Gem::Specification.new do |s|
32
40
  "test/movie.mov",
33
41
  "test/test_helper.rb"
34
42
  ]
35
- s.homepage = %q{http://github.com/honkster/encosion}
43
+ s.homepage = %q{http://github.com/cannikin/encosion}
36
44
  s.rdoc_options = ["--charset=UTF-8"]
37
45
  s.require_paths = ["lib"]
38
- s.rubygems_version = %q{1.3.4}
46
+ s.rubygems_version = %q{1.3.5}
39
47
  s.summary = %q{Ruby library for working with the Brightcove API}
40
48
  s.test_files = [
41
49
  "test/encosion_test.rb",
data/lib/encosion.rb CHANGED
@@ -17,27 +17,27 @@ require 'encosion/playlist'
17
17
  require 'encosion/exceptions'
18
18
 
19
19
  module Encosion
20
-
21
- VERSION = '0.3.1'
20
+
21
+ VERSION = '0.3.2'
22
22
  LOGGER = Logger.new(STDOUT)
23
-
23
+
24
24
  SERVER = 'api.brightcove.com'
25
25
  PORT = 80
26
26
  SECURE = false
27
27
  READ_PATH = '/services/library'
28
28
  WRITE_PATH = '/services/post'
29
29
  DEFAULT_OPTIONS = { :debug => false }
30
-
31
- @options = { :read_token => nil,
32
- :write_token => nil,
33
- :server => SERVER,
34
- :port => PORT,
35
- :secure => SECURE,
36
- :read_path => READ_PATH,
30
+
31
+ @options = { :read_token => nil,
32
+ :write_token => nil,
33
+ :server => SERVER,
34
+ :port => PORT,
35
+ :secure => SECURE,
36
+ :read_path => READ_PATH,
37
37
  :write_path => WRITE_PATH }
38
38
  attr_accessor :options
39
-
39
+
40
40
  # make @options available so it can be set externally when using the library
41
41
  extend self
42
-
42
+
43
43
  end
data/lib/encosion/base.rb CHANGED
@@ -4,38 +4,38 @@ require 'httpclient'
4
4
  require 'json'
5
5
 
6
6
  module Encosion
7
-
7
+
8
8
  # Generic Encosion error class
9
9
  class EncosionError < StandardError
10
10
  end
11
-
11
+
12
12
  # Raised when there is no token (required to use the Brightcove API)
13
13
  class MissingToken < EncosionError
14
14
  end
15
-
15
+
16
16
  # Raised when some parameter is missing that we need in order to do a search
17
17
  class AssetNotFound < EncosionError
18
18
  end
19
-
19
+
20
20
  # Raised when Brightcove doesn't like the call that was made for whatever reason
21
21
  class BrightcoveException < EncosionError
22
22
  end
23
-
23
+
24
24
  # Raised when Brightcove doesn't like the call that was made for whatever reason
25
25
  class NoFile < EncosionError
26
26
  end
27
-
28
-
27
+
28
+
29
29
  # The base for all Encosion objects
30
30
  class Base
31
-
31
+
32
32
  attr_accessor :read_token, :write_token
33
33
 
34
34
  #
35
35
  # Class methods
36
36
  #
37
37
  class << self
38
-
38
+
39
39
  # Does a GET to search photos and other good stuff
40
40
  def find(*args)
41
41
  options = extract_options(args)
@@ -44,42 +44,40 @@ module Encosion
44
44
  else find_from_ids(args,options)
45
45
  end
46
46
  end
47
-
48
-
47
+
48
+
49
49
  # This is an alias for find(:all)
50
50
  def all(*args)
51
51
  find(:all, *args)
52
52
  end
53
-
53
+
54
54
 
55
55
  # Performs an HTTP GET
56
56
  def get(server,port,secure,path,command,options)
57
57
  http = HTTPClient.new
58
58
  url = secure ? 'https://' : 'http://'
59
59
  url += "#{server}:#{port}#{path}"
60
-
60
+
61
61
  options.merge!({'command' => command })
62
62
  query_string = options.collect { |key,value| "#{key.to_s}=#{value.to_s}" }.join('&')
63
-
63
+
64
64
  response = http.get(url, query_string)
65
-
65
+
66
66
  body = response.body.content.strip == 'null' ? nil : JSON.parse(response.body.content.strip) # if the call returns 'null' then there were no valid results
67
67
  header = response.header
68
-
68
+
69
69
  error_check(header,body)
70
-
71
- # puts "url: #{url}\nquery_string:#{query_string}"
72
70
 
73
71
  return body
74
72
  end
75
-
76
-
73
+
74
+
77
75
  # Performs an HTTP POST
78
76
  def post(server,port,secure,path,command,options,instance)
79
77
  http = HTTPClient.new
80
78
  url = secure ? 'https://' : 'http://'
81
79
  url += "#{server}:#{port}#{path}"
82
-
80
+
83
81
  content = { 'json' => { 'method' => command, 'params' => options }.to_json } # package up the variables as a JSON-RPC string
84
82
  content.merge!({ 'file' => instance.file }) if instance.respond_to?('file') # and add a file if there is one
85
83
 
@@ -92,8 +90,8 @@ module Encosion
92
90
  # if we get here then no exceptions were raised
93
91
  return body
94
92
  end
95
-
96
-
93
+
94
+
97
95
  # Checks the HTTP response and handles any errors
98
96
  def error_check(header,body)
99
97
  if header.status_code == 200
@@ -101,7 +99,7 @@ module Encosion
101
99
  # puts body['error']
102
100
  if body.has_key? 'error' && !body['error'].nil?
103
101
  message = "Brightcove responded with an error: #{body['error']} (code #{body['code']})"
104
- body['errors'].each do |error|
102
+ body['errors'].each do |error|
105
103
  message += "\n#{error.values.first} (code #{error.values.last})"
106
104
  end if body.has_key? 'errors'
107
105
  raise BrightcoveException, message
@@ -111,10 +109,10 @@ module Encosion
111
109
  raise BrightcoveException, body + " (status code: #{header.status_code})"
112
110
  end
113
111
  end
114
-
112
+
115
113
 
116
114
  protected
117
-
115
+
118
116
  # Pulls any Hash off the end of an array of arguments and returns it
119
117
  def extract_options(opts)
120
118
  opts.last.is_a?(::Hash) ? opts.pop : {}
@@ -138,7 +136,7 @@ module Encosion
138
136
  find_some(ids, options)
139
137
  end
140
138
  end
141
-
139
+
142
140
 
143
141
  # Turns a hash into a query string and appends the token
144
142
  def queryize_args(args, type)
@@ -152,10 +150,10 @@ module Encosion
152
150
  end
153
151
  return args.collect { |key,value| "#{key.to_s}=#{value.to_s}" }.join('&')
154
152
  end
155
-
153
+
156
154
  end
157
-
158
-
155
+
156
+
159
157
  end
160
-
158
+
161
159
  end
@@ -1,43 +1,46 @@
1
1
  module Encosion
2
-
2
+
3
3
  # Raised if you try to set an invalid economics value
4
4
  class InvalidEconomicsValue < StandardError; end;
5
-
5
+
6
6
  class Video < Base
7
-
7
+
8
8
  ENUMS = { :economics => { :free => 'FREE', :ad_supported => 'AD_SUPPORTED'}}
9
-
10
- attr_accessor(:name,
11
- :short_description,
9
+
10
+ attr_accessor(:name,
11
+ :short_description,
12
12
  :long_description,
13
- :link_url,
14
- :link_text,
15
- :tags,
16
- :reference_id,
13
+ :link_url,
14
+ :link_text,
15
+ :tags,
16
+ :reference_id,
17
17
  :economics,
18
+ :encode_to,
19
+ :create_multiple_renditions,
18
20
  :file)
19
- attr_reader(:id,
20
- :account_id,
21
+ attr_reader(:id,
22
+ :account_id,
21
23
  :flv_url,
22
- :creation_date,
23
- :published_date,
24
- :last_modified_date,
25
- :video_still_url,
26
- :thumbnail_url,
27
- :length,
28
- :plays_total,
24
+ :renditions,
25
+ :creation_date,
26
+ :published_date,
27
+ :last_modified_date,
28
+ :video_still_url,
29
+ :thumbnail_url,
30
+ :length,
31
+ :plays_total,
29
32
  :plays_trailing_week)
30
-
31
- #
33
+
34
+ #
32
35
  # Class methods
33
36
  #
34
37
  class << self
35
-
38
+
36
39
  # Find a video by reference_id. Invokes Brightcove Media API command 'find_video_by_reference_id' or
37
40
  # 'find_videos_by_reference_ids' depending on whether you call one or multiple ids
38
41
  # Encosion::Video.find_by_reference_id('mycompany_1')
39
42
  # Encosion::Video.find_by_reference_id('mycompany_1','mycompany_2','mycompany_3')
40
-
43
+
41
44
  def find_by_reference_id(*args)
42
45
  options = extract_options(args)
43
46
  ids = args.flatten.compact.uniq
@@ -55,10 +58,10 @@ module Encosion
55
58
  return response['items'].collect { |item| self.parse(item) }
56
59
  end
57
60
  end
58
-
61
+
59
62
  # Find a video by text search. Invokes Brightcove Media API command 'find_videos_by_text'
60
63
  # Encosion::Video.find_by_text('funny videos')
61
-
64
+
62
65
  def find_by_text(*args)
63
66
  options = extract_options(args)
64
67
  text = args.flatten.compact.uniq
@@ -70,11 +73,11 @@ module Encosion
70
73
  nil
71
74
  end
72
75
  end
73
-
76
+
74
77
 
75
78
  # Find videos related to the given video_id. Invokes Brightcove Media API command 'find_related_videos'
76
79
  # Encosion::Video.find_related(123456)
77
-
80
+
78
81
  def find_related(*args)
79
82
  options = extract_options(args)
80
83
  raise AssetNotFound, "Cannot find related #{self.class}s without a video_id or reference_id" if options[:video_id].nil? && options[:reference_id].nil?
@@ -84,11 +87,11 @@ module Encosion
84
87
  return nil
85
88
  end
86
89
  end
87
-
88
-
90
+
91
+
89
92
  # Find a video by tag search. Invokes Brightcove Media API command 'find_videos_by_tags'
90
93
  # Encosion::Video.find_by_tags('bloopers','gagreel','funny')
91
-
94
+
92
95
  def find_by_tags(*args)
93
96
  options = extract_options(args)
94
97
  tags = args.flatten.compact.uniq
@@ -105,31 +108,31 @@ module Encosion
105
108
  end
106
109
  end
107
110
  end
108
-
109
-
111
+
112
+
110
113
  # Returns the status of a video upload (returns one of :uploading | :processing | :complete | :error )
111
114
  # Takes either Brightcove's video_id or your own reference_id. If you pass an integer it's assumed to be
112
115
  # a video_id, if you pass a string it's assumed to be a reference_id.
113
116
  # Encosion::Video.status(12345)
114
-
117
+
115
118
  def status(*args)
116
119
  options = extract_options(args)
117
120
  id = args.flatten.compact.uniq.first
118
-
121
+
119
122
  if id.class == String
120
123
  options.merge!({:reference_id => id})
121
124
  else
122
125
  options.merge!({:video_id => id})
123
126
  end
124
-
127
+
125
128
  if response = write('get_upload_status',options)
126
129
  return response['result'].downcase.to_sym
127
130
  else
128
131
  return nil
129
132
  end
130
133
  end
131
-
132
-
134
+
135
+
133
136
  # the actual method that calls a get (user can use this directly if they want to call a method that's not included here)
134
137
  def read(method,options)
135
138
  # options.merge!(Encosion.options)
@@ -141,8 +144,8 @@ module Encosion
141
144
  method,
142
145
  options)
143
146
  end
144
-
145
-
147
+
148
+
146
149
  # the actual method that calls a post (user can use this directly if they want to call a method that's not included here)
147
150
  def write(method,options)
148
151
  # options.merge!(Encosion.options)
@@ -163,23 +166,23 @@ module Encosion
163
166
  response = read('find_video_by_id',options)
164
167
  return self.parse(response)
165
168
  end
166
-
167
-
169
+
170
+
168
171
  # Find mutliple videos by id
169
172
  def find_some(ids, options)
170
173
  options.merge!({:video_ids => ids.join(',')})
171
174
  response = read('find_videos_by_ids',options)
172
175
  return response['items'].collect { |item| self.parse(item) }
173
176
  end
174
-
175
-
177
+
178
+
176
179
  # Find all videos
177
180
  def find_all(options)
178
181
  response = read('find_all_videos', options)
179
182
  return response['items'].collect { |item| self.parse(item) }
180
183
  end
181
-
182
-
184
+
185
+
183
186
  # Creates a new Video object from a Ruby hash (used to create a video from a parsed API call)
184
187
  def parse(obj)
185
188
  if obj
@@ -197,17 +200,34 @@ module Encosion
197
200
  :thumbnail_url => obj['thumbnailURL'],
198
201
  :reference_id => obj['referenceID'],
199
202
  :length => obj['length'].to_i,
203
+ :flv_url => obj['FLVURL'],
200
204
  :economics => obj['economics'] ? ENUMS[:economics].find { |key,value| value == obj['economics'] }.first : nil,
201
205
  :plays_total => obj['playsTotal'].to_i,
202
- :plays_trailing_week => obj['playsTrailingWeek'].to_i } unless obj.nil?
206
+ :plays_trailing_week => obj['playsTrailingWeek'].to_i }
207
+
208
+ args[:renditions] = obj['renditions'].map do |rendition|
209
+ { :encodingRate => rendition["encodingRate"], :url => rendition["url"] }
210
+ end if obj['renditions']
211
+
203
212
  return self.new(args)
204
213
  else
205
214
  return nil
206
215
  end
207
216
  end
208
-
209
217
  end
210
-
218
+
219
+ def best_rendition(max_rate = 262144)
220
+ return flv_url unless renditions
221
+
222
+ urls = {}
223
+ best_rate = renditions.map do |r|
224
+ urls[r[:encodingRate]] = r[:url]
225
+ r[:encodingRate]
226
+ end.sort.reverse.select { |rate| rate <= max_rate }.first
227
+
228
+ urls[best_rate] || flv_url
229
+ end
230
+
211
231
  #
212
232
  # Instance methods
213
233
  #
@@ -229,19 +249,25 @@ module Encosion
229
249
  @economics = self.economics = args[:economics]
230
250
  @plays_total = args[:plays_total]
231
251
  @plays_trailing_week = args[:plays_trailing_week]
252
+ @encode_to = args[:encode_to] || 'MP4'
253
+ @create_multiple_renditions = args[:create_multiple_renditions] || true
254
+ @flv_url = args[:flv_url]
255
+ @renditions = args[:renditions]
232
256
  @file = args[:file]
233
257
  end
234
-
235
-
258
+
259
+
236
260
  # Saves a video to Brightcove. Returns the Brightcove ID for the video that was just uploaded.
237
261
  # new_video = Encosion::Video.new(:file => File.new('/path/to/file'), :name => "My Awesome Video", :short_description => "A video of some awesome happenings", :tags => ['awesome','sweet'])
238
262
  # brightcove_id = new_video.save(:token => '123abc')
239
-
263
+
240
264
  def save(args={})
241
265
  # check to make sure we have everything needed for a create_video call
242
266
  raise NoFile, "You need to attach a file to this video before you can upload it: Video.file = File.new('/path/to/file')" if @file.nil?
243
267
  options = args.merge({ 'video' => self.to_brightcove }) # take the parameters of this video and make them a valid video object for upload
244
- options.merge!({:token => Encosion.options[:write_token]}) unless options[:token]
268
+ options.merge!({ :token => Encosion.options[:write_token] }) unless options[:token]
269
+ options.merge!({ 'encode_to' => @encode_to }) unless options[:encode_to]
270
+ options.merge!({ 'create_multiple_renditions' => @create_multiple_renditions }) unless options[:create_multiple_renditions]
245
271
  response = Video.post(Encosion.options[:server],
246
272
  Encosion.options[:port],
247
273
  Encosion.options[:secure],
@@ -251,8 +277,8 @@ module Encosion
251
277
  self)
252
278
  return response['result'] # returns the Brightcove ID of the video that was just uploaded
253
279
  end
254
-
255
-
280
+
281
+
256
282
  # Output the video as JSON
257
283
  def to_json
258
284
  { :id => @id,
@@ -271,10 +297,11 @@ module Encosion
271
297
  :length => @length,
272
298
  :economics => @economics,
273
299
  :plays_total => @plays_total,
300
+ :flv_url => @flv_url,
274
301
  :plays_trailing_week => @plays_trailing_week }.to_json
275
302
  end
276
-
277
-
303
+
304
+
278
305
  # Outputs the video object into Brightcove's expected format
279
306
  def to_brightcove
280
307
  { 'name' => @name,
@@ -286,8 +313,8 @@ module Encosion
286
313
  'referenceId' => @reference_id,
287
314
  'economics' => ENUMS[:economics][@economics] }
288
315
  end
289
-
290
-
316
+
317
+
291
318
  # Makes sure that the economics set on this video is one of a predetermined list
292
319
  def economics=(sym)
293
320
  unless sym.nil?
@@ -298,7 +325,7 @@ module Encosion
298
325
  end
299
326
  end
300
327
  end
301
-
328
+
302
329
  end
303
-
330
+
304
331
  end
metadata CHANGED
@@ -1,15 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: honkster-encosion
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rob Cameron
8
+ - Mason Glaves
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
12
 
12
- date: 2009-11-09 00:00:00 -08:00
13
+ date: 2010-04-07 00:00:00 -07:00
13
14
  default_executable:
14
15
  dependencies:
15
16
  - !ruby/object:Gem::Dependency
@@ -44,11 +45,16 @@ extra_rdoc_files:
44
45
  files:
45
46
  - .document
46
47
  - .gitignore
48
+ - .idea/encodings.xml
49
+ - .idea/honkster-encosion.iml
50
+ - .idea/misc.xml
51
+ - .idea/modules.xml
52
+ - .idea/vcs.xml
47
53
  - LICENSE
48
54
  - README.rdoc
49
55
  - Rakefile
50
56
  - VERSION
51
- - encosion.gemspec
57
+ - honkster-encosion.gemspec
52
58
  - lib/encosion.rb
53
59
  - lib/encosion/base.rb
54
60
  - lib/encosion/cue_point.rb
@@ -61,7 +67,7 @@ files:
61
67
  - test/movie.mov
62
68
  - test/test_helper.rb
63
69
  has_rdoc: true
64
- homepage: http://github.com/honkster/encosion
70
+ homepage: http://github.com/cannikin/encosion
65
71
  licenses: []
66
72
 
67
73
  post_install_message: