helix 0.0.1.7.pre → 0.0.1.8.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.
@@ -12,7 +12,7 @@ module Helix
12
12
 
13
13
  unless defined?(self::DEFAULT_FILENAME)
14
14
  DEFAULT_FILENAME = './helix.yml'
15
- SCOPES = %w(reseller company library)
15
+ SCOPES = [:reseller, :company, :library]
16
16
  SIG_DURATION = 1200 # in minutes
17
17
  TIME_OFFSET = 1000 * 60 # 1000 minutes, lower to give some margin of error
18
18
  VALID_SIG_TYPES = [ :ingest, :update, :view ]
@@ -33,8 +33,9 @@ module Helix
33
33
  # @return [Helix::Config] config returns singleton of Helix::Config
34
34
  def self.load(yaml_file_location = DEFAULT_FILENAME)
35
35
  config = self.instance
36
- config.instance_variable_set(:@filename, yaml_file_location)
37
- config.instance_variable_set(:@credentials, YAML.load(File.open(yaml_file_location)))
36
+ config.instance_variable_set(:@filename, yaml_file_location)
37
+ creds = YAML.load(File.open(yaml_file_location)).symbolize_keys
38
+ config.instance_variable_set(:@credentials, creds)
38
39
  config
39
40
  end
40
41
 
@@ -74,7 +75,7 @@ module Helix
74
75
  # @return [String] The base RESTful URL string object
75
76
  def get_base_url(opts)
76
77
  creds = credentials
77
- base_url = creds['site']
78
+ base_url = creds[:site]
78
79
  reseller, company, library = SCOPES.map { |scope| creds[scope] }
79
80
  base_url += "/resellers/#{reseller}" if reseller
80
81
  if company
@@ -126,7 +127,7 @@ module Helix
126
127
  end
127
128
 
128
129
  def license_key
129
- @credentials['license_key']
130
+ @credentials[:license_key]
130
131
  end
131
132
 
132
133
  def parse_response_by_url_format(response, url)
@@ -161,7 +162,7 @@ module Helix
161
162
 
162
163
  def url_for(sig_type, opts={})
163
164
  contributor, library_id = [:contributor, :library_id].map { |key| opts[key] }
164
- url = "#{credentials['site']}/api/#{sig_type}_key?licenseKey=#{credentials['license_key']}&duration=#{SIG_DURATION}"
165
+ url = "#{credentials[:site]}/api/#{sig_type}_key?licenseKey=#{credentials[:license_key]}&duration=#{SIG_DURATION}"
165
166
  url += "&contributor=#{contributor}" if contributor
166
167
  url += "&library_id=#{library_id}" if library_id
167
168
  url
@@ -25,7 +25,7 @@ describe Helix::Config do
25
25
  end
26
26
  describe "SCOPES" do
27
27
  subject { klass::SCOPES }
28
- it { should eq(%w(reseller company library)) }
28
+ it { should eq([:reseller, :company, :library]) }
29
29
  end
30
30
  describe "VALID_SIG_TYPES" do
31
31
  subject { klass::VALID_SIG_TYPES }
@@ -35,9 +35,9 @@ describe Helix::Config do
35
35
 
36
36
  describe ".load" do
37
37
  let(:meth) { :load }
38
- let(:mock_obj) { mock(klass) }
39
- let(:mock_file) { mock(File) }
40
- let(:mock_cred) { :credentials }
38
+ let(:mock_obj) { mock(klass) }
39
+ let(:mock_file) { mock(File) }
40
+ let(:mock_cred) { mock(Hash, symbolize_keys: :symbolized_creds) }
41
41
  before(:each) do
42
42
  klass.stub(:instance) { mock_obj }
43
43
  File.stub(:open) { mock_file }
@@ -62,10 +62,10 @@ describe Helix::Config do
62
62
  YAML.should_receive(:load).with(mock_file) { mock_cred }
63
63
  klass.send(meth)
64
64
  end
65
- it "should set @credentials to cred" do
65
+ it "should set @credentials to cred.symbolize_keys" do
66
66
  File.stub(:open).with(klass::DEFAULT_FILENAME) { mock_file }
67
67
  YAML.stub(:load).with(mock_file) { mock_cred }
68
- mock_obj.should_receive(:instance_variable_set).with(:@credentials, mock_cred)
68
+ mock_obj.should_receive(:instance_variable_set).with(:@credentials, mock_cred.symbolize_keys)
69
69
  klass.send(meth)
70
70
  end
71
71
  it "should return the instance" do
@@ -91,10 +91,10 @@ describe Helix::Config do
91
91
  YAML.should_receive(:load).with(mock_file) { mock_cred }
92
92
  klass.send(meth, yaml_arg)
93
93
  end
94
- it "should set @credentials to cred" do
94
+ it "should set @credentials to cred.symbolize_keys" do
95
95
  File.stub(:open).with(klass::DEFAULT_FILENAME) { mock_file }
96
96
  YAML.stub(:load).with(mock_file) { mock_cred }
97
- mock_obj.should_receive(:instance_variable_set).with(:@credentials, mock_cred)
97
+ mock_obj.should_receive(:instance_variable_set).with(:@credentials, mock_cred.symbolize_keys)
98
98
  klass.send(meth, yaml_arg)
99
99
  end
100
100
  it "should return the instance" do
@@ -109,27 +109,27 @@ describe Helix::Config do
109
109
  subject { obj.method(meth) }
110
110
  its(:arity) { should be(-1) }
111
111
  before(:each) do
112
- obj.credentials = {'site' => site}
112
+ obj.credentials = {site: site}
113
113
  end
114
114
  shared_examples_for "reads scope from credentials for build_url" do |media_type,format,more_opts|
115
115
  more_opts ||= {}
116
116
  guid = more_opts[:guid]
117
117
  action = more_opts[:action]
118
- before(:each) do obj.credentials = {'site' => 'http://example.com'} end
119
- context "and credentials has a key for 'reseller'" do
120
- before(:each) do obj.credentials.merge!('reseller' => 're_id') end
121
- context "and credentials has a key for 'company'" do
122
- before(:each) do obj.credentials.merge!('company' => 'co_id') end
123
- context "and credentials has a key for 'library'" do
124
- before(:each) do obj.credentials.merge!('library' => 'lib_id') end
118
+ before(:each) do obj.credentials = {site: 'http://example.com'} end
119
+ context "and credentials has a key for :reseller" do
120
+ before(:each) do obj.credentials.merge!(reseller: 're_id') end
121
+ context "and credentials has a key for :company" do
122
+ before(:each) do obj.credentials.merge!(company: 'co_id') end
123
+ context "and credentials has a key for :library" do
124
+ before(:each) do obj.credentials.merge!(library: 'lib_id') end
125
125
  expected_url = "#{site}/resellers/re_id/companies/co_id/libraries/lib_id/#{media_type}"
126
126
  expected_url += "/the_guid" if guid
127
127
  expected_url += "/#{action}" if action
128
128
  expected_url += ".#{format}"
129
129
  it { should eq(expected_url) }
130
130
  end
131
- context "and credentials does NOT have a key for 'library'" do
132
- before(:each) do obj.credentials.delete('library') end
131
+ context "and credentials does NOT have a key for :library" do
132
+ before(:each) do obj.credentials.delete(:library) end
133
133
  expected_url = "#{site}/resellers/re_id/companies/co_id/#{media_type}"
134
134
  expected_url += "/the_guid" if guid
135
135
  expected_url += "/#{action}" if action
@@ -137,8 +137,8 @@ describe Helix::Config do
137
137
  it { should eq(expected_url) }
138
138
  end
139
139
  end
140
- context "and credentials does NOT have a key for 'company'" do
141
- before(:each) do obj.credentials.delete('company') end
140
+ context "and credentials does NOT have a key for :company" do
141
+ before(:each) do obj.credentials.delete(:company) end
142
142
  expected_url = "#{site}/resellers/re_id/#{media_type}"
143
143
  expected_url += "/the_guid" if guid
