helix 0.0.3.1.pre → 0.0.3.2.pre

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,6 +6,7 @@ require 'helix/track'
6
6
  require 'helix/tag'
7
7
  require 'helix/album'
8
8
  require 'helix/image'
9
+ require 'helix/document'
9
10
  require 'helix/config'
10
11
  require 'helix/statistics'
11
12
  require 'helix/library'
@@ -0,0 +1,19 @@
1
+ require 'helix/media'
2
+
3
+ module Helix
4
+
5
+ class Document < Media
6
+
7
+ # The class name, to be used by supporting classes. Such as Config which uses
8
+ # this method as a way to build URLs.
9
+ #
10
+ #
11
+ # @example
12
+ # Helix::Document.resource_label_sym #=> :document
13
+ #
14
+ # @return [Symbol] Name of the class.
15
+ def self.resource_label_sym; :document; end
16
+
17
+ end
18
+
19
+ end
@@ -0,0 +1,137 @@
1
+ require File.expand_path('../spec_helper', __FILE__)
2
+ require 'helix'
3
+
4
+ describe Helix::Document do
5
+ let(:klass) { Helix::Document }
6
+
7
+ subject { klass }
8
+ mods = [ Helix::Base, Helix::Media ]
9
+ mods.each { |mod| its(:ancestors) { should include(mod) } }
10
+ its(:guid_name) { should eq('document_id') }
11
+ its(:resource_label_sym) { should be(:document) }
12
+ its(:plural_resource_label) { should eq('documents') }
13
+ [:find, :create, :all, :find_all, :where].each do |crud_call|
14
+ it { should respond_to(crud_call) }
15
+ end
16
+
17
+ describe "Constants"
18
+
19
+ ### INSTANCE METHODS
20
+
21
+ describe "an instance" do
22
+ let(:obj) { klass.new({'document_id' => 'some_document_guid'}) }
23
+ subject { obj }
24
+ its(:resource_label_sym) { should be(:document) }
25
+ [:destroy, :update].each do |crud_call|
26
+ it { should respond_to(crud_call) }
27
+ end
28
+ end
29
+
30
+ ### CLASS METHODS
31
+
32
+ describe ".upload" do
33
+ let(:meth) { :upload }
34
+ let(:mock_config) { mock(Helix::Config) }
35
+ subject { klass.method(meth) }
36
+ its(:arity) { should eq(1) }
37
+ let(:file_hash) { { file: :some_file } }
38
+ let(:multipart_hash) { { multipart: true } }
39
+ it "should call upload_server_name and RestClient.post with params" do
40
+ klass.should_receive(:upload_server_name) { :some_server_url }
41
+ File.should_receive(:new).with(:some_file.to_s, "rb") { :some_file }
42
+ RestClient.should_receive(:post).with(:some_server_url,
43
+ file_hash,
44
+ multipart_hash)
45
+ klass.should_receive(:http_close)
46
+ klass.send(meth, :some_file)
47
+ end
48
+ end
49
+
50
+ describe ".upload_server_name" do
51
+ let(:meth) { :upload_server_name }
52
+ let(:mock_config) { mock(Helix::Config) }
53
+ subject { klass.method(meth) }
54
+ its(:arity) { should eq(0) }
55
+ let(:url_opts) { { resource_label: "upload_sessions",
56
+ guid: :some_sig,
57
+ action: :http_open,
58
+ content_type: "" } }
59
+ before { Helix::Config.stub(:instance) { mock_config } }
60
+ it "should call RestClient.get with correct url building" do
61
+ mock_config.should_receive(:build_url).with(url_opts) { :url }
62
+ mock_config.should_receive(:signature).with(:ingest) { :some_sig }
63
+ RestClient.should_receive(:get).with(:url)
64
+ klass.send(meth)
65
+ end
66
+ end
67
+
68
+ describe ".http_close" do
69
+ let(:meth) { :http_close }
70
+ let(:mock_config) { mock(Helix::Config) }
71
+ subject { klass.method(meth) }
72
+ its(:arity) { should eq(0) }
73
+ let(:url_opts) { { resource_label: "upload_sessions",
74
+ guid: :some_sig,
75
+ action: :http_close,
76
+ content_type: "" } }
77
+ before { Helix::Config.stub(:instance) { mock_config } }
78
+ it "should call RestClient.get with correct url building" do
79
+ mock_config.should_receive(:build_url).with(url_opts) { :url }
80
+ mock_config.should_receive(:signature).with(:ingest) { :some_sig }
81
+ RestClient.should_receive(:get).with(:url)
82
+ klass.send(meth)
83
+ end
84
+ end
85
+
86
+ describe ".upload_get" do
87
+ let(:meth) { :upload_get }
88
+ let(:mock_config) { mock(Helix::Config) }
89
+ subject { klass.method(meth) }
90
+ its(:arity) { should eq(1) }
91
+ let(:url_opts) { { resource_label: "upload_sessions",
92
+ guid: :some_sig,
93
+ action: :upload_get,
94
+ content_type: "" } }
95
+ before { Helix::Config.stub(:instance) { mock_config } }
96
+ it "should call RestClient.get with correct url building" do
97
+ mock_config.should_receive(:build_url).with(url_opts) { :url }
98
+ mock_config.should_receive(:signature).with(:ingest) { :some_sig }
99
+ RestClient.should_receive(:get).with(:url)
100
+ klass.send(meth, :upload_get)
101
+ end
102
+ end
103
+
104
+ describe ".http_open" do
105
+ let(:meth) { :http_open }
106
+ let(:mock_config) { mock(Helix::Config) }
107
+ subject { klass.method(meth) }
108
+ its(:arity) { should eq(0) }
109
+ it "should call upload_server_name" do
110
+ klass.should_receive(:upload_server_name)
111
+ klass.send(meth)
112
+ end
113
+ end
114
+
115
+ describe ".upload_open" do
116
+ let(:meth) { :upload_open }
117
+ let(:mock_config) { mock(Helix::Config) }
118
+ subject { klass.method(meth) }
119
+ its(:arity) { should eq(0) }
120
+ it "should call upload_server_name" do
121
+ klass.should_receive(:upload_server_name)
122
+ klass.send(meth)
123
+ end
124
+ end
125
+
126
+ describe ".upload_close" do
127
+ let(:meth) { :upload_close }
128
+ let(:mock_config) { mock(Helix::Config) }
129
+ subject { klass.method(meth) }
130
+ its(:arity) { should eq(0) }
131
+ it "should call upload_server_name" do
132
+ klass.should_receive(:http_close)
133
+ klass.send(meth)
134
+ end
135
+ end
136
+
137
+ end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: helix
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease: 8
5
- version: 0.0.3.1.pre
5
+ version: 0.0.3.2.pre
6
6
  platform: ruby
