helix 0.0.1.1.pre → 0.0.1.2.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.
@@ -105,9 +105,9 @@ module Helix
105
105
  #
106
106
  # @return [String] The response from the HTTP DELETE call.
107
107
  def destroy
108
- memo_cfg = config
109
- url = memo_cfg.build_url(format: :xml, guid: guid, media_type: plural_media_type)
110
- RestClient.delete(url, params: {signature: memo_cfg.signature(:update)})
108
+ config = Helix::Config.instance
109
+ url = config.build_url(format: :xml, guid: guid, media_type: plural_media_type)
110
+ RestClient.delete(url, params: {signature: config.signature(:update)})
111
111
  end
112
112
 
113
113
  # Creates a string that associates to the class id.
@@ -16,6 +16,7 @@ module Helix
16
16
  def self.media_type_sym; :video; end
17
17
 
18
18
  # Used to import videos from a URL into the Twistage system.
19
+ # Doc reference: /doc/api/video/import
19
20
  #
20
21
  # @example
21
22
  # video = Helix::Video.import(src: "www.google.com/video.mp4",
@@ -23,10 +24,12 @@ module Helix
23
24
  # description: "A random video.")
24
25
  # new_video.video_id # => dd891b83ba39e
25
26
  #
26
- # @param [Hash] attrs The attributes for creating a video
27
+ # @param [Hash] attrs The attributes for creating a video.
27
28
  # @return [RestClient] The response object.
28
29
  def self.import(attrs={})
29
- RestClient.post(self.get_url, self.get_xml(attrs), self.get_params)
30
+ RestClient.post(self.get_url,
31
+ self.get_xml(attrs),
32
+ self.get_params(self.extract_params(attrs)))
30
33
  end
31
34
 
32
35
  private
@@ -36,7 +39,7 @@ module Helix
36
39
  # takes raw xml as an argument. Allowing for xml files to be
37
40
  # used in place of attributes.
38
41
  #
39
- #
42
+ # @param [Hash] attrs The attributes for creating xml.
40
43
  # @return [String] Returns xml either from a raw entry or generated from attributes.
41
44
  def self.get_xml(attrs={})
42
45
  return attrs[:use_raw_xml] if attrs[:use_raw_xml].present?
@@ -61,12 +64,18 @@ module Helix
61
64
  Helix::Config.instance.build_url(self.get_url_opts)
62
65
  end
63
66
 
67
+ def self.extract_params(attrs)
68
+ [:contributor, :library_id].each_with_object({}) do |param, hash|
69
+ hash[param] = attrs[param] unless attrs[param].nil?
70
+ end
71
+ end
72
+
64
73
  # Gets the hash used in adding the signature to the API
65
74
  # call.
66
75
  #
67
76
  # @return [Hash] Returns a formatted hash for passing in the signature to the API call.
68
- def self.get_params
69
- opts = { contributor: :helix, library_id: :development }
77
+ def self.get_params(opts={})
78
+ opts = { contributor: :helix, library_id: :development }.merge(opts)
70
79
  sig = Helix::Config.instance.signature(:ingest, opts)
71
80
  { params: { signature: sig } }
72
81
  end
@@ -90,12 +90,24 @@ describe Helix::Video do
90
90
  describe ".get_params" do
91
91
  let(:meth) { :get_params }
92
92
  subject { klass.method(meth) }
93
- its(:arity) { should eq(0) }
93
+ its(:arity) { should eq(-1) }
94
94
  it "should call Helix::Config#signature and return a hash of params" do
95
95
  Helix::Config.instance.should_receive(:signature).with(:ingest, sig_opts) { :sig }
96
96
  expect(klass.send(meth)).to eq({ params: { signature: :sig } })
97
97
  end
98
98
  end
99
99
 
100
+ describe ".extract_params" do
101
+ let(:meth) { :extract_params }
102
+ subject { klass.method(meth) }
103
+ its(:arity) { should eq(1) }
104
+ let(:expected_hash) { { contributor: :con, library_id: :id } }
105
+ let(:attrs) { { extra_key_one: :one,
106
+ extra_key_two: :two }.merge(expected_hash) }
107
+ it "should return the correct key values from attributes" do
108
+ expect(klass.send(meth, attrs)).to eq(expected_hash)
109
+ end
110
+ end
111
+
100
112
 
101
113
  end
metadata CHANGED
@@ -1,104 +1,112 @@
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.2.pre
4
5
  prerelease: 8
5
- version: 0.0.1.1.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-11-26 00:00:00 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
12
+ date: 2012-11-28 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
30
25
  none: false
31
- requirements:
32
- - - ">="
33
- - !ruby/object:Gem::Version
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
33
+ none: false
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: activesupport
39
39
  prerelease: false
40
- requirement: &id003 !ruby/object:Gem::Requirement
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: 1.6.7
46
+ - !ruby/object:Gem::Dependency
47
+ name: activesupport
48
+ requirement: !ruby/object:Gem::Requirement
41
49
  none: false
42
- requirements:
43
- - - ">="
44
- - !ruby/object:Gem::Version
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
45
53
  version: 3.0.9
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: 3.0.9
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/album.rb
59
69
  - lib/helix/track.rb
60
- - lib/helix/base.rb
61
- - lib/helix/statistics.rb
62
70
  - lib/helix/video.rb
63
- - lib/helix/config.rb
71
+ - lib/helix/statistics.rb
64
72
  - lib/helix/image.rb
73
+ - lib/helix/album.rb
74
+ - lib/helix/config.rb
75
+ - lib/helix/base.rb
76
+ - spec/video_spec.rb
77
+ - spec/album_spec.rb
78
+ - spec/config_spec.rb
65
79
  - spec/base_spec.rb
66
80
  - spec/statistics_spec.rb
67
- - spec/config_spec.rb
81
+ - spec/spec_helper.rb
68
82
  - spec/track_spec.rb
69
83
  - spec/image_spec.rb
70
- - spec/spec_helper.rb
71
- - spec/video_spec.rb
72
- - spec/album_spec.rb
73
84
  - LICENSE
74
85
  - README.md
75
86
  homepage: https://github.com/Twistage/helix/
76
- licenses:
87
+ licenses:
77
88
  - 3-Clause BSD
78
89
  post_install_message:
79
90
  rdoc_options: []
80
-
81
- require_paths:
91
+ require_paths:
82
92
  - lib
83
- required_ruby_version: !ruby/object:Gem::Requirement
93
+ required_ruby_version: !ruby/object:Gem::Requirement
84
94
  none: false
85
- requirements:
86
- - - ">="
87
- - !ruby/object:Gem::Version
88
- version: "0"
89
- required_rubygems_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ! '>='
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ required_rubygems_version: !ruby/object:Gem::Requirement
90
100
  none: false
91
- requirements:
92
- - - ">"
93
- - !ruby/object:Gem::Version
101
+ requirements:
102
+ - - ! '>'
103
+ - !ruby/object:Gem::Version
94
104
  version: 1.3.1
95
105
  requirements: []
96
-
97
106
  rubyforge_project:
98
107
  rubygems_version: 1.8.24
99
108
  signing_key:
100
109
  specification_version: 3
101
110
  summary: Wrapper library for the video API
102
111
  test_files: []
103
-
104
112
  has_rdoc: true