core_ex 0.4.0 → 0.5.1.1

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.
Files changed (68) hide show
  1. data/ChangeLog +251 -0
  2. data/NEWS +29 -0
  3. data/README +1 -1
  4. data/SPEC.yml +10 -10
  5. data/lib/core_ex/dependencies_ext/constant_load_path.rb +1 -1
  6. data/lib/core_ex/embedded_tests.rb +1 -1
  7. data/lib/core_ex/enumerable.rb +87 -5
  8. data/lib/core_ex/exception.rb +1 -1
  9. data/lib/core_ex/file_utils.rb +1 -1
  10. data/lib/core_ex/lazy_loading.rb +159 -0
  11. data/lib/core_ex/module/attr_once.rb +1 -1
  12. data/lib/core_ex/module/import.rb +4 -6
  13. data/lib/core_ex/module/in_place.rb +1 -1
  14. data/lib/core_ex/module/mix_in_with_args.rb +1 -1
  15. data/lib/core_ex/numeric.rb +46 -0
  16. data/lib/core_ex/object/instance_eval_with_args.rb +1 -1
  17. data/lib/core_ex/object/singleton_class.rb +1 -1
  18. data/lib/core_ex/object/the_first_time.rb +1 -1
  19. data/lib/core_ex/pathname.rb +17 -11
  20. data/lib/core_ex/proc.rb +80 -1
  21. data/lib/core_ex/rakefile_base.rf +192 -296
  22. data/lib/core_ex/require.rb +1 -1
  23. data/lib/core_ex/string.rb +11 -2
  24. data/lib/core_ex/time.rb +1 -1
  25. data/lib/core_ex/try_dup.rb +1 -1
  26. data/lib/core_ex/yaml.rb +101 -79
  27. data/lib/core_ex.rb +129 -128
  28. data/lib/d_time.rb +225 -53
  29. data/lib/dumpable_proc.rb +1 -10
  30. data/lib/path_list.rb +18 -7
  31. data/lib/temp_path.rb +3 -3
  32. data/lib/test/unit/u_i/yaml/test_runner.rb +1 -1
  33. data/lib/version.rb +309 -69
  34. data/lib/yaml_extension.rb +1 -1
  35. data/test/fixtures/lazy_loading/a_b/a/c.rb +6 -0
  36. data/test/fixtures/lazy_loading/a_b/a.rb +2 -0
  37. data/test/fixtures/lazy_loading/a_b/b/c.rb +4 -0
  38. data/test/fixtures/lazy_loading/a_b/b.rb +2 -0
  39. data/test/fixtures/lazy_loading/double/a/bouhou.rb +2 -0
  40. data/test/fixtures/lazy_loading/double/a/foo_bar.rb +5 -0
  41. data/test/fixtures/lazy_loading/double/a/sub/a/suba.rb +7 -0
  42. data/test/fixtures/lazy_loading/double/b/root/sub/b.rb +6 -0
  43. data/test/fixtures/lazy_loading/double/b/root/sub.rb +4 -0
  44. data/test/fixtures/lazy_loading/double/b/root.rb +2 -0
  45. data/test/fixtures/lazy_loading/foo_bars/foo_bar.rb +4 -0
  46. data/test/fixtures/lazy_loading/foo_bars/mods/mod.rb +6 -0
  47. data/test/fixtures/lazy_loading/foo_bars/mods/sub_mod.rb +6 -0
  48. data/test/fixtures/lazy_loading/foo_bars/mods/sub_sub_mod.rb +7 -0
  49. data/test/fixtures/lazy_loading/foo_bars/mods.rb +4 -0
  50. data/test/fixtures/lazy_loading/foo_bars/sub_foo_bar.rb +5 -0
  51. data/test/fixtures/lazy_loading/foo_bars/titis/tutu.rb +6 -0
  52. data/test/fixtures/lazy_loading/foo_bars/totos.rb +6 -0
  53. data/test/fixtures/lazy_loading/foo_bars.rb +4 -0
  54. data/test/lazy_loading/test_already_present_name_absolute.rb +6 -0
  55. data/test/lazy_loading/test_already_present_name_relative.rb +11 -0
  56. data/test/lazy_loading/test_inside_another_module.rb +5 -0
  57. data/test/lazy_loading/test_lazy_loading.rb +179 -0
  58. data/test/sanity/multiple-requires.yml +22 -4
  59. data/test/unit-suite.yml +5 -4
  60. metadata +119 -80
  61. data/SPEC.dyn.yml +0 -10
  62. data/SPEC.gemspec +0 -13
  63. data/test/test-unit-setup.rb +0 -19
  64. /data/test/{resources → fixtures}/require/test_require +0 -0
  65. /data/test/{resources → fixtures}/require/test_require_rb.rb +0 -0
  66. /data/test/{resources → fixtures}/require/test_require_so.so +0 -0
  67. /data/test/{resources → fixtures}/use-from-gems.rb +0 -0
  68. /data/test/{resources → fixtures}/yaml_testrunner/unit_test.rb +0 -0
@@ -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: require.rb 334 2005-09-04 14:29:40Z ertai $
4
+ # Revision:: $Id: /w/fey/ruby_ex/trunk/core_ex/lib/core_ex/require.rb 7939 2005-09-04T14:29:40.923141Z ertai $
5
5
 
6
6
  # FIXME This autoload didn't work for these reasons:
7
7
  # - |
@@ -26,14 +26,23 @@ module CoreEx
26
26
  self
27
27
  end
28
28
 
29
- def import
30
- to_path.import
29
+ def import!
30
+ to_path.import!
31
31
  end
32
32
 
33
33
  def to_path
34
34
  ::Pathname.new(self)
35
35
  end
36
36
 
37
+ def to_uri
38
+ URI.parse(self)
39
+ end
40
+ alias_method :to_url, :to_uri
41
+
42
+ def to_proc
43
+ DumpableProc.new(self)
44
+ end
45
+
37
46
  def rec_fold ( init, &block )
38
47
  if include? "\n"
39
48
  super
data/lib/core_ex/time.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # Author:: Nicolas Pouillard <ertai@lrde.epita.fr>.
2
2
  # Copyright:: Copyright (c) 2005 Nicolas Pouillard. All rights reserved.
3
3
  # License:: GNU General Public License (GPL).
4
- # Revision:: $Id: time.rb 336 2005-09-06 20:32:49Z ertai $
4
+ # Revision:: $Id: /w/fey/ruby_ex/trunk/core_ex/lib/core_ex/time.rb 7941 2005-09-06T20:32:49.915023Z ertai $
5
5
 
6
6
 
7
7
  module CoreEx
@@ -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: try_dup.rb 334 2005-09-04 14:29:40Z ertai $
4
+ # Revision:: $Id: /w/fey/ruby_ex/trunk/core_ex/lib/core_ex/try_dup.rb 7939 2005-09-04T14:29:40.923141Z ertai $
5
5
 
6
6
 
7
7
  module CoreEx
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: yaml.rb 383 2005-10-02 16:48:09Z ertai $
4
+ # Revision:: $Id: /w/fey/ruby_ex/trunk/core_ex/lib/core_ex/yaml.rb 21944 2006-02-19T17:32:33.171560Z pouillar $
5
5
 
6
6
 
7
7
  module CoreEx
@@ -11,6 +11,75 @@ module CoreEx
11
11
 
12
12
  end # module CoreEx
13
13
 
14
+
15
+ module YAML
16
+
17
+ module_function
18
+
19
+ def load_from_io ( io, &block )
20
+ buffer = ''
21
+ io.each_line do |line|
22
+ if not buffer.empty? and line =~ /^---/
23
+ block[YAML.load(buffer)]
24
+ buffer = ''
25
+ else
26
+ buffer += line
27
+ end
28
+ end
29
+ end
30
+
31
+ def have_option? ( opts, opt_name )
32
+ if opts.respond_to? :[]
33
+ opts[opt_name] || have_option?(opts[:Emitter], opt_name)
34
+ elsif opts.respond_to? :options
35
+ have_option? opts.options, opt_name
36
+ end
37
+ end
38
+
39
+
40
+ module BaseNode
41
+
42
+ def symbol_safe_key_transform ( t, k, v )
43
+ k = k.symbol_safe_transform if k.is_a? BaseNode
44
+ case k
45
+ when /^:"(.*)"/ then k = $1.to_sym
46
+ when /^:(.*)/ then k = $1.to_sym
47
+ end
48
+ if v.is_a? BaseNode
49
+ t[k] = v.symbol_safe_transform
50
+ else
51
+ t[k] = v
52
+ end
53
+ end
54
+ private :symbol_safe_key_transform
55
+
56
+ def symbol_safe_transform
57
+ @type_id = nil unless defined? @type_id
58
+ t = nil
59
+ case @value
60
+ when Hash
61
+ t = {}
62
+ @value.each do |k, v|
63
+ symbol_safe_key_transform(t, k, v)
64
+ end
65
+ when Array
66
+ t = []
67
+ @value.each do |v|
68
+ t.push v.symbol_safe_transform
69
+ end
70
+ when /^:"(.*)"/, /^:(.*)/
71
+ return $1.to_sym
72
+ else
73
+ return transform
74
+ end
75
+ YAML.transfer(@type_id, t)
76
+ end
77
+
78
+ end # module BaseNode
79
+
80
+ end # module YAML
81
+
82
+
14
83
  class Regexp
15
84
  have YamlExtension, :re
16
85
 
@@ -41,17 +110,20 @@ end # class Regexp
41
110
 
42
111
 
43
112
 
44
- class Range
45
- have YamlExtension
46
-
47
- def to_yaml_string
48
- to_s
49
- end
113
+ class Range # FIXME
114
+ yaml_as 'tag:yaml.org,2002:range'
50
115
 
51
- def self.yaml_load ( val )
52
- range = eval(val.to_s)
53
- raise ArgumentError, "need a range not #{val}" unless range.is_a? Range
54
- range
116
+ class << self
117
+ alias_method :yaml_new_no_eval, :yaml_new
118
+ def yaml_new( klass, tag, val )
119
+ begin
120
+ yaml_new_no_eval klass, tag, val
121
+ rescue YAML::TypeError
122
+ range = eval val.to_s
123
+ raise unless range.is_a? Range
124
+ range
125
+ end
126
+ end
55
127
  end
56
128
 
57
129
  end # class Range
@@ -62,42 +134,18 @@ class Array
62
134
 
63
135
  alias_method :old_to_yaml, :to_yaml
64
136
 
65
- if HAVE_YAML_TAGURI
66
- def to_yaml ( opts={} )
67
- inline = nil
68
- if not opts.is_a?(YAML::Syck::Emitter) and opts[:Inline] and not is_complex_yaml?
69
- inline = :inline
70
- end
71
- YAML::quick_emit(object_id, opts) do |out|
72
- out.seq( taguri, to_yaml_style || inline ) do |seq|
73
- each { |x| seq.add x }
74
- end
75
- end
137
+ def to_yaml ( opts={} )
138
+ inline = nil
139
+ if YAML.have_option? opts, :Inline and not is_complex_yaml?
140
+ inline = :inline
76
141
  end
77
- else
78
- def to_yaml ( opts={} )
79
- em = (opts.is_a? YAML::Syck::Emitter)? opts : opts[:Emitter]
80
- if (opts[:Inline] or (em and em.options[:Inline])) and not is_complex_yaml?
81
- YAML::quick_emit(self.object_id, opts) do |out|
82
- out << '['
83
- first = true
84
- each do |x|
85
- if first
86
- first = false
87
- else
88
- out << ', '
89
- end
90
- x.to_yaml(:Emitter => out)
91
- end
92
- out << ']'
93
- end
94
- else
95
- old_to_yaml(opts)
142
+ YAML::quick_emit(object_id, opts) do |out|
143
+ out.seq( taguri, to_yaml_style || inline ) do |seq|
144
+ each { |x| seq.add x }
96
145
  end
97
146
  end
98
147
  end
99
148
 
100
-
101
149
  suppress(NoMethodError, NameError) { undef_method :is_complex_yaml? }
102
150
 
103
151
  def is_complex_yaml?
@@ -112,44 +160,18 @@ class Hash
112
160
 
113
161
  alias_method :old_to_yaml, :to_yaml
114
162
 
115
- if HAVE_YAML_TAGURI
116
- def to_yaml ( opts={} )
117
- inline = nil
118
- if not opts.is_a?(YAML::Syck::Emitter) and opts[:Inline] and not is_complex_yaml?
119
- inline = :inline
120
- end
121
- YAML::quick_emit(object_id, opts) do |out|
122
- out.map(taguri, to_yaml_style || inline) do |map|
123
- each { |k, v| map.add k, v }
124
- end
125
- end
163
+ def to_yaml ( opts={} )
164
+ inline = nil
165
+ if YAML.have_option? opts, :Inline and not is_complex_yaml?
166
+ inline = :inline
126
167
  end
127
- else
128
- def to_yaml ( opts={} )
129
- em = (opts.is_a? YAML::Syck::Emitter)? opts : opts[:Emitter]
130
- if (opts[:Inline] or (em and em.options[:Inline])) and not is_complex_yaml?
131
- YAML::quick_emit(self.object_id, opts) do |out|
132
- out << '{'
133
- first = true
134
- each do |k, v|
135
- if first
136
- first = false
137
- else
138
- out << ', '
139
- end
140
- k.to_yaml(:Emitter => out)
141
- out << ': '
142
- v.to_yaml(:Emitter => out)
143
- end
144
- out << '}'
145
- end
146
- else
147
- old_to_yaml(opts)
168
+ YAML::quick_emit(object_id, opts) do |out|
169
+ out.map(taguri, to_yaml_style || inline) do |map|
170
+ each { |k, v| map.add k, v }
148
171
  end
149
172
  end
150
173
  end
151
174
 
152
-
153
175
  suppress(NoMethodError, NameError) { undef_method :is_complex_yaml? }
154
176
 
155
177
  def is_complex_yaml?
@@ -189,10 +211,10 @@ test_section __FILE__ do
189
211
  end
190
212
 
191
213
  def test_range
192
- assert_yaml_load "!range 0..10", Range, 0..10
193
- assert_yaml_dump @val, @ref
194
- assert_yaml_load "!range 0...10", Range, 0...10
195
- assert_yaml_dump @val, @ref
214
+ assert_yaml_load '!range "0..10"', Range, 0..10
215
+ assert_yaml_dump @val, "!range \nbegin: 0\nend: 10\nexcl: false"
216
+ assert_yaml_load '!range "0...10"', Range, 0...10
217
+ assert_yaml_dump @val, "!range \nbegin: 0\nend: 10\nexcl: true"
196
218
  end
197
219
 
198
220
  def test_ruby
data/lib/core_ex.rb CHANGED
@@ -1,10 +1,17 @@
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: core_ex.rb 386 2005-10-03 00:02:16Z ertai $
4
+ # Revision:: $Id: /w/fey/ruby_ex/trunk/core_ex/lib/core_ex.rb 22188 2006-02-23T16:26:24.490864Z pouillar $
5
5
 
6
6
  unless defined? CORE_EX_LOADED and CORE_EX_LOADED
7
7
  CORE_EX_LOADED = true
8
+
9
+ # Nothing before me !!!
10
+ class Module
11
+ alias_method :original_core_ex_const_missing, :const_missing
12
+ alias_method :the_standard_name, :name
13
+ end # module Module
14
+
8
15
  require 'English'
9
16
  $LOADED_FEATURES << 'core_ex.rb' unless $LOADED_FEATURES.include? 'core_ex.rb'
10
17
 
@@ -46,7 +53,7 @@ unless defined? CORE_EX_LOADED and CORE_EX_LOADED
46
53
  end
47
54
 
48
55
  begin
49
- require 'rubygems'
56
+ require 'rubygems' unless ENV['NO_GEM']
50
57
  raise LoadError, 'RubyGems not loaded' unless defined? RubyGems
51
58
  def core_ex_gem_require ( gem_name, gem_version='> 0' )
52
59
  require_gem gem_name, gem_version
@@ -73,45 +80,123 @@ unless defined? CORE_EX_LOADED and CORE_EX_LOADED
73
80
  verbose = $VERBOSE
74
81
  $VERBOSE = false
75
82
 
76
- # <<< Dynamic fix: bug: Ruby 1.8.3 vs active_support 1.1.1
77
- require 'logger'
78
- class Logger
79
- Format = 42 unless defined? Format
83
+ core_ex_require 'active_support', 'activesupport', 'activesupport', '~> 1.2.5'
84
+
85
+ $VERBOSE = verbose
86
+
87
+ # <<< little active_support patch
88
+ silence_warnings do
89
+ module Inflector
90
+ class Inflections
91
+ # <<<
92
+ attr_reader :underscore_rules, :camelize_rules
93
+ # >>>
94
+ def initialize
95
+ # <<<
96
+ clear_all
97
+ # >>>
98
+ end
99
+ # <<<
100
+ def clear_all
101
+ @plurals, @singulars, @uncountables, @underscore_rules, @camelize_rules = [], [], [], [], []
102
+ end
103
+ # >>>
104
+ def clear ( scope=:all )
105
+ case scope
106
+ when :all
107
+ # <<<
108
+ clear_all
109
+ # >>>
110
+ else
111
+ instance_variable_set "@#{scope}", []
112
+ end
113
+ end
114
+ def mk_regexp ( anObject )
115
+ case anObject
116
+ when Regexp then anObject
117
+ else
118
+ str = Regexp.quote anObject.to_s
119
+ /\b#{str}\b/
120
+ end
121
+ end
122
+ private :mk_regexp
123
+ def underscore(rule, replacement)
124
+ @underscore_rules.unshift [mk_regexp(rule), replacement]
125
+ end
126
+ def camelize(rule, replacement)
127
+ @camelize_rules.unshift [mk_regexp(rule), replacement]
128
+ end
129
+ def fixed_case ( camel_cased_word,
130
+ lower_case_and_underscored_word=camel_cased_word.downcase )
131
+ camelize(lower_case_and_underscored_word, camel_cased_word)
132
+ underscore(camel_cased_word, lower_case_and_underscored_word)
133
+ end
134
+ def fixed_cases ( *words )
135
+ for word in words
136
+ if word.is_a? Array
137
+ fixed_case(*word)
138
+ else
139
+ fixed_case word
140
+ end
141
+ end
142
+ end
143
+ end
144
+ # Since Inflections is already loaded and is a Singleton we need to initialize
145
+ # our variables by hand:
146
+ Inflections.instance.instance_eval { @underscore_rules, @camelize_rules = [], [] }
147
+
148
+ def underscore(camel_cased_word)
149
+ # <<<
150
+ result = camel_cased_word.to_s.split '::'
151
+ result.map! do |word|
152
+ inflections.underscore_rules.each { |(rule, replacement)| break if word.gsub!(rule, replacement) }
153
+ word.gsub!(/([A-Z])/, '_\1')
154
+ word.gsub!(/^_/, '')
155
+ word.downcase!
156
+ word
157
+ end
158
+ result.join '/'
159
+ # >>>
160
+ end
161
+ def camelize(lower_case_and_underscored_word)
162
+ # <<<
163
+ result = lower_case_and_underscored_word.to_s.split '/'
164
+ result.map! do |word|
165
+ inflections.camelize_rules.each { |(rule, replacement)| break if word.gsub!(rule, replacement) }
166
+ word.gsub!(/(^|_)(.)/) { $2.upcase }
167
+ word
168
+ end
169
+ result.join '::'
170
+ # >>>
171
+ end
172
+ end # module Inflector
80
173
  end
174
+ module Dependencies
175
+ def self.change_mechanism ( arg, &block )
176
+ save = mechanism
177
+ begin
178
+ self.mechanism = arg
179
+ block[]
180
+ ensure
181
+ self.mechanism = save
182
+ end
183
+ end
184
+ end # module Dependencies
81
185
  # >>>
82
186
 
83
- core_ex_require 'active_support', 'activesupport', 'activesupport', '~> 1.1.1'
84
-
85
187
  # <<< Dynamic patch: Yaml warnings in ruby 1.8.3
86
188
  begin
87
- silence_warnings { require 'yaml/tag' }
189
+ Dependencies.change_mechanism(:require) { silence_warnings { require_dependency 'yaml' } }
88
190
  class Module
89
- alias yaml_as_bugged yaml_as
191
+ alias_method :yaml_as_bugged, :yaml_as
90
192
  def yaml_as( tag, sc = true )
91
- class_eval <<-"end;", __FILE__, __LINE__
92
- attr_writer :taguri
93
- def taguri
94
- if respond_to? :to_yaml_type
95
- YAML::tagurize( to_yaml_type[1..-1] )
96
- else
97
- return @taguri if defined? @taguri
98
- tag = #{ tag.dump }
99
- if self.class.yaml_tag_subclasses? and self.class != YAML::tagged_classes[tag]
100
- tag = "\#{ tag }:\#{ self.class.yaml_tag_class_name }"
101
- end
102
- tag
103
- end
104
- end
105
- def self.yaml_tag_subclasses?; #{ sc ? 'true' : 'false' }; end
106
- end;
107
- YAML::tag_class tag, self
193
+ silence_warnings { yaml_as_bugged(tag, sc) }
108
194
  end
109
195
  end
110
- silence_warnings { require 'yaml' }
111
196
  module YAML
112
197
  module Syck
113
198
  class Parser
114
- alias initialize_bugged initialize
199
+ alias_method :initialize_bugged, :initialize
115
200
  def initialize ( *a, &b )
116
201
  @input = nil
117
202
  initialize_bugged(*a, &b)
@@ -131,74 +216,6 @@ unless defined? CORE_EX_LOADED and CORE_EX_LOADED
131
216
  # >>>
132
217
 
133
218
 
134
- # <<< little active_support patch
135
- module Inflector
136
- def underscore(camel_cased_word)
137
- camel_cased_word.to_s.gsub(/::/, '/').gsub(/([A-Z])/,'_\1').gsub(/(^|\/)_/, '\1').downcase
138
- end
139
- def constantize(camel_cased_word, start=Object)
140
- camel_cased_word.split("::").inject(start) do |final_type, part|
141
- return nil unless final_type.const_defined? part
142
- final_type.const_get(part)
143
- end
144
- end
145
- end # module Inflector
146
- module Dependencies
147
- class LoadingModule
148
- def const_load!(name, file_name = nil)
149
- file_name ||= 'application' if root? && name.to_s == 'ApplicationController'
150
- path = self.path + [file_name || name]
151
-
152
- load_paths.each do |load_path|
153
- fs_path = load_path.filesystem_path(path)
154
- next unless fs_path
155
-
156
- case
157
- when File.directory?(fs_path)
158
- new_module = LoadingModule.new(self.root, self.path + [name])
159
- self.const_set name, new_module
160
- if self.root?
161
- if Object.const_defined?(name)
162
- msg = "Cannot load module #{name}: Object::#{name} is set to #{Object.const_get(name).inspect}"
163
- raise NameError, msg
164
- end
165
- Object.const_set(name, new_module)
166
- end
167
- # <<<
168
- module_fs_path = fs_path + '.rb'
169
- self.root.load_file!(module_fs_path) if File.exist?(module_fs_path)
170
- # >>>
171
- break
172
- when File.file?(fs_path)
173
- self.root.load_file!(fs_path)
174
-
175
- # Import the loaded constant from Object provided we are the root node.
176
- self.const_set(name, Object.const_get(name)) if self.root? && Object.const_defined?(name)
177
- break
178
- end
179
- end
180
-
181
- self.const_defined?(name)
182
- end
183
- end # class LoadingModule
184
- end # module Dependencies
185
- # >>>
186
-
187
- $VERBOSE = verbose
188
-
189
- DEPENDENCIES_MECHANISM = :require unless defined? DEPENDENCIES_MECHANISM
190
- Dependencies.mechanism = DEPENDENCIES_MECHANISM
191
-
192
- if Object.const_defined? :Controllers
193
- # Perhaps a rails environement
194
- raise 'bad Controllers' unless Controllers.is_a? Dependencies::RootLoadingModule
195
- Controllers.load_paths << Dependencies::ConstantLoadPath.new(CORE_EX_DIR.to_s)
196
- else
197
- Controllers = Dependencies::LoadingModule.root(CORE_EX_DIR.to_s)
198
- end
199
- Controllers::CoreEx.name # .import! is not yet defined
200
- Controllers::Test::Unit::UI::Yaml.name
201
-
202
219
  module CoreEx
203
220
 
204
221
  module_function
@@ -211,8 +228,20 @@ module CoreEx
211
228
  dir + 'core_ex'
212
229
  end
213
230
 
231
+ def test_dir
232
+ dir.parent + 'test'
233
+ end
234
+
235
+ def fixtures_dir
236
+ test_dir + 'fixtures'
237
+ end
238
+
214
239
  end # module CoreEx
215
240
 
241
+ $LOAD_PATH << CoreEx.dir
242
+
243
+ require 'core_ex/embedded_tests'
244
+
216
245
  class Object
217
246
  include CoreEx::EmbeddedTests
218
247
  end # class Object
@@ -220,6 +249,8 @@ if defined? EMBEDDED_TEST_MODE
220
249
  embedded_test_mode EMBEDDED_TEST_MODE
221
250
  end
222
251
 
252
+ require 'core_ex/lazy_loading'
253
+
223
254
  class String
224
255
  include CoreEx::String
225
256
  end # class String
@@ -251,34 +282,6 @@ class Pathname
251
282
  include CoreEx::Pathname
252
283
  end # class Pathname
253
284
 
254
- $LOADED_FEATURES.dup.each do |feature|
255
- if (path = Pathname.new(feature)).absolute?
256
- load_path, base_path = path.split_with_load_path($LOAD_PATH)
257
- unless load_path.nil?
258
- new_feature = base_path.to_s
259
- next if $LOADED_FEATURES.include? new_feature
260
- $LOADED_FEATURES << new_feature
261
- end
262
- end
263
- end
264
-
265
- module Kernel
266
-
267
- alias_method :require_without_unification, :require
268
- def require ( file, *a )
269
- if (path = Pathname.new(file)).absolute?
270
- load_path, base_path = path.split_with_load_path
271
- unless load_path.nil?
272
- feature = base_path.to_s
273
- return false if $LOADED_FEATURES.include? feature
274
- $LOADED_FEATURES << feature
275
- end
276
- end
277
- require_without_unification(file, *a)
278
- end
279
-
280
- end # module Kernel
281
-
282
285
  module Enumerable
283
286
  include CoreEx::Enumerable
284
287
  end # module Enumerable
@@ -303,9 +306,7 @@ CoreEx.dir.load_path!
303
306
  CoreEx::Yaml.import!
304
307
  CoreEx::TryDup.import!
305
308
 
306
-
307
309
  require 'pp'
308
- silence_warnings { require 'active_support/breakpoint' }
309
310
 
310
311
  test_section __FILE__ do
311
312
 
@@ -318,7 +319,7 @@ test_section __FILE__ do
318
319
  end
319
320
 
320
321
  def test_simple
321
- assert_kind_of Dependencies::LoadingModule, Controllers::CoreEx
322
+ assert_kind_of Module, CoreEx
322
323
  assert_raise(NameError) { EmbeddedTests }
323
324
  assert_kind_of Module, CoreEx::EmbeddedTests
324
325
  end