ambidexter 0.0.2 → 0.0.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 +4 -4
- data/lib/client.rb +2 -2
- data/lib/server.rb +6 -6
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 876bc3378a41d7821607b57beed8df253c2f022d
|
4
|
+
data.tar.gz: 1cbc4cad843fd7005e9d740b412a0517e617334e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6578138dddbb9da7dbaf748519108efb515ded9c6dfa7cef93a20f4ccc2636d273d9c1571c889b0c88dca81b2ae6a102b95a7be46db57121d9a9ad92de2ebfe2
|
7
|
+
data.tar.gz: 51d1c893118fb84052893db44a7394fc38a7c253d0cf98b40be9d2aca7ff5cd302c9b5857f8cce977a044206377da3fe769f975185d24fcb3f3404bcd4036478
|
data/lib/client.rb
CHANGED
@@ -115,7 +115,7 @@ class Client < Application
|
|
115
115
|
t = Time.now
|
116
116
|
response = Curl.get(@uri + file_name)
|
117
117
|
@req_times << Time.now - t
|
118
|
-
file = File.open("
|
118
|
+
file = File.open("#{__dir__}/../files#{file_name}", 'r')
|
119
119
|
if response.body == file.read && response.status == '200 OK'
|
120
120
|
print '.'.green
|
121
121
|
else
|
@@ -127,7 +127,7 @@ class Client < Application
|
|
127
127
|
response = Curl::Easy.new(@uri + '/file')
|
128
128
|
response.multipart_form_post = true
|
129
129
|
t = Time.now
|
130
|
-
response.http_post(Curl::PostField.file('uploaded_image', "
|
130
|
+
response.http_post(Curl::PostField.file('uploaded_image', "#{__dir__}/../files/#{file_name}"))
|
131
131
|
@req_times << Time.now - t
|
132
132
|
if response.status == '200 OK'
|
133
133
|
print '.'.green
|
data/lib/server.rb
CHANGED
@@ -41,11 +41,11 @@ class Server < Application
|
|
41
41
|
def do_POST(request, response)
|
42
42
|
file_data = request.query["uploaded_image"]
|
43
43
|
random_string = SecureRandom.hex(3)
|
44
|
-
f = File.open("tmp/#{random_string}_image.jpeg", "wb")
|
44
|
+
f = File.open("#{__dir__}/../tmp/#{random_string}_image.jpeg", "wb")
|
45
45
|
f.syswrite file_data
|
46
46
|
f.close
|
47
|
-
response.status = FileUtils.compare_file("tmp/#{random_string}_image.jpeg",
|
48
|
-
FileUtils.rm_rf("tmp/#{random_string}_image.jpeg")
|
47
|
+
response.status = FileUtils.compare_file("#{__dir__}/../tmp/#{random_string}_image.jpeg", "#{__dir__}/../files/image.jpeg") ? 200 : 500
|
48
|
+
FileUtils.rm_rf("#{__dir__}/../tmp/#{random_string}_image.jpeg")
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
@@ -53,8 +53,8 @@ class Server < Application
|
|
53
53
|
print "Input Port of servrer: ".green
|
54
54
|
@port = $stdin.gets.chomp
|
55
55
|
@port = '5899' if blank? @port
|
56
|
-
FileUtils.rm_rf(
|
57
|
-
Dir.mkdir(
|
56
|
+
FileUtils.rm_rf("#{__dir__}/../tmp")
|
57
|
+
Dir.mkdir("#{__dir__}/../tmp")
|
58
58
|
end
|
59
59
|
|
60
60
|
def mount
|
@@ -63,7 +63,7 @@ class Server < Application
|
|
63
63
|
@server.mount "/lorem", LoremPath
|
64
64
|
@server.mount "/cookie", CookiePath
|
65
65
|
@server.mount "/file", FilePath
|
66
|
-
@server.mount('/file.txt', WEBrick::HTTPServlet::DefaultFileHandler,
|
66
|
+
@server.mount('/file.txt', WEBrick::HTTPServlet::DefaultFileHandler, "#{__dir__}/../files/file.txt")
|
67
67
|
end
|
68
68
|
|
69
69
|
def start
|