doxie 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ae4e4a69165781ebee343cba581f5a735e68ac08
4
- data.tar.gz: 7757f3e1c1a1eeda217bb307e708e9cc4e6e6815
3
+ metadata.gz: 8d39bd2c7b157da537b10cfb0c8ff28bdc522c82
4
+ data.tar.gz: 4bfa90536b4a460b11518a43c1054d2b436f1aa5
5
5
  SHA512:
6
- metadata.gz: 8e5d37700e28d2c523f92966815c5b491ffac320bf0394aad2a8ee094d9d9cd2f2b5366580c624d20a20e335cbc25b537618027849de0912fa44327d4b228cda
7
- data.tar.gz: 546710b03cb98194449ab32780456864f1bdbdb9ef33293a997aa5c1a91e858cb6a01fa7a8980f84b6b25c112e4d66fb65b344904e7cc2d08ca11ea0adc6dda8
6
+ metadata.gz: 8f897990e36093e82150fe6a97186c619a73c1fbec507e191eb29be4f8e2f0a7618f291fbdd6c52d64a565baf9f778bc3e338b1b3c8326b1745fbf9e96a26f29
7
+ data.tar.gz: dcef9dda48bfd608d39678075061961d2d25fdabdd30cfe084b8c618645eb36895b18807d0b95ed22d594f72c0375bbb51eba5ffef8d46a77f1b38442eb713f6
@@ -1,7 +1,7 @@
1
1
 
2
2
  Gem::Specification.new do |s|
3
3
  s.name = 'doxie'
4
- s.version = '0.0.8'
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"]
@@ -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 = URI("https://#{ip}:8080#{path}")
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 nil
79
+ return true
66
80
  when Net::HTTPSuccess
67
81
  if response['Content-Type'].split(';').first == 'application/json'
68
82
  JSON.parse(response.body)
@@ -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(nil)
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)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: doxie
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cristiano Betta