qnap-file_station 0.0.2 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -3
- data/lib/qnap/file_station.rb +9 -6
- data/qnap-file_station.gemspec +1 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b7b6ede6e731c28529b06f66fb3f540c74ba51c1
|
4
|
+
data.tar.gz: 78a98a04f25f4704ac241831c0ecc22a26217ee4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b44c4e7a3b33c78d3b48b451e49a3249a62928ae4c825a2e7bdd5317d2804cdac483887e4f34462ebfe041e6e0be57cd87c601aefec6a43067c86b2031e03302
|
7
|
+
data.tar.gz: 498130c57a0ee5baa59be4a46cae3aee1e2e94b46c0aa6c97342d6de70be3c65e191e31ad60188b1574dab8e2a501f3d6ba80c3ff840f4e6b1f2a43c99ed09ef
|
data/README.md
CHANGED
@@ -41,13 +41,15 @@ end
|
|
41
41
|
|
42
42
|
Constants
|
43
43
|
-------
|
44
|
-
`Qnap::FileStation::DEBUG`, default: `false`. Print extensive debugging information to
|
45
|
-
|
44
|
+
`Qnap::FileStation::DEBUG`, default: `false`. Print extensive debugging information to `$stdout` if `true`
|
45
|
+
|
46
|
+
`Qnap::FileStation::DISCARD_EXTRANEOUS`, default: `true`, Discard any parameters we're not expecting before despatching to the API
|
47
|
+
|
46
48
|
`Qnap::FileStation::PROTOCOL`, default: `"https"`
|
47
49
|
|
48
50
|
Exceptions
|
49
51
|
-------
|
50
|
-
API communication errors will raise a Qnap::ApiError exception. The message will indicate what went wrong, the `uri` method will return the URI that was being queried at the time, and
|
52
|
+
API communication errors will raise a `Qnap::ApiError` exception. The message will indicate what went wrong, the `uri` method will return the URI that was being queried at the time, and the `response` method will return the `Net::HTTPResponse` response
|
51
53
|
|
52
54
|
```ruby
|
53
55
|
begin
|
data/lib/qnap/file_station.rb
CHANGED
@@ -123,7 +123,7 @@ module Qnap
|
|
123
123
|
def despatch_query(path, params)
|
124
124
|
uri = @base_uri.clone
|
125
125
|
uri.path = path
|
126
|
-
uri.query = URI.encode_www_form(params) if params.keys.length > 0
|
126
|
+
uri.query = URI.encode_www_form(params).gsub('+', '%20') if params.keys.length > 0
|
127
127
|
req = Net::HTTP::Get.new uri
|
128
128
|
|
129
129
|
puts "\n\n\e[1;32mDespatching request to #{params[:func]}\e[0m" if DEBUG
|
@@ -137,12 +137,15 @@ module Qnap
|
|
137
137
|
raise "Error response from #{uri} -> #{response.read_body}"
|
138
138
|
end
|
139
139
|
|
140
|
-
|
141
|
-
|
140
|
+
case response['content-type']
|
141
|
+
when /application\/json/
|
142
|
+
data = JSON.parse response.read_body, symbolize_names: true
|
143
|
+
when /application\/force-download/
|
144
|
+
data = response.read_body.force_encoding('UTF-8')
|
145
|
+
else
|
146
|
+
raise "Don't know how to parse #{response['content-type']}"
|
142
147
|
end
|
143
|
-
|
144
|
-
data = JSON.parse response.read_body, symbolize_names: true
|
145
|
-
|
148
|
+
|
146
149
|
if data.respond_to?(:key?) and data.key?(:status) and data[:status] != 1
|
147
150
|
raise Qnap::ApiError.new data[:status], uri, response
|
148
151
|
end
|
data/qnap-file_station.gemspec
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "qnap-file_station"
|
3
|
-
s.version = "0.0.
|
4
|
-
s.date = "2016-09-28"
|
3
|
+
s.version = "0.0.4"
|
5
4
|
s.summary = "Interface to the File Station API"
|
6
5
|
s.description = "Manage your files and folders in File Station"
|
7
6
|
s.authors = "cyclotron3k"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qnap-file_station
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- cyclotron3k
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-08-01 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Manage your files and folders in File Station
|
14
14
|
email:
|