abstract_type 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.devtools +1 -1
- data/abstract_type.gemspec +1 -1
- data/config/flay.yml +1 -1
- data/config/flog.yml +1 -1
- data/lib/abstract_type.rb +4 -2
- data/lib/abstract_type/version.rb +1 -1
- data/spec/spec_helper.rb +0 -1
- data/spec/unit/abstract_type/class_methods/abstract_method_spec.rb +5 -0
- data/spec/unit/abstract_type/class_methods/abstract_singleton_method_spec.rb +5 -0
- metadata +7 -3
data/Gemfile.devtools
CHANGED
data/abstract_type.gemspec
CHANGED
@@ -12,7 +12,7 @@ Gem::Specification.new do |gem|
|
|
12
12
|
gem.homepage = 'https://github.com/dkubb/abstract_type'
|
13
13
|
|
14
14
|
gem.files = `git ls-files`.split($/)
|
15
|
-
gem.test_files = `git ls-files --
|
15
|
+
gem.test_files = `git ls-files -- spec/unit`.split($/)
|
16
16
|
gem.extra_rdoc_files = %w[LICENSE README.md TODO]
|
17
17
|
|
18
18
|
gem.add_runtime_dependency('backports', '~> 2.8.2')
|
data/config/flay.yml
CHANGED
data/config/flog.yml
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
---
|
2
|
-
threshold:
|
2
|
+
threshold: 19.8
|
data/lib/abstract_type.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
+
require 'backports'
|
4
|
+
|
3
5
|
# Module to allow class and methods to be abstract
|
4
6
|
module AbstractType
|
5
7
|
|
@@ -91,7 +93,7 @@ module AbstractType
|
|
91
93
|
# @api private
|
92
94
|
def create_abstract_singleton_method(name)
|
93
95
|
singleton_class.class_eval do
|
94
|
-
define_method(name) do
|
96
|
+
define_method(name) do |*|
|
95
97
|
raise NotImplementedError, "#{inspect}.#{name} is not implemented"
|
96
98
|
end
|
97
99
|
end
|
@@ -106,7 +108,7 @@ module AbstractType
|
|
106
108
|
#
|
107
109
|
# @api private
|
108
110
|
def create_abstract_instance_method(name)
|
109
|
-
define_method(name) do
|
111
|
+
define_method(name) do |*|
|
110
112
|
raise NotImplementedError, "#{self.class.inspect}##{name} is not implemented"
|
111
113
|
end
|
112
114
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -24,6 +24,11 @@ describe AbstractType::ClassMethods, '#abstract_method' do
|
|
24
24
|
to(true)
|
25
25
|
end
|
26
26
|
|
27
|
+
it 'creates an abstract method with the expected arity' do
|
28
|
+
subject
|
29
|
+
object.instance_method(:some_method).arity.should be(-1)
|
30
|
+
end
|
31
|
+
|
27
32
|
it 'creates a method that raises an exception' do
|
28
33
|
subject
|
29
34
|
expect { subclass.new.some_method }.to raise_error(NotImplementedError, 'Subclass#some_method is not implemented')
|
@@ -24,6 +24,11 @@ describe AbstractType::ClassMethods, '#abstract_singleton_method' do
|
|
24
24
|
to(true)
|
25
25
|
end
|
26
26
|
|
27
|
+
it 'creates an abstract method with the expected arity' do
|
28
|
+
subject
|
29
|
+
object.method(:some_method).arity.should be(-1)
|
30
|
+
end
|
31
|
+
|
27
32
|
it 'creates a method that raises an exception' do
|
28
33
|
subject
|
29
34
|
expect { subclass.some_method }.to raise_error(NotImplementedError, 'Subclass.some_method is not implemented')
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: abstract_type
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-02-
|
12
|
+
date: 2013-02-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: backports
|
@@ -124,5 +124,9 @@ rubygems_version: 1.8.25
|
|
124
124
|
signing_key:
|
125
125
|
specification_version: 3
|
126
126
|
summary: Module to declare abstract classes and methods
|
127
|
-
test_files:
|
127
|
+
test_files:
|
128
|
+
- spec/unit/abstract_type/class_methods/abstract_method_spec.rb
|
129
|
+
- spec/unit/abstract_type/class_methods/abstract_singleton_method_spec.rb
|
130
|
+
- spec/unit/abstract_type/class_methods/included_spec.rb
|
131
|
+
- spec/unit/abstract_type/class_methods/new_spec.rb
|
128
132
|
has_rdoc:
|