qnap-download_station 0.0.1 → 0.0.2

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: 95c97768502e19e7b96d3d507bf82287141dfede
4
- data.tar.gz: 78f15e2110972d614542ecf16b22c49e8f170e53
3
+ metadata.gz: b10081f0cf4abe429c48bdd7c60fa15d34c4fda8
4
+ data.tar.gz: 6104a3b1f6dc9db6d4d8d022aa1de0307a59f503
5
5
  SHA512:
6
- metadata.gz: 4c110e4dc4cd730ccf8970961c10b77af96e6bc14847af6c2246db0f5644901cd7cc99c599ecd9609bbc255e86ace8159413da1afc8600f5654ea67604753034
7
- data.tar.gz: ba26c14d726db3a5e30f80a44a0fa3cfd71e1e141d54be7e48f399be5b35eb22462d7ddf78efe0d3496c4cb5024a574828429103e78d05b5b55bfddf66f012cc
6
+ metadata.gz: c9961e935e456e2c7c3fdc568dca3c8db08066df54ab1bee6c67be8a7bae17c5b8d50b64b10d78412e0a4fb7cac6ae7dc04c51e7347ba12a457cfac879e0ac5b
7
+ data.tar.gz: f27c1be4a506a4e0286832c64cbba2d7b21c51b450ebdd50bd0cb0b2611668c5eb416b79a118016a79b87b0d19cc1714c0367a7a6cf08d1fdde4ea822543816e
data/README.md CHANGED
@@ -1,9 +1,9 @@
1
1
  Qnap::DownloadStation
2
2
  =======
3
3
 
4
- This gem provides an interface to the Download Station app that comes installed by default on many QNAP NAS
4
+ This gem provides an interface to the Download Station app that comes installed by default on many QNAP NAS.
5
5
 
6
- It proves access to all endpoints, but only a few have been documented.
6
+ It provides access to all available endpoints, but only a few have been documented.
7
7
 
8
8
  Installation
9
9
  -------
@@ -24,6 +24,17 @@ active_downloads = ds.task_query
24
24
  ds.logout
25
25
  ```
26
26
 
27
+ ```ruby
28
+ # Alternative syntax to guarantee logout
29
+
30
+ Qnap::DownloadStation.session('192.168.1.100', 'username', 'password') do |ds|
31
+ ds.task_add_url temp: 'Download', move: 'Multimedia/New', url: magnet_link
32
+ pp ds.task_query
33
+ # logout is automatically called, even if there was an exception
34
+ end
35
+
36
+ ```
37
+
27
38
  Available methods
28
39
  -------
29
40
 
@@ -52,7 +63,7 @@ Available methods
52
63
  * misc_logout
53
64
  * misc_socks_5
54
65
 
55
- **Rss methods**
66
+ **RSS methods**
56
67
  * rss_add
57
68
  * rss_add_job
58
69
  * rss_query
@@ -78,8 +89,9 @@ Available methods
78
89
  * task_status
79
90
  * task_stop
80
91
 
81
- Notes and known issues
92
+ TODO
82
93
  -------
83
94
 
84
- * Needs inputs validation
85
- * Need to allow users to specify a SSL cert instead of just ignoring certificate errors
95
+ * Document the endpoints
96
+ * Input validation
97
+ * Allow users to specify a SSL cert instead of just ignoring certificate errors
@@ -17,6 +17,15 @@ module Qnap
17
17
  addon: [:query, :enable, :verify, :install, :uninstall, :search],
18
18
  }
19
19
 
20
+ def self.session(*args)
21
+ ds = self.new *args
22
+ begin
23
+ yield ds
24
+ ensure
25
+ ds.logout
26
+ end
27
+ end
28
+
20
29
  def logout
21
30
  return unless @sid
22
31
 
@@ -62,7 +71,7 @@ module Qnap
62
71
 
63
72
  def uri_for_path(app, endpoint)
64
73
  path = [app, endpoint].map { |s| s.to_s.gsub(/(^|_)(.)/){ $2.upcase } }.join "/"
65
- URI("#{PROTOCOL}://#{@host}/#{APP_NAME}/#{API_VERSION}/#{path}")
74
+ URI "#{PROTOCOL}://#{@host}/#{APP_NAME}/#{API_VERSION}/#{path}"
66
75
  end
67
76
 
68
77
  def despatch_query(uri, params)
@@ -81,8 +90,7 @@ module Qnap
81
90
  data = JSON.parse response.read_body, symbolize_names: true
82
91
 
83
92
  if (data.key?(:error) and data[:error] > 0)
84
- pp data
85
- raise RuntimeError.new data[:reason]
93
+ raise RuntimeError.new "Error response from #{uri} -> #{data}"
86
94
  end
87
95
 
88
96
  data
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "qnap-download_station"
3
- s.version = "0.0.1"
3
+ s.version = "0.0.2"
4
4
  s.date = "2016-09-21"
5
5
  s.summary = "Interface to the Download Station API"
6
6
  s.description = "Manage your downloads in Download Station"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qnap-download_station
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - cyclotron3k
@@ -41,7 +41,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
41
41
  version: '0'
42
42
  requirements: []
43
43
  rubyforge_project:
44
- rubygems_version: 2.5.1
44
+ rubygems_version: 2.2.2
45
45
  signing_key:
46
46
  specification_version: 4
47
47
  summary: Interface to the Download Station API