7
7
  authors:
8
8
  - Twistage, Inc
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2013-05-13 00:00:00 Z
13
+ date: 2013-05-14 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: json
@@ -68,7 +68,7 @@ dependencies:
68
68
  type: :runtime
69
69
  version_requirements: *id005
70
70
  description: Provides helper libraries for Ruby access to the Twistage API
71
- email: kbaird@twistage.com
71
+ email: kevin.baird@perceptivesoftware.com, michael.wood@perceptivesoftware.com
72
72
  executables: []
73
73
 
74
74
  extensions: []
@@ -84,6 +84,7 @@ files:
84
84
  - lib/helix/library.rb
85
85
  - lib/helix/uploadable.rb
86
86
  - lib/helix/statistics.rb
87
+ - lib/helix/document.rb
87
88
  - lib/helix/video_playlist.rb
88
89
  - lib/helix/media.rb
89
90
  - lib/helix/video.rb
@@ -94,6 +95,7 @@ files:
94
95
  - lib/helix/track.rb
95
96
  - lib/helix/exceptions.rb
96
97
  - lib/helix/config.rb
98
+ - spec/document_spec.rb
97
99
  - spec/audio_playlist_spec.rb
98
100
  - spec/library_spec.rb
99
101
  - spec/spec_helper.rb