blankslate-3.1.3/0000755000004100000410000000000012352212225013662 5ustar www-datawww-datablankslate-3.1.3/Rakefile0000644000004100000410000000037112352212225015330 0ustar www-datawww-data require 'bundler' Bundler::GemHelper.install_tasks task :default => :spec require 'rake/testtask' Rake::TestTask.new(:spec) do |test| test.libs << '.' test.ruby_opts = ['-rubygems'] test.pattern = 'spec/*_spec.rb' test.verbose = true end blankslate-3.1.3/Gemfile.lock0000644000004100000410000000067712352212225016116 0ustar www-datawww-dataGEM remote: https://rubygems.org/ specs: diff-lcs (1.2.5) rspec (3.0.0) rspec-core (~> 3.0.0) rspec-expectations (~> 3.0.0) rspec-mocks (~> 3.0.0) rspec-core (3.0.1) rspec-support (~> 3.0.0) rspec-expectations (3.0.1) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.0.0) rspec-mocks (3.0.1) rspec-support (~> 3.0.0) rspec-support (3.0.0) PLATFORMS ruby DEPENDENCIES rspec blankslate-3.1.3/Gemfile0000644000004100000410000000011112352212225015146 0ustar www-datawww-datasource 'https://rubygems.org/' group :development do gem 'rspec' end blankslate-3.1.3/MIT-LICENSE0000644000004100000410000000206212352212225015316 0ustar www-datawww-dataCopyright 2011 Jim Weirich (jim@weirichhouse.org) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. blankslate-3.1.3/blankslate.gemspec0000644000004100000410000000145512352212225017354 0ustar www-datawww-data# -*- encoding: utf-8 -*- $:.push File.expand_path("../lib", __FILE__) require "blankslate" Gem::Specification.new do |s| s.name = "blankslate" s.version = File.read('VERSION') s.platform = Gem::Platform::RUBY s.summary = 'BlankSlate extracted from Builder.' s.email = 'rubygems@6brand.com' s.authors = ['Jim Weirich', 'David Masover', 'Jack Danger Canty'] s.email = "rubygems@6brand.com" s.homepage = "http://github.com/masover/blankslate" s.add_development_dependency 'rspec' s.add_development_dependency 'bundler' s.files = `git ls-files`.split("\n") s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } s.require_paths = ["lib"] end blankslate-3.1.3/README0000644000004100000410000000225512352212225014546 0ustar www-datawww-dataBlankSlate === BlankSlate provides an abstract base class with no predefined methods (except for \_\_send__ and \_\_id__). BlankSlate is useful as a base class when writing classes that depend upon method_missing (e.g. dynamic proxies). Copyright 2004, 2006 by Jim Weirich (jim@weirichhouse.org). All rights reserved. Extracted from Builder because, for no conceivable reason, blankslate isn't in its own gem. Gemified by David Masover, moved to gemcutter by Jack Danger Canty (gemcutter@6brand.com if you'd like to own this gem). Explanation on extraction from David Masover: So, Builder seems to have the most complete implementation of BlankSlate, short of Ruby 1.9's BasicObject. The problem is, this is part of Builder, and still inside the Builder gem. It's especially frustrating, because the Builder source (lib/builder/blankslate.rb) seems to acknowledge that there should be a separate gem. But the only reference I can find refers to onestepback.org's gem repository, which isn't working. So I built my own. I'll try to keep it up to date with Builder. The first three parts of the version number are the Builder version; the last part is my revision.blankslate-3.1.3/spec/0000755000004100000410000000000012352212225014614 5ustar www-datawww-datablankslate-3.1.3/spec/blankslate_spec.rb0000644000004100000410000000177312352212225020303 0ustar www-datawww-datarequire 'blankslate' require 'rspec' describe BlankSlate do RSPEC_MOCK_METHODS = [ "as_null_object", "null_object?", "received_message?", "should", "should_not", "should_not_receive", "should_receive", "stub", "stub_chain", "unstub" ] let(:blank_slate) { BlankSlate.new } def call(obj, meth, *args) BlankSlate.find_hidden_method(meth).bind(obj).call(*args) end describe "cleanliness" do it "should not have many methods" do methods = BlankSlate.instance_methods.map(&:to_s) (methods - RSPEC_MOCK_METHODS.sort).should =~ [ "__id__", "__send__", "instance_eval", "object_id" ] end end context "when methods are added to Object" do after(:each) { class Object undef :foo end } it "should still be blank" do class Object def foo end end Object.new.foo lambda { BlankSlate.new.foo }.should raise_error(NoMethodError) end end end blankslate-3.1.3/lib/0000755000004100000410000000000012352212225014430 5ustar www-datawww-datablankslate-3.1.3/lib/blankslate.rb0000644000004100000410000000741312352212225017102 0ustar www-datawww-data#!/usr/bin/env ruby #-- # Copyright 2004, 2006 by Jim Weirich (jim@weirichhouse.org). # All rights reserved. # Permission is granted for use, copying, modification, distribution, # and distribution of modified versions of this work as long as the # above copyright notice is included. #++ class String if instance_methods.first.is_a?(Symbol) def _blankslate_as_name to_sym end else def _blankslate_as_name self end end end class Symbol if instance_methods.first.is_a?(Symbol) def _blankslate_as_name self end else def _blankslate_as_name to_s end end end ###################################################################### # BlankSlate provides an abstract base class with no predefined # methods (except for \_\_send__ and \_\_id__). # BlankSlate is useful as a base class when writing classes that # depend upon method_missing (e.g. dynamic proxies). # class BlankSlate class << self # Hide the method named +name+ in the BlankSlate class. Don't # hide +instance_eval+ or any method beginning with "__". def hide(name) warn_level = $VERBOSE $VERBOSE = nil if instance_methods.include?(name._blankslate_as_name) && name !~ /^(__|instance_eval|object_id$)/ @hidden_methods ||= {} @hidden_methods[name.to_sym] = instance_method(name) undef_method name end ensure $VERBOSE = warn_level end def find_hidden_method(name) @hidden_methods ||= {} @hidden_methods[name] || superclass.find_hidden_method(name) end # Redefine a previously hidden method so that it may be called on a blank # slate object. def reveal(name) hidden_method = find_hidden_method(name) fail "Don't know how to reveal method '#{name}'" unless hidden_method define_method(name, hidden_method) end end instance_methods.each { |m| hide(m) } end ###################################################################### # Since Ruby is very dynamic, methods added to the ancestors of # BlankSlate after BlankSlate is defined will show up in the # list of available BlankSlate methods. We handle this by defining a # hook in the Object and Kernel classes that will hide any method # defined after BlankSlate has been loaded. # module Kernel class << self alias_method :blank_slate_method_added, :method_added # Detect method additions to Kernel and remove them in the # BlankSlate class. def method_added(name) result = blank_slate_method_added(name) return result if self != Kernel BlankSlate.hide(name) result end end end ###################################################################### # Same as above, except in Object. # class Object class << self alias_method :blank_slate_method_added, :method_added # Detect method additions to Object and remove them in the # BlankSlate class. def method_added(name) result = blank_slate_method_added(name) return result if self != Object BlankSlate.hide(name) result end def find_hidden_method(name) nil end end end ###################################################################### # Also, modules included into Object need to be scanned and have their # instance methods removed from blank slate. In theory, modules # included into Kernel would have to be removed as well, but a # "feature" of Ruby prevents late includes into modules from being # exposed in the first place. # class Module alias blankslate_original_append_features append_features def append_features(mod) result = blankslate_original_append_features(mod) return result if mod != Object instance_methods.each do |name| BlankSlate.hide(name) end result end end blankslate-3.1.3/metadata.yml0000644000004100000410000000344512352212225016173 0ustar www-datawww-data--- !ruby/object:Gem::Specification name: blankslate version: !ruby/object:Gem::Version version: 3.1.3 platform: ruby authors: - Jim Weirich - David Masover - Jack Danger Canty autorequire: bindir: bin cert_chain: [] date: 2014-06-18 00:00:00.000000000 Z dependencies: - !ruby/object:Gem::Dependency name: rspec requirement: !ruby/object:Gem::Requirement requirements: - - ! '>=' - !ruby/object:Gem::Version version: '0' type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - ! '>=' - !ruby/object:Gem::Version version: '0' - !ruby/object:Gem::Dependency name: bundler requirement: !ruby/object:Gem::Requirement requirements: - - ! '>=' - !ruby/object:Gem::Version version: '0' type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - ! '>=' - !ruby/object:Gem::Version version: '0' description: email: rubygems@6brand.com executables: [] extensions: [] extra_rdoc_files: [] files: - Gemfile - Gemfile.lock - MIT-LICENSE - README - Rakefile - VERSION - blankslate.gemspec - lib/blankslate.rb - spec/blankslate_spec.rb homepage: http://github.com/masover/blankslate licenses: [] metadata: {} post_install_message: rdoc_options: [] require_paths: - lib required_ruby_version: !ruby/object:Gem::Requirement requirements: - - ! '>=' - !ruby/object:Gem::Version version: '0' required_rubygems_version: !ruby/object:Gem::Requirement requirements: - - ! '>=' - !ruby/object:Gem::Version version: '0' requirements: [] rubyforge_project: rubygems_version: 2.2.2 signing_key: specification_version: 4 summary: BlankSlate extracted from Builder. test_files: - spec/blankslate_spec.rb has_rdoc: blankslate-3.1.3/VERSION0000644000004100000410000000000612352212225014726 0ustar www-datawww-data3.1.3 blankslate-3.1.3/checksums.yaml.gz0000444000004100000410000000065212352212225017153 0ustar www-datawww-dataɱS1o0w 5 f)K8nSH:2iw||=n͗u-rx==F~oR XOSP݊P6ʮ!ҊVpl/[.%+H(lC C "LVPݝ^HP o*ijwmoRWm l|]({H^'HPh7_{ d0t0BȜL=4@]a0OY rJ9 f~OҔ# 2Sf_ |aayhD+r%50g>XQfu 9QcTW!w5CAf*Bgr1( P4MVfp'ߕ[dk#6~kx