bitsontherun 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/LICENSE +1 -1
- data/{README.md → README.markdown} +24 -12
- data/bitsontherun.gemspec +18 -14
- data/lib/bitsontherun.rb +8 -2
- data/lib/bitsontherun/api.rb +3 -3
- data/lib/bitsontherun/call.rb +2 -2
- data/lib/bitsontherun/configuration.rb +4 -6
- data/lib/bitsontherun/store.rb +1 -1
- data/lib/bitsontherun/version.rb +1 -1
- data/spec/lib/account_spec.rb +2 -2
- data/spec/lib/configuration_spec.rb +9 -9
- metadata +12 -12
- data/.rspec +0 -4
data/LICENSE
CHANGED
@@ -1,30 +1,40 @@
|
|
1
1
|
BitsOnTheRun
|
2
|
-
|
2
|
+
============
|
3
3
|
|
4
|
-
BitsOnTheRun is an implementation of [bitsontherun.com](bitsontherun.com) API in Ruby.
|
4
|
+
BitsOnTheRun is an implementation of [bitsontherun.com](http://bitsontherun.com) API in Ruby.
|
5
5
|
|
6
6
|
## Install
|
7
7
|
|
8
|
-
|
8
|
+
Just run the following command:
|
9
9
|
|
10
|
-
gem
|
10
|
+
gem install bitsontherun
|
11
11
|
|
12
|
-
|
12
|
+
Then in your Gemfile add the following line:
|
13
13
|
|
14
|
-
|
15
|
-
|
14
|
+
gem 'bitsontherun'
|
15
|
+
|
16
|
+
And finally run:
|
17
|
+
|
18
|
+
bundle install
|
19
|
+
|
20
|
+
For rails app create the _config/initializers/bitsontherun.rb_ file:
|
21
|
+
|
22
|
+
# Bitsonthrun configuration
|
23
|
+
BitsOnTheRun.key = "your api key"
|
24
|
+
BitsOnTheRun.secret = "your api secret"
|
16
25
|
|
17
26
|
## Usage
|
18
27
|
|
19
|
-
Basic:
|
28
|
+
Basic call:
|
20
29
|
|
21
30
|
BitsOnTheRun::call('version') => {:status => "ok", :version => "X.X.X"}
|
22
|
-
|
23
|
-
BitsOnTheRun::store('videos/create', 'video.mp4') => {:status => "ok", ...}
|
24
|
-
|
25
31
|
BitsOnTheRun::call('videos/update', :video_key => 'your video key', :title => 'New title for video').ok? => true
|
26
32
|
|
27
|
-
|
33
|
+
Basic store:
|
34
|
+
|
35
|
+
BitsOnTheRun::store('videos/create', 'video.mp4') => {:status => "ok", ...}
|
36
|
+
|
37
|
+
Extended call methods:
|
28
38
|
|
29
39
|
call = BitsOnTheRun::API.new(:call)
|
30
40
|
call.method('videos/list')
|
@@ -38,6 +48,8 @@ Extended:
|
|
38
48
|
call.method('videos/update', :video_key => 'your video key', :title => 'New title for video')
|
39
49
|
call.execute
|
40
50
|
|
51
|
+
Extended store methods:
|
52
|
+
|
41
53
|
call = BitsOnTheRun::API.new(:store)
|
42
54
|
call.method('videos/create')
|
43
55
|
call.file('video.mp4')
|
data/bitsontherun.gemspec
CHANGED
@@ -1,26 +1,30 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "bitsontherun/version"
|
3
4
|
|
4
5
|
Gem::Specification.new do |s|
|
5
6
|
s.name = "bitsontherun"
|
6
7
|
s.version = BitsOnTheRun::VERSION
|
7
8
|
s.platform = Gem::Platform::RUBY
|
8
|
-
s.authors = [
|
9
|
-
s.email = [
|
9
|
+
s.authors = ["Adrian Dulić"]
|
10
|
+
s.email = ["adulic@gmail.com"]
|
10
11
|
s.homepage = "http://github.com/adriandulic/bitsontherun"
|
11
|
-
s.summary =
|
12
|
-
s.description =
|
13
|
-
|
12
|
+
s.summary = %q{BitsOnTheRun.com API implementation in Ruby}
|
13
|
+
s.description = %q{BitsOnTheRun.com API implementation in Ruby}
|
14
|
+
|
15
|
+
s.extra_rdoc_files = ["LICENSE", "README.markdown"]
|
16
|
+
|
14
17
|
s.required_rubygems_version = ">= 1.3.6"
|
15
|
-
s.rubyforge_project
|
16
|
-
|
18
|
+
s.rubyforge_project = s.name
|
19
|
+
|
17
20
|
s.add_dependency "json", "1.5.1"
|
18
21
|
s.add_dependency "curb", "0.7.10"
|
19
|
-
|
22
|
+
|
20
23
|
s.add_development_dependency "bundler", "1.0.10"
|
21
|
-
s.add_development_dependency "rspec", "2.
|
22
|
-
|
23
|
-
s.files
|
24
|
-
s.
|
25
|
-
s.
|
24
|
+
s.add_development_dependency "rspec", "2.5.0"
|
25
|
+
|
26
|
+
s.files = `git ls-files`.split("\n")
|
27
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
28
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
29
|
+
s.require_paths = ["lib"]
|
26
30
|
end
|
data/lib/bitsontherun.rb
CHANGED
@@ -13,7 +13,9 @@ module BitsOnTheRun
|
|
13
13
|
autoload :Store, "bitsontherun/store"
|
14
14
|
autoload :Response, "bitsontherun/response"
|
15
15
|
autoload :Parser, "bitsontherun/parser"
|
16
|
-
|
16
|
+
|
17
|
+
extend Configuration
|
18
|
+
|
17
19
|
class Base
|
18
20
|
def initialize
|
19
21
|
@params = {}
|
@@ -37,7 +39,7 @@ module BitsOnTheRun
|
|
37
39
|
|
38
40
|
def build_signature
|
39
41
|
signature = escape_params
|
40
|
-
Digest::SHA1.hexdigest(signature +
|
42
|
+
Digest::SHA1.hexdigest(signature + BitsOnTheRun.secret)
|
41
43
|
end
|
42
44
|
|
43
45
|
def escape_params
|
@@ -60,5 +62,9 @@ module BitsOnTheRun
|
|
60
62
|
adapter.file(filename)
|
61
63
|
adapter.execute
|
62
64
|
end
|
65
|
+
|
66
|
+
def configure
|
67
|
+
yield self if block_given?
|
68
|
+
end
|
63
69
|
end
|
64
70
|
end
|
data/lib/bitsontherun/api.rb
CHANGED
@@ -6,13 +6,13 @@ module BitsOnTheRun
|
|
6
6
|
|
7
7
|
def method(method, params = {})
|
8
8
|
if params.include?(:api_format)
|
9
|
-
raise ArgumentError("Params hash should not include :api_format
|
9
|
+
raise ArgumentError("Params hash should not include :api_format")
|
10
10
|
end
|
11
11
|
if params.include?(:api_key)
|
12
|
-
raise ArgumentError("Params hash should not include :api_key, use BitsOnTheRun
|
12
|
+
raise ArgumentError("Params hash should not include :api_key, use BitsOnTheRun.key instead")
|
13
13
|
end
|
14
14
|
if params.include?(:api_secret)
|
15
|
-
raise ArgumentError("Params hash should not include :api_secret, use BitsOnTheRun
|
15
|
+
raise ArgumentError("Params hash should not include :api_secret, use BitsOnTheRun.secret instead")
|
16
16
|
end
|
17
17
|
@adapter.method(method, params)
|
18
18
|
end
|
data/lib/bitsontherun/call.rb
CHANGED
@@ -7,8 +7,8 @@ module BitsOnTheRun
|
|
7
7
|
@defaults = {
|
8
8
|
:api_nonce => "%08d" % rand(99999999),
|
9
9
|
:api_timestamp => Time.now.to_i,
|
10
|
-
:api_key =>
|
11
|
-
:api_format =>
|
10
|
+
:api_key => BitsOnTheRun.key,
|
11
|
+
:api_format => BitsOnTheRun.format,
|
12
12
|
:api_kit => "ruby-%s" % VERSION
|
13
13
|
}
|
14
14
|
super
|
data/lib/bitsontherun/store.rb
CHANGED
data/lib/bitsontherun/version.rb
CHANGED
data/spec/lib/account_spec.rb
CHANGED
@@ -5,10 +5,10 @@ describe "API call to retrieve account" do
|
|
5
5
|
|
6
6
|
before do
|
7
7
|
@responses = []
|
8
|
-
@responses << BitsOnTheRun::call('accounts/show', :account_key => BitsOnTheRun
|
8
|
+
@responses << BitsOnTheRun::call('accounts/show', :account_key => BitsOnTheRun.key)
|
9
9
|
|
10
10
|
@manual = BitsOnTheRun::API.new(:call)
|
11
|
-
@manual.method('accounts/show', :account_key => BitsOnTheRun
|
11
|
+
@manual.method('accounts/show', :account_key => BitsOnTheRun.key)
|
12
12
|
@responses << @manual.execute
|
13
13
|
end
|
14
14
|
|
@@ -2,21 +2,21 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe "Configuration" do
|
4
4
|
before do
|
5
|
-
@key = BitsOnTheRun
|
6
|
-
@secret = BitsOnTheRun
|
5
|
+
@key = BitsOnTheRun.key
|
6
|
+
@secret = BitsOnTheRun.secret
|
7
7
|
end
|
8
8
|
|
9
9
|
it "should store configuration information in class attributes" do
|
10
|
-
BitsOnTheRun
|
11
|
-
BitsOnTheRun
|
10
|
+
BitsOnTheRun.key = "your api key"
|
11
|
+
BitsOnTheRun.secret = "your api secret"
|
12
12
|
|
13
|
-
BitsOnTheRun
|
14
|
-
BitsOnTheRun
|
15
|
-
BitsOnTheRun
|
13
|
+
BitsOnTheRun.key.should == "your api key"
|
14
|
+
BitsOnTheRun.secret.should == "your api secret"
|
15
|
+
BitsOnTheRun.format.should == "json"
|
16
16
|
end
|
17
17
|
|
18
18
|
after do
|
19
|
-
BitsOnTheRun
|
20
|
-
BitsOnTheRun
|
19
|
+
BitsOnTheRun.key = @key
|
20
|
+
BitsOnTheRun.secret = @secret
|
21
21
|
end
|
22
22
|
end
|
metadata
CHANGED
@@ -1,21 +1,21 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bitsontherun
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
|
-
- Adrian
|
13
|
+
- "Adrian Duli\xC4\x87"
|
14
14
|
autorequire:
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-02-
|
18
|
+
date: 2011-02-09 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -74,12 +74,12 @@ dependencies:
|
|
74
74
|
requirements:
|
75
75
|
- - "="
|
76
76
|
- !ruby/object:Gem::Version
|
77
|
-
hash:
|
77
|
+
hash: 27
|
78
78
|
segments:
|
79
79
|
- 2
|
80
|
-
-
|
80
|
+
- 5
|
81
81
|
- 0
|
82
|
-
version: 2.
|
82
|
+
version: 2.5.0
|
83
83
|
type: :development
|
84
84
|
version_requirements: *id004
|
85
85
|
description: BitsOnTheRun.com API implementation in Ruby
|
@@ -89,15 +89,15 @@ executables: []
|
|
89
89
|
|
90
90
|
extensions: []
|
91
91
|
|
92
|
-
extra_rdoc_files:
|
93
|
-
|
92
|
+
extra_rdoc_files:
|
93
|
+
- LICENSE
|
94
|
+
- README.markdown
|
94
95
|
files:
|
95
96
|
- .gitignore
|
96
|
-
- .rspec
|
97
97
|
- Gemfile
|
98
98
|
- Gemfile.lock
|
99
99
|
- LICENSE
|
100
|
-
- README.
|
100
|
+
- README.markdown
|
101
101
|
- Rakefile
|
102
102
|
- bitsontherun.gemspec
|
103
103
|
- lib/bitsontherun.rb
|
data/.rspec
DELETED