banana_peels 0.0.6 → 0.0.7

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: cf964a01fdfa237c8d9f3e4f8db840d01bbbe362
4
- data.tar.gz: 60e08aaa01f84a5d4de39346a2def7a487b2f8b8
3
+ metadata.gz: 97a30723701c03dce5179bc21696aee1e98d2836
4
+ data.tar.gz: 0a0a7085c04afab5b6d84309bb9beff6dc599b57
5
5
  SHA512:
6
- metadata.gz: 6d02b382ef52080b0f96e0689bbfb95f601dda85c6158205dc4b3a5a4859ac63ad12bd7d66bf11659ce086dabc2166cad263a778b657498f7f22b13f694163d0
7
- data.tar.gz: 2ead56707037d66cac075ad35e687eabfc5e5b2dd76d96df10632063c712024b9a964f62e3881cbc92b5f56424bd1872a33d63fd55a83ac4c8d9b3339b3b8719
6
+ metadata.gz: 98881fcc4fa0493dc51a34adeb3e160a93f3a472258c23e4ce29422692860190e46983a3b90ba7c8c5f8755a070026454a6b2c16d69e5f96ec00db2f6258eb9c
7
+ data.tar.gz: 5701e123aef396ae624a527d21084c983d28caa0619922efac00b450cdec9893fd540d4c1d8158f857512b67aaf6af5d12510ea40ef37ddf9dd0089a5a90ac15
@@ -3,7 +3,7 @@ module BananaPeels
3
3
  class << self
4
4
 
5
5
  def api(api_key)
6
- Mailchimp::API.new(api_key)
6
+ API.new(api_key)
7
7
  end
8
8
 
9
9
  def campaigns(api_key)
@@ -52,4 +52,69 @@ module BananaPeels
52
52
 
53
53
  end
54
54
 
55
+
56
+ class API
57
+
58
+ attr_reader :api_key
59
+
60
+
61
+ class << self
62
+
63
+ def cache_get(key)
64
+ cache[key]
65
+ end
66
+
67
+ def cache_set(key, value)
68
+ cache[key] = value if cache?
69
+ value
70
+ end
71
+
72
+ def cache?
73
+ ['true', 't', 'yes', 'y', 'on'].include?(ENV['BANANA_PEELS_CACHE'].to_s.downcase)
74
+ end
75
+
76
+
77
+ private
78
+
79
+ def cache
80
+ @cache ||= {}
81
+ end
82
+
83
+ end
84
+
85
+
86
+ def initialize(api_key)
87
+ @api_key = api_key
88
+ end
89
+
90
+ def method_missing(method, *args)
91
+ Proxy.new(@api_key, method)
92
+ end
93
+
94
+
95
+ class Proxy
96
+
97
+ def initialize(api_key, mod)
98
+ @api_key = api_key
99
+ @mod = mod
100
+ end
101
+
102
+ def method_missing(method, *args)
103
+ if API.cache?
104
+ cache_keys = [ @api_key, @mod.to_s, method.to_s ]
105
+ cache_keys.concat(args)
106
+ cache_key = cache_keys.to_json
107
+ cache_val = API.cache_get(cache_key)
108
+ return cache_val if cache_val
109
+ end
110
+ cache_val = Mailchimp::API.new(@api_key).__send__(@mod).__send__(method, *args)
111
+ API.cache_set(cache_key, cache_val) if API.cache?
112
+ cache_val
113
+ end
114
+
115
+ end
116
+
117
+ end
118
+
119
+
55
120
  end
@@ -1,3 +1,3 @@
1
1
  module BananaPeels
2
- VERSION = '0.0.6'
2
+ VERSION = '0.0.7'
3
3
  end
metadata CHANGED
@@ -1,41 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: banana_peels
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steven Bull
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-13 00:00:00.000000000 Z
11
+ date: 2015-11-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.3'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.3'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: mailchimp-api
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '2.0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '2.0'
41
41
  description: Interface for using MailChimp as a template repository for transactional
@@ -47,7 +47,7 @@ executables: []
47
47
  extensions: []
48
48
  extra_rdoc_files: []
49
49
  files:
50
- - .gitignore
50
+ - ".gitignore"
51
51
  - Gemfile
52
52
  - LICENSE.txt
53
53
  - README.md
@@ -68,17 +68,17 @@ require_paths:
68
68
  - lib
69
69
  required_ruby_version: !ruby/object:Gem::Requirement
70
70
  requirements:
71
- - - '>='
71
+ - - ">="
72
72
  - !ruby/object:Gem::Version
73
73
  version: '0'
74
74
  required_rubygems_version: !ruby/object:Gem::Requirement
75
75
  requirements:
76
- - - '>='
76
+ - - ">="
77
77
  - !ruby/object:Gem::Version
78
78
  version: '0'
79
79
  requirements: []
80
80
  rubyforge_project:
81
- rubygems_version: 2.0.14
81
+ rubygems_version: 2.4.8
82
82
  signing_key:
83
83
  specification_version: 4
84
84
  summary: Interface for using MailChimp as a template repository for transactional