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 CHANGED
@@ -1,4 +1,5 @@
1
1
  pkg/*
2
2
  *.gem
3
3
  .bundle
4
+ .rspec
4
5
  nbproject
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2010 Adrian Dulic
1
+ Copyright (c) 2010 Adrian Dulić
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
@@ -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
- Gemfile:
8
+ Just run the following command:
9
9
 
10
- gem 'bitsontherun', :git => 'http://github.com/adriandulic/bitsontherun.git'
10
+ gem install bitsontherun
11
11
 
12
- Setup:
12
+ Then in your Gemfile add the following line:
13
13
 
14
- BitsOnTheRun::Configuration.key = "your api key"
15
- BitsOnTheRun::Configuration.secret = "your api secret"
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
- Extended:
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')
@@ -1,26 +1,30 @@
1
1
  # -*- encoding: utf-8 -*-
2
- require File.expand_path("../lib/bitsontherun/version", __FILE__)
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 = ['Adrian Dulic']
9
- s.email = ['adulic@gmail.com']
9
+ s.authors = ["Adrian Dulić"]
10
+ s.email = ["adulic@gmail.com"]
10
11
  s.homepage = "http://github.com/adriandulic/bitsontherun"
11
- s.summary = "BitsOnTheRun.com API implementation in Ruby"
12
- s.description = "BitsOnTheRun.com API implementation in Ruby"
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 = "bitsontherun"
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.4.0"
22
-
23
- s.files = `git ls-files`.split("\n")
24
- s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
25
- s.require_path = 'lib'
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
@@ -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 + Configuration.secret)
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
@@ -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, use BitsOnTheRun::Configuration.format instead")
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::Configuration.key instead")
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::Configuration.secret instead")
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
@@ -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 => Configuration.key,
11
- :api_format => Configuration.format,
10
+ :api_key => BitsOnTheRun.key,
11
+ :api_format => BitsOnTheRun.format,
12
12
  :api_kit => "ruby-%s" % VERSION
13
13
  }
14
14
  super
@@ -1,10 +1,8 @@
1
1
  module BitsOnTheRun
2
- class Configuration
3
- class << self
4
- attr_accessor :key
5
- attr_accessor :secret
2
+ module Configuration
3
+ attr_accessor :key
4
+ attr_accessor :secret
6
5
 
7
- def format; "json"; end
8
- end
6
+ def format; "json"; end
9
7
  end
10
8
  end
@@ -3,7 +3,7 @@ module BitsOnTheRun
3
3
  def initialize
4
4
  @response = nil
5
5
  @defaults = {
6
- :api_format => Configuration.format
6
+ :api_format => BitsOnTheRun.format
7
7
  }
8
8
  super
9
9
  end
@@ -1,3 +1,3 @@
1
1
  module BitsOnTheRun
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -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::Configuration.key)
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::Configuration.key)
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::Configuration.key
6
- @secret = BitsOnTheRun::Configuration.secret
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::Configuration.key = "your api key"
11
- BitsOnTheRun::Configuration.secret = "your api secret"
10
+ BitsOnTheRun.key = "your api key"
11
+ BitsOnTheRun.secret = "your api secret"
12
12
 
13
- BitsOnTheRun::Configuration.key.should == "your api key"
14
- BitsOnTheRun::Configuration.secret.should == "your api secret"
15
- BitsOnTheRun::Configuration.format.should == "json"
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::Configuration.key = @key
20
- BitsOnTheRun::Configuration.secret = @secret
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: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
- - Adrian Dulic
13
+ - "Adrian Duli\xC4\x87"
14
14
  autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-02-07 00:00:00 +01:00
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: 31
77
+ hash: 27
78
78
  segments:
79
79
  - 2
80
- - 4
80
+ - 5
81
81
  - 0
82
- version: 2.4.0
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.md
100
+ - README.markdown
101
101
  - Rakefile
102
102
  - bitsontherun.gemspec
103
103
  - lib/bitsontherun.rb
data/.rspec DELETED
@@ -1,4 +0,0 @@
1
- --colour
2
- --format
3
- documentation
4
- mtime