webpurify 0.5.2 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3c707414ce2a466ece2257184332ae8b0f01f521
4
+ data.tar.gz: dae8c7e08f2a7223d3731734b0773cfb5ed5668e
5
+ SHA512:
6
+ metadata.gz: ab4ab468cdc84cab0b1c2e7550a5fc1d665acef20fa73621cc856e0ffe8da03d150ab23a7d257b6cc20e9a808f9d47177eae1311b96d0edac85fa9e31b1342aa
7
+ data.tar.gz: 78f5889a7feda0501de88453c3649dcfcaed2b5d64a4901a27acf46224511a92938a1f21548f22276de4523820e72e1dac7f1a7ed0368a91ebc555b92db17a3e
@@ -12,6 +12,19 @@ module WebPurify
12
12
  module Request
13
13
 
14
14
  WRAPPER = :rsp
15
+
16
+ class RequestError < StandardError
17
+ attr_accessor :code, :msg
18
+
19
+ def initialize code, msg
20
+ @code = code
21
+ @msg = msg
22
+ end
23
+
24
+ def to_s
25
+ "[#{@code}] #{@msg}"
26
+ end
27
+ end
15
28
 
16
29
 
17
30
  # Converts a hash of key/values into a url-ready query string
@@ -37,7 +50,13 @@ module WebPurify
37
50
  :path => request_base[:path],
38
51
  :query => WebPurify::Request.to_query(q)
39
52
  )
40
- return JSON.parse(WebPurify::Request.get(uri, request_base[:scheme]), :symbolize_names => true)[WRAPPER]
53
+ res = JSON.parse(WebPurify::Request.get(uri, request_base[:scheme]), :symbolize_names => true)[WRAPPER]
54
+ if res[:err]
55
+ err_attrs = res[:err][:@attributes]
56
+ raise RequestError.new(err_attrs[:code], err_attrs[:msg])
57
+ else
58
+ res
59
+ end
41
60
  end
42
61
 
43
62
 
@@ -48,12 +67,7 @@ module WebPurify
48
67
  # @return [String] The JSON request response
49
68
  def self.get(uri, scheme)
50
69
  req = (scheme=='https') ? Net::HTTPS : Net::HTTP
51
- begin
52
- request = req.get(uri)
53
- rescue Exception => e
54
- p e
55
- end
56
- return request
70
+ req.get uri
57
71
  end
58
72
 
59
73
  end
@@ -1,3 +1,3 @@
1
1
  module WebPurify
2
- VERSION = "0.5.2"
3
- end
2
+ VERSION = "0.6.0"
3
+ end
metadata CHANGED
@@ -1,46 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webpurify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
5
- prerelease:
4
+ version: 0.6.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Miles Zimmerman
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-06-26 00:00:00.000000000 Z
11
+ date: 2015-04-22 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rspec
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ~>
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
19
  version: 2.5.0
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ~>
24
+ - - "~>"
28
25
  - !ruby/object:Gem::Version
29
26
  version: 2.5.0
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: json
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ">="
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  description: A RubyGem for interfacing with the WebPurify API.
@@ -50,7 +45,7 @@ executables: []
50
45
  extensions: []
51
46
  extra_rdoc_files: []
52
47
  files:
53
- - .gitignore
48
+ - ".gitignore"
54
49
  - README.md
55
50
  - lib/web_purify.rb
56
51
  - lib/web_purify/client.rb
@@ -63,27 +58,25 @@ files:
63
58
  - web_purify.gemspec
64
59
  homepage: https://github.com/mileszim/webpurify-gem
65
60
  licenses: []
61
+ metadata: {}
66
62
  post_install_message:
67
63
  rdoc_options: []
68
64
  require_paths:
69
65
  - lib
70
66
  required_ruby_version: !ruby/object:Gem::Requirement
71
- none: false
72
67
  requirements:
73
- - - ! '>='
68
+ - - ">="
74
69
  - !ruby/object:Gem::Version
75
70
  version: '0'
76
71
  required_rubygems_version: !ruby/object:Gem::Requirement
77
- none: false
78
72
  requirements:
79
- - - ! '>='
73
+ - - ">="
80
74
  - !ruby/object:Gem::Version
81
75
  version: '0'
82
76
  requirements: []
83
77
  rubyforge_project:
84
- rubygems_version: 1.8.24
78
+ rubygems_version: 2.2.2
85
79
  signing_key:
86
- specification_version: 3
80
+ specification_version: 4
87
81
  summary: A RubyGem for interfacing with the WebPurify API.
88
82
  test_files: []
89
- has_rdoc: