heroix 0.2.1 → 0.2.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: c7631547c7d39fbec4cd974b8e582b6350b6b216
4
- data.tar.gz: af1e343ba5e3d16cef171d0b652cd7d22baae4b2
3
+ metadata.gz: d6918e1258f70ff55500f20aa8bc3255b718a283
4
+ data.tar.gz: 7753d1b4968efe9cda393a115a099c9709de3653
5
5
  SHA512:
6
- metadata.gz: b5b67c923fa0b726179f0f10c98889861548b106679cd1f9122a8b138b2d66b55434249fa0b7d002a3482094afd03eb3d444da6172210083d0ddb10d73829130
7
- data.tar.gz: 1aa099c027230a26546a951734bff5f3d0244862b1eddca795e3cc2e8b3a63f1a31b4b90b822a482c942a5698ca1c9a8b32e0bae7fc74a7316652806f97625f7
6
+ metadata.gz: 0b849ec9b037a4adb6407eae7bcb337e1f056c1584e204cfb628e3fc903ba60a9f8f0a699b7b7b9607eba1cf6ab6942f20bbd415d61a856ee56b6ee5a101f6fa
7
+ data.tar.gz: d57adf6700ba42c4c2fbc5a51282a4f9b282b43d108c59172af11f0f23a7a88cfcc9a1816a39e7f7c375786f83632844a8a8a7b45fdde9151b273ae652c441a0
@@ -8,3 +8,6 @@ Documentation:
8
8
  HashSyntax:
9
9
  Exclude:
10
10
  - '**/*'
11
+
12
+ TrivialAccessors:
13
+ Enabled: false
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- heroix (0.2.1)
4
+ heroix (0.2.2)
5
5
  rest-client (~> 1.6.1)
6
6
 
7
7
  GEM
@@ -1,66 +1,13 @@
1
+ require 'logger'
1
2
  require 'heroix/version'
2
- require 'heroix/resource'
3
+ require 'heroix/client'
3
4
 
4
5
  module Heroix
5
- class Client < Resource
6
- def users
7
- build_resource :users, :user
8
- end
9
-
10
- def session
11
- build_resource :session, :session
12
- end
13
-
14
- def organisations
15
- build_resource :organisations, :organisation
16
- end
17
-
18
- def beneficiaries
19
- build_resource :beneficiaries, :beneficiary
20
- end
21
-
22
- def beneficiary_registrations
23
- build_resource :beneficiary_registrations, :beneficiary_registration
24
- end
25
-
26
- def beneficiary_rules
27
- build_resource :beneficiary_rules, :beneficiary_rule
28
- end
29
-
30
- def campaigns
31
- build_resource :campaigns, :campaign
32
- end
33
-
34
- def campaign_peer_to_peers
35
- build_resource :campaign_peer_to_peers, :campaign_peer_to_peer
36
- end
37
-
38
- def organisation_beneficiaries
39
- build_resource :organisation_beneficiaries, :organisation_beneficiary
40
- end
41
-
42
- def campaign_beneficiaries
43
- build_resource :campaign_beneficiaries, :campaign_beneficiary
44
- end
45
-
46
- def microsites
47
- build_resource :microsites, :microsite
48
- end
49
-
50
- def microsite_pages
51
- build_resource :microsite_pages, :microsite_page
52
- end
53
-
54
- def search(type, params)
55
- build_resource("search/#{type}", type).index(params).fetch(type, [])
56
- end
57
-
58
- private
6
+ def self.logger
7
+ @logger ||= Logger.new(STDOUT)
8
+ end
59
9
 
60
- def build_resource(path, type)
61
- Resource.new :url => url_for(path),
62
- :token => token,
63
- :type => type
64
- end
10
+ def self.logger=(logger)
11
+ @logger = logger
65
12
  end
66
13
  end
@@ -0,0 +1,65 @@
1
+ require_relative 'resource'
2
+
3
+ module Heroix
4
+ class Client < Resource
5
+ def users
6
+ build_resource :users, :user
7
+ end
8
+
9
+ def session
10
+ build_resource :session, :session
11
+ end
12
+
13
+ def organisations
14
+ build_resource :organisations, :organisation
15
+ end
16
+
17
+ def beneficiaries
18
+ build_resource :beneficiaries, :beneficiary
19
+ end
20
+
21
+ def beneficiary_registrations
22
+ build_resource :beneficiary_registrations, :beneficiary_registration
23
+ end
24
+
25
+ def beneficiary_rules
26
+ build_resource :beneficiary_rules, :beneficiary_rule
27
+ end
28
+
29
+ def campaigns
30
+ build_resource :campaigns, :campaign
31
+ end
32
+
33
+ def campaign_peer_to_peers
34
+ build_resource :campaign_peer_to_peers, :campaign_peer_to_peer
35
+ end
36
+
37
+ def organisation_beneficiaries
38
+ build_resource :organisation_beneficiaries, :organisation_beneficiary
39
+ end
40
+
41
+ def campaign_beneficiaries
42
+ build_resource :campaign_beneficiaries, :campaign_beneficiary
43
+ end
44
+
45
+ def microsites
46
+ build_resource :microsites, :microsite
47
+ end
48
+
49
+ def microsite_pages
50
+ build_resource :microsite_pages, :microsite_page
51
+ end
52
+
53
+ def search(type, params)
54
+ build_resource("search/#{type}", type).index(params)
55
+ end
56
+
57
+ private
58
+
59
+ def build_resource(path, type)
60
+ Resource.new :url => url_for(path),
61
+ :token => token,
62
+ :type => type
63
+ end
64
+ end
65
+ end
@@ -47,6 +47,15 @@ module Heroix
47
47
  private
48
48
 
49
49
  def request(method, url, options = {})
50
+ rest_logger = RestClient.log
51
+ RestClient.log = logger
52
+
53
+ perform_request(method, url, options)
54
+ ensure
55
+ RestClient.log = rest_logger
56
+ end
57
+
58
+ def perform_request(method, url, options)
50
59
  handle RestClient::Request.execute(
51
60
  :method => method,
52
61
  :url => url,
@@ -60,7 +69,7 @@ module Heroix
60
69
 
61
70
  def handle(response)
62
71
  deprecation = response.headers[:x_deprecation]
63
- puts "[heroix] DEPRECATION WARNING #{deprecation}" if deprecation
72
+ logger.warn "[heroix] DEPRECATION WARNING #{deprecation}" if deprecation
64
73
 
65
74
  parse_response response.to_str
66
75
  end
@@ -74,5 +83,9 @@ module Heroix
74
83
  data = { type => data } if data && type
75
84
  data.to_json
76
85
  end
86
+
87
+ def logger
88
+ Heroix.logger
89
+ end
77
90
  end
78
91
  end
@@ -1,3 +1,3 @@
1
1
  module Heroix
2
- VERSION = '0.2.1'
2
+ VERSION = '0.2.2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: heroix
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leon Fu
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-01-05 00:00:00.000000000 Z
13
+ date: 2015-01-06 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rest-client
@@ -97,6 +97,7 @@ files:
97
97
  - bin/ci
98
98
  - heroix.gemspec
99
99
  - lib/heroix.rb
100
+ - lib/heroix/client.rb
100
101
  - lib/heroix/resource.rb
101
102
  - lib/heroix/version.rb
102
103
  - lib/jack_and_rose.rb