qnap-file_station 0.0.3 → 0.0.6

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
- SHA1:
3
- metadata.gz: a5b17e28b82aa0b9bd84caad5770597a5c2583cf
4
- data.tar.gz: f32a9a1d6fb8b94567858240380a09e6f451346c
2
+ SHA256:
3
+ metadata.gz: ca26ebc789756816af968b65dc339121add6123ff8d0711bc6ce76f22be61f66
4
+ data.tar.gz: f96d5b60f387ccba7c896ff1b8fc7f7dcd0653f7ff8b09d67e6f940140dff0bb
5
5
  SHA512:
6
- metadata.gz: 0a4aad404e2a946c721b01e15d21eb0b17a9189a68b1c11533edf5fb7feda00215ba36c5d687b0804b53b80ceff41ae53f54f1ead168dd376e9bd7f801309492
7
- data.tar.gz: 94334ac4acc3435d43d0e4889064463ff9754436d2eae99a0be96fa87376173c6f647d44cb2f01368875884e5c52a4e470a3e913f475e83b6edf0ce1037244c7
6
+ metadata.gz: e25869cf0edddbde0c6198044dfcfdba1e0ab95b5bb4095b09abd06b18cd11319dd88550d3211b24b22ef8e21b82c5be6f5ada2ae4c7823f6b44dcf2592e4c76
7
+ data.tar.gz: 46af445566e25654086b92a31ef4749cc48515f834e76ee6cad6144a0313a05e7db7f61f09c98d48cf648aa43b7c9d3b18293e4fb5e2656f38b6d72bd3700bc9
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  Qnap::FileStation
2
2
  =======
3
3
 
4
+ > NOTE: This library works with older QNAP NAS models that use QTS 4.x. Newer models are now being released with QTS 5.x, and most likely this library will not work with them. Patches welcome.
5
+
4
6
  This gem provides an interface to the File Station app that comes installed by default on many QNAP NAS.
5
7
 
6
8
  It provides access to all available endpoints, but the documentation is patchy and untested. Use with caution.
@@ -39,6 +41,21 @@ end
39
41
 
40
42
  ```
41
43
 
44
+ Alternatively, if the username and password are not provided, Qnap::FileStation will attempt to read them from environment variables.
45
+ ```ruby
46
+ # ENV['QNAP_USERNAME']
47
+ # ENV['QNAP_PASSWORD']
48
+
49
+ fs = Qnap::FileStation.new '192.168.1.100'
50
+ # ...
51
+ fs.logout
52
+
53
+ # or...
54
+ Qnap::FileStation.session('192.168.1.100') do |fs|
55
+ # ...
56
+ end
57
+ ```
58
+
42
59
  Constants
43
60
  -------
44
61
  `Qnap::FileStation::DEBUG`, default: `false`. Print extensive debugging information to `$stdout` if `true`
@@ -290,7 +307,7 @@ path | Folder path.
290
307
  file_total | Total number of folder/file(s).
291
308
  file_name | Folder/file name.
292
309
 
293
- ### stat
310
+ ### stat
294
311
  Set folder(s)/file(s) modification time.
295
312
 
296
313
  #### Parameters
@@ -316,7 +333,7 @@ limit | Number of response data
316
333
  sort | Sort field (filename/filesize/filetype/mt/privilege/owner/group)
317
334
  start | Response data start index
318
335
 
319
- ###
336
+ ###
320
337
  Download a shared file by an unique ID (ssid).
321
338
 
322
339
  #### Parameters
@@ -463,7 +480,7 @@ Show available network players (AirPlay, Chromecast, DLNA players, etc.) May not
463
480
  #### Parameters
464
481
  Key | Description
465
482
  --- | ---
466
- op | 1:
483
+ op | 1:
467
484
 
468
485
  ### video_ml_queue
469
486
  Retrieve the status of media library transcoding queue.
@@ -103,7 +103,11 @@ module Qnap
103
103
  @sid ||= login(user: @username, pwd: Base64.encode64(@password).strip)[:sid]
104
104
  end
105
105
 
106
- def initialize(host, username, password)
106
+ def initialize(host, username = ENV['QNAP_USERNAME'], password = ENV['QNAP_PASSWORD'])
107
+
108
+ raise ArgumentError.new("No username defined") if username.nil?
109
+ raise ArgumentError.new("No password defined") if password.nil?
110
+
107
111
  @host = host
108
112
  @username = username
109
113
  @password = password
@@ -111,7 +115,7 @@ module Qnap
111
115
  @base_uri = URI "#{PROTOCOL}://#{@host}"
112
116
  @path = "/cgi-bin/filemanager/utilRequest.cgi"
113
117
  @agent = Net::HTTP.new @base_uri.host, @base_uri.port
114
-
118
+
115
119
  @agent.use_ssl = PROTOCOL == 'https',
116
120
  @agent.verify_mode = OpenSSL::SSL::VERIFY_NONE
117
121
  @agent.keep_alive_timeout = 10
@@ -123,7 +127,7 @@ module Qnap
123
127
  def despatch_query(path, params)
124
128
  uri = @base_uri.clone
125
129
  uri.path = path
126
- uri.query = URI.encode_www_form(params) if params.keys.length > 0
130
+ uri.query = URI.encode_www_form(params).gsub('+', '%20') if params.keys.length > 0
127
131
  req = Net::HTTP::Get.new uri
128
132
 
129
133
  puts "\n\n\e[1;32mDespatching request to #{params[:func]}\e[0m" if DEBUG
@@ -1,8 +1,8 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "qnap-file_station"
3
- s.version = "0.0.3"
3
+ s.version = "0.0.6"
4
4
  s.summary = "Interface to the File Station API"
5
- s.description = "Manage your files and folders in File Station"
5
+ s.description = "Manage your files and folders in File Station. (Compatible with older, QTS 4.x models)"
6
6
  s.authors = "cyclotron3k"
7
7
  s.files = ["lib/qnap/file_station.rb", "lib/qnap/api_error.rb", "Rakefile", "qnap-file_station.gemspec", "README.md"]
8
8
  s.test_files = ["test/test_file_station.rb"]
metadata CHANGED
@@ -1,16 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qnap-file_station
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - cyclotron3k
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-26 00:00:00.000000000 Z
11
+ date: 2022-05-30 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: Manage your files and folders in File Station
13
+ description: Manage your files and folders in File Station. (Compatible with older,
14
+ QTS 4.x models)
14
15
  email:
15
16
  executables: []
16
17
  extensions: []
@@ -41,8 +42,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
41
42
  - !ruby/object:Gem::Version
42
43
  version: '0'
43
44
  requirements: []
44
- rubyforge_project:
45
- rubygems_version: 2.5.1
45
+ rubygems_version: 3.3.7
46
46
  signing_key:
47
47
  specification_version: 4
48
48
  summary: Interface to the File Station API