doxie 3.0.0 → 4.0.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 86ca65be716261fc75507c33432181058e8c567be9e9c8f34e88b884222822be
4
- data.tar.gz: 2686549b36f731522f3f7c11c505f9c57dbb2ff5e1d8cac461b2827d2a535b90
3
+ metadata.gz: 591a978e8945f3c342eac2c122adde1b330f90d417d5e616fd1d8ff00751e8f4
4
+ data.tar.gz: 327f7f0eed33eba5b3c5d6bf17cbbda37026ee76b60a70ecd7d67b02a6bb40df
5
5
  SHA512:
6
- metadata.gz: 87d150d0d5fc9cf79c06e3aa6726d92c3a1eaf83c8208043f4dd512f79f32af37512402a83919a095769ec63ba80722df70f83b225a00eb6ffe32cf60bb3fae7
7
- data.tar.gz: b3b46c8ceb2128959117a7ca2502da83cf77ff3afece80acd563d95f849dd58ba6f42b31bef641770edd6cd80ef23578ab048cbbda5fe521f77c119ba8792f2b
6
+ metadata.gz: 575607ce83d5d093615560dcff55df8ae9b99358dc80a61447ca22bc3c19befcbbd9d9a8cd9c4d0052383b922cfc5dd1c095a6207f09b0fb34e47b8bfc21b14f
7
+ data.tar.gz: 0de1669b05a1d6ab5e707faae735f9da5691e230ef0a7f1517c2a793233a3b06f3b2bf073a4a399c8c56e6f5b5e53ee95561f550f4bfc73bc6a01e5fdfad5ef9
data/README.md CHANGED
@@ -80,7 +80,7 @@ client.hello
80
80
  }
81
81
  ```
82
82
 
83
- * `model`: DX250 for the Doxie Go WiFi.
83
+ * `model`: DX250 for the Doxie Go WiFi, DX255 for the Doxie Go SE, and DX300 for the Doxie Q.
84
84
  * `name`: The name of the scanner, which defaults to the form "Doxie_XXXXXX".
85
85
  The name of a scanner can be changed by using the Doxie desktop app.
86
86
  * `firmwareWiFi`: The Wi-Fi firmware version.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require File.expand_path('lib/doxie/version', File.dirname(__FILE__))
2
4
 
3
5
  Gem::Specification.new do |s|
@@ -13,8 +15,8 @@ Gem::Specification.new do |s|
13
15
  s.license = 'MIT'
14
16
  s.require_path = 'lib'
15
17
 
18
+ s.add_development_dependency('fakefs')
19
+ s.add_development_dependency('minitest')
16
20
  s.add_development_dependency('rake')
17
21
  s.add_development_dependency('webmock')
18
- s.add_development_dependency('minitest')
19
- s.add_development_dependency('fakefs')
20
22
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'doxie/version'
2
4
  require 'doxie/models'
3
5
  require 'doxie/client'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'net/http'
2
4
  require 'json'
3
5
 
@@ -9,7 +11,7 @@ module Doxie
9
11
  class Client
10
12
  class Error < StandardError; end
11
13
 
12
- USERNAME = 'doxie'.freeze
14
+ USERNAME = 'doxie'
13
15
 
14
16
  attr_accessor :ip, :password, :model, :port
15
17
 
@@ -17,7 +19,7 @@ module Doxie
17
19
  @ip = options[:ip] || ''
18
20
  @password = options[:password] || ''
19
21
  @model = options[:model] || Doxie::API_V1
20
- @port = @model == Doxie::API_V1 ? 8080 : 80
22
+ @port = @model == Doxie::API_V1 ? 8080 : 80
21
23
  end
22
24
 
23
25
  def hello
@@ -25,7 +27,10 @@ module Doxie
25
27
  end
26
28
 
27
29
  def hello_extra
28
- raise Error.new('Method does not exist for this model') if model == Doxie::API_V2
30
+ if model == Doxie::API_V2
31
+ raise Doxie::Client::Error, 'Method does not exist for this model'
32
+ end
33
+
29
34
  get('/hello_extra.json')
30
35
  end
31
36
 
@@ -35,11 +40,12 @@ module Doxie
35
40
 
36
41
  def scans
37
42
  get('/scans.json')
38
- rescue Doxie::Client::Error => error
39
- # a 404 is thrown on the Doxie Q and
43
+ rescue Doxie::Client::Error => e
44
+ # a 404 is thrown on the Doxie Q and
40
45
  # Doxie GO SE when there are no scans
41
- raise error if model == Doxie::DX250
42
- []
46
+ raise e if model == Doxie::API_V1
47
+
48
+ []
43
49
  end
44
50
 
45
51
  def recent_scans
@@ -88,7 +94,7 @@ module Doxie
88
94
  end
89
95
 
90
96
  def request(uri, message)
91
- message.basic_auth USERNAME, password if password && password.length > 0
97
+ message.basic_auth USERNAME, password if password && !password.empty?
92
98
  http = Net::HTTP.new(uri.host, uri.port)
93
99
  http.request(message)
94
100
  end
@@ -1,12 +1,14 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Doxie
2
- API_V1 = 'API_V1'.freeze
3
- API_V2 = 'API_V2'.freeze
4
+ API_V1 = 'API_V1'
5
+ API_V2 = 'API_V2'
4
6
 
5
7
  DX250 = API_V1
6
8
  DX255 = API_V2
7
9
  DX300 = API_V2
8
10
 
9
11
  GO = API_V1
10
- GO_SE = API_V2
12
+ GO_SE = API_V2
11
13
  Q = API_V2
12
- end
14
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Doxie
2
- VERSION = '3.0.0'.freeze
4
+ VERSION = '4.0.0'
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'minitest/autorun'
2
4
  require 'webmock/minitest'
3
5
  require 'fakefs'
@@ -32,13 +34,13 @@ describe 'Doxie::Client' do
32
34
  assert_equal Doxie::DX255, Doxie::API_V2
33
35
  assert_equal Doxie::DX300, Doxie::API_V2
34
36
  end
35
- end
37
+ end
36
38
 
37
39
  describe 'get /hello.json' do
38
40
  it 'should return the result' do
39
41
  stub_request(:get, "#{@base_url}/hello.json")
40
42
  .to_return(@json_response_body)
41
- @client.hello.must_equal(@json_response_object)
43
+ _(@client.hello).must_equal(@json_response_object)
42
44
  end
43
45
  end
44
46
 
@@ -46,13 +48,13 @@ describe 'Doxie::Client' do
46
48
  it 'should return the result' do
47
49
  stub_request(:get, "#{@base_url}/hello_extra.json")
48
50
  .to_return(@json_response_body)
49
- @client.hello_extra.must_equal(@json_response_object)
51
+ _(@client.hello_extra).must_equal(@json_response_object)
50
52
  end
51
53
 
52
54
  it 'should error for API V2 models, as the method does not exist' do
53
55
  @client = Doxie::Client.new(ip: @ip, model: Doxie::API_V2)
54
- error = -> { @client.hello_extra }.must_raise(Doxie::Client::Error)
55
- error.message.must_match "Method does not exist for this model"
56
+ error = _(-> { @client.hello_extra }).must_raise(Doxie::Client::Error)
57
+ _(error.message).must_match 'Method does not exist for this model'
56
58
  end
57
59
  end
58
60
 
@@ -60,7 +62,7 @@ describe 'Doxie::Client' do
60
62
  it 'should return the result' do
61
63
  stub_request(:get, "#{@base_url}/restart.json")
62
64
  .to_return(status: 204)
63
- @client.restart.must_equal(true)
65
+ _(@client.restart).must_equal(true)
64
66
  end
65
67
  end
66
68
 
@@ -68,14 +70,14 @@ describe 'Doxie::Client' do
68
70
  it 'should return the result' do
69
71
  stub_request(:get, "#{@base_url}/scans.json")
70
72
  .to_return(@json_response_body)
71
- @client.scans.must_equal(@json_response_object)
73
+ _(@client.scans).must_equal(@json_response_object)
72
74
  end
73
75
 
74
76
  it 'should return an empty array when there are no scans on a V2 model' do
75
77
  @client = Doxie::Client.new(ip: @ip, model: Doxie::API_V2)
76
78
  stub_request(:get, "#{@base_url_v2}/scans.json")
77
79
  .to_return(status: 404)
78
- @client.scans.must_equal([])
80
+ _(@client.scans).must_equal([])
79
81
  end
80
82
  end
81
83
 
@@ -83,14 +85,14 @@ describe 'Doxie::Client' do
83
85
  it 'should return the result' do
84
86
  stub_request(:get, "#{@base_url}/scans/recent.json")
85
87
  .to_return(@json_response_body)
86
- @client.recent_scans.must_equal(@json_response_object)
88
+ _(@client.recent_scans).must_equal(@json_response_object)
87
89
  end
88
90
 
89
91
  it 'should return an empty array when there are no scans on a V2 model' do
90
92
  @client = Doxie::Client.new(ip: @ip, model: Doxie::API_V2)
91
93
  stub_request(:get, "#{@base_url_v2}/scans/recent.json")
92
94
  .to_return(status: 204)
93
- @client.recent_scans.must_equal([])
95
+ _(@client.recent_scans).must_equal([])
94
96
  end
95
97
  end
96
98
 
@@ -98,13 +100,14 @@ describe 'Doxie::Client' do
98
100
  it 'should return the result' do
99
101
  stub_request(:get, "#{@base_url}/scans/DOXIE/JPEG/IMG_0001.JPG")
100
102
  .to_return(@json_response_body)
101
- @client.scan('/DOXIE/JPEG/IMG_0001.JPG').must_equal(@json_response_object)
103
+ _(@client.scan('/DOXIE/JPEG/IMG_0001.JPG'))
104
+ .must_equal(@json_response_object)
102
105
  end
103
106
 
104
107
  it 'should write to file' do
105
108
  stub_request(:get, "#{@base_url}/scans/DOXIE/JPEG/IMG_0001.JPG")
106
109
  .to_return(@json_response_body)
107
- @client.scan('/DOXIE/JPEG/IMG_0001.JPG', 'test.jpg').must_equal(true)
110
+ _(@client.scan('/DOXIE/JPEG/IMG_0001.JPG', 'test.jpg')).must_equal(true)
108
111
  end
109
112
  end
110
113
 
@@ -112,14 +115,15 @@ describe 'Doxie::Client' do
112
115
  it 'should return the result' do
113
116
  stub_request(:get, "#{@base_url}/thumbnails/DOXIE/JPEG/IMG_0001.JPG")
114
117
  .to_return(@json_response_body)
115
- @client.thumbnail('/DOXIE/JPEG/IMG_0001.JPG')
116
- .must_equal(@json_response_object)
118
+ _(@client.thumbnail('/DOXIE/JPEG/IMG_0001.JPG'))
119
+ .must_equal(@json_response_object)
117
120
  end
118
121
 
119
122
  it 'should write to file' do
120
123
  stub_request(:get, "#{@base_url}/thumbnails/DOXIE/JPEG/IMG_0001.JPG")
121
124
  .to_return(@json_response_body)
122
- @client.thumbnail('/DOXIE/JPEG/IMG_0001.JPG', 'test.jpg').must_equal(true)
125
+ _(@client.thumbnail('/DOXIE/JPEG/IMG_0001.JPG', 'test.jpg'))
126
+ .must_equal(true)
123
127
  end
124
128
  end
125
129
 
@@ -127,8 +131,8 @@ describe 'Doxie::Client' do
127
131
  it 'should return the result' do
128
132
  stub_request(:delete, "#{@base_url}/scans/DOXIE/JPEG/IMG_0001.JPG")
129
133
  .to_return(@json_response_body)
130
- @client.delete_scan('/DOXIE/JPEG/IMG_0001.JPG')
131
- .must_equal(@json_response_object)
134
+ _(@client.delete_scan('/DOXIE/JPEG/IMG_0001.JPG'))
135
+ .must_equal(@json_response_object)
132
136
  end
133
137
  end
134
138
 
@@ -136,26 +140,26 @@ describe 'Doxie::Client' do
136
140
  it 'should return the result' do
137
141
  stub_request(:post, "#{@base_url}/scans/delete.json")
138
142
  .to_return(status: 204)
139
- @client.delete_scans(['/DOXIE/JPEG/IMG_0001.JPG'])
140
- .must_equal(true)
143
+ _(@client.delete_scans(['/DOXIE/JPEG/IMG_0001.JPG']))
144
+ .must_equal(true)
141
145
  end
142
146
  end
143
147
 
144
148
  it 'raises an authentication error exception if the response code is 401' do
145
149
  stub_request(:get, "#{@base_url}/hello.json")
146
150
  .to_return(status: 401)
147
- proc { @client.hello }.must_raise(Doxie::Client::Error)
151
+ _(proc { @client.hello }).must_raise(Doxie::Client::Error)
148
152
  end
149
153
 
150
154
  it 'raises a client error exception if the response code is 4xx' do
151
155
  stub_request(:get, "#{@base_url}/hello.json")
152
156
  .to_return(status: 400)
153
- proc { @client.hello }.must_raise(Doxie::Client::Error)
157
+ _(proc { @client.hello }).must_raise(Doxie::Client::Error)
154
158
  end
155
159
 
156
160
  it 'raises a server error exception if the response code is 5xx' do
157
161
  stub_request(:get, "#{@base_url}/hello.json")
158
162
  .to_return(status: 500)
159
- proc { @client.hello }.must_raise(Doxie::Client::Error)
163
+ _(proc { @client.hello }).must_raise(Doxie::Client::Error)
160
164
  end
161
165
  end
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: doxie
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cristiano Betta
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-19 00:00:00.000000000 Z
11
+ date: 2020-05-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rake
14
+ name: fakefs
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
@@ -25,7 +25,7 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: webmock
28
+ name: minitest
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
@@ -39,7 +39,7 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: minitest
42
+ name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
@@ -53,7 +53,7 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: fakefs
56
+ name: webmock
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="
@@ -99,7 +99,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
99
99
  - !ruby/object:Gem::Version
100
100
  version: '0'
101
101
  requirements: []
102
- rubygems_version: 3.0.2
102
+ rubyforge_project:
103
+ rubygems_version: 2.7.7
103
104
  signing_key:
104
105
  specification_version: 4
105
106
  summary: Doxie API Wrapper for getting scans off your Doxie scanner