Use abstract support gem instead of homebrew

The support gem is better speced than the homebrew version ever was.
This commit is contained in:
Markus Schirp 2012-08-03 01:28:15 +02:00
parent 51e68800d4
commit 23a04009ce
11 changed files with 19 additions and 87 deletions

View file

@ -3,6 +3,7 @@ source 'https://rubygems.org'
gemspec
gem 'immutable', :git => 'https://github.com/mbj/immutable'
gem 'abstract', :git => 'https://github.com/mbj/abstract'
# Until there is a release with explicit sends to self fix
gem 'to_source', :git => 'https://github.com/mbj/to_source'

View file

@ -1,4 +1,5 @@
require 'immutable'
require 'abstract'
require 'securerandom'
require 'to_source'
require 'ice_nine'
@ -33,7 +34,6 @@ module Mutant
end
end
require 'mutant/support/abstract'
require 'mutant/random'
require 'mutant/runner'
#require 'mutant/runner/rspec'

View file

@ -1,8 +1,7 @@
module Mutant
# An abstract context where mutations can be appied to.
class Context
include Immutable
extend Abstract
include Immutable, Abstract
# Return root ast for mutated node
#
@ -12,6 +11,6 @@ module Mutant
#
# @api private
#
abstract :root
abstract_method :root
end
end

View file

@ -1,8 +1,7 @@
module Mutant
# Abstract matcher to find ASTs to mutate
class Matcher
include Enumerable
extend Abstract
include Enumerable, Abstract
# Enumerate subjects
#
@ -10,7 +9,7 @@ module Mutant
#
# @return [undefined]
#
abstract :each
abstract_method :each
private

View file

@ -86,7 +86,7 @@ module Mutant
#
# @api private
#
abstract :method
abstract_method :method
# Return node classes this matcher matches
#
@ -94,7 +94,7 @@ module Mutant
#
# @api private
#
abstract :node_class
abstract_method :node_class
# Check if node is matched
#
@ -160,7 +160,7 @@ module Mutant
#
# @api private
#
abstract :matched_node
abstract_method :matched_node
# Return subject
#

View file

@ -1,8 +1,7 @@
module Mutant
# Generator for mutations
class Mutator
include Immutable
extend Abstract
include Immutable, Abstract
# Enumerate mutations on node
#
@ -65,7 +64,7 @@ module Mutant
#
# @api private
#
abstract :dispatch
abstract_method :dispatch
# Append node to generated mutations if node does not equal orignal node
#

View file

@ -23,7 +23,7 @@ module Mutant
#
# @api private
#
abstract :inverse
abstract_method :inverse
# Represent mutations of true literal
class TrueLiteral < Boolean

View file

@ -48,7 +48,7 @@ module Mutant
#
# @api private
#
abstract :inverse_class
abstract_method :inverse_class
# Mutator for range exclude literals
class Exclude < Range

View file

@ -1,8 +1,7 @@
module Mutant
# Abstract runner for tests
class Runner
include Immutable
extend Abstract
include Immutable, Abstract
# Run runner
#
@ -75,6 +74,6 @@ module Mutant
#
# @api private
#
abstract :run
abstract_method :run
end
end

View file

@ -1,67 +0,0 @@
module Mutant
# Module to declare abstract methods
module Abstract
# Declare abstract instance method
#
# @return [self]
#
# @api private
#
def abstract(*names)
names.each do |name|
define_instance_method(name)
end
self
end
# Declare abstract singleton method
#
# @return [self]
#
# @api private
#
def abstract_singleton(*names)
names.each do |name|
define_singleton_method(name)
end
self
end
private
# Define abstract method stub on singleton
#
# @param [String] name
#
# @return [undefined]
#
# @api private
#
def define_singleton_method(name)
class_eval(<<-RUBY, __FILE__, __LINE__+1)
def #{name}(*)
raise NotImplementedError, "\#{self.name}.\#{__method__} is not implemented"
end
RUBY
end
# Define abstract method stub on instances
#
# @param [String] name
#
# @return [undefined]
#
# @api private
#
def define_instance_method(name)
class_eval(<<-RUBY, __FILE__, __LINE__+1)
def #{name}(*)
raise NotImplementedError, "\#{self.class.name}#\#{__method__} is not implemented"
end
RUBY
end
end
end

View file

@ -16,7 +16,9 @@ Gem::Specification.new do |gem|
gem.test_files = `git ls-files -- spec`.split("\n")
gem.extra_rdoc_files = %w[TODO]
gem.add_dependency('to_source', '~> 0.1.3')
gem.add_dependency('ice_nine', '~> 0.4.0')
gem.add_runtime_dependency('to_source', '~> 0.1.3')
gem.add_runtime_dependency('ice_nine', '~> 0.4.0')
gem.add_runtime_dependency('backports', '~> 2.6')
gem.add_runtime_dependency('immutable', '~> 0.0.1')
gem.add_runtime_dependency('abstract', '~> 0.0.1')
end