BtSync 0.1.2 → 0.2.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
- ---
2
- SHA512:
3
- metadata.gz: 21b0171af7da2cd9b686d6259f5649fb520b643d001ec883130f1cdea188ff1e4377f802a1240a37d5a0f415b79e8caa804fe4ae65f43b4ec8365aba6a1a8821
4
- data.tar.gz: a33fc44ae08d5e11c9f1509111440b59df349e9d23c07c20ab5244c462efda03d4a8ee018a3f99f8213286129a0fdcf75df007abfab6680cfc786c94a5ba6dc0
5
- SHA1:
6
- metadata.gz: 06ebccf1bf025cba4bbadec32ad28a64d5a6f796
7
- data.tar.gz: 656fe16887a65e3f533ee54a511d92f90dc955c2
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ODYwZWQyNTQ5MmY5ZTk0MWU3YWM1MTYwYmM0ZjVkNjY0MDI1MTUxZg==
5
+ data.tar.gz: !binary |-
6
+ ZmRkODRiNDAxMGZiN2Q5N2UyNTk2NjFiNTExN2Q0ZDIwNGNjMTkxYw==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ NWQ3ZjcxZDc0NWFmODBiYjYwYmQzNmM3N2M2NGIxZGYyODc4OTcxYjNjZjI0
10
+ MWE5Y2E5NmY2ZTNhMjNhNjRkNzc4NmM1OTUyYTBhYTU0ZjUzZjM0NWFmMGIw
11
+ NjQwY2Q2NDE5ZDVlNDI2ZTNmMThjNDJjYTNmNWMzN2NiY2E1OWY=
12
+ data.tar.gz: !binary |-
13
+ OTFjNjFmNmJjNmY5MmJhZmM1ODMwMTkzYTllODhlZmQyMjZlYmJkNzhlMGRj
14
+ ZTY4OWViODMyNzNmMTdlMDQ0MzlmY2EwYjI2NzI1ZTcyNmZmZmUzMTE0YTcx
15
+ OGMwZjQxM2YyNDcwNWUzOGJkNTVmOTJlNGZmZWUzM2IwNjBiNDg=
data/.gitignore CHANGED
@@ -15,3 +15,4 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
+ .DS_Store
data/lib/btsync.rb CHANGED
@@ -3,18 +3,17 @@ require 'httparty'
3
3
  class BtSync
4
4
  include HTTParty
5
5
  default_params :output => 'json'
6
+ debug_output
6
7
  def initialize uri=nil, port=nil
7
- @cache = {
8
- :folder => 0,
9
- :secret => 0,
10
- :settings => 0,
11
- :os_type => 0,
12
- :version => 0,
13
- :new_version => 0
14
- }
15
8
  @uri = uri
16
9
  @port = port
17
- token
10
+ @errors = []
11
+ @token_cache = 0
12
+ end
13
+ def errors
14
+ errors = @errors
15
+ @errors = []
16
+ errors
18
17
  end
19
18
  def get_folders
20
19
  get_folder_list["folders"]
@@ -25,56 +24,141 @@ class BtSync
25
24
  down = s[1].split(" ")
26
25
  {:up => up[0], :down => down[0], :metric => up[1]}
27
26
  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'), :headers => {"Cookie" => cookies })
33
- @settings = res.parsed_response["settings"]
34
- @cache[:settings] = time
27
+ def remove_folder folder_name, my_secret = nil
28
+ my_secret ||= secret(folder_name)
29
+ res = self.class.get(path('removefolder'), :query => { :name => folder_name, :secret => my_secret}, :headers => {"Cookie" => cookies})
30
+ token(true)
31
+ true
32
+ end
33
+ def add_folder folder_name, my_secret = nil
34
+ my_secret ||= generate_secret
35
+ res = self.class.get(path('addsyncfolder'), :query => { :name => folder_name, :secret => my_secret}, :headers => {"Cookie" => cookies})
36
+ unless res["error"] == 0
37
+ @errors << res["message"]
38
+ return false
35
39
  end
