helix 0.0.4.7.pre → 0.0.4.8.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/helix/config.rb +2 -1
- data/lib/helix/has_signatures.rb +28 -5
- data/lib/helix/uploadable.rb +5 -5
- data/spec/config_spec.rb +10 -4
- data/spec/document_spec.rb +3 -3
- data/spec/spec_helper.rb +1 -1
- data/spec/track_spec.rb +1 -1
- data/spec/video_spec.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NDdlNDE3OWNiMmYwNmU5Y2NmOGI0NWU2M2YzYmNjNWRjYzA1NzAyMA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
OTQ2MTRkMzQyZDYwYWQ2NGVkYjVmZjczZmViZTUzMThkZmJlNjI1ZA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZGJjYTk3M2RlMGM1NTA4YzhiOTI3MWU0MGJkODhjOTcwOTliMzkxNDJmZDMy
|
10
|
+
YWVhMmU4ODc1MzgyNDM0NGQ1YWM2ZTFiM2NlMGM4NzlmZTdmYmNjZGExZTgw
|
11
|
+
MDQ4MDFiY2U3MDVmYjczYmIyNTBhZWYyMjU2MDY1MDk3ZTE0ZjY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NDhhNWI4NWU0YWYxYWVkOGFlZjhiYjVlZTY0ZTlhYTYwYTc4OTdkZmU0M2Mz
|
14
|
+
MmFiOWNhMjcxYjliOTA4NTVlZGYzM2Q1MWIxYzNmYjVkZDQ0ZmRmM2Q2NzI3
|
15
|
+
OTllNjcyMDkzOGMxNjk2YjgwMTA0MDM1YWU0YTJhZjkzNDdlNDI=
|
data/lib/helix/config.rb
CHANGED
@@ -38,6 +38,7 @@ module Helix
|
|
38
38
|
# @return [Helix::Config] config returns singleton of Helix::Config
|
39
39
|
def self.load_from_hash(desired_credentials)
|
40
40
|
config = self.instance
|
41
|
+
desired_credentials = desired_credentials.symbolize_keys
|
41
42
|
config.instance_variable_set(:@credentials, desired_credentials)
|
42
43
|
RestClient.proxy = config.proxy
|
43
44
|
config
|
@@ -58,7 +59,7 @@ module Helix
|
|
58
59
|
# @param [String] yaml_file_location the yaml file used for config
|
59
60
|
# @return [Helix::Config] config returns singleton of Helix::Config
|
60
61
|
def self.load_yaml_file(yaml_file_location = DEFAULT_FILENAME)
|
61
|
-
creds = YAML.load(File.open(yaml_file_location))
|
62
|
+
creds = YAML.load(File.open(yaml_file_location))
|
62
63
|
config = load_from_hash(creds)
|
63
64
|
config.instance_variable_set(:@filename, yaml_file_location)
|
64
65
|
config
|
data/lib/helix/has_signatures.rb
CHANGED
@@ -3,9 +3,10 @@ module Helix
|
|
3
3
|
module HasSignatures
|
4
4
|
|
5
5
|
unless defined?(self::VALID_SIG_TYPES)
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
REQUIRES_CONTRIBUTOR = Set.new([ :ingest, :upload ])
|
7
|
+
SIG_DURATION = 1200 # in minutes
|
8
|
+
TIME_OFFSET = 1000 * 60 # 1000 minutes, lower to give some margin of error
|
9
|
+
VALID_SIG_TYPES = Set.new([ :ingest, :update, :upload, :view ])
|
9
10
|
end
|
10
11
|
|
11
12
|
def clear_signatures!
|
@@ -51,6 +52,27 @@ module Helix
|
|
51
52
|
[contributor, library, company]
|
52
53
|
end
|
53
54
|
|
55
|
+
# Returns the proper Twistage ApiController action for the specific sig_type.
|
56
|
+
#
|
57
|
+
# @param [Symbol] sig_type The type of signature required for calls.
|
58
|
+
# @return [String] The action, such as ingest_key in '.../api/ingest_key'
|
59
|
+
# which will return a usable signature of that type when given a proper
|
60
|
+
# licenseKey parameter in the query string.
|
61
|
+
#
|
62
|
+
# Why does this method exist? The key types returnable by the Twistage API
|
63
|
+
# include [ :ingest, :update, :view ]. Typically, :update and :view keys are
|
64
|
+
# memoized, whereas :ingest keys are not.
|
65
|
+
#
|
66
|
+
# However, Helix upload actions require persistent signatures across multiple
|
67
|
+
# sub-actions, so within Helix, we have provided the alias :upload, which
|
68
|
+
# means "memoized :ingest". Interactions with the Twistage API will still be
|
69
|
+
# as :ingest, but the internal label within Helix will be :upload, in order
|
70
|
+
# to easily allow the needed memoization and also disambiguate.
|
71
|
+
def key_action_for(sig_type)
|
72
|
+
key_type = {upload: :ingest}[sig_type] || sig_type
|
73
|
+
"#{key_type}_key"
|
74
|
+
end
|
75
|
+
|
54
76
|
def license_key
|
55
77
|
@credentials[:license_key]
|
56
78
|
end
|
@@ -73,9 +95,10 @@ module Helix
|
|
73
95
|
|
74
96
|
def signature_url_for(sig_type, opts={})
|
75
97
|
contributor, library, company = get_contributor_library_company(opts)
|
76
|
-
|
98
|
+
key_action = key_action_for(sig_type)
|
99
|
+
url = "#{credentials[:site]}/api/#{key_action}?"
|
77
100
|
url += "licenseKey=#{credentials[:license_key]}&duration=#{SIG_DURATION}"
|
78
|
-
url += "&contributor=#{contributor}" if sig_type
|
101
|
+
url += "&contributor=#{contributor}" if REQUIRES_CONTRIBUTOR.include?(sig_type)
|
79
102
|
url += "&library_id=#{library}" if library
|
80
103
|
url += "&company_id=#{company}" if company
|
81
104
|
url
|
data/lib/helix/uploadable.rb
CHANGED
@@ -15,7 +15,7 @@ module Helix
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def upload_server_name(http_open_opts={})
|
18
|
-
upload_get(:http_open,
|
18
|
+
upload_get(:http_open, upload_sig_opts, http_open_opts)
|
19
19
|
end
|
20
20
|
|
21
21
|
def http_open(opts={})
|
@@ -48,17 +48,17 @@ module Helix
|
|
48
48
|
"#{url}?#{query_string}"
|
49
49
|
end
|
50
50
|
|
51
|
-
def
|
51
|
+
def upload_sig_opts
|
52
52
|
cc = config.credentials
|
53
|
-
|
53
|
+
upload_sig_opts = {
|
54
54
|
contributor: cc[:contributor],
|
55
55
|
company_id: cc[:company],
|
56
56
|
library_id: cc[:library],
|
57
57
|
}
|
58
58
|
end
|
59
59
|
|
60
|
-
def upload_get(action,
|
61
|
-
guid = config.signature(:
|
60
|
+
def upload_get(action, upload_sig_opts={}, http_open_opts={})
|
61
|
+
guid = config.signature(:upload, upload_sig_opts)
|
62
62
|
url_opts = {
|
63
63
|
resource_label: "upload_sessions",
|
64
64
|
guid: guid,
|
data/spec/config_spec.rb
CHANGED
@@ -27,6 +27,10 @@ describe Helix::Config do
|
|
27
27
|
subject { klass::ITEMS_PER_PAGE }
|
28
28
|
it { should eq(100) }
|
29
29
|
end
|
30
|
+
describe "REQUIRES_CONTRIBUTOR" do
|
31
|
+
subject { klass::REQUIRES_CONTRIBUTOR }
|
32
|
+
it { should eq(Set.new([:ingest, :upload])) }
|
33
|
+
end
|
30
34
|
describe "SCOPES" do
|
31
35
|
subject { klass::SCOPES }
|
32
36
|
it { should eq([:reseller, :company, :library]) }
|
@@ -45,7 +49,7 @@ describe Helix::Config do
|
|
45
49
|
end
|
46
50
|
describe "VALID_SIG_TYPES" do
|
47
51
|
subject { klass::VALID_SIG_TYPES }
|
48
|
-
it { should eq([:ingest, :update, :view]) }
|
52
|
+
it { should eq(Set.new([:ingest, :update, :upload, :view])) }
|
49
53
|
end
|
50
54
|
end
|
51
55
|
|
@@ -62,9 +66,11 @@ describe Helix::Config do
|
|
62
66
|
end
|
63
67
|
meths.each do |meth|
|
64
68
|
context "when given a Hash" do
|
65
|
-
|
66
|
-
|
67
|
-
|
69
|
+
let(:the_hash_arg) { double('Hash') }
|
70
|
+
it "should set the instance's credentials to the key-symbolized version of that Hash arg" do
|
71
|
+
the_hash_arg.should_receive(:symbolize_keys) { :symbolized }
|
72
|
+
mock_obj.should_receive(:instance_variable_set).with(:@credentials, :symbolized)
|
73
|
+
klass.send(meth, the_hash_arg)
|
68
74
|
end
|
69
75
|
end
|
70
76
|
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 ".upload_sig_opts" do
|
33
|
+
let(:meth) { :upload_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,7 +61,7 @@ describe Helix::Document do
|
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
64
|
-
it_behaves_like "
|
64
|
+
it_behaves_like "upload_sig_opts", Helix::Document
|
65
65
|
it_behaves_like "uploads", Helix::Document
|
66
66
|
|
67
67
|
end
|
data/spec/spec_helper.rb
CHANGED
data/spec/track_spec.rb
CHANGED
data/spec/video_spec.rb
CHANGED
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.
|
4
|
+
version: 0.0.4.8.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-
|
11
|
+
date: 2013-10-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|