require-me 0.5.5 → 0.5.6

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -14,26 +14,26 @@ require 'require-dsl' # to include the Require DSL language only
14
14
  Folder.enter 'mira' do |folder| # enter subfolder 'mira'
15
15
  `# from new location, enter a subdir`
16
16
  folder.enter 'subdir' do |path| # mira/subdir
17
- folder.all('**/*.rb').except(/sound\/*.rb/).require
17
+ folder.all('**/*.rb').except(/sound\/*.rb/).do_require
18
18
  end
19
19
 
20
20
  folder.enter 'another/subdir' do |path|
21
- folder.all('**/*.rb').require # use file blobs here
21
+ folder.all('**/*.rb').do_require # use file blobs here
22
22
  end
23
23
 
24
24
  folder.enter 'a_subdir' do |path|
25
25
  `# matching and except are to be used as include and exclude filters
26
26
  # they each take a list containing regular expressions and strings
27
27
  # string arguments are postfixed with .rb internally if not present`
28
- folder.all('blip/**/*.rb').matching(/_mixin.rb/, /.*\/power/).except(/sound/, /disco/).require
28
+ folder.all('blip/**/*.rb').matching(/_mixin.rb/, /.*\/power/).except(/sound/, /disco/).do_require
29
29
 
30
30
  folder.enter 'sub_a' do |path|
31
31
  folder.enter 'sub_b' do |path| # a_subdir/sub_a/sub_b
32
- folder.all('grusch/**/*.rb').require
32
+ folder.all('grusch/**/*.rb').do_require
33
33
  end
34
34
 
35
35
  end
36
- folder.all.require
36
+ folder.all.do_require
37
37
  end
38
38
  end
39
39
  </pre>
@@ -44,8 +44,8 @@ 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.all('**/*.rb').require
48
- folder.enter 'game' do |path|
47
+ folder.enter 'game' do |f|
48
+ folder.require_all # require all .rb files within this folder!
49
49
 
50
50
  `# use static require functions`
51
51
  Require.base_path path # set base path to use for Require
@@ -55,7 +55,7 @@ Folder.enter do |folder| # use current path as folder
55
55
 
56
56
  list = path.all('**/*.rb')
57
57
  puts list.matching('sound', 'network').except(/sound/).show_require(:relative)
58
- list.matching('sound', 'network').except(/sound/).require
58
+ list.matching('sound', 'network').except(/sound/).do_require
59
59
  end
60
60
  end
61
61
  </pre>
data/lib/require-dsl.rb CHANGED
@@ -93,12 +93,12 @@ module Folder
93
93
  dir_stack.push path = FileUtils.pwd
94
94
  @current_path = path
95
95
  if block_given?
96
- yield path
96
+ yield self
97
97
  current_path = dir_stack.last
98
98
  old_dir = dir_stack.last if dir_stack.pop
99
99
  FileUtils.cd old_dir if old_dir
100
100
  end
101
- path
101
+ self
102
102
  end
103
103
 
104
104
  def all(*globs)
@@ -109,6 +109,10 @@ module Folder
109
109
  list.rel_path = current_path
110
110
  list.freeze
111
111
  end
112
+
113
+ def require_all
114
+ all.dup.extend(MagicList).do_require
115
+ end
112
116
 
113
117
  end
114
118
  end
@@ -3,7 +3,8 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
3
3
  describe "RequireMagic" do
4
4
  it "works" do
5
5
  Folder.enter '../spec/fixtures' do |folder|
6
- folder.enter 'game' do |path|
6
+ folder.enter 'game' do |f|
7
+ puts f
7
8
  list = folder.all('**/*.rb')
8
9
  l1 = list.matching( 'sound', 'network').except(/sound/).do_require
9
10
  l1_res = l1.show_require(:relative).inspect
@@ -18,13 +19,18 @@ describe "RequireMagic" do
18
19
  it "works with base folder " do
19
20
  Folder.enter do |folder|
20
21
  puts folder.current_path
21
- folder.enter 'game' do |path|
22
- list = folder.all # ('**/*.rb')
22
+ folder.enter 'game' do |f|
23
+ puts f
24
+ f.require_all
25
+ list = f.all # ('**/*.rb')
23
26
  l1 = list.matching( 'sound', 'network').except(/sound/).show_require(:relative).inspect
24
27
  l1.should include("network/network.rb")
25
28
 
26
29
  l2 = list.matching( '*/sound', 'network').show_require(:relative).inspect
27
30
  l2.should include("network/network.rb")
31
+
32
+
33
+
28
34
  end
29
35
  end
30
36
  end
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.5.5
4
+ version: 0.5.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kristian Mandrup
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-03-03 00:00:00 -04:00
12
+ date: 2010-03-05 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies: []
15
15