grabbio 0.0.4 → 0.0.6
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.
- data/grabbio.gemspec +3 -0
- data/lib/grabbio/utils.rb +1 -1
- data/lib/grabbio/version.rb +1 -1
- data/spec/fixtures/grabb.io_error.json +1 -0
- data/spec/fixtures/grabb.io_invalid_token.json +3 -0
- data/spec/fixtures/grabb.io_valid_response.json +36 -0
- data/spec/grabbio/client_spec.rb +36 -0
- data/spec/grabbio/utils_spec.rb +40 -0
- data/spec/spec_helper.rb +15 -0
- metadata +33 -14
data/grabbio.gemspec
CHANGED
@@ -13,6 +13,9 @@ Gem::Specification.new do |s|
|
|
13
13
|
s.description = "A ruby wrapper for the grabbio platform"
|
14
14
|
|
15
15
|
s.rubyforge_project = "grabbio"
|
16
|
+
|
17
|
+
s.add_development_dependency "rspec", "~> 2.0.0"
|
18
|
+
s.add_development_dependency "fakeweb"
|
16
19
|
|
17
20
|
s.files = `git ls-files`.split("\n")
|
18
21
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
data/lib/grabbio/utils.rb
CHANGED
data/lib/grabbio/version.rb
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
This file is deliberately not json
|
@@ -0,0 +1,36 @@
|
|
1
|
+
{
|
2
|
+
"video": {
|
3
|
+
"callback_url": null,
|
4
|
+
"cost": 1,
|
5
|
+
"created_at": "2011-07-17T14:50:39Z",
|
6
|
+
"developer_mode": false,
|
7
|
+
"external_id": null,
|
8
|
+
"filename": "ssCLGKk1JN",
|
9
|
+
"id": 393,
|
10
|
+
"number_of_thumbnails": 1,
|
11
|
+
"scale_mode": "pad",
|
12
|
+
"source": "http://example.com/grabbio/test.wmv",
|
13
|
+
"source_type": "http",
|
14
|
+
"status": "pending",
|
15
|
+
"thumbnail_format": "jpg",
|
16
|
+
"thumbnail_types": "individual",
|
17
|
+
"updated_at": "2011-07-17T14:50:39Z",
|
18
|
+
"upload_placeholders": true,
|
19
|
+
"upload_type": "s3",
|
20
|
+
"requested_thumbnails": [
|
21
|
+
{
|
22
|
+
"thumbnail": {
|
23
|
+
"created_at": "2011-07-17T14:50:41Z",
|
24
|
+
"filename": "ssCLGKk1JN_120x90_0.jpg",
|
25
|
+
"height": 90,
|
26
|
+
"id": 1408,
|
27
|
+
"order": 0,
|
28
|
+
"thumbnail_type": "individual",
|
29
|
+
"updated_at": "2011-07-17T14:50:41Z",
|
30
|
+
"video_id": 393,
|
31
|
+
"width": 120
|
32
|
+
}
|
33
|
+
}
|
34
|
+
]
|
35
|
+
}
|
36
|
+
}
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'grabbio'
|
2
|
+
|
3
|
+
describe Grabbio::Client do
|
4
|
+
|
5
|
+
it "requires an API key" do
|
6
|
+
lambda{Grabbio.new()}.should raise_error(ArgumentError)
|
7
|
+
end
|
8
|
+
|
9
|
+
it "requires an API secret" do
|
10
|
+
lambda{Grabbio.new("key")}.should raise_error(ArgumentError)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should initialize when key and secret are included" do
|
14
|
+
lambda{Grabbio.new("key", "secret")}.should_not raise_error
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should require a source on grab" do
|
18
|
+
grabbio = Grabbio.new("key", "secret")
|
19
|
+
lambda{grabbio.grab}.should raise_error(ArgumentError)
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should require a destination on grab" do
|
23
|
+
grabbio = Grabbio.new("key", "secret")
|
24
|
+
lambda{grabbio.grab("source")}.should raise_error(ArgumentError)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should require a string as source" do
|
28
|
+
grabbio = Grabbio.new("key", "secret")
|
29
|
+
lambda{grabbio.grab(1, 2)}.should raise_error(ArgumentError)
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should require a string as source" do
|
33
|
+
grabbio = Grabbio.new("key", "secret")
|
34
|
+
lambda{grabbio.grab(1, 2)}.should raise_error(ArgumentError)
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'grabbio'
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
class DummyClass
|
5
|
+
include Grabbio::Utils
|
6
|
+
end
|
7
|
+
|
8
|
+
describe Grabbio::Utils do
|
9
|
+
|
10
|
+
before(:each) do
|
11
|
+
@dummy_class = DummyClass.new
|
12
|
+
end
|
13
|
+
|
14
|
+
it "converts a hash to parameter strings" do
|
15
|
+
@dummy_class.parameters_to_string(:param1 => "1", :param2 => "2").should eql("?param1=1¶m2=2")
|
16
|
+
end
|
17
|
+
|
18
|
+
it "creates a hash" do
|
19
|
+
secret_key = "secret"
|
20
|
+
parameters = "param1=1¶m2=2"
|
21
|
+
hash = "l4o75YWJgQhLGJBdVZ1kG3u0yc0=" #Base64.encode64(OpenSSL::HMAC.digest(OpenSSL::Digest::Digest.new('sha1'), secret_key,parameters)).chomp.gsub(/\n/,'')
|
22
|
+
@dummy_class.sign_request(secret_key, parameters).should eql(hash)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should throw error on invalid JSON" do
|
26
|
+
stub_get("http://grabb.io", "grabb.io_error.json")
|
27
|
+
lambda{@dummy_class.make_request("http://grabb.io")}.should raise_error(GrabbioError)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should throw error on invalid token" do
|
31
|
+
stub_get("http://grabb.io/api/v1/videos.js", "grabb.io_invalid_token.json")
|
32
|
+
lambda{@dummy_class.make_request("http://grabb.io/api/v1/videos.js")}.should raise_error(GrabbioError)
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should contain a video element on valid response" do
|
36
|
+
stub_get("http://grabb.io/api/v1/videos.js", "grabb.io_valid_response.json")
|
37
|
+
response = @dummy_class.make_request("http://grabb.io/api/v1/videos.js")
|
38
|
+
response.should have_key("video")
|
39
|
+
end
|
40
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'fakeweb'
|
2
|
+
FakeWeb.allow_net_connect = false
|
3
|
+
|
4
|
+
def fixture_file(filename)
|
5
|
+
return '' if filename == ''
|
6
|
+
file_path = File.expand_path(File.dirname(__FILE__) + '/fixtures/' + filename)
|
7
|
+
File.read(file_path)
|
8
|
+
end
|
9
|
+
|
10
|
+
def stub_get(url, filename, status=nil)
|
11
|
+
options = {:body => fixture_file(filename)}
|
12
|
+
options.merge!({:status => status}) unless status.nil?
|
13
|
+
|
14
|
+
FakeWeb.register_uri(:get, url, options)
|
15
|
+
end
|
metadata
CHANGED
@@ -1,12 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grabbio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 0
|
8
|
-
- 4
|
9
|
-
version: 0.0.4
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.6
|
10
6
|
platform: ruby
|
11
7
|
authors:
|
12
8
|
- Gazler
|
@@ -14,10 +10,31 @@ autorequire:
|
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
12
|
|
17
|
-
date: 2011-
|
13
|
+
date: 2011-07-17 00:00:00 +01:00
|
18
14
|
default_executable:
|
19
|
-
dependencies:
|
20
|
-
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: rspec
|
18
|
+
prerelease: false
|
19
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
|
+
none: false
|
21
|
+
requirements:
|
22
|
+
- - ~>
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: 2.0.0
|
25
|
+
type: :development
|
26
|
+
version_requirements: *id001
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: fakeweb
|
29
|
+
prerelease: false
|
30
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
31
|
+
none: false
|
32
|
+
requirements:
|
33
|
+
- - ">="
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: "0"
|
36
|
+
type: :development
|
37
|
+
version_requirements: *id002
|
21
38
|
description: A ruby wrapper for the grabbio platform
|
22
39
|
email:
|
23
40
|
- gary@banta.tv
|
@@ -37,6 +54,12 @@ files:
|
|
37
54
|
- lib/grabbio/utils.rb
|
38
55
|
- lib/grabbio/version.rb
|
39
56
|
- readme.md
|
57
|
+
- spec/fixtures/grabb.io_error.json
|
58
|
+
- spec/fixtures/grabb.io_invalid_token.json
|
59
|
+
- spec/fixtures/grabb.io_valid_response.json
|
60
|
+
- spec/grabbio/client_spec.rb
|
61
|
+
- spec/grabbio/utils_spec.rb
|
62
|
+
- spec/spec_helper.rb
|
40
63
|
has_rdoc: true
|
41
64
|
homepage: http://github.com/Gazler/
|
42
65
|
licenses: []
|
@@ -51,21 +74,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
51
74
|
requirements:
|
52
75
|
- - ">="
|
53
76
|
- !ruby/object:Gem::Version
|
54
|
-
segments:
|
55
|
-
- 0
|
56
77
|
version: "0"
|
57
78
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
79
|
none: false
|
59
80
|
requirements:
|
60
81
|
- - ">="
|
61
82
|
- !ruby/object:Gem::Version
|
62
|
-
segments:
|
63
|
-
- 0
|
64
83
|
version: "0"
|
65
84
|
requirements: []
|
66
85
|
|
67
86
|
rubyforge_project: grabbio
|
68
|
-
rubygems_version: 1.
|
87
|
+
rubygems_version: 1.5.2
|
69
88
|
signing_key:
|
70
89
|
specification_version: 3
|
71
90
|
summary: A ruby wrapper for the grabbio platform
|