36
- @settings
40
+ token(true)
41
+ true
42
+ end
43
+ def update_secret with_dir, new_secret = nil, my_secret = nil
44
+ my_secret ||= secret(with_dir)
45
+ new_secret ||= generate_secret
46
+ self.class.get(path('updatesecret'), :query => { :name => with_dir, :secret => my_secret, :newsecret => new_secret}, :headers => {"Cookie" => cookies})
47
+ true
48
+ end
49
+ def use_tracker with_dir, opt = true
50
+ res = self.class.get(path('setfolderpref'), query: make_opts(with_dir, 'usetracker', opt), :headers => {"Cookie" => cookies })
51
+ true
52
+ end
53
+ def use_tracker? with_dir
54
+ bool(get_folder_preferences(with_dir)["usetracker"])
55
+ end
56
+ def use_hosts with_dir, opt = false
57
+ res = self.class.get(path('setfolderpref'), query: make_opts(with_dir, 'usehosts', opt), :headers => {"Cookie" => cookies })
58
+ true
59
+ end
60
+ def use_hosts? with_dir
61
+ bool(get_folder_preferences(with_dir)["usehosts"])
62
+ end
63
+ def search_lan with_dir, opt = true
64
+ res = self.class.get(path('setfolderpref'), query: make_opts(with_dir, 'searchlan', opt), :headers => {"Cookie" => cookies })
65
+ true
66
+ end
67
+ def search_lan? with_dir
68
+ bool(get_folder_preferences(with_dir)["searchlan"])
69
+ end
70
+ def search_dht with_dir, opt = false
71
+ res = self.class.get(path('setfolderpref'), query: make_opts(with_dir, 'searchdht', opt), :headers => {"Cookie" => cookies })
72
+ true
73
+ end
74
+ def search_dht? with_dir
75
+ bool(get_folder_preferences(with_dir)["searchdht"])
76
+ end
77
+ def use_relay with_dir, opt = true
78
+ res = self.class.get(path('setfolderpref'), query: make_opts(with_dir, 'relay', opt), :headers => {"Cookie" => cookies })
79
+ true
80
+ end
81
+ def use_relay? with_dir
82
+ bool(get_folder_preferences(with_dir)["relay"])
83
+ end
84
+ def delete_to_trash with_dir, opt = true
85
+ res = self.class.get(path('setfolderpref'), query: make_opts(with_dir, 'deletetotrash', opt), :headers => {"Cookie" => cookies })
86
+ true
87
+ end
88
+ def delete_to_trash? with_dir
89
+ bool(get_folder_preferences(with_dir)["deletetotrash"])
90
+ end
91
+ def is_writable? with_dir
92
+ bool(get_folder_preferences(with_dir)["iswritable"])
93
+ end
94
+ def generate_secret
95
+ res = self.class.get(path('generatesecret'), :headers => {"Cookie" => cookies })
96
+ res.parsed_response["secret"]
97
+ end
98
+ def get_settings
99
+ res = self.class.get(path('getsettings'), :headers => {"Cookie" => cookies })
100
+ res.parsed_response["settings"]
37
101
  end
38
102
  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'), :headers => {"Cookie" => cookies })
42
- @os_type = res.parsed_response["os"]
43
- @cache[:os_type] = time
44
- end
45
- @os_type
103
+ res = self.class.get(path('getostype'), :headers => {"Cookie" => cookies })
104
+ res.parsed_response["os"]
46
105
  end
47
106
  def get_version
48
- time = DateTime.now.strftime("%s").to_i
49
- if time > @cache[:version] + 600
50
- res = self.class.get(path('getversion'), :headers => {"Cookie" => cookies })
51
- @version = res.parsed_response["version"]
52
- @cache[:version] = time
53
- end
54
- @version
107
+ res = self.class.get(path('getversion'), :headers => {"Cookie" => cookies })
108
+ res.parsed_response["version"]
55
109
  end
56
110
  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'), :headers => {"Cookie" => cookies })
60
- @new_version = res.parsed_response["version"]
61
- @cache[:new_version] = time
62
- end
63
- @new_version
111
+ res = self.class.get(path('checknewversion'), :headers => {"Cookie" => cookies })
112
+ res.parsed_response["version"]
113
+ end
114
+ def get_folder_preferences folder_name, my_secret = nil
115
+ my_secret ||= secret(folder_name)
116
+ res = self.class.get(path('getfolderpref'), :query => { :name => folder_name, :secret => my_secret}, :headers => {"Cookie" => cookies})
117
+ res.parsed_response["folderpref"]
64
118
  end
65
119
  def get_dir with_dir
66
120
  res = self.class.get(path('getdir'), :query => {:dir => with_dir}, :headers => {"Cookie" => cookies })
67
121
  res.parsed_response["folders"]
68
122
  end
123
+ def get_known_hosts with_dir, my_secret = nil
124
+ my_secret ||= secret(with_dir)
125
+ res = self.class.get(path('getknownhosts'), :query => {:name => with_dir, :secret => my_secret}, :headers => {"Cookie" => cookies })
126
+ res["hosts"]
127
+ end
128
+ def secret with_dir
129
+ f = get_folders.select{|folder| folder["name"] == with_dir}.first
130
+ f["secret"]
131
+ end
132
+ def get_read_only_secret with_dir, my_secret = nil
133
+ my_secret ||= secret(with_dir)
134
+ get_folder_preferences(with_dir, my_secret)["readonlysecret"]
135
+ end
69
136
  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'), :headers => {"Cookie" => cookies })
74
- @folder_list = res.parsed_response
75
- @cache[:folder] = time
137
+ def make_opts with_dir, name, opt
138
+ opts = get_folder_preferences(with_dir)
139
+ opts[name] = bool_to_i(opt)
140
+ opts.delete('readonlysecret')
141
+ opts.merge!({:name => with_dir, :secret => secret(with_dir)})
142
+ end
143
+ def bool i
144
+ if i == 0
145
+ false
146
+ elsif i == 1
147
+ true
148
+ else
149
+ i
76
150
  end
77
- @folder_list
151
+ end
152
+ def bool_to_i bool
153
+ if bool
154
+ 1
155
+ else
156
+ 0
157
+ end
158
+ end
159
+ def get_folder_list
160
+ res = self.class.get(path('getsyncfolders'), :headers => {"Cookie" => cookies })
161
+ @folder_list = res.parsed_response
78
162
  end
79
163
 
80
164
  def port
@@ -83,19 +167,24 @@ class BtSync
83
167
  def uri
84
168
  @uri ||= "http://localhost"
85
169
  end
86
- def token
170
+ def token force = false
87
171
  time = DateTime.now.strftime("%s").to_i
88
- if time > @cache[:secret] + 600
89
- @token = request_token.gsub('</div></html>', '').gsub("<html><div id='token' style='display:none;'>", '')
90
- @cache[:secret] = time
172
+ if time > @token_cache + 600 || force
173
+ @token = request_token(force).gsub('</div></html>', '').gsub("<html><div id='token' style='display:none;'>", '')
174
+ @token_cache = time
91
175
  end
176
+ @cookies = nil if force
92
177
  @token
93
178
  end
94
179
  def cookies
95
180
  @cookies ||= request_token.headers["set-cookie"].split("; ")[0]
96
181
  end
97
- def request_token
98
- @request_token ||= self.class.get("#{uri}:#{port}/gui/token.html", :query => {:output => :text})
182
+ def request_token force = false
183
+ if @request_token.nil? || force
184
+ @request_token = self.class.get("#{uri}:#{port}/gui/token.html", :query => {:output => :text})
185
+ else
186
+ @request_token
187
+ end
99
188
  end
100
189
  def path action_name
101
190
  "#{uri}:#{port}/gui/?token=#{token}&action=#{action_name}"
@@ -1,3 +1,3 @@
1
1
  module BtsyncVersion
2
- VERSION = "0.1.2"
2
+ VERSION = "0.2.1"
3
3
  end
@@ -1,18 +1,17 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
2
2
  require 'btsync'
3
3
  describe 'BtSync' do
4
- before do
4
+ before(:each) do
5
5
  VCR.use_cassette("Setup-BtSync") do
6
6
  @bt = BtSync.new
7
7
  end
8
8
  end
9
+
9
10
  it "can view a folder list" do
10
11
  VCR.use_cassette("get-folders") do
11
12
  @folder = @bt.get_folders.first
12
13
  end
13
- @folder["secret"].should == "KLXT6ZZBEABLFIL6X7VBHT7YA4YQQOJM"
14
- @folder["peers"].should == []
15
- @folder["size"].should == "21 B in 1 files"
14
+ @folder["name"].should == "/home/chris/Documents"
16
15
  end
17
16
  it "can view settings" do
18
17
  VCR.use_cassette("get-settings") do
@@ -33,4 +32,24 @@ describe 'BtSync' do
33
32
  end
34
33
  @version.should == 16777350
35
34
  end
35
+ it "can add and delete a folder" do
36
+ VCR.use_cassette("add-folder") do
37
+ @bt.add_folder '/home/chris/bt_test'
38
+ end
39
+ VCR.use_cassette("add-folder-list") do
40
+ folders = @bt.get_folders
41
+ folders.count.should == 2
42
+ folder = folders.last
43
+ folder["name"].should == "/home/chris/bt_test"
44
+ end
45
+ VCR.use_cassette("remove-folder") do
46
+ @bt.remove_folder '/home/chris/bt_test'
47
+ end
48
+ VCR.use_cassette("remove-folder-list") do
49
+ folders = @bt.get_folders
50
+ folders.count.should == 1
51
+ folder = folders.last
52
+ folder["name"].should == "/home/chris/Documents"
53
+ end
54
+ end
36
55
  end
