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 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| # enter doesn't work with special folders '.' and '..' yet
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
- puts "Path:#{path}"
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
- puts "Path:#{path}"
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
- puts "cd #{dir}"
93
+ def enter(dir)
94
+ path = FileUtils.pwd
95
+ dir_stack.push path
99
96
  FileUtils.cd dir if !dir.empty?
100
- dir_stack.push path = FileUtils.pwd
101
- @current_path = path
97
+ @current_path = FileUtils.pwd
102
98
  if block_given?
103
99
  yield self
104
- exit(dir)
100
+ exit
105
101
  end
106
102
  self
107
103
  end
108
104
 
109
- def exit(dir)
105
+ def exit
110
106
  current_path = dir_stack.last
111
- old_dir = dir_stack.last if dir_stack.pop
112
- puts "cd .."
113
- # FileUtils.cd old_dir if old_dir
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
 
@@ -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
- # f.require_all 'graphics', 'network', 'sound'
32
+ folder.require_all 'graphics', 'network', 'sound'
33
33
  end
34
34
  end
35
35
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: require-me
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kristian Mandrup