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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OGNmMmI1MWM4NzhjNWM5YjAyOTkzNGJhZjA1YjIzMTUyYThkMDQxNA==
4
+ NDdlNDE3OWNiMmYwNmU5Y2NmOGI0NWU2M2YzYmNjNWRjYzA1NzAyMA==
5
5
  data.tar.gz: !binary |-
6
- YmM3MWJlYmIwMmI1ZDdlMjQyZjhkNzQ0YmMxMGFhMmZlNjMxNDhkZQ==
6
+ OTQ2MTRkMzQyZDYwYWQ2NGVkYjVmZjczZmViZTUzMThkZmJlNjI1ZA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MDhiM2ZkYTcyZTRlNTVjODkyZWI1NGY3YTY4MGM5ODA5MWUyNmRkNmM3MGEz
10
- Mzg0ZjNiOWZlYjkxMjVlMjUxYTY4MTdmZjgzOGMxYjU0OTQxZTkzYWE5N2Nk
11
- NWY3MTdiMmMxMGZkODkzYzc5ZmNmZjYwZWJhMjY5MGY2Mjc1MTc=
9
+ ZGJjYTk3M2RlMGM1NTA4YzhiOTI3MWU0MGJkODhjOTcwOTliMzkxNDJmZDMy
10
+ YWVhMmU4ODc1MzgyNDM0NGQ1YWM2ZTFiM2NlMGM4NzlmZTdmYmNjZGExZTgw
11
+ MDQ4MDFiY2U3MDVmYjczYmIyNTBhZWYyMjU2MDY1MDk3ZTE0ZjY=
12
12
  data.tar.gz: !binary |-
13
- MDgyMWEzN2QxZDljZGQ2MDViMzNmZWJmZmQ4NDRkZGM1NWFlYzkxOGIyNmRk
14
- ODk0MTFlYzhjY2RkN2ZjNzA0MmZmZTcxNjkxMWRlMGNlYWQwN2M4NjM5ZDU1
15
- MjkyNGY4MzRiNjk4OGYwYjZjMWQxYjNlMjE1ODYyNjdlZTlmNDE=
13
+ NDhhNWI4NWU0YWYxYWVkOGFlZjhiYjVlZTY0ZTlhYTYwYTc4OTdkZmU0M2Mz
14
+ MmFiOWNhMjcxYjliOTA4NTVlZGYzM2Q1MWIxYzNmYjVkZDQ0ZmRmM2Q2NzI3
15
+ OTllNjcyMDkzOGMxNjk2YjgwMTA0MDM1YWU0YTJhZjkzNDdlNDI=
@@ -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)).symbolize_keys
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
@@ -3,9 +3,10 @@ module Helix
3
3
  module HasSignatures
4
4
 
5
5
  unless defined?(self::VALID_SIG_TYPES)
6
- SIG_DURATION = 1200 # in minutes
7
- TIME_OFFSET = 1000 * 60 # 1000 minutes, lower to give some margin of error
8
- VALID_SIG_TYPES = [ :ingest, :update, :view ]
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
- url = "#{credentials[:site]}/api/#{sig_type}_key?"
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 == :ingest
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
@@ -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, ingest_sig_opts, http_open_opts)
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 ingest_sig_opts
51
+ def upload_sig_opts
52
52
  cc = config.credentials
53
- ingest_sig_opts = {
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, ingest_sig_opts={}, http_open_opts={})
61
- guid = config.signature(:ingest, ingest_sig_opts)
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,
@@ -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
- it "should set the instance's credentials to that Hash arg" do
66
- mock_obj.should_receive(:instance_variable_set).with(:@credentials, :the_hash_arg)
67
- klass.send(meth, :the_hash_arg)
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
@@ -29,8 +29,8 @@ describe Helix::Document do
29
29
 
30
30
  ### CLASS METHODS
31
31
 
32
- describe ".ingest_sig_opts" do
33
- let(:meth) { :ingest_sig_opts }
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 "ingest_sig_opts", Helix::Document
64
+ it_behaves_like "upload_sig_opts", Helix::Document
65
65
  it_behaves_like "uploads", Helix::Document
66
66
 
67
67
  end
@@ -7,7 +7,7 @@ SimpleCov.start do
7
7
  end
8
8
 
9
9
  require 'support/downloads'
10
- require 'support/ingest_sig_opts'
10
+ require 'support/upload_sig_opts'
11
11
  require 'support/plays'
12
12
  require 'support/uploads'
13
13
 
@@ -31,7 +31,7 @@ describe Helix::Track do
31
31
 
32
32
  ### CLASS METHODS
33
33
 
34
- it_behaves_like "ingest_sig_opts", Helix::Track
34
+ it_behaves_like "upload_sig_opts", Helix::Track
35
35
  it_behaves_like "uploads", Helix::Track
36
36
 
37
37
  end
@@ -123,7 +123,7 @@ describe Helix::Video do
123
123
 
124
124
  ### CLASS METHODS
125
125
 
126
- it_behaves_like "ingest_sig_opts", Helix::Video
126
+ it_behaves_like "upload_sig_opts", Helix::Video
127
127
  it_behaves_like "uploads", Helix::Video
128
128
 
129
129
  describe ".slice" do
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.7.pre
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-07 00:00:00.000000000 Z
11
+ date: 2013-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json