doxie 0.0.8 → 0.0.9
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/doxie.gemspec +1 -1
- data/lib/doxie.rb +16 -2
- data/spec/doxie_spec.rb +9 -1
- 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: 8d39bd2c7b157da537b10cfb0c8ff28bdc522c82
|
4
|
+
data.tar.gz: 4bfa90536b4a460b11518a43c1054d2b436f1aa5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8f897990e36093e82150fe6a97186c619a73c1fbec507e191eb29be4f8e2f0a7618f291fbdd6c52d64a565baf9f778bc3e338b1b3c8326b1745fbf9e96a26f29
|
7
|
+
data.tar.gz: dcef9dda48bfd608d39678075061961d2d25fdabdd30cfe084b8c618645eb36895b18807d0b95ed22d594f72c0375bbb51eba5ffef8d46a77f1b38442eb713f6
|
data/doxie.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
|
2
2
|
Gem::Specification.new do |s|
|
3
3
|
s.name = 'doxie'
|
4
|
-
s.version = '0.0.
|
4
|
+
s.version = '0.0.9'
|
5
5
|
s.summary = "Doxie API Wrapper for getting scans off your Doxie scanner"
|
6
6
|
s.description = "Doxie API Wrapper for getting scans off your Doxie scanner"
|
7
7
|
s.authors = ["Cristiano Betta"]
|
data/lib/doxie.rb
CHANGED
@@ -45,14 +45,28 @@ module Doxie
|
|
45
45
|
file "/thumbnails#{scan_name}", file_name
|
46
46
|
end
|
47
47
|
|
48
|
+
def delete_scan scan_name
|
49
|
+
delete("/scans#{scan_name}")
|
50
|
+
end
|
51
|
+
|
48
52
|
private
|
49
53
|
|
50
54
|
def get path
|
51
|
-
uri =
|
55
|
+
uri = uri_for(path)
|
52
56
|
message = Net::HTTP::Get.new(uri.request_uri)
|
53
57
|
parse(request(uri, message))
|
54
58
|
end
|
55
59
|
|
60
|
+
def delete path
|
61
|
+
uri = uri_for(path)
|
62
|
+
message = Net::HTTP::Delete.new(uri.request_uri)
|
63
|
+
parse(request(uri, message))
|
64
|
+
end
|
65
|
+
|
66
|
+
def uri_for path
|
67
|
+
URI("https://#{ip}:8080#{path}")
|
68
|
+
end
|
69
|
+
|
56
70
|
def request(uri, message)
|
57
71
|
message.basic_auth USERNAME, password if password
|
58
72
|
http = Net::HTTP.new(uri.host, uri.port)
|
@@ -62,7 +76,7 @@ module Doxie
|
|
62
76
|
def parse response
|
63
77
|
case response
|
64
78
|
when Net::HTTPNoContent
|
65
|
-
return
|
79
|
+
return true
|
66
80
|
when Net::HTTPSuccess
|
67
81
|
if response['Content-Type'].split(';').first == 'application/json'
|
68
82
|
JSON.parse(response.body)
|
data/spec/doxie_spec.rb
CHANGED
@@ -36,7 +36,7 @@ describe 'Doxie::Client' do
|
|
36
36
|
it 'should return the result' do
|
37
37
|
stub_request(:get, "#{@base_url}/restart.json")
|
38
38
|
.to_return(status: 204)
|
39
|
-
@client.restart.must_equal(
|
39
|
+
@client.restart.must_equal(true)
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
@@ -84,6 +84,14 @@ describe 'Doxie::Client' do
|
|
84
84
|
end
|
85
85
|
end
|
86
86
|
|
87
|
+
describe 'delete /scans/DOXIE/JPEG/IMG_0001.JPG' do
|
88
|
+
it 'should return the result' do
|
89
|
+
stub_request(:delete, "#{@base_url}/scans/DOXIE/JPEG/IMG_0001.JPG")
|
90
|
+
.to_return(@json_response_body)
|
91
|
+
@client.delete_scan('/DOXIE/JPEG/IMG_0001.JPG').must_equal(@json_response_object)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
87
95
|
it 'raises an authentication error exception if the response code is 401' do
|
88
96
|
stub_request(:get, "#{@base_url}/hello.json")
|
89
97
|
.to_return(status: 401)
|