BtSync 0.5.1 → 0.5.3
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 +8 -8
- data/.gitignore +1 -0
- data/.travis.yml +1 -0
- data/Vagrantfile +31 -0
- data/cookbooks/apt/.gitignore +14 -0
- data/cookbooks/apt/.kitchen.yml +38 -0
- data/cookbooks/apt/Berksfile +8 -0
- data/cookbooks/apt/CHANGELOG.md +97 -0
- data/cookbooks/apt/CONTRIBUTING +29 -0
- data/cookbooks/apt/LICENSE +201 -0
- data/cookbooks/apt/README.md +243 -0
- data/cookbooks/apt/TESTING.md +25 -0
- data/cookbooks/apt/attributes/default.rb +4 -0
- data/cookbooks/apt/files/default/apt-proxy-v2.conf +50 -0
- data/cookbooks/apt/metadata.json +1 -0
- data/cookbooks/apt/metadata.rb +30 -0
- data/cookbooks/apt/providers/preference.rb +61 -0
- data/cookbooks/apt/providers/repository.rb +132 -0
- data/cookbooks/apt/recipes/cacher-client.rb +59 -0
- data/cookbooks/apt/recipes/cacher-ng.rb +40 -0
- data/cookbooks/apt/recipes/default.rb +68 -0
- data/cookbooks/apt/resources/preference.rb +30 -0
- data/cookbooks/apt/resources/repository.rb +40 -0
- data/cookbooks/apt/templates/debian-6.0/acng.conf.erb +174 -0
- data/cookbooks/apt/templates/default/01proxy.erb +2 -0
- data/cookbooks/apt/templates/default/acng.conf.erb +276 -0
- data/cookbooks/apt/templates/ubuntu-10.04/acng.conf.erb +270 -0
- data/cookbooks/btsync/README.md +2 -0
- data/cookbooks/btsync/metadata.rb +14 -0
- data/cookbooks/btsync/recipes/default.rb +13 -0
- data/cookbooks/build-essential/.gitignore +4 -0
- data/cookbooks/build-essential/.kitchen.yml +42 -0
- data/cookbooks/build-essential/Berksfile +3 -0
- data/cookbooks/build-essential/CHANGELOG.md +42 -0
- data/cookbooks/build-essential/CONTRIBUTING +29 -0
- data/cookbooks/build-essential/LICENSE +201 -0
- data/cookbooks/build-essential/README.md +139 -0
- data/cookbooks/build-essential/TESTING.md +25 -0
- data/cookbooks/build-essential/attributes/default.rb +33 -0
- data/cookbooks/build-essential/metadata.json +44 -0
- data/cookbooks/build-essential/metadata.rb +16 -0
- data/cookbooks/build-essential/recipes/debian.rb +45 -0
- data/cookbooks/build-essential/recipes/default.rb +24 -0
- data/cookbooks/build-essential/recipes/fedora.rb +36 -0
- data/cookbooks/build-essential/recipes/mac_os_x.rb +40 -0
- data/cookbooks/build-essential/recipes/rhel.rb +43 -0
- data/cookbooks/build-essential/recipes/smartos.rb +36 -0
- data/cookbooks/build-essential/recipes/solaris2.rb +42 -0
- data/cookbooks/build-essential/recipes/suse.rb +36 -0
- data/lib/btsync.rb +13 -13
- data/lib/btsync/communicator.rb +14 -4
- data/lib/btsync/directory.rb +12 -12
- data/lib/btsync/version.rb +1 -1
- data/spec/BtSync/bt_sync_spec.rb +13 -9
- data/spec/BtSync/directory_spec.rb +13 -20
- data/spec/fixtures/cassettes/{get-known-hosts.yml → Remove-Default-Host.yml} +5 -5
- data/spec/fixtures/cassettes/Setup-BtSync-Directory.yml +289 -12
- data/spec/fixtures/cassettes/Setup-BtSync.yml +252 -0
- data/spec/fixtures/cassettes/Setup-Directory-Settings.yml +8 -38
- data/spec/fixtures/cassettes/add-folder-list.yml +32 -35
- data/spec/fixtures/cassettes/add-folder.yml +10 -94
- data/spec/fixtures/cassettes/add-known-host.yml +6 -6
- data/spec/fixtures/cassettes/change_download_limit.yml +15 -42
- data/spec/fixtures/cassettes/change_listening_port.yml +15 -42
- data/spec/fixtures/cassettes/change_name.yml +13 -40
- data/spec/fixtures/cassettes/change_upload_limit.yml +15 -42
- data/spec/fixtures/cassettes/get-folders.yml +54 -24
- data/spec/fixtures/cassettes/get-os-type.yml +3 -30
- data/spec/fixtures/cassettes/get-peers.yml +7 -8
- data/spec/fixtures/cassettes/get-preferences.yml +24 -24
- data/spec/fixtures/cassettes/get-settings.yml +6 -33
- data/spec/fixtures/cassettes/get-version.yml +3 -30
- data/spec/fixtures/cassettes/remove-folder-list.yml +18 -20
- data/spec/fixtures/cassettes/remove-folder.yml +35 -38
- data/spec/fixtures/cassettes/remove-known-host.yml +6 -6
- data/spec/fixtures/cassettes/reset_device_name.yml +13 -13
- data/spec/fixtures/cassettes/reset_download_limit.yml +15 -15
- data/spec/fixtures/cassettes/reset_listening_port.yml +15 -15
- data/spec/fixtures/cassettes/reset_upload_limit.yml +15 -15
- data/spec/fixtures/cassettes/set-preferences-delete.yml +11 -11
- data/spec/fixtures/cassettes/set-preferences-dht.yml +11 -11
- data/spec/fixtures/cassettes/set-preferences-hosts.yml +11 -11
- data/spec/fixtures/cassettes/set-preferences-lan.yml +11 -11
- data/spec/fixtures/cassettes/set-preferences-relay.yml +11 -11
- data/spec/fixtures/cassettes/set-preferences-tracker.yml +11 -11
- data/spec/fixtures/cassettes/view-folders.yml +5 -5
- metadata +52 -4
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Cookbook Name:: build-essential
|
|
3
|
+
# Recipe:: smartos
|
|
4
|
+
#
|
|
5
|
+
# Copyright 2008-2013, Opscode, Inc.
|
|
6
|
+
#
|
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
# you may not use this file except in compliance with the License.
|
|
9
|
+
# You may obtain a copy of the License at
|
|
10
|
+
#
|
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
#
|
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
# See the License for the specific language governing permissions and
|
|
17
|
+
# limitations under the License.
|
|
18
|
+
#
|
|
19
|
+
|
|
20
|
+
include_recipe 'pkgin'
|
|
21
|
+
|
|
22
|
+
%w{
|
|
23
|
+
gcc47
|
|
24
|
+
gcc47-runtime
|
|
25
|
+
scmgit-base
|
|
26
|
+
gmake
|
|
27
|
+
pkg-config
|
|
28
|
+
binutils
|
|
29
|
+
}.each do |pkg|
|
|
30
|
+
|
|
31
|
+
r = pkgin_package pkg do
|
|
32
|
+
action( node['build_essential']['compiletime'] ? :nothing : :install )
|
|
33
|
+
end
|
|
34
|
+
r.run_action(:install) if node['build_essential']['compiletime']
|
|
35
|
+
|
|
36
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Cookbook Name:: build-essential
|
|
3
|
+
# Recipe:: solaris2
|
|
4
|
+
#
|
|
5
|
+
# Copyright 2013, Opscode, Inc.
|
|
6
|
+
#
|
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
# you may not use this file except in compliance with the License.
|
|
9
|
+
# You may obtain a copy of the License at
|
|
10
|
+
#
|
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
#
|
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
# See the License for the specific language governing permissions and
|
|
17
|
+
# limitations under the License.
|
|
18
|
+
#
|
|
19
|
+
|
|
20
|
+
%w{
|
|
21
|
+
autoconf
|
|
22
|
+
automake
|
|
23
|
+
bison
|
|
24
|
+
coreutils
|
|
25
|
+
flex
|
|
26
|
+
gcc4core
|
|
27
|
+
gcc4g++
|
|
28
|
+
gcc4objc
|
|
29
|
+
gcc3core
|
|
30
|
+
gcc3g++
|
|
31
|
+
ggrep
|
|
32
|
+
gmake
|
|
33
|
+
gtar
|
|
34
|
+
pkgconfig
|
|
35
|
+
}.each do |pkg|
|
|
36
|
+
|
|
37
|
+
r = pkgutil_package pkg do
|
|
38
|
+
action( node['build_essential']['compiletime'] ? :nothing : :install )
|
|
39
|
+
end
|
|
40
|
+
r.run_action(:install) if node['build_essential']['compiletime']
|
|
41
|
+
|
|
42
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Cookbook Name:: build-essential
|
|
3
|
+
# Recipe:: suse
|
|
4
|
+
#
|
|
5
|
+
# Copyright 2008-2013, Opscode, Inc.
|
|
6
|
+
#
|
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
# you may not use this file except in compliance with the License.
|
|
9
|
+
# You may obtain a copy of the License at
|
|
10
|
+
#
|
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
#
|
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
# See the License for the specific language governing permissions and
|
|
17
|
+
# limitations under the License.
|
|
18
|
+
#
|
|
19
|
+
|
|
20
|
+
%w{
|
|
21
|
+
autoconf
|
|
22
|
+
bison
|
|
23
|
+
flex
|
|
24
|
+
gcc
|
|
25
|
+
gcc-c++
|
|
26
|
+
kernel-default-devel
|
|
27
|
+
make
|
|
28
|
+
m4
|
|
29
|
+
}.each do |pkg|
|
|
30
|
+
|
|
31
|
+
r = package pkg do
|
|
32
|
+
action( node['build_essential']['compiletime'] ? :nothing : :install )
|
|
33
|
+
end
|
|
34
|
+
r.run_action(:install) if node['build_essential']['compiletime']
|
|
35
|
+
|
|
36
|
+
end
|
data/lib/btsync.rb
CHANGED
|
@@ -14,8 +14,8 @@ class BtSync
|
|
|
14
14
|
:protocol => "http",
|
|
15
15
|
:uri => "localhost",
|
|
16
16
|
:port => "8888",
|
|
17
|
-
:user => "",
|
|
18
|
-
:password => ""}
|
|
17
|
+
:user => "admin",
|
|
18
|
+
:password => "AdminPassword"}
|
|
19
19
|
@opts.merge!(options.symbolize)
|
|
20
20
|
@opts[:uri].gsub!(/^(https?:\/\/){1,}/i, '')
|
|
21
21
|
@port = @opts[:port]
|
|
@@ -64,7 +64,7 @@ class BtSync
|
|
|
64
64
|
def change_setting type, opt
|
|
65
65
|
options = get_settings.merge!({type => opt})
|
|
66
66
|
|
|
67
|
-
res =
|
|
67
|
+
res = get(path('setsettings'), :query => options)
|
|
68
68
|
end
|
|
69
69
|
def get_speed
|
|
70
70
|
s = get_folder_list["speed"].split(", ")
|
|
@@ -74,12 +74,12 @@ class BtSync
|
|
|
74
74
|
end
|
|
75
75
|
def remove_folder folder_name, my_secret = nil
|
|
76
76
|
my_secret ||= secret(folder_name)
|
|
77
|
-
res =
|
|
77
|
+
res = get(path('removefolder'), :query => { :name => folder_name, :secret => my_secret})
|
|
78
78
|
true
|
|
79
79
|
end
|
|
80
80
|
def add_folder folder_name, my_secret = nil
|
|
81
81
|
my_secret ||= generate_secret
|
|
82
|
-
res =
|
|
82
|
+
res = get(path('addsyncfolder'), :query => { :name => folder_name, :secret => my_secret})
|
|
83
83
|
unless res["error"] == 0
|
|
84
84
|
@errors << res["message"]
|
|
85
85
|
return false
|
|
@@ -88,25 +88,25 @@ class BtSync
|
|
|
88
88
|
end
|
|
89
89
|
|
|
90
90
|
def get_settings
|
|
91
|
-
res =
|
|
91
|
+
res = get(path('getsettings'))
|
|
92
92
|
res.parsed_response["settings"]
|
|
93
93
|
end
|
|
94
94
|
def get_os_type
|
|
95
|
-
res =
|
|
95
|
+
res = get(path('getostype'))
|
|
96
96
|
res.parsed_response["os"]
|
|
97
97
|
end
|
|
98
98
|
def get_version
|
|
99
|
-
res =
|
|
99
|
+
res = get(path('getversion'))
|
|
100
100
|
res.parsed_response["version"]
|
|
101
101
|
end
|
|
102
102
|
def check_new_version
|
|
103
|
-
res =
|
|
103
|
+
res = get(path('checknewversion'))
|
|
104
104
|
res.parsed_response["version"]
|
|
105
105
|
end
|
|
106
106
|
|
|
107
|
-
def get_dir with_dir
|
|
108
|
-
res =
|
|
109
|
-
res.parsed_response["folders"]
|
|
107
|
+
def get_dir with_dir = "/"
|
|
108
|
+
res = get(path('getdir'), :query => {"dir" => with_dir})
|
|
109
|
+
res.parsed_response["folders"].map{|f| f.gsub!('//', '/')}
|
|
110
110
|
end
|
|
111
111
|
|
|
112
112
|
def secret with_dir
|
|
@@ -116,7 +116,7 @@ class BtSync
|
|
|
116
116
|
private
|
|
117
117
|
|
|
118
118
|
def get_folder_list
|
|
119
|
-
res =
|
|
119
|
+
res = get(path('getsyncfolders'))
|
|
120
120
|
@folder_list = res.parsed_response
|
|
121
121
|
end
|
|
122
122
|
end
|
data/lib/btsync/communicator.rb
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
module BtCommunicator
|
|
2
2
|
include HTTParty
|
|
3
|
-
|
|
3
|
+
disable_rails_query_string_format
|
|
4
|
+
default_params :output => 'json'
|
|
4
5
|
def generate_secret
|
|
5
|
-
res =
|
|
6
|
+
res = get(path('generatesecret'))
|
|
6
7
|
res.parsed_response["secret"]
|
|
7
8
|
end
|
|
8
9
|
def port
|
|
@@ -23,6 +24,9 @@ module BtCommunicator
|
|
|
23
24
|
def communication_options
|
|
24
25
|
@opts
|
|
25
26
|
end
|
|
27
|
+
def auth
|
|
28
|
+
{:username => user, :password => password}
|
|
29
|
+
end
|
|
26
30
|
def token force = false
|
|
27
31
|
@token_cache ||= 0
|
|
28
32
|
time = DateTime.now.strftime("%s").to_i
|
|
@@ -39,18 +43,24 @@ module BtCommunicator
|
|
|
39
43
|
def root_url
|
|
40
44
|
"#{starter}#{uri}:#{port}/"
|
|
41
45
|
end
|
|
46
|
+
|
|
47
|
+
def get path, opts = {}
|
|
48
|
+
opts = {:headers=>{"Cookie" => cookies}, :query => {}, :basic_auth => auth}.merge(opts)
|
|
49
|
+
self.class.get(path, opts)
|
|
50
|
+
end
|
|
51
|
+
|
|
42
52
|
def request_token force = false
|
|
43
53
|
@last_request ||= 0
|
|
44
54
|
t = DateTime.now.strftime('%s').to_i
|
|
45
55
|
if @request_token.nil? || force || (@last_request + 600) < t
|
|
46
56
|
@last_request = t
|
|
47
|
-
@request_token = self.class.get("#{root_url}gui/token.html", :
|
|
57
|
+
@request_token = self.class.get("#{root_url}gui/token.html", :basic_auth => auth)
|
|
48
58
|
else
|
|
49
59
|
@request_token
|
|
50
60
|
end
|
|
51
61
|
end
|
|
52
62
|
def starter
|
|
53
|
-
"#{protocol}
|
|
63
|
+
"#{protocol}://"
|
|
54
64
|
end
|
|
55
65
|
def path action_name
|
|
56
66
|
"#{root_url}gui/?token=#{token}&action=#{action_name}"
|
data/lib/btsync/directory.rb
CHANGED
|
@@ -17,12 +17,12 @@ class BtSync
|
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
def destroy
|
|
20
|
-
|
|
20
|
+
get(path('removefolder'), :query => { :name => name, :secret => secret} )
|
|
21
21
|
self.instance_variables.each{|v| v = nil}
|
|
22
22
|
end
|
|
23
23
|
def update_secret new_secret = nil
|
|
24
24
|
new_secret ||= generate_secret
|
|
25
|
-
res =
|
|
25
|
+
res = get(path('updatesecret'), :query => { :name => @name, :secret => @secret, :newsecret => new_secret} )
|
|
26
26
|
if res.parsed_response != "{}" && res.parsed_response != '\r\ninvalid request'
|
|
27
27
|
@secret = new_secret
|
|
28
28
|
true
|
|
@@ -32,26 +32,26 @@ class BtSync
|
|
|
32
32
|
end
|
|
33
33
|
end
|
|
34
34
|
def folders
|
|
35
|
-
res =
|
|
35
|
+
res = get(path('getdir'), :query => {:dir => @name})
|
|
36
36
|
res.parsed_response["folders"]
|
|
37
37
|
end
|
|
38
38
|
def peers
|
|
39
|
-
res =
|
|
39
|
+
res = get(path('getsyncfolders') )
|
|
40
40
|
f = res.parsed_response["folders"].select{|f| f["name"] == name}.first
|
|
41
41
|
f["peers"]
|
|
42
42
|
end
|
|
43
43
|
def known_hosts
|
|
44
|
-
res =
|
|
44
|
+
res = get(path('getknownhosts'), :query => {:name => name, :secret => secret})
|
|
45
45
|
hosts = {}
|
|
46
46
|
res["hosts"].map{|h| hosts[h["index"]] = h["peer"]}
|
|
47
47
|
hosts
|
|
48
48
|
end
|
|
49
49
|
def add_host host, port
|
|
50
|
-
res =
|
|
50
|
+
res = get(path('addknownhosts'), :query =>{:name => name, :secret => secret, :addr =>host, :port => port} )
|
|
51
51
|
true
|
|
52
52
|
end
|
|
53
53
|
def remove_host index
|
|
54
|
-
res =
|
|
54
|
+
res = get(path('removeknownhosts'), :query =>{:name => name, :secret => secret, :index => index} )
|
|
55
55
|
if res.parsed_response != {}
|
|
56
56
|
res.parsed_response
|
|
57
57
|
else
|
|
@@ -101,7 +101,7 @@ class BtSync
|
|
|
101
101
|
bool(preferences["iswritable"])
|
|
102
102
|
end
|
|
103
103
|
def preferences
|
|
104
|
-
res =
|
|
104
|
+
res = get(path('getfolderpref'), :query => { :name => @name, :secret => @secret})
|
|
105
105
|
res.parsed_response["folderpref"]
|
|
106
106
|
end
|
|
107
107
|
def read_only_secret
|
|
@@ -109,7 +109,7 @@ class BtSync
|
|
|
109
109
|
end
|
|
110
110
|
private
|
|
111
111
|
def set_pref pref, opt
|
|
112
|
-
res =
|
|
112
|
+
res = get(path('setfolderpref'), :query => make_opts(pref, opt) )
|
|
113
113
|
true
|
|
114
114
|
end
|
|
115
115
|
def default_settings
|
|
@@ -123,7 +123,7 @@ class BtSync
|
|
|
123
123
|
'deletetotrash' => 1,
|
|
124
124
|
'usehosts' => 1
|
|
125
125
|
}
|
|
126
|
-
|
|
126
|
+
get(path('setfolderpref'), :query => opts )
|
|
127
127
|
end
|
|
128
128
|
def make_opts name, opt
|
|
129
129
|
opts = preferences
|
|
@@ -148,12 +148,12 @@ class BtSync
|
|
|
148
148
|
end
|
|
149
149
|
end
|
|
150
150
|
def find_or_create
|
|
151
|
-
res =
|
|
151
|
+
res = get(path('getsyncfolders'))
|
|
152
152
|
folder_list = res.parsed_response["folders"]
|
|
153
153
|
if folder_list.map{|f| f["name"]}.include? name
|
|
154
154
|
true
|
|
155
155
|
else
|
|
156
|
-
res =
|
|
156
|
+
res = get(path('addsyncfolder'), :query => { :name => name, :secret => secret})
|
|
157
157
|
end
|
|
158
158
|
end
|
|
159
159
|
end
|
data/lib/btsync/version.rb
CHANGED
data/spec/BtSync/bt_sync_spec.rb
CHANGED
|
@@ -4,6 +4,10 @@ describe 'BtSync' do
|
|
|
4
4
|
before(:each) do
|
|
5
5
|
VCR.use_cassette("Setup-BtSync") do
|
|
6
6
|
@bt = BtSync.new
|
|
7
|
+
@bt.add_folder '/home/vagrant'
|
|
8
|
+
@bt.listening_port = 63754
|
|
9
|
+
@bt.upload_limit = 0
|
|
10
|
+
@bt.device_name = "precise32 - Default Instance"
|
|
7
11
|
end
|
|
8
12
|
end
|
|
9
13
|
|
|
@@ -11,13 +15,13 @@ describe 'BtSync' do
|
|
|
11
15
|
VCR.use_cassette("get-folders") do
|
|
12
16
|
@folder = @bt.folders.first
|
|
13
17
|
end
|
|
14
|
-
@folder.name.should == "/home/
|
|
18
|
+
@folder.name.should == "/home/vagrant"
|
|
15
19
|
end
|
|
16
20
|
it "can view settings" do
|
|
17
21
|
VCR.use_cassette("get-settings") do
|
|
18
22
|
@settings = @bt.get_settings
|
|
19
23
|
end
|
|
20
|
-
@settings["devicename"].should == "
|
|
24
|
+
@settings["devicename"].should == "precise32 - Default Instance"
|
|
21
25
|
@settings["listeningport"].should == 63754
|
|
22
26
|
end
|
|
23
27
|
it "can get listening port" do
|
|
@@ -37,7 +41,7 @@ describe 'BtSync' do
|
|
|
37
41
|
end
|
|
38
42
|
it "can get device name" do
|
|
39
43
|
VCR.use_cassette("get-settings") do
|
|
40
|
-
@bt.device_name.should == "
|
|
44
|
+
@bt.device_name.should == "precise32 - Default Instance"
|
|
41
45
|
end
|
|
42
46
|
end
|
|
43
47
|
it "can change the device_name" do
|
|
@@ -46,8 +50,8 @@ describe 'BtSync' do
|
|
|
46
50
|
@bt.device_name.should == "IceyEC-Virtual2"
|
|
47
51
|
end
|
|
48
52
|
VCR.use_cassette('reset_device_name') do
|
|
49
|
-
@bt.device_name = "
|
|
50
|
-
@bt.device_name.should == "
|
|
53
|
+
@bt.device_name = "precise32 - Default Instance"
|
|
54
|
+
@bt.device_name.should == "precise32 - Default Instance"
|
|
51
55
|
end
|
|
52
56
|
end
|
|
53
57
|
it "can change the upload limit" do
|
|
@@ -94,22 +98,22 @@ describe 'BtSync' do
|
|
|
94
98
|
end
|
|
95
99
|
it "can add and delete a folder" do
|
|
96
100
|
VCR.use_cassette("add-folder") do
|
|
97
|
-
@bt.add_folder '/
|
|
101
|
+
@bt.add_folder '/tmp'
|
|
98
102
|
end
|
|
99
103
|
VCR.use_cassette("add-folder-list") do
|
|
100
104
|
folders = @bt.folders
|
|
101
105
|
folders.count.should == 2
|
|
102
106
|
folder = folders.last
|
|
103
|
-
folder.name.should == "/
|
|
107
|
+
folder.name.should == "/tmp"
|
|
104
108
|
end
|
|
105
109
|
VCR.use_cassette("remove-folder") do
|
|
106
|
-
@bt.remove_folder '/
|
|
110
|
+
@bt.remove_folder '/tmp'
|
|
107
111
|
end
|
|
108
112
|
VCR.use_cassette("remove-folder-list") do
|
|
109
113
|
folders = @bt.folders
|
|
110
114
|
folders.count.should == 1
|
|
111
115
|
folder = folders.last
|
|
112
|
-
folder.name.should == "/home/
|
|
116
|
+
folder.name.should == "/home/vagrant"
|
|
113
117
|
end
|
|
114
118
|
end
|
|
115
119
|
end
|
|
@@ -4,51 +4,44 @@ describe 'BtSync::Directory' do
|
|
|
4
4
|
before(:each) do
|
|
5
5
|
VCR.use_cassette("Setup-BtSync-Directory") do
|
|
6
6
|
@bt = BtSync.new
|
|
7
|
-
@
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
@bt.add_folder '/home/vagrant'
|
|
8
|
+
@bt.listening_port = 63754
|
|
9
|
+
@bt.upload_limit = 0
|
|
10
|
+
@bt.device_name = "precise32 - Default Instance"
|
|
11
|
+
@directory = @bt.folders.first
|
|
11
12
|
end
|
|
12
13
|
VCR.use_cassette('Setup-Directory-Settings') do
|
|
13
|
-
@bt = BtSync.new
|
|
14
|
-
@directory = BtSync::Directory.new(
|
|
15
|
-
'/home/chris/Documents',
|
|
16
|
-
'6PX74LIR2RA2FF2W3DC25MG2CF6SQDSJ',
|
|
17
|
-
@bt)
|
|
18
14
|
@directory.send('default_settings')
|
|
15
|
+
@directory.add_host('192.168.1.5','45685')
|
|
19
16
|
end
|
|
20
17
|
end
|
|
21
18
|
after(:each) do
|
|
22
19
|
VCR.use_cassette('Setup-Directory-Settings') do
|
|
23
20
|
@directory.send('default_settings')
|
|
24
21
|
end
|
|
22
|
+
VCR.use_cassette('Remove-Default-Host') do
|
|
23
|
+
@directory.remove_host 0
|
|
24
|
+
end
|
|
25
25
|
end
|
|
26
26
|
it "can view contained folders" do
|
|
27
27
|
VCR.use_cassette("view-folders") do
|
|
28
28
|
@folders = @directory.folders
|
|
29
29
|
end
|
|
30
|
-
@folders.
|
|
30
|
+
@folders.should == []
|
|
31
31
|
end
|
|
32
32
|
it "can get a list of peers" do
|
|
33
33
|
VCR.use_cassette("get-peers") do
|
|
34
34
|
@peers = @directory.peers
|
|
35
35
|
end
|
|
36
|
-
@peers.
|
|
36
|
+
@peers.should == []
|
|
37
37
|
end
|
|
38
|
-
it "can
|
|
39
|
-
VCR.use_cassette("get-known-hosts") do
|
|
40
|
-
@hosts = @directory.known_hosts
|
|
41
|
-
end
|
|
42
|
-
@hosts[0].should == "192.168.1.5:45685"
|
|
43
|
-
end
|
|
44
|
-
it "can add a known host" do
|
|
38
|
+
it "can add and remove a known host" do
|
|
45
39
|
VCR.use_cassette('add-known-host') do
|
|
46
40
|
@directory.add_host('10.0.1.254', '12345')
|
|
47
41
|
@hosts = @directory.known_hosts
|
|
48
42
|
end
|
|
49
43
|
@hosts[1].should == "10.0.1.254:12345"
|
|
50
|
-
|
|
51
|
-
it "can remove a known host" do
|
|
44
|
+
|
|
52
45
|
VCR.use_cassette('remove-known-host') do
|
|
53
46
|
@directory.remove_host(1)
|
|
54
47
|
@hosts = @directory.known_hosts
|