banana_peels 0.0.7 → 0.0.8

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: 97a30723701c03dce5179bc21696aee1e98d2836
4
- data.tar.gz: 0a0a7085c04afab5b6d84309bb9beff6dc599b57
3
+ metadata.gz: 0b18d21c1895b884cac8e6c5d5496138bb16728b
4
+ data.tar.gz: d2716ccbaf4deb4ab23724c8618b6872546900d7
5
5
  SHA512:
6
- metadata.gz: 98881fcc4fa0493dc51a34adeb3e160a93f3a472258c23e4ce29422692860190e46983a3b90ba7c8c5f8755a070026454a6b2c16d69e5f96ec00db2f6258eb9c
7
- data.tar.gz: 5701e123aef396ae624a527d21084c983d28caa0619922efac00b450cdec9893fd540d4c1d8158f857512b67aaf6af5d12510ea40ef37ddf9dd0089a5a90ac15
6
+ metadata.gz: 0f7dd092dfd1363fcf8b2c61600c742e094e9b835b3b09f9ac0d0a23e934278e4f72c93fc0363a7e0476651c7ca9c22ee4be7556a2c485ba83ea24b2a8c28679
7
+ data.tar.gz: 5ff0c40326c0cdf334cea7a024c2c9d4b317a56b520560857618e0d0b315ebfdd435be63bc5cbf624e00ac49c18107b24b28524f71b2edf24376a86e2388dc29
data/README.md CHANGED
@@ -99,6 +99,18 @@ end
99
99
  And then use the merge tags `*|FIRST_NAME|*`, `*|LAST_NAME|*`, `*|RESET_PASSWORD_URL|*` in your MailChimp Campaign.
100
100
 
101
101
 
102
+ ### Caching
103
+
104
+ To enable a rudimentary cache, set:
105
+ ```ruby
106
+ ENV['BANANA_PEELS_CACHE'] = 'ON'
107
+ ```
108
+
109
+ This caches the responses for identical API & argument combinations,
110
+ and modifies individual campaign metadata calls to retrieve the metadata
111
+ for all campaigns.
112
+
113
+
102
114
  ## Contributing
103
115
 
104
116
  1. Fork it
@@ -17,6 +17,7 @@ class BananaPeels::Campaign
17
17
  def initialize(campaign_id, merge_tags, api_key)
18
18
  @campaign_id = campaign_id
19
19
  @raw_merge_tags = merge_tags
20
+ @api_key = api_key
20
21
  @api = BananaPeels.api(api_key)
21
22
  end
22
23
 
@@ -25,8 +26,18 @@ class BananaPeels::Campaign
25
26
  end
26
27
 
27
28
  def mailchimp_meta
28
- # TODO: Cache campaigns from mailchimp.
29
- @mailchimp_meta ||= @api.campaigns.list({ campaign_id: @campaign_id })['data'].first
29
+ @mailchimp_meta ||=
30
+ begin
31
+ meta = nil
32
+ if BananaPeels::API.cache?
33
+ campaigns_list_data = BananaPeels.campaigns_list(@api_key)
34
+ meta = campaigns_list_data.find{|camp| camp['id'] == @campaign_id }
35
+ end
36
+ unless meta
37
+ meta = @api.campaigns.list({ campaign_id: @campaign_id })['data'].first
38
+ end
39
+ meta
40
+ end
30
41
  end
31
42
  def mailchimp_meta=(mailchimp_meta)
32
43
  @mailchimp_meta = mailchimp_meta
@@ -1,3 +1,3 @@
1
1
  module BananaPeels
2
- VERSION = '0.0.7'
2
+ VERSION = '0.0.8'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: banana_peels
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steven Bull
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-26 00:00:00.000000000 Z
11
+ date: 2015-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler