core_ex 0.5.6.2 → 0.6.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +7 -0
- data/NEWS +8 -0
- data/SPEC.gemspec +13 -0
- data/SPEC.yml +7 -5
- data/lib/core_ex.rb +51 -25
- data/lib/core_ex/enumerable.rb +1 -31
- data/lib/core_ex/module/mix_in_with_args.rb +4 -1
- data/lib/core_ex/pathname.rb +3 -3
- data/lib/core_ex/rakefile_base.rf +27 -37
- data/lib/core_ex/version_id.rb +1 -1
- data/lib/core_ex/yaml.rb +15 -7
- data/lib/path_list.rb +10 -5
- data/lib/temp_path.rb +35 -31
- data/test/sanity/single-requires.yml +1 -1
- metadata +50 -54
- data/lib/core_ex/lazy_loading.rb +0 -159
- data/test/lazy_loading/test_already_present_name_absolute.rb +0 -6
- data/test/lazy_loading/test_already_present_name_relative.rb +0 -11
- data/test/lazy_loading/test_inside_another_module.rb +0 -5
- data/test/lazy_loading/test_lazy_loading.rb +0 -179
data/ChangeLog
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
2006-03-25 Nicolas Despr�s <nicolas.despres@gmail.com>
|
2
|
+
|
3
|
+
Display clobber tasks with rake -T.
|
4
|
+
|
5
|
+
* lib/core_ex/rakefile_base.rf: Display the clobber tasks when
|
6
|
+
'rake -T' is invoked.
|
7
|
+
|
1
8
|
2006-02-23 Nicolas Despr�s <nicolas.despres@gmail.com>
|
2
9
|
|
3
10
|
Update the NEWS file.
|
data/NEWS
CHANGED
data/SPEC.gemspec
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = %q{core_ex}
|
3
|
+
s.version = "0.6.5.0"
|
4
|
+
s.date = %q{2007-01-14}
|
5
|
+
s.summary = %q{CoreEx is a proposal for a standard library extension.}
|
6
|
+
s.email = ["nicolas.despres@gmail.com", "ertai@feydakins.org"]
|
7
|
+
s.homepage = %q{http://api.feydakins.org/core_ex}
|
8
|
+
s.rubyforge_project = %q{core_ex}
|
9
|
+
s.description = %q{CoreEx is designed to provide a simple but quite useful extension of the standard library of Ruby. So some classes and modules like Pathname, Time, Enumerable, Exception, FileUtils, String, and YAML are extended. There is also some new features like attr_once, DTime, TempPath, Version, embedded_tests, filelist (almost from rake), a common Rakefile, and an extension of the require system.}
|
10
|
+
s.authors = ["Nicolas Despr\350s", "Nicolas Pouillard"]
|
11
|
+
s.files = ["lib/core_ex.rb", "lib/d_time.rb", "lib/dumpable_proc.rb", "lib/path_list.rb", "lib/temp_path.rb", "lib/version.rb", "lib/yaml_extension.rb", "lib/core_ex/embedded_tests.rb", "lib/core_ex/enumerable.rb", "lib/core_ex/exception.rb", "lib/core_ex/file_utils.rb", "lib/core_ex/numeric.rb", "lib/core_ex/pathname.rb", "lib/core_ex/proc.rb", "lib/core_ex/rakefile_base.rf", "lib/core_ex/require.rb", "lib/core_ex/string.rb", "lib/core_ex/time.rb", "lib/core_ex/try_dup.rb", "lib/core_ex/version_id.rb", "lib/core_ex/yaml.rb", "lib/core_ex/dependencies_ext/constant_load_path.rb", "lib/core_ex/module/attr_once.rb", "lib/core_ex/module/import.rb", "lib/core_ex/module/in_place.rb", "lib/core_ex/module/mix_in_with_args.rb", "lib/core_ex/object/instance_eval_with_args.rb", "lib/core_ex/object/singleton_class.rb", "lib/core_ex/object/the_first_time.rb", "lib/test/unit/u_i/yaml/test_runner.rb", "test/check-core_ex.yml", "test/check-pkg-core_ex.yml", "test/fixtures", "test/sanity", "test/sanity-suite.yml", "test/unit-suite.yml", "test/fixtures/lazy_loading", "test/fixtures/require", "test/fixtures/use-from-gems.rb", "test/fixtures/yaml_testrunner", "test/fixtures/lazy_loading/a_b", "test/fixtures/lazy_loading/double", "test/fixtures/lazy_loading/foo_bars", "test/fixtures/lazy_loading/foo_bars.rb", "test/fixtures/lazy_loading/a_b/a", "test/fixtures/lazy_loading/a_b/a.rb", "test/fixtures/lazy_loading/a_b/b", "test/fixtures/lazy_loading/a_b/b.rb", "test/fixtures/lazy_loading/a_b/a/c.rb", "test/fixtures/lazy_loading/a_b/b/c.rb", "test/fixtures/lazy_loading/double/a", "test/fixtures/lazy_loading/double/b", "test/fixtures/lazy_loading/double/a/bouhou.rb", "test/fixtures/lazy_loading/double/a/foo_bar.rb", "test/fixtures/lazy_loading/double/a/sub", "test/fixtures/lazy_loading/double/a/sub/a", "test/fixtures/lazy_loading/double/a/sub/a/suba.rb", "test/fixtures/lazy_loading/double/b/bouhou", "test/fixtures/lazy_loading/double/b/root", "test/fixtures/lazy_loading/double/b/root.rb", "test/fixtures/lazy_loading/double/b/root/sub", "test/fixtures/lazy_loading/double/b/root/sub.rb", "test/fixtures/lazy_loading/double/b/root/sub/b.rb", "test/fixtures/lazy_loading/foo_bars/foo_bar.rb", "test/fixtures/lazy_loading/foo_bars/mods", "test/fixtures/lazy_loading/foo_bars/mods.rb", "test/fixtures/lazy_loading/foo_bars/sub_foo_bar.rb", "test/fixtures/lazy_loading/foo_bars/titis", "test/fixtures/lazy_loading/foo_bars/totos.rb", "test/fixtures/lazy_loading/foo_bars/mods/mod.rb", "test/fixtures/lazy_loading/foo_bars/mods/sub_mod.rb", "test/fixtures/lazy_loading/foo_bars/mods/sub_sub_mod.rb", "test/fixtures/lazy_loading/foo_bars/titis/tutu.rb", "test/fixtures/require/test_require", "test/fixtures/require/test_require_rb.rb", "test/fixtures/require/test_require_so.so", "test/fixtures/yaml_testrunner/unit_test.rb", "test/sanity/multiple-requires.yml", "test/sanity/single-requires.yml", "AUTHORS", "ChangeLog", "NEWS", "Rakefile", "README", "SPEC.gemspec", "SPEC.yml"]
|
12
|
+
s.add_dependency(%q<activesupport>, ["~> 1.3.1"])
|
13
|
+
end
|
data/SPEC.yml
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
---
|
2
2
|
Author: The Uttk Team.
|
3
3
|
License: Ruby License
|
4
|
-
Revision: '$Id: /w/fey/ruby_ex/trunk/core_ex/SPEC.yml
|
4
|
+
Revision: '$Id: /w/fey/ruby_ex/trunk/core_ex/SPEC.yml 53909 2007-01-14T10:46:48.821577Z ertai $'
|
5
5
|
|
6
|
-
version: !feydakins.org,2006/version dev-ruby/core_ex-0.
|
6
|
+
version: !feydakins.org,2006/version dev-ruby/core_ex-0.6
|
7
|
+
|
8
|
+
# XXX check also lib/core_ex/version_id.rb
|
7
9
|
|
8
10
|
title: CoreEx -- A proposal for a standard library extension.
|
9
11
|
summary: CoreEx is a proposal for a standard library extension.
|
@@ -38,7 +40,7 @@ pkg_files: !filelist
|
|
38
40
|
|
39
41
|
dependencies:
|
40
42
|
activesupport:
|
41
|
-
gem: ~> 1.
|
42
|
-
tarball:
|
43
|
+
gem: ~> 1.3.1
|
44
|
+
tarball: http://rubyforge.rubyuser.de/activesupport/activesupport-1.3.1.tgz
|
43
45
|
|
44
|
-
uttk_version:
|
46
|
+
uttk_version: >= 0.3.6.1
|
data/lib/core_ex.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# Copyright:: Copyright (c) 2005 Nicolas Pouillard. All rights reserved.
|
2
2
|
# Author:: Nicolas Pouillard <ertai@lrde.epita.fr>.
|
3
3
|
# License:: Gnu General Public License.
|
4
|
-
# Revision:: $Id: /w/fey/ruby_ex/trunk/core_ex/lib/core_ex.rb
|
4
|
+
# Revision:: $Id: /w/fey/ruby_ex/trunk/core_ex/lib/core_ex.rb 53947 2007-01-14T12:29:57.727375Z ertai $
|
5
5
|
|
6
6
|
min_release = '1.8.4 (2005-12-24)'
|
7
7
|
ruby_release = "#{RUBY_VERSION} (#{RUBY_RELEASE_DATE})"
|
@@ -38,8 +38,13 @@ unless defined? CORE_EX_LOADED and CORE_EX_LOADED
|
|
38
38
|
$CORE_EX_VENDORS ||= []
|
39
39
|
$CORE_EX_VENDORS << CORE_EX_DIR.parent + 'vendor'
|
40
40
|
|
41
|
-
|
42
|
-
|
41
|
+
if ENV['CORE_EX_DEBUG']
|
42
|
+
def core_ex_debug &block
|
43
|
+
STDERR.puts block[].inspect
|
44
|
+
end
|
45
|
+
else
|
46
|
+
def core_ex_debug &block
|
47
|
+
end
|
43
48
|
end
|
44
49
|
|
45
50
|
def core_ex_vendor_require ( dir_name, sub_dir='lib' )
|
@@ -53,10 +58,12 @@ unless defined? CORE_EX_LOADED and CORE_EX_LOADED
|
|
53
58
|
end
|
54
59
|
core_ex_debug { [:vendor, dir_name, sub_dir] }
|
55
60
|
else
|
61
|
+
core_ex_debug { [:novendor, dir] }
|
56
62
|
raise LoadError, "no vendor dir #{dir}"
|
57
63
|
end
|
58
64
|
else
|
59
|
-
core_ex_debug { :novendor }
|
65
|
+
core_ex_debug { [:novendor, $CORE_EX_VENDORS] }
|
66
|
+
raise LoadError, "no valid vendor dir among #{$CORE_EX_VENDORS.inspect}"
|
60
67
|
end
|
61
68
|
end
|
62
69
|
|
@@ -65,34 +72,50 @@ unless defined? CORE_EX_LOADED and CORE_EX_LOADED
|
|
65
72
|
end
|
66
73
|
|
67
74
|
begin
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
75
|
+
unless ENV['NO_GEM']
|
76
|
+
require 'rubygems'
|
77
|
+
core_ex_debug { [:require, :rubygems] }
|
78
|
+
end
|
79
|
+
raise LoadError, 'RubyGems not loaded' unless defined? Gem
|
80
|
+
def core_ex_gem_require ( gem_name, gem_version=nil )
|
81
|
+
if gem_version
|
82
|
+
require_gem gem_name, gem_version
|
83
|
+
else
|
84
|
+
require_gem gem_name
|
85
|
+
end
|
72
86
|
core_ex_debug { [:require_gem, gem_name, gem_version] }
|
73
87
|
end
|
74
88
|
rescue LoadError => ex
|
89
|
+
core_ex_debug { [:nogem1, ex] }
|
75
90
|
def core_ex_gem_require ( *a, &b )
|
76
|
-
core_ex_debug { :
|
91
|
+
core_ex_debug { :nogem2 }
|
77
92
|
end
|
78
93
|
end
|
79
94
|
|
80
|
-
def core_ex_require
|
95
|
+
def core_ex_require name, opts=nil
|
96
|
+
core_ex_debug { [:core_ex_require, name, opts] }
|
97
|
+
opts ||= {}
|
81
98
|
begin
|
82
|
-
core_ex_vendor_require(dir_name,
|
99
|
+
core_ex_vendor_require(opts[:dir_name] || name,
|
100
|
+
opts[:sub_dir] || 'lib')
|
83
101
|
rescue LoadError => ex
|
84
102
|
begin
|
85
|
-
core_ex_gem_require(gem_name, gem_version)
|
103
|
+
core_ex_gem_require(opts[:gem_name] || name, opts[:gem_version])
|
86
104
|
rescue LoadError
|
87
105
|
end
|
88
106
|
end
|
89
|
-
require name
|
107
|
+
core_ex_debug { [:require, name] }
|
108
|
+
unless require name
|
109
|
+
core_ex_debug { [:require, name, :has_returned_false] }
|
110
|
+
end
|
90
111
|
end
|
91
112
|
|
92
113
|
verbose = $VERBOSE
|
93
114
|
$VERBOSE = false
|
94
115
|
|
95
|
-
core_ex_require 'active_support',
|
116
|
+
core_ex_require 'active_support',
|
117
|
+
:dir_name => 'activesupport',
|
118
|
+
:gem_name => 'activesupport'
|
96
119
|
|
97
120
|
$VERBOSE = verbose
|
98
121
|
|
@@ -170,16 +193,21 @@ unless defined? CORE_EX_LOADED and CORE_EX_LOADED
|
|
170
193
|
result.join '/'
|
171
194
|
# >>>
|
172
195
|
end
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
196
|
+
|
197
|
+
def camelize(lower_case_and_underscored_word, first_letter_in_uppercase = true)
|
198
|
+
if first_letter_in_uppercase
|
199
|
+
# <<<
|
200
|
+
result = lower_case_and_underscored_word.to_s.split '/'
|
201
|
+
result.map! do |word|
|
202
|
+
inflections.camelize_rules.each { |(rule, replacement)| break if word.gsub!(rule, replacement) }
|
203
|
+
word.gsub!(/(^|_)(.)/) { $2.upcase }
|
204
|
+
word
|
205
|
+
end
|
206
|
+
result.join '::'
|
207
|
+
# >>>
|
208
|
+
else
|
209
|
+
lower_case_and_underscored_word.first + camelize(lower_case_and_underscored_word)[1..-1]
|
180
210
|
end
|
181
|
-
result.join '::'
|
182
|
-
# >>>
|
183
211
|
end
|
184
212
|
end # module Inflector
|
185
213
|
end
|
@@ -261,8 +289,6 @@ if defined? EMBEDDED_TEST_MODE
|
|
261
289
|
embedded_test_mode EMBEDDED_TEST_MODE
|
262
290
|
end
|
263
291
|
|
264
|
-
require 'core_ex/lazy_loading'
|
265
|
-
|
266
292
|
class String
|
267
293
|
include CoreEx::String
|
268
294
|
end # class String
|
data/lib/core_ex/enumerable.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# Copyright:: Copyright (c) 2005 Nicolas Pouillard. All rights reserved.
|
2
2
|
# Author:: Nicolas Pouillard <ertai@lrde.epita.fr>.
|
3
3
|
# License:: Gnu General Public License.
|
4
|
-
# Revision:: $Id: /w/fey/ruby_ex/trunk/core_ex/lib/core_ex/enumerable.rb
|
4
|
+
# Revision:: $Id: /w/fey/ruby_ex/trunk/core_ex/lib/core_ex/enumerable.rb 24377 2006-07-09T16:38:32.920555Z ertai $
|
5
5
|
|
6
6
|
|
7
7
|
module CoreEx
|
@@ -65,22 +65,6 @@ module Enumerable
|
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
68
|
-
def group_by ( &block )
|
69
|
-
result = []
|
70
|
-
sorted = sort_by(&block)
|
71
|
-
current = nil
|
72
|
-
sorted.each do |x|
|
73
|
-
new_val = block[x]
|
74
|
-
if current != new_val
|
75
|
-
result << [x]
|
76
|
-
current = new_val
|
77
|
-
else
|
78
|
-
result.last << x
|
79
|
-
end
|
80
|
-
end
|
81
|
-
result
|
82
|
-
end
|
83
|
-
|
84
68
|
def group_sequences_by ( &block )
|
85
69
|
result = []
|
86
70
|
current = nil
|
@@ -221,20 +205,6 @@ test_section __FILE__ do
|
|
221
205
|
assert_equal(a.flatten.sum, y)
|
222
206
|
end
|
223
207
|
|
224
|
-
def test_group_by
|
225
|
-
foo31 = { :name => 'foo', :age => 31 }
|
226
|
-
foo2 = { :name => 'foo', :age => 2 }
|
227
|
-
bar2 = { :name => 'bar', :age => 2 }
|
228
|
-
bar4 = { :name => 'bar', :age => 4 }
|
229
|
-
bar6 = { :name => 'bar', :age => 6 }
|
230
|
-
baz7 = { :name => 'baz', :age => 7 }
|
231
|
-
list = [foo31, bar2, foo2, bar4, bar6, baz7]
|
232
|
-
groups = list.group_by { |x| x[:name] }
|
233
|
-
assert_equal [[bar4, bar2, bar6], [baz7], [foo2, foo31]], groups, 'name'
|
234
|
-
groups = list.group_by { |x| x[:age] }
|
235
|
-
assert_equal [[foo2, bar2], [bar4], [bar6], [baz7], [foo31]], groups, 'age'
|
236
|
-
end
|
237
|
-
|
238
208
|
def test_group_sequences_by
|
239
209
|
list = [1, 2, 3, 4, 5, 8, 9, 3, 4, 5, 2, 1, 3, 4, 5]
|
240
210
|
seqs = list.group_sequences_by { |x, y| y - x == 1 }
|
@@ -1,8 +1,9 @@
|
|
1
1
|
# Copyright:: Copyright (c) 2005 Nicolas Pouillard. All rights reserved.
|
2
2
|
# Author:: Nicolas Pouillard <ertai@lrde.epita.fr>.
|
3
3
|
# License:: Gnu General Public License.
|
4
|
-
# Revision:: $Id: /w/fey/ruby_ex/trunk/core_ex/lib/core_ex/module/mix_in_with_args.rb
|
4
|
+
# Revision:: $Id: /w/fey/ruby_ex/trunk/core_ex/lib/core_ex/module/mix_in_with_args.rb 53909 2007-01-14T10:46:48.821577Z ertai $
|
5
5
|
|
6
|
+
unless defined? CoreEx::Module::MixInWithArgs
|
6
7
|
|
7
8
|
class Module
|
8
9
|
|
@@ -265,3 +266,5 @@ module CoreEx
|
|
265
266
|
end # module Module
|
266
267
|
|
267
268
|
end # module CoreEx
|
269
|
+
|
270
|
+
end
|
data/lib/core_ex/pathname.rb
CHANGED
@@ -2,8 +2,8 @@
|
|
2
2
|
# Author: Nicolas Despres <polrop@lrde.epita.fr>.
|
3
3
|
# License: Gnu General Public License.
|
4
4
|
|
5
|
-
# $LastChangedBy:
|
6
|
-
# $Id: /w/fey/ruby_ex/trunk/core_ex/lib/core_ex/pathname.rb
|
5
|
+
# $LastChangedBy: ertai $
|
6
|
+
# $Id: /w/fey/ruby_ex/trunk/core_ex/lib/core_ex/pathname.rb 53903 2007-01-13T11:36:41.481975Z ertai $
|
7
7
|
|
8
8
|
|
9
9
|
|
@@ -144,7 +144,7 @@ module CoreEx
|
|
144
144
|
|
145
145
|
def load_path!
|
146
146
|
string = expand_path.cleanpath.to_s
|
147
|
-
raise "bad path name `#{
|
147
|
+
raise "bad path name `#{self}' need a directory" unless directory?
|
148
148
|
return false if $LOAD_PATH.include? string
|
149
149
|
$LOAD_PATH.unshift string
|
150
150
|
return true
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# Copyright:: Copyright (c) 2005 Nicolas Pouillard. All rights reserved.
|
2
2
|
# Author:: Nicolas Pouillard <ertai@lrde.epita.fr>.
|
3
3
|
# License:: Gnu General Public License.
|
4
|
-
# Revision:: $Id: /w/fey/ruby_ex/trunk/core_ex/lib/core_ex/rakefile_base.rf
|
4
|
+
# Revision:: $Id: /w/fey/ruby_ex/trunk/core_ex/lib/core_ex/rakefile_base.rf 53943 2007-01-14T11:44:13.489929Z ertai $
|
5
5
|
|
6
6
|
DEFAULT_RUBY_EX_VERSION = ENV['DEFAULT_RUBY_EX_VERSION'] || '~> 0.3'
|
7
7
|
DEFAULT_UTTK_VERSION = ENV['DEFAULT_UTTK_VERSION'] || '~> 0.3'
|
@@ -47,6 +47,7 @@ def clean_task ( arg, &block )
|
|
47
47
|
name, deps = arg, []
|
48
48
|
end
|
49
49
|
clobber_name = :"clobber_#{name}"
|
50
|
+
desc "Clobber files built by the #{name} rule"
|
50
51
|
task clobber_name => deps do
|
51
52
|
say "Clobber #{name}"
|
52
53
|
Rake::Task[name].instance_eval { @already_invoked = false }
|
@@ -80,17 +81,13 @@ end
|
|
80
81
|
|
81
82
|
|
82
83
|
task :ruby_ex => [ :spec ] do
|
83
|
-
|
84
|
-
|
85
|
-
Commands.import!
|
86
|
-
$runner = Commands::Runners::System.new
|
87
|
-
$runner.raise_on_failures
|
88
|
-
$runner.make_verbose
|
84
|
+
core_ex_require 'ruby_ex',
|
85
|
+
:gem_version => SPEC.ruby_ex_version || DEFAULT_RUBY_EX_VERSION
|
89
86
|
end
|
90
87
|
|
91
88
|
|
92
89
|
# desc 'Setup the uttk command'
|
93
|
-
task :uttk => [ :spec
|
90
|
+
task :uttk => [ :spec ] do
|
94
91
|
require_gem('uttk', SPEC.uttk_version || DEFAULT_UTTK_VERSION)
|
95
92
|
require 'uttk'
|
96
93
|
def uttk ( *a, &b )
|
@@ -238,7 +235,7 @@ file GEM_SPEC.to_s => [ :spec, :spec_pkg_files, :rdoc_spec ] do
|
|
238
235
|
end
|
239
236
|
|
240
237
|
if SPEC.has_rdoc
|
241
|
-
s.has_rdoc = true
|
238
|
+
s.has_rdoc = true
|
242
239
|
s.extra_rdoc_files = SPEC.rdoc.rdoc_files.map { |x| x.to_s }
|
243
240
|
s.rdoc_options = SPEC.rdoc.option_list.map { |x| x[/^'?(.*?)'?$/, 1] }
|
244
241
|
end
|
@@ -444,35 +441,30 @@ task :publish_package => [ :spec, :package ] do
|
|
444
441
|
# end
|
445
442
|
|
446
443
|
system "rubyforge login"
|
447
|
-
|
444
|
+
release = { :notes => release_notes, :changes => release_changes }
|
445
|
+
[:notes, :changes].each do |x|
|
446
|
+
loop do
|
447
|
+
loop do
|
448
|
+
say "No release #{x} (editing...)"
|
449
|
+
edit release[x]
|
450
|
+
break if release[x].exist?
|
451
|
+
end
|
452
|
+
say "Publish these release #{x}:"
|
453
|
+
say release[x].read
|
454
|
+
break if agree 'Agree? (y/n) ', true
|
455
|
+
end
|
456
|
+
end
|
457
|
+
files_to_release = ""
|
448
458
|
files.each do |path|
|
449
459
|
say "Releasing #{path.basename}..."
|
450
460
|
next unless agree 'Agree? (y/n)', true
|
451
|
-
|
452
|
-
cmd = "rubyforge add_release '#{group_id}' '#{package_name}' " +
|
453
|
-
"'#{release_name}' '#{path}' --release_notes '#{release_notes}' " +
|
454
|
-
"--release_changes '#{release_changes}' --preformatted"
|
455
|
-
unless release_id then
|
456
|
-
release = { :notes => release_notes, :changes => release_changes }
|
457
|
-
[:notes, :changes].each do |x|
|
458
|
-
loop do
|
459
|
-
loop do
|
460
|
-
say "No release #{x} (editing...)"
|
461
|
-
edit release[x]
|
462
|
-
break if release[x].exist?
|
463
|
-
end
|
464
|
-
say "Publish these release #{x}:"
|
465
|
-
say release[x].read
|
466
|
-
break if agree 'Agree? (y/n) ', true
|
467
|
-
end
|
468
|
-
end
|
469
|
-
release_id = `#{cmd} --show_release_id`[/release_id: (\d+)/, 1]
|
470
|
-
puts "release_id: #{release_id}"
|
471
|
-
else
|
472
|
-
system "#{cmd} --release_id '#{release_id}'"
|
473
|
-
end
|
474
|
-
|
461
|
+
files_to_release << " '#{path}'"
|
475
462
|
end
|
463
|
+
cmd = "rubyforge add_release '#{group_id}' '#{package_name}' " +
|
464
|
+
"'#{release_name}'#{files_to_release} --release_notes '#{release_notes}' " +
|
465
|
+
"--release_changes '#{release_changes}' --preformatted"
|
466
|
+
say cmd
|
467
|
+
system cmd
|
476
468
|
end
|
477
469
|
|
478
470
|
clean_task :publish_package do
|
@@ -514,9 +506,7 @@ task :vendor => [ :spec, :ruby_ex ] do
|
|
514
506
|
out = out.extract if out.extractable?
|
515
507
|
out.path.mv(dest)
|
516
508
|
if dev and vcs and (dest + 'SPEC.yml').exist?
|
517
|
-
|
518
|
-
cmd.dir = dest
|
519
|
-
data = cmd.run($runner)
|
509
|
+
sh "cd #{dest} && #$0 revendor_dev"
|
520
510
|
end
|
521
511
|
end
|
522
512
|
end
|
data/lib/core_ex/version_id.rb
CHANGED
data/lib/core_ex/yaml.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# Copyright:: Copyright (c) 2005 Nicolas Pouillard. All rights reserved.
|
2
2
|
# Author:: Nicolas Pouillard <ertai@lrde.epita.fr>.
|
3
3
|
# License:: Gnu General Public License.
|
4
|
-
# Revision:: $Id: /w/fey/ruby_ex/trunk/core_ex/lib/core_ex/yaml.rb
|
4
|
+
# Revision:: $Id: /w/fey/ruby_ex/trunk/core_ex/lib/core_ex/yaml.rb 24775 2006-07-27T07:47:33.576559Z ertai $
|
5
5
|
|
6
6
|
|
7
7
|
module CoreEx
|
@@ -16,16 +16,24 @@ module YAML
|
|
16
16
|
|
17
17
|
module_function
|
18
18
|
|
19
|
-
def load_from_io
|
20
|
-
buffer =
|
19
|
+
def load_from_io io, &block
|
20
|
+
buffer = []
|
21
21
|
io.each_line do |line|
|
22
|
-
if
|
23
|
-
|
24
|
-
|
22
|
+
if line == '...'
|
23
|
+
unless buffer.empty?
|
24
|
+
block[YAML.parse(buffer.join).symbol_safe_transform]
|
25
|
+
buffer = []
|
26
|
+
end
|
27
|
+
elsif not buffer.empty? and line =~ /^---/
|
28
|
+
block[YAML.parse(buffer.join).symbol_safe_transform]
|
29
|
+
buffer = [line]
|
25
30
|
else
|
26
|
-
buffer
|
31
|
+
buffer << line
|
27
32
|
end
|
28
33
|
end
|
34
|
+
if not buffer.empty?
|
35
|
+
block[YAML.parse(buffer.join).symbol_safe_transform]
|
36
|
+
end
|
29
37
|
end
|
30
38
|
|
31
39
|
def have_option? ( opts, opt_name )
|
data/lib/path_list.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# Copyright:: Copyright (c) 2005 Nicolas Pouillard. All rights reserved.
|
2
2
|
# Author:: Nicolas Pouillard <ertai@lrde.epita.fr>.
|
3
3
|
# License:: Gnu General Public License.
|
4
|
-
# Revision:: $Id: /w/fey/ruby_ex/trunk/core_ex/lib/path_list.rb
|
4
|
+
# Revision:: $Id: /w/fey/ruby_ex/trunk/core_ex/lib/path_list.rb 53903 2007-01-13T11:36:41.481975Z ertai $
|
5
5
|
#--
|
6
6
|
# Copyright (c) 2003, 2004 Jim Weirich
|
7
7
|
#
|
@@ -368,10 +368,15 @@ class PathList
|
|
368
368
|
end
|
369
369
|
|
370
370
|
class PathAndMatchData < Pathname
|
371
|
-
|
372
|
-
def
|
373
|
-
|
374
|
-
|
371
|
+
attr_accessor :match
|
372
|
+
def self.new path, match=nil
|
373
|
+
if match.nil?
|
374
|
+
Pathname.new path
|
375
|
+
else
|
376
|
+
o = super(path)
|
377
|
+
o.match = match
|
378
|
+
o
|
379
|
+
end
|
375
380
|
end
|
376
381
|
end
|
377
382
|
|
data/lib/temp_path.rb
CHANGED
@@ -2,14 +2,15 @@
|
|
2
2
|
# Author: Nicolas Pouillard <ertai@lrde.epita.fr>.
|
3
3
|
# License: Gnu General Public License.
|
4
4
|
|
5
|
-
# $LastChangedBy:
|
6
|
-
# $Id: /w/fey/ruby_ex/trunk/core_ex/lib/temp_path.rb
|
5
|
+
# $LastChangedBy: pouillar $
|
6
|
+
# $Id: /w/fey/ruby_ex/trunk/core_ex/lib/temp_path.rb 24748 2006-07-19T16:13:06.016011Z pouillar $
|
7
7
|
|
8
8
|
require 'tempfile'
|
9
9
|
require 'tmpdir'
|
10
10
|
require 'thread'
|
11
11
|
|
12
|
-
|
12
|
+
module TempPath
|
13
|
+
module_function
|
13
14
|
|
14
15
|
@@initialized = false
|
15
16
|
@@mutex = Mutex.new
|
@@ -50,27 +51,26 @@ class TempPath < Pathname
|
|
50
51
|
# which follow this format:
|
51
52
|
# => 'base.pid.uniq.ext
|
52
53
|
#
|
53
|
-
def
|
54
|
+
def new base=nil, ext='', &block
|
55
|
+
tmp = nil
|
54
56
|
if base and base.to_s =~ /\//
|
55
57
|
raise ArgumentError, "bad basename, you give me a pathname #{base}"
|
56
58
|
end
|
57
|
-
|
59
|
+
init
|
58
60
|
base ||= @@progname
|
59
61
|
ext = ".#{ext}" unless ext.empty? or ext[0] == ?.
|
60
62
|
res = nil
|
61
63
|
@@mutex.synchronize do
|
62
|
-
|
64
|
+
tmp = Pathname.new ''
|
65
|
+
id_tmp = tmp.object_id
|
63
66
|
while (res = @@tmpdir + "#{base}.#{id_tmp}#{ext}").exist? \
|
64
67
|
and not @@tmps.include? res
|
65
68
|
id_tmp += 1
|
66
69
|
end
|
67
|
-
|
70
|
+
tmp.instance_eval { @path = res.instance_eval { @path } }
|
71
|
+
tmp.extend TempPathname
|
68
72
|
@@tmps << self
|
69
73
|
end
|
70
|
-
end
|
71
|
-
|
72
|
-
def self.new ( *a, &block )
|
73
|
-
tmp = super(*a)
|
74
74
|
return tmp unless block_given?
|
75
75
|
begin
|
76
76
|
return block[tmp.dup]
|
@@ -79,25 +79,6 @@ class TempPath < Pathname
|
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
82
|
-
# This method remove your temporary pathname.
|
83
|
-
# You do not need to call this method if you provide
|
84
|
-
# a block when you create a tempfile.
|
85
|
-
def clean
|
86
|
-
if exist?
|
87
|
-
if directory?
|
88
|
-
rmtree
|
89
|
-
else
|
90
|
-
unlink
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
def temp?
|
96
|
-
true
|
97
|
-
end
|
98
|
-
|
99
|
-
class << self
|
100
|
-
|
101
82
|
def init ( tmp_base_dir=nil ) #:nodoc:
|
102
83
|
return if @@initialized
|
103
84
|
@@mutex.synchronize do
|
@@ -153,9 +134,28 @@ class TempPath < Pathname
|
|
153
134
|
@@tmpdir
|
154
135
|
end
|
155
136
|
|
137
|
+
end # module TempPath
|
138
|
+
|
139
|
+
module TempPathname
|
140
|
+
|
141
|
+
# This method remove your temporary pathname.
|
142
|
+
# You do not need to call this method if you provide
|
143
|
+
# a block when you create a tempfile.
|
144
|
+
def clean
|
145
|
+
if exist?
|
146
|
+
if directory?
|
147
|
+
rmtree
|
148
|
+
else
|
149
|
+
unlink
|
150
|
+
end
|
151
|
+
end
|
156
152
|
end
|
157
153
|
|
158
|
-
|
154
|
+
def temp?
|
155
|
+
true
|
156
|
+
end
|
157
|
+
|
158
|
+
end # class TempPathname
|
159
159
|
|
160
160
|
|
161
161
|
class Pathname
|
@@ -199,6 +199,10 @@ test_section __FILE__ do
|
|
199
199
|
end
|
200
200
|
end
|
201
201
|
|
202
|
+
def test_different
|
203
|
+
assert_not_equal TempPath.new, TempPath.new
|
204
|
+
end
|
205
|
+
|
202
206
|
def test_temp?
|
203
207
|
assert(@foo.temp?, 'not tmp.temp?')
|
204
208
|
assert_nothing_raised do
|
metadata
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.
|
2
|
+
rubygems_version: 0.9.0
|
3
3
|
specification_version: 1
|
4
4
|
name: core_ex
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.5.
|
7
|
-
date:
|
6
|
+
version: 0.6.5.0
|
7
|
+
date: 2007-01-14 00:00:00 +01:00
|
8
8
|
summary: CoreEx is a proposal for a standard library extension.
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -27,101 +27,97 @@ required_ruby_version: !ruby/object:Gem::Version::Requirement
|
|
27
27
|
platform: ruby
|
28
28
|
signing_key:
|
29
29
|
cert_chain:
|
30
|
+
post_install_message:
|
30
31
|
authors:
|
31
32
|
- "Nicolas Despr\xE8s"
|
32
33
|
- Nicolas Pouillard
|
33
34
|
files:
|
35
|
+
- lib/core_ex.rb
|
34
36
|
- lib/d_time.rb
|
35
37
|
- lib/dumpable_proc.rb
|
36
38
|
- lib/path_list.rb
|
37
|
-
- lib/yaml_extension.rb
|
38
|
-
- lib/core_ex.rb
|
39
39
|
- lib/temp_path.rb
|
40
40
|
- lib/version.rb
|
41
|
-
- lib/
|
42
|
-
- lib/core_ex/lazy_loading.rb
|
43
|
-
- lib/core_ex/numeric.rb
|
44
|
-
- lib/core_ex/yaml.rb
|
45
|
-
- lib/core_ex/try_dup.rb
|
46
|
-
- lib/core_ex/string.rb
|
47
|
-
- lib/core_ex/file_utils.rb
|
48
|
-
- lib/core_ex/time.rb
|
49
|
-
- lib/core_ex/rakefile_base.rf
|
41
|
+
- lib/yaml_extension.rb
|
50
42
|
- lib/core_ex/embedded_tests.rb
|
51
|
-
- lib/core_ex/version_id.rb
|
52
|
-
- lib/core_ex/require.rb
|
53
|
-
- lib/core_ex/exception.rb
|
54
43
|
- lib/core_ex/enumerable.rb
|
44
|
+
- lib/core_ex/exception.rb
|
45
|
+
- lib/core_ex/file_utils.rb
|
46
|
+
- lib/core_ex/numeric.rb
|
55
47
|
- lib/core_ex/pathname.rb
|
56
48
|
- lib/core_ex/proc.rb
|
49
|
+
- lib/core_ex/rakefile_base.rf
|
50
|
+
- lib/core_ex/require.rb
|
51
|
+
- lib/core_ex/string.rb
|
52
|
+
- lib/core_ex/time.rb
|
53
|
+
- lib/core_ex/try_dup.rb
|
54
|
+
- lib/core_ex/version_id.rb
|
55
|
+
- lib/core_ex/yaml.rb
|
56
|
+
- lib/core_ex/dependencies_ext/constant_load_path.rb
|
57
57
|
- lib/core_ex/module/attr_once.rb
|
58
|
-
- lib/core_ex/module/in_place.rb
|
59
58
|
- lib/core_ex/module/import.rb
|
59
|
+
- lib/core_ex/module/in_place.rb
|
60
60
|
- lib/core_ex/module/mix_in_with_args.rb
|
61
|
-
- lib/core_ex/object/the_first_time.rb
|
62
61
|
- lib/core_ex/object/instance_eval_with_args.rb
|
63
62
|
- lib/core_ex/object/singleton_class.rb
|
64
|
-
- lib/core_ex/
|
65
|
-
- test/unit
|
66
|
-
- test/
|
67
|
-
- test/fixtures
|
63
|
+
- lib/core_ex/object/the_first_time.rb
|
64
|
+
- lib/test/unit/u_i/yaml/test_runner.rb
|
65
|
+
- test/check-core_ex.yml
|
68
66
|
- test/check-pkg-core_ex.yml
|
67
|
+
- test/fixtures
|
69
68
|
- test/sanity
|
70
69
|
- test/sanity-suite.yml
|
71
|
-
- test/
|
72
|
-
- test/lazy_loading/test_inside_another_module.rb
|
73
|
-
- test/lazy_loading/test_lazy_loading.rb
|
74
|
-
- test/lazy_loading/test_already_present_name_relative.rb
|
75
|
-
- test/lazy_loading/test_already_present_name_absolute.rb
|
76
|
-
- test/fixtures/require
|
77
|
-
- test/fixtures/yaml_testrunner
|
70
|
+
- test/unit-suite.yml
|
78
71
|
- test/fixtures/lazy_loading
|
72
|
+
- test/fixtures/require
|
79
73
|
- test/fixtures/use-from-gems.rb
|
80
|
-
- test/fixtures/
|
81
|
-
- test/fixtures/require/test_require_rb.rb
|
82
|
-
- test/fixtures/require/test_require_so.so
|
83
|
-
- test/fixtures/yaml_testrunner/unit_test.rb
|
74
|
+
- test/fixtures/yaml_testrunner
|
84
75
|
- test/fixtures/lazy_loading/a_b
|
85
|
-
- test/fixtures/lazy_loading/foo_bars.rb
|
86
|
-
- test/fixtures/lazy_loading/foo_bars
|
87
76
|
- test/fixtures/lazy_loading/double
|
77
|
+
- test/fixtures/lazy_loading/foo_bars
|
78
|
+
- test/fixtures/lazy_loading/foo_bars.rb
|
88
79
|
- test/fixtures/lazy_loading/a_b/a
|
89
|
-
- test/fixtures/lazy_loading/a_b/b
|
90
80
|
- test/fixtures/lazy_loading/a_b/a.rb
|
81
|
+
- test/fixtures/lazy_loading/a_b/b
|
91
82
|
- test/fixtures/lazy_loading/a_b/b.rb
|
92
83
|
- test/fixtures/lazy_loading/a_b/a/c.rb
|
93
84
|
- test/fixtures/lazy_loading/a_b/b/c.rb
|
94
|
-
- test/fixtures/lazy_loading/foo_bars/mods
|
95
|
-
- test/fixtures/lazy_loading/foo_bars/sub_foo_bar.rb
|
96
|
-
- test/fixtures/lazy_loading/foo_bars/titis
|
97
|
-
- test/fixtures/lazy_loading/foo_bars/mods.rb
|
98
|
-
- test/fixtures/lazy_loading/foo_bars/foo_bar.rb
|
99
|
-
- test/fixtures/lazy_loading/foo_bars/totos.rb
|
100
|
-
- test/fixtures/lazy_loading/foo_bars/mods/sub_sub_mod.rb
|
101
|
-
- test/fixtures/lazy_loading/foo_bars/mods/mod.rb
|
102
|
-
- test/fixtures/lazy_loading/foo_bars/mods/sub_mod.rb
|
103
|
-
- test/fixtures/lazy_loading/foo_bars/titis/tutu.rb
|
104
85
|
- test/fixtures/lazy_loading/double/a
|
105
86
|
- test/fixtures/lazy_loading/double/b
|
106
|
-
- test/fixtures/lazy_loading/double/a/sub
|
107
|
-
- test/fixtures/lazy_loading/double/a/foo_bar.rb
|
108
87
|
- test/fixtures/lazy_loading/double/a/bouhou.rb
|
88
|
+
- test/fixtures/lazy_loading/double/a/foo_bar.rb
|
89
|
+
- test/fixtures/lazy_loading/double/a/sub
|
109
90
|
- test/fixtures/lazy_loading/double/a/sub/a
|
110
91
|
- test/fixtures/lazy_loading/double/a/sub/a/suba.rb
|
92
|
+
- test/fixtures/lazy_loading/double/b/bouhou
|
111
93
|
- test/fixtures/lazy_loading/double/b/root
|
112
94
|
- test/fixtures/lazy_loading/double/b/root.rb
|
113
|
-
- test/fixtures/lazy_loading/double/b/bouhou
|
114
95
|
- test/fixtures/lazy_loading/double/b/root/sub
|
115
96
|
- test/fixtures/lazy_loading/double/b/root/sub.rb
|
116
97
|
- test/fixtures/lazy_loading/double/b/root/sub/b.rb
|
117
|
-
- test/
|
98
|
+
- test/fixtures/lazy_loading/foo_bars/foo_bar.rb
|
99
|
+
- test/fixtures/lazy_loading/foo_bars/mods
|
100
|
+
- test/fixtures/lazy_loading/foo_bars/mods.rb
|
101
|
+
- test/fixtures/lazy_loading/foo_bars/sub_foo_bar.rb
|
102
|
+
- test/fixtures/lazy_loading/foo_bars/titis
|
103
|
+
- test/fixtures/lazy_loading/foo_bars/totos.rb
|
104
|
+
- test/fixtures/lazy_loading/foo_bars/mods/mod.rb
|
105
|
+
- test/fixtures/lazy_loading/foo_bars/mods/sub_mod.rb
|
106
|
+
- test/fixtures/lazy_loading/foo_bars/mods/sub_sub_mod.rb
|
107
|
+
- test/fixtures/lazy_loading/foo_bars/titis/tutu.rb
|
108
|
+
- test/fixtures/require/test_require
|
109
|
+
- test/fixtures/require/test_require_rb.rb
|
110
|
+
- test/fixtures/require/test_require_so.so
|
111
|
+
- test/fixtures/yaml_testrunner/unit_test.rb
|
118
112
|
- test/sanity/multiple-requires.yml
|
113
|
+
- test/sanity/single-requires.yml
|
114
|
+
- AUTHORS
|
115
|
+
- ChangeLog
|
119
116
|
- NEWS
|
120
117
|
- Rakefile
|
121
118
|
- README
|
122
|
-
-
|
119
|
+
- SPEC.gemspec
|
123
120
|
- SPEC.yml
|
124
|
-
- ChangeLog
|
125
121
|
test_files: []
|
126
122
|
|
127
123
|
rdoc_options: []
|
@@ -142,5 +138,5 @@ dependencies:
|
|
142
138
|
requirements:
|
143
139
|
- - ~>
|
144
140
|
- !ruby/object:Gem::Version
|
145
|
-
version: 1.
|
141
|
+
version: 1.3.1
|
146
142
|
version:
|
data/lib/core_ex/lazy_loading.rb
DELETED
@@ -1,159 +0,0 @@
|
|
1
|
-
# Copyright:: Copyright (c) 2005 Nicolas Pouillard. All rights reserved.
|
2
|
-
# Author:: Nicolas Pouillard <ertai@lrde.epita.fr>.
|
3
|
-
# License:: Gnu General Public License.
|
4
|
-
# Revision:: $Id: /w/fey/ruby_ex/trunk/core_ex/lib/core_ex/lazy_loading.rb 21865 2006-02-18T17:13:28.680350Z pouillar $
|
5
|
-
|
6
|
-
# This file is hand protected against double inclusion for stranges reasons
|
7
|
-
unless defined? LazyLoading
|
8
|
-
|
9
|
-
require 'active_support/binding_of_caller'
|
10
|
-
|
11
|
-
|
12
|
-
module LazyLoading
|
13
|
-
|
14
|
-
mattr_accessor :logger
|
15
|
-
self.logger = Logger.new(STDERR)
|
16
|
-
|
17
|
-
class LazyLoader
|
18
|
-
|
19
|
-
mattr_accessor :logger
|
20
|
-
self.logger = LazyLoading.logger
|
21
|
-
|
22
|
-
def initialize ( aModule, aConst, theNesting )
|
23
|
-
@const = aConst
|
24
|
-
@roots = theNesting
|
25
|
-
@module = aModule
|
26
|
-
|
27
|
-
# self is not necessary in the nesting:
|
28
|
-
# class B
|
29
|
-
# end
|
30
|
-
#
|
31
|
-
# class A
|
32
|
-
# p B::C # here the nesting is [A] and self is B
|
33
|
-
# end
|
34
|
-
@roots.delete aModule
|
35
|
-
@roots.unshift aModule
|
36
|
-
|
37
|
-
# The Object root is here to deal with top level objects:
|
38
|
-
# class B
|
39
|
-
# end
|
40
|
-
#
|
41
|
-
# class A
|
42
|
-
# p B
|
43
|
-
# end
|
44
|
-
@roots << Object unless @roots.include? Object
|
45
|
-
|
46
|
-
@selection = []
|
47
|
-
end
|
48
|
-
|
49
|
-
attr_reader :const, :roots, :root, :selection, :basename
|
50
|
-
|
51
|
-
# For each `roots' module load all files that match.
|
52
|
-
def load
|
53
|
-
roots.each do |@root|
|
54
|
-
setup_basename!
|
55
|
-
select!
|
56
|
-
unless selection.empty?
|
57
|
-
import_the_selection!
|
58
|
-
if root.const_defined? const
|
59
|
-
logger.debug { "LazyLoader#load: Ok `#{const}' defined" }
|
60
|
-
succeeded!
|
61
|
-
return result
|
62
|
-
end
|
63
|
-
logger.debug { "LazyLoader#load: Even after loading #{selection.inspect}, #{const} is not available (root: #{root})" }
|
64
|
-
end
|
65
|
-
end
|
66
|
-
roots.each do |@root|
|
67
|
-
setup_basename!
|
68
|
-
make_a_new_module_if_the_directory_exist!
|
69
|
-
return result if succeeded?
|
70
|
-
end
|
71
|
-
return result
|
72
|
-
end
|
73
|
-
|
74
|
-
def setup_basename!
|
75
|
-
prefix = (root == Object)? '' : "#{root}::"
|
76
|
-
@basename = "#{prefix}#{const}".underscore
|
77
|
-
end
|
78
|
-
|
79
|
-
def select!
|
80
|
-
each_load_path do |dir|
|
81
|
-
%w[ rb rf so ].each do |ext|
|
82
|
-
path = Pathname.new(dir) + "#{basename}.#{ext}"
|
83
|
-
selection << basename if path.exist? and not selection.include? basename
|
84
|
-
end
|
85
|
-
end
|
86
|
-
logger.debug { "LazyLoader#select!(basename: #{basename}): #{selection.inspect}" }
|
87
|
-
end
|
88
|
-
|
89
|
-
def make_a_new_module_if_the_directory_exist!
|
90
|
-
each_load_path do |dir|
|
91
|
-
path = Pathname.new(dir) + basename
|
92
|
-
if path.directory?
|
93
|
-
mod = "#{root.name}::#{const}".sub(/^:*/, '::')
|
94
|
-
logger.debug do
|
95
|
-
"LazyLoader#make_a_new_module_if_the_directory_exist!: " +
|
96
|
-
"Build #{mod}"
|
97
|
-
end
|
98
|
-
eval "module #{mod} end"
|
99
|
-
succeeded!
|
100
|
-
end
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
def import_the_selection!
|
105
|
-
selection.each { |path| require_dependency path }
|
106
|
-
end
|
107
|
-
|
108
|
-
def succeeded!
|
109
|
-
@result = root.const_get const
|
110
|
-
end
|
111
|
-
|
112
|
-
def succeeded?
|
113
|
-
defined? @result
|
114
|
-
end
|
115
|
-
|
116
|
-
def result
|
117
|
-
if succeeded?
|
118
|
-
return @result
|
119
|
-
else
|
120
|
-
return @module.original_core_ex_const_missing(const)
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
def each_load_path ( &block )
|
125
|
-
$LOAD_PATH.each(&block)
|
126
|
-
end
|
127
|
-
|
128
|
-
end # class LazyLoader
|
129
|
-
|
130
|
-
class << self
|
131
|
-
def load ( aModule, aConst, theNesting )
|
132
|
-
logger.info { "LazyLoading::load(module: #{aModule}, const: #{aConst}, nesting: #{theNesting.inspect})" }
|
133
|
-
LazyLoader.new(aModule, aConst, theNesting).load
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
end # module LazyLoading
|
138
|
-
|
139
|
-
LazyLoading.logger.level = Logger::WARN
|
140
|
-
|
141
|
-
class Module
|
142
|
-
def name
|
143
|
-
the_standard_name.sub(/^Controllers::/, '')
|
144
|
-
end
|
145
|
-
alias_method :core_ex_const_missing, :const_missing
|
146
|
-
def const_missing ( aConst )
|
147
|
-
Binding.of_caller do |binding|
|
148
|
-
nesting = eval "::Module.nesting", binding
|
149
|
-
return LazyLoading.load(self, aConst, nesting)
|
150
|
-
end
|
151
|
-
# Nothing here, not reached !!!
|
152
|
-
end
|
153
|
-
end
|
154
|
-
|
155
|
-
test_section __FILE__ do
|
156
|
-
load CoreEx.test_dir/'lazy_loading'/'test_lazy_loading.rb'
|
157
|
-
end
|
158
|
-
|
159
|
-
end
|
@@ -1,179 +0,0 @@
|
|
1
|
-
# Copyright:: Copyright (c) 2005 Nicolas Pouillard. All rights reserved.
|
2
|
-
# Author:: Nicolas Pouillard <ertai@lrde.epita.fr>.
|
3
|
-
# License:: Gnu General Public License.
|
4
|
-
# Revision:: $Id: /w/fey/ruby_ex/trunk/core_ex/test/lazy_loading/test_lazy_loading.rb 21865 2006-02-18T17:13:28.680350Z pouillar $
|
5
|
-
|
6
|
-
require 'core_ex/lazy_loading'
|
7
|
-
require 'test/unit'
|
8
|
-
|
9
|
-
module LazyLoading
|
10
|
-
|
11
|
-
class TestLazyLoading < ::Test::Unit::TestCase
|
12
|
-
|
13
|
-
@@dir = __FILE__.to_path.dirname
|
14
|
-
lazy_loading_dir = @@dir.parent/'fixtures'/'lazy_loading'
|
15
|
-
double_dir = lazy_loading_dir/'double'
|
16
|
-
|
17
|
-
@@fixtures =
|
18
|
-
{
|
19
|
-
:foo_bars => lazy_loading_dir,
|
20
|
-
:double => double_dir,
|
21
|
-
:double_a => double_dir/'a',
|
22
|
-
:double_b => double_dir/'b',
|
23
|
-
:a_b => lazy_loading_dir/'a_b',
|
24
|
-
}
|
25
|
-
|
26
|
-
def teardown
|
27
|
-
@@fixtures.each_value { |v| $LOAD_PATH.delete(v.to_s) }
|
28
|
-
$".delete_if { |x| x.to_s =~ /\b(sub|root|foo_bars|a_b)\// }
|
29
|
-
Dependencies.loaded.delete_if { |x| x.to_s =~ /\b(sub|root|foo_bars|a_b)\// }
|
30
|
-
%w[ FooBars FooBar Root Sub A B ].each do |aConst|
|
31
|
-
suppress(NameError) { Object.send(:remove_const, aConst) }
|
32
|
-
end
|
33
|
-
TestLazyLoading.send(:remove_const, :FooBar) if defined? TestLazyLoading::FooBar
|
34
|
-
end
|
35
|
-
|
36
|
-
def self.test ( name, *fixtures, &block )
|
37
|
-
define_method("test_#{name}") do
|
38
|
-
fixtures.each { |fixture| @@fixtures[fixture].load_path! }
|
39
|
-
file = @@dir/"test_#{name}.rb"
|
40
|
-
load file.to_s if file.exist?
|
41
|
-
instance_eval(&block)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
test :inside_another_module, :foo_bars do
|
46
|
-
assert(defined? ::FooBars::Youhou)
|
47
|
-
assert_equal('FooBars::SubFooBar', FooBars::Youhou::X.name)
|
48
|
-
end
|
49
|
-
|
50
|
-
test :foo_bars__mods, :foo_bars do
|
51
|
-
assert_equal('FooBars::Mods', FooBars::Mods.name)
|
52
|
-
end
|
53
|
-
|
54
|
-
test :foo_bars__mods__sub_mod, :foo_bars do
|
55
|
-
assert_equal('FooBars::Mods::SubMod', FooBars::Mods::SubMod.name)
|
56
|
-
end
|
57
|
-
|
58
|
-
test :foo_bars__mods__mod_AND_foo_bars__mods, :foo_bars do
|
59
|
-
assert_equal('FooBars::Mods::Mod', FooBars::Mods::Mod.name)
|
60
|
-
assert_equal('FooBars::Mods', FooBars::Mods.name)
|
61
|
-
end
|
62
|
-
|
63
|
-
test :already_present_name_absolute, :foo_bars do
|
64
|
-
assert(defined? ::FooBar)
|
65
|
-
assert(defined? ::FooBars::Boo)
|
66
|
-
assert_equal('FooBars::FooBar', FooBars::Boo.superclass.name)
|
67
|
-
end
|
68
|
-
|
69
|
-
test :inside_another_module2, :foo_bars do
|
70
|
-
x =
|
71
|
-
module ::FooBars
|
72
|
-
module ::Youhou
|
73
|
-
SubFooBar
|
74
|
-
end
|
75
|
-
end
|
76
|
-
assert_equal('FooBars::SubFooBar', x.name)
|
77
|
-
end
|
78
|
-
|
79
|
-
test :already_present_name_absolute2, :foo_bars do
|
80
|
-
class ::FooBar
|
81
|
-
end
|
82
|
-
class FooBar
|
83
|
-
end
|
84
|
-
module ::FooBars
|
85
|
-
class Boo < ::FooBars::FooBar
|
86
|
-
end
|
87
|
-
end
|
88
|
-
assert_equal('FooBars::FooBar', FooBars::Boo.superclass.name)
|
89
|
-
end
|
90
|
-
|
91
|
-
test :already_present_name_relative_with_self2, :foo_bars do
|
92
|
-
class ::A
|
93
|
-
end
|
94
|
-
class ::FooBar
|
95
|
-
end
|
96
|
-
module ::FooBars
|
97
|
-
class B < A
|
98
|
-
end
|
99
|
-
class Boo < self::FooBar
|
100
|
-
end
|
101
|
-
end
|
102
|
-
assert_equal('A', FooBars::B.superclass.name)
|
103
|
-
assert_equal('FooBars::FooBar', FooBars::Boo.superclass.name)
|
104
|
-
end
|
105
|
-
|
106
|
-
test :complex_nestings, :foo_bars do
|
107
|
-
module ::FooBars
|
108
|
-
class ::B
|
109
|
-
class C < FooBar
|
110
|
-
end
|
111
|
-
end
|
112
|
-
end
|
113
|
-
assert_equal('FooBars::FooBar', ::B::C.superclass.name)
|
114
|
-
assert_equal('B::C', ::B::C.name)
|
115
|
-
end
|
116
|
-
|
117
|
-
test :foo_bars__totos__tata, :foo_bars do
|
118
|
-
assert_equal('FooBars::Totos::Tata', FooBars::Totos::Tata.name)
|
119
|
-
end
|
120
|
-
|
121
|
-
test :foo_bars__titis__tutu, :foo_bars do
|
122
|
-
assert_equal('FooBars::Titis::Tutu', FooBars::Titis::Tutu.name)
|
123
|
-
end
|
124
|
-
|
125
|
-
test :double_a_sub_a_suba, :double_a do
|
126
|
-
assert_equal('Sub::A::Suba', Sub::A::Suba.name)
|
127
|
-
end
|
128
|
-
|
129
|
-
test :double_b_root_sub_b, :double_b do
|
130
|
-
assert_equal('Root::Sub::B', Root::Sub::B.name)
|
131
|
-
end
|
132
|
-
|
133
|
-
test :double_ab_root_sub_b, :double_a, :double_b do
|
134
|
-
assert_equal('Root::Sub::B', Root::Sub::B.name)
|
135
|
-
assert_equal('Sub::A::Suba', Sub::A::Suba.name)
|
136
|
-
end
|
137
|
-
|
138
|
-
test :double_ab_sub_a_suba, :double_b, :double_a do
|
139
|
-
assert_equal('Sub::A::Suba', Sub::A::Suba.name)
|
140
|
-
assert_equal('Root::Sub::B', Root::Sub::B.name)
|
141
|
-
end
|
142
|
-
|
143
|
-
test :foo_bar_in_double_a, :double_a, :foo_bars do
|
144
|
-
assert_equal('FooBars::FooBar', FooBars::FooBar.name)
|
145
|
-
assert_equal('FooBar in double/a', FooBar.name)
|
146
|
-
end
|
147
|
-
|
148
|
-
test :bouhou_in_double_ab, :double, :double_a do
|
149
|
-
class ::B
|
150
|
-
A = Bouhou
|
151
|
-
end
|
152
|
-
assert_equal('Bouhou', ::B::A.name)
|
153
|
-
end
|
154
|
-
|
155
|
-
test :vicious_nestings, :a_b do
|
156
|
-
class ::A
|
157
|
-
X = B::C
|
158
|
-
end # class ::A
|
159
|
-
assert_equal('B::C', ::A::X.name)
|
160
|
-
end
|
161
|
-
|
162
|
-
##### XFAILS #####
|
163
|
-
test :already_present_name_relative, :foo_bars do
|
164
|
-
assert(defined? ::FooBar)
|
165
|
-
assert(defined? ::FooBars::Boo)
|
166
|
-
assert(defined? ::A)
|
167
|
-
assert(defined? ::FooBars::B)
|
168
|
-
assert_equal('A', FooBars::B.superclass.name)
|
169
|
-
|
170
|
-
# It should be this: assert_equal('FooBars::FooBar', FooBars::Boo.superclass.name).
|
171
|
-
# But since ::FooBar already exist the const_missing callback is not triggered.
|
172
|
-
# So its the limitation of this LazyLoading feature.
|
173
|
-
assert_equal('FooBar', FooBars::Boo.superclass.name)
|
174
|
-
end
|
175
|
-
|
176
|
-
end # class TestLazyLoading
|
177
|
-
|
178
|
-
end # module LazyLoading
|
179
|
-
|