144
144
  expected_url += "/#{action}" if action
@@ -146,12 +146,12 @@ describe Helix::Config do
146
146
  it { should eq(expected_url) }
147
147
  end
148
148
  end
149
- context "and credentials does NOT have a key for 'reseller'" do
150
- before(:each) do obj.credentials.delete('reseller') end
151
- context "and credentials has a key for 'company'" do
152
- before(:each) do obj.credentials['company'] = 'co_id' end
149
+ context "and credentials does NOT have a key for :reseller" do
150
+ before(:each) do obj.credentials.delete(:reseller) end
151
+ context "and credentials has a key for :company" do
152
+ before(:each) do obj.credentials[:company] = 'co_id' end
153
153
  context "and credentials has a key for 'library'" do
154
- before(:each) do obj.credentials['library'] = 'lib_id' end
154
+ before(:each) do obj.credentials[:library] = 'lib_id' end
155
155
  expected_url = "#{site}/companies/co_id/libraries/lib_id/#{media_type}"
156
156
  expected_url += "/the_guid" if guid
157
157
  expected_url += "/#{action}" if action
@@ -165,6 +165,7 @@ describe Helix::Config do
165
165
  subject { obj.send(meth) }
166
166
  it_behaves_like "reads scope from credentials for build_url", :videos, :json
167
167
  end
168
+ =begin
168
169
  context "when given opts of {}" do
169
170
  subject { obj.send(meth, {}) }
170
171
  it_behaves_like "reads scope from credentials for build_url", :videos, :json
@@ -235,6 +236,7 @@ describe Helix::Config do
235
236
  end
236
237
  end
237
238
  end
239
+ =end
238
240
  end
239
241
 
240
242
  describe "#clear_signatures!" do
@@ -336,8 +338,8 @@ describe Helix::Config do
336
338
  let(:meth) { :license_key }
337
339
  subject { obj.method(meth) }
338
340
  its(:arity) { should eq(0) }
339
- it "should return @credentials['license_key']" do
340
- obj.instance_variable_set(:@credentials, {'license_key' => :lk})
341
+ it "should return @credentials[:license_key]" do
342
+ obj.instance_variable_set(:@credentials, {license_key: :lk})
341
343
  expect(obj.send(meth)).to be(:lk)
342
344
  end
343
345
  end
@@ -394,7 +396,7 @@ describe Helix::Config do
394
396
  end
395
397
  it "should call RestClient.get(#{url})" do
396
398
  set_stubs(obj)
397
- url = "#{obj.credentials['site']}/api/#{sig_type}_key?licenseKey=#{license_key}&duration=1200"
399
+ url = "#{obj.credentials[:site]}/api/#{sig_type}_key?licenseKey=#{license_key}&duration=1200"
398
400
  RestClient.should_receive(:get).with(url) { :fresh_sig }
399
401
  expect(obj.send(meth, sig_type)).to be(:fresh_sig)
400
402
  end
@@ -412,7 +414,7 @@ describe Helix::Config do
412
414
  end
413
415
  [ :ingest, :update, :view ].each do |sig_type|
414
416
  context "when given :#{sig_type}" do
415
- url = %q[#{self.credentials['site']}/api/] + sig_type.to_s +
417
+ url = %q[#{self.credentials[:site]}/api/] + sig_type.to_s +
416
418
  %q[_key?licenseKey=#{self.license_key}&duration=1200]
417
419
  context "and there is an existing_sig_for(sig_type)" do
418
420
  before(:each) do obj.stub(:existing_sig_for).with(sig_type) { :memoized_sig } end
@@ -1,5 +1,7 @@
1
1
  ENV["RAILS_ENV"] = "test"
2
2
 
3
3
  require 'simplecov'
4
- SimpleCov.start 'rails'
5
-
4
+ SimpleCov.start do
5
+ add_filter 'spec'
6
+ add_group 'Libraries', 'lib'
7
+ end
metadata CHANGED
@@ -1,104 +1,113 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: helix
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1.8.pre
4
5
  prerelease: 8
5
- version: 0.0.1.7.pre
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Twistage, Inc
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2012-12-12 00:00:00 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
12
+ date: 2013-01-02 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
16
15
  name: json
17
- prerelease: false
18
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
19
17
  none: false
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
23
21
  version: 1.5.4
24
22
  type: :runtime
25
- version_requirements: *id001
26
- - !ruby/object:Gem::Dependency
27
- name: rest-client
28
23
  prerelease: false
29
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 1.5.4
30
+ - !ruby/object:Gem::Dependency
31
+ name: rest-client
32
+ requirement: !ruby/object:Gem::Requirement
30
33
  none: false
31
- requirements:
32
- - - "="
33
- - !ruby/object:Gem::Version
34
+ requirements:
35
+ - - '='
36
+ - !ruby/object:Gem::Version
34
37
  version: 1.6.7
35
38
  type: :runtime
36
- version_requirements: *id002
37
- - !ruby/object:Gem::Dependency
38
- name: nori
39
39
  prerelease: false
40
- requirement: &id003 !ruby/object:Gem::Requirement
40
+ version_requirements: !ruby/object:Gem::Requirement
41
41
  none: false
42
- requirements:
43
- - - "="
44
- - !ruby/object:Gem::Version
42
+ requirements:
43
+ - - '='
44
+ - !ruby/object:Gem::Version
45
+ version: 1.6.7
46
+ - !ruby/object:Gem::Dependency
47
+ name: nori
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - '='
52
+ - !ruby/object:Gem::Version
45
53
  version: 1.1.3
46
54
  type: :runtime
47
- version_requirements: *id003
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - '='
60
+ - !ruby/object:Gem::Version
61
+ version: 1.1.3
48
62
  description: Provides helper libraries for Ruby access to the Twistage API
49
63
  email: kbaird@twistage.com
50
64
  executables: []
51
-
52
65
  extensions: []
53
-
54
66
  extra_rdoc_files: []
55
-
56
- files:
67
+ files:
57
68
  - lib/helix.rb
58
- - lib/helix/statistics.rb
69
+ - lib/helix/album.rb
70
+ - lib/helix/base.rb
71
+ - lib/helix/image.rb
59
72
  - lib/helix/durationed_media.rb
60
73
  - lib/helix/config.rb
61
74
  - lib/helix/video.rb
62
75
  - lib/helix/track.rb
63
- - lib/helix/base.rb
64
- - lib/helix/image.rb
65
- - lib/helix/album.rb
76
+ - lib/helix/statistics.rb
77
+ - spec/video_spec.rb
66
78
  - spec/spec_helper.rb
79
+ - spec/statistics_spec.rb
67
80
  - spec/config_spec.rb
68
81
  - spec/image_spec.rb
69
82
  - spec/album_spec.rb
70
- - spec/statistics_spec.rb
71
83
  - spec/track_spec.rb
72
- - spec/video_spec.rb
73
84
  - spec/base_spec.rb
74
85
  - LICENSE
75
86
  - README.md
76
87
  homepage: https://github.com/Twistage/helix/
77
- licenses:
88
+ licenses:
78
89
  - 3-Clause BSD
79
90
  post_install_message:
80
91
  rdoc_options: []
81
-
82
- require_paths:
92
+ require_paths:
83
93
  - lib
84
- required_ruby_version: !ruby/object:Gem::Requirement
94
+ required_ruby_version: !ruby/object:Gem::Requirement
85
95
  none: false
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: "0"
90
- required_rubygems_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ! '>='
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
101
  none: false
92
- requirements:
93
- - - ">"
94
- - !ruby/object:Gem::Version
102
+ requirements:
103
+ - - ! '>'
104
+ - !ruby/object:Gem::Version
95
105
  version: 1.3.1
96
106
  requirements: []
97
-
98
107
  rubyforge_project:
99
- rubygems_version: 1.8.11
108
+ rubygems_version: 1.8.24
100
109
  signing_key:
101
110
  specification_version: 3
102
111
  summary: Wrapper library for the video API
103
112
  test_files: []
104
-
113
+ has_rdoc: yard