filezor 1.3.2 → 1.3.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.
- data/VERSION +1 -1
- data/filezor.gemspec +2 -2
- data/lib/filezor/client.rb +19 -1
- data/lib/filezor/server.rb +7 -1
- data/spec/filezor/client_spec.rb +3 -3
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.3.
|
1
|
+
1.3.3
|
data/filezor.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{filezor}
|
8
|
-
s.version = "1.3.
|
8
|
+
s.version = "1.3.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Kyle Maxwell"]
|
12
|
-
s.date = %q{2010-09-
|
12
|
+
s.date = %q{2010-09-07}
|
13
13
|
s.default_executable = %q{filezor}
|
14
14
|
s.description = %q{pure ruby file sync}
|
15
15
|
s.email = %q{kyle@kylemaxwell.com}
|
data/lib/filezor/client.rb
CHANGED
@@ -11,9 +11,17 @@ class Filezor::Client
|
|
11
11
|
|
12
12
|
attr_reader :options
|
13
13
|
|
14
|
+
def self.last_exception
|
15
|
+
@e
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.last_exception=(e)
|
19
|
+
@e = e
|
20
|
+
end
|
21
|
+
|
14
22
|
def initialize(host, port, password, options = {})
|
15
23
|
@root = "http://admin:#{password}@#{host}:#{port}"
|
16
|
-
@options ||= options
|
24
|
+
@options ||= stringify_keys(options)
|
17
25
|
@options.update JSON.parse(post("info", options.to_json, "/"))
|
18
26
|
end
|
19
27
|
|
@@ -89,11 +97,17 @@ private
|
|
89
97
|
def _get(*args)
|
90
98
|
puts args.inspect if ENV["FILEZOR_DEBUG"]
|
91
99
|
RestClient.get(*args)
|
100
|
+
rescue => e
|
101
|
+
self.class.last_exception = e
|
102
|
+
raise
|
92
103
|
end
|
93
104
|
|
94
105
|
def _post(*args)
|
95
106
|
puts args.inspect if ENV["FILEZOR_DEBUG"]
|
96
107
|
RestClient.post(*args)
|
108
|
+
rescue => e
|
109
|
+
self.class.last_exception = e
|
110
|
+
raise
|
97
111
|
end
|
98
112
|
|
99
113
|
def test(*files)
|
@@ -103,4 +117,8 @@ private
|
|
103
117
|
end
|
104
118
|
end
|
105
119
|
end
|
120
|
+
|
121
|
+
def stringify_keys(hash)
|
122
|
+
hash.inject({}) {|memo, (k, v)| memo.update k.to_s => v }
|
123
|
+
end
|
106
124
|
end
|
data/lib/filezor/server.rb
CHANGED
@@ -3,6 +3,7 @@ require "cgi"
|
|
3
3
|
require "fileutils"
|
4
4
|
require "json"
|
5
5
|
require "filezor/util"
|
6
|
+
require "logger"
|
6
7
|
class Filezor::Server < Sinatra::Base
|
7
8
|
class BadRequest < RuntimeError; end
|
8
9
|
include FileUtils
|
@@ -19,6 +20,8 @@ class Filezor::Server < Sinatra::Base
|
|
19
20
|
authenticate(username, password)
|
20
21
|
end
|
21
22
|
|
23
|
+
logger = Logger.new(STDERR)
|
24
|
+
|
22
25
|
use Rack::CommonLogger
|
23
26
|
|
24
27
|
get INFO do
|
@@ -37,6 +40,7 @@ class Filezor::Server < Sinatra::Base
|
|
37
40
|
if File.file?(path)
|
38
41
|
File.read(path)
|
39
42
|
else
|
43
|
+
logger.info "Not found: #{path}"
|
40
44
|
404
|
41
45
|
end
|
42
46
|
end
|
@@ -89,7 +93,9 @@ class Filezor::Server < Sinatra::Base
|
|
89
93
|
end
|
90
94
|
end
|
91
95
|
"ok"
|
92
|
-
rescue BadRequest
|
96
|
+
rescue BadRequest => e
|
97
|
+
logger.error e.message
|
98
|
+
logger.error e.backtrace.join("\n")
|
93
99
|
400
|
94
100
|
end
|
95
101
|
end
|
data/spec/filezor/client_spec.rb
CHANGED
@@ -41,8 +41,8 @@ describe Filezor::Client do
|
|
41
41
|
it "should send the md5, not the file" do
|
42
42
|
@file = Filezor::File.new(fixture_file("a.txt"), "b.txt")
|
43
43
|
@client.should_receive(:cached).and_return(["11e561e2cfcd0ac2b4bb0089a665b031"])
|
44
|
-
@client.should_receive(:post).with("", {"--
|
45
|
-
@client.sync("x"
|
44
|
+
@client.should_receive(:post).with("", {"--root" => "x", "b.txt" => "11e561e2cfcd0ac2b4bb0089a665b031" })
|
45
|
+
@client.sync(@file, :root => "x")
|
46
46
|
end
|
47
47
|
end
|
48
48
|
end
|
@@ -76,7 +76,7 @@ describe Filezor::Client do
|
|
76
76
|
@unwanted = "#{@root}/a/b/gone.txt"
|
77
77
|
File.open(@unwanted, "w"){|f| f.puts "hi" }
|
78
78
|
file = Filezor::File.new(fixture_file("a.txt"), "c.txt")
|
79
|
-
@client.sync("a/b",
|
79
|
+
@client.sync(file, :root => "a/b", :delete => "*")
|
80
80
|
end
|
81
81
|
|
82
82
|
it "should upload the files" do
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 1
|
7
7
|
- 3
|
8
|
-
-
|
9
|
-
version: 1.3.
|
8
|
+
- 3
|
9
|
+
version: 1.3.3
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Kyle Maxwell
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-09-
|
17
|
+
date: 2010-09-07 00:00:00 -07:00
|
18
18
|
default_executable: filezor
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|