eigenclass 2.0.3 → 2.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +1 -20
- data/README.md +6 -1
- data/eigenclass.gemspec +0 -2
- data/lib/eigenclass/version.rb +1 -1
- data/spec/eigenclass_spec.rb +13 -46
- data/spec/spec_helper.rb +28 -8
- metadata +2 -30
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4812af25ec11c550957ba6b8d62d46fbb74493ce
|
4
|
+
data.tar.gz: 81e6e35fc7617e65830a3d1a463c95db47a70d7a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d4a7b67abb8f2cba93b326060d1d6b82e39b8fd901081086078e1c4bb171eca65fe60d8f0de78e2aea929aeb9ed027ed2e244a3fcfd575772754ba7d2ad0b374
|
7
|
+
data.tar.gz: 12c2fb51331de95b900fc3bc8abb2ff23f67f5739d9b33fec89c3853b08947db708fd99d99834930dcc8ce46117d1f75a7187ac5e8bdbbce6d2e69f4bc00efee
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,24 +1,15 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
eigenclass (2.0.
|
4
|
+
eigenclass (2.0.4)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://www.rubygems.org/
|
8
8
|
specs:
|
9
|
-
activesupport (4.2.0)
|
10
|
-
i18n (~> 0.7)
|
11
|
-
json (~> 1.7, >= 1.7.7)
|
12
|
-
minitest (~> 5.1)
|
13
|
-
thread_safe (~> 0.3, >= 0.3.4)
|
14
|
-
tzinfo (~> 1.1)
|
15
9
|
codeclimate-test-reporter (0.4.7)
|
16
10
|
simplecov (>= 0.7.1, < 1.0.0)
|
17
11
|
diff-lcs (1.2.5)
|
18
12
|
docile (1.1.5)
|
19
|
-
i18n (0.7.0)
|
20
|
-
json (1.8.2)
|
21
|
-
minitest (5.5.1)
|
22
13
|
multi_json (1.10.1)
|
23
14
|
rspec (3.2.0)
|
24
15
|
rspec-core (~> 3.2.0)
|
@@ -33,20 +24,11 @@ GEM
|
|
33
24
|
diff-lcs (>= 1.2.0, < 2.0)
|
34
25
|
rspec-support (~> 3.2.0)
|
35
26
|
rspec-support (3.2.2)
|
36
|
-
shoulda (3.5.0)
|
37
|
-
shoulda-context (~> 1.0, >= 1.0.1)
|
38
|
-
shoulda-matchers (>= 1.4.1, < 3.0)
|
39
|
-
shoulda-context (1.2.1)
|
40
|
-
shoulda-matchers (2.8.0)
|
41
|
-
activesupport (>= 3.0.0)
|
42
27
|
simplecov (0.9.2)
|
43
28
|
docile (~> 1.1.0)
|
44
29
|
multi_json (~> 1.0)
|
45
30
|
simplecov-html (~> 0.9.0)
|
46
31
|
simplecov-html (0.9.0)
|
47
|
-
thread_safe (0.3.4)
|
48
|
-
tzinfo (1.2.2)
|
49
|
-
thread_safe (~> 0.1)
|
50
32
|
|
51
33
|
PLATFORMS
|
52
34
|
ruby
|
@@ -55,4 +37,3 @@ DEPENDENCIES
|
|
55
37
|
codeclimate-test-reporter
|
56
38
|
eigenclass!
|
57
39
|
rspec
|
58
|
-
shoulda
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# eigenclass - [![Build Status](https://secure.travis-ci.org/shuber/eigenclass.png)](http://travis-ci.org/shuber/eigenclass) [![Code Climate](https://codeclimate.com/github/shuber/eigenclass/badges/gpa.svg)](https://codeclimate.com/github/shuber/eigenclass) [![Coverage](https://codeclimate.com/github/shuber/eigenclass/badges/coverage.svg)](https://codeclimate.com/github/shuber/eigenclass)
|
1
|
+
# [![Sean Huber](https://cloud.githubusercontent.com/assets/2419/6550752/832d9a64-c5ea-11e4-9717-6f9aa6e023b5.png)](https://github.com/shuber) eigenclass - [![Build Status](https://secure.travis-ci.org/shuber/eigenclass.png)](http://travis-ci.org/shuber/eigenclass) [![Code Climate](https://codeclimate.com/github/shuber/eigenclass/badges/gpa.svg)](https://codeclimate.com/github/shuber/eigenclass) [![Coverage](https://codeclimate.com/github/shuber/eigenclass/badges/coverage.svg)](https://codeclimate.com/github/shuber/eigenclass)
|
2
2
|
|
3
3
|
Eigenclasses *aka metaclasses or singleton classes* in Ruby.
|
4
4
|
|
@@ -21,6 +21,11 @@ gem install eigenclass
|
|
21
21
|
```
|
22
22
|
|
23
23
|
|
24
|
+
## Requirements
|
25
|
+
|
26
|
+
Ruby 1.8.7+
|
27
|
+
|
28
|
+
|
24
29
|
## Usage
|
25
30
|
|
26
31
|
Everything in Ruby is an object, including classes.
|
data/eigenclass.gemspec
CHANGED
@@ -15,7 +15,5 @@ Gem::Specification.new do |s|
|
|
15
15
|
s.test_files = `git ls-files -- spec/*`.split("\n")
|
16
16
|
s.version = Eigenclass::VERSION
|
17
17
|
|
18
|
-
s.add_development_dependency 'codeclimate-test-reporter'
|
19
18
|
s.add_development_dependency 'rspec'
|
20
|
-
s.add_development_dependency 'shoulda'
|
21
19
|
end
|
data/lib/eigenclass/version.rb
CHANGED
data/spec/eigenclass_spec.rb
CHANGED
@@ -1,60 +1,27 @@
|
|
1
|
-
|
1
|
+
require File.expand_path('../../lib/eigenclass', __FILE__)
|
2
2
|
|
3
3
|
RSpec.describe Eigenclass do
|
4
4
|
subject { Object.new.extend(described_class) }
|
5
5
|
|
6
|
-
it { should delegate_method(:ealias_method)
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
it { should delegate_method(:
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
it { should delegate_method(:eattr_reader)
|
15
|
-
.to(:eigenclass)
|
16
|
-
.as(:attr_reader) }
|
17
|
-
|
18
|
-
it { should delegate_method(:eattr_writer)
|
19
|
-
.to(:eigenclass)
|
20
|
-
.as(:attr_writer) }
|
21
|
-
|
22
|
-
it { should delegate_method(:edefine_method)
|
23
|
-
.to(:eigenclass)
|
24
|
-
.as(:define_method) }
|
25
|
-
|
26
|
-
it { should delegate_method(:extended_modules)
|
27
|
-
.to(:eigenclass)
|
28
|
-
.as(:included_modules) }
|
6
|
+
it { should delegate_method(:ealias_method).to(:eigenclass).as(:alias_method) }
|
7
|
+
it { should delegate_method(:eattr_accessor).to(:eigenclass).as(:attr_accessor) }
|
8
|
+
it { should delegate_method(:eattr_reader).to(:eigenclass).as(:attr_reader) }
|
9
|
+
it { should delegate_method(:eattr_writer).to(:eigenclass).as(:attr_writer) }
|
10
|
+
it { should delegate_method(:edefine_method).to(:eigenclass).as(:define_method) }
|
11
|
+
it { should delegate_method(:extended_modules).to(:eigenclass).as(:included_modules) }
|
12
|
+
it { should delegate_method(:eigenclass_eval).to(:eigenclass).as(:instance_eval) }
|
13
|
+
it { should delegate_method(:eigenclass_exec).to(:eigenclass).as(:instance_exec) }
|
29
14
|
|
30
15
|
describe '#eigenclass' do
|
31
16
|
it 'should return the eigenclass instance' do
|
32
17
|
expected = class << subject; self end
|
33
18
|
expect(subject.eigenclass).to eq(expected)
|
34
19
|
end
|
35
|
-
end
|
36
|
-
|
37
|
-
describe '#eigenclass_eval' do
|
38
|
-
it 'should evaluate in the eigenclass scope' do
|
39
|
-
expectation = be_respond_to(:test)
|
40
|
-
|
41
|
-
expect(subject).not_to expectation
|
42
|
-
subject.eigenclass_eval { attr_reader :test }
|
43
|
-
expect(subject).to expectation
|
44
|
-
|
45
|
-
expect(subject.class.new).not_to expectation
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
describe '#eigenclass_exec' do
|
50
|
-
it 'should evaluate in the eigenclass scope' do
|
51
|
-
expectation = be_respond_to(:test)
|
52
|
-
|
53
|
-
expect(subject).not_to expectation
|
54
|
-
subject.eigenclass_exec(:test) { |name| attr_reader name }
|
55
|
-
expect(subject).to expectation
|
56
20
|
|
57
|
-
|
21
|
+
it 'should return the same object as singleton_class if that method exists' do
|
22
|
+
if subject.respond_to?(:singleton_class)
|
23
|
+
expect(subject.eigenclass).to eq(subject.singleton_class)
|
24
|
+
end
|
58
25
|
end
|
59
26
|
end
|
60
27
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,13 +1,33 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
1
|
+
begin
|
2
|
+
if ENV['CODECLIMATE_REPO_TOKEN']
|
3
|
+
require 'codeclimate-test-reporter'
|
4
|
+
CodeClimate::TestReporter.start
|
5
|
+
else
|
6
|
+
require 'simplecov'
|
7
|
+
SimpleCov.start { add_filter('/vendor/bundle/') }
|
8
|
+
end
|
9
|
+
rescue LoadError
|
10
|
+
# Ignore when testing with Ruby 1.8.7
|
7
11
|
end
|
8
12
|
|
9
|
-
require 'shoulda'
|
10
|
-
|
11
13
|
RSpec.configure do |config|
|
12
14
|
config.raise_errors_for_deprecations!
|
13
15
|
end
|
16
|
+
|
17
|
+
RSpec::Matchers.define(:delegate_method) do |method|
|
18
|
+
chain(:to) { |to| @to = to }
|
19
|
+
chain(:as) { |as| @as = as }
|
20
|
+
|
21
|
+
match do |subject|
|
22
|
+
target = double "target"
|
23
|
+
expect(subject).to receive(@to).and_return(target)
|
24
|
+
|
25
|
+
args = double "args"
|
26
|
+
block = proc { }
|
27
|
+
value = double "value"
|
28
|
+
expect(target).to receive(@as).with(args, &block).and_return(value)
|
29
|
+
|
30
|
+
result = subject.send(method, args, &block)
|
31
|
+
expect(result).to eq(value)
|
32
|
+
end
|
33
|
+
end
|
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eigenclass
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Huber
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: codeclimate-test-reporter
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: rspec
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -38,20 +24,6 @@ dependencies:
|
|
38
24
|
- - ">="
|
39
25
|
- !ruby/object:Gem::Version
|
40
26
|
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: shoulda
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
27
|
description: Eigenclasses (aka metaclasses or singleton classes) in ruby
|
56
28
|
email: github@shuber.io
|
57
29
|
executables: []
|