@@ -0,0 +1,33 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://localhost:8888/gui/?action=getsyncfolders&output=json&token=7P1iDM-j30_D4KpN4veMfy1O12KRXyAdIaSU2A1JsesOOPcU7IJwtBlOr1EAAAAA
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Cookie:
11
+ - GUID=QCUnp9BcpaVLftYoQ2ZB
12
+ response:
13
+ status:
14
+ code: 200
15
+ message: OK
16
+ headers:
17
+ Connection:
18
+ - keep-alive
19
+ Content-Length:
20
+ - '311'
21
+ Content-Type:
22
+ - application/json; charset=utf-8
23
+ Cache-Control:
24
+ - no-cache
25
+ body:
26
+ encoding: US-ASCII
27
+ string: ! '{ "folders": [ { "name": "\/home\/chris\/Documents", "peers": [ ],
28
+ "secret": "6VX7XSMS5R2CSDKLXBENUZIENMVUONRT", "size": "21 B in 1 files" },
29
+ { "name": "\/home\/chris\/bt_test", "peers": [ ], "secret": "EV63ZJO7DX25LMMRDDQWDDQ3XZ4ETJV5",
30
+ "size": "0 B in 0 files" } ], "speed": "0.0 kB\/s up, 0.0 kB\/s down" }'
31
+ http_version:
32
+ recorded_at: Wed, 05 Jun 2013 14:41:29 GMT
33
+ recorded_with: VCR 2.5.0
@@ -0,0 +1,87 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://localhost:8888/gui/token.html?output=text
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers: {}
10
+ response:
11
+ status:
12
+ code: 200
13
+ message: OK
14
+ headers:
15
+ Connection:
16
+ - keep-alive
17
+ Content-Length:
18
+ - '121'
19
+ Content-Type:
20
+ - text/html
21
+ Set-Cookie:
22
+ - GUID=QCUnp9BcpaVLftYoQ2ZB; path=/
23
+ Cache-Control:
24
+ - no-cache
25
+ body:
26
+ encoding: US-ASCII
27
+ string: <html><div id='token' style='display:none;'>7P1iDM-j30_D4KpN4veMfy1O12KRXyAdIaSU2A1JsesOOPcU7IJwtBlOr1EAAAAA</div></html>
28
+ http_version:
29
+ recorded_at: Wed, 05 Jun 2013 14:41:29 GMT
30
+ - request:
31
+ method: get
32
+ uri: http://localhost:8888/gui/?action=generatesecret&output=json&token=7P1iDM-j30_D4KpN4veMfy1O12KRXyAdIaSU2A1JsesOOPcU7IJwtBlOr1EAAAAA
33
+ body:
34
+ encoding: US-ASCII
35
+ string: ''
36
+ headers:
37
+ Cookie:
38
+ - GUID=QCUnp9BcpaVLftYoQ2ZB
39
+ response:
40
+ status:
41
+ code: 200
42
+ message: OK
43
+ headers:
44
+ Connection:
45
+ - keep-alive
46
+ Content-Length:
47
+ - '97'
48
+ Content-Type:
49
+ - application/json; charset=utf-8
50
+ Cache-Control:
51
+ - no-cache
52
+ body:
53
+ encoding: US-ASCII
54
+ string: ! '{ "rosecret": "RXMAKBNPSWLXHML7WKZJLNDKI5N7ESOJZ", "secret": "LGNHKDANNJJIGN4NU4PBV4IS3TAEWGDS"
55
+ }'
56
+ http_version:
57
+ recorded_at: Wed, 05 Jun 2013 14:41:29 GMT
58
+ - request:
59
+ method: get
60
+ uri: http://localhost:8888/gui/?action=addsyncfolder&name=/home/chris/bt_test&output=json&secret=LGNHKDANNJJIGN4NU4PBV4IS3TAEWGDS&token=7P1iDM-j30_D4KpN4veMfy1O12KRXyAdIaSU2A1JsesOOPcU7IJwtBlOr1EAAAAA
61
+ body:
62
+ encoding: US-ASCII
63
+ string: ''
64
+ headers:
65
+ Cookie:
66
+ - GUID=QCUnp9BcpaVLftYoQ2ZB
67
+ response:
68
+ status:
69
+ code: 200
70
+ message: OK
71
+ headers:
72
+ Connection:
73
+ - keep-alive
74
+ Content-Length:
75
+ - '160'
76
+ Content-Type:
77
+ - application/json; charset=utf-8
78
+ Cache-Control:
79
+ - no-cache
80
+ body:
81
+ encoding: US-ASCII
82
+ string: ! '{ "error": 200, "message": "Selected folder is already added to BitTorrent
83
+ Sync.", "n": "\/home\/chris\/bt_test", "secret": "LGNHKDANNJJIGN4NU4PBV4IS3TAEWGDS"
84
+ }'
85
+ http_version:
86
+ recorded_at: Wed, 05 Jun 2013 14:41:29 GMT
87
+ recorded_with: VCR 2.5.0
@@ -1,28 +1,60 @@
1
- ---
2
- recorded_with: VCR 2.5.0
3
- http_interactions:
4
- - request:
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://localhost:8888/gui/token.html?output=text
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers: {}
10
+ response:
11
+ status:
12
+ code: 200
13
+ message: OK
14
+ headers:
15
+ Connection:
16
+ - keep-alive
17
+ Content-Length:
18
+ - '121'
19
+ Content-Type:
20
+ - text/html
21
+ Set-Cookie:
22
+ - GUID=UlSArc3wDYfvcUrEuASX; path=/
23
+ Cache-Control:
24
+ - no-cache
25
+ body:
26
+ encoding: US-ASCII
27
+ string: <html><div id='token' style='display:none;'>3LoV0nj_bN345atjFiAg6B8JpJT6Fg8Dxh8U5QFeBF6kpf1M0MsyqRlOr1EAAAAA</div></html>
28
+ http_version:
29
+ recorded_at: Wed, 05 Jun 2013 14:41:29 GMT
30
+ - request:
5
31
  method: get
6
- uri: http://localhost:8888/gui/?action=getsyncfolders&output=json&token=grsJ7BMbd6FPJND8DVjjZBZdHKV44iACI83vsaYfENHJYr2peP4GJdU7rlEAAAAA
7
- body:
8
- string: ""
9
- headers:
10
- Cookie:
11
- - GUID=SklJvMPAaAAUrQIQ3W3i
12
- response:
13
- status:
32
+ uri: http://localhost:8888/gui/?action=getsyncfolders&output=json&token=3LoV0nj_bN345atjFiAg6B8JpJT6Fg8Dxh8U5QFeBF6kpf1M0MsyqRlOr1EAAAAA
33
+ body:
34
+ encoding: US-ASCII
35
+ string: ''
36
+ headers:
37
+ Cookie:
38
+ - GUID=UlSArc3wDYfvcUrEuASX
39
+ response:
40
+ status:
14
41
  code: 200
15
42
  message: OK
16
- headers:
17
- Connection:
43
+ headers:
44
+ Connection:
18
45
  - keep-alive
19
- Content-Type:
46
+ Content-Length:
47
+ - '311'
48
+ Content-Type:
20
49
  - application/json; charset=utf-8
21
- Content-Length:
22
- - "186"
23
- Cache-Control:
50
+ Cache-Control:
24
51
  - no-cache
25
- body:
26
- string: "{ \"folders\": [ { \"name\": \"\\/home\\/chris\\/Documents\", \"peers\": [ ], \"secret\": \"KLXT6ZZBEABLFIL6X7VBHT7YA4YQQOJM\", \"size\": \"21 B in 1 files\" } ], \"speed\": \"0.0 kB\\/s up, 0.0 kB\\/s down\" }"
52
+ body:
53
+ encoding: US-ASCII
54
+ string: ! '{ "folders": [ { "name": "\/home\/chris\/Documents", "peers": [ ],
55
+ "secret": "6VX7XSMS5R2CSDKLXBENUZIENMVUONRT", "size": "21 B in 1 files" },
56
+ { "name": "\/home\/chris\/bt_test", "peers": [ ], "secret": "EV63ZJO7DX25LMMRDDQWDDQ3XZ4ETJV5",
57
+ "size": "0 B in 0 files" } ], "speed": "0.0 kB\/s up, 0.0 kB\/s down" }'
27
58
  http_version:
28
- recorded_at: Tue, 04 Jun 2013 19:11:20 GMT
59
+ recorded_at: Wed, 05 Jun 2013 14:41:29 GMT
60
+ recorded_with: VCR 2.5.0
@@ -1,28 +1,57 @@
1
- ---
2
- recorded_with: VCR 2.5.0
3
- http_interactions:
4
- - request:
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://localhost:8888/gui/token.html?output=text
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers: {}
10
+ response:
11
+ status:
12
+ code: 200
13
+ message: OK
14
+ headers:
15
+ Connection:
16
+ - keep-alive
17
+ Content-Length:
18
+ - '121'
19
+ Content-Type:
20
+ - text/html
21
+ Set-Cookie:
22
+ - GUID=E8QEpnn31pUHTfaat2xB; path=/
23
+ Cache-Control:
24
+ - no-cache
25
+ body:
26
+ encoding: US-ASCII
27
+ string: <html><div id='token' style='display:none;'>xhHpPZNEhQHIv1F-lM7CrvqrsNp_F2-lgweazZXUsAt3ZECxYkkvmhlOr1EAAAAA</div></html>
28
+ http_version:
29
+ recorded_at: Wed, 05 Jun 2013 14:41:29 GMT
30
+ - request:
5
31
  method: get
6
- uri: http://localhost:8888/gui/?action=getostype&output=json&token=grsJ7BMbd6FPJND8DVjjZBZdHKV44iACI83vsaYfENHJYr2peP4GJdU7rlEAAAAA
7
- body:
8
- string: ""
9
- headers:
10
- Cookie:
11
- - GUID=SklJvMPAaAAUrQIQ3W3i
12
- response:
13
- status:
32
+ uri: http://localhost:8888/gui/?action=getostype&output=json&token=xhHpPZNEhQHIv1F-lM7CrvqrsNp_F2-lgweazZXUsAt3ZECxYkkvmhlOr1EAAAAA
33
+ body:
34
+ encoding: US-ASCII
35
+ string: ''
36
+ headers:
37
+ Cookie:
38
+ - GUID=E8QEpnn31pUHTfaat2xB
39
+ response:
40
+ status:
14
41
  code: 200
15
42
  message: OK
16
- headers:
17
- Connection:
43
+ headers:
44
+ Connection:
18
45
  - keep-alive
19
- Content-Type:
46
+ Content-Length:
47
+ - '17'
48
+ Content-Type:
20
49
  - application/json; charset=utf-8
21
- Content-Length:
22
- - "17"
23
- Cache-Control:
50
+ Cache-Control:
24
51
  - no-cache
25
- body:
26
- string: "{ \"os\": \"linux\" }"
52
+ body:
53
+ encoding: US-ASCII
54
+ string: ! '{ "os": "linux" }'
27
55
  http_version:
28
- recorded_at: Tue, 04 Jun 2013 19:11:20 GMT
56
+ recorded_at: Wed, 05 Jun 2013 14:41:29 GMT
57
+ recorded_with: VCR 2.5.0
@@ -1,28 +1,58 @@
1
- ---
2
- recorded_with: VCR 2.5.0
3
- http_interactions:
4
- - request:
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://localhost:8888/gui/token.html?output=text
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers: {}
10
+ response:
11
+ status:
12
+ code: 200
13
+ message: OK
14
+ headers:
15
+ Connection:
16
+ - keep-alive
17
+ Content-Length:
18
+ - '121'
19
+ Content-Type:
20
+ - text/html
21
+ Set-Cookie:
22
+ - GUID=5VHKF4UDutvWFb60xkAE; path=/
23
+ Cache-Control:
24
+ - no-cache
25
+ body:
26
+ encoding: US-ASCII
27
+ string: <html><div id='token' style='display:none;'>hyPzlNlTakxYRbFDwMZVRm5dPpjbgMpwrUb3MCh4piy_H5W8E2JUxhlOr1EAAAAA</div></html>
28
+ http_version:
29
+ recorded_at: Wed, 05 Jun 2013 14:41:29 GMT
30
+ - request:
5
31
  method: get
6
- uri: http://localhost:8888/gui/?action=getsettings&output=json&token=grsJ7BMbd6FPJND8DVjjZBZdHKV44iACI83vsaYfENHJYr2peP4GJdU7rlEAAAAA
7
- body:
8
- string: ""
9
- headers:
10
- Cookie:
11
- - GUID=SklJvMPAaAAUrQIQ3W3i
12
- response:
13
- status:
32
+ uri: http://localhost:8888/gui/?action=getsettings&output=json&token=hyPzlNlTakxYRbFDwMZVRm5dPpjbgMpwrUb3MCh4piy_H5W8E2JUxhlOr1EAAAAA
33
+ body:
34
+ encoding: US-ASCII
35
+ string: ''
36
+ headers:
37
+ Cookie:
38
+ - GUID=5VHKF4UDutvWFb60xkAE
39
+ response:
40
+ status:
14
41
  code: 200
15
42
  message: OK
16
- headers:
17
- Connection:
43
+ headers:
44
+ Connection:
18
45
  - keep-alive
19
- Content-Type:
46
+ Content-Length:
47
+ - '119'
48
+ Content-Type:
20
49
  - application/json; charset=utf-8
21
- Content-Length:
22
- - "119"
23
- Cache-Control:
50
+ Cache-Control:
24
51
  - no-cache
25
- body:
26
- string: "{ \"settings\": { \"devicename\": \"IceyEC-Virtual1\", \"dlrate\": 0, \"listeningport\": 63754, \"portmapping\": 1, \"ulrate\": 0 } }"
52
+ body:
53
+ encoding: US-ASCII
54
+ string: ! '{ "settings": { "devicename": "IceyEC-Virtual1", "dlrate": 0, "listeningport":
55
+ 63754, "portmapping": 1, "ulrate": 0 } }'
27
56
  http_version:
28
- recorded_at: Tue, 04 Jun 2013 19:11:20 GMT
57
+ recorded_at: Wed, 05 Jun 2013 14:41:29 GMT
58
+ recorded_with: VCR 2.5.0
@@ -1,28 +1,57 @@
1
- ---
2
- recorded_with: VCR 2.5.0
3
- http_interactions:
4
- - request:
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://localhost:8888/gui/token.html?output=text
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers: {}
10
+ response:
11
+ status:
12
+ code: 200
13
+ message: OK
14
+ headers:
15
+ Connection:
16
+ - keep-alive
17
+ Content-Length:
18
+ - '121'
19
+ Content-Type:
20
+ - text/html
21
+ Set-Cookie:
22
+ - GUID=GoXJLgGXVpf8y8SEot2L; path=/
23
+ Cache-Control:
24
+ - no-cache
25
+ body:
26
+ encoding: US-ASCII
27
+ string: <html><div id='token' style='display:none;'>-afkqn0LVJ2YA6qsCgzbECZCMaC0c_tZzY7E24t3veFaMQYcSP0ncBlOr1EAAAAA</div></html>
28
+ http_version:
29
+ recorded_at: Wed, 05 Jun 2013 14:41:29 GMT
30
+ - request:
5
31
  method: get
6
- uri: http://localhost:8888/gui/?action=getversion&output=json&token=grsJ7BMbd6FPJND8DVjjZBZdHKV44iACI83vsaYfENHJYr2peP4GJdU7rlEAAAAA
7
- body:
8
- string: ""
9
- headers:
10
- Cookie:
11
- - GUID=SklJvMPAaAAUrQIQ3W3i
12
- response:
13
- status:
32
+ uri: http://localhost:8888/gui/?action=getversion&output=json&token=-afkqn0LVJ2YA6qsCgzbECZCMaC0c_tZzY7E24t3veFaMQYcSP0ncBlOr1EAAAAA
33
+ body:
34
+ encoding: US-ASCII
35
+ string: ''
36
+ headers:
37
+ Cookie:
38
+ - GUID=GoXJLgGXVpf8y8SEot2L
39
+ response:
40
+ status:
14
41
  code: 200
15
42
  message: OK
16
- headers:
17
- Connection:
43
+ headers:
44
+ Connection:
18
45
  - keep-alive
19
- Content-Type:
46
+ Content-Length:
47
+ - '23'
48
+ Content-Type:
20
49
  - application/json; charset=utf-8
21
- Content-Length:
22
- - "23"
23
- Cache-Control:
50
+ Cache-Control:
24
51
  - no-cache
25
- body:
26
- string: "{ \"version\": 16777350 }"
52
+ body:
53
+ encoding: US-ASCII
54
+ string: ! '{ "version": 16777350 }'
27
55
  http_version:
28
- recorded_at: Tue, 04 Jun 2013 19:11:20 GMT
56
+ recorded_at: Wed, 05 Jun 2013 14:41:29 GMT
57
+ recorded_with: VCR 2.5.0
@@ -0,0 +1,32 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://localhost:8888/gui/?action=getsyncfolders&output=json&token=7P1iDM-j30_D4KpN4veMfy1O12KRXyAdIaSU2A1JsesOOPcU7IJwtBlOr1EAAAAA
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Cookie:
11
+ - GUID=QCUnp9BcpaVLftYoQ2ZB
12
+ response:
13
+ status:
14
+ code: 200
15
+ message: OK
16
+ headers:
17
+ Connection:
18
+ - keep-alive
19
+ Content-Length:
20
+ - '186'
21
+ Content-Type:
22
+ - application/json; charset=utf-8
23
+ Cache-Control:
24
+ - no-cache
25
+ body:
26
+ encoding: US-ASCII
27
+ string: ! '{ "folders": [ { "name": "\/home\/chris\/Documents", "peers": [ ],
28
+ "secret": "6VX7XSMS5R2CSDKLXBENUZIENMVUONRT", "size": "21 B in 1 files" }
29
+ ], "speed": "0.0 kB\/s up, 0.0 kB\/s down" }'
30
+ http_version:
31
+ recorded_at: Wed, 05 Jun 2013 14:41:29 GMT
32
+ recorded_with: VCR 2.5.0
@@ -0,0 +1,60 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://localhost:8888/gui/?action=getsyncfolders&output=json&token=7P1iDM-j30_D4KpN4veMfy1O12KRXyAdIaSU2A1JsesOOPcU7IJwtBlOr1EAAAAA
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Cookie:
11
+ - GUID=QCUnp9BcpaVLftYoQ2ZB
12
+ response:
13
+ status:
14
+ code: 200
15
+ message: OK
16
+ headers:
17
+ Connection:
18
+ - keep-alive
19
+ Content-Length:
20
+ - '311'
21
+ Content-Type:
22
+ - application/json; charset=utf-8
23
+ Cache-Control:
24
+ - no-cache
25
+ body:
26
+ encoding: US-ASCII
27
+ string: ! '{ "folders": [ { "name": "\/home\/chris\/Documents", "peers": [ ],
28
+ "secret": "6VX7XSMS5R2CSDKLXBENUZIENMVUONRT", "size": "21 B in 1 files" },
29
+ { "name": "\/home\/chris\/bt_test", "peers": [ ], "secret": "EV63ZJO7DX25LMMRDDQWDDQ3XZ4ETJV5",
30
+ "size": "0 B in 0 files" } ], "speed": "0.0 kB\/s up, 0.0 kB\/s down" }'
31
+ http_version:
32
+ recorded_at: Wed, 05 Jun 2013 14:41:29 GMT
33
+ - request:
34
+ method: get
35
+ uri: http://localhost:8888/gui/?action=removefolder&name=/home/chris/bt_test&output=json&secret=EV63ZJO7DX25LMMRDDQWDDQ3XZ4ETJV5&token=7P1iDM-j30_D4KpN4veMfy1O12KRXyAdIaSU2A1JsesOOPcU7IJwtBlOr1EAAAAA
36
+ body:
37
+ encoding: US-ASCII
38
+ string: ''
39
+ headers:
40
+ Cookie:
41
+ - GUID=QCUnp9BcpaVLftYoQ2ZB
42
+ response:
43
+ status:
44
+ code: 200
45
+ message: OK
46
+ headers:
47
+ Connection:
48
+ - keep-alive
49
+ Content-Length:
50
+ - '4'
51
+ Content-Type:
52
+ - application/json; charset=utf-8
53
+ Cache-Control:
54
+ - no-cache
55
+ body:
56
+ encoding: US-ASCII
57
+ string: ! '{ }'
58
+ http_version:
59
+ recorded_at: Wed, 05 Jun 2013 14:41:29 GMT
60
+ recorded_with: VCR 2.5.0
metadata CHANGED
@@ -1,79 +1,107 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: BtSync
3
- version: !ruby/object:Gem::Version
4
- version: 0.1.2
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.1
5
5
  platform: ruby
6
- authors:
6
+ authors:
7
7
  - Chris MacNaughton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
-
12
- date: 2013-06-05 00:00:00 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
11
+ date: 2013-06-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
15
14
  name: bundler
16
- prerelease: false
17
- requirement: &id001 !ruby/object:Gem::Requirement
18
- requirements:
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
19
17
  - - ~>
20
- - !ruby/object:Gem::Version
21
- version: "1.3"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
22
20
  type: :development
23
- version_requirements: *id001
24
- - !ruby/object:Gem::Dependency
25
- name: rake
26
21
  prerelease: false
27
- requirement: &id002 !ruby/object:Gem::Requirement
28
- requirements:
29
- - &id003
30
- - ">="
31
- - !ruby/object:Gem::Version
32
- version: "0"
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
33
34
  type: :development
34
- version_requirements: *id002
35
- - !ruby/object:Gem::Dependency
36
- name: rspec
37
35
  prerelease: false
38
- requirement: &id004 !ruby/object:Gem::Requirement
39
- requirements:
40
- - *id003
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
41
48
  type: :development
