rubysl-e2mmap 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 346bf1dcdde5b69543447281363a996392422990
4
+ data.tar.gz: ddbbb3a0c8e4b5ff355522bc78c17ac828ec770b
5
+ SHA512:
6
+ metadata.gz: 020b324df8806e79016476f329ba2683a777e062555dbf9a3fcf080de9b5debb997a11f5090bd9eb36051e71f47b17ebc91cfdf92cb9aa8dd5d8ee6ff2a28d9c
7
+ data.tar.gz: cba3d12fcb4368c30dd660465637f6e5a73bceb4ae235ede17352f25bb9fa917727c96eee13a4d650ea48e659efaa73a84dc4e7edb984499b5326026fbf9a541
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.travis.yml ADDED
@@ -0,0 +1,8 @@
1
+ language: ruby
2
+ before_install:
3
+ - gem update --system
4
+ - gem --version
5
+ - gem install rubysl-bundler
6
+ script: bundle exec mspec spec
7
+ rvm:
8
+ - rbx-nightly-18mode
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rubysl-e2mmap.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,25 @@
1
+ Copyright (c) 2013, Brian Shirai
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions are met:
6
+
7
+ 1. Redistributions of source code must retain the above copyright notice, this
8
+ list of conditions and the following disclaimer.
9
+ 2. Redistributions in binary form must reproduce the above copyright notice,
10
+ this list of conditions and the following disclaimer in the documentation
11
+ and/or other materials provided with the distribution.
12
+ 3. Neither the name of the library nor the names of its contributors may be
13
+ used to endorse or promote products derived from this software without
14
+ specific prior written permission.
15
+
16
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19
+ DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY DIRECT,
20
+ INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21
+ BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
23
+ OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
24
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
25
+ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Rubysl::E2mmap
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'rubysl-e2mmap'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install rubysl-e2mmap
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/lib/e2mmap.rb ADDED
@@ -0,0 +1 @@
1
+ require "rubysl/e2mmap"
@@ -0,0 +1,2 @@
1
+ require "rubysl/e2mmap/e2mmap"
2
+ require "rubysl/e2mmap/version"
@@ -0,0 +1,191 @@
1
+ #
2
+ # e2mmap.rb - for ruby 1.1
3
+ # $Release Version: 2.0$
4
+ # $Revision: 1.10 $
5
+ # $Date: 1999/02/17 12:33:17 $
6
+ # by Keiju ISHITSUKA
7
+ #
8
+ # --
9
+ # Usage:
10
+ #
11
+ # U1)
12
+ # class Foo
13
+ # extend Exception2MessageMapper
14
+ # def_e2message ExistingExceptionClass, "message..."
15
+ # def_exception :NewExceptionClass, "message..."[, superclass]
16
+ # ...
17
+ # end
18
+ #
19
+ # U2)
20
+ # module Error
21
+ # extend Exception2MessageMapper
22
+ # def_e2meggage ExistingExceptionClass, "message..."
23
+ # def_exception :NewExceptionClass, "message..."[, superclass]
24
+ # ...
25
+ # end
26
+ # class Foo
27
+ # include Error
28
+ # ...
29
+ # end
30
+ #
31
+ # foo = Foo.new
32
+ # foo.Fail ....
33
+ #
34
+ # U3)
35
+ # module Error
36
+ # extend Exception2MessageMapper
37
+ # def_e2message ExistingExceptionClass, "message..."
38
+ # def_exception :NewExceptionClass, "message..."[, superclass]
39
+ # ...
40
+ # end
41
+ # class Foo
42
+ # extend Exception2MessageMapper
43
+ # include Error
44
+ # ...
45
+ # end
46
+ #
47
+ # Foo.Fail NewExceptionClass, arg...
48
+ # Foo.Fail ExistingExceptionClass, arg...
49
+ #
50
+ #
51
+ fail "Use Ruby 1.1" if VERSION < "1.1"
52
+
53
+ module Exception2MessageMapper
54
+ @RCS_ID='-$Id: e2mmap.rb,v 1.10 1999/02/17 12:33:17 keiju Exp keiju $-'
55
+
56
+ E2MM = Exception2MessageMapper
57
+
58
+ def E2MM.extend_object(cl)
59
+ super
60
+ cl.bind(self) unless cl == E2MM
61
+ end
62
+
63
+ # backward compatibility
64
+ def E2MM.extend_to(b)
65
+ c = eval("self", b)
66
+ c.extend(self)
67
+ end
68
+
69
+ def bind(cl)
70
+ self.module_eval %[
71
+ def Raise(err = nil, *rest)
72
+ Exception2MessageMapper.Raise(self.class, err, *rest)
73
+ end
74
+ alias Fail Raise
75
+
76
+ def self.included(mod)
77
+ mod.extend Exception2MessageMapper
78
+ end
79
+ ]
80
+ end
81
+
82
+ # Fail(err, *rest)
83
+ # err: exception
84
+ # rest: message arguments
85
+ #
86
+ def Raise(err=nil, *rest)
87
+ E2MM.Raise(self, err, *rest)
88
+ end
89
+ alias Fail Raise
90
+
91
+ # backward compatibility
92
+ alias fail! fail
93
+ def fail(err=nil, *rest)
94
+ begin
95
+ E2MM.Fail(self, err, *rest)
96
+ rescue E2MM::ErrNotRegisteredException
97
+ super
98
+ end
99
+ end
100
+ class << self
101
+ public :fail
102
+ end
103
+
104
+
105
+ # def_e2message(c, m)
106
+ # c: exception
107
+ # m: message_form
108
+ # define exception c with message m.
109
+ #
110
+ def def_e2message(c, m)
111
+ E2MM.def_e2message(self, c, m)
112
+ end
113
+
114
+ # def_exception(n, m, s)
115
+ # n: exception_name
116
+ # m: message_form
117
+ # s: superclass(default: StandardError)
118
+ # define exception named ``c'' with message m.
119
+ #
120
+ def def_exception(n, m, s=StandardError)
121
+ E2MM.def_exception(self, n, m, s)
122
+ end
123
+
124
+ #
125
+ # Private definitions.
126
+ #
127
+ # {[class, exp] => message, ...}
128
+ @MessageMap = {}
129
+
130
+ # E2MM.def_exception(k, e, m)
131
+ # k: class to define exception under.
132
+ # e: exception
133
+ # m: message_form
134
+ # define exception c with message m.
135
+ #
136
+ def E2MM.def_e2message(k, c, m)
137
+ E2MM.instance_eval { @MessageMap[[k, c]] = m }
138
+ c
139
+ end
140
+
141
+ # E2MM.def_exception(k, n, m, s)
142
+ # k: class to define exception under.
143
+ # n: exception_name
144
+ # m: message_form
145
+ # s: superclass(default: StandardError)
146
+ # define exception named ``c'' with message m.
147
+ #
148
+ def E2MM.def_exception(k, n, m, s=StandardError)
149
+ e = Class.new(s)
150
+ E2MM.instance_eval { @MessageMap[[k, e]] = m }
151
+ k.const_set(n, e)
152
+ end
153
+
154
+ # Fail(klass, err, *rest)
155
+ # klass: class to define exception under.
156
+ # err: exception
157
+ # rest: message arguments
158
+ #
159
+ def E2MM.Raise(klass=E2MM, err=nil, *rest)
160
+ if form = e2mm_message(klass, err)
161
+ raise err, sprintf(form, *rest)
162
+ else
163
+ E2MM.Fail E2MM, ErrNotRegisteredException, err.inspect
164
+ end
165
+ end
166
+
167
+ class <<E2MM
168
+ alias Fail Raise
169
+ end
170
+
171
+ def E2MM.e2mm_message(klass, exp)
172
+ for c in klass.ancestors
173
+ if mes = @MessageMap[[c,exp]]
174
+ #p mes
175
+ m = klass.instance_eval('"' + mes + '"')
176
+ return m
177
+ end
178
+ end
179
+ nil
180
+ end
181
+
182
+ class <<self
183
+ alias message e2mm_message
184
+ end
185
+
186
+ E2MM.def_exception(E2MM,
187
+ :ErrNotRegisteredException,
188
+ "not registerd exception(%s)")
189
+ end
190
+
191
+
@@ -0,0 +1,5 @@
1
+ module RubySL
2
+ module Exception2MessageMapper
3
+ VERSION = "1.0.0"
4
+ end
5
+ end
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ require './lib/rubysl/e2mmap/version'
3
+
4
+ Gem::Specification.new do |spec|
5
+ spec.name = "rubysl-e2mmap"
6
+ spec.version = RubySL::Exception2MessageMapper::VERSION
7
+ spec.authors = ["Brian Shirai"]
8
+ spec.email = ["brixen@gmail.com"]
9
+ spec.description = %q{Ruby standard library e2mmap.}
10
+ spec.summary = %q{Ruby standard library e2mmap.}
11
+ spec.homepage = "https://github.com/rubysl/rubysl-e2mmap"
12
+ spec.license = "BSD"
13
+
14
+ spec.files = `git ls-files`.split($/)
15
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
16
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
17
+ spec.require_paths = ["lib"]
18
+
19
+ spec.add_development_dependency "bundler", "~> 1.3"
20
+ spec.add_development_dependency "rake", "~> 10.0"
21
+ spec.add_development_dependency "mspec", "~> 1.5"
22
+ spec.add_development_dependency "rubysl-prettyprint", "~> 1.0"
23
+ end
metadata ADDED
@@ -0,0 +1,112 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rubysl-e2mmap
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Brian Shirai
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-09-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: mspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '1.5'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.5'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubysl-prettyprint
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '1.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '1.0'
69
+ description: Ruby standard library e2mmap.
70
+ email:
71
+ - brixen@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - .gitignore
77
+ - .travis.yml
78
+ - Gemfile
79
+ - LICENSE
80
+ - README.md
81
+ - Rakefile
82
+ - lib/e2mmap.rb
83
+ - lib/rubysl/e2mmap.rb
84
+ - lib/rubysl/e2mmap/e2mmap.rb
85
+ - lib/rubysl/e2mmap/version.rb
86
+ - rubysl-e2mmap.gemspec
87
+ homepage: https://github.com/rubysl/rubysl-e2mmap
88
+ licenses:
89
+ - BSD
90
+ metadata: {}
91
+ post_install_message:
92
+ rdoc_options: []
93
+ require_paths:
94
+ - lib
95
+ required_ruby_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - '>='
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ required_rubygems_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - '>='
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ requirements: []
106
+ rubyforge_project:
107
+ rubygems_version: 2.0.3
108
+ signing_key:
109
+ specification_version: 4
110
+ summary: Ruby standard library e2mmap.
111
+ test_files: []
112
+ has_rdoc: