Skip to content
Browse files

Merge branch 'master' of https://github.com/dkubb/abstract_type into …

…fix-new-method-for-classes-without-object-as-their-superclass

Conflicts:
	spec/unit/abstract_type/abstract_method_declarations/included_spec.rb
  • Loading branch information...
2 parents 6ad24c7 + bd4c3b2 commit 79794e559e3e98f35c2c810eda3c8de81dc14012 @misfo misfo committed Oct 5, 2013
View
1 .rspec
@@ -1,4 +1,5 @@
--color
--format progress
--profile
+--warnings
--order random
View
27 .travis.yml
@@ -1,30 +1,23 @@
language: ruby
before_install: gem install bundler
-bundler_args: --without yard guard metrics benchmarks
+bundler_args: --without yard guard benchmarks
script: "bundle exec rake ci"
rvm:
- - 1.9.2
- 1.9.3
- 2.0.0
- - rbx-19mode
- - jruby-19mode
- ruby-head
-notifications:
- irc:
- channels:
- - irc.freenode.org#rom-rb
- on_success: never
- on_failure: change
- email:
- recipients:
- - dan.kubb@gmail.com
- on_success: never
- on_failure: change
+ - rbx-19mode
matrix:
- allow_failures:
- - rvm: ruby-head
include:
- rvm: jruby-19mode
env: JRUBY_OPTS="$JRUBY_OPTS --debug"
- rvm: jruby-head
env: JRUBY_OPTS="$JRUBY_OPTS --debug"
+ allow_failures:
+ - rvm: ruby-head # travis broken
+notifications:
+ irc:
+ channels:
+ - irc.freenode.org#rom-rb
+ on_success: never
+ on_failure: change
View
7 Gemfile
@@ -4,5 +4,8 @@ source 'https://rubygems.org'
gemspec
-gem 'devtools', :git => 'https://github.com/rom-rb/devtools.git'
-eval File.read('Gemfile.devtools')
+group :development, :test do
+ gem 'devtools', git: 'https://github.com/rom-rb/devtools.git'
+end
+
+eval_gemfile 'Gemfile.devtools'
View
42 Gemfile.devtools
@@ -2,49 +2,45 @@
group :development do
gem 'rake', '~> 10.1.0'
- gem 'rspec', '~> 2.13.0'
- gem 'yard', '~> 0.8.6.1'
+ gem 'rspec', '~> 2.14.1'
+ gem 'yard', '~> 0.8.7'
end
group :yard do
- gem 'kramdown', '~> 1.0.1'
+ gem 'kramdown', '~> 1.2.0'
end
group :guard do
gem 'guard', '~> 1.8.1'
gem 'guard-bundler', '~> 1.0.0'
gem 'guard-rspec', '~> 3.0.2'
+ gem 'guard-rubocop', '~> 0.2.0'
+ gem 'guard-mutant', '~> 0.0.1'
# file system change event handling
- gem 'listen', '~> 1.2.2'
- gem 'rb-fchange', '~> 0.0.6', :require => false
- gem 'rb-fsevent', '~> 0.9.3', :require => false
- gem 'rb-inotify', '~> 0.9.0', :require => false
+ gem 'listen', '~> 1.3.0'
+ gem 'rb-fchange', '~> 0.0.6', require: false
+ gem 'rb-fsevent', '~> 0.9.3', require: false
+ gem 'rb-inotify', '~> 0.9.0', require: false
# notification handling
- gem 'libnotify', '~> 0.8.0', :require => false
- gem 'rb-notifu', '~> 0.0.4', :require => false
- gem 'terminal-notifier-guard', '~> 1.5.3', :require => false
+ gem 'libnotify', '~> 0.8.0', require: false
+ gem 'rb-notifu', '~> 0.0.4', require: false
+ gem 'terminal-notifier-guard', '~> 1.5.3', require: false
end
group :metrics do
gem 'coveralls', '~> 0.6.7'
- gem 'flay', '~> 2.3.0'
- gem 'flog', '~> 4.1.0'
- gem 'reek', '~> 1.3.1', :git => 'https://github.com/troessner/reek.git'
+ gem 'flay', '~> 2.4.0'
+ gem 'flog', '~> 4.1.1'
+ gem 'reek', '~> 1.3.2'
+ gem 'rubocop', '~> 0.13.0'
gem 'simplecov', '~> 0.7.1'
- gem 'yardstick', '~> 0.9.6'
-
- platforms :ruby_19 do
- gem 'yard-spellcheck', '~> 0.1.5'
- end
+ gem 'yardstick', '~> 0.9.7', git: 'https://github.com/dkubb/yardstick.git'
platforms :ruby_19, :ruby_20 do
- gem 'mutant', '~> 0.3.0.beta6'
- end
-
- platforms :rbx do
- gem 'pelusa', '~> 0.2.2'
+ gem 'mutant', git: 'https://github.com/mbj/mutant.git'
+ gem 'yard-spellcheck', '~> 0.1.5'
end
end
View
44 README.md
@@ -1,5 +1,7 @@
-abstract_type
-==============
+# abstract_type
+
+This is a small standalone gem featuring a module ripped out from [axiom](https://github.com/dkubb/axiom).
+It allows to declare abstract_type classes and modules in an unobstrusive way.
[![Gem Version](https://badge.fury.io/rb/abstract_type.png)][gem]
[![Build Status](https://secure.travis-ci.org/dkubb/abstract_type.png?branch=master)][travis]
@@ -13,34 +15,7 @@ abstract_type
[codeclimate]: https://codeclimate.com/github/dkubb/abstract_type
[coveralls]: https://coveralls.io/r/dkubb/abstract_type
-This is a small standalone gem featuring a module ripped out from [axiom](https://github.com/dkubb/axiom).
-It allows to declare abstract_type classes and modules in an unobstrusive way.
-
-Installation
-------------
-
-With Rubygems:
-
-```bash
-$ gem install abstract_type
-$ irb -rubygems
->> require 'abstract_type'
-=> true
-```
-
-With git and local working copy:
-
-```bash
-$ git clone git://github.com/dkubb/abstract_type.git
-$ cd abstract_type
-$ rake install
-$ irb -rubygems
->> require 'abstract_type'
-=> true
-```
-
-Examples
---------
+## Examples
``` ruby
class Foo
@@ -64,18 +39,15 @@ object.bar # raises NotImplementedError: Baz#bar is not implemented
```
-Credits
--------
+## Credits
* Dan Kubb ([dkubb](https://github.com/dkubb))
* Markus Schirp ([mbj](https://github.com/mbj))
-Contributing
-------------
+## Contributing
See [CONTRIBUTING.md](CONTRIBUTING.md) for details.
-Copyright
----------
+## Copyright
Copyright © 2009-2013 Dan Kubb. See LICENSE for details.
View
3 abstract_type.gemspec
@@ -10,10 +10,11 @@ Gem::Specification.new do |gem|
gem.description = 'Module to declare abstract classes and methods'
gem.summary = gem.description
gem.homepage = 'https://github.com/dkubb/abstract_type'
+ gem.license = 'MIT'
gem.files = `git ls-files`.split($/)
gem.test_files = `git ls-files -- spec/unit`.split($/)
- gem.extra_rdoc_files = %w[LICENSE README.md TODO]
+ gem.extra_rdoc_files = %w[LICENSE README.md CONTRIBUTING.md TODO]
gem.add_development_dependency('bundler', '~> 1.3', '>= 1.3.5')
end
View
2 config/flog.yml
@@ -1,2 +1,2 @@
---
-threshold: 9.0
+threshold: 7.5
View
62 config/rubocop.yml
@@ -0,0 +1,62 @@
+AllCops:
+ Includes:
+ - '../**/*.rake'
+ - 'Gemfile'
+ - 'Gemfile.devtools'
+ Excludes:
+ - '**/vendor/**'
+ - '**/benchmarks/**'
+
+# Avoid parameter lists longer than five parameters.
+ParameterLists:
+ Max: 3
+ CountKeywordArgs: true
+
+# Avoid more than `Max` levels of nesting.
+BlockNesting:
+ Max: 3
+
+# Align with the style guide.
+CollectionMethods:
+ PreferredMethods:
+ collect: 'map'
+ inject: 'reduce'
+ find: 'detect'
+ find_all: 'select'
+
+# Do not force public/protected/private keyword to be indented at the same
+# level as the def keyword. My personal preference is to outdent these keywords
+# because I think when scanning code it makes it easier to identify the
+# sections of code and visually separate them. When the keyword is at the same
+# level I think it sort of blends in with the def keywords and makes it harder
+# to scan the code and see where the sections are.
+AccessControl:
+ Enabled: false
+
+# Limit line length
+LineLength:
+ Max: 79
+
+# Disable documentation checking until a class needs to be documented once
+Documentation:
+ Enabled: false
+
+# Do not always use &&/|| instead of and/or.
+AndOr:
+ Enabled: false
+
+# Do not favor modifier if/unless usage when you have a single-line body
+IfUnlessModifier:
+ Enabled: false
+
+# Allow case equality operator (in limited use within the specs)
+CaseEquality:
+ Enabled: false
+
+# Constants do not always have to use SCREAMING_SNAKE_CASE
+ConstantName:
+ Enabled: false
+
+# Not all trivial readers/writers can be defined with attr_* methods
+TrivialAccessors:
+ Enabled: false
View
2 lib/abstract_type.rb
@@ -109,7 +109,7 @@ def create_abstract_singleton_method(name)
# @api private
def create_abstract_instance_method(name)
define_method(name) do |*|
- raise NotImplementedError, "#{self.class.inspect}##{name} is not implemented"
+ raise NotImplementedError, "#{self.class}##{name} is not implemented"
end
end
View
25 spec/spec_helper.rb
@@ -1,7 +1,30 @@
# encoding: utf-8
-require 'abstract_type'
+if ENV['COVERAGE'] == 'true'
+ require 'simplecov'
+ require 'coveralls'
+
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
+ SimpleCov::Formatter::HTMLFormatter,
+ Coveralls::SimpleCov::Formatter
+ ]
+
+ SimpleCov.start do
+ command_name 'spec:unit'
+
+ add_filter 'config'
+ add_filter 'spec'
+ add_filter 'vendor'
+
+ minimum_coverage 100
+ end
+end
+
require 'devtools/spec_helper'
+require 'abstract_type'
RSpec.configure do |config|
+ config.expect_with :rspec do |expect_with|
+ expect_with.syntax = :expect
+ end
end
View
13 spec/unit/abstract_type/abstract_method_declarations/abstract_method_spec.rb
@@ -19,18 +19,21 @@
it { should equal(object) }
it 'creates an abstract method' do
- expect { subject }.to change { subclass.method_defined?(:some_method) }.
- from(false).
- to(true)
+ expect { subject }.to change { subclass.method_defined?(:some_method) }
+ .from(false)
+ .to(true)
end
it 'creates an abstract method with the expected arity' do
subject
- object.instance_method(:some_method).arity.should be(-1)
+ expect(object.instance_method(:some_method).arity).to be(-1)
end
it 'creates a method that raises an exception' do
subject
- expect { subclass.new.some_method }.to raise_error(NotImplementedError, 'Subclass#some_method is not implemented')
+ expect { subclass.new.some_method }.to raise_error(
+ NotImplementedError,
+ 'Subclass#some_method is not implemented'
+ )
end
end
View
13 spec/unit/abstract_type/abstract_method_declarations/abstract_singleton_method_spec.rb
@@ -19,18 +19,21 @@
it { should equal(object) }
it 'creates an abstract method' do
- expect { subject }.to change { subclass.respond_to?(:some_method) }.
- from(false).
- to(true)
+ expect { subject }.to change { subclass.respond_to?(:some_method) }
+ .from(false)
+ .to(true)
end
it 'creates an abstract method with the expected arity' do
subject
- object.method(:some_method).arity.should be(-1)
+ expect(object.method(:some_method).arity).to be(-1)
end
it 'creates a method that raises an exception' do
subject
- expect { subclass.some_method }.to raise_error(NotImplementedError, 'Subclass.some_method is not implemented')
+ expect { subclass.some_method }.to raise_error(
+ NotImplementedError,
+ 'Subclass.some_method is not implemented'
+ )
end
end
View
9 spec/unit/abstract_type/abstract_method_declarations/included_spec.rb
@@ -9,18 +9,17 @@
let(:klass) { Class.new }
it 'extends the klass' do
- klass.singleton_class.should_not include(described_class::AbstractMethodDeclarations)
+ expect(klass.singleton_class).to_not include(described_class::AbstractMethodDeclarations)
klass.send(:include, subject)
- klass.singleton_class.should include(described_class::AbstractMethodDeclarations)
+ expect(klass.singleton_class).to include(described_class::AbstractMethodDeclarations)
end
it 'delegates to the ancestor' do
included_ancestor = false
subject.extend Module.new {
define_method(:included) { |_| included_ancestor = true }
}
- expect {
- klass.send(:include, subject)
- }.to change { included_ancestor }.from(false).to(true)
+ expect { klass.send(:include, subject) }
+ .to change { included_ancestor }.from(false).to(true)
end
end
View
14 spec/unit/abstract_type/module_methods/create_new_method_spec.rb
@@ -25,7 +25,12 @@ def initialize(foo)
context 'called on the class' do
let(:object) { abstract_type }
- specify { expect { subject }.to raise_error(NotImplementedError, "#{object} is an abstract type") }
+ specify do
+ expect { subject }.to raise_error(
+ NotImplementedError,
+ "#{object} is an abstract type"
+ )
+ end
end
end
@@ -43,7 +48,12 @@ def initialize(foo)
context 'called on the class' do
let(:object) { abstract_type }
- specify { expect { subject }.to raise_error(NotImplementedError, "#{object} is an abstract type") }
+ specify do
+ expect { subject }.to raise_error(
+ NotImplementedError,
+ "#{object} is an abstract type"
+ )
+ end
end
end

0 comments on commit 79794e5

Please sign in to comment.
Something went wrong with that request. Please try again.