ayadn 1.4.1 → 1.4.2

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
  SHA1:
3
- metadata.gz: 08a202fea9f47db0c64d1c9d0b1a12b809a25650
4
- data.tar.gz: f620955c6f10034e69ee9969e51e1601d146275e
3
+ metadata.gz: 4844f6ffe9a330e65f8af4cdd518fe7753e36890
4
+ data.tar.gz: e9b0f90c5add38d0a938303a89908efe1ea7bf2b
5
5
  SHA512:
6
- metadata.gz: 9790a6fdc3958a4329ac873d3aefeddbe86291215eca8e07cd8b863903673721062d166d2ff876703447b28902b1970c17c14679acc5e21ec780baa5209220b5
7
- data.tar.gz: b167b9aae1d9f9535a380dd51d96823efd375356465ee055aeefe6b27c01d32a769e8755bc085875784864bfaf24aeb59293824468ddb41da26f9891b1a2ee07
6
+ metadata.gz: ed02423f52ee4cafe6836b95e7d8a1b3babd71a3314ff2efb0fe657663302b2a732f74f7f71b790a9b116577603427a6e7633d8d8f2ef0633ae3e022b1328a40
7
+ data.tar.gz: 2bd08d85a8c479e23cd048579505c54fb757c3eb3b689e13005119137ac02a7962a8e60b1604509c305c324387ef78bc61daa89993117293527dfb99932f9bf8
data/CHANGELOG.md CHANGED
@@ -1,6 +1,11 @@
1
- # 1.4.1 - Fixes
1
+ # 1.4.2 - CNX
2
2
 
3
- - A few fixes here and there
3
+ - Ayadn is more resilient to connectivity errors
4
+ - Better handling of filenames when uploading
5
+
6
+ # 1.4.1 - NowPlaying
7
+
8
+ - A few fixes in the NowPlaying section
4
9
 
5
10
  # 1.4.0 - 'Florian'
6
11
 
data/lib/ayadn/cnx.rb CHANGED
@@ -17,15 +17,7 @@ module Ayadn
17
17
  Debug.http response, url
18
18
  check_nr response, url
19
19
  end
20
- rescue SocketError => e
21
- if working == true
22
- working = false
23
- sleep 0.5
24
- retry
25
- end
26
- Errors.nr "URL: #{url}"
27
- return {'meta' => {'code' => 666}, 'data' => "#{e}"}.to_json
28
- rescue SystemCallError => e
20
+ rescue SocketError, SystemCallError, OpenSSL::SSL::SSLError, RestClient::RequestTimeout => e
29
21
  if working == true
30
22
  working = false
31
23
  sleep 0.5
@@ -57,20 +49,13 @@ module Ayadn
57
49
  Debug.http response, url
58
50
  check response
59
51
  end
60
- rescue SocketError => e
52
+ rescue SocketError, SystemCallError, OpenSSL::SSL::SSLError, RestClient::RequestTimeout => e
61
53
  if try_cnx < 4
62
54
  try_cnx = retry_adn 10, try_cnx
63
55
  retry
64
56
  end
65
57
  puts "\nConnection error.".color(:red)
66
58
  Errors.global_error("cnx.rb/get_response_from", url, e)
67
- rescue SystemCallError => e
68
- if try_cnx < 4
69
- try_cnx = retry_adn 15, try_cnx
70
- retry
71
- end
72
- puts "\nConnection error.".color(:red)
73
- Errors.global_error("cnx.rb/get_response_from", url, e)
74
59
  rescue => e
75
60
  Errors.global_error("cnx.rb/get_response_from", url, e)
76
61
  end
data/lib/ayadn/fileops.rb CHANGED
@@ -41,17 +41,15 @@ module Ayadn
41
41
  end
42
42
  end
43
43
 
44
- def self.upload(path, token)
44
+ def self.upload(file, token)
45
45
  begin
46
- temp = Regexp.escape(path).gsub('\.', '.')
47
- file = temp.gsub('\-', '-')
48
- case File.extname(path).downcase
46
+ case File.extname(file).downcase
49
47
  when ".png"
50
- `curl -k -H 'Authorization: BEARER #{token}' https://api.app.net/files -F 'type=com.ayadn.files' -F "content=@#{file};type=image/png" -F 'public=true' -X POST`
48
+ `curl -k -H 'Authorization: BEARER #{token}' https://api.app.net/files -F 'type=com.ayadn.files' -F "content=@'#{file}';type=image/png" -F 'public=true' -X POST`
51
49
  when ".gif"
52
- `curl -k -H 'Authorization: BEARER #{token}' https://api.app.net/files -F 'type=com.ayadn.files' -F "content=@#{file};type=image/gif" -F 'public=true' -X POST`
50
+ `curl -k -H 'Authorization: BEARER #{token}' https://api.app.net/files -F 'type=com.ayadn.files' -F "content=@'#{file}';type=image/gif" -F 'public=true' -X POST`
53
51
  else #jpg or jpeg or JPG or JPEG, automatically recognized as such
54
- `curl -k -H 'Authorization: BEARER #{token}' https://api.app.net/files -F 'type=com.ayadn.files' -F content=@#{file} -F 'public=true' -X POST`
52
+ `curl -k -H 'Authorization: BEARER #{token}' https://api.app.net/files -F 'type=com.ayadn.files' -F content=@'#{file}' -F 'public=true' -X POST`
55
53
  end
56
54
  rescue Errno::ENOENT
57
55
  abort(Status.no_curl)
@@ -45,10 +45,16 @@ module Ayadn
45
45
 
46
46
  unless get_these.empty?
47
47
  got = CNX.get "#{@url}#{get_these.join(',')}&show_details=Y"
48
- unless got.code != 200
49
- resp = JSON.parse(got)
48
+ blank = JSON.parse({'meta' => {'code' => 404}, 'data' => []}.to_json)
49
+ if got.nil? || got == ""
50
+ parsed = blank
50
51
  else
51
- resp = JSON.parse({'meta' => {'code' => got.code}}.to_json)
52
+ parsed = JSON.parse(got)
53
+ end
54
+ if parsed['meta']['code'] != 200
55
+ resp = blank
56
+ else
57
+ resp = parsed
52
58
  end
53
59
 
54
60
  if resp['meta']['code'] != 200
data/lib/ayadn/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  # encoding: utf-8
2
2
  module Ayadn
3
- VERSION = "1.4.1"
3
+ VERSION = "1.4.2"
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ayadn
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Dejonckheere
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-14 00:00:00.000000000 Z
11
+ date: 2014-07-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor