summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHiroshi SHIBATA <hsbt@ruby-lang.org>2019-11-27 12:17:03 +0900
committerSHIBATA Hiroshi <hsbt@ruby-lang.org>2019-11-30 08:00:40 +0900
commitf47f2076fed1546d993a376ce3c35ca81b1f0c6a (patch)
tree5dcb0a4b596136da68b7145c047e23b4978255ff
parent04511b994e19de65fff84dd55a246842a2f9ad29 (diff)
downloadruby-f47f2076fed1546d993a376ce3c35ca81b1f0c6a.tar.gz
Retire to maintain e2mmap on ruby core
-rw-r--r--lib/e2mmap.rb177
-rw-r--r--lib/e2mmap/e2mmap.gemspec26
-rw-r--r--lib/e2mmap/version.rb3
3 files changed, 0 insertions, 206 deletions
diff --git a/lib/e2mmap.rb b/lib/e2mmap.rb
deleted file mode 100644
index 1c1d7148ff..0000000000
--- a/lib/e2mmap.rb
+++ /dev/null
@@ -1,177 +0,0 @@
-# frozen_string_literal: true
-#
-#--
-# e2mmap.rb - for Ruby 1.1
-# $Release Version: 2.0$
-# $Revision: 1.10 $
-# by Keiju ISHITSUKA
-#
-#++
-#
-# Helper module for easily defining exceptions with predefined messages.
-#
-# == Usage
-#
-# 1.
-# class Foo
-# extend Exception2MessageMapper
-# def_e2message ExistingExceptionClass, "message..."
-# def_exception :NewExceptionClass, "message..."[, superclass]
-# ...
-# end
-#
-# 2.
-# module Error
-# extend Exception2MessageMapper
-# def_e2message ExistingExceptionClass, "message..."
-# def_exception :NewExceptionClass, "message..."[, superclass]
-# ...
-# end
-# class Foo
-# include Error
-# ...
-# end
-#
-# foo = Foo.new
-# foo.Fail ....
-#
-# 3.
-# module Error
-# extend Exception2MessageMapper
-# def_e2message ExistingExceptionClass, "message..."
-# def_exception :NewExceptionClass, "message..."[, superclass]
-# ...
-# end
-# class Foo
-# extend Exception2MessageMapper
-# include Error
-# ...
-# end
-#
-# Foo.Fail NewExceptionClass, arg...
-# Foo.Fail ExistingExceptionClass, arg...
-#
-#
-module Exception2MessageMapper
-
- E2MM = Exception2MessageMapper # :nodoc:
-
- def E2MM.extend_object(cl)
- super
- cl.bind(self) unless cl < E2MM
- end
-
- def bind(cl)
- self.module_eval "#{<<-"begin;"}\n#{<<-"end;"}", __FILE__, __LINE__+1
- begin;
- def Raise(err = nil, *rest)
- Exception2MessageMapper.Raise(self.class, err, *rest)
- end
- alias Fail Raise
-
- class << self
- undef included
- end
- def self.included(mod)
- mod.extend Exception2MessageMapper
- end
- end;
- end
-
- # Fail(err, *rest)
- # err: exception
- # rest: message arguments
- #
- def Raise(err = nil, *rest)
- E2MM.Raise(self, err, *rest)
- end
- alias Fail Raise
- alias fail Raise
-
- # def_e2message(c, m)
- # c: exception
- # m: message_form
- # define exception c with message m.
- #
- def def_e2message(c, m)
- E2MM.def_e2message(self, c, m)
- end
-
- # def_exception(n, m, s)
- # n: exception_name
- # m: message_form
- # s: superclass(default: StandardError)
- # define exception named ``c'' with message m.
- #
- def def_exception(n, m, s = StandardError)
- E2MM.def_exception(self, n, m, s)
- end
-
- #
- # Private definitions.
- #
- # {[class, exp] => message, ...}
- @MessageMap = {}
-
- # E2MM.def_e2message(k, e, m)
- # k: class to define exception under.
- # e: exception
- # m: message_form
- # define exception c with message m.
- #
- def E2MM.def_e2message(k, c, m)
- E2MM.instance_eval{@MessageMap[[k, c]] = m}
- c
- end
-
- # E2MM.def_exception(k, n, m, s)
- # k: class to define exception under.
- # n: exception_name
- # m: message_form
- # s: superclass(default: StandardError)
- # define exception named ``c'' with message m.
- #
- def E2MM.def_exception(k, n, m, s = StandardError)
- e = Class.new(s)
- E2MM.instance_eval{@MessageMap[[k, e]] = m}
- k.module_eval {remove_const(n)} if k.const_defined?(n, false)
- k.const_set(n, e)
- end
-
- # Fail(klass, err, *rest)
- # klass: class to define exception under.
- # err: exception
- # rest: message arguments
- #
- def E2MM.Raise(klass = E2MM, err = nil, *rest)
- if form = e2mm_message(klass, err)
- b = $@.nil? ? caller(1) : $@
- b.shift if b[0] =~ /^#{Regexp.quote(__FILE__)}:/
- raise err, sprintf(form, *rest), b
- else
- E2MM.Fail E2MM, ErrNotRegisteredException, err.inspect
- end
- end
- class << E2MM
- alias Fail Raise
- end
-
- def E2MM.e2mm_message(klass, exp)
- for c in klass.ancestors
- if mes = @MessageMap[[c,exp]]
- m = klass.instance_eval('"' + mes + '"')
- return m
- end
- end
- nil
- end
- class << self
- alias message e2mm_message
- end
-
- E2MM.def_exception(E2MM,
- :ErrNotRegisteredException,
- "not registered exception(%s)")
-end
-
-
diff --git a/lib/e2mmap/e2mmap.gemspec b/lib/e2mmap/e2mmap.gemspec
deleted file mode 100644
index fc3efde04b..0000000000
--- a/lib/e2mmap/e2mmap.gemspec
+++ /dev/null
@@ -1,26 +0,0 @@
-begin
- require_relative "lib/e2mmap/version"
-rescue LoadError
- # for Ruby core repository
- require_relative "version"
-end
-
-Gem::Specification.new do |spec|
- spec.name = "e2mmap"
- spec.version = Exception2MessageMapper::VERSION
- spec.authors = ["Keiju ISHITSUKA"]
- spec.email = ["keiju@ruby-lang.org"]
-
- spec.summary = %q{Module for defining custom exceptions with specific messages.}
- spec.description = %q{Module for defining custom exceptions with specific messages.}
- spec.homepage = "https://github.com/ruby/e2mmap"
- spec.license = "BSD-2-Clause"
-
- spec.files = [".gitignore", "Gemfile", "LICENSE.txt", "README.md", "Rakefile", "bin/console", "bin/setup", "e2mmap.gemspec", "lib/e2mmap.rb", "lib/e2mmap/version.rb"]
- spec.bindir = "exe"
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
- spec.require_paths = ["lib"]
-
- spec.add_development_dependency "bundler", "~> 1.16"
- spec.add_development_dependency "rake", "~> 10.0"
-end
diff --git a/lib/e2mmap/version.rb b/lib/e2mmap/version.rb
deleted file mode 100644
index c459aeace3..0000000000
--- a/lib/e2mmap/version.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-module Exception2MessageMapper
- VERSION = "0.1.0"
-end