eigenclass 1.1.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c94ea8b81cea1f689c5045034ba16014c96e66e1
4
+ data.tar.gz: 9a18e12547a636fcae7328507a5679632a6b31a2
5
+ SHA512:
6
+ metadata.gz: 33cbea52ad3e7311cc0dd69963b5baeff104b20ff7ff688cd6aecfbf0ef4bb15968715530d8f4ed08511ab0168e6ad36d1bfd7018ad3db2c927784adc5c4fb83
7
+ data.tar.gz: b6d0ecb33424c1ac70cd54b5cb50926e073fbf71ef3cca46b5b6ab5eae02b65c5ae3f9ec392d4e1e0d707708f03e100b171618c4bfea323b236d7db4cd682290
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ .DS_Store
2
+ pkg
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,8 @@
1
+ rvm:
2
+ - 1.9.3
3
+ - 2.0.0
4
+ - ruby-head
5
+ script: bundle exec rspec
6
+ addons:
7
+ code_climate:
8
+ repo_token: 6e85e0e345260307d97927e8eee7f52e2cec36c021b792a30bf7ffb9a6f8eea8
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://www.rubygems.org'
2
+
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,58 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ eigenclass (1.1.1)
5
+
6
+ GEM
7
+ remote: https://www.rubygems.org/
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
+ codeclimate-test-reporter (0.4.7)
16
+ simplecov (>= 0.7.1, < 1.0.0)
17
+ diff-lcs (1.2.5)
18
+ docile (1.1.5)
19
+ i18n (0.7.0)
20
+ json (1.8.2)
21
+ minitest (5.5.1)
22
+ multi_json (1.10.1)
23
+ rspec (3.2.0)
24
+ rspec-core (~> 3.2.0)
25
+ rspec-expectations (~> 3.2.0)
26
+ rspec-mocks (~> 3.2.0)
27
+ rspec-core (3.2.1)
28
+ rspec-support (~> 3.2.0)
29
+ rspec-expectations (3.2.0)
30
+ diff-lcs (>= 1.2.0, < 2.0)
31
+ rspec-support (~> 3.2.0)
32
+ rspec-mocks (3.2.1)
33
+ diff-lcs (>= 1.2.0, < 2.0)
34
+ rspec-support (~> 3.2.0)
35
+ 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
+ simplecov (0.9.2)
43
+ docile (~> 1.1.0)
44
+ multi_json (~> 1.0)
45
+ simplecov-html (~> 0.9.0)
46
+ simplecov-html (0.9.0)
47
+ thread_safe (0.3.4)
48
+ tzinfo (1.2.2)
49
+ thread_safe (~> 0.1)
50
+
51
+ PLATFORMS
52
+ ruby
53
+
54
+ DEPENDENCIES
55
+ codeclimate-test-reporter
56
+ eigenclass!
57
+ rspec
58
+ shoulda
@@ -1,4 +1,4 @@
1
- Copyright (c) 2008 Sean Huber - shuber@huberry.com
1
+ Copyright (c) 2008 Sean Huber - github@shuber.io
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
@@ -17,4 +17,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
17
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
18
  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
19
  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc CHANGED
@@ -1,6 +1,13 @@
1
- = eigenclass
1
+ = eigenclass - {<img src="https://secure.travis-ci.org/shuber/eigenclass.png"/>}[http://travis-ci.org/shuber/eigenclass] {<img src="https://codeclimate.com/github/shuber/eigenclass/badges/gpa.svg" />}[https://codeclimate.com/github/shuber/eigenclass] {<img src="https://codeclimate.com/github/shuber/eigenclass/badges/coverage.svg" />}[https://codeclimate.com/github/shuber/eigenclass]
2
2
 
3
- Utility methods for modifying a ruby object's eigenclass/metaclass
3
+ Eigenclasses (aka metaclasses or singleton classes) in ruby.
4
+
5
+ Check out the implementations for {metaclasses}[http://en.wikipedia.org/wiki/Metaclass] in other languages for more examples.
6
+
7
+ *Note*: This gem was originally written back in 2009. Since then, Ruby has introduced a couple new methods which provide the same functionality as this gem's <tt>eigenclass</tt> and <tt>edefine_method</tt> methods.
8
+
9
+ * {Object#singleton_class}[http://ruby-doc.org/core-1.9.2/Object.html#method-i-singleton_class]
10
+ * {Object#define_singleton_method}[http://ruby-doc.org/core-1.9.2/Object.html#method-i-define_singleton_method]
4
11
 
5
12
 
6
13
  == Installation
@@ -10,52 +17,80 @@ Utility methods for modifying a ruby object's eigenclass/metaclass
10
17
 
11
18
  == Usage
12
19
 
13
- This gem allows you to define class level accessors, readers, and writers
20
+ Everything in Ruby is an object, including classes.
14
21
 
15
- class SomeClass
16
- eattr_accessor :test_accessor
17
- eattr_reader :test_reader
18
- eattr_writer :test_writer
22
+ class SomeObject
19
23
  end
20
-
21
- SomeClass.test_accessor = 'testing'
22
24
 
23
- You can also dynamically create class methods
25
+ Every object has an <tt>eigenclass</tt>.
26
+
27
+ SomeObject.eigenclass #=> #<Class:#<SomeObject:0x007f9611030300>>
24
28
 
25
- SomeClass.class_eval do
26
- define_class_method 'test_class_method' do
27
- 'test'
29
+ The implementation of the <tt>eigenclass</tt> method is pretty simple.
30
+
31
+ class Object
32
+ def eigenclass
33
+ class << self
34
+ self
35
+ end
28
36
  end
29
37
  end
30
-
31
- SomeClass.test_class_method # returns 'test'
32
38
 
33
- You can even evaluate a block of code inside the scope of an object's eigenclass
39
+ Evaluating code within the context of an object's <tt>eigenclass</tt> allows us to do some pretty cool things like defining class level attributes.
34
40
 
35
- SomeClass.eigenclass_eval do
36
- attr_accessor :test_eigenclass_eval
41
+ SomeObject.eigenclass_eval do
42
+ attr_accessor :testing
37
43
  end
38
-
39
- SomeClass.test_eigenclass_eval = true
40
44
 
45
+ SomeObject.testing = :example
46
+ SomeObject.testing #=> :example
41
47
 
42
- A reference to any object's eigenclass can be accessed by calling
48
+ The convenience methods for defining class level methods makes this even easier.
43
49
 
44
- SomeObject.eigenclass
50
+ class SomeObject
51
+ eattr_accessor :test_accessor
52
+ eattr_reader :test_reader
53
+ eattr_writer :test_writer
45
54
 
55
+ edefine_method(:test_class_method) do
56
+ :test_define
57
+ end
58
+ end
46
59
 
47
- == Note on Patches/Pull Requests
60
+ SomeObject.test_class_method #=> :test_define
48
61
 
49
- * Fork the project.
50
- * Make your feature addition or bug fix.
51
- * Add tests for it. This is important so I don't break it in a
52
- future version unintentionally.
53
- * Commit, do not mess with rakefile, version, or history.
54
- (if you want to have your own version, that is fine but
55
- bump version in a commit by itself I can ignore when I pull)
56
- * Send me a pull request. Bonus points for topic branches.
62
+ Since all objects have an <tt>eigenclass</tt>, we can even define methods on individual _instances_ of a class.
63
+
64
+ object = SomeObject.new
65
+ object.eattr_accessor :example
66
+ object.example = "cool"
67
+ object.example #=> cool
68
+
69
+ other_object = SomeObject.new
70
+ other_object.example #=> NoMethodError undefined method `example' for #<SomeObject:0x007fee348dde00>
71
+
72
+ This is pretty incredible! Ruby is like one big plugin framework - with an awesome standard library!
73
+
74
+
75
+ == API
57
76
 
77
+ * {eattr_accessor}[http://ruby-doc.org/core-1.9.3/Module.html#method-i-attr_accessor]
78
+ * {eattr_reader}[http://ruby-doc.org/core-1.9.3/Module.html#method-i-attr_reader]
79
+ * {eattr_writer}[http://ruby-doc.org/core-1.9.3/Module.html#method-i-attr_writer]
80
+ * {edefine_method}[http://ruby-doc.org/core-1.9.3/Module.html#method-i-define_method]
81
+ * {eigenclass_eval}[http://ruby-doc.org/core-1.9.3/BasicObject.html#method-i-instance_eval]
82
+ * {eigenclass_exec}[http://ruby-doc.org/core-1.9.3/BasicObject.html#method-i-instance_exec]
58
83
 
59
- == Contact
60
84
 
61
- Problems, comments, and suggestions all welcome: shuber@huberry.com
85
+ == Testing
86
+
87
+ bundle exec rspec
88
+
89
+
90
+ == Contributing
91
+
92
+ * Fork the project.
93
+ * Make your feature addition or bug fix.
94
+ * Add tests for it. This is important so I don't break it in a future version unintentionally.
95
+ * Commit, do not mess with Rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
96
+ * Send me a pull request. Bonus points for topic branches.
@@ -0,0 +1,21 @@
1
+ require File.expand_path('../lib/eigenclass/version', __FILE__)
2
+
3
+ Gem::Specification.new do |s|
4
+ s.author = 'Sean Huber'
5
+ s.description = 'Eigenclasses (aka metaclasses or singleton classes) in ruby'
6
+ s.email = 'github@shuber.io'
7
+ s.extra_rdoc_files = %w(LICENSE)
8
+ s.files = `git ls-files`.split("\n")
9
+ s.homepage = 'https://github.com/shuber/eigenclass'
10
+ s.license = 'MIT'
11
+ s.name = 'eigenclass'
12
+ s.rdoc_options = %w(--charset=UTF-8 --inline-source --line-numbers --main README.rdoc)
13
+ s.require_paths = %w(lib)
14
+ s.summary = 'Eigenclasses in ruby'
15
+ s.test_files = `git ls-files -- test/*`.split("\n")
16
+ s.version = Eigenclass::VERSION
17
+
18
+ s.add_development_dependency 'codeclimate-test-reporter'
19
+ s.add_development_dependency 'rspec'
20
+ s.add_development_dependency 'shoulda'
21
+ end
data/lib/eigenclass.rb CHANGED
@@ -1,77 +1,21 @@
1
+ require 'forwardable'
2
+ require 'eigenclass/version'
3
+
1
4
  module Eigenclass
2
- # Uses <tt>eigenclass_eval</tt> to define attr_accessors in an object's <tt>eigenclass</tt>
3
- # which can be called like a class methods
4
- #
5
- # Example
6
- #
7
- # class User
8
- # eattr_accessor :testing
9
- # end
10
- #
11
- # User.testing = true
12
- def eattr_accessor(*attrs)
13
- eigenclass_eval { attr_accessor *attrs }
14
- end
15
-
16
- # Uses <tt>eigenclass_eval</tt> to define attr_readers in an object's <tt>eigenclass</tt>
17
- # which can be called like a class methods
18
- #
19
- # Example
20
- #
21
- # class User
22
- # eattr_reader :testing
23
- # @testing = true
24
- # end
25
- #
26
- # User.testing # returns true
27
- def eattr_reader(*attrs)
28
- eigenclass_eval { attr_reader *attrs }
29
- end
30
-
31
- # Uses <tt>eigenclass_eval</tt> to define attr_writers in an object's <tt>eigenclass</tt>
32
- # which can be called like a class methods
33
- #
34
- # Example
35
- #
36
- # class User
37
- # eattr_writer :testing
38
- # end
39
- #
40
- # User.testing = true
41
- def eattr_writer(*attrs)
42
- eigenclass_eval { attr_writer *attrs }
43
- end
44
-
45
- # Uses <tt>eigenclass_eval</tt> to define a method in an object's <tt>eigenclass</tt>
46
- # which can be called like a class method
47
- #
48
- # Example
49
- #
50
- # User.class_eval do
51
- # define_class_method 'testing' do
52
- # 'test'
53
- # end
54
- # end
55
- #
56
- # User.testing # returns 'test'
57
- def define_class_method(name, &block)
58
- eigenclass_eval { define_method name, &block }
59
- end
60
-
61
- # Returns an object's eigenclass
5
+ extend Forwardable
6
+
7
+ def_delegator :eigenclass, :attr_accessor, :eattr_accessor
8
+ def_delegator :eigenclass, :attr_reader, :eattr_reader
9
+ def_delegator :eigenclass, :attr_writer, :eattr_writer
10
+ def_delegator :eigenclass, :define_method, :edefine_method
11
+ def_delegator :eigenclass, :instance_eval, :eigenclass_eval
12
+ def_delegator :eigenclass, :instance_exec, :eigenclass_exec
13
+
62
14
  def eigenclass
63
- class << self; self; end
64
- end
65
-
66
- # Accepts a block to evaluate inside the scope of an object's <tt>eigenclass</tt>
67
- #
68
- # Example
69
- #
70
- # User.eigenclass_eval { attr_accessor :testing }
71
- # User.testing = true
72
- def eigenclass_eval(&block)
73
- eigenclass.instance_eval &block
15
+ class << self
16
+ self
17
+ end
74
18
  end
75
19
  end
76
20
 
77
- Object.send :include, Eigenclass
21
+ Object.send(:include, Eigenclass)
@@ -0,0 +1,3 @@
1
+ module Eigenclass
2
+ VERSION = '2.0.0'
3
+ end
@@ -0,0 +1,52 @@
1
+ require_relative '../lib/eigenclass'
2
+
3
+ RSpec.describe Eigenclass do
4
+ subject { Object.new.extend(described_class) }
5
+
6
+ it { should delegate_method(:eattr_accessor)
7
+ .to(:eigenclass)
8
+ .as(:attr_accessor) }
9
+
10
+ it { should delegate_method(:eattr_reader)
11
+ .to(:eigenclass)
12
+ .as(:attr_reader) }
13
+
14
+ it { should delegate_method(:eattr_writer)
15
+ .to(:eigenclass)
16
+ .as(:attr_writer) }
17
+
18
+ it { should delegate_method(:edefine_method)
19
+ .to(:eigenclass)
20
+ .as(:define_method) }
21
+
22
+ describe '#eigenclass' do
23
+ it 'should return the eigenclass instance' do
24
+ expected = class << subject; self end
25
+ expect(subject.eigenclass).to eq(expected)
26
+ end
27
+ end
28
+
29
+ describe '#eigenclass_eval' do
30
+ it 'should evaluate in the eigenclass scope' do
31
+ expectation = be_respond_to(:test)
32
+
33
+ expect(subject).not_to expectation
34
+ subject.eigenclass_eval { attr_reader :test }
35
+ expect(subject).to expectation
36
+
37
+ expect(subject.class.new).not_to expectation
38
+ end
39
+ end
40
+
41
+ describe '#eigenclass_exec' do
42
+ it 'should evaluate in the eigenclass scope' do
43
+ expectation = be_respond_to(:test)
44
+
45
+ expect(subject).not_to expectation
46
+ subject.eigenclass_exec(:test) { |name| attr_reader name }
47
+ expect(subject).to expectation
48
+
49
+ expect(subject.class.new).not_to expectation
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,97 @@
1
+ if ENV['CODECLIMATE_REPO_TOKEN']
2
+ require 'codeclimate-test-reporter'
3
+ CodeClimate::TestReporter.start
4
+ end
5
+
6
+ require 'shoulda'
7
+
8
+ # This file was generated by the `rspec --init` command. Conventionally, all
9
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
10
+ # The generated `.rspec` file contains `--require spec_helper` which will cause
11
+ # this file to always be loaded, without a need to explicitly require it in any
12
+ # files.
13
+ #
14
+ # Given that it is always loaded, you are encouraged to keep this file as
15
+ # light-weight as possible. Requiring heavyweight dependencies from this file
16
+ # will add to the boot time of your test suite on EVERY test run, even for an
17
+ # individual file that may not need all of that loaded. Instead, consider making
18
+ # a separate helper file that requires the additional dependencies and performs
19
+ # the additional setup, and require it from the spec files that actually need
20
+ # it.
21
+ #
22
+ # The `.rspec` file also contains a few flags that are not defaults but that
23
+ # users commonly want.
24
+ #
25
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
26
+ RSpec.configure do |config|
27
+ # rspec-expectations config goes here. You can use an alternate
28
+ # assertion/expectation library such as wrong or the stdlib/minitest
29
+ # assertions if you prefer.
30
+ config.expect_with :rspec do |expectations|
31
+ # This option will default to `true` in RSpec 4. It makes the `description`
32
+ # and `failure_message` of custom matchers include text for helper methods
33
+ # defined using `chain`, e.g.:
34
+ # be_bigger_than(2).and_smaller_than(4).description
35
+ # # => "be bigger than 2 and smaller than 4"
36
+ # ...rather than:
37
+ # # => "be bigger than 2"
38
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
39
+ end
40
+
41
+ # rspec-mocks config goes here. You can use an alternate test double
42
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
43
+ config.mock_with :rspec do |mocks|
44
+ # Prevents you from mocking or stubbing a method that does not exist on
45
+ # a real object. This is generally recommended, and will default to
46
+ # `true` in RSpec 4.
47
+ mocks.verify_partial_doubles = true
48
+ end
49
+
50
+ # The settings below are suggested to provide a good initial experience
51
+ # with RSpec, but feel free to customize to your heart's content.
52
+
53
+ # These two settings work together to allow you to limit a spec run
54
+ # to individual examples or groups you care about by tagging them with
55
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
56
+ # get run.
57
+ config.filter_run :focus
58
+ config.run_all_when_everything_filtered = true
59
+
60
+ # Limits the available syntax to the non-monkey patched syntax that is
61
+ # recommended. For more details, see:
62
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
63
+ # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
64
+ # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
65
+ config.disable_monkey_patching!
66
+
67
+ # This setting enables warnings. It's recommended, but in some cases may
68
+ # be too noisy due to issues in dependencies.
69
+ config.warnings = true
70
+
71
+ # Many RSpec users commonly either run the entire suite or an individual
72
+ # file, and it's useful to allow more verbose output when running an
73
+ # individual spec file.
74
+ if config.files_to_run.one?
75
+ # Use the documentation formatter for detailed output,
76
+ # unless a formatter has already been configured
77
+ # (e.g. via a command-line flag).
78
+ config.default_formatter = 'doc'
79
+ end
80
+
81
+ # Print the 10 slowest examples and example groups at the
82
+ # end of the spec run, to help surface which specs are running
83
+ # particularly slow.
84
+ config.profile_examples = 10
85
+
86
+ # Run specs in random order to surface order dependencies. If you find an
87
+ # order dependency and want to debug it, you can fix the order by providing
88
+ # the seed, which is printed after each run.
89
+ # --seed 1234
90
+ config.order = :random
91
+
92
+ # Seed global randomization in this process using the `--seed` CLI option.
93
+ # Setting this allows you to use `--seed` to deterministically reproduce
94
+ # test failures related to randomization by passing the same `--seed` value
95
+ # as the one that triggered the failure.
96
+ Kernel.srand config.seed
97
+ end
metadata CHANGED
@@ -1,62 +1,103 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: eigenclass
3
- version: !ruby/object:Gem::Version
4
- version: 1.1.1
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.0.0
5
5
  platform: ruby
6
- authors:
6
+ authors:
7
7
  - Sean Huber
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
-
12
- date: 2010-01-28 00:00:00 -08:00
13
- default_executable:
14
- dependencies: []
15
-
16
- description: Utility methods for modifying a ruby object's eigenclass/metaclass
17
- email: shuber@huberry.com
11
+ date: 2015-03-06 00:00:00.000000000 Z
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
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ 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
+ description: Eigenclasses (aka metaclasses or singleton classes) in ruby
56
+ email: github@shuber.io
18
57
  executables: []
19
-
20
58
  extensions: []
21
-
22
- extra_rdoc_files: []
23
-
24
- files:
25
- - lib/eigenclass.rb
26
- - MIT-LICENSE
27
- - Rakefile
59
+ extra_rdoc_files:
60
+ - LICENSE
61
+ files:
62
+ - ".gitignore"
63
+ - ".rspec"
64
+ - ".travis.yml"
65
+ - Gemfile
66
+ - Gemfile.lock
67
+ - LICENSE
28
68
  - README.rdoc
29
- - test/eigenclass_test.rb
30
- has_rdoc: true
31
- homepage: http://github.com/shuber/eigenclass
32
- licenses: []
33
-
69
+ - eigenclass.gemspec
70
+ - lib/eigenclass.rb
71
+ - lib/eigenclass/version.rb
72
+ - spec/eigenclass_spec.rb
73
+ - spec/spec_helper.rb
74
+ homepage: https://github.com/shuber/eigenclass
75
+ licenses:
76
+ - MIT
77
+ metadata: {}
34
78
  post_install_message:
35
- rdoc_options:
36
- - --line-numbers
37
- - --inline-source
38
- - --main
79
+ rdoc_options:
80
+ - "--charset=UTF-8"
81
+ - "--inline-source"
82
+ - "--line-numbers"
83
+ - "--main"
39
84
  - README.rdoc
40
- require_paths:
85
+ require_paths:
41
86
  - lib
42
- required_ruby_version: !ruby/object:Gem::Requirement
43
- requirements:
87
+ required_ruby_version: !ruby/object:Gem::Requirement
88
+ requirements:
44
89
  - - ">="
45
- - !ruby/object:Gem::Version
46
- version: "0"
47
- version:
48
- required_rubygems_version: !ruby/object:Gem::Requirement
49
- requirements:
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ required_rubygems_version: !ruby/object:Gem::Requirement
93
+ requirements:
50
94
  - - ">="
51
- - !ruby/object:Gem::Version
52
- version: "0"
53
- version:
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
54
97
  requirements: []
55
-
56
98
  rubyforge_project:
57
- rubygems_version: 1.3.5
99
+ rubygems_version: 2.4.5
58
100
  signing_key:
59
- specification_version: 3
60
- summary: Utility methods for modifying a ruby object's eigenclass/metaclass
61
- test_files:
62
- - test/eigenclass_test.rb
101
+ specification_version: 4
102
+ summary: Eigenclasses in ruby
103
+ test_files: []
data/Rakefile DELETED
@@ -1,22 +0,0 @@
1
- require 'rake'
2
- require 'rake/testtask'
3
- require 'rake/rdoctask'
4
-
5
- desc 'Default: run unit tests.'
6
- task :default => :test
7
-
8
- desc 'Test the eigenclass gem.'
9
- Rake::TestTask.new(:test) do |t|
10
- t.libs << 'lib'
11
- t.pattern = 'test/**/*_test.rb'
12
- t.verbose = true
13
- end
14
-
15
- desc 'Generate documentation for the eigenclass gem.'
16
- Rake::RDocTask.new(:rdoc) do |rdoc|
17
- rdoc.rdoc_dir = 'rdoc'
18
- rdoc.title = 'Eigenclass'
19
- rdoc.options << '--line-numbers' << '--inline-source'
20
- rdoc.rdoc_files.include('README*')
21
- rdoc.rdoc_files.include('lib/**/*.rb')
22
- end
@@ -1,90 +0,0 @@
1
- require 'test/unit'
2
- require File.dirname(__FILE__) + '/../lib/eigenclass'
3
-
4
- class TestClass; end
5
- class ChildTestClass < TestClass; end
6
- class AnotherTestClass; end
7
-
8
- class EigenclassTest < Test::Unit::TestCase
9
-
10
- def test_should_return_the_eigenclass
11
- assert_equal (class << TestClass; self; end), TestClass.eigenclass
12
- end
13
-
14
- def test_should_return_the_same_instance_of_the_eigenclass
15
- assert_equal TestClass.eigenclass.object_id, TestClass.eigenclass.object_id
16
- end
17
-
18
- def test_should_eigenclass_eval_correctly
19
- assert !TestClass.respond_to?(:testing)
20
- TestClass.eigenclass_eval do
21
- define_method 'testing' do
22
- 'test'
23
- end
24
- end
25
- assert TestClass.respond_to?(:testing)
26
- assert_equal 'test', TestClass.testing
27
- end
28
-
29
- def test_should_define_class_method
30
- assert !TestClass.respond_to?(:testing_again)
31
- TestClass.class_eval do
32
- define_class_method 'testing_again' do
33
- 'test'
34
- end
35
- end
36
- assert TestClass.respond_to?(:testing_again)
37
- assert_equal 'test', TestClass.testing_again
38
- end
39
-
40
- def test_child_class_should_inherit_defined_class_methods
41
- assert !ChildTestClass.respond_to?(:testing_yet_again)
42
- TestClass.class_eval do
43
- define_class_method 'testing_yet_again' do
44
- 'test'
45
- end
46
- end
47
- assert ChildTestClass.respond_to?(:testing_yet_again)
48
- assert_equal 'test', ChildTestClass.testing_yet_again
49
- end
50
-
51
- def test_should_not_define_methods_accross_all_classes
52
- assert !TestClass.respond_to?(:testing_one_more_time)
53
- assert !AnotherTestClass.respond_to?(:testing_one_more_time)
54
- TestClass.class_eval do
55
- define_class_method 'testing_one_more_time' do
56
- 'test'
57
- end
58
- end
59
- assert TestClass.respond_to?(:testing_one_more_time)
60
- assert !AnotherTestClass.respond_to?(:testing_one_more_time)
61
- end
62
-
63
- def test_cattr_accessor
64
- assert !TestClass.respond_to?(:this_is_a_test)
65
- TestClass.eattr_accessor :this_is_a_test
66
- assert TestClass.respond_to?(:this_is_a_test)
67
- assert TestClass.this_is_a_test.nil?
68
- TestClass.this_is_a_test = true
69
- assert TestClass.this_is_a_test
70
- end
71
-
72
- def test_cattr_reader
73
- assert !TestClass.respond_to?(:this_is_another_test)
74
- TestClass.eattr_reader :this_is_another_test
75
- assert TestClass.respond_to?(:this_is_another_test)
76
- assert TestClass.this_is_another_test.nil?
77
- TestClass.instance_variable_set('@this_is_another_test', true)
78
- assert TestClass.this_is_another_test
79
- end
80
-
81
- def test_cattr_writer
82
- assert !TestClass.respond_to?(:this_is_yet_another_test=)
83
- TestClass.eattr_writer :this_is_yet_another_test
84
- assert TestClass.respond_to?(:this_is_yet_another_test=)
85
- assert TestClass.instance_variable_get('@this_is_yet_another_test').nil?
86
- TestClass.this_is_yet_another_test = true
87
- assert TestClass.instance_variable_get('@this_is_yet_another_test')
88
- end
89
-
90
- end