btsync_api 0.8.1 → 0.8.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +4 -0
- data/README.md +4 -1
- data/lib/btsync/api.rb +2 -2
- data/lib/btsync/version.rb +1 -1
- data/spec/btsync/api_spec.rb +8 -1
- metadata +3 -2
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# btsync
|
2
2
|
|
3
|
+
[![Build Status](https://travis-ci.org/pascalj/btsync.png?branch=master)](https://travis-ci.org/pascalj/btsync)
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/btsync_api.png)](http://badge.fury.io/rb/btsync_api)
|
5
|
+
|
3
6
|
A Ruby wrapper for the [BitTorrent Sync API](http://www.bittorrent.com/sync/developers).
|
4
7
|
|
5
8
|
## Installation
|
@@ -26,7 +29,7 @@ api = BtsyncApi::Api.new(options)
|
|
26
29
|
api.get_os # => {"os"=>"mac"}
|
27
30
|
|
28
31
|
# pass arguments to the API
|
29
|
-
api.add_folder(dir:
|
32
|
+
api.add_folder(dir: dir_path, secret: my_secret, selective_sync: 1)
|
30
33
|
|
31
34
|
api.remove_folder # raises BtsyncApi::ApiError('Specify all the required parameters for remove_folder')
|
32
35
|
```
|
data/lib/btsync/api.rb
CHANGED
@@ -2,7 +2,7 @@ require 'net/http'
|
|
2
2
|
require 'json'
|
3
3
|
|
4
4
|
module BtsyncApi
|
5
|
-
class ApiError <
|
5
|
+
class ApiError < StandardError
|
6
6
|
attr_reader :error_code
|
7
7
|
def initialize(error_code)
|
8
8
|
@error_code = error_code
|
@@ -20,7 +20,7 @@ module BtsyncApi
|
|
20
20
|
params = {method: method.to_s}
|
21
21
|
params.merge!(options)
|
22
22
|
response = do_request(params)
|
23
|
-
if response['error'] && response['error'] != 0
|
23
|
+
if response.is_a?(Hash) && response['error'] && response['error'] != 0
|
24
24
|
raise BtsyncApi::ApiError.new(response['error']), response['message']
|
25
25
|
end
|
26
26
|
response
|
data/lib/btsync/version.rb
CHANGED
data/spec/btsync/api_spec.rb
CHANGED
@@ -15,7 +15,7 @@ describe BtsyncApi::Api do
|
|
15
15
|
api.settings[:port].should == 8888
|
16
16
|
end
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
describe "#execute" do
|
20
20
|
|
21
21
|
it "calls the API" do
|
@@ -27,6 +27,13 @@ describe BtsyncApi::Api do
|
|
27
27
|
api.should_receive(:do_request).with(method: 'my_method', foo: 'bar', baz: 'foo')
|
28
28
|
api.execute('my_method', foo: 'bar', baz: 'foo')
|
29
29
|
end
|
30
|
+
|
31
|
+
it "handles arrays as response" do
|
32
|
+
api.stub(:do_request).and_return([])
|
33
|
+
expect{
|
34
|
+
api.execute('get_folders')
|
35
|
+
}.to_not raise_error
|
36
|
+
end
|
30
37
|
end
|
31
38
|
|
32
39
|
describe "#method_missing" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: btsync_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2014-01-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -68,6 +68,7 @@ extra_rdoc_files: []
|
|
68
68
|
files:
|
69
69
|
- .gitignore
|
70
70
|
- .rspec
|
71
|
+
- .travis.yml
|
71
72
|
- Gemfile
|
72
73
|
- LICENSE.txt
|
73
74
|
- README.md
|