blankslate 3.1.2 → 3.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZjhmM2YyZDliYjI4MjBkZGUyNzg1NGZjOGQyZmYyNDMyYmJhMzExYQ==
5
+ data.tar.gz: !binary |-
6
+ YjQyMDIwZDJlN2Q5YzMzNTE0M2ZkYzJlMjYyMGUxYTIwY2Y0MWM2NQ==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ ZTc5ZjI3YjA0Mzg5OTIyNmJmZjQzOWJkMjcwYmQxZjFiYWIzNWVmYTJkN2I2
10
+ YzYxZDVmMDQ2NjNlODc0NGNkN2U2MThiMmMwODY2Y2QwNWM5MGZhYjgxYTU0
11
+ YzlkY2Q2MDFhNjA4ZDkzNmJlMWY2NGUyMWRmYzkzZDVjMGMwZDk=
12
+ data.tar.gz: !binary |-
13
+ YzgwOGY1NDk5ODI4ZjNmODdjMmZkM2MwYmU5NmQzMmQ2ZmY4NmZlNWU5NjA1
14
+ ZTFkN2UyN2RlOTA4NjA2NTUxYzY5OGU1NjU4NDE0ZTI2ZDIzN2I5OTFiZGM4
15
+ N2E0MjRhMWQ5ZWQ2YThlMTRjM2Y1MWU0NjYyYzQ4OGViMjIxZTg=
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org/'
2
+
3
+ group :development do
4
+ gem 'rspec'
5
+ end
6
+
@@ -0,0 +1,22 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ diff-lcs (1.2.5)
5
+ rspec (3.0.0)
6
+ rspec-core (~> 3.0.0)
7
+ rspec-expectations (~> 3.0.0)
8
+ rspec-mocks (~> 3.0.0)
9
+ rspec-core (3.0.1)
10
+ rspec-support (~> 3.0.0)
11
+ rspec-expectations (3.0.1)
12
+ diff-lcs (>= 1.2.0, < 2.0)
13
+ rspec-support (~> 3.0.0)
14
+ rspec-mocks (3.0.1)
15
+ rspec-support (~> 3.0.0)
16
+ rspec-support (3.0.0)
17
+
18
+ PLATFORMS
19
+ ruby
20
+
21
+ DEPENDENCIES
22
+ rspec
@@ -1,4 +1,4 @@
1
- Copyright (c) 2003-2012 Jim Weirich (jim.weirich@gmail.com)
1
+ Copyright 2011 Jim Weirich (jim@weirichhouse.org)
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README ADDED
@@ -0,0 +1,31 @@
1
+ BlankSlate
2
+ ===
3
+
4
+ BlankSlate provides an abstract base class with no predefined
5
+ methods (except for <tt>\_\_send__</tt> and <tt>\_\_id__</tt>).
6
+ BlankSlate is useful as a base class when writing classes that
7
+ depend upon <tt>method_missing</tt> (e.g. dynamic proxies).
8
+
9
+ Copyright 2004, 2006 by Jim Weirich (jim@weirichhouse.org).
10
+ All rights reserved.
11
+
12
+
13
+ Extracted from Builder because, for no conceivable reason,
14
+ blankslate isn't in its own gem. Gemified by David Masover,
15
+ moved to gemcutter by Jack Danger Canty (gemcutter@6brand.com
16
+ if you'd like to own this gem).
17
+
18
+ Explanation on extraction from David Masover:
19
+
20
+ So, Builder seems to have the most complete implementation of
21
+ BlankSlate, short of Ruby 1.9's BasicObject. The problem is,
22
+ this is part of Builder, and still inside the Builder gem.
23
+
24
+ It's especially frustrating, because the Builder source
25
+ (lib/builder/blankslate.rb) seems to acknowledge that there
26
+ should be a separate gem. But the only reference I can find
27
+ refers to onestepback.org's gem repository, which isn't working.
28
+
29
+ So I built my own. I'll try to keep it up to date with Builder.
30
+ The first three parts of the version number are
31
+ the Builder version; the last part is my revision.
data/Rakefile CHANGED
@@ -1,189 +1,13 @@
1
- # Rakefile for rake -*- ruby -*-
2
1
 
3
- # Copyright 2004, 2005, 2006 by Jim Weirich (jim@weirichhouse.org).
4
- # All rights reserved.
2
+ require 'bundler'
3
+ Bundler::GemHelper.install_tasks
5
4
 
6
- # Permission is granted for use, copying, modification, distribution,
7
- # and distribution of modified versions of this work as long as the
8
- # above copyright notice is included.
5
+ task :default => :spec
9
6
 
10
- require 'rake/clean'
11
7
  require 'rake/testtask'
12
- require 'rdoc/task'
13
- begin
14
- require 'rubygems'
15
- require 'rubygems/package_task'
16
- rescue Exception
17
- nil
18
- end
19
-
20
- require './lib/builder/version'
21
-
22
- # Determine the current version of the software
23
-
24
- CLOBBER.include('pkg')
25
- CLEAN.include('pkg/builder-*').include('pkg/blankslate-*').exclude('pkg/*.gem')
26
-
27
- PKG_VERSION = Builder::VERSION
28
-
29
- SRC_RB = FileList['lib/**/*.rb']
30
-
31
- # The default task is run if rake is given no explicit arguments.
32
-
33
- desc "Default Task"
34
- task :default => :test_all
35
-
36
- # Test Tasks ---------------------------------------------------------
37
-
38
- desc "Run all tests"
39
- task :test_all => [:test_units]
40
- task :ta => [:test_all]
41
-
42
- task :tu => [:test_units]
43
-
44
- Rake::TestTask.new("test_units") do |t|
45
- t.test_files = FileList['test/test*.rb']
46
- t.libs << "."
47
- t.verbose = false
48
- end
49
-
50
- # Create a task to build the RDOC documentation tree.
51
-
52
- rd = RDoc::Task.new("rdoc") { |rdoc|
53
- rdoc.rdoc_dir = 'html'
54
- rdoc.title = "Builder for Markup"
55
- rdoc.options << '--line-numbers' << '--inline-source' << '--main' << 'README.rdoc'
56
- rdoc.rdoc_files.include('lib/**/*.rb', '[A-Z]*', 'doc/**/*.rdoc').exclude("TAGS")
57
- rdoc.template = 'doc/jamis.rb'
58
- }
59
-
60
- # ====================================================================
61
- # Create a task that will package the Rake software into distributable
62
- # gem files.
63
-
64
- PKG_FILES = FileList[
65
- 'lib/**/*.rb',
66
- 'test/**/*.rb',
67
- 'scripts/**/*.rb'
68
- ]
69
- PKG_FILES.exclude('test/test_cssbuilder.rb')
70
- PKG_FILES.exclude('lib/builder/css.rb')
71
- PKG_FILES.exclude('TAGS')
72
-
73
- BLANKSLATE_FILES = FileList[
74
- 'lib/blankslate.rb',
75
- 'test/test_blankslate.rb'
76
- ]
77
-
78
- if ! defined?(Gem)
79
- puts "Package Target requires RubyGEMs"
80
- else
81
- spec = Gem::Specification.new do |s|
82
-
83
- #### Basic information.
84
-
85
- s.name = 'builder'
86
- s.version = PKG_VERSION
87
- s.summary = "Builders for MarkUp."
88
- s.description = %{\
89
- Builder provides a number of builder objects that make creating structured data
90
- simple to do. Currently the following builder objects are supported:
91
-
92
- * XML Markup
93
- * XML Events
94
- }
95
-
96
- s.files = PKG_FILES.to_a
97
- s.require_path = 'lib'
98
-
99
- s.test_files = PKG_FILES.select { |fn| fn =~ /^test\/test/ }
100
-
101
- s.has_rdoc = true
102
- s.extra_rdoc_files = rd.rdoc_files.reject { |fn| fn =~ /\.rb$/ }.to_a
103
- s.rdoc_options <<
104
- '--title' << 'Builder -- Easy XML Building' <<
105
- '--main' << 'README.rdoc' <<
106
- '--line-numbers'
107
-
108
- s.author = "Jim Weirich"
109
- s.email = "jim.weirich@gmail.com"
110
- s.homepage = "http://onestepback.org"
111
- s.license = 'MIT'
112
- end
113
-
114
- blankslate_spec = Gem::Specification.new do |s|
115
-
116
- #### Basic information.
117
-
118
- s.name = 'blankslate'
119
- s.version = PKG_VERSION
120
- s.summary = "Blank Slate base class."
121
- s.description = %{\
122
- BlankSlate provides a base class where almost all of the methods from Object and
123
- Kernel have been removed. This is useful when providing proxy object and other
124
- classes that make heavy use of method_missing.
125
- }
126
-
127
- s.files = BLANKSLATE_FILES.to_a
128
- s.require_path = 'lib'
129
-
130
- s.test_files = PKG_FILES.select { |fn| fn =~ /^test\/test/ }
131
-
132
- s.has_rdoc = true
133
- s.extra_rdoc_files = rd.rdoc_files.reject { |fn| fn =~ /\.rb$/ }.to_a
134
- s.rdoc_options <<
135
- '--title' << 'BlankSlate -- Base Class for building proxies.' <<
136
- '--main' << 'README.rdoc' <<
137
- '--line-numbers'
138
-
139
- s.author = "Jim Weirich"
140
- s.email = "jim.weirich@gmail.com"
141
- s.homepage = "http://onestepback.org"
142
- s.license = 'MIT'
143
- end
144
-
145
- namespace 'builder' do
146
- Gem::PackageTask.new(spec) do |t|
147
- t.need_tar = false
148
- end
149
- end
150
-
151
- namespace 'blankslate' do
152
- Gem::PackageTask.new(blankslate_spec) do |t|
153
- t.need_tar = false
154
- end
155
- end
156
-
157
- task :package => [:remove_tags, 'builder:package', 'blankslate:package']
158
- end
159
-
160
- task :remove_tags do
161
- rm "TAGS" rescue nil
162
- end
163
-
164
- # RCov ---------------------------------------------------------------
165
- begin
166
- require 'rcov/rcovtask'
167
-
168
- Rcov::RcovTask.new do |t|
169
- t.libs << "test"
170
- t.rcov_opts = [
171
- '-xRakefile', '--text-report'
172
- ]
173
- t.test_files = FileList[
174
- 'test/test*.rb'
175
- ]
176
- t.output_dir = 'coverage'
177
- t.verbose = true
178
- end
179
- rescue LoadError
180
- # No rcov available
181
- end
182
-
183
- desc "Install the jamis RDoc template"
184
- task :install_jamis_template do
185
- require 'rbconfig'
186
- dest_dir = File.join(Config::CONFIG['rubylibdir'], "rdoc/generators/template/html")
187
- fail "Unabled to write to #{dest_dir}" unless File.writable?(dest_dir)
188
- install "doc/jamis.rb", dest_dir, :verbose => true
8
+ Rake::TestTask.new(:spec) do |test|
9
+ test.libs << '.'
10
+ test.ruby_opts = ['-rubygems']
11
+ test.pattern = 'spec/*_spec.rb'
12
+ test.verbose = true
189
13
  end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 3.1.3
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "blankslate"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "blankslate"
7
+ s.version = File.read('VERSION')
8
+ s.platform = Gem::Platform::RUBY
9
+ s.summary = 'BlankSlate extracted from Builder.'
10
+ s.email = 'rubygems@6brand.com'
11
+ s.authors = ['Jim Weirich', 'David Masover', 'Jack Danger Canty']
12
+ s.email = "rubygems@6brand.com"
13
+ s.homepage = "http://github.com/masover/blankslate"
14
+
15
+ s.add_development_dependency 'rspec'
16
+ s.add_development_dependency 'bundler'
17
+
18
+ s.files = `git ls-files`.split("\n")
19
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
20
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
21
+ s.require_paths = ["lib"]
22
+ end
@@ -44,12 +44,16 @@ class BlankSlate
44
44
  # Hide the method named +name+ in the BlankSlate class. Don't
45
45
  # hide +instance_eval+ or any method beginning with "__".
46
46
  def hide(name)
47
- if instance_methods.include?(name._blankslate_as_name) and
48
- name !~ /^(__|instance_eval$)/
47
+ warn_level = $VERBOSE
48
+ $VERBOSE = nil
49
+ if instance_methods.include?(name._blankslate_as_name) &&
50
+ name !~ /^(__|instance_eval|object_id$)/
49
51
  @hidden_methods ||= {}
50
52
  @hidden_methods[name.to_sym] = instance_method(name)
51
53
  undef_method name
52
54
  end
55
+ ensure
56
+ $VERBOSE = warn_level
53
57
  end
54
58
 
55
59
  def find_hidden_method(name)
@@ -0,0 +1,54 @@
1
+ require 'blankslate'
2
+ require 'rspec'
3
+
4
+ describe BlankSlate do
5
+
6
+ RSPEC_MOCK_METHODS = [
7
+ "as_null_object",
8
+ "null_object?",
9
+ "received_message?",
10
+ "should",
11
+ "should_not",
12
+ "should_not_receive",
13
+ "should_receive",
14
+ "stub",
15
+ "stub_chain",
16
+ "unstub"
17
+ ]
18
+
19
+ let(:blank_slate) { BlankSlate.new }
20
+
21
+ def call(obj, meth, *args)
22
+ BlankSlate.find_hidden_method(meth).bind(obj).call(*args)
23
+ end
24
+
25
+ describe "cleanliness" do
26
+ it "should not have many methods" do
27
+ methods = BlankSlate.instance_methods.map(&:to_s)
28
+ (methods - RSPEC_MOCK_METHODS.sort).should =~ [
29
+ "__id__", "__send__", "instance_eval", "object_id"
30
+ ]
31
+ end
32
+ end
33
+
34
+ context "when methods are added to Object" do
35
+ after(:each) {
36
+ class Object
37
+ undef :foo
38
+ end
39
+ }
40
+
41
+ it "should still be blank" do
42
+ class Object
43
+ def foo
44
+ end
45
+ end
46
+ Object.new.foo
47
+
48
+ lambda {
49
+ BlankSlate.new.foo
50
+ }.should raise_error(NoMethodError)
51
+ end
52
+
53
+ end
54
+ end
metadata CHANGED
@@ -1,97 +1,83 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: blankslate
3
- version: !ruby/object:Gem::Version
4
- hash: 7
5
- prerelease:
6
- segments:
7
- - 3
8
- - 1
9
- - 2
10
- version: 3.1.2
3
+ version: !ruby/object:Gem::Version
4
+ version: 3.1.3
11
5
  platform: ruby
12
- authors:
6
+ authors:
13
7
  - Jim Weirich
8
+ - David Masover
9
+ - Jack Danger Canty
14
10
  autorequire:
15
11
  bindir: bin
16
12
  cert_chain: []
17
-
18
- date: 2012-09-07 00:00:00 Z
19
- dependencies: []
20
-
21
- description: |
22
- BlankSlate provides a base class where almost all of the methods from Object and
23
- Kernel have been removed. This is useful when providing proxy object and other
24
- classes that make heavy use of method_missing.
25
-
26
- email: jim.weirich@gmail.com
13
+ date: 2014-06-18 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rspec
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - ! '>='
27
+ - !ruby/object:Gem::Version
28
+ version: '0'
29
+ - !ruby/object:Gem::Dependency
30
+ name: bundler
31
+ requirement: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - ! '>='
34
+ - !ruby/object:Gem::Version
35
+ version: '0'
36
+ type: :development
37
+ prerelease: false
38
+ version_requirements: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ! '>='
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
43
+ description:
44
+ email: rubygems@6brand.com
27
45
  executables: []
28
-
29
46
  extensions: []
30
-
31
- extra_rdoc_files:
32
- - CHANGES
47
+ extra_rdoc_files: []
48
+ files:
49
+ - Gemfile
50
+ - Gemfile.lock
33
51
  - MIT-LICENSE
52
+ - README
34
53
  - Rakefile
35
- - README.rdoc
36
- - doc/releases/builder-1.2.4.rdoc
37
- - doc/releases/builder-2.0.0.rdoc
38
- - doc/releases/builder-2.1.1.rdoc
39
- files:
54
+ - VERSION
55
+ - blankslate.gemspec
40
56
  - lib/blankslate.rb
41
- - test/test_blankslate.rb
42
- - test/test_eventbuilder.rb
43
- - test/test_markupbuilder.rb
44
- - test/test_method_caching.rb
45
- - test/test_namecollision.rb
46
- - test/test_xchar.rb
47
- - CHANGES
48
- - MIT-LICENSE
49
- - Rakefile
50
- - README.rdoc
51
- - doc/releases/builder-1.2.4.rdoc
52
- - doc/releases/builder-2.0.0.rdoc
53
- - doc/releases/builder-2.1.1.rdoc
54
- homepage: http://onestepback.org
55
- licenses:
56
- - MIT
57
+ - spec/blankslate_spec.rb
58
+ homepage: http://github.com/masover/blankslate
59
+ licenses: []
60
+ metadata: {}
57
61
  post_install_message:
58
- rdoc_options:
59
- - --title
60
- - BlankSlate -- Base Class for building proxies.
61
- - --main
62
- - README.rdoc
63
- - --line-numbers
64
- require_paths:
62
+ rdoc_options: []
63
+ require_paths:
65
64
  - lib
66
- required_ruby_version: !ruby/object:Gem::Requirement
67
- none: false
68
- requirements:
69
- - - ">="
70
- - !ruby/object:Gem::Version
71
- hash: 3
72
- segments:
73
- - 0
74
- version: "0"
75
- required_rubygems_version: !ruby/object:Gem::Requirement
76
- none: false
77
- requirements:
78
- - - ">="
79
- - !ruby/object:Gem::Version
80
- hash: 3
81
- segments:
82
- - 0
83
- version: "0"
65
+ required_ruby_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ! '>='
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
84
75
  requirements: []
85
-
86
76
  rubyforge_project:
87
- rubygems_version: 1.8.23
77
+ rubygems_version: 2.2.2
88
78
  signing_key:
89
- specification_version: 3
90
- summary: Blank Slate base class.
91
- test_files:
92
- - test/test_blankslate.rb
93
- - test/test_eventbuilder.rb
94
- - test/test_markupbuilder.rb
95
- - test/test_method_caching.rb
96
- - test/test_namecollision.rb
97
- - test/test_xchar.rb
79
+ specification_version: 4
80
+ summary: BlankSlate extracted from Builder.
81
+ test_files:
82
+ - spec/blankslate_spec.rb
83
+ has_rdoc: