shitcan 0.1

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.
data/README.textile ADDED
@@ -0,0 +1,31 @@
1
+ h1. Shit Can
2
+
3
+ __A teeny-tiny wrapper for the memcached gem that makes partial caching so easy a monkey could do it__
4
+
5
+ *Some method somewhere*
6
+
7
+ ==
8
+ <pre>
9
+ def some_controller_action
10
+ ShitCan.skip_if_exists("#{params[:id]}_save_me") do
11
+ @blah = User.find_by_login(params[:id])
12
+ @items = Ass.timeline(@dj.id.to_s)
13
+ @items.some_cpu_heavy_command_and_database_heavy_command
14
+ end
15
+ end
16
+ </pre>
17
+ ==
18
+
19
+ *Some view somewhere*
20
+
21
+ <pre>
22
+ <% ShitCan.get_or_set "#{params[:id]}_save_me" do %>
23
+ <% @items.each do |item| %>
24
+ <li class="activity_feed_<%= item[1]['type'] %> clear">
25
+ <div class="feed_item_body">
26
+ <%= item.some.heavy.associations.lookup %>
27
+ </div>
28
+ </li>
29
+ <% end %>
30
+ <% end %>
31
+ </pre>
data/Rakefile ADDED
@@ -0,0 +1,24 @@
1
+ require 'rubygems'
2
+ require 'rake/testtask'
3
+
4
+ task :default => [:test]
5
+
6
+ task :test do
7
+ ruby "test/test_suite.rb"
8
+ end
9
+
10
+ spec = Gem::Specification.new do |s|
11
+ s.name = 'shitcan'
12
+ s.version = '0.1'
13
+ s.summary = "Ultra lightweight wrapper for the memcached gem"
14
+ s.description = %{Ultra lightweight wrapper for the memcached gem. Allows for stupidly simple partial caching, code block skipping, memcache fun.}
15
+ s.files = Dir['lib/**/*.rb'] + Dir['test/**/*.rb'] - Dir['test/test_config.yml']
16
+ s.require_path = 'lib'
17
+ s.autorequire = 'builder'
18
+ s.has_rdoc = true
19
+ s.extra_rdoc_files = Dir['[A-Z]*']
20
+ s.rdoc_options << '--title' << 'Shitcan'
21
+ s.author = "Tyler Love"
22
+ s.email = "git@tylr.org"
23
+ s.homepage = "http://github.com/tylr/shitcan"
24
+ end
data/lib/shit_can.rb ADDED
@@ -0,0 +1,40 @@
1
+ module ShitCan
2
+ require 'memcached'
3
+
4
+ def self.load(con_path='localhost:11211')
5
+ @cache = Memcached.new(con_path)
6
+ end
7
+
8
+ def self.cache
9
+ if @cache
10
+ return @cache
11
+ else
12
+ raise ShitCan, 'NO CAN HERE!'
13
+ end
14
+ end
15
+
16
+ def self.set *args
17
+ cache.set *args
18
+ end
19
+
20
+ def self.get *args
21
+ cache.get *args
22
+ end
23
+
24
+ def self.get_if_exists *args
25
+ get *args if exists?
26
+ end
27
+
28
+ def self.skip_if_exists key
29
+ yield unless exists? key
30
+ end
31
+
32
+ def self.exists? key
33
+ begin
34
+ get key
35
+ return true
36
+ rescue
37
+ return false
38
+ end
39
+ end
40
+ end
@@ -0,0 +1 @@
1
+ # Write tests
@@ -0,0 +1 @@
1
+ # Write tests
metadata ADDED
@@ -0,0 +1,85 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: shitcan
3
+ version: !ruby/object:Gem::Version
4
+ hash: 9
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 1
9
+ version: "0.1"
10
+ platform: ruby
11
+ authors:
12
+ - Tyler Love
13
+ autorequire: builder
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-09-23 00:00:00 -04:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: memcached
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 1
29
+ segments:
30
+ - 1
31
+ version: "1"
32
+ type: :runtime
33
+ version_requirements: *id001
34
+ description: Ultra lightweight wrapper for the memcached gem. Allows for stupidly simple partial caching, code block skipping, memcache fun.
35
+ email: git@tylr.org
36
+ executables: []
37
+
38
+ extensions: []
39
+
40
+ extra_rdoc_files:
41
+ - Rakefile
42
+ - README.textile
43
+ files:
44
+ - lib/shit_can.rb
45
+ - test/test_helper.rb
46
+ - test/test_suite.rb
47
+ - Rakefile
48
+ - README.textile
49
+ has_rdoc: true
50
+ homepage: http://github.com/tylr/shitcan
51
+ licenses: []
52
+
53
+ post_install_message:
54
+ rdoc_options:
55
+ - --title
56
+ - Shitcan
57
+ require_paths:
58
+ - lib
59
+ required_ruby_version: !ruby/object:Gem::Requirement
60
+ none: false
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ hash: 3
65
+ segments:
66
+ - 0
67
+ version: "0"
68
+ required_rubygems_version: !ruby/object:Gem::Requirement
69
+ none: false
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ hash: 3
74
+ segments:
75
+ - 0
76
+ version: "0"
77
+ requirements: []
78
+
79
+ rubyforge_project:
80
+ rubygems_version: 1.3.7
81
+ signing_key:
82
+ specification_version: 3
83
+ summary: Ultra lightweight wrapper for the memcached gem
84
+ test_files: []
85
+