helix 0.0.4.4.pre → 0.0.4.5.pre
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.
- checksums.yaml +15 -0
- data/lib/helix/album.rb +0 -4
- data/lib/helix/library.rb +0 -5
- data/lib/helix/paginates.rb +13 -14
- data/lib/helix/uploadable.rb +33 -17
- data/lib/helix/user.rb +0 -4
- data/spec/_integration_spec.rb +1 -1
- data/spec/album_spec.rb +0 -8
- data/spec/config_spec.rb +11 -0
- data/spec/document_spec.rb +4 -107
- data/spec/library_spec.rb +0 -35
- data/spec/media_spec.rb +4 -3
- data/spec/spec_helper.rb +6 -0
- data/spec/track_spec.rb +8 -203
- data/spec/user_spec.rb +0 -4
- data/spec/video_spec.rb +7 -200
- metadata +5 -13
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
ZjA5ODZhZTViNWE2ZjhlYzk2NTMyZTRmMGUzZDA4YjM5NzExNGM1NQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
MWVjMTliMTgyNWJlM2U0NzFmMDU2ZmU5NzhjZjNmNWE0OTM0ZDY0Mg==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
M2M2MGQ2NmMxNTI4YzhjYmJlNzZhNmMyMTgyM2VhYTEyYzI2MmU3NjE3NzA1
|
10
|
+
NzIyZTFlYTUxYmNkYTkyNWNhYjQ4Nzg3ZDQzNmI0NmVjYTJjOTEyZDM5ODgx
|
11
|
+
ZDI1NTFlMTRlOGEyNmQxN2Q5MzA3OTVjMjVjNDE5ZTNhYTUwMTM=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
ZTcwNjBmM2Q3ODVkZjAxNGY5NDA2ZmYwZGRmYjNlY2JlODI0ZDI1Y2RlYjgy
|
14
|
+
YmZkNDE5NTYxODZkZGViYjRhOGU5ZDkyZmQ4ZGQzMWE2MGFkY2VhNWU5NTdl
|
15
|
+
MTIzNzQ3NDgzOTM2OTNhZmRiNWFmODU1YTNjZWVlMWM0ZTRkZTc=
|
data/lib/helix/album.rb
CHANGED
data/lib/helix/library.rb
CHANGED
data/lib/helix/paginates.rb
CHANGED
@@ -16,13 +16,14 @@ module Helix
|
|
16
16
|
# @return [Array] The accumulated attribute Hashes for ORM instances
|
17
17
|
def get_aggregated_data_sets(url, plural_resource_label, original_opts={})
|
18
18
|
data_sets, page, per_page = [], STARTING_PAGE
|
19
|
+
specific_page_requested = specific_page_requested?(original_opts)
|
19
20
|
begin
|
20
21
|
aggregation_opts = {page: page, per_page: ITEMS_PER_PAGE}.merge(original_opts)
|
21
22
|
raw_response = get_response(url, {sig_type: :view}.merge(aggregation_opts))
|
22
23
|
data_set = raw_response[plural_resource_label]
|
23
24
|
data_sets += data_set if data_set
|
24
25
|
page += 1
|
25
|
-
end until
|
26
|
+
end until specific_page_requested || last_page?
|
26
27
|
data_sets
|
27
28
|
end
|
28
29
|
|
@@ -71,19 +72,17 @@ module Helix
|
|
71
72
|
end
|
72
73
|
|
73
74
|
def parse_response_by_url_format(response, url)
|
74
|
-
|
75
|
-
if url =~ /
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
raise "Could not parse #{url}"
|
86
|
-
end
|
75
|
+
return JSON.parse(response) if url =~ /json/
|
76
|
+
return response if url =~ /csv/
|
77
|
+
return parse_xml_response(response, url) if url =~ /xml/
|
78
|
+
raise "Could not parse #{url}"
|
79
|
+
end
|
80
|
+
|
81
|
+
def parse_xml_response(response, url)
|
82
|
+
#TODO: Cleanup Nori and response gsub.
|
83
|
+
Nori.parser = :nokogiri
|
84
|
+
xml = response.gsub(/<custom-fields type='array'>/, "<custom-fields type='hash'>")
|
85
|
+
Nori.parse(xml)
|
87
86
|
end
|
88
87
|
|
89
88
|
end
|
data/lib/helix/uploadable.rb
CHANGED
@@ -6,24 +6,24 @@ module Helix
|
|
6
6
|
|
7
7
|
module ClassMethods
|
8
8
|
|
9
|
-
def upload(file_name)
|
10
|
-
url = upload_server_name
|
9
|
+
def upload(file_name, opts={})
|
10
|
+
url = upload_server_name(opts)
|
11
11
|
payload = { file: File.new(file_name.to_s, "rb") }
|
12
|
-
headers = { multipart:
|
12
|
+
headers = { multipart: true }
|
13
13
|
RestClient.post(url, payload, headers)
|
14
14
|
http_close
|
15
15
|
end
|
16
16
|
|
17
|
-
def upload_server_name
|
18
|
-
upload_get(:http_open,
|
17
|
+
def upload_server_name(http_open_opts={})
|
18
|
+
upload_get(:http_open, ingest_sig_opts, http_open_opts)
|
19
19
|
end
|
20
20
|
|
21
|
-
def http_open
|
22
|
-
upload_server_name
|
21
|
+
def http_open(opts={})
|
22
|
+
upload_server_name(opts)
|
23
23
|
end
|
24
24
|
|
25
|
-
def upload_open
|
26
|
-
upload_server_name
|
25
|
+
def upload_open(opts={})
|
26
|
+
upload_server_name(opts)
|
27
27
|
end
|
28
28
|
|
29
29
|
def http_close
|
@@ -36,21 +36,37 @@ module Helix
|
|
36
36
|
|
37
37
|
private
|
38
38
|
|
39
|
-
|
39
|
+
# OPTIMIZE: This only accepts a flat Hash for http_open_opts, and
|
40
|
+
# doesn't encode. Neither is a big problem for the expected use
|
41
|
+
# cases, but should still be noted.
|
42
|
+
def add_params_to_url(url, http_open_opts)
|
43
|
+
return url if http_open_opts == {}
|
44
|
+
query_string = http_open_opts.inject([]) do |memo,pair|
|
45
|
+
k,v = *pair
|
46
|
+
memo << "#{k}=#{v}"
|
47
|
+
end.join('&')
|
48
|
+
"#{url}?#{query_string}"
|
49
|
+
end
|
50
|
+
|
51
|
+
def ingest_sig_opts
|
40
52
|
cc = config.credentials
|
41
|
-
|
53
|
+
ingest_sig_opts = {
|
42
54
|
contributor: cc[:contributor],
|
43
55
|
company_id: cc[:company],
|
44
56
|
library_id: cc[:library],
|
45
57
|
}
|
46
58
|
end
|
47
59
|
|
48
|
-
def upload_get(action,
|
49
|
-
guid
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
60
|
+
def upload_get(action, ingest_sig_opts={}, http_open_opts={})
|
61
|
+
guid = config.signature(:ingest, ingest_sig_opts)
|
62
|
+
url_opts = {
|
63
|
+
resource_label: "upload_sessions",
|
64
|
+
guid: guid,
|
65
|
+
action: action,
|
66
|
+
content_type: ""
|
67
|
+
}
|
68
|
+
url = config.build_url(url_opts)
|
69
|
+
url = add_params_to_url(url, http_open_opts)
|
54
70
|
RestClient.get(url)
|
55
71
|
end
|
56
72
|
|
data/lib/helix/user.rb
CHANGED
data/spec/_integration_spec.rb
CHANGED
@@ -6,7 +6,7 @@ config = File.exists?(config_filename) ? Helix::Config.load(config_filename) : n
|
|
6
6
|
|
7
7
|
if config.nil?
|
8
8
|
puts "No config, skipping integration specs"
|
9
|
-
elsif %w(1 t true).include?(ENV['SKIP_INTEGRATION'])
|
9
|
+
elsif %w(1 t true).include?(ENV['SKIP_INTEGRATION']) or not %w(1 t true).include?(ENV['INTEGRATION'])
|
10
10
|
puts "Skipping integration specs due to user request"
|
11
11
|
else
|
12
12
|
|
data/spec/album_spec.rb
CHANGED
@@ -14,14 +14,6 @@ describe Helix::Album do
|
|
14
14
|
it { should respond_to(crud_call) }
|
15
15
|
end
|
16
16
|
|
17
|
-
describe ".known_attributes" do
|
18
|
-
let(:meth) { :known_attributes }
|
19
|
-
let(:expected_attrs) { [:title, :description] }
|
20
|
-
it "should equal expected_attrs" do
|
21
|
-
expect(klass.send(meth)).to eq(expected_attrs)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
17
|
describe "Constants"
|
26
18
|
|
27
19
|
describe "an instance" do
|
data/spec/config_spec.rb
CHANGED
@@ -624,4 +624,15 @@ describe Helix::Config do
|
|
624
624
|
end
|
625
625
|
end
|
626
626
|
|
627
|
+
describe "#sub_url_scoping" do
|
628
|
+
context "when given 'base_url_with_companies', {resource_label: 'libraries'})" do
|
629
|
+
subject { obj.send(:sub_url_scoping, 'base_url_with_companies', {resource_label: 'libraries'}) }
|
630
|
+
it { should eq('base_url_with_companies/libraries') }
|
631
|
+
end
|
632
|
+
context "when given 'base_url_without', {resource_label: 'libraries'})" do
|
633
|
+
subject { obj.send(:sub_url_scoping, 'base_url_without', {resource_label: 'libraries'}) }
|
634
|
+
it { should eq('base_url_without/companies/the_co/libraries') }
|
635
|
+
end
|
636
|
+
end
|
637
|
+
|
627
638
|
end
|
data/spec/document_spec.rb
CHANGED
@@ -29,8 +29,8 @@ describe Helix::Document do
|
|
29
29
|
|
30
30
|
### CLASS METHODS
|
31
31
|
|
32
|
-
describe ".
|
33
|
-
let(:meth) { :
|
32
|
+
describe ".ingest_sig_opts" do
|
33
|
+
let(:meth) { :ingest_sig_opts }
|
34
34
|
let(:mock_config) { double(Helix::Config, credentials: {}) }
|
35
35
|
subject { klass.method(meth) }
|
36
36
|
its(:arity) { should eq(0) }
|
@@ -61,110 +61,7 @@ describe Helix::Document do
|
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
64
|
-
|
65
|
-
|
66
|
-
let(:mock_config) { double(Helix::Config) }
|
67
|
-
subject { klass.method(meth) }
|
68
|
-
its(:arity) { should eq(1) }
|
69
|
-
let(:file_hash) { { file: :some_file } }
|
70
|
-
let(:multipart_hash) { { multipart: true } }
|
71
|
-
it "should call upload_server_name and RestClient.post with params" do
|
72
|
-
klass.should_receive(:upload_server_name) { :some_server_url }
|
73
|
-
File.should_receive(:new).with(:some_file.to_s, "rb") { :some_file }
|
74
|
-
RestClient.should_receive(:post).with(:some_server_url,
|
75
|
-
file_hash,
|
76
|
-
multipart_hash)
|
77
|
-
klass.should_receive(:http_close)
|
78
|
-
klass.send(meth, :some_file)
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
describe ".upload_server_name" do
|
83
|
-
let(:meth) { :upload_server_name }
|
84
|
-
let(:mock_config) { double(Helix::Config) }
|
85
|
-
subject { klass.method(meth) }
|
86
|
-
its(:arity) { should eq(0) }
|
87
|
-
let(:url_opts) { { resource_label: "upload_sessions",
|
88
|
-
guid: :some_sig,
|
89
|
-
action: :http_open,
|
90
|
-
content_type: "" } }
|
91
|
-
before { Helix::Config.stub(:instance) { mock_config } }
|
92
|
-
it "should call RestClient.get with correct url building" do
|
93
|
-
klass.should_receive(:ingest_opts) { :ingest_opts }
|
94
|
-
mock_config.should_receive(:build_url).with(url_opts) { :url }
|
95
|
-
mock_config.should_receive(:signature).with(:ingest, :ingest_opts) { :some_sig }
|
96
|
-
RestClient.should_receive(:get).with(:url)
|
97
|
-
klass.send(meth)
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
describe ".http_close" do
|
102
|
-
let(:meth) { :http_close }
|
103
|
-
let(:mock_config) { double(Helix::Config) }
|
104
|
-
subject { klass.method(meth) }
|
105
|
-
its(:arity) { should eq(0) }
|
106
|
-
let(:url_opts) { { resource_label: "upload_sessions",
|
107
|
-
guid: :some_sig,
|
108
|
-
action: :http_close,
|
109
|
-
content_type: "" } }
|
110
|
-
before { Helix::Config.stub(:instance) { mock_config } }
|
111
|
-
it "should call RestClient.get with correct url building" do
|
112
|
-
mock_config.should_receive(:build_url).with(url_opts) { :url }
|
113
|
-
mock_config.should_receive(:signature).with(:ingest, {}) { :some_sig }
|
114
|
-
RestClient.should_receive(:get).with(:url)
|
115
|
-
klass.send(meth)
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
describe ".upload_get" do
|
120
|
-
let(:meth) { :upload_get }
|
121
|
-
let(:mock_config) { double(Helix::Config) }
|
122
|
-
subject { klass.method(meth) }
|
123
|
-
its(:arity) { should eq(-2) }
|
124
|
-
let(:url_opts) { { resource_label: "upload_sessions",
|
125
|
-
guid: :some_sig,
|
126
|
-
action: :upload_get,
|
127
|
-
content_type: "" } }
|
128
|
-
before { Helix::Config.stub(:instance) { mock_config } }
|
129
|
-
it "should call RestClient.get with correct url building" do
|
130
|
-
mock_config.should_receive(:build_url).with(url_opts) { :url }
|
131
|
-
mock_config.should_receive(:signature).with(:ingest, {}) { :some_sig }
|
132
|
-
RestClient.should_receive(:get).with(:url)
|
133
|
-
klass.send(meth, :upload_get)
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
describe ".http_open" do
|
138
|
-
let(:meth) { :http_open }
|
139
|
-
let(:mock_config) { double(Helix::Config) }
|
140
|
-
subject { klass.method(meth) }
|
141
|
-
its(:arity) { should eq(0) }
|
142
|
-
it "should call upload_server_name" do
|
143
|
-
klass.should_receive(:upload_server_name)
|
144
|
-
klass.send(meth)
|
145
|
-
end
|
146
|
-
end
|
147
|
-
|
148
|
-
describe ".upload_open" do
|
149
|
-
let(:meth) { :upload_open }
|
150
|
-
let(:mock_config) { double(Helix::Config) }
|
151
|
-
subject { klass.method(meth) }
|
152
|
-
its(:arity) { should eq(0) }
|
153
|
-
it "should call upload_server_name" do
|
154
|
-
klass.should_receive(:upload_server_name)
|
155
|
-
klass.send(meth)
|
156
|
-
end
|
157
|
-
end
|
158
|
-
|
159
|
-
describe ".upload_close" do
|
160
|
-
let(:meth) { :upload_close }
|
161
|
-
let(:mock_config) { double(Helix::Config) }
|
162
|
-
subject { klass.method(meth) }
|
163
|
-
its(:arity) { should eq(0) }
|
164
|
-
it "should call upload_server_name" do
|
165
|
-
klass.should_receive(:http_close)
|
166
|
-
klass.send(meth)
|
167
|
-
end
|
168
|
-
end
|
64
|
+
it_behaves_like "ingest_sig_opts", Helix::Document
|
65
|
+
it_behaves_like "uploads", Helix::Document
|
169
66
|
|
170
67
|
end
|
data/spec/library_spec.rb
CHANGED
@@ -17,43 +17,8 @@ describe Helix::Library do
|
|
17
17
|
it { should respond_to(crud_call) }
|
18
18
|
end
|
19
19
|
|
20
|
-
describe ".known_attributes" do
|
21
|
-
let(:meth) { :known_attributes }
|
22
|
-
let(:expected_attrs) { [ :player_profile,
|
23
|
-
:ingest_profile,
|
24
|
-
:secure_stream_callback_url,
|
25
|
-
:hooks_attributes] }
|
26
|
-
it "should equal expected_attrs" do
|
27
|
-
expect(klass.send(meth)).to eq(expected_attrs)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
20
|
describe "Constants"
|
32
21
|
|
33
|
-
describe ".find" do
|
34
|
-
let(:meth) { :find }
|
35
|
-
subject { klass.method(meth) }
|
36
|
-
its(:arity) { should eq(-2) }
|
37
|
-
context "when given just a nickname" do
|
38
|
-
=begin
|
39
|
-
it "should call super(nickname, {content_type: :xml})" do
|
40
|
-
Helix::Base.should_not_receive(:load)
|
41
|
-
Helix::RESTful.should_not_receive(:find)
|
42
|
-
expect(klass.send(meth, :a_nickname)).to be :blah
|
43
|
-
end
|
44
|
-
=end
|
45
|
-
end
|
46
|
-
context "when given a nickname and opts" do
|
47
|
-
=begin
|
48
|
-
it "should call super(nickname, opts.merge(content_type: :xml))" do
|
49
|
-
Helix::Base.should_not_receive(:load)
|
50
|
-
Helix::RESTful.should_not_receive(:find)
|
51
|
-
expect(klass.send(meth, :a_nickname, {k: :v})).to be :blah
|
52
|
-
end
|
53
|
-
=end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
22
|
describe "an instance" do
|
58
23
|
let(:obj) { klass.new({'library_id' => 'some_library_id'}) }
|
59
24
|
subject { obj }
|
data/spec/media_spec.rb
CHANGED
@@ -17,7 +17,7 @@ describe Helix::Media do
|
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
-
klasses = [ Helix::Album, Helix::Document, Helix::Image, Helix::Track, Helix::User, Helix::Video ]
|
20
|
+
klasses = [ Helix::Album, Helix::Document, Helix::Image, Helix::Library, Helix::Track, Helix::User, Helix::Video ]
|
21
21
|
klasses.each do |klass|
|
22
22
|
|
23
23
|
subject { klass }
|
@@ -168,8 +168,9 @@ describe Helix::Media do
|
|
168
168
|
klass.should_receive(:new).with({attributes: {guid_name => guid}, config: mock_config})
|
169
169
|
klass.send(meth, guid, content_type: content_type)
|
170
170
|
end
|
171
|
-
|
172
|
-
|
171
|
+
internal_content_type = (klass == Helix::Library) ? :xml : content_type
|
172
|
+
it "should load(content_type: #{internal_content_type}" do
|
173
|
+
mock_obj.should_receive(:load).with(content_type: internal_content_type)
|
173
174
|
klass.send(meth, guid, content_type: content_type)
|
174
175
|
end
|
175
176
|
end
|
data/spec/spec_helper.rb
CHANGED
data/spec/track_spec.rb
CHANGED
@@ -3,8 +3,8 @@ require 'helix'
|
|
3
3
|
|
4
4
|
describe Helix::Track do
|
5
5
|
|
6
|
-
|
7
|
-
subject
|
6
|
+
klass = Helix::Track
|
7
|
+
subject { klass }
|
8
8
|
mods = [ Helix::Base, Helix::Durationed, Helix::Media ]
|
9
9
|
mods.each { |mod| its(:ancestors) { should include(mod) } }
|
10
10
|
its(:guid_name) { should eq('track_id') }
|
@@ -19,214 +19,19 @@ describe Helix::Track do
|
|
19
19
|
### INSTANCE METHODS
|
20
20
|
|
21
21
|
describe "an instance" do
|
22
|
-
|
23
|
-
subject
|
22
|
+
obj = klass.new({'track_id' => 'some_track_guid'})
|
23
|
+
subject { obj }
|
24
24
|
its(:resource_label_sym) { should be(:track) }
|
25
25
|
[:destroy, :update].each do |crud_call|
|
26
26
|
it { should respond_to(crud_call) }
|
27
27
|
end
|
28
|
-
|
29
|
-
|
30
|
-
let(:meth) { :download }
|
31
|
-
let(:mock_config) { double(Helix::Config, build_url: :the_built_url, signature: :some_sig) }
|
32
|
-
subject { obj.method(meth) }
|
33
|
-
let(:params) { { params: {signature: :some_sig } } }
|
34
|
-
before do
|
35
|
-
obj.stub(:config) { mock_config }
|
36
|
-
obj.stub(:guid) { :some_guid }
|
37
|
-
obj.stub(:plural_resource_label) { :resource_label }
|
38
|
-
RestClient.stub(:get) { '' }
|
39
|
-
end
|
40
|
-
{ '' => '', mp3: :mp3, nil => '' }.each do |arg,actual|
|
41
|
-
build_url_h = {action: :file, content_type: actual, guid: :some_guid, resource_label: :resource_label}
|
42
|
-
context "when given {content_type: #{arg}" do
|
43
|
-
it "should build_url(#{build_url_h})" do
|
44
|
-
mock_config.should_receive(:build_url).with(build_url_h)
|
45
|
-
obj.send(meth, content_type: arg)
|
46
|
-
end
|
47
|
-
it "should get a view signature" do
|
48
|
-
mock_config.should_receive(:signature).with(:view) { :some_sig }
|
49
|
-
obj.send(meth, content_type: arg)
|
50
|
-
end
|
51
|
-
it "should return an HTTP get to the built URL with the view sig" do
|
52
|
-
mock_config.stub(:build_url).with(build_url_h) { :the_url }
|
53
|
-
RestClient.should_receive(:get).with(:the_url, params) { :expected }
|
54
|
-
expect(obj.send(meth, content_type: arg)).to be(:expected)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
describe "#play" do
|
61
|
-
let(:meth) { :play }
|
62
|
-
let(:mock_config) { double(Helix::Config, build_url: :the_built_url, signature: :some_sig) }
|
63
|
-
subject { obj.method(meth) }
|
64
|
-
let(:params) { { params: {signature: :some_sig } } }
|
65
|
-
before do
|
66
|
-
obj.stub(:config) { mock_config }
|
67
|
-
obj.stub(:guid) { :some_guid }
|
68
|
-
obj.stub(:plural_resource_label) { :resource_label }
|
69
|
-
RestClient.stub(:get) { '' }
|
70
|
-
end
|
71
|
-
{ '' => '', mp3: :mp3, nil => '' }.each do |arg,actual|
|
72
|
-
build_url_h = {action: :play, content_type: actual, guid: :some_guid, resource_label: :resource_label}
|
73
|
-
context "when given {content_type: #{arg}" do
|
74
|
-
it "should build_url(#{build_url_h})" do
|
75
|
-
mock_config.should_receive(:build_url).with(build_url_h)
|
76
|
-
obj.send(meth, content_type: arg)
|
77
|
-
end
|
78
|
-
it "should get a view signature" do
|
79
|
-
mock_config.should_receive(:signature).with(:view) { :some_sig }
|
80
|
-
obj.send(meth, content_type: arg)
|
81
|
-
end
|
82
|
-
it "should return an HTTP get to the built URL with the view sig" do
|
83
|
-
mock_config.stub(:build_url).with(build_url_h) { :the_url }
|
84
|
-
RestClient.should_receive(:get).with(:the_url, params) { :expected }
|
85
|
-
expect(obj.send(meth, content_type: arg)).to be(:expected)
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
28
|
+
it_behaves_like "downloads", obj
|
29
|
+
it_behaves_like "plays", obj
|
91
30
|
end
|
92
31
|
|
93
32
|
### CLASS METHODS
|
94
33
|
|
95
|
-
|
96
|
-
|
97
|
-
let(:mock_config) { double(Helix::Config, credentials: {}) }
|
98
|
-
subject { klass.method(meth) }
|
99
|
-
its(:arity) { should eq(0) }
|
100
|
-
it "should be private" do expect(klass.private_methods).to include(meth) end
|
101
|
-
context "when called" do
|
102
|
-
subject { klass.send(meth) }
|
103
|
-
before(:each) do klass.stub(:config) { mock_config } end
|
104
|
-
it "should be a Hash" do expect(klass.send(meth)).to be_a(Hash) end
|
105
|
-
its(:keys) { should match_array([:contributor, :company_id, :library_id]) }
|
106
|
-
context "the value for :contributor" do
|
107
|
-
it "should be config.credentials[:contributor]" do
|
108
|
-
mock_config.should_receive(:credentials) { {contributor: :expected_contributor} }
|
109
|
-
expect(klass.send(meth)[:contributor]).to be(:expected_contributor)
|
110
|
-
end
|
111
|
-
end
|
112
|
-
context "the value for :company_id" do
|
113
|
-
it "should be config.credentials[:company]" do
|
114
|
-
mock_config.should_receive(:credentials) { {company: :expected_company} }
|
115
|
-
expect(klass.send(meth)[:company_id]).to be(:expected_company)
|
116
|
-
end
|
117
|
-
end
|
118
|
-
context "the value for :library_id" do
|
119
|
-
it "should be config.credentials[:library]" do
|
120
|
-
mock_config.should_receive(:credentials) { {library: :expected_library} }
|
121
|
-
expect(klass.send(meth)[:library_id]).to be(:expected_library)
|
122
|
-
end
|
123
|
-
end
|
124
|
-
end
|
125
|
-
end
|
126
|
-
describe ".upload" do
|
127
|
-
let(:meth) { :upload }
|
128
|
-
let(:mock_config) { double(Helix::Config) }
|
129
|
-
subject { klass.method(meth) }
|
130
|
-
its(:arity) { should eq(1) }
|
131
|
-
let(:file_hash) { { file: :some_file } }
|
132
|
-
let(:multipart_hash) { { multipart: true } }
|
133
|
-
it "should call upload_server_name and RestClient.post with params" do
|
134
|
-
klass.should_receive(:upload_server_name) { :some_server_url }
|
135
|
-
File.should_receive(:new).with(:some_file.to_s, "rb") { :some_file }
|
136
|
-
RestClient.should_receive(:post).with(:some_server_url,
|
137
|
-
file_hash,
|
138
|
-
multipart_hash)
|
139
|
-
klass.should_receive(:http_close)
|
140
|
-
klass.send(meth, :some_file)
|
141
|
-
end
|
142
|
-
end
|
143
|
-
|
144
|
-
describe ".upload_server_name" do
|
145
|
-
let(:meth) { :upload_server_name }
|
146
|
-
let(:mock_config) { double(Helix::Config) }
|
147
|
-
subject { klass.method(meth) }
|
148
|
-
its(:arity) { should eq(0) }
|
149
|
-
let(:url_opts) { { resource_label: "upload_sessions",
|
150
|
-
guid: :some_sig,
|
151
|
-
action: :http_open,
|
152
|
-
content_type: "" } }
|
153
|
-
before { Helix::Config.stub(:instance) { mock_config } }
|
154
|
-
it "should call RestClient.get with correct url building" do
|
155
|
-
klass.should_receive(:ingest_opts) { :ingest_opts }
|
156
|
-
mock_config.should_receive(:build_url).with(url_opts) { :url }
|
157
|
-
mock_config.should_receive(:signature).with(:ingest, :ingest_opts) { :some_sig }
|
158
|
-
RestClient.should_receive(:get).with(:url)
|
159
|
-
klass.send(meth)
|
160
|
-
end
|
161
|
-
end
|
162
|
-
|
163
|
-
describe ".http_close" do
|
164
|
-
let(:meth) { :http_close }
|
165
|
-
let(:mock_config) { double(Helix::Config) }
|
166
|
-
subject { klass.method(meth) }
|
167
|
-
its(:arity) { should eq(0) }
|
168
|
-
let(:url_opts) { { resource_label: "upload_sessions",
|
169
|
-
guid: :some_sig,
|
170
|
-
action: :http_close,
|
171
|
-
content_type: "" } }
|
172
|
-
before { Helix::Config.stub(:instance) { mock_config } }
|
173
|
-
it "should call RestClient.get with correct url building" do
|
174
|
-
mock_config.should_receive(:build_url).with(url_opts) { :url }
|
175
|
-
mock_config.should_receive(:signature).with(:ingest, {}) { :some_sig }
|
176
|
-
RestClient.should_receive(:get).with(:url)
|
177
|
-
klass.send(meth)
|
178
|
-
end
|
179
|
-
end
|
180
|
-
|
181
|
-
describe ".upload_get" do
|
182
|
-
let(:meth) { :upload_get }
|
183
|
-
let(:mock_config) { double(Helix::Config) }
|
184
|
-
subject { klass.method(meth) }
|
185
|
-
its(:arity) { should eq(-2) }
|
186
|
-
let(:url_opts) { { resource_label: "upload_sessions",
|
187
|
-
guid: :some_sig,
|
188
|
-
action: :upload_get,
|
189
|
-
content_type: "" } }
|
190
|
-
before { Helix::Config.stub(:instance) { mock_config } }
|
191
|
-
it "should call RestClient.get with correct url building" do
|
192
|
-
mock_config.should_receive(:build_url).with(url_opts) { :url }
|
193
|
-
mock_config.should_receive(:signature).with(:ingest, {}) { :some_sig }
|
194
|
-
RestClient.should_receive(:get).with(:url)
|
195
|
-
klass.send(meth, :upload_get)
|
196
|
-
end
|
197
|
-
end
|
198
|
-
|
199
|
-
describe ".http_open" do
|
200
|
-
let(:meth) { :http_open }
|
201
|
-
let(:mock_config) { double(Helix::Config) }
|
202
|
-
subject { klass.method(meth) }
|
203
|
-
its(:arity) { should eq(0) }
|
204
|
-
it "should call upload_server_name" do
|
205
|
-
klass.should_receive(:upload_server_name)
|
206
|
-
klass.send(meth)
|
207
|
-
end
|
208
|
-
end
|
209
|
-
|
210
|
-
describe ".upload_open" do
|
211
|
-
let(:meth) { :upload_open }
|
212
|
-
let(:mock_config) { double(Helix::Config) }
|
213
|
-
subject { klass.method(meth) }
|
214
|
-
its(:arity) { should eq(0) }
|
215
|
-
it "should call upload_server_name" do
|
216
|
-
klass.should_receive(:upload_server_name)
|
217
|
-
klass.send(meth)
|
218
|
-
end
|
219
|
-
end
|
220
|
-
|
221
|
-
describe ".upload_close" do
|
222
|
-
let(:meth) { :upload_close }
|
223
|
-
let(:mock_config) { double(Helix::Config) }
|
224
|
-
subject { klass.method(meth) }
|
225
|
-
its(:arity) { should eq(0) }
|
226
|
-
it "should call upload_server_name" do
|
227
|
-
klass.should_receive(:http_close)
|
228
|
-
klass.send(meth)
|
229
|
-
end
|
230
|
-
end
|
34
|
+
it_behaves_like "ingest_sig_opts", Helix::Track
|
35
|
+
it_behaves_like "uploads", Helix::Track
|
231
36
|
|
232
37
|
end
|
data/spec/user_spec.rb
CHANGED
data/spec/video_spec.rb
CHANGED
@@ -7,8 +7,8 @@ describe Helix::Video do
|
|
7
7
|
{ list: { entry: values[:url_params] || {} } }.to_xml(root: :add)
|
8
8
|
end
|
9
9
|
|
10
|
-
|
11
|
-
subject
|
10
|
+
klass = Helix::Video
|
11
|
+
subject { klass }
|
12
12
|
mods = [ Helix::Base, Helix::Durationed, Helix::Media ]
|
13
13
|
mods.each { |mod| its(:ancestors) { should include(mod) } }
|
14
14
|
its(:guid_name) { should eq('video_id') }
|
@@ -23,71 +23,12 @@ describe Helix::Video do
|
|
23
23
|
### INSTANCE METHODS
|
24
24
|
|
25
25
|
describe "an instance" do
|
26
|
-
|
26
|
+
obj = klass.new({video_id: 'some_video_guid'})
|
27
27
|
subject { obj }
|
28
28
|
its(:resource_label_sym) { should be(:video) }
|
29
29
|
|
30
|
-
|
31
|
-
|
32
|
-
let(:mock_config) { double(Helix::Config, build_url: :the_built_url, signature: :some_sig) }
|
33
|
-
subject { obj.method(meth) }
|
34
|
-
let(:params) { { params: {signature: :some_sig } } }
|
35
|
-
before do
|
36
|
-
obj.stub(:config) { mock_config }
|
37
|
-
obj.stub(:guid) { :some_guid }
|
38
|
-
obj.stub(:plural_resource_label) { :resource_label }
|
39
|
-
RestClient.stub(:get) { '' }
|
40
|
-
end
|
41
|
-
{ '' => '', mp3: :mp3, nil => '' }.each do |arg,actual|
|
42
|
-
build_url_h = {action: :file, content_type: actual, guid: :some_guid, resource_label: :resource_label}
|
43
|
-
context "when given {content_type: #{arg}" do
|
44
|
-
it "should build_url(#{build_url_h})" do
|
45
|
-
mock_config.should_receive(:build_url).with(build_url_h)
|
46
|
-
obj.send(meth, content_type: arg)
|
47
|
-
end
|
48
|
-
it "should get a view signature" do
|
49
|
-
mock_config.should_receive(:signature).with(:view) { :some_sig }
|
50
|
-
obj.send(meth, content_type: arg)
|
51
|
-
end
|
52
|
-
it "should return an HTTP get to the built URL with the view sig" do
|
53
|
-
mock_config.stub(:build_url).with(build_url_h) { :the_url }
|
54
|
-
RestClient.should_receive(:get).with(:the_url, params) { :expected }
|
55
|
-
expect(obj.send(meth, content_type: arg)).to be(:expected)
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
describe "#play" do
|
62
|
-
let(:meth) { :play }
|
63
|
-
let(:mock_config) { double(Helix::Config, build_url: :the_built_url, signature: :some_sig) }
|
64
|
-
subject { obj.method(meth) }
|
65
|
-
let(:params) { { params: {signature: :some_sig } } }
|
66
|
-
before do
|
67
|
-
obj.stub(:config) { mock_config }
|
68
|
-
obj.stub(:guid) { :some_guid }
|
69
|
-
obj.stub(:plural_resource_label) { :resource_label }
|
70
|
-
RestClient.stub(:get) { '' }
|
71
|
-
end
|
72
|
-
{ '' => '', mp3: :mp3, nil => '' }.each do |arg,actual|
|
73
|
-
build_url_h = {action: :play, content_type: actual, guid: :some_guid, resource_label: :resource_label}
|
74
|
-
context "when given {content_type: #{arg}" do
|
75
|
-
it "should build_url(#{build_url_h})" do
|
76
|
-
mock_config.should_receive(:build_url).with(build_url_h)
|
77
|
-
obj.send(meth, content_type: arg)
|
78
|
-
end
|
79
|
-
it "should get a view signature" do
|
80
|
-
mock_config.should_receive(:signature).with(:view) { :some_sig }
|
81
|
-
obj.send(meth, content_type: arg)
|
82
|
-
end
|
83
|
-
it "should return an HTTP get to the built URL with the view sig" do
|
84
|
-
mock_config.stub(:build_url).with(build_url_h) { :the_url }
|
85
|
-
RestClient.should_receive(:get).with(:the_url, params) { :expected }
|
86
|
-
expect(obj.send(meth, content_type: arg)).to be(:expected)
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
30
|
+
it_behaves_like "downloads", obj
|
31
|
+
it_behaves_like "plays", obj
|
91
32
|
|
92
33
|
describe "#stillframe" do
|
93
34
|
let(:meth) { :stillframe }
|
@@ -182,142 +123,8 @@ describe Helix::Video do
|
|
182
123
|
|
183
124
|
### CLASS METHODS
|
184
125
|
|
185
|
-
|
186
|
-
|
187
|
-
let(:mock_config) { double(Helix::Config, credentials: {}) }
|
188
|
-
subject { klass.method(meth) }
|
189
|
-
its(:arity) { should eq(0) }
|
190
|
-
it "should be private" do expect(klass.private_methods).to include(meth) end
|
191
|
-
context "when called" do
|
192
|
-
subject { klass.send(meth) }
|
193
|
-
before(:each) do klass.stub(:config) { mock_config } end
|
194
|
-
it "should be a Hash" do expect(klass.send(meth)).to be_a(Hash) end
|
195
|
-
its(:keys) { should match_array([:contributor, :company_id, :library_id]) }
|
196
|
-
context "the value for :contributor" do
|
197
|
-
it "should be config.credentials[:contributor]" do
|
198
|
-
mock_config.should_receive(:credentials) { {contributor: :expected_contributor} }
|
199
|
-
expect(klass.send(meth)[:contributor]).to be(:expected_contributor)
|
200
|
-
end
|
201
|
-
end
|
202
|
-
context "the value for :company_id" do
|
203
|
-
it "should be config.credentials[:company]" do
|
204
|
-
mock_config.should_receive(:credentials) { {company: :expected_company} }
|
205
|
-
expect(klass.send(meth)[:company_id]).to be(:expected_company)
|
206
|
-
end
|
207
|
-
end
|
208
|
-
context "the value for :library_id" do
|
209
|
-
it "should be config.credentials[:library]" do
|
210
|
-
mock_config.should_receive(:credentials) { {library: :expected_library} }
|
211
|
-
expect(klass.send(meth)[:library_id]).to be(:expected_library)
|
212
|
-
end
|
213
|
-
end
|
214
|
-
end
|
215
|
-
end
|
216
|
-
describe ".upload" do
|
217
|
-
let(:meth) { :upload }
|
218
|
-
let(:mock_config) { double(Helix::Config) }
|
219
|
-
subject { klass.method(meth) }
|
220
|
-
its(:arity) { should eq(1) }
|
221
|
-
let(:file_hash) { { file: :some_file } }
|
222
|
-
let(:multipart_hash) { { multipart: true } }
|
223
|
-
it "should call upload_server_name and RestClient.post with params" do
|
224
|
-
klass.should_receive(:upload_server_name) { :some_server_url }
|
225
|
-
File.should_receive(:new).with(:some_file.to_s, "rb") { :some_file }
|
226
|
-
RestClient.should_receive(:post).with(:some_server_url,
|
227
|
-
file_hash,
|
228
|
-
multipart_hash)
|
229
|
-
klass.should_receive(:http_close)
|
230
|
-
klass.send(meth, :some_file)
|
231
|
-
end
|
232
|
-
end
|
233
|
-
|
234
|
-
describe ".upload_server_name" do
|
235
|
-
let(:meth) { :upload_server_name }
|
236
|
-
let(:mock_config) { double(Helix::Config) }
|
237
|
-
subject { klass.method(meth) }
|
238
|
-
its(:arity) { should eq(0) }
|
239
|
-
let(:url_opts) { { resource_label: "upload_sessions",
|
240
|
-
guid: :some_sig,
|
241
|
-
action: :http_open,
|
242
|
-
content_type: "" } }
|
243
|
-
before { Helix::Config.stub(:instance) { mock_config } }
|
244
|
-
it "should call RestClient.get with correct url building" do
|
245
|
-
klass.should_receive(:ingest_opts) { :ingest_opts }
|
246
|
-
mock_config.should_receive(:build_url).with(url_opts) { :url }
|
247
|
-
mock_config.should_receive(:signature).with(:ingest, :ingest_opts) { :some_sig }
|
248
|
-
RestClient.should_receive(:get).with(:url)
|
249
|
-
klass.send(meth)
|
250
|
-
end
|
251
|
-
end
|
252
|
-
|
253
|
-
describe ".http_close" do
|
254
|
-
let(:meth) { :http_close }
|
255
|
-
let(:mock_config) { double(Helix::Config) }
|
256
|
-
subject { klass.method(meth) }
|
257
|
-
its(:arity) { should eq(0) }
|
258
|
-
let(:url_opts) { { resource_label: "upload_sessions",
|
259
|
-
guid: :some_sig,
|
260
|
-
action: :http_close,
|
261
|
-
content_type: "" } }
|
262
|
-
before { Helix::Config.stub(:instance) { mock_config } }
|
263
|
-
it "should call RestClient.get with correct url building" do
|
264
|
-
mock_config.should_receive(:build_url).with(url_opts) { :url }
|
265
|
-
mock_config.should_receive(:signature).with(:ingest, {}) { :some_sig }
|
266
|
-
RestClient.should_receive(:get).with(:url)
|
267
|
-
klass.send(meth)
|
268
|
-
end
|
269
|
-
end
|
270
|
-
|
271
|
-
describe ".upload_get" do
|
272
|
-
let(:meth) { :upload_get }
|
273
|
-
let(:mock_config) { double(Helix::Config) }
|
274
|
-
subject { klass.method(meth) }
|
275
|
-
its(:arity) { should eq(-2) }
|
276
|
-
let(:url_opts) { { resource_label: "upload_sessions",
|
277
|
-
guid: :some_sig,
|
278
|
-
action: :upload_get,
|
279
|
-
content_type: "" } }
|
280
|
-
before { Helix::Config.stub(:instance) { mock_config } }
|
281
|
-
it "should call RestClient.get with correct url building" do
|
282
|
-
mock_config.should_receive(:build_url).with(url_opts) { :url }
|
283
|
-
mock_config.should_receive(:signature).with(:ingest, {}) { :some_sig }
|
284
|
-
RestClient.should_receive(:get).with(:url)
|
285
|
-
klass.send(meth, :upload_get)
|
286
|
-
end
|
287
|
-
end
|
288
|
-
|
289
|
-
describe ".http_open" do
|
290
|
-
let(:meth) { :http_open }
|
291
|
-
let(:mock_config) { double(Helix::Config) }
|
292
|
-
subject { klass.method(meth) }
|
293
|
-
its(:arity) { should eq(0) }
|
294
|
-
it "should call upload_server_name" do
|
295
|
-
klass.should_receive(:upload_server_name)
|
296
|
-
klass.send(meth)
|
297
|
-
end
|
298
|
-
end
|
299
|
-
|
300
|
-
describe ".upload_open" do
|
301
|
-
let(:meth) { :upload_open }
|
302
|
-
let(:mock_config) { double(Helix::Config) }
|
303
|
-
subject { klass.method(meth) }
|
304
|
-
its(:arity) { should eq(0) }
|
305
|
-
it "should call upload_server_name" do
|
306
|
-
klass.should_receive(:upload_server_name)
|
307
|
-
klass.send(meth)
|
308
|
-
end
|
309
|
-
end
|
310
|
-
|
311
|
-
describe ".upload_close" do
|
312
|
-
let(:meth) { :upload_close }
|
313
|
-
let(:mock_config) { double(Helix::Config) }
|
314
|
-
subject { klass.method(meth) }
|
315
|
-
its(:arity) { should eq(0) }
|
316
|
-
it "should call upload_server_name" do
|
317
|
-
klass.should_receive(:http_close)
|
318
|
-
klass.send(meth)
|
319
|
-
end
|
320
|
-
end
|
126
|
+
it_behaves_like "ingest_sig_opts", Helix::Video
|
127
|
+
it_behaves_like "uploads", Helix::Video
|
321
128
|
|
322
129
|
describe ".slice" do
|
323
130
|
let(:meth) { :slice }
|
metadata
CHANGED
@@ -1,20 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: helix
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.4.
|
5
|
-
prerelease: 8
|
4
|
+
version: 0.0.4.5.pre
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Twistage, Inc
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-
|
11
|
+
date: 2013-10-02 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: json
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
17
|
- - ! '>='
|
20
18
|
- !ruby/object:Gem::Version
|
@@ -22,7 +20,6 @@ dependencies:
|
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
24
|
- - ! '>='
|
28
25
|
- !ruby/object:Gem::Version
|
@@ -30,7 +27,6 @@ dependencies:
|
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: rest-client
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
31
|
- - '='
|
36
32
|
- !ruby/object:Gem::Version
|
@@ -38,7 +34,6 @@ dependencies:
|
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
38
|
- - '='
|
44
39
|
- !ruby/object:Gem::Version
|
@@ -46,7 +41,6 @@ dependencies:
|
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: nori
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
45
|
- - '='
|
52
46
|
- !ruby/object:Gem::Version
|
@@ -54,7 +48,6 @@ dependencies:
|
|
54
48
|
type: :runtime
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
52
|
- - '='
|
60
53
|
- !ruby/object:Gem::Version
|
@@ -115,27 +108,26 @@ files:
|
|
115
108
|
homepage: https://github.com/Twistage/helix/
|
116
109
|
licenses:
|
117
110
|
- 3-Clause BSD
|
111
|
+
metadata: {}
|
118
112
|
post_install_message:
|
119
113
|
rdoc_options: []
|
120
114
|
require_paths:
|
121
115
|
- lib
|
122
116
|
required_ruby_version: !ruby/object:Gem::Requirement
|
123
|
-
none: false
|
124
117
|
requirements:
|
125
118
|
- - ! '>='
|
126
119
|
- !ruby/object:Gem::Version
|
127
120
|
version: '0'
|
128
121
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
129
|
-
none: false
|
130
122
|
requirements:
|
131
123
|
- - ! '>'
|
132
124
|
- !ruby/object:Gem::Version
|
133
125
|
version: 1.3.1
|
134
126
|
requirements: []
|
135
127
|
rubyforge_project:
|
136
|
-
rubygems_version: 1.
|
128
|
+
rubygems_version: 2.1.4
|
137
129
|
signing_key:
|
138
|
-
specification_version:
|
130
|
+
specification_version: 4
|
139
131
|
summary: Wrapper library for the video API
|
140
132
|
test_files: []
|
141
133
|
has_rdoc: yard
|