Permalink
Browse files

gem-this

  • Loading branch information...
1 parent 06ee8cf commit 1a79d50c927039b900fa9cc574a2020ed78fa053 @matthewrudy committed Dec 7, 2011
Showing with 179 additions and 0 deletions.
  1. +1 −0 .gitignore
  2. +54 −0 README.md
  3. +97 −0 Rakefile
  4. +27 −0 memoizer.gemspec
View
@@ -0,0 +1 @@
+pkg/
View
@@ -0,0 +1,54 @@
+Memoizer
+=============
+
+Memoizer is an extraction of ActiveSupport::Memoizable.
+
+Since June 2011 ActiveSupport::Memoizable has been deprecated.
+But I love it,
+and so I plan to keep it alive.
+
+Usage
+-----
+
+Just extend with the Memoizer module
+
+ require 'memoizer'
+ class Person
+ extend Memoizer
+
+ def social_security
+ decrypt_social_security
+ end
+ memoize :social_security
+ end
+
+And person.social_security will only be calculated once.
+
+You can even do it with a method that takes arguments.
+
+
+ class Person
+ def taxes_due(income)
+ income * 0.40
+ end
+ memoize :taxes_due
+ end
+
+This will only be calculated once per value of income.
+
+Authors
+===========
+
+Everyone who contributed to it in the rails repository.
+
+* Joshua Peek
+* Tarmo Tänav
+* Jeremy Kemper
+* Eugene Pimenov
+* Xavier Noria
+* Niels Ganser
+* Carl Lerche & Yehuda Katz
+* jeem
+* Jay Pignata
+* Damien Mathieu
+* José Valim
View
@@ -0,0 +1,97 @@
+# encoding: utf-8
+require "rubygems"
+require "rubygems/package_task"
+require "rdoc/task"
+
+require "rake/testtask"
+Rake::TestTask.new do |t|
+ t.libs << "test"
+ t.test_files = FileList["test/**/*_test.rb"]
+ t.verbose = true
+end
+
+
+task :default => ["test"]
+
+# This builds the actual gem. For details of what all these options
+# mean, and other ones you can add, check the documentation here:
+#
+# http://rubygems.org/read/chapter/20
+#
+
+AUTHORS = [
+ ["Joshua Peek", "josh@joshpeek.com"],
+ ["Tarmo Tänav", "tarmo@itech.ee"],
+ ["Jeremy Kemper", "jeremy@bitsweat.net"],
+ ["Eugene Pimenov", "libc@mac.com"],
+ ["Xavier Noria", "fxn@hashref.com"],
+ ["Niels Ganser", "niels@herimedia.co"],
+ ["Carl Lerche & Yehuda Katz", "wycats@gmail.com"],
+ ["jeem", "jeem@hughesorama.com"],
+ ["Jay Pignata", "john.pignata@gmail.com"],
+ ["Damien Mathieu", "42@dmathieu.com"],
+ ["José Valim", "jose.valim@gmail.com"],
+]
+
+spec = Gem::Specification.new do |s|
+
+ # Change these as appropriate
+ s.name = "memoizer"
+ s.version = "0.1.0"
+ s.summary = "memoize methods invocation"
+ s.authors = AUTHORS.map{ |name, email| name }
+ s.email = AUTHORS.map{ |name, email| email }
+ s.homepage = "https://github.com/matthewrudy/memoizable"
+
+ s.has_rdoc = true
+ # You should probably have a README of some kind. Change the filename
+ # as appropriate
+ s.extra_rdoc_files = %w(README.md)
+ s.rdoc_options = %w(--main README.md)
+
+ # Add any extra files to include in the gem (like your README)
+ s.files = %w(README.md) + Dir.glob("{test,lib}/**/*")
+ s.require_paths = ["lib"]
+
+ # If you want to depend on other gems, add them here, along with any
+ # relevant versions
+ # s.add_dependency("some_other_gem", "~> 0.1.0")
+
+ # If your tests use any gems, include them here
+ # s.add_development_dependency("mocha") # for example
+end
+
+# This task actually builds the gem. We also regenerate a static
+# .gemspec file, which is useful if something (i.e. GitHub) will
+# be automatically building a gem for this project. If you're not
+# using GitHub, edit as appropriate.
+#
+# To publish your gem online, install the 'gemcutter' gem; Read more
+# about that here: http://gemcutter.org/pages/gem_docs
+Gem::PackageTask.new(spec) do |pkg|
+ pkg.gem_spec = spec
+end
+
+desc "Build the gemspec file #{spec.name}.gemspec"
+task :gemspec do
+ file = File.dirname(__FILE__) + "/#{spec.name}.gemspec"
+ File.open(file, "w") {|f| f << spec.to_ruby }
+end
+
+# If you don't want to generate the .gemspec file, just remove this line. Reasons
+# why you might want to generate a gemspec:
+# - using bundler with a git source
+# - building the gem without rake (i.e. gem build blah.gemspec)
+# - maybe others?
+task :package => :gemspec
+
+# Generate documentation
+RDoc::Task.new do |rd|
+ rd.rdoc_files.include("lib/**/*.rb")
+ rd.rdoc_dir = "rdoc"
+end
+
+desc 'Clear out RDoc and generated packages'
+task :clean => [:clobber_rdoc, :clobber_package] do
+ rm "#{spec.name}.gemspec"
+end
View
@@ -0,0 +1,27 @@
+# -*- encoding: utf-8 -*-
+
+Gem::Specification.new do |s|
+ s.name = "memoizer"
+ s.version = "0.1.0"
+
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
+ s.authors = ["Joshua Peek", "Tarmo T\u{e4}nav", "Jeremy Kemper", "Eugene Pimenov", "Xavier Noria", "Niels Ganser", "Carl Lerche & Yehuda Katz", "jeem", "Jay Pignata", "Damien Mathieu", "Jos\u{e9} Valim"]
+ s.date = "2011-12-07"
+ s.email = ["josh@joshpeek.com", "tarmo@itech.ee", "jeremy@bitsweat.net", "libc@mac.com", "fxn@hashref.com", "niels@herimedia.co", "wycats@gmail.com", "jeem@hughesorama.com", "john.pignata@gmail.com", "42@dmathieu.com", "jose.valim@gmail.com"]
+ s.extra_rdoc_files = ["README.md"]
+ s.files = ["README.md", "test/memoizer_test.rb", "test/test_helper.rb", "lib/core_ext/singleton_class.rb", "lib/memoizer.rb"]
+ s.homepage = "https://github.com/matthewrudy/memoizable"
+ s.rdoc_options = ["--main", "README.md"]
+ s.require_paths = ["lib"]
+ s.rubygems_version = "1.8.10"
+ s.summary = "memoize methods invocation"
+
+ if s.respond_to? :specification_version then
+ s.specification_version = 3
+
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
+ else
+ end
+ else
+ end
+end

0 comments on commit 1a79d50

Please sign in to comment.