gnip-client 0.1.9 → 0.2.0

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: 29fc5f29ca80ad4cc0890c96fe11ede63cc3cfae
4
- data.tar.gz: 343351bcd72e115270688bdd71d17952a4072ad7
3
+ metadata.gz: 5e382f081861096fa68f6bb8debb5681ce0320eb
4
+ data.tar.gz: 4bb687a49db956b891c49ba092faf4ee62c58708
5
5
  SHA512:
6
- metadata.gz: e3d24eac3276135861abe708a47c17d15a16fb9ccf2676fb7f430d087e5c9b9991325f45cf33ec1b13183af2f27f933f27e9d8cfd63b6645b4aa6d53cf882f73
7
- data.tar.gz: 8c2624f96f34bea6d7bb8fa5cbd1a0e2d5b37d8dad6f903802fe1c4af8f947be90e8b662ad6e07ca7671490c43e856edf171632aca9823e9bf49dff90982a2e3
6
+ metadata.gz: ea8d15bbf867c69574606c1ad7e0b76178bcaf116b1253b88d2b12392c16a7c878b2e59efb1a13f224a55d14c2376e9de0670401c9c3191f512be42d7232e2f4
7
+ data.tar.gz: ddbf82402cb4e7d9002a8e94692867121a79e609ce5c8f249bc7784273caf1a95bd383a9a6546a33da52b7aa13b40d31da070b9dc76b011c606f50b04710dc17
@@ -16,10 +16,10 @@ module Gnip
16
16
  def add(rules)
17
17
  begin
18
18
  response = self.class.post(self.rules_url, basic_auth: @auth, body: rules.to_json)
19
- if response.parsed_response["error"].present?
19
+ if response.parsed_response.present? && response.parsed_response["error"].present?
20
20
  { status: :error, code: response.response.code, error: response.parsed_response["error"]["message"] }
21
21
  else
22
- { status: :success, code: response.response.code }
22
+ { status: :success, code: 200 }
23
23
  end
24
24
  rescue Exception => e
25
25
  { status: :error, code: 500, error: e.message }
@@ -32,10 +32,10 @@ module Gnip
32
32
  def remove(rules)
33
33
  begin
34
34
  response = self.class.delete(self.rules_url, basic_auth: @auth, body: rules.to_json)
35
- if response.parsed_response["error"].present?
35
+ if response.parsed_response.present? && response.parsed_response["error"].present?
36
36
  { status: :error, code: response.response.code, error: response.parsed_response["error"]["message"] }
37
37
  else
38
- { status: :success, code: response.response.code }
38
+ { status: :success, code: 200 }
39
39
  end
40
40
  rescue Exception => e
41
41
  { status: :error, code: 500, error: e.message }
@@ -72,12 +72,12 @@ module Gnip
72
72
  retry_times = 0
73
73
  begin
74
74
  rules_list = self.list
75
- rules_list["rules"].in_groups_of(2, false).each do |group_of_rules|
75
+ rules_list[:rules].in_groups_of(2, false).each do |group_of_rules|
76
76
  self.remove({ "rules": group_of_rules })
77
77
  end
78
78
  sleep 0.05
79
79
  rules_list = self.list
80
- if !rules_list["rules"].size.zero?
80
+ if !rules_list[:rules].size.zero?
81
81
  self.delete_all!
82
82
  else
83
83
  return { status: :success, code: 200, rules: []}
@@ -1,3 +1,3 @@
1
1
  module Gnip
2
- VERSION = "0.1.9"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gnip-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Duccio Giovannelli