sugar-high 0.4.9.1 → 0.4.9.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.9.1
1
+ 0.4.9.2
@@ -13,7 +13,19 @@ class Class
13
13
  end
14
14
  end
15
15
 
16
- module ClassExt
16
+ module AutoLoader
17
+ @@root = ''
18
+
19
+ def self.root
20
+ @@root
21
+ end
22
+
23
+ def self.root= root_dir
24
+ @@root = root_dir
25
+ end
26
+ end
27
+
28
+ module ClassExt
17
29
  def get_module name
18
30
  # Module.const_get(name)
19
31
  name.to_s.camelize.constantize
@@ -91,13 +103,13 @@ class Object
91
103
  # Mixing this method to Object, so both modules and classes would be able to use it!
92
104
  def autoload_modules *args
93
105
 
94
- options = args.extract_options!
95
- from = options[:from] || self.name.to_s.underscore
96
-
106
+ options = args.extract_options!
107
+ root = options[:root] || AutoLoader.root || ''
108
+ from = options[:from] || File.join(root, self.name.to_s.underscore)
109
+
97
110
  # Here also could be adding of the file in top of load_paths like: $:.unshift File.dirname(__FILE__)
98
111
  # It is very useful for situations of having not load_paths built Rails or Gems way.
99
-
100
- args.each do |req_name|
112
+ args.each do |req_name|
101
113
  send :autoload, req_name, "#{from}/#{req_name.to_s.underscore}"
102
114
  end
103
115
  end
@@ -1,8 +1,3 @@
1
- $:.unshift File.dirname(__FILE__)
2
-
3
1
  module AutoloadModules
4
- #autoload :First, 'autoload_modules/first'
5
- #autoload :Second, 'autoload_modules/second'
6
- #autoload :Third, 'autoload_modules/third'
7
- autoload_modules :First, :Second, :Third, :from => 'autoload_modules/subdir'
2
+ autoload_modules :First, :Second, :Third, :from => 'fixtures/autoload_modules/subdir'
8
3
  end
@@ -0,0 +1,3 @@
1
+ module AutoloadModulesRoot
2
+ autoload_modules :First, :Second, :Third
3
+ end
@@ -0,0 +1,7 @@
1
+ module AutoloadModulesRoot
2
+ module First
3
+ def test
4
+ puts "here is the test"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,4 @@
1
+ module AutoloadModulesRoot
2
+ class Second
3
+ end
4
+ end
@@ -0,0 +1,7 @@
1
+ module AutoloadModulesRoot
2
+ class Third
3
+ def self.test
4
+ puts "here is the test"
5
+ end
6
+ end
7
+ end
@@ -1,6 +1,4 @@
1
- $:.unshift File.dirname(__FILE__)
2
-
3
1
  module AutoloadModulez
4
- autoload_modules :First, :Second, :ThirdOneHere
2
+ autoload_modules :First, :Second, :ThirdOneHere, :root => 'fixtures'
5
3
  end
6
4
 
@@ -41,6 +41,13 @@ describe Object do
41
41
  require 'fixtures/autoload_modules'
42
42
  AutoloadModules::Third.should respond_to(:test)
43
43
  end
44
+
45
+ it 'should autoload modules using ClassExt#autoload_root' do
46
+ AutoLoader.root = 'fixtures'
47
+ require 'fixtures/autoload_modules_root'
48
+ AutoloadModulesRoot::Third.should respond_to(:test)
49
+ end
50
+
44
51
  it "should autoload modules from __FILE__'s dir if :from is omitted'" do
45
52
  require 'fixtures/autoload_modulez'
46
53
  AutoloadModulez::ThirdOneHere.should respond_to(:test)
data/sugar-high.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{sugar-high}
8
- s.version = "0.4.9.1"
8
+ s.version = "0.4.9.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = [%q{Kristian Mandrup}]
@@ -63,6 +63,10 @@ Gem::Specification.new do |s|
63
63
  "spec/fixtures/autoload_modules/subdir/first.rb",
64
64
  "spec/fixtures/autoload_modules/subdir/second.rb",
65
65
  "spec/fixtures/autoload_modules/subdir/third.rb",
66
+ "spec/fixtures/autoload_modules_root.rb",
67
+ "spec/fixtures/autoload_modules_root/first.rb",
68
+ "spec/fixtures/autoload_modules_root/second.rb",
69
+ "spec/fixtures/autoload_modules_root/third.rb",
66
70
  "spec/fixtures/autoload_modulez.rb",
67
71
  "spec/fixtures/autoload_modulez/first.rb",
68
72
  "spec/fixtures/autoload_modulez/second.rb",
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sugar-high
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.9.1
4
+ version: 0.4.9.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2011-06-23 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &2156798840 !ruby/object:Gem::Requirement
16
+ requirement: &2158529860 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *2156798840
24
+ version_requirements: *2158529860
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: active_support
27
- requirement: &2156798160 !ruby/object:Gem::Requirement
27
+ requirement: &2158529300 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *2156798160
35
+ version_requirements: *2158529300
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &2156797460 !ruby/object:Gem::Requirement
38
+ requirement: &2158528740 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '2.5'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *2156797460
46
+ version_requirements: *2158528740
47
47
  description: More Ruby sugar - inspired by the 'zuker' project
48
48
  email: kmandrup@gmail.com
49
49
  executables: []
@@ -98,6 +98,10 @@ files:
98
98
  - spec/fixtures/autoload_modules/subdir/first.rb
99
99
  - spec/fixtures/autoload_modules/subdir/second.rb
100
100
  - spec/fixtures/autoload_modules/subdir/third.rb
101
+ - spec/fixtures/autoload_modules_root.rb
102
+ - spec/fixtures/autoload_modules_root/first.rb
103
+ - spec/fixtures/autoload_modules_root/second.rb
104
+ - spec/fixtures/autoload_modules_root/third.rb
101
105
  - spec/fixtures/autoload_modulez.rb
102
106
  - spec/fixtures/autoload_modulez/first.rb
103
107
  - spec/fixtures/autoload_modulez/second.rb