42
- version_requirements: *id004
43
- - !ruby/object:Gem::Dependency
44
- name: webmock
45
49
  prerelease: false
46
- requirement: &id005 !ruby/object:Gem::Requirement
47
- requirements:
48
- - *id003
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: webmock
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
49
62
  type: :development
50
- version_requirements: *id005
51
- - !ruby/object:Gem::Dependency
52
- name: vcr
53
63
  prerelease: false
54
- requirement: &id006 !ruby/object:Gem::Requirement
55
- requirements:
56
- - *id003
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: vcr
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ! '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
57
76
  type: :development
58
- version_requirements: *id006
59
- - !ruby/object:Gem::Dependency
60
- name: httparty
61
77
  prerelease: false
62
- requirement: &id007 !ruby/object:Gem::Requirement
63
- requirements:
64
- - *id003
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: httparty
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ! '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
65
90
  type: :runtime
66
- version_requirements: *id007
67
- description: Class to interact with BTSync's web interface using their unofficial API
68
- email:
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ! '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: Class to interact with BTSync's web interface using their unofficial
98
+ API
99
+ email:
69
100
  - chmacnaughton@gmail.com
70
101
  executables: []
71
-
72
102
  extensions: []
73
-
74
103
  extra_rdoc_files: []
75
-
76
- files:
104
+ files:
77
105
  - .gitignore
78
106
  - .ruby-gemset
79
107
  - .ruby-version
@@ -85,40 +113,47 @@ files:
85
113
  - lib/btsync.rb
86
114
  - lib/btsync/version.rb
87
115
  - spec/BtSync/bt_sync_spec.rb
88
- - spec/fixtures/cassettes/Setup-BtSync.yml
116
+ - spec/fixtures/cassettes/add-folder-list.yml
117
+ - spec/fixtures/cassettes/add-folder.yml
89
118
  - spec/fixtures/cassettes/get-folders.yml
90
119
  - spec/fixtures/cassettes/get-os-type.yml
91
120
  - spec/fixtures/cassettes/get-settings.yml
92
121
  - spec/fixtures/cassettes/get-version.yml
122
+ - spec/fixtures/cassettes/remove-folder-list.yml
123
+ - spec/fixtures/cassettes/remove-folder.yml
93
124
  - spec/spec_helper.rb
94
125
  homepage: http://chrismacnaughton.com/projects#btsync
95
- licenses:
126
+ licenses:
96
127
  - MIT
97
128
  metadata: {}
98
-
99
129
  post_install_message:
100
130
  rdoc_options: []
101
-
102
- require_paths:
131
+ require_paths:
103
132
  - lib
104
- required_ruby_version: !ruby/object:Gem::Requirement
105
- requirements:
106
- - *id003
107
- required_rubygems_version: !ruby/object:Gem::Requirement
108
- requirements:
109
- - *id003
133
+ required_ruby_version: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - ! '>='
136
+ - !ruby/object:Gem::Version
137
+ version: '0'
138
+ required_rubygems_version: !ruby/object:Gem::Requirement
139
+ requirements:
140
+ - - ! '>='
141
+ - !ruby/object:Gem::Version
142
+ version: '0'
110
143
  requirements: []
111
-
112
144
  rubyforge_project:
113
145
  rubygems_version: 2.0.3
114
146
  signing_key:
115
147
  specification_version: 4
116
148
  summary: Class to interact with BTSync's web interface
117
- test_files:
149
+ test_files:
118
150
  - spec/BtSync/bt_sync_spec.rb
119
- - spec/fixtures/cassettes/Setup-BtSync.yml
151
+ - spec/fixtures/cassettes/add-folder-list.yml
152
+ - spec/fixtures/cassettes/add-folder.yml
120
153
  - spec/fixtures/cassettes/get-folders.yml
121
154
  - spec/fixtures/cassettes/get-os-type.yml
122
155
  - spec/fixtures/cassettes/get-settings.yml
123
156
  - spec/fixtures/cassettes/get-version.yml
157
+ - spec/fixtures/cassettes/remove-folder-list.yml
158
+ - spec/fixtures/cassettes/remove-folder.yml
124
159
  - spec/spec_helper.rb
@@ -1,29 +0,0 @@
1
- ---
2
- recorded_with: VCR 2.5.0
3
- http_interactions:
4
- - request:
5
- method: get
6
- uri: http://localhost:8888/gui/token.html
7
- body:
8
- string: ""
9
- headers: {}
10
-
11
- response:
12
- status:
13
- code: 200
14
- message: OK
15
- headers:
16
- Set-Cookie:
17
- - GUID=SklJvMPAaAAUrQIQ3W3i; path=/
18
- Connection:
19
- - keep-alive
20
- Content-Type:
21
- - text/html
22
- Content-Length:
23
- - "121"
24
- Cache-Control:
25
- - no-cache
26
- body:
27
- string: <html><div id='token' style='display:none;'>grsJ7BMbd6FPJND8DVjjZBZdHKV44iACI83vsaYfENHJYr2peP4GJdU7rlEAAAAA</div></html>
28
- http_version:
29
- recorded_at: Tue, 04 Jun 2013 19:11:20 GMT