motion_abstract_type 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ OGQ2Nzk0MmMxNjc0OGYwYTRiNjgxYzI1ZjBkYzk0N2ZmOGQ0Y2ZiMw==
5
+ data.tar.gz: !binary |-
6
+ Yzk0NGMxZDZkMDAwNTI2NzhmZGQ1ZDZlNDQ3OTcwYzA0ZWIxNzE2Ng==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ N2RlYjExMzY4YTQxOThjZTUwNWYxYTRhYjhiNTQ5ZjdhMTkzYmNjMGYwMGZm
10
+ NjI1NmQyODdhOWY0YTJlYWE3OWYzYmY2MThkYTQ0YTY4NDg1MjYxODU1ODI3
11
+ NWU2MmY5ODBiMmJjYTYwYzdjNzJiMGE5ODM1NWJjYjAyZjQ5Zjc=
12
+ data.tar.gz: !binary |-
13
+ OThmMGVhMzA1MjZkNTFmYzMwY2JmZjMzYWYxZmRhMDE2ZWZkN2YyNGFjZTkz
14
+ NjA3NTkzOTUxM2ZmZTUyNmY2MDdmNjU3ZDMwMjM2YzlmMTIzNzY2NDEyNDli
15
+ YWQ1MDQxMzUyYWNmZDE2NWMwZjI3YWVkNDgwNjM2NjRjZDdiMjg=
data/.gitignore ADDED
@@ -0,0 +1,37 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## Rubinius
17
+ *.rbc
18
+ .rbx
19
+
20
+ ## PROJECT::GENERAL
21
+ *.gem
22
+ coverage
23
+ profiling
24
+ turbulence
25
+ rdoc
26
+ pkg
27
+ tmp
28
+ doc
29
+ log
30
+ .yardoc
31
+ measurements
32
+
33
+ ## BUNDLER
34
+ .bundle
35
+ Gemfile.lock
36
+
37
+ ## PROJECT::SPECIFIC
data/.rspec ADDED
@@ -0,0 +1,4 @@
1
+ --color
2
+ --format progress
3
+ --profile
4
+ --order random
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ abstract_type
data/.travis.yml ADDED
@@ -0,0 +1,30 @@
1
+ language: ruby
2
+ before_install: gem install bundler
3
+ bundler_args: --without yard guard metrics benchmarks
4
+ script: "bundle exec rake ci"
5
+ rvm:
6
+ - 1.9.2
7
+ - 1.9.3
8
+ - 2.0.0
9
+ - rbx-19mode
10
+ - jruby-19mode
11
+ - ruby-head
12
+ notifications:
13
+ irc:
14
+ channels:
15
+ - irc.freenode.org#rom-rb
16
+ on_success: never
17
+ on_failure: change
18
+ email:
19
+ recipients:
20
+ - dan.kubb@gmail.com
21
+ on_success: never
22
+ on_failure: change
23
+ matrix:
24
+ allow_failures:
25
+ - rvm: ruby-head
26
+ include:
27
+ - rvm: jruby-19mode
28
+ env: JRUBY_OPTS="$JRUBY_OPTS --debug"
29
+ - rvm: jruby-head
30
+ env: JRUBY_OPTS="$JRUBY_OPTS --debug"
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,11 @@
1
+ Contributing
2
+ ------------
3
+
4
+ * If you want your code merged into the mainline, please discuss the proposed changes with me before doing any work on it. This library is still in early development, and the direction it is going may not always be clear. Some features may not be appropriate yet, may need to be deferred until later when the foundation for them is laid, or may be more applicable in a plugin.
5
+ * Fork the project.
6
+ * Make your feature addition or bug fix.
7
+ * Follow this [style guide](https://github.com/dkubb/styleguide).
8
+ * Add specs for it. This is important so I don't break it in a future version unintentionally. Tests must cover all branches within the code, and code must be fully covered.
9
+ * 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)
10
+ * Run "rake ci". This must pass and not show any regressions in the metrics for the code to be merged.
11
+ * Send me a pull request. Bonus points for topic branches.
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ # encoding: utf-8
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gemspec
6
+
7
+ gem 'devtools', :git => 'https://github.com/rom-rb/devtools.git'
8
+ eval File.read('Gemfile.devtools')
data/Gemfile.devtools ADDED
@@ -0,0 +1,59 @@
1
+ # encoding: utf-8
2
+
3
+ group :development do
4
+ gem 'rake', '~> 10.1.0'
5
+ gem 'rspec', '~> 2.13.0'
6
+ gem 'yard', '~> 0.8.6.1'
7
+ end
8
+
9
+ group :yard do
10
+ gem 'kramdown', '~> 1.0.1'
11
+ end
12
+
13
+ group :guard do
14
+ gem 'guard', '~> 1.8.1'
15
+ gem 'guard-bundler', '~> 1.0.0'
16
+ gem 'guard-rspec', '~> 3.0.2'
17
+
18
+ # file system change event handling
19
+ gem 'listen', '~> 1.2.2'
20
+ gem 'rb-fchange', '~> 0.0.6', :require => false
21
+ gem 'rb-fsevent', '~> 0.9.3', :require => false
22
+ gem 'rb-inotify', '~> 0.9.0', :require => false
23
+
24
+ # notification handling
25
+ gem 'libnotify', '~> 0.8.0', :require => false
26
+ gem 'rb-notifu', '~> 0.0.4', :require => false
27
+ gem 'terminal-notifier-guard', '~> 1.5.3', :require => false
28
+ end
29
+
30
+ group :metrics do
31
+ gem 'coveralls', '~> 0.6.7'
32
+ gem 'flay', '~> 2.3.0'
33
+ gem 'flog', '~> 4.1.0'
34
+ gem 'reek', '~> 1.3.1', :git => 'https://github.com/troessner/reek.git'
35
+ gem 'simplecov', '~> 0.7.1'
36
+ gem 'yardstick', '~> 0.9.6'
37
+
38
+ platforms :ruby_19 do
39
+ gem 'yard-spellcheck', '~> 0.1.5'
40
+ end
41
+
42
+ platforms :ruby_19, :ruby_20 do
43
+ gem 'mutant', '~> 0.3.0.beta6'
44
+ end
45
+
46
+ platforms :rbx do
47
+ gem 'pelusa', '~> 0.2.2'
48
+ end
49
+ end
50
+
51
+ group :benchmarks do
52
+ gem 'rbench', '~> 0.2.3'
53
+ end
54
+
55
+ platform :jruby do
56
+ group :jruby do
57
+ gem 'jruby-openssl', '~> 0.8.5'
58
+ end
59
+ end
data/Guardfile ADDED
@@ -0,0 +1,18 @@
1
+ # encoding: utf-8
2
+
3
+ guard :bundler do
4
+ watch('Gemfile')
5
+ end
6
+
7
+ guard :rspec do
8
+ # run all specs if the spec_helper or supporting files files are modified
9
+ watch('spec/spec_helper.rb') { 'spec' }
10
+ watch(%r{\Aspec/(?:lib|support|shared)/.+\.rb\z}) { 'spec' }
11
+
12
+ # run unit specs if associated lib code is modified
13
+ watch(%r{\Alib/(.+)\.rb\z}) { |m| Dir["spec/unit/#{m[1]}"] }
14
+ watch("lib/#{File.basename(File.expand_path('../', __FILE__))}.rb") { 'spec' }
15
+
16
+ # run a spec if it is modified
17
+ watch(%r{\Aspec/(?:unit|integration)/.+_spec\.rb\z})
18
+ end
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ Copyright (c) 2009-2013 Dan Kubb
2
+ Copyright (c) 2012 Markus Schirp
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining
5
+ a copy of this software and associated documentation files (the
6
+ "Software"), to deal in the Software without restriction, including
7
+ without limitation the rights to use, copy, modify, merge, publish,
8
+ distribute, sublicense, and/or sell copies of the Software, and to
9
+ permit persons to whom the Software is furnished to do so, subject to
10
+ the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,57 @@
1
+ motion_abstract_type
2
+ ==============
3
+
4
+ A RubyMotion port of [dkubb's](https://github.com/dkubb) [abstract_type](https://github.com/dkubb/abstract_type)
5
+
6
+ Installation
7
+ ------------
8
+
9
+ With Rubygems:
10
+
11
+ ```bash
12
+ $ gem install motion_abstract_type
13
+ $ irb -rubygems
14
+ >> require 'motion_abstract_type'
15
+ => true
16
+ ```
17
+
18
+ Examples
19
+ --------
20
+
21
+ ``` ruby
22
+ class Foo
23
+ include AbstractType
24
+
25
+ # Declare abstract instance method
26
+ abstract_method :bar
27
+
28
+ # Declare abstract singleton method
29
+ abstract_singleton_method :baz
30
+ end
31
+
32
+ Foo.new # raises NotImplementedError: Foo is an abstract type
33
+ Foo.baz # raises NotImplementedError: Foo.baz is not implemented
34
+
35
+ # Subclassing to allow instantiation
36
+ class Baz < Foo; end
37
+
38
+ object = Baz.new
39
+ object.bar # raises NotImplementedError: Baz#bar is not implemented
40
+
41
+ ```
42
+
43
+ Credits
44
+ -------
45
+
46
+ * Dan Kubb ([dkubb](https://github.com/dkubb))
47
+ * Markus Schirp ([mbj](https://github.com/mbj))
48
+
49
+ Contributing
50
+ ------------
51
+
52
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for details.
53
+
54
+ Copyright
55
+ ---------
56
+
57
+ Copyright &copy; 2009-2013 Dan Kubb. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,5 @@
1
+ # encoding: utf-8
2
+
3
+ require 'devtools'
4
+
5
+ Devtools.init_rake_tasks
data/TODO ADDED
File without changes
data/config/flay.yml ADDED
@@ -0,0 +1,3 @@
1
+ ---
2
+ threshold: 9
3
+ total_score: 17
data/config/flog.yml ADDED
@@ -0,0 +1,2 @@
1
+ ---
2
+ threshold: 9.0
data/config/mutant.yml ADDED
@@ -0,0 +1,3 @@
1
+ ---
2
+ name: abstract_type
3
+ namespace: AbstractType
data/config/reek.yml ADDED
@@ -0,0 +1,93 @@
1
+ ---
2
+ UncommunicativeParameterName:
3
+ accept: []
4
+ exclude: []
5
+ enabled: true
6
+ reject:
7
+ - !ruby/regexp /^.$/
8
+ - !ruby/regexp /[0-9]$/
9
+ - !ruby/regexp /[A-Z]/
10
+ TooManyMethods:
11
+ max_methods: 10
12
+ exclude: []
13
+ enabled: true
14
+ max_instance_variables: 2
15
+ UncommunicativeMethodName:
16
+ accept: []
17
+ exclude: []
18
+ enabled: true
19
+ reject:
20
+ - !ruby/regexp /^[a-z]$/
21
+ - !ruby/regexp /[0-9]$/
22
+ - !ruby/regexp /[A-Z]/
23
+ LongParameterList:
24
+ max_params: 2 # TODO: decrease max_params to 2
25
+ exclude: []
26
+ enabled: true
27
+ overrides: {}
28
+ FeatureEnvy:
29
+ exclude: []
30
+ enabled: true
31
+ ClassVariable:
32
+ exclude: []
33
+ enabled: true
34
+ BooleanParameter:
35
+ exclude: []
36
+ enabled: true
37
+ IrresponsibleModule:
38
+ exclude: []
39
+ enabled: true
40
+ UncommunicativeModuleName:
41
+ accept: []
42
+ exclude: []
43
+ enabled: true
44
+ reject:
45
+ - !ruby/regexp /^.$/
46
+ - !ruby/regexp /[0-9]$/
47
+ NestedIterators:
48
+ ignore_iterators: []
49
+ exclude: [
50
+ 'AbstractType::ClassMethods#create_abstract_singleton_method'
51
+ ]
52
+ enabled: true
53
+ max_allowed_nesting: 1
54
+ TooManyStatements:
55
+ max_statements: 7 # TODO: decrease max_statements to 5 or less
56
+ exclude: []
57
+ enabled: true
58
+ DuplicateMethodCall:
59
+ allow_calls: []
60
+ exclude: []
61
+ enabled: true
62
+ max_calls: 1
63
+ UtilityFunction:
64
+ max_helper_calls: 1
65
+ exclude: []
66
+ enabled: true
67
+ Attribute:
68
+ exclude: []
69
+ enabled: false
70
+ UncommunicativeVariableName:
71
+ accept: []
72
+ exclude: []
73
+ enabled: true
74
+ reject:
75
+ - !ruby/regexp /^.$/
76
+ - !ruby/regexp /[0-9]$/
77
+ - !ruby/regexp /[A-Z]/
78
+ RepeatedConditional:
79
+ exclude: []
80
+ enabled: true
81
+ max_ifs: 1
82
+ DataClump:
83
+ exclude: []
84
+ enabled: true
85
+ max_copies: 1
86
+ min_clump_size: 3
87
+ ControlParameter:
88
+ exclude: []
89
+ enabled: true
90
+ LongYieldList:
91
+ max_params: 1
92
+ exclude: []
93
+ enabled: true
data/config/roodi.yml ADDED
@@ -0,0 +1,18 @@
1
+ ---
2
+ AbcMetricMethodCheck: { score: 10.3 }
3
+ AssignmentInConditionalCheck: { }
4
+ CaseMissingElseCheck: { }
5
+ ClassLineCountCheck: { line_count: 293 }
6
+ ClassNameCheck: { pattern: !ruby/regexp '/\A(?:[A-Z]+|[A-Z][a-z](?:[A-Z]?[a-z])+)\z/' }
7
+ ClassVariableCheck: { }
8
+ CyclomaticComplexityBlockCheck: { complexity: 2 }
9
+ CyclomaticComplexityMethodCheck: { complexity: 4 }
10
+ EmptyRescueBodyCheck: { }
11
+ ForLoopCheck: { }
12
+ # TODO: decrease line_count to 5 to 10
13
+ MethodLineCountCheck: { line_count: 14 }
14
+ MethodNameCheck: { pattern: !ruby/regexp '/\A(?:[a-z\d](?:_?[a-z\d])+[?!=]?|\[\]=?|==|<=>|[+*&|-])\z/' }
15
+ ModuleLineCountCheck: { line_count: 295 }
16
+ ModuleNameCheck: { pattern: !ruby/regexp '/\A(?:[A-Z]+|[A-Z][a-z](?:[A-Z]?[a-z])+)\z/' }
17
+ # TODO: decrease parameter_count to 2 or less
18
+ ParameterNumberCheck: { parameter_count: 3 }
@@ -0,0 +1,2 @@
1
+ ---
2
+ threshold: 100
@@ -0,0 +1,9 @@
1
+ unless defined?(Motion::Project::Config)
2
+ raise "This file must be required within a RubyMotion project Rakefile."
3
+ end
4
+
5
+ Motion::Project::App.setup do |app|
6
+ Dir.glob(File.join(File.dirname(__FILE__), 'motion_abstract_type/**/*.rb')).each do |file|
7
+ app.files.unshift(file)
8
+ end
9
+ end
@@ -0,0 +1,113 @@
1
+ # encoding: utf-8
2
+
3
+ # Module to allow class and methods to be abstract
4
+ module AbstractType
5
+
6
+ # Hook called when module is included
7
+ #
8
+ # @param [Module] descendant
9
+ # the module or class including AbstractType
10
+ #
11
+ # @return [undefined]
12
+ #
13
+ # @api private
14
+ def self.included(descendant)
15
+ super
16
+ descendant.extend(ClassMethods)
17
+ end
18
+
19
+ private_class_method :included
20
+
21
+ module ClassMethods
22
+
23
+ # Instantiate a new object
24
+ #
25
+ # Ensures that the instance cannot be of the abstract type
26
+ # and must be a descendant.
27
+ #
28
+ # @example
29
+ # object = AbstractType.new
30
+ #
31
+ # @return [Object]
32
+ #
33
+ # @api public
34
+ def new(*)
35
+ if superclass.equal?(Object)
36
+ raise NotImplementedError, "#{inspect} is an abstract type"
37
+ else
38
+ super
39
+ end
40
+ end
41
+
42
+ # Create abstract instance methods
43
+ #
44
+ # @example
45
+ # class Foo
46
+ # include AbstractType
47
+ #
48
+ # # Create an abstract instance method
49
+ # abstract_method :some_method
50
+ # end
51
+ #
52
+ # @param [Array<#to_s>] names
53
+ #
54
+ # @return [self]
55
+ #
56
+ # @api public
57
+ def abstract_method(*names)
58
+ names.each { |name| create_abstract_instance_method(name) }
59
+ self
60
+ end
61
+
62
+ # Create abstract singleton methods
63
+ #
64
+ # @example
65
+ # class Foo
66
+ # include AbstractType
67
+ #
68
+ # # Create an abstract instance method
69
+ # abstract_singleton_method :some_method
70
+ # end
71
+ #
72
+ # @param [Array<#to_s>] names
73
+ #
74
+ # @return [self]
75
+ #
76
+ # @api private
77
+ def abstract_singleton_method(*names)
78
+ names.each { |name| create_abstract_singleton_method(name) }
79
+ self
80
+ end
81
+
82
+ private
83
+
84
+ # Create abstract singleton method
85
+ #
86
+ # @param [#to_s] name
87
+ # the name of the method to create
88
+ #
89
+ # @return [undefined]
90
+ #
91
+ # @api private
92
+ def create_abstract_singleton_method(name)
93
+ define_singleton_method(name) do |*|
94
+ raise NotImplementedError, "#{inspect}.#{name} is not implemented"
95
+ end
96
+ end
97
+
98
+ # Create abstract instance method
99
+ #
100
+ # @param [#to_s] name
101
+ # the name of the method to create
102
+ #
103
+ # @return [undefined]
104
+ #
105
+ # @api private
106
+ def create_abstract_instance_method(name)
107
+ define_method(name) do |*|
108
+ raise NotImplementedError, "#{self.class.inspect}##{name} is not implemented"
109
+ end
110
+ end
111
+
112
+ end # module ClassMethods
113
+ end # module AbstractType
@@ -0,0 +1,8 @@
1
+ # encoding: utf-8
2
+
3
+ module AbstractType
4
+
5
+ # Gem version
6
+ VERSION = '0.0.6'.freeze
7
+
8
+ end # module AbstractType
@@ -0,0 +1,19 @@
1
+ # encoding: utf-8
2
+
3
+ require File.expand_path('../lib/motion_abstract_type/version', __FILE__)
4
+
5
+ Gem::Specification.new do |gem|
6
+ gem.name = 'motion_abstract_type'
7
+ gem.version = AbstractType::VERSION.dup
8
+ gem.authors = [ 'Dan Kubb', 'Ryan Closner' ]
9
+ gem.email = %w[ dan.kubb@gmail.com ryan@ryanclosner.com ]
10
+ gem.description = 'Module to declare abstract classes and methods for RubyMotion'
11
+ gem.summary = gem.description
12
+ gem.homepage = 'https://github.com/rclosner/motion_abstract_type'
13
+
14
+ gem.files = `git ls-files`.split($/)
15
+ gem.test_files = `git ls-files -- spec/unit`.split($/)
16
+ gem.extra_rdoc_files = %w[LICENSE README.md TODO]
17
+
18
+ gem.add_development_dependency('bundler', '~> 1.3', '>= 1.3.5')
19
+ end
@@ -0,0 +1,7 @@
1
+ # encoding: utf-8
2
+
3
+ require 'motion_abstract_type'
4
+ require 'devtools/spec_helper'
5
+
6
+ RSpec.configure do |config|
7
+ end
@@ -0,0 +1,5 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rbconfig'
4
+
5
+ ::Config = RbConfig unless defined?(::Config)
@@ -0,0 +1,36 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe AbstractType::ClassMethods, '#abstract_method' do
6
+ subject { object.abstract_method(:some_method) }
7
+
8
+ let(:object) { Class.new { include AbstractType } }
9
+ let(:subclass) { Class.new(object) }
10
+
11
+ before do
12
+ Subclass = subclass
13
+ end
14
+
15
+ after do
16
+ Object.class_eval { remove_const(:Subclass) }
17
+ end
18
+
19
+ it { should equal(object) }
20
+
21
+ it 'creates an abstract method' do
22
+ expect { subject }.to change { subclass.method_defined?(:some_method) }.
23
+ from(false).
24
+ to(true)
25
+ end
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
+
32
+ it 'creates a method that raises an exception' do
33
+ subject
34
+ expect { subclass.new.some_method }.to raise_error(NotImplementedError, 'Subclass#some_method is not implemented')
35
+ end
36
+ end
@@ -0,0 +1,36 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe AbstractType::ClassMethods, '#abstract_singleton_method' do
6
+ subject { object.abstract_singleton_method(:some_method) }
7
+
8
+ let(:object) { Class.new { include AbstractType } }
9
+ let(:subclass) { Class.new(object) }
10
+
11
+ before do
12
+ Subclass = subclass
13
+ end
14
+
15
+ after do
16
+ Object.class_eval { remove_const(:Subclass) }
17
+ end
18
+
19
+ it { should equal(object) }
20
+
21
+ it 'creates an abstract method' do
22
+ expect { subject }.to change { subclass.respond_to?(:some_method) }.
23
+ from(false).
24
+ to(true)
25
+ end
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
+
32
+ it 'creates a method that raises an exception' do
33
+ subject
34
+ expect { subclass.some_method }.to raise_error(NotImplementedError, 'Subclass.some_method is not implemented')
35
+ end
36
+ end
@@ -0,0 +1,26 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe AbstractType, '.included' do
6
+ subject { object }
7
+
8
+ let(:object) { described_class }
9
+ let(:klass) { Class.new }
10
+
11
+ it 'extends the klass' do
12
+ klass.singleton_class.should_not include(described_class::ClassMethods)
13
+ klass.send(:include, subject)
14
+ klass.singleton_class.should include(described_class::ClassMethods)
15
+ end
16
+
17
+ it 'delegates to the ancestor' do
18
+ included_ancestor = false
19
+ subject.extend Module.new {
20
+ define_method(:included) { |_| included_ancestor = true }
21
+ }
22
+ expect {
23
+ klass.send(:include, subject)
24
+ }.to change { included_ancestor }.from(false).to(true)
25
+ end
26
+ end
@@ -0,0 +1,49 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe AbstractType::ClassMethods, '#new' do
6
+ context 'with arguments' do
7
+ subject { object.new(:foo) }
8
+
9
+ let(:abstract_type) do
10
+ Class.new do
11
+ include AbstractType
12
+
13
+ def initialize(foo)
14
+ @foo = foo
15
+ end
16
+ end
17
+ end
18
+
19
+ context 'called on a subclass' do
20
+ let(:object) { Class.new(abstract_type) }
21
+
22
+ it { should be_instance_of(object) }
23
+ end
24
+
25
+ context 'called on the class' do
26
+ let(:object) { abstract_type }
27
+
28
+ specify { expect { subject }.to raise_error(NotImplementedError, "#{object} is an abstract type") }
29
+ end
30
+ end
31
+
32
+ context 'without arguments' do
33
+ subject { object.new }
34
+
35
+ let(:abstract_type) { Class.new { include AbstractType } }
36
+
37
+ context 'called on a subclass' do
38
+ let(:object) { Class.new(abstract_type) }
39
+
40
+ it { should be_instance_of(object) }
41
+ end
42
+
43
+ context 'called on the class' do
44
+ let(:object) { abstract_type }
45
+
46
+ specify { expect { subject }.to raise_error(NotImplementedError, "#{object} is an abstract type") }
47
+ end
48
+ end
49
+ end
metadata ADDED
@@ -0,0 +1,101 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: motion_abstract_type
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.6
5
+ platform: ruby
6
+ authors:
7
+ - Dan Kubb
8
+ - Ryan Closner
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-08-28 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ~>
19
+ - !ruby/object:Gem::Version
20
+ version: '1.3'
21
+ - - ! '>='
22
+ - !ruby/object:Gem::Version
23
+ version: 1.3.5
24
+ type: :development
25
+ prerelease: false
26
+ version_requirements: !ruby/object:Gem::Requirement
27
+ requirements:
28
+ - - ~>
29
+ - !ruby/object:Gem::Version
30
+ version: '1.3'
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: 1.3.5
34
+ description: Module to declare abstract classes and methods for RubyMotion
35
+ email:
36
+ - dan.kubb@gmail.com
37
+ - ryan@ryanclosner.com
38
+ executables: []
39
+ extensions: []
40
+ extra_rdoc_files:
41
+ - LICENSE
42
+ - README.md
43
+ - TODO
44
+ files:
45
+ - .gitignore
46
+ - .rspec
47
+ - .ruby-gemset
48
+ - .travis.yml
49
+ - CONTRIBUTING.md
50
+ - Gemfile
51
+ - Gemfile.devtools
52
+ - Guardfile
53
+ - LICENSE
54
+ - README.md
55
+ - Rakefile
56
+ - TODO
57
+ - config/flay.yml
58
+ - config/flog.yml
59
+ - config/mutant.yml
60
+ - config/reek.yml
61
+ - config/roodi.yml
62
+ - config/yardstick.yml
63
+ - lib/motion_abstract_type.rb
64
+ - lib/motion_abstract_type/abstract_type.rb
65
+ - lib/motion_abstract_type/version.rb
66
+ - motion_abstract_type.gemspec
67
+ - spec/spec_helper.rb
68
+ - spec/support/config_alias.rb
69
+ - spec/unit/abstract_type/class_methods/abstract_method_spec.rb
70
+ - spec/unit/abstract_type/class_methods/abstract_singleton_method_spec.rb
71
+ - spec/unit/abstract_type/class_methods/included_spec.rb
72
+ - spec/unit/abstract_type/class_methods/new_spec.rb
73
+ homepage: https://github.com/rclosner/motion_abstract_type
74
+ licenses: []
75
+ metadata: {}
76
+ post_install_message:
77
+ rdoc_options: []
78
+ require_paths:
79
+ - lib
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ! '>='
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ! '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ requirements: []
91
+ rubyforge_project:
92
+ rubygems_version: 2.0.6
93
+ signing_key:
94
+ specification_version: 4
95
+ summary: Module to declare abstract classes and methods for RubyMotion
96
+ test_files:
97
+ - spec/unit/abstract_type/class_methods/abstract_method_spec.rb
98
+ - spec/unit/abstract_type/class_methods/abstract_singleton_method_spec.rb
99
+ - spec/unit/abstract_type/class_methods/included_spec.rb
100
+ - spec/unit/abstract_type/class_methods/new_spec.rb
101
+ has_rdoc: