BtSync 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/btsync.gemspec +27 -0
- data/lib/btsync.rb +103 -0
- data/lib/btsync/version.rb +3 -0
- metadata +103 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA512:
|
3
|
+
metadata.gz: 836f4bb22c32ea95ae660a7552e54de2ac5b862d7a661619e8d8e2f9dcf85ebc3f2a4ec0660ac6fdf47b59a639c67a54d657a40741f4673ad8669fa59a40075b
|
4
|
+
data.tar.gz: 23476217aa90091abe25801ec24a7524b8b2c9ef8465d6a60395395e78d5b6a58f547f67b2185dc76da3d22ec908fdb10cb06651f7dde24c5c11a64a7d61dfd6
|
5
|
+
SHA1:
|
6
|
+
metadata.gz: b0f8fbda9f18fe7d8e42acf16d036a9ed52675df
|
7
|
+
data.tar.gz: 316de2ce209f019a82e8300cae406a044af318ee
|
data/.gitignore
ADDED
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
btsync
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-1.9.3-p392
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Chris MacNaughton
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Btsync
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'btsync'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install btsync
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/btsync.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'btsync/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "BtSync"
|
8
|
+
spec.version = BtsyncVersion::VERSION
|
9
|
+
spec.authors = ["Chris MacNaughton"]
|
10
|
+
spec.email = ["chmacnaughton@gmail.com"]
|
11
|
+
spec.description = %q{Class to interact with BTSync's web interface using their unofficial API}
|
12
|
+
spec.summary = %q{Class to interact with BTSync's web interface}
|
13
|
+
spec.homepage = "http://chrismacnaughton.com/projects#btsync"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
|
24
|
+
spec.add_runtime_dependency "httparty"
|
25
|
+
spec.add_runtime_dependency "nokogiri"
|
26
|
+
spec.add_runtime_dependency "json"
|
27
|
+
end
|
data/lib/btsync.rb
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
require 'nokogiri'
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
class Btsync
|
6
|
+
include HTTParty
|
7
|
+
def initialize uri=nil, port=nil
|
8
|
+
@cache = {
|
9
|
+
:folder => 0,
|
10
|
+
:secret => 0,
|
11
|
+
:settings => 0,
|
12
|
+
:os_type => 0,
|
13
|
+
:new_version => 0
|
14
|
+
}
|
15
|
+
@uri = uri
|
16
|
+
@port = port
|
17
|
+
secret
|
18
|
+
end
|
19
|
+
def get_folders
|
20
|
+
get_folder_list["folders"]
|
21
|
+
end
|
22
|
+
def get_speed
|
23
|
+
s = get_folder_list["speed"].split(", ")
|
24
|
+
up = s[0].split(" ")
|
25
|
+
down = s[1].split(" ")
|
26
|
+
{:up => up[0], :down => down[0], :metric => up[1]}
|
27
|
+
end
|
28
|
+
|
29
|
+
def get_settings
|
30
|
+
time = DateTime.now.strftime("%s").to_i
|
31
|
+
if time > @cache[:settings] + 600
|
32
|
+
res = self.class.get(path('getsettings'), :query => {:output => "json"}, :headers => {"Cookie" => cookies })
|
33
|
+
@settings = res.parsed_response["settings"]
|
34
|
+
@cache[:settings] = time
|
35
|
+
end
|
36
|
+
@settings
|
37
|
+
end
|
38
|
+
def get_os_type
|
39
|
+
time = DateTime.now.strftime("%s").to_i
|
40
|
+
if time > @cache[:os_type] + 600
|
41
|
+
res = self.class.get(path('getostype'), :query => {:output => "json"}, :headers => {"Cookie" => cookies })
|
42
|
+
@os_type = res.parsed_response["os"]
|
43
|
+
@cache[:os_type] = time
|
44
|
+
end
|
45
|
+
@os_type
|
46
|
+
end
|
47
|
+
def get_version
|
48
|
+
time = DateTime.now.strftime("%s").to_i
|
49
|
+
if time > @cache[:version] + 600
|
50
|
+
res = self.class.get(path('getversion'), :query => {:output => "json"}, :headers => {"Cookie" => cookies })
|
51
|
+
@version = res.parsed_response
|
52
|
+
@cache[:version] = time
|
53
|
+
end
|
54
|
+
@version
|
55
|
+
end
|
56
|
+
def check_new_version
|
57
|
+
time = DateTime.now.strftime("%s").to_i
|
58
|
+
if time > @cache[:new_version] + 600
|
59
|
+
res = self.class.get(path('checknewversion'), :query => {:output => "json"}, :headers => {"Cookie" => cookies })
|
60
|
+
@new_version = res.parsed_response["version"]
|
61
|
+
@cache[:new_version] = time
|
62
|
+
end
|
63
|
+
@new_version
|
64
|
+
end
|
65
|
+
def get_dir with_dir
|
66
|
+
res = self.class.get(path('getdir'), :query => {:dir => with_dir, :output => "json"}, :headers => {"Cookie" => cookies })
|
67
|
+
res.parsed_response["folders"]
|
68
|
+
end
|
69
|
+
private
|
70
|
+
def get_folder_list
|
71
|
+
time = DateTime.now.strftime("%s").to_i
|
72
|
+
if time > @cache[:folder] + 600
|
73
|
+
res = self.class.get(path('getsyncfolders'), :query => {:output => "json"}, :headers => {"Cookie" => cookies })
|
74
|
+
@folder_list = res.parsed_response
|
75
|
+
@cache[:folder] = time
|
76
|
+
end
|
77
|
+
@folder_list
|
78
|
+
end
|
79
|
+
|
80
|
+
def port
|
81
|
+
@port ||= '8888'
|
82
|
+
end
|
83
|
+
def uri
|
84
|
+
@uri ||= "http://localhost"
|
85
|
+
end
|
86
|
+
def secret
|
87
|
+
time = DateTime.now.strftime("%s").to_i
|
88
|
+
if time > @cache[:secret] + 600
|
89
|
+
@secret = Nokogiri::HTML(request_token).search('#token').text
|
90
|
+
@cache[:secret] = time
|
91
|
+
end
|
92
|
+
@secret
|
93
|
+
end
|
94
|
+
def cookies
|
95
|
+
@cookies ||= request_token.headers["set-cookie"].split("; ")[0]
|
96
|
+
end
|
97
|
+
def request_token
|
98
|
+
@request_token ||= self.class.get("#{uri}:#{port}/gui/token.html?t=" + DateTime.now.strftime('%s'))
|
99
|
+
end
|
100
|
+
def path action_name
|
101
|
+
"#{uri}:#{port}/gui/?token=#{secret}&action=#{action_name}"
|
102
|
+
end
|
103
|
+
end
|
metadata
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: BtSync
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Chris MacNaughton
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2013-06-04 00:00:00 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
prerelease: false
|
17
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: "1.3"
|
22
|
+
type: :development
|
23
|
+
version_requirements: *id001
|
24
|
+
- !ruby/object:Gem::Dependency
|
25
|
+
name: rake
|
26
|
+
prerelease: false
|
27
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
28
|
+
requirements:
|
29
|
+
- &id003
|
30
|
+
- ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: "0"
|
33
|
+
type: :development
|
34
|
+
version_requirements: *id002
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: httparty
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- *id003
|
41
|
+
type: :runtime
|
42
|
+
version_requirements: *id004
|
43
|
+
- !ruby/object:Gem::Dependency
|
44
|
+
name: nokogiri
|
45
|
+
prerelease: false
|
46
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
47
|
+
requirements:
|
48
|
+
- *id003
|
49
|
+
type: :runtime
|
50
|
+
version_requirements: *id005
|
51
|
+
- !ruby/object:Gem::Dependency
|
52
|
+
name: json
|
53
|
+
prerelease: false
|
54
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- *id003
|
57
|
+
type: :runtime
|
58
|
+
version_requirements: *id006
|
59
|
+
description: Class to interact with BTSync's web interface using their unofficial API
|
60
|
+
email:
|
61
|
+
- chmacnaughton@gmail.com
|
62
|
+
executables: []
|
63
|
+
|
64
|
+
extensions: []
|
65
|
+
|
66
|
+
extra_rdoc_files: []
|
67
|
+
|
68
|
+
files:
|
69
|
+
- .gitignore
|
70
|
+
- .ruby-gemset
|
71
|
+
- .ruby-version
|
72
|
+
- Gemfile
|
73
|
+
- LICENSE.txt
|
74
|
+
- README.md
|
75
|
+
- Rakefile
|
76
|
+
- btsync.gemspec
|
77
|
+
- lib/btsync.rb
|
78
|
+
- lib/btsync/version.rb
|
79
|
+
homepage: http://chrismacnaughton.com/projects#btsync
|
80
|
+
licenses:
|
81
|
+
- MIT
|
82
|
+
metadata: {}
|
83
|
+
|
84
|
+
post_install_message:
|
85
|
+
rdoc_options: []
|
86
|
+
|
87
|
+
require_paths:
|
88
|
+
- lib
|
89
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- *id003
|
92
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- *id003
|
95
|
+
requirements: []
|
96
|
+
|
97
|
+
rubyforge_project:
|
98
|
+
rubygems_version: 2.0.3
|
99
|
+
signing_key:
|
100
|
+
specification_version: 4
|
101
|
+
summary: Class to interact with BTSync's web interface
|
102
|
+
test_files: []
|
103
|
+
|