sugar-high 0.4.9.2 → 0.4.9.3
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/VERSION +1 -1
- data/lib/sugar-high/class_ext.rb +15 -17
- data/spec/sugar-high/class_ext_spec.rb +17 -14
- data/sugar-high.gemspec +2 -2
- metadata +8 -8
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.9.
|
1
|
+
0.4.9.3
|
data/lib/sugar-high/class_ext.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'sugar-high/kind_of'
|
2
2
|
require 'sugar-high/array'
|
3
3
|
|
4
|
-
class
|
4
|
+
class Module
|
5
5
|
def include_and_extend(the_module, options={})
|
6
6
|
options[:instance_methods] ||= :InstanceMethods
|
7
7
|
options[:class_methods] ||= :ClassMethods
|
@@ -11,6 +11,20 @@ class Class
|
|
11
11
|
include main_module.const_get(options[:instance_methods]) if main_module.const_defined?(options[:instance_methods])
|
12
12
|
extend main_module.const_get(options[:class_methods]) if main_module.const_defined?(options[:class_methods])
|
13
13
|
end
|
14
|
+
|
15
|
+
def autoload_modules *args
|
16
|
+
|
17
|
+
options = args.extract_options!
|
18
|
+
root = options[:root] || AutoLoader.root || ''
|
19
|
+
from = options[:from] || File.join(root, self.name.to_s.underscore)
|
20
|
+
|
21
|
+
# Here also could be adding of the file in top of load_paths like: $:.unshift File.dirname(__FILE__)
|
22
|
+
# It is very useful for situations of having not load_paths built Rails or Gems way.
|
23
|
+
args.each do |req_name|
|
24
|
+
send :autoload, req_name, "#{from}/#{req_name.to_s.underscore}"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
14
28
|
end
|
15
29
|
|
16
30
|
module AutoLoader
|
@@ -98,19 +112,3 @@ module ClassExt
|
|
98
112
|
modules.first
|
99
113
|
end
|
100
114
|
end
|
101
|
-
|
102
|
-
class Object
|
103
|
-
# Mixing this method to Object, so both modules and classes would be able to use it!
|
104
|
-
def autoload_modules *args
|
105
|
-
|
106
|
-
options = args.extract_options!
|
107
|
-
root = options[:root] || AutoLoader.root || ''
|
108
|
-
from = options[:from] || File.join(root, self.name.to_s.underscore)
|
109
|
-
|
110
|
-
# Here also could be adding of the file in top of load_paths like: $:.unshift File.dirname(__FILE__)
|
111
|
-
# It is very useful for situations of having not load_paths built Rails or Gems way.
|
112
|
-
args.each do |req_name|
|
113
|
-
send :autoload, req_name, "#{from}/#{req_name.to_s.underscore}"
|
114
|
-
end
|
115
|
-
end
|
116
|
-
end
|
@@ -27,15 +27,30 @@ module First
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
-
|
30
|
+
module Second
|
31
31
|
include_and_extend First
|
32
32
|
end
|
33
33
|
|
34
|
+
class Third
|
35
|
+
include_and_extend Second
|
36
|
+
end
|
37
|
+
|
34
38
|
def trial
|
35
39
|
@trial ||= Trial.new
|
36
40
|
end
|
37
41
|
|
38
|
-
describe
|
42
|
+
describe Module do
|
43
|
+
|
44
|
+
describe "#include_and_extend" do
|
45
|
+
it "should include class methods" do
|
46
|
+
Third.should respond_to(:class_method)
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should include class methods" do
|
50
|
+
Third.new.should respond_to(:instance_method)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
39
54
|
describe "#autoload_modules" do
|
40
55
|
it "should autoload modules using :from => path" do
|
41
56
|
require 'fixtures/autoload_modules'
|
@@ -53,19 +68,7 @@ describe Object do
|
|
53
68
|
AutoloadModulez::ThirdOneHere.should respond_to(:test)
|
54
69
|
end
|
55
70
|
end
|
56
|
-
end
|
57
|
-
|
58
|
-
describe Class do
|
59
|
-
|
60
|
-
describe "#include_and_extend" do
|
61
|
-
it "should include class methods" do
|
62
|
-
Second.should respond_to(:class_method)
|
63
|
-
end
|
64
71
|
|
65
|
-
it "should include class methods" do
|
66
|
-
Second.new.should respond_to(:instance_method)
|
67
|
-
end
|
68
|
-
end
|
69
72
|
end
|
70
73
|
|
71
74
|
describe ClassExt do
|
data/sugar-high.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{sugar-high}
|
8
|
-
s.version = "0.4.9.
|
8
|
+
s.version = "0.4.9.3"
|
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}]
|
12
|
-
s.date = %q{2011-06-
|
12
|
+
s.date = %q{2011-06-24}
|
13
13
|
s.description = %q{More Ruby sugar - inspired by the 'zuker' project}
|
14
14
|
s.email = %q{kmandrup@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
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.
|
4
|
+
version: 0.4.9.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-06-
|
12
|
+
date: 2011-06-24 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &2160205840 !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: *
|
24
|
+
version_requirements: *2160205840
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: active_support
|
27
|
-
requirement: &
|
27
|
+
requirement: &2160205180 !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: *
|
35
|
+
version_requirements: *2160205180
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rspec
|
38
|
-
requirement: &
|
38
|
+
requirement: &2160204680 !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: *
|
46
|
+
version_requirements: *2160204680
|
47
47
|
description: More Ruby sugar - inspired by the 'zuker' project
|
48
48
|
email: kmandrup@gmail.com
|
49
49
|
executables: []
|