require-me 0.6.5 → 0.7.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +28 -1
- data/lib/folder/folder.rb +94 -0
- data/lib/folder/magic.rb +97 -0
- data/lib/folder/magic_list.rb +72 -0
- data/lib/require-dsl.rb +2 -174
- data/spec/blip.rb +1 -0
- data/spec/dsl/blap.rb +1 -0
- data/spec/dsl/require-dsl_spec.rb +94 -0
- data/spec/spec_helper.rb +9 -5
- metadata +53 -8
- data/spec/require-dsl_spec.rb +0 -65
data/README.markdown
CHANGED
@@ -3,6 +3,11 @@
|
|
3
3
|
Includes a DSL for requiring files and folders and some also some static utility functions which can be used in combination.
|
4
4
|
These tools in combination facilitates managing requiring various subfolder structures.
|
5
5
|
|
6
|
+
## Important ##
|
7
|
+
|
8
|
+
The tool has gone through some more testing and some bugs have been found and fixed so it should now be more stable.
|
9
|
+
The rspec tests in spec/dsl directory demonstrate most of these new features.
|
10
|
+
|
6
11
|
## Installation ##
|
7
12
|
This gem is also available for installation on gemcutter.
|
8
13
|
|
@@ -74,7 +79,28 @@ Folder.enter do |folder| # use current path as folder
|
|
74
79
|
end
|
75
80
|
</pre>
|
76
81
|
|
77
|
-
Using '
|
82
|
+
Using 'require_rel' method. This is nice when fx requiring helper files used in test suite files
|
83
|
+
|
84
|
+
<pre>
|
85
|
+
require File.expand_path(File.dirname(__FILE__) + "../../../spec_helper")
|
86
|
+
</pre>
|
87
|
+
|
88
|
+
Can be replaced with the following in all .rb files under /spec
|
89
|
+
|
90
|
+
<pre>
|
91
|
+
Folder.require_rel 'spec/spec_helper', __FILE__
|
92
|
+
</pre>
|
93
|
+
|
94
|
+
Or ... using special convenience wrappers
|
95
|
+
|
96
|
+
|
97
|
+
<pre>
|
98
|
+
Folder.require_spec 'spec_helper', __FILE__ # relative to /spec folder
|
99
|
+
|
100
|
+
Folder.require_test 'spec_helper', __FILE__ # relative to /test folder
|
101
|
+
</pre>
|
102
|
+
|
103
|
+
Using 'require_me' method
|
78
104
|
|
79
105
|
<pre>
|
80
106
|
|
@@ -160,6 +186,7 @@ Set verbose mode on to see full path of each required file
|
|
160
186
|
Require.verbose = :off # turn off verbose globally
|
161
187
|
</pre>
|
162
188
|
|
189
|
+
|
163
190
|
### Require.recursive ##
|
164
191
|
|
165
192
|
Require all files within the top level folder 'data' recursively
|
@@ -0,0 +1,94 @@
|
|
1
|
+
require 'folder/magic'
|
2
|
+
require 'folder/magic_list'
|
3
|
+
|
4
|
+
module Folder
|
5
|
+
def self.enter(path = '.', &block)
|
6
|
+
m = Magic.new
|
7
|
+
m.enter path
|
8
|
+
m.relative_to_me
|
9
|
+
if block_given?
|
10
|
+
yield m
|
11
|
+
end
|
12
|
+
m.exit
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.enter_here(file, &block)
|
16
|
+
m = Magic.new
|
17
|
+
path = File.dirname(file)
|
18
|
+
m.enter path
|
19
|
+
m.relative_to_me
|
20
|
+
if block_given?
|
21
|
+
yield m
|
22
|
+
end
|
23
|
+
m.exit
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.rel_base(dir, source, &block)
|
27
|
+
enter(relative_path dir, source, &block)
|
28
|
+
end
|
29
|
+
|
30
|
+
# Folder.require_rel 'spec/spec_helper', __FILE__
|
31
|
+
# require /spec/spec_helper.rb relative to current file location
|
32
|
+
def self.relative_path(req_file, source, base_dir = nil)
|
33
|
+
req_file = File.join(base_dir, req_file) if base_dir
|
34
|
+
source_dir = File.dirname(source)
|
35
|
+
req_dir = req_file.split('/')[0] || req_file
|
36
|
+
# puts "req_dir: #{req_dir}"
|
37
|
+
|
38
|
+
req_file = req_file.split('/')[1]
|
39
|
+
folders = source_dir.split req_dir
|
40
|
+
|
41
|
+
folderlist = folders[1] ? folders[1].split('/') : folders[1]
|
42
|
+
if folderlist
|
43
|
+
path_nav = folderlist.inject([]){|res, f| res << '..' }.join('/')
|
44
|
+
else
|
45
|
+
path_nav = ''
|
46
|
+
end
|
47
|
+
File.expand_path(source_dir + "#{path_nav}/#{req_file}")
|
48
|
+
end
|
49
|
+
|
50
|
+
# Folder.require_rel 'spec/spec_helper', __FILE__
|
51
|
+
# require /spec/spec_helper.rb relative to current file location
|
52
|
+
def self.require_rel(req_file, source, base_dir = nil)
|
53
|
+
require relative_path(req_file, source, base_dir)
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.require_spec(req_file, source)
|
57
|
+
require relative_path(req_file, source, 'spec')
|
58
|
+
end
|
59
|
+
|
60
|
+
def self.require_test(req_file, source)
|
61
|
+
require relative_path(req_file, source, 'test')
|
62
|
+
end
|
63
|
+
|
64
|
+
|
65
|
+
def self.require_all(*folders)
|
66
|
+
return Magic.new.all.dup.extend(MagicList).do_require if folders.empty?
|
67
|
+
folders.each do |folder|
|
68
|
+
enter folder do |f|
|
69
|
+
f.all.dup.extend(MagicList).do_require
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def self.show_require_all(*folders)
|
75
|
+
return Magic.new.all.dup.extend(MagicList).show_require if folders.empty?
|
76
|
+
folders.each do |folder|
|
77
|
+
enter folder do |f|
|
78
|
+
f.all.dup.extend(MagicList).show_require
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
|
84
|
+
def self.here(file)
|
85
|
+
FileUtils.cd File.dirname(file)
|
86
|
+
self
|
87
|
+
end
|
88
|
+
|
89
|
+
def self.require_me(*files)
|
90
|
+
return Magic.new.all(files).dup.extend(MagicList).do_require
|
91
|
+
end
|
92
|
+
|
93
|
+
|
94
|
+
end
|
data/lib/folder/magic.rb
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
|
3
|
+
module Folder
|
4
|
+
class Magic
|
5
|
+
attr_accessor :current_path
|
6
|
+
attr_accessor :dir_stack
|
7
|
+
attr_accessor :relative_path
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
@dir_stack = []
|
11
|
+
@current_path = FileUtils.pwd
|
12
|
+
|
13
|
+
end
|
14
|
+
|
15
|
+
def relative_to_me
|
16
|
+
@relative_path = me
|
17
|
+
end
|
18
|
+
|
19
|
+
def to_s
|
20
|
+
"path: #{current_path}, directory stack: #{dir_stack.inspect}"
|
21
|
+
end
|
22
|
+
|
23
|
+
def me
|
24
|
+
Pathname.new(current_path).basename.to_s
|
25
|
+
end
|
26
|
+
|
27
|
+
def enter(dir)
|
28
|
+
path = FileUtils.pwd
|
29
|
+
dir_stack.push path
|
30
|
+
FileUtils.cd dir if !dir.empty?
|
31
|
+
@current_path = FileUtils.pwd
|
32
|
+
self.relative_to_me
|
33
|
+
if block_given?
|
34
|
+
yield self
|
35
|
+
exit
|
36
|
+
end
|
37
|
+
self
|
38
|
+
end
|
39
|
+
|
40
|
+
def exit
|
41
|
+
current_path = dir_stack.last
|
42
|
+
old_dir = dir_stack.last
|
43
|
+
dir_stack.pop
|
44
|
+
FileUtils.cd old_dir if old_dir
|
45
|
+
end
|
46
|
+
|
47
|
+
|
48
|
+
def all(*globs)
|
49
|
+
globs = '**/*.rb' if globs.empty?
|
50
|
+
list = FileList.new(globs)
|
51
|
+
magic_list(list)
|
52
|
+
end
|
53
|
+
|
54
|
+
def require_all(*folders)
|
55
|
+
relative = {:relative_to => relative_path || ''}
|
56
|
+
relative = folders.pop if folders && !folders.empty? && folders.last.kind_of?(Hash)
|
57
|
+
|
58
|
+
# puts "relative_to: #{relative[:relative_to]}"
|
59
|
+
|
60
|
+
if folders.empty?
|
61
|
+
files = all.dup.extend(MagicList)
|
62
|
+
files.rel_path = relative[:relative_to]
|
63
|
+
return files.do_require
|
64
|
+
end
|
65
|
+
|
66
|
+
# puts "iterate"
|
67
|
+
folders.each do |folder|
|
68
|
+
enter folder do |f|
|
69
|
+
file = f.all.dup.extend(MagicList)
|
70
|
+
require_relative_to = relative ? relative_to(folder, relative) : folder
|
71
|
+
file.do_require(require_relative_to)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def require_me(*files)
|
77
|
+
file = all(files).dup.extend(MagicList)
|
78
|
+
file.do_require(relative_path)
|
79
|
+
end
|
80
|
+
|
81
|
+
protected
|
82
|
+
|
83
|
+
def relative_to(folder, relative)
|
84
|
+
# puts "relative_to: #{relative.inspect}"
|
85
|
+
# puts "relative_to: #{relative[:relative_to]}"
|
86
|
+
relative[:relative_to] ? File.join(relative[:relative_to], folder) : folder
|
87
|
+
end
|
88
|
+
|
89
|
+
def magic_list(list)
|
90
|
+
list.extend(MagicList)
|
91
|
+
list.base_path = dir_stack.first
|
92
|
+
list.rel_path = current_path
|
93
|
+
list.freeze
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
module Folder
|
2
|
+
module MagicList
|
3
|
+
attr_accessor :base_path
|
4
|
+
attr_accessor :rel_path
|
5
|
+
|
6
|
+
def do_require(*options)
|
7
|
+
rel_path = options.shift if options && !options.empty?
|
8
|
+
each do |file|
|
9
|
+
req_file = self.rel_path ? File.join(self.rel_path, file) : file
|
10
|
+
require req_file
|
11
|
+
end
|
12
|
+
self
|
13
|
+
end
|
14
|
+
|
15
|
+
def show_require(*options)
|
16
|
+
each do |f|
|
17
|
+
if options.include? :relative
|
18
|
+
file_path = File.join(rel_path, f)
|
19
|
+
path = Require::Directory.relative_path(base_path, file_path)
|
20
|
+
end
|
21
|
+
path = File.join(base_path, f) if !options.include? :relative
|
22
|
+
path
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def except(*reg_exps)
|
27
|
+
duplicate = self.dup.extend(MagicList)
|
28
|
+
duplicate.each do |file|
|
29
|
+
reg_exps.each {|re| duplicate.delete(file) if file.match(re) }
|
30
|
+
end
|
31
|
+
duplicate
|
32
|
+
end
|
33
|
+
|
34
|
+
def matching(*reg_exps)
|
35
|
+
duplicate = self.dup.extend(MagicList)
|
36
|
+
keep_list = []
|
37
|
+
duplicate.each do |file|
|
38
|
+
reg_exps.each do |re|
|
39
|
+
re = fix(re) if re.kind_of? String
|
40
|
+
keep_list << file if file.match(re)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
reject_list = (duplicate - keep_list).flatten
|
44
|
+
duplicate.delete_these(reject_list)
|
45
|
+
end
|
46
|
+
|
47
|
+
protected
|
48
|
+
def delete_these(objs)
|
49
|
+
reject! do |obj|
|
50
|
+
a = false
|
51
|
+
objs.each do |del|
|
52
|
+
a = true if obj.include? del
|
53
|
+
end
|
54
|
+
a
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
def postfix_rb(str)
|
60
|
+
str << '.rb' if !str.include? '.rb'
|
61
|
+
end
|
62
|
+
|
63
|
+
def fix(str)
|
64
|
+
postfix_rb(str)
|
65
|
+
str = Regexp.escape(str)
|
66
|
+
str.gsub! '\*', '[a-zA-Z0-9\s_-]*'
|
67
|
+
str.gsub! '/', '\/'
|
68
|
+
str
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
end
|
data/lib/require-dsl.rb
CHANGED
@@ -1,182 +1,10 @@
|
|
1
1
|
require 'rake'
|
2
2
|
require 'fileutils'
|
3
3
|
require 'util/util'
|
4
|
+
|
5
|
+
require 'folder/folder'
|
4
6
|
|
5
|
-
module Folder
|
6
7
|
|
7
|
-
def self.enter(path = '.', &block)
|
8
|
-
m = Magic.new
|
9
|
-
m.enter path
|
10
|
-
if block_given?
|
11
|
-
yield m
|
12
|
-
end
|
13
|
-
m.exit
|
14
|
-
end
|
15
|
-
|
16
|
-
def self.enter_here(file, &block)
|
17
|
-
m = Magic.new
|
18
|
-
path = File.dirname(file)
|
19
|
-
m.enter path
|
20
|
-
if block_given?
|
21
|
-
yield m
|
22
|
-
end
|
23
|
-
m.exit
|
24
|
-
end
|
25
|
-
|
26
|
-
|
27
|
-
def self.require_all(*folders)
|
28
|
-
return Magic.new.all.dup.extend(MagicList).do_require if folders.empty?
|
29
|
-
folders.each do |folder|
|
30
|
-
enter folder do |f|
|
31
|
-
f.all.dup.extend(MagicList).do_require
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def self.show_require_all(*folders)
|
37
|
-
return Magic.new.all.dup.extend(MagicList).show_require if folders.empty?
|
38
|
-
folders.each do |folder|
|
39
|
-
enter folder do |f|
|
40
|
-
f.all.dup.extend(MagicList).show_require
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
|
46
|
-
def self.here(file)
|
47
|
-
FileUtils.cd File.dirname(file)
|
48
|
-
self
|
49
|
-
end
|
50
|
-
|
51
|
-
def self.require_me(*files)
|
52
|
-
return Magic.new.all(files).dup.extend(MagicList).do_require
|
53
|
-
end
|
54
|
-
|
55
|
-
module MagicList
|
56
|
-
attr_accessor :base_path
|
57
|
-
attr_accessor :rel_path
|
58
|
-
|
59
|
-
def do_require
|
60
|
-
each do |file|
|
61
|
-
require file
|
62
|
-
end
|
63
|
-
self
|
64
|
-
end
|
65
|
-
|
66
|
-
def show_require(*options)
|
67
|
-
each do |f|
|
68
|
-
if options.include? :relative
|
69
|
-
file_path = File.join(rel_path, f)
|
70
|
-
path = Require::Directory.relative_path(base_path, file_path)
|
71
|
-
end
|
72
|
-
path = File.join(base_path, f) if !options.include? :relative
|
73
|
-
path
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
|
78
|
-
def delete_these(objs)
|
79
|
-
reject! do |obj|
|
80
|
-
a = false
|
81
|
-
objs.each do |del|
|
82
|
-
a = true if obj.include? del
|
83
|
-
end
|
84
|
-
a
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
def except(*reg_exps)
|
89
|
-
duplicate = self.dup.extend(MagicList)
|
90
|
-
duplicate.each do |file|
|
91
|
-
reg_exps.each {|re| duplicate.delete(file) if file.match(re) }
|
92
|
-
end
|
93
|
-
duplicate
|
94
|
-
end
|
95
|
-
|
96
|
-
def postfix_rb(str)
|
97
|
-
str << '.rb' if !str.include? '.rb'
|
98
|
-
end
|
99
|
-
|
100
|
-
def fix(str)
|
101
|
-
postfix_rb(str)
|
102
|
-
str = Regexp.escape(str)
|
103
|
-
str.gsub! '\*', '[a-zA-Z0-9\s_-]*'
|
104
|
-
str.gsub! '/', '\/'
|
105
|
-
str
|
106
|
-
end
|
107
|
-
|
108
|
-
def matching(*reg_exps)
|
109
|
-
duplicate = self.dup.extend(MagicList)
|
110
|
-
keep_list = []
|
111
|
-
duplicate.each do |file|
|
112
|
-
reg_exps.each do |re|
|
113
|
-
re = fix(re) if re.kind_of? String
|
114
|
-
keep_list << file if file.match(re)
|
115
|
-
end
|
116
|
-
end
|
117
|
-
reject_list = (duplicate - keep_list).flatten
|
118
|
-
duplicate.delete_these(reject_list)
|
119
|
-
duplicate
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
|
-
class Magic
|
124
|
-
attr_accessor :current_path
|
125
|
-
attr_accessor :dir_stack
|
126
|
-
|
127
|
-
def initialize
|
128
|
-
@dir_stack = []
|
129
|
-
@current_path = FileUtils.pwd
|
130
|
-
end
|
131
|
-
|
132
|
-
def to_s
|
133
|
-
"path: #{current_path}, directory stack: #{dir_stack.inspect}"
|
134
|
-
end
|
135
|
-
|
136
|
-
def enter(dir)
|
137
|
-
path = FileUtils.pwd
|
138
|
-
dir_stack.push path
|
139
|
-
FileUtils.cd dir if !dir.empty?
|
140
|
-
@current_path = FileUtils.pwd
|
141
|
-
if block_given?
|
142
|
-
yield self
|
143
|
-
exit
|
144
|
-
end
|
145
|
-
self
|
146
|
-
end
|
147
|
-
|
148
|
-
def exit
|
149
|
-
current_path = dir_stack.last
|
150
|
-
old_dir = dir_stack.last
|
151
|
-
dir_stack.pop
|
152
|
-
FileUtils.cd old_dir if old_dir
|
153
|
-
end
|
154
|
-
|
155
|
-
|
156
|
-
def all(*globs)
|
157
|
-
globs = '**/*.rb' if globs.empty?
|
158
|
-
list = FileList.new(globs)
|
159
|
-
list.extend(MagicList)
|
160
|
-
list.base_path = dir_stack.first
|
161
|
-
list.rel_path = current_path
|
162
|
-
list.freeze
|
163
|
-
end
|
164
|
-
|
165
|
-
def require_all(*folders)
|
166
|
-
return all.dup.extend(MagicList).do_require if folders.empty?
|
167
|
-
folders.each do |folder|
|
168
|
-
enter folder do |f|
|
169
|
-
f.all.dup.extend(MagicList).do_require
|
170
|
-
end
|
171
|
-
end
|
172
|
-
end
|
173
|
-
|
174
|
-
def require_me(*files)
|
175
|
-
return all(files).dup.extend(MagicList).do_require
|
176
|
-
end
|
177
|
-
|
178
|
-
end
|
179
|
-
end
|
180
8
|
|
181
9
|
|
182
10
|
|
data/spec/blip.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
puts "Blip included"
|
data/spec/dsl/blap.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
puts "Blap included"
|
@@ -0,0 +1,94 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
describe "RequireMagic" do
|
4
|
+
it "Folder.enter works " do
|
5
|
+
Folder.enter '..' do
|
6
|
+
Folder.enter '../fixtures/game' do |folder|
|
7
|
+
# puts "Current 1:" + folder.current_path
|
8
|
+
end
|
9
|
+
Folder.enter('../fixtures/game') do |folder|
|
10
|
+
# puts "Current 2:" + folder.current_path
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
it "just works " do
|
16
|
+
Folder.enter '../../fixtures' do |folder| # oops!
|
17
|
+
folder.enter 'game' do |f|
|
18
|
+
list = f.all('**/*.rb')
|
19
|
+
l1 = list.matching( 'sound', 'network').except(/sound/)
|
20
|
+
|
21
|
+
# require fx 'game/network/network.rb'
|
22
|
+
l1.do_require(f.me)
|
23
|
+
|
24
|
+
l1_res = l1.show_require(:relative).inspect
|
25
|
+
l1_res.should include("network/network.rb")
|
26
|
+
|
27
|
+
l2 = list.matching( '*/sound', 'network').show_require(:relative).inspect
|
28
|
+
l2.should include("network/network.rb")
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
it "works with require_all " do
|
34
|
+
Folder.enter('../../fixtures/game') do |folder|
|
35
|
+
folder.require_all 'graphics', 'network', 'sound'
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
it "works with require_all and explicit :relative_to" do
|
40
|
+
Folder.enter('../../fixtures/game') do |folder|
|
41
|
+
folder.require_all 'graphics', 'network', 'sound', :relative_to => folder.me
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
it "works with require_all and require me" do
|
47
|
+
Folder.enter '..' do
|
48
|
+
Folder.enter '../fixtures/game' do |f|
|
49
|
+
f.require_all
|
50
|
+
f.require_me 'game.rb'
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
it "works with require_all " do
|
56
|
+
Folder.require_all '../../fixtures'
|
57
|
+
end
|
58
|
+
|
59
|
+
it "works with require_rel " do
|
60
|
+
Folder.require_spec 'blip', __FILE__
|
61
|
+
|
62
|
+
Folder.require_rel 'blap', __FILE__ , 'dsl'
|
63
|
+
|
64
|
+
Folder.require_rel 'spec/blip', __FILE__
|
65
|
+
Folder.require_rel 'blip', __FILE__ , 'spec'
|
66
|
+
|
67
|
+
# puts Folder.relative_path 'blip', __FILE__ , 'spec'
|
68
|
+
|
69
|
+
Folder.rel_base 'spec', __FILE__ do |f|
|
70
|
+
f.require_me 'blip'
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
|
75
|
+
it "works with base folder " do
|
76
|
+
Folder.enter '..' do
|
77
|
+
Folder.enter '../fixtures' do |folder|
|
78
|
+
# puts "Current 2:" + folder.current_path
|
79
|
+
folder.enter 'game' do |f|
|
80
|
+
f.relative_to_me # set implicit by default
|
81
|
+
|
82
|
+
f.require_all
|
83
|
+
list = f.all # ('**/*.rb')
|
84
|
+
l1 = list.matching( 'sound', 'network').except(/sound/).show_require(:relative).inspect
|
85
|
+
l1.should include("network/network.rb")
|
86
|
+
|
87
|
+
l2 = list.matching( '*/sound', 'network').show_require(:relative).inspect
|
88
|
+
l2.should include("network/network.rb")
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,7 +1,11 @@
|
|
1
|
-
|
2
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
3
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'spec'))
|
4
|
-
# require 'require-dsl'
|
5
|
-
require 'require-me'
|
1
|
+
require 'load-me'
|
6
2
|
require 'rspec'
|
7
3
|
require 'rspec/autorun'
|
4
|
+
require 'require-me'
|
5
|
+
|
6
|
+
# add fixtures to load path!
|
7
|
+
LoadPath.relative_to(__FILE__, '../')
|
8
|
+
LoadPath.add('fixtures')
|
9
|
+
|
10
|
+
|
11
|
+
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 0.
|
7
|
+
- 7
|
8
|
+
- 3
|
9
|
+
version: 0.7.3
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Kristian Mandrup
|
@@ -14,10 +14,39 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-05-29 00:00:00 -04:00
|
18
18
|
default_executable:
|
19
|
-
dependencies:
|
20
|
-
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: load-me
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 0
|
30
|
+
- 1
|
31
|
+
- 0
|
32
|
+
version: 0.1.0
|
33
|
+
type: :development
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: rspec
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
segments:
|
44
|
+
- 2
|
45
|
+
- 0
|
46
|
+
- 0
|
47
|
+
version: 2.0.0
|
48
|
+
type: :development
|
49
|
+
version_requirements: *id002
|
21
50
|
description: Lets you easily define how to include hierarchies of ruby files, and also apply inclusion/exclusion filters for what to include
|
22
51
|
email: kmandrup@gmail.com
|
23
52
|
executables: []
|
@@ -28,12 +57,24 @@ extra_rdoc_files:
|
|
28
57
|
- LICENSE
|
29
58
|
- README.markdown
|
30
59
|
files:
|
60
|
+
- lib/folder/folder.rb
|
61
|
+
- lib/folder/magic.rb
|
62
|
+
- lib/folder/magic_list.rb
|
31
63
|
- lib/playground.rb
|
32
64
|
- lib/require-dsl.rb
|
33
65
|
- lib/require-me.rb
|
34
66
|
- lib/util/util.rb
|
35
67
|
- LICENSE
|
36
68
|
- README.markdown
|
69
|
+
- spec/blip.rb
|
70
|
+
- spec/dsl/blap.rb
|
71
|
+
- spec/dsl/require-dsl_spec.rb
|
72
|
+
- spec/require_more_spec.rb
|
73
|
+
- spec/spec_helper.rb
|
74
|
+
- test/test_require_folder.rb
|
75
|
+
- test/test_require_folders.rb
|
76
|
+
- test/test_require_folders_adv.rb
|
77
|
+
- test/unit_test_require.rb
|
37
78
|
has_rdoc: true
|
38
79
|
homepage: http://github.com/kristianmandrup/require-magic
|
39
80
|
licenses: []
|
@@ -44,6 +85,7 @@ rdoc_options:
|
|
44
85
|
require_paths:
|
45
86
|
- lib
|
46
87
|
required_ruby_version: !ruby/object:Gem::Requirement
|
88
|
+
none: false
|
47
89
|
requirements:
|
48
90
|
- - ">="
|
49
91
|
- !ruby/object:Gem::Version
|
@@ -51,6 +93,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
51
93
|
- 0
|
52
94
|
version: "0"
|
53
95
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
|
+
none: false
|
54
97
|
requirements:
|
55
98
|
- - ">="
|
56
99
|
- !ruby/object:Gem::Version
|
@@ -60,12 +103,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
60
103
|
requirements: []
|
61
104
|
|
62
105
|
rubyforge_project:
|
63
|
-
rubygems_version: 1.3.
|
106
|
+
rubygems_version: 1.3.7
|
64
107
|
signing_key:
|
65
108
|
specification_version: 3
|
66
109
|
summary: Facilitates requiring select ruby files in folders
|
67
110
|
test_files:
|
68
|
-
- spec/
|
111
|
+
- spec/blip.rb
|
112
|
+
- spec/dsl/blap.rb
|
113
|
+
- spec/dsl/require-dsl_spec.rb
|
69
114
|
- spec/require_more_spec.rb
|
70
115
|
- spec/spec_helper.rb
|
71
116
|
- test/test_require_folder.rb
|
data/spec/require-dsl_spec.rb
DELETED
@@ -1,65 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
-
|
3
|
-
describe "RequireMagic" do
|
4
|
-
it "Folder.enter works " do
|
5
|
-
puts FileUtils.pwd
|
6
|
-
Folder.enter '../fixtures/game' do |folder|
|
7
|
-
# puts "Current 1:" + folder.current_path
|
8
|
-
end
|
9
|
-
Folder.enter('../fixtures/game') do |folder|
|
10
|
-
# puts "Current 2:" + folder.current_path
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
it "just works " do
|
15
|
-
Folder.enter '../fixtures' do |folder| # oops!
|
16
|
-
folder.enter 'game' do |f|
|
17
|
-
list = folder.all('**/*.rb')
|
18
|
-
l1 = list.matching( 'sound', 'network').except(/sound/).do_require
|
19
|
-
l1_res = l1.show_require(:relative).inspect
|
20
|
-
l1_res.should include("network/network.rb")
|
21
|
-
|
22
|
-
l2 = list.matching( '*/sound', 'network').show_require(:relative).inspect
|
23
|
-
l2.should include("network/network.rb")
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
it "works with require_all " do
|
29
|
-
Folder.enter('../fixtures/game') do |folder|
|
30
|
-
# puts "Current 1:" + folder.current_path
|
31
|
-
folder.require_all 'graphics', 'network', 'sound'
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
it "works with require_all " do
|
36
|
-
Folder.require_me '../fixtures/game/game.rb'
|
37
|
-
|
38
|
-
Folder.enter '../fixtures/game' do |f|
|
39
|
-
f.require_all
|
40
|
-
f.require_me 'game.rb'
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
it "works with require_all " do
|
45
|
-
Folder.require_all '../fixtures'
|
46
|
-
end
|
47
|
-
|
48
|
-
|
49
|
-
it "works with base folder " do
|
50
|
-
Folder.enter '../fixtures' do |folder|
|
51
|
-
# puts "Current 2:" + folder.current_path
|
52
|
-
folder.enter 'game' do |f|
|
53
|
-
# puts f
|
54
|
-
f.require_all
|
55
|
-
list = f.all # ('**/*.rb')
|
56
|
-
l1 = list.matching( 'sound', 'network').except(/sound/).show_require(:relative).inspect
|
57
|
-
l1.should include("network/network.rb")
|
58
|
-
|
59
|
-
l2 = list.matching( '*/sound', 'network').show_require(:relative).inspect
|
60
|
-
l2.should include("network/network.rb")
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
end
|