method_cacheable 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.rvmrc ADDED
@@ -0,0 +1,17 @@
1
+ ruby_string="ree"
2
+ gemset_name="johnny_cache"
3
+
4
+ if rvm list strings | grep -q "${ruby_string}" ; then
5
+
6
+ rvm use "${ruby_string}@${gemset_name}" --create
7
+
8
+ # Complain if bundler isn't installed
9
+ if [[ -z "`gem which bundler 2>&1 | grep -v ERROR`" ]]; then
10
+ echo "You need bundler:"
11
+ echo ""
12
+ echo " gem install bundler"
13
+ echo ""
14
+ fi
15
+ else
16
+ echo "${ruby_string} was not found, please run 'rvm install ${ruby_string}' and then cd back into the project directory."
17
+ fi
@@ -0,0 +1 @@
1
+ lib/johnny_cache.rb 9420d7832edce1f3c2bb65bc9922e19da6e9d204
Binary file
@@ -0,0 +1,2 @@
1
+ {" Object:
2
+ class"ActiveSupport::Concern: module
data/Gemfile ADDED
@@ -0,0 +1,17 @@
1
+ source 'http://rubygems.org'
2
+ gem 'activesupport'
3
+ gem 'keytar'
4
+
5
+ group :development, :test do
6
+ gem 'yard'
7
+ gem 'rdiscount'
8
+ gem 'rake', '~>0.8.7'
9
+ gem 'jeweler', '~>1.5.2'
10
+ gem "autotest-standalone"
11
+ gem "autotest-growl"
12
+ end
13
+
14
+ group :test do
15
+ gem 'sqlite3', '~> 1.3.3'
16
+ gem 'rspec', '~> 2.5'
17
+ end
@@ -0,0 +1,58 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'rake'
11
+
12
+ require 'jeweler'
13
+ Jeweler::Tasks.new do |gem|
14
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
15
+ gem.name = "method_cacheable"
16
+ gem.homepage = "http://github.com/Schnems/method_cacheable"
17
+ gem.license = "MIT"
18
+ gem.summary = %Q{
19
+ Cache methods quickly and easily.
20
+ }
21
+ gem.description = %Q{
22
+ Cache methods quickly and easily
23
+ }
24
+ gem.email = "richard.schneeman@gmail.com"
25
+ gem.authors = ["Schneems"]
26
+ gem.add_development_dependency "rspec"
27
+
28
+ # Include your dependencies below. Runtime dependencies are required when using your gem,
29
+ # and development dependencies are only needed for development (ie running rake tasks, tests, etc)
30
+ # gem.add_runtime_dependency 'jabber4r', '> 0.1'
31
+ # gem.add_development_dependency 'rspec', '> 1.2.3'
32
+ end
33
+ Jeweler::RubygemsDotOrgTasks.new
34
+
35
+
36
+ # require 'spec/rake/spectask'
37
+ # Spec::Rake::SpecTask.new(:spec) do |spec|
38
+ # spec.libs << 'lib' << 'spec'
39
+ # spec.spec_files = FileList['spec/**/*_spec.rb']
40
+ # end
41
+ #
42
+ # Spec::Rake::SpecTask.new(:rcov) do |spec|
43
+ # spec.libs << 'lib' << 'spec'
44
+ # spec.pattern = 'spec/**/*_spec.rb'
45
+ # spec.rcov = true
46
+ # end
47
+ #
48
+ # task :default => :test
49
+
50
+ # require 'rake/rdoctask'
51
+ # Rake::RDocTask.new do |rdoc|
52
+ # version = File.exist?('VERSION') ? File.read('VERSION') : ""
53
+ #
54
+ # rdoc.rdoc_dir = 'rdoc'
55
+ # rdoc.title = "keytar #{version}"
56
+ # rdoc.rdoc_files.include('README*')
57
+ # rdoc.rdoc_files.include('lib/**/*.rb')
58
+ # end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
@@ -0,0 +1 @@
1
+ Autotest.add_discovery { "rspec2" }
@@ -0,0 +1,345 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6
+ <title>
7
+ Module: JohnnyCache
8
+
9
+ &mdash; Documentation by YARD 0.7.2
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="css/style.css" type="text/css" media="screen" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="css/common.css" type="text/css" media="screen" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ relpath = '';
19
+ if (relpath != '') relpath += '/';
20
+ </script>
21
+
22
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
23
+
24
+ <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
25
+
26
+
27
+ </head>
28
+ <body>
29
+ <script type="text/javascript" charset="utf-8">
30
+ if (window.top.frames.main) document.body.className = 'frames';
31
+ </script>
32
+
33
+ <div id="header">
34
+ <div id="menu">
35
+
36
+ <a href="_index.html">Index (J)</a> &raquo;
37
+
38
+
39
+ <span class="title">JohnnyCache</span>
40
+
41
+
42
+ <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
43
+ </div>
44
+
45
+ <div id="search">
46
+
47
+ <a id="class_list_link" href="#">Class List</a>
48
+
49
+ <a id="method_list_link" href="#">Method List</a>
50
+
51
+ <a id="file_list_link" href="#">File List</a>
52
+
53
+ </div>
54
+ <div class="clear"></div>
55
+ </div>
56
+
57
+ <iframe id="search_frame"></iframe>
58
+
59
+ <div id="content"><h1>Module: JohnnyCache
60
+
61
+
62
+
63
+ </h1>
64
+
65
+ <dl class="box">
66
+
67
+
68
+
69
+ <dt class="r1">Extended by:</dt>
70
+ <dd class="r1">ActiveSupport::Concern</dd>
71
+
72
+
73
+
74
+
75
+
76
+
77
+
78
+ <dt class="r2 last">Defined in:</dt>
79
+ <dd class="r2 last">lib/johnny_cache.rb</dd>
80
+
81
+ </dl>
82
+ <div class="clear"></div>
83
+
84
+ <h2>Overview</h2><div class="docstring">
85
+ <div class="discussion">
86
+ <p>include JohnnyCache</p>
87
+
88
+
89
+ </div>
90
+ </div>
91
+ <div class="tags">
92
+
93
+ <div class="examples">
94
+ <h3>Examples:</h3>
95
+
96
+ <h4><div class='inline'>
97
+ </div></h4>
98
+ <pre class="example code"><span class='class class kw'>class</span> <span class='User constant id'>User</span> <span class='lt op'>&lt;</span> <span class='ActiveRecord constant id'>ActiveRecord</span><span class='colon2 op'>::</span><span class='Base constant id'>Base</span>
99
+ <span class='include identifier id'>include</span> <span class='JohnnyCache constant id'>JohnnyCache</span>
100
+
101
+ <span class='def def kw'>def</span> <span class='expensive_method identifier id'>expensive_method</span><span class='lparen token'>(</span><span class='val identifier id'>val</span><span class='rparen token'>)</span>
102
+ <span class='sleep identifier id'>sleep</span> <span class='integer val'>120</span>
103
+ <span class='return return kw'>return</span> <span class='val identifier id'>val</span>
104
+ <span class='end end kw'>end</span>
105
+ <span class='end end kw'>end</span>
106
+
107
+ <span class='user identifier id'>user</span> <span class='assign token'>=</span> <span class='User constant id'>User</span><span class='dot token'>.</span><span class='last identifier id'>last</span>
108
+
109
+ <span class='user identifier id'>user</span><span class='dot token'>.</span><span class='expensive_method identifier id'>expensive_method</span><span class='lparen token'>(</span><span class='integer val'>22</span><span class='rparen token'>)</span>
110
+ <span class='comment val'># =&gt; 22</span>
111
+ <span class='user identifier id'>user</span><span class='dot token'>.</span><span class='cache identifier id'>cache</span><span class='dot token'>.</span><span class='expensive_method identifier id'>expensive_method</span><span class='lparen token'>(</span><span class='integer val'>22</span><span class='rparen token'>)</span>
112
+ <span class='comment val'># =&gt; 22</span>
113
+
114
+ <span class='Benchmark constant id'>Benchmark</span><span class='dot token'>.</span><span class='measure identifier id'>measure</span> <span class='do do kw'>do</span>
115
+ <span class='user identifier id'>user</span><span class='dot token'>.</span><span class='expensive_method identifier id'>expensive_method</span><span class='lparen token'>(</span><span class='integer val'>22</span><span class='rparen token'>)</span>
116
+ <span class='end end kw'>end</span><span class='dot token'>.</span><span class='real identifier id'>real</span>
117
+ <span class='comment val'># =&gt; 120.00037693977356</span>
118
+
119
+ <span class='Benchmark constant id'>Benchmark</span><span class='dot token'>.</span><span class='measure identifier id'>measure</span> <span class='do do kw'>do</span>
120
+ <span class='user identifier id'>user</span><span class='dot token'>.</span><span class='cache identifier id'>cache</span><span class='dot token'>.</span><span class='expensive_method identifier id'>expensive_method</span><span class='lparen token'>(</span><span class='integer val'>22</span><span class='rparen token'>)</span>
121
+ <span class='end end kw'>end</span><span class='dot token'>.</span><span class='real identifier id'>real</span>
122
+ <span class='comment val'># =&gt; 0.000840902328491211</span>
123
+
124
+ <span class='comment val'># SOOOOOOOO FAST!!</span>
125
+ </pre>
126
+
127
+ </div>
128
+
129
+ <h3>See Also:</h3>
130
+ <ul class="see">
131
+
132
+ <li><span class='object_link'><a href="#cache-instance_method" title="JohnnyCache#cache (method)">More info on cache options</a></span></li>
133
+
134
+ </ul>
135
+
136
+ </div><h2>Defined Under Namespace</h2>
137
+ <p class="children">
138
+
139
+
140
+ <strong class="modules">Modules:</strong> <span class='object_link'><a href="JohnnyCache/ClassMethods.html" title="JohnnyCache::ClassMethods (module)">ClassMethods</a></span>
141
+
142
+
143
+
144
+ <strong class="classes">Classes:</strong> <span class='object_link'><a href="JohnnyCache/MethodCache.html" title="JohnnyCache::MethodCache (class)">MethodCache</a></span>
145
+
146
+
147
+ </p>
148
+
149
+ <h2>Constant Summary</h2>
150
+
151
+ <dl class="constants">
152
+
153
+ <dt id="STORE-constant" class="">STORE =
154
+
155
+ </dt>
156
+ <dd><pre class="code"><span class='nil nil kw'>nil</span> <span class='orop op'>||</span> <span class='Rails constant id'>Rails</span><span class='dot token'>.</span><span class='cache identifier id'>cache</span>
157
+ </pre></dd>
158
+
159
+ </dl>
160
+
161
+
162
+
163
+
164
+
165
+
166
+
167
+
168
+
169
+ <h2>
170
+ Instance Method Summary
171
+ <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
172
+ </h2>
173
+
174
+ <ul class="summary">
175
+
176
+ <li class="public ">
177
+ <span class="summary_signature">
178
+
179
+ <a href="#cache-instance_method" title="#cache (instance method)">- (Object) <strong>cache</strong>(*args) </a>
180
+
181
+
182
+
183
+ </span>
184
+
185
+
186
+
187
+
188
+
189
+
190
+
191
+
192
+ <span class="summary_desc"><div class='inline'>
193
+ </div></span>
194
+
195
+ </li>
196
+
197
+
198
+ </ul>
199
+
200
+
201
+
202
+
203
+
204
+ <div id="instance_method_details" class="method_details_list">
205
+ <h2>Instance Method Details</h2>
206
+
207
+
208
+ <div class="method_details first">
209
+ <p class="signature first" id="cache-instance_method">
210
+
211
+
212
+ <span class="overload">- (<tt>Object</tt>) <strong>cache</strong> </span>
213
+
214
+ <span class="overload">- (<tt>Object</tt>) <strong>cache</strong>(options = {}) </span>
215
+
216
+ <span class="overload">- (<tt>Object</tt>) <strong>cache</strong>(cache_operation = :fetch) </span>
217
+
218
+ <span class="overload">- (<tt>Object</tt>) <strong>cache</strong>(cache_operation = :fetch, options = {}) </span>
219
+
220
+
221
+
222
+
223
+ </p><div class="docstring">
224
+ <div class="discussion">
225
+
226
+
227
+
228
+ </div>
229
+ </div>
230
+ <div class="tags">
231
+
232
+ <div class="examples">
233
+ <h3>Examples:</h3>
234
+
235
+ <h4><div class='inline'>
236
+ </div></h4>
237
+ <pre class="example code"><span class='user identifier id'>user</span> <span class='assign token'>=</span> <span class='User constant id'>User</span><span class='dot token'>.</span><span class='last identifier id'>last</span>
238
+ <span class='comment val'># cache</span>
239
+ <span class='user identifier id'>user</span><span class='dot token'>.</span><span class='cache identifier id'>cache</span><span class='dot token'>.</span><span class='some_method identifier id'>some_method</span>
240
+
241
+ <span class='comment val'># cache(options)</span>
242
+ <span class='user identifier id'>user</span><span class='dot token'>.</span><span class='cache identifier id'>cache</span><span class='lparen token'>(</span><span class='symbol val'>:expires_in</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='float val'>1</span><span class='dot token'>.</span><span class='minutes identifier id'>minutes</span><span class='rparen token'>)</span><span class='dot token'>.</span><span class='some_method identifier id'>some_method</span>
243
+
244
+ <span class='comment val'># cache(cache_operation)</span>
245
+ <span class='user identifier id'>user</span><span class='dot token'>.</span><span class='cache identifier id'>cache</span><span class='lparen token'>(</span><span class='symbol val'>:fetch</span><span class='rparen token'>)</span><span class='dot token'>.</span><span class='some_method identifier id'>some_method</span>
246
+ <span class='user identifier id'>user</span><span class='dot token'>.</span><span class='cache identifier id'>cache</span><span class='lparen token'>(</span><span class='symbol val'>:read</span><span class='rparen token'>)</span><span class='dot token'>.</span><span class='some_method identifier id'>some_method</span>
247
+ <span class='user identifier id'>user</span><span class='dot token'>.</span><span class='cache identifier id'>cache</span><span class='lparen token'>(</span><span class='symbol val'>:write</span><span class='rparen token'>)</span><span class='dot token'>.</span><span class='some_method identifier id'>some_method</span>
248
+
249
+ <span class='comment val'># cache(cache_operation, options)</span>
250
+ <span class='user identifier id'>user</span><span class='dot token'>.</span><span class='cache identifier id'>cache</span><span class='lparen token'>(</span><span class='symbol val'>:write</span><span class='comma token'>,</span> <span class='symbol val'>:expires_in</span> <span class='float val'>2</span><span class='dot token'>.</span><span class='minutes identifier id'>minutes</span><span class='rparen token'>)</span><span class='dot token'>.</span><span class='some_method identifier id'>some_method</span>
251
+ </pre>
252
+
253
+ </div>
254
+
255
+ <h3>Overloads:</h3>
256
+ <ul class="overload">
257
+
258
+
259
+
260
+
261
+
262
+ <li class="overload_item">
263
+ <span class="signature">- (<tt>Object</tt>) <strong>cache</strong>(cache_operation = :fetch, options = {}) </span>
264
+ <div class="docstring">
265
+ <div class="discussion">
266
+ <p>Creates a MethodCache instance that performs the given cache operation on the method it receives</p>
267
+
268
+
269
+ </div>
270
+ </div>
271
+ <div class="tags">
272
+ <h3>Parameters:</h3>
273
+ <ul class="param">
274
+
275
+ <li>
276
+
277
+ <span class='name'>cache_operation</span>
278
+
279
+
280
+ <span class='type'>(<tt>Symbol</tt>)</span>
281
+
282
+
283
+
284
+ &mdash;
285
+ <div class='inline'><p>(:fetch) The method called on the cache (:write, :read, or :fetch)</p>
286
+ </div>
287
+
288
+ </li>
289
+
290
+ <li>
291
+
292
+ <span class='name'>options</span>
293
+
294
+
295
+ <span class='type'>(<tt>Hash</tt>)</span>
296
+
297
+
298
+
299
+ &mdash;
300
+ <div class='inline'><p>Optional hash that gets passed to the cache store</p>
301
+ </div>
302
+
303
+ </li>
304
+
305
+ </ul>
306
+
307
+ </div>
308
+ </li>
309
+
310
+ </ul>
311
+
312
+ </div><table class="source_code">
313
+ <tr>
314
+ <td>
315
+ <pre class="lines">
316
+
317
+
318
+ 69
319
+ 70
320
+ 71</pre>
321
+ </td>
322
+ <td>
323
+ <pre class="code"><span class="info file"># File 'lib/johnny_cache.rb', line 69</span>
324
+
325
+ <span class='def def kw'>def</span> <span class='cache identifier id'>cache</span><span class='lparen token'>(</span><span class='mult op'>*</span><span class='args identifier id'>args</span><span class='rparen token'>)</span>
326
+ <span class='MethodCache constant id'>MethodCache</span><span class='dot token'>.</span><span class='new identifier id'>new</span><span class='lparen token'>(</span><span class='self self kw'>self</span><span class='comma token'>,</span> <span class='mult op'>*</span><span class='args identifier id'>args</span><span class='rparen token'>)</span>
327
+ <span class='end end kw'>end</span>
328
+ </pre>
329
+ </td>
330
+ </tr>
331
+ </table>
332
+ </div>
333
+
334
+ </div>
335
+
336
+ </div>
337
+
338
+ <div id="footer">
339
+ Generated on Sun Aug 7 21:40:15 2011 by
340
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
341
+ 0.7.2 (ruby-1.8.7).
342
+ </div>
343
+
344
+ </body>
345
+ </html>