rubinjam 0.2.0 → 0.3.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.
- data/lib/rubinjam/version.rb +1 -1
- data/lib/rubinjam.rb +82 -6
- metadata +51 -32
- checksums.yaml +0 -7
data/lib/rubinjam/version.rb
CHANGED
data/lib/rubinjam.rb
CHANGED
@@ -84,15 +84,91 @@ module Rubinjam
|
|
84
84
|
#{libraries.map { |name,content| "#{name.inspect} => #{content.inspect}" }.join(",\n ")}
|
85
85
|
}
|
86
86
|
|
87
|
-
ROOT = File.expand_path("../", __FILE__) << "/
|
87
|
+
ROOT = File.expand_path("../", __FILE__) << "/rubinjam/"
|
88
88
|
|
89
|
-
|
89
|
+
class << self
|
90
|
+
def normalize_file(file)
|
91
|
+
return file unless file.start_with?("/")
|
92
|
+
if file.start_with?(ROOT)
|
93
|
+
file.sub(ROOT, "")
|
94
|
+
else
|
95
|
+
file.split('/lib/').last
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
def file_from_nesting(mod, const)
|
100
|
+
if file = mod.rubinjam_autload[const]
|
101
|
+
return [mod, file]
|
102
|
+
end
|
103
|
+
|
104
|
+
nesting(mod.name)[1..-1].detect do |mod|
|
105
|
+
file = mod.rubinjam_autload[const]
|
106
|
+
break [mod, file] if file
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
# this does not reflect the actual Module.nesting of the caller,
|
111
|
+
# but it should be close enough
|
112
|
+
def nesting(name)
|
113
|
+
nesting = []
|
114
|
+
namespace = name.split("::")
|
115
|
+
namespace.inject(Object) do |base, n|
|
116
|
+
klass = base.const_get(n)
|
117
|
+
nesting << klass
|
118
|
+
klass
|
119
|
+
end
|
120
|
+
nesting.reverse
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
module ModuleAutoloadFix
|
90
125
|
def self.included(base)
|
91
126
|
base.class_eval do
|
127
|
+
def rubinjam_autload
|
128
|
+
@rubinjam_autload ||= {}
|
129
|
+
end
|
130
|
+
|
92
131
|
alias autoload_without_rubinjam autoload
|
93
132
|
def autoload(const, file)
|
94
|
-
|
133
|
+
normalized_file = Rubinjam.normalize_file(file)
|
134
|
+
if Rubinjam::LIBRARIES[normalized_file]
|
135
|
+
rubinjam_autload[const] = normalized_file
|
136
|
+
else
|
137
|
+
autoload_without_rubinjam(const, file)
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
alias const_missing_without_rubinjam const_missing
|
142
|
+
def const_missing(const)
|
143
|
+
# do not load twice / go into infitire loops
|
144
|
+
@rubinjam_tried_const_missing ||= {}
|
145
|
+
if @rubinjam_tried_const_missing[const]
|
146
|
+
return const_missing_without_rubinjam(const)
|
147
|
+
end
|
148
|
+
@rubinjam_tried_const_missing[const] = true
|
149
|
+
|
150
|
+
# try to find autoload in current module or nesting
|
151
|
+
nesting, file = Rubinjam.file_from_nesting(self, const)
|
152
|
+
if file
|
95
153
|
require file
|
154
|
+
nesting.const_get(const)
|
155
|
+
else
|
156
|
+
const_missing_without_rubinjam(const)
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
module BaseAutoloadFix
|
164
|
+
def self.included(base)
|
165
|
+
base.class_eval do
|
166
|
+
alias autoload_without_rubinjam autoload
|
167
|
+
|
168
|
+
def autoload(const, file)
|
169
|
+
normalized_file = Rubinjam.normalize_file(file)
|
170
|
+
if Rubinjam::LIBRARIES[normalized_file]
|
171
|
+
require normalized_file
|
96
172
|
else
|
97
173
|
autoload_without_rubinjam(const, file)
|
98
174
|
end
|
@@ -102,11 +178,11 @@ module Rubinjam
|
|
102
178
|
end
|
103
179
|
end
|
104
180
|
|
105
|
-
Module.send(:include, Rubinjam::
|
106
|
-
include Rubinjam::
|
181
|
+
Module.send(:include, Rubinjam::ModuleAutoloadFix)
|
182
|
+
include Rubinjam::BaseAutoloadFix
|
107
183
|
|
108
184
|
def require(file)
|
109
|
-
normalized_file =
|
185
|
+
normalized_file = Rubinjam.normalize_file(file)
|
110
186
|
if code = Rubinjam::LIBRARIES[normalized_file]
|
111
187
|
return if code == :loaded
|
112
188
|
eval(code, TOPLEVEL_BINDING, "rubinjam/\#{normalized_file}.rb")
|
metadata
CHANGED
@@ -1,62 +1,81 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubinjam
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 19
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 3
|
9
|
+
- 0
|
10
|
+
version: 0.3.0
|
5
11
|
platform: ruby
|
6
|
-
authors:
|
12
|
+
authors:
|
7
13
|
- Michael Grosser
|
8
14
|
autorequire:
|
9
15
|
bindir: bin
|
10
16
|
cert_chain: []
|
11
|
-
|
12
|
-
|
13
|
-
|
17
|
+
|
18
|
+
date: 2014-12-20 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
prerelease: false
|
14
22
|
name: bundler
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
20
23
|
type: :runtime
|
21
|
-
|
22
|
-
|
23
|
-
requirements:
|
24
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
24
27
|
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
version: "0"
|
33
|
+
requirement: *id001
|
27
34
|
description:
|
28
35
|
email: michael@grosser.it
|
29
|
-
executables:
|
36
|
+
executables:
|
30
37
|
- rubinjam
|
31
38
|
extensions: []
|
39
|
+
|
32
40
|
extra_rdoc_files: []
|
33
|
-
|
41
|
+
|
42
|
+
files:
|
34
43
|
- MIT-LICENSE
|
35
44
|
- bin/rubinjam
|
36
45
|
- lib/rubinjam.rb
|
37
46
|
- lib/rubinjam/version.rb
|
38
47
|
homepage: https://github.com/grosser/rubinjam
|
39
|
-
licenses:
|
48
|
+
licenses:
|
40
49
|
- MIT
|
41
|
-
metadata: {}
|
42
50
|
post_install_message:
|
43
51
|
rdoc_options: []
|
44
|
-
|
52
|
+
|
53
|
+
require_paths:
|
45
54
|
- lib
|
46
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
47
|
-
|
55
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
56
|
+
none: false
|
57
|
+
requirements:
|
48
58
|
- - ">="
|
49
|
-
- !ruby/object:Gem::Version
|
50
|
-
|
51
|
-
|
52
|
-
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
hash: 3
|
61
|
+
segments:
|
62
|
+
- 0
|
63
|
+
version: "0"
|
64
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
53
67
|
- - ">="
|
54
|
-
- !ruby/object:Gem::Version
|
55
|
-
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
hash: 3
|
70
|
+
segments:
|
71
|
+
- 0
|
72
|
+
version: "0"
|
56
73
|
requirements: []
|
74
|
+
|
57
75
|
rubyforge_project:
|
58
|
-
rubygems_version:
|
76
|
+
rubygems_version: 1.8.15
|
59
77
|
signing_key:
|
60
|
-
specification_version:
|
78
|
+
specification_version: 3
|
61
79
|
summary: Jam a gem into a universal binary that works with any ruby
|
62
80
|
test_files: []
|
81
|
+
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: 3ad8b2a441f97b43165b8de34a5d5f4f497d9252
|
4
|
-
data.tar.gz: ff1a5400580c19c7a302783fe2844ede15db39e9
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: eabcb9d642ad130f409c6518ded37d8ddd1a7e8794bc74f4351bbcc1f7fdefb4da6b68d4b627b3bdf405787619aa7c9912da809749233625e420b998ceb7811e
|
7
|
-
data.tar.gz: 1a1a9c87aecc77722ea5a2f3e12e1202462da8dac8e85d7eab9dcd6f9a4d69569b56bad82e31ca9ac9eb29e4bc61706e8285a46235411702e6662664119a6a3e
|