helix 0.0.4.8.pre → 0.0.4.9.pre

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NDdlNDE3OWNiMmYwNmU5Y2NmOGI0NWU2M2YzYmNjNWRjYzA1NzAyMA==
4
+ OWY5OTNjMjY3NTE4ZWVhMTk0MWRjYTRmNTY2NGQwYzRiNjk2MWJjYQ==
5
5
  data.tar.gz: !binary |-
6
- OTQ2MTRkMzQyZDYwYWQ2NGVkYjVmZjczZmViZTUzMThkZmJlNjI1ZA==
6
+ NmZkNGU3NDhlY2IxNjI2ODc1ZmU3YTJkODNmODdhYWFjMmM3Y2IyZA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZGJjYTk3M2RlMGM1NTA4YzhiOTI3MWU0MGJkODhjOTcwOTliMzkxNDJmZDMy
10
- YWVhMmU4ODc1MzgyNDM0NGQ1YWM2ZTFiM2NlMGM4NzlmZTdmYmNjZGExZTgw
11
- MDQ4MDFiY2U3MDVmYjczYmIyNTBhZWYyMjU2MDY1MDk3ZTE0ZjY=
9
+ NzU4M2RmYzY2MDc5ZTk2NWY4OTFkMGRhNmM4MDA2ZDE3ZTRmNTVlNDE5YTBm
10
+ MzE3OWNjMzljNWVhYTg3NjU0NTlmMWE5YjhiYTRjOTMyMjM2NGUzNzdhYzA3
11
+ ZDNmYWJkMDYwYmY4MWE3ZTA0ODYyMWIxMzU5OGU5M2EwNGFlOGY=
12
12
  data.tar.gz: !binary |-
13
- NDhhNWI4NWU0YWYxYWVkOGFlZjhiYjVlZTY0ZTlhYTYwYTc4OTdkZmU0M2Mz
14
- MmFiOWNhMjcxYjliOTA4NTVlZGYzM2Q1MWIxYzNmYjVkZDQ0ZmRmM2Q2NzI3
15
- OTllNjcyMDkzOGMxNjk2YjgwMTA0MDM1YWU0YTJhZjkzNDdlNDI=
13
+ NzI2NTFkMzk0NjBhYjA4NzE5NTBlOGJjYTI0OWE1ZmNjZDljYjZjNzU0NzQ1
14
+ OTU2YjE4NGU0MTA2ZjVjZmJhOThiMTZjYzQ3NmJhMGExYjRiYmY3NTNlZmI4
15
+ NzliOWUzYzY5M2VkN2ExMWM1N2FlYjk4MmIzMTVlNTcxNzczNjM=
data/lib/helix.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'helix/restful'
2
2
  require 'helix/uploadable'
3
+ require 'helix/downloadable'
3
4
  require 'helix/durationed'
4
5
  require 'helix/video'
5
6
  require 'helix/track'
@@ -14,6 +14,34 @@ module Helix
14
14
  # @return [Symbol] Name of the class.
15
15
  def self.resource_label_sym; :document; end
16
16
 
17
+ # Used to download data for the given Document.
18
+ #
19
+ # @example
20
+ # document = Helix::Document.find("239c59483d346")
21
+ # document_data = document.download #=> xDC\xF1?\xE9*?\xFF\xD9
22
+ # File.open("my_document.mp4", "w") { |f| f.puts document_data }
23
+ #
24
+ # @param [Hash] opts a hash of options for building URL
25
+ # @return [String] Raw document data, save it to a file
26
+ def download(opts={})
27
+ generic_download(opts.merge(action: :file))
28
+ end
29
+
30
+ # Used to play the given Document.
31
+ #
32
+ # The definition of what "play" means for Documents
33
+ # may vary by specific type.
34
+ #
35
+ # @example
36
+ # document = Helix::Document.find("239c59483d346")
37
+ # document_data = document.play #=> xDC\xF1?\xE9*?\xFF\xD9
38
+ #
39
+ # @param [Hash] opts a hash of options for building URL
40
+ # @return [String] Raw document data
41
+ def play(opts={})
42
+ generic_download(opts.merge(action: :play))
43
+ end
44
+
17
45
  end
18
46
 
19
47
  end
@@ -0,0 +1,18 @@
1
+ module Helix
2
+
3
+ module Downloadable
4
+
5
+ private
6
+
7
+ def generic_download(opts)
8
+ content_type = opts[:content_type] || ''
9
+ url = config.build_url( action: opts[:action],
10
+ content_type: content_type,
11
+ guid: guid,
12
+ resource_label: plural_resource_label )
13
+ RestClient.get(url, params: {signature: config.signature(:view)})
14
+ end
15
+
16
+ end
17
+
18
+ end
@@ -2,15 +2,6 @@ module Helix
2
2
 
3
3
  module Durationed
4
4
 
5
- def generic_download(opts)
6
- content_type = opts[:content_type] || ''
7
- url = config.build_url( action: opts[:action],
8
- content_type: content_type,
9
- guid: guid,
10
- resource_label: plural_resource_label )
11
- RestClient.get(url, params: {signature: config.signature(:view)})
12
- end
13
-
14
5
  module ClassMethods
15
6
 
16
7
  # Used to import tracks from a URL into the Twistage system.
@@ -1,5 +1,6 @@
1
1
  module Helix
2
2
 
3
+ require 'set'
3
4
  module HasSignatures
4
5
 
5
6
  unless defined?(self::VALID_SIG_TYPES)
data/lib/helix/media.rb CHANGED
@@ -4,7 +4,7 @@ module Helix
4
4
 
5
5
  class Media < Base
6
6
 
7
- include RESTful, Uploadable
7
+ include RESTful, Uploadable, Downloadable
8
8
 
9
9
  end
10
10
 
@@ -2,14 +2,14 @@ require File.expand_path('../spec_helper', __FILE__)
2
2
  require 'helix'
3
3
 
4
4
  describe Helix::Document do
5
- let(:klass) { Helix::Document }
6
5
 
6
+ klass = Helix::Document
7
7
  subject { klass }
8
8
  mods = [ Helix::Base, Helix::Media ]
9
9
  mods.each { |mod| its(:ancestors) { should include(mod) } }
10
- its(:guid_name) { should eq('document_id') }
11
- its(:resource_label_sym) { should be(:document) }
12
- its(:plural_resource_label) { should eq('documents') }
10
+ its(:guid_name) { should eq('document_id') }
11
+ its(:resource_label_sym) { should be(:document) }
12
+ its(:plural_resource_label) { should eq('documents') }
13
13
  [:find, :create, :all, :find_all, :where].each do |crud_call|
14
14
  it { should respond_to(crud_call) }
15
15
  end
@@ -19,12 +19,14 @@ describe Helix::Document do
19
19
  ### INSTANCE METHODS
20
20
 
21
21
  describe "an instance" do
22
- let(:obj) { klass.new({'document_id' => 'some_document_guid'}) }
22
+ obj = klass.new({'document_id' => 'some_document_guid'})
23
23
  subject { obj }
24
24
  its(:resource_label_sym) { should be(:document) }
25
25
  [:destroy, :update].each do |crud_call|
26
26
  it { should respond_to(crud_call) }
27
27
  end
28
+ it_behaves_like "downloads", obj
29
+ it_behaves_like "plays", obj
28
30
  end
29
31
 
30
32
  ### CLASS METHODS
data/spec/media_spec.rb CHANGED
@@ -31,7 +31,7 @@ describe Helix::Media do
31
31
  Helix::Video => :video,
32
32
  }
33
33
 
34
- mods = [ Helix::RESTful, Helix::Uploadable ]
34
+ mods = [ Helix::RESTful, Helix::Uploadable, Helix::Downloadable ]
35
35
  mods.each { |mod| its(:ancestors) { should include(mod) } }
36
36
 
37
37
  describe ".create" do
@@ -43,7 +43,7 @@ describe Helix::Paginates do
43
43
  non_final_response = double(String, headers: {is_last_page: 'false'})
44
44
  RestClient.should_receive(:get).once { non_final_response }
45
45
  @klass.stub(:parse_response_by_url_format).with(non_final_response, :a_url) { {label => [:non_final]} }
46
- @klass.send(meth, :a_url, label, opts)
46
+ @klass.send(meth, :a_url, label, opts)
47
47
  end
48
48
  end
49
49
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: helix
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4.8.pre
4
+ version: 0.0.4.9.pre
5
5
  platform: ruby
6
6
  authors:
7
7
  - Twistage, Inc
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-14 00:00:00.000000000 Z
11
+ date: 2014-01-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -59,50 +59,49 @@ extensions: []
59
59
  extra_rdoc_files: []
60
60
  files:
61
61
  - lib/helix.rb
62
- - lib/helix/album.rb
63
- - lib/helix/audio_playlist.rb
64
62
  - lib/helix/base.rb
65
- - lib/helix/builds_urls.rb
66
- - lib/helix/config.rb
67
- - lib/helix/document.rb
68
- - lib/helix/durationed.rb
69
- - lib/helix/exceptions.rb
70
- - lib/helix/has_signatures.rb
71
- - lib/helix/hash_ext.rb
72
- - lib/helix/image.rb
73
- - lib/helix/library.rb
74
- - lib/helix/media.rb
75
- - lib/helix/object_ext.rb
76
63
  - lib/helix/paginates.rb
77
- - lib/helix/playlist.rb
64
+ - lib/helix/audio_playlist.rb
65
+ - lib/helix/image.rb
78
66
  - lib/helix/restful.rb
67
+ - lib/helix/hash_ext.rb
68
+ - lib/helix/library.rb
69
+ - lib/helix/user.rb
70
+ - lib/helix/has_signatures.rb
71
+ - lib/helix/uploadable.rb
72
+ - lib/helix/downloadable.rb
79
73
  - lib/helix/statistics.rb
74
+ - lib/helix/document.rb
75
+ - lib/helix/durationed.rb
76
+ - lib/helix/object_ext.rb
77
+ - lib/helix/video_playlist.rb
78
+ - lib/helix/media.rb
79
+ - lib/helix/video.rb
80
+ - lib/helix/album.rb
81
+ - lib/helix/builds_urls.rb
80
82
  - lib/helix/tag.rb
83
+ - lib/helix/playlist.rb
81
84
  - lib/helix/track.rb
82
- - lib/helix/uploadable.rb
83
- - lib/helix/user.rb
84
- - lib/helix/video.rb
85
- - lib/helix/video_playlist.rb
86
- - spec/_integration_spec.rb
87
- - spec/album_spec.rb
88
- - spec/audio_playlist_spec.rb
89
- - spec/base_spec.rb
90
- - spec/config_spec.rb
91
- - spec/document_spec.rb
85
+ - lib/helix/exceptions.rb
86
+ - lib/helix/config.rb
92
87
  - spec/durationed_spec.rb
93
- - spec/helix_spec.rb
94
- - spec/image_spec.rb
88
+ - spec/document_spec.rb
95
89
  - spec/library_spec.rb
96
- - spec/media_spec.rb
97
- - spec/paginates_spec.rb
98
- - spec/playlist_spec.rb
99
90
  - spec/spec_helper.rb
100
- - spec/statistics_spec.rb
91
+ - spec/config_spec.rb
92
+ - spec/base_spec.rb
93
+ - spec/playlist_spec.rb
94
+ - spec/video_spec.rb
101
95
  - spec/tag_spec.rb
102
- - spec/track_spec.rb
103
96
  - spec/user_spec.rb
104
- - spec/video_playlist_spec.rb
105
- - spec/video_spec.rb
97
+ - spec/_integration_spec.rb
98
+ - spec/album_spec.rb
99
+ - spec/image_spec.rb
100
+ - spec/helix_spec.rb
101
+ - spec/statistics_spec.rb
102
+ - spec/paginates_spec.rb
103
+ - spec/media_spec.rb
104
+ - spec/track_spec.rb
106
105
  - LICENSE
107
106
  - README.md
108
107
  homepage: https://github.com/Twistage/helix/
@@ -125,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
124
  version: 1.3.1
126
125
  requirements: []
127
126
  rubyforge_project:
128
- rubygems_version: 2.1.4
127
+ rubygems_version: 2.1.9
129
128
  signing_key:
130
129
  specification_version: 4
131
130
  summary: Wrapper library for the video API
File without changes
File without changes