blank_slate 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d98e8ec51e0d5404e761fa84b0b4f7fc65c238a752d747ea4b5ba6f94a3c2c1f
4
- data.tar.gz: dc6643c7f80e4d635133cd1c8b3dfebe9132bf0ee5896f4ad86ba7808112882a
3
+ metadata.gz: 72b84dd5ad01afcfdb026bf9a830120e95a90c095fd362adcbeea433307bedec
4
+ data.tar.gz: a76f1f4e546a0c20a1f91f72b58e4d0b39880bf79ab0a0ac468b4d72513abdf2
5
5
  SHA512:
6
- metadata.gz: 9ac8ea9d6e58504ea64e013a081c692dc5d8b5b4bd870f90445b70380cd3e8b1ddaf26b875690681f9a94ef850afef2707b2505e4d56261f0ce19b722ec9d195
7
- data.tar.gz: 2b725ebbf53bdf4e6c711d3d21f17fdb7d695ae687f93de36ed59709cfcdc7adff7531aedbc82fa157209c4e74d58335cf302f27b2afeca7101db1043466dc86
6
+ metadata.gz: 8da83799e3f060a9f225a4c162c16fd60947cae61e99468e23dfe3fcdfa0d99fb88679776d904b02dae61a254115b10df2c646b532821d18f0539c3cfe946780
7
+ data.tar.gz: 4f4ab28aa58ebd5bb13084111fe4b4f60ddd901f85ac5ac8d9159ea7a9fc706031a20ed2a031eedfe58fb21c3dde462972470081e1c1685fd333494e6600832e
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 1.1.2
2
+
3
+ Minor change to simplify the methods that are iterated when creating the BlankSlate class.
4
+
1
5
  # 1.1.1
2
6
 
3
7
  1.1.0 used method_defined? which has an arity of 2 in Ruby 2.6 but 1 in previous rubies.
data/Gemfile CHANGED
@@ -3,5 +3,8 @@ source 'https://rubygems.org'
3
3
  gemspec
4
4
 
5
5
  group :test do
6
+ gem 'minitest'
7
+ gem 'minitest-allow'
8
+ gem 'rake'
6
9
  gem 'simplecov'
7
10
  end
@@ -1,3 +1,3 @@
1
1
  module BlankSlate
2
- VERSION = "1.1.1"
2
+ VERSION = "1.1.2"
3
3
  end
data/lib/blank_slate.rb CHANGED
@@ -2,9 +2,7 @@ module BlankSlate
2
2
  def BlankSlate(klass, &block)
3
3
  blank_slate = Class.new(klass, &block)
4
4
  blank_slate.class_eval do
5
- klass.instance_methods(false).
6
- reject{|meth| instance_methods(false).include?(meth) }.
7
- each do |meth|
5
+ (klass.instance_methods(false) - instance_methods(false)).each do |meth|
8
6
  define_method(meth){ nil }
9
7
  end
10
8
  end
data/test/allowed.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ - BlankSlate#test_0001_returns a class with all instance_methods of the given class
3
+ - BlankSlate#test_0002_sets the values of instance methods to nil
4
+ - BlankSlate#test_0003_accepts a block to define methods on the null class
5
+ - BlankSlate#test_0004_allows the block to override method definitions from the given class
6
+ - BlankSlate#test_0005_inherits from the provide class
7
+ - BlankSlate#test_0006_preserves parent methods
@@ -0,0 +1,64 @@
1
+ require 'test_helper'
2
+
3
+ include BlankSlate
4
+
5
+ module BlankSlate
6
+ class Parent
7
+ def inherited
8
+ "this should be inherited"
9
+ end
10
+ end
11
+
12
+ class TesterClass < Parent
13
+ def one
14
+ "one"
15
+ end
16
+ end
17
+ end
18
+
19
+ describe "BlankSlate" do
20
+ def blank_slate(&block)
21
+ BlankSlate(BlankSlate::TesterClass, &block)
22
+ end
23
+
24
+ it "returns a class with all instance_methods of the given class" do
25
+ assert_equal BlankSlate::TesterClass.instance_methods.sort, blank_slate.instance_methods.sort
26
+ end
27
+
28
+ it "sets the values of instance methods to nil" do
29
+ null_object = blank_slate.new
30
+
31
+ _(null_object.one).must_be_nil
32
+ end
33
+
34
+ it "accepts a block to define methods on the null class" do
35
+ null_object = blank_slate do
36
+ def passed_block_method
37
+ 'this is from the method defined in the block!'
38
+ end
39
+ end.new
40
+
41
+ _(null_object.passed_block_method).must_equal 'this is from the method defined in the block!'
42
+ end
43
+
44
+ it "allows the block to override method definitions from the given class" do
45
+ null_object = blank_slate do
46
+ def one
47
+ 'not the same one'
48
+ end
49
+ end.new
50
+
51
+ _(null_object.one).must_equal 'not the same one'
52
+ end
53
+
54
+ it "inherits from the provide class" do
55
+ null_object = blank_slate.new
56
+ assert_kind_of BlankSlate::TesterClass, null_object
57
+ assert_respond_to null_object, :inherited
58
+ end
59
+
60
+ it "preserves parent methods" do
61
+ null_object = blank_slate.new
62
+ assert_equal null_object.inherited, 'this should be inherited'
63
+ end
64
+ end
@@ -0,0 +1,7 @@
1
+ require 'simplecov'
2
+ require "minitest/autorun"
3
+ require 'minitest/spec'
4
+ SimpleCov.start do
5
+ add_filter 'test'
6
+ end
7
+ require "blank_slate"
metadata CHANGED
@@ -1,57 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blank_slate
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jim Gay
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-02-19 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: bundler
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '2.0'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '2.0'
27
- - !ruby/object:Gem::Dependency
28
- name: rake
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '10.0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '10.0'
41
- - !ruby/object:Gem::Dependency
42
- name: minitest
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '5.0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '5.0'
11
+ date: 2022-07-12 00:00:00.000000000 Z
12
+ dependencies: []
55
13
  description: |2-
56
14
 
57
15
  Create null classes based upon other classes.
@@ -60,30 +18,24 @@ description: |2-
60
18
  the behavior you designed in your other classes.
61
19
  email:
62
20
  - jim@saturnflyer.com
63
- executables:
64
- - console
65
- - setup
21
+ executables: []
66
22
  extensions: []
67
23
  extra_rdoc_files: []
68
24
  files:
69
- - ".gitignore"
70
- - ".simplecov"
71
- - ".travis.yml"
72
25
  - CHANGELOG.md
73
26
  - CODE_OF_CONDUCT.md
74
27
  - Gemfile
75
28
  - LICENSE.txt
76
29
  - README.md
77
- - Rakefile
78
- - blank_slate.gemspec
79
- - exe/console
80
- - exe/setup
81
30
  - lib/blank_slate.rb
82
31
  - lib/blank_slate/version.rb
32
+ - test/allowed.yml
33
+ - test/blank_slate_test.rb
34
+ - test/test_helper.rb
83
35
  homepage: http://github.com/saturnflyer/blank_slate
84
36
  licenses: []
85
37
  metadata: {}
86
- post_install_message:
38
+ post_install_message:
87
39
  rdoc_options: []
88
40
  require_paths:
89
41
  - lib
@@ -98,9 +50,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
98
50
  - !ruby/object:Gem::Version
99
51
  version: '0'
100
52
  requirements: []
101
- rubyforge_project:
102
- rubygems_version: 2.7.6
103
- signing_key:
53
+ rubygems_version: 3.3.17
54
+ signing_key:
104
55
  specification_version: 4
105
56
  summary: Impliment a null object without resorting to method_missing.
106
- test_files: []
57
+ test_files:
58
+ - test/allowed.yml
59
+ - test/blank_slate_test.rb
60
+ - test/test_helper.rb
data/.gitignore DELETED
@@ -1,10 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /_yardoc/
4
- /coverage/
5
- /doc/
6
- /pkg/
7
- /spec/reports/
8
- /tmp/
9
- Gemfile.lock
10
- *.gem
data/.simplecov DELETED
File without changes
data/.travis.yml DELETED
@@ -1,28 +0,0 @@
1
- sudo: false
2
- before_install:
3
- - gem update --system
4
- - gem install bundler
5
- language: ruby
6
- cache: bundler
7
- rvm:
8
- - 2.3.6
9
- - 2.4.4
10
- - 2.5.3
11
- - 2.6.1
12
- - ruby-head
13
- - jruby-head
14
- env:
15
- global:
16
- - CC_TEST_REPORTER_ID=7cf83cb3647a2969a1af2e1bbe49155388ad3a8ff45e6b0ec9be6c1c65ea9b96
17
- matrix:
18
- allow_failures:
19
- - rvm: ruby-head
20
- - rvm: jruby-head
21
- before_script:
22
- - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
23
- - chmod +x ./cc-test-reporter
24
- - ./cc-test-reporter before-build
25
- script:
26
- - bundle exec rake
27
- after_script:
28
- - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
data/Rakefile DELETED
@@ -1,10 +0,0 @@
1
- require "bundler/gem_tasks"
2
- require "rake/testtask"
3
-
4
- Rake::TestTask.new(:test) do |t|
5
- t.libs << "test"
6
- t.libs << "lib"
7
- t.test_files = FileList["test/**/*_test.rb"]
8
- end
9
-
10
- task :default => :test
data/blank_slate.gemspec DELETED
@@ -1,30 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'blank_slate/version'
5
-
6
- Gem::Specification.new do |gem|
7
- gem.name = "blank_slate"
8
- gem.version = BlankSlate::VERSION
9
- gem.authors = ["Jim Gay"]
10
- gem.email = ["jim@saturnflyer.com"]
11
- gem.description = %q{
12
- Create null classes based upon other classes.
13
- This allows you to create null objects without resorting to
14
- method_missing to catch every message passed regardless of
15
- the behavior you designed in your other classes.}
16
- gem.summary = %q{Impliment a null object without resorting to method_missing.}
17
- gem.homepage = "http://github.com/saturnflyer/blank_slate"
18
-
19
- gem.files = Dir.chdir(File.expand_path('..', __FILE__)) do
20
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
21
- end
22
- gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
23
- gem.bindir = "exe"
24
- gem.executables = gem.files.grep(%r{^exe/}) { |f| File.basename(f) }
25
- gem.require_paths = ["lib"]
26
-
27
- gem.add_development_dependency "bundler", "~> 2.0"
28
- gem.add_development_dependency "rake", "~> 10.0"
29
- gem.add_development_dependency "minitest", "~> 5.0"
30
- end
data/exe/console DELETED
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "blank_slate"
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
14
- IRB.start(__FILE__)
data/exe/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here