function_importer 0.0.1 → 0.0.2
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.
- data/ChangeLog +18 -0
- data/Rakefile +1 -1
- data/lib/function_importer.rb +9 -0
- data/spec/function_exporter_spec.rb +6 -0
- data/spec/spec.opts +0 -0
- metadata +3 -2
data/ChangeLog
CHANGED
@@ -1,3 +1,21 @@
|
|
1
|
+
commit 1e51372c65043d5e2463a37bee9d3877dfa82190
|
2
|
+
Author: Keiji, Yoshimi <walf443@gmail.com>
|
3
|
+
Date: Wed Apr 1 09:20:26 2009 +0900
|
4
|
+
|
5
|
+
It should raise some Exception when you specify unexist method in export.
|
6
|
+
|
7
|
+
commit 8d0dc0cf4dc6035c6aaefdaa975f94958617a996
|
8
|
+
Author: Keiji, Yoshimi <walf443@gmail.com>
|
9
|
+
Date: Sat Mar 28 20:25:21 2009 +0900
|
10
|
+
|
11
|
+
added dummy spec/spec.opts
|
12
|
+
|
13
|
+
commit e4f54a3ee503eb3847ce9f9b763064420644f180
|
14
|
+
Author: Keiji, Yoshimi <walf443@gmail.com>
|
15
|
+
Date: Sat Mar 28 20:12:44 2009 +0900
|
16
|
+
|
17
|
+
released 0.0.1
|
18
|
+
|
1
19
|
commit 1e41d415433a45ecac051021ac62fd88345c428c
|
2
20
|
Author: Keiji, Yoshimi <walf443@gmail.com>
|
3
21
|
Date: Sat Mar 28 20:00:10 2009 +0900
|
data/Rakefile
CHANGED
data/lib/function_importer.rb
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# add module a method to export function.
|
2
2
|
module FunctionExporter
|
3
|
+
# raise this exception when method is not exist in a module.
|
4
|
+
class NameError < ::NameError; end
|
5
|
+
|
3
6
|
# Example:
|
4
7
|
# module Utils
|
5
8
|
# extend FunctionExporter
|
@@ -55,9 +58,15 @@ module FunctionExporter
|
|
55
58
|
end
|
56
59
|
end
|
57
60
|
|
61
|
+
orig_mod = self
|
58
62
|
parent_mod.module_eval do
|
59
63
|
# renate method.
|
60
64
|
method_of.each do |key, val|
|
65
|
+
begin
|
66
|
+
raise NameError, "no such method #{key} exist in #{orig_mod}" unless instance_method(key)
|
67
|
+
rescue ::NameError => e
|
68
|
+
raise NameError, "no such method #{key} exist in #{orig_mod}"
|
69
|
+
end
|
61
70
|
next if val.kind_of? TrueClass
|
62
71
|
alias_method val, key
|
63
72
|
undef_method key
|
@@ -40,4 +40,10 @@ describe FunctionExporter do
|
|
40
40
|
@export_mod.instance_methods.any? {|i| i.to_s == 'my_escape' }.should be_true
|
41
41
|
end
|
42
42
|
end
|
43
|
+
|
44
|
+
it 'should raise Exception when unexist method' do
|
45
|
+
lambda {
|
46
|
+
@module.create_export_module :no_exist_method_in_module
|
47
|
+
}.should raise_error(FunctionExporter::NameError)
|
48
|
+
end
|
43
49
|
end
|
data/spec/spec.opts
ADDED
File without changes
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: function_importer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Keiji, Yoshimi
|
@@ -9,7 +9,7 @@ autorequire: ""
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-04-01 00:00:00 +09:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -37,6 +37,7 @@ files:
|
|
37
37
|
- ChangeLog
|
38
38
|
- lib/function_importer.rb
|
39
39
|
- spec/function_exporter_spec.rb
|
40
|
+
- spec/spec.opts
|
40
41
|
- spec/spec_helper.rb
|
41
42
|
- tasks/basic_config.rake
|
42
43
|
- tasks/basic_tasks.rake
|