require-me 0.6.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +1 -1
- data/lib/require-dsl.rb +12 -17
- data/spec/require-dsl_spec.rb +1 -1
- metadata +1 -1
data/README.markdown
CHANGED
@@ -44,7 +44,7 @@ If no argument, current path is used as initial folder
|
|
44
44
|
require 'require-me' # include both the static require helpers and the DSL require language
|
45
45
|
|
46
46
|
Folder.enter do |folder| # use current path as folder
|
47
|
-
folder.enter 'game' do |f|
|
47
|
+
folder.enter 'game' do |f|
|
48
48
|
folder.require_all # require all .rb files within this folder!
|
49
49
|
|
50
50
|
`# use static require functions`
|
data/lib/require-dsl.rb
CHANGED
@@ -6,15 +6,11 @@ module Folder
|
|
6
6
|
|
7
7
|
def self.enter(path = '.', &block)
|
8
8
|
m = Magic.new
|
9
|
-
|
10
|
-
paths = path.split('/')
|
11
|
-
puts paths
|
12
|
-
paths.each{|p| m.enter p}
|
9
|
+
m.enter path
|
13
10
|
if block_given?
|
14
11
|
yield m
|
15
|
-
end
|
16
|
-
|
17
|
-
path.split('/').each{|p| m.exit p }
|
12
|
+
end
|
13
|
+
m.exit
|
18
14
|
end
|
19
15
|
|
20
16
|
module MagicList
|
@@ -94,24 +90,23 @@ module Folder
|
|
94
90
|
@current_path = FileUtils.pwd
|
95
91
|
end
|
96
92
|
|
97
|
-
def enter(dir)
|
98
|
-
|
93
|
+
def enter(dir)
|
94
|
+
path = FileUtils.pwd
|
95
|
+
dir_stack.push path
|
99
96
|
FileUtils.cd dir if !dir.empty?
|
100
|
-
|
101
|
-
@current_path = path
|
97
|
+
@current_path = FileUtils.pwd
|
102
98
|
if block_given?
|
103
99
|
yield self
|
104
|
-
exit
|
100
|
+
exit
|
105
101
|
end
|
106
102
|
self
|
107
103
|
end
|
108
104
|
|
109
|
-
def exit
|
105
|
+
def exit
|
110
106
|
current_path = dir_stack.last
|
111
|
-
old_dir = dir_stack.last
|
112
|
-
|
113
|
-
|
114
|
-
FileUtils.cd '..'
|
107
|
+
old_dir = dir_stack.last
|
108
|
+
dir_stack.pop
|
109
|
+
FileUtils.cd old_dir if old_dir
|
115
110
|
end
|
116
111
|
|
117
112
|
|
data/spec/require-dsl_spec.rb
CHANGED
@@ -29,7 +29,7 @@ describe "RequireMagic" do
|
|
29
29
|
it "works with require_all " do
|
30
30
|
Folder.enter('fixtures/game') do |folder|
|
31
31
|
puts "Current 1:" + folder.current_path
|
32
|
-
|
32
|
+
folder.require_all 'graphics', 'network', 'sound'
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|