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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7b53bdac66bf563c2314cdad578479e57b1c621b
4
- data.tar.gz: eba64d3cf0bec2d666fd2d43ce771317e327cb2e
3
+ metadata.gz: b7b6ede6e731c28529b06f66fb3f540c74ba51c1
4
+ data.tar.gz: 78a98a04f25f4704ac241831c0ecc22a26217ee4
5
5
  SHA512:
6
- metadata.gz: 7e6c546e57b12b145e6101f97e69bc7f6509f886baff56c6add067a2996fc5ceddeba238c43e08acdb405b74441b2102611c0c9d24fad90805a8449bf895ab42
7
- data.tar.gz: a080dea3bfb8c1868a7cd722234dfa91997c447d353dea539a94e182cb369bfb3ffcce7487c85fc9989bc04246c8dde09b20aa1ebc63708adee31a76d89aa9e7
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 @stdout of `true`
45
- `Qnap::FileStation::DISCARD_EXTRANEOUS` default: `true`, Discard any parameters we're not expecting, before despatching to the API
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 `the response` method will return the `Net::HTTPResponse` response
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
@@ -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
- unless response['content-type'] =~ /application\/json/
141
- raise "Don't know how to parse #{response['content-type']}"
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
@@ -1,7 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "qnap-file_station"
3
- s.version = "0.0.2"
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.2
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: 2016-09-28 00:00:00.000000000 Z
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: