require-me 0.5.5

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Kristian Mandrup
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.markdown ADDED
@@ -0,0 +1,175 @@
1
+ # Require-Me ##
2
+
3
+ Includes a DSL for requiring files and folders and some also some static utility functions which can be used in combination.
4
+ These tools in combination facilitates managing requiring various subfolder structures.
5
+ FIXED
6
+
7
+ ## Require DSL ##
8
+
9
+ The following example code demonstrates how to use the Require DSL
10
+
11
+ <pre>
12
+ require 'require-dsl' # to include the Require DSL language only
13
+
14
+ Folder.enter 'mira' do |folder| # enter subfolder 'mira'
15
+ `# from new location, enter a subdir`
16
+ folder.enter 'subdir' do |path| # mira/subdir
17
+ folder.all('**/*.rb').except(/sound\/*.rb/).require
18
+ end
19
+
20
+ folder.enter 'another/subdir' do |path|
21
+ folder.all('**/*.rb').require # use file blobs here
22
+ end
23
+
24
+ folder.enter 'a_subdir' do |path|
25
+ `# matching and except are to be used as include and exclude filters
26
+ # they each take a list containing regular expressions and strings
27
+ # string arguments are postfixed with .rb internally if not present`
28
+ folder.all('blip/**/*.rb').matching(/_mixin.rb/, /.*\/power/).except(/sound/, /disco/).require
29
+
30
+ folder.enter 'sub_a' do |path|
31
+ folder.enter 'sub_b' do |path| # a_subdir/sub_a/sub_b
32
+ folder.all('grusch/**/*.rb').require
33
+ end
34
+
35
+ end
36
+ folder.all.require
37
+ end
38
+ end
39
+ </pre>
40
+
41
+ If no argument, current path is used as initial folder
42
+
43
+ <pre>
44
+ require 'require-me' # include both the static require helpers and the DSL require language
45
+
46
+ Folder.enter do |folder| # use current path as folder
47
+ folder.all('**/*.rb').require
48
+ folder.enter 'game' do |path|
49
+
50
+ `# use static require functions`
51
+ Require.base_path path # set base path to use for Require
52
+
53
+ `# include .rb files within data1, data2 but not within their subfolders (use recursive instead)`
54
+ Require.folders('data1', 'data2')
55
+
56
+ list = path.all('**/*.rb')
57
+ puts list.matching('sound', 'network').except(/sound/).show_require(:relative)
58
+ list.matching('sound', 'network').except(/sound/).require
59
+ end
60
+ end
61
+ </pre>
62
+
63
+ ## Static helpers ##
64
+
65
+ Unit tests demonstrations how to use the static helpers (tests currently broken due to missing data files!):
66
+
67
+ ### Setting the base path ##
68
+
69
+ Setting global base_path
70
+ <pre>
71
+ Require.base_path = File.dirname(__FILE__)
72
+ </pre>
73
+
74
+ Set basepath to use within block
75
+ <pre>
76
+ Require.enter 'sound' do |path|
77
+ Require.folders 'data' # can be used for any number of folders
78
+ Require.folder 'data2' # for one folder only
79
+ end
80
+ </pre>
81
+
82
+ #### Override base_path ##
83
+
84
+ <pre>
85
+ Require.folders 'data', {:base_path => File.dirname(__FILE__) + '/../my/path}
86
+ </pre>
87
+
88
+ Simple usage examples
89
+ Require .rb files from a folder
90
+ <pre>
91
+ Require.folders 'data', 'data2'
92
+ Require.recursive 'data', 'data2' # recursively require all in subtrees
93
+ </pre>
94
+
95
+ ### Simple debugging ##
96
+
97
+ Get list of required files and print them
98
+ <pre>
99
+ required_files = Require.folder 'data'
100
+ puts required_files
101
+ </pre>
102
+
103
+ ### Tracing mode (for debugging) ##
104
+
105
+ Apply tracing to see output for the process of requiring the files
106
+ <pre>
107
+ Require.tracing = :on # turn on tracing globally
108
+ Require.folder 'data'
109
+ Require.tracing = :off # turn off tracing globally
110
+ </pre>
111
+
112
+ Alternatively pass tracing as an option
113
+
114
+ <pre>
115
+ Require.folder 'data', {:tracing => :on}
116
+ </pre>
117
+
118
+ ### Verbose mode (for detailed debugging) ##
119
+
120
+ Set verbose mode on to see full path of each required file
121
+ <pre>
122
+ Require.tracing = :on # turn on tracing
123
+ Require.verbose = :on # turn on verbose globally
124
+ Require.folder 'data'
125
+ Require.verbose = :off # turn off verbose globally
126
+ </pre>
127
+
128
+ ### Require.recursive ##
129
+
130
+ Require all files within the top level folder 'data' recursively
131
+ <pre>
132
+ required_files = Require.recursive 'data'
133
+ </pre>
134
+
135
+ Require all files within the top level folders 'data' and 'data2' (non-recursively)
136
+ <pre>
137
+ required_files = Require.recursive 'data', 'data2'
138
+ </pre>
139
+
140
+ Require all files within the top level folders 'data' and 'data2' recursively
141
+ <pre>
142
+ required_files = Require.recursive 'data', 'data2'
143
+ </pre>
144
+
145
+ ### Require.folders ##
146
+
147
+ Require files within the top level folders 'data' and 'data2' and also files within the subdirectory 'blip' if it exists
148
+ <pre>
149
+ required_files = Require.folders 'data', 'data2', {:folders => 'blip'}
150
+ </pre>
151
+
152
+ Require files within 'data/blip' and 'data2/blip' only, NOT including the root files
153
+ <pre>
154
+ required_files = Require.folders 'data', 'data2', {:folders => 'blip', :ignore_root_files => true}
155
+ </pre>
156
+
157
+ Require files within 'data' and 'data2' first and then AFTER any files within the subdirectory 'blip' (default order)
158
+ <pre>
159
+ required_files = Require.folders 'data', 'data2', {:folders => 'blip', :root_files => :before}
160
+ </pre>
161
+
162
+ Require files within 'data/blip' and 'data2/blip' first and then AFTER any files within 'data' and 'data2' folders (the root files)
163
+ <pre>
164
+ required_files = Require.folders(['data', 'data2'], {:folders => 'blip', :root_files => :after})
165
+ </pre>
166
+
167
+ Require files within 'data' and 'data2' (the root files) first (BEFORE) and then any files within the subdirectories 'blip' and 'blap'
168
+ <pre>
169
+ required_files = Require.folders(['data', 'data2'], {:folders => ['blip', 'blap'], :root_files => :before})
170
+ </pre>
171
+
172
+
173
+ ## Copyright
174
+
175
+ Copyright (c) 2010 Kristian Mandrup. See LICENSE for details.
@@ -0,0 +1,119 @@
1
+ require 'rake'
2
+ require 'fileutils'
3
+ require 'util/util'
4
+
5
+ module Folder
6
+
7
+ def self.enter(path = '.', &block)
8
+ m = Magic.new
9
+ m.enter path
10
+ yield m
11
+ m.dir_stack.pop
12
+ end
13
+
14
+ module MagicList
15
+ attr_accessor :base_path
16
+ attr_accessor :rel_path
17
+
18
+ def do_require
19
+ each do |file|
20
+ require file
21
+ end
22
+ self
23
+ end
24
+
25
+ def show_require(*options)
26
+ each do |f|
27
+ if options.include? :relative
28
+ file_path = File.join(rel_path, f)
29
+ path = Require::Dir.relative_path(base_path, file_path)
30
+ end
31
+ path = File.join(base_path, f) if !options.include? :relative
32
+ path
33
+ end
34
+ end
35
+
36
+
37
+ def delete_these(objs)
38
+ reject! do |obj|
39
+ a = false
40
+ objs.each do |del|
41
+ a = true if obj.include? del
42
+ end
43
+ a
44
+ end
45
+ end
46
+
47
+ def except(*reg_exps)
48
+ duplicate = self.dup.extend(MagicList)
49
+ duplicate.each do |file|
50
+ reg_exps.each {|re| duplicate.delete(file) if file.match(re) }
51
+ end
52
+ duplicate
53
+ end
54
+
55
+ def postfix_rb(str)
56
+ str << '.rb' if !str.include? '.rb'
57
+ end
58
+
59
+ def fix(str)
60
+ postfix_rb(str)
61
+ str = Regexp.escape(str)
62
+ str.gsub! '\*', '[a-zA-Z0-9\s_-]*'
63
+ str.gsub! '/', '\/'
64
+ str
65
+ end
66
+
67
+ def matching(*reg_exps)
68
+ duplicate = self.dup.extend(MagicList)
69
+ keep_list = []
70
+ duplicate.each do |file|
71
+ reg_exps.each do |re|
72
+ re = fix(re) if re.kind_of? String
73
+ keep_list << file if file.match(re)
74
+ end
75
+ end
76
+ reject_list = (duplicate - keep_list).flatten
77
+ duplicate.delete_these(reject_list)
78
+ duplicate
79
+ end
80
+ end
81
+
82
+ class Magic
83
+ attr_accessor :current_path
84
+ attr_accessor :dir_stack
85
+
86
+ def initialize
87
+ @dir_stack = []
88
+ @current_path = FileUtils.pwd
89
+ end
90
+
91
+ def enter(dir)
92
+ FileUtils.cd dir
93
+ dir_stack.push path = FileUtils.pwd
94
+ @current_path = path
95
+ if block_given?
96
+ yield path
97
+ current_path = dir_stack.last
98
+ old_dir = dir_stack.last if dir_stack.pop
99
+ FileUtils.cd old_dir if old_dir
100
+ end
101
+ path
102
+ end
103
+
104
+ def all(*globs)
105
+ globs = '**/*.rb' if globs.empty?
106
+ list = FileList.new(globs)
107
+ list.extend(MagicList)
108
+ list.base_path = dir_stack.first
109
+ list.rel_path = current_path
110
+ list.freeze
111
+ end
112
+
113
+ end
114
+ end
115
+
116
+
117
+
118
+
119
+
data/lib/require-me.rb ADDED
@@ -0,0 +1,143 @@
1
+ require 'require-dsl'
2
+
3
+ module Require
4
+
5
+ class << self
6
+ attr_accessor :base_path
7
+ attr_accessor :tracing
8
+ attr_accessor :verbose
9
+ end
10
+
11
+ def self.recursive(*names, options, &block)
12
+ options = {} if !options
13
+ options[:recursive] = true
14
+ names.each{|name| folder(name, options) }
15
+ end
16
+
17
+ def self.folders(*names, options)
18
+ options = {} if !options
19
+ required_files = []
20
+ names.each do |path|
21
+ options[:root] = path if is_root?(path, options)
22
+ required_files << folder(path, options)
23
+ end
24
+ required_files.flatten
25
+ end
26
+
27
+ def self.enter(name, options = {}, &block)
28
+ options[:recursive] = true
29
+ file = folder(name, options)
30
+ base_path = File.dirname(file)
31
+ yield base_path
32
+ end
33
+
34
+
35
+ def self.folder(name, options = {})
36
+ recursive = options[:recursive]
37
+ folder_list = options[:folders]
38
+ file_pattern = recursive ? "#{name}/**/*.rb" : "#{name}/*.rb"
39
+
40
+ base_dir = File.dirname(__FILE__)
41
+
42
+ curr_base_path = options[:base_path] || base_path || base_dir
43
+
44
+ # puts "base_path: #{curr_base_path}, base_dir:#{base_dir}, :base_path #{base_path}"
45
+
46
+ path = File.join(curr_base_path, file_pattern)
47
+ required_files = []
48
+
49
+ puts_trace "folder:: name: #{name}", options
50
+
51
+ if !options[:root_files] || options[:root_files] == :before
52
+ required_files << require_root_files(name, folder_list, path, options)
53
+ # options[:root] = false
54
+ required_files << require_folder_list(name, folder_list, options)
55
+ else
56
+ required_files << require_folder_list(name, folder_list, options)
57
+ required_files << require_root_files(name, folder_list, path, options)
58
+ # options[:root] = false
59
+ end
60
+ required_files.flatten
61
+ end
62
+
63
+ protected
64
+ def self.puts_trace(txt, options)
65
+ puts txt if tracing?(options)
66
+ end
67
+
68
+ def self.tracing?(options)
69
+ tracing == :on || options[:tracing] == :on
70
+ end
71
+
72
+ def self.is_root?(path, options)
73
+ root = options[:root]
74
+ root == nil || (root && path.size < root.size)
75
+ end
76
+
77
+ def self.require_root_files(name, folder_list, path, options)
78
+ puts_trace "require_root_files:: name: #{name}, folders: #{folder_list.inspect}, path: #{path}", options
79
+ required_files = []
80
+ i_am_root = options[:root] == name
81
+ if options[:ignore_root_files] && i_am_root
82
+ options.delete :ignore_root_files
83
+ else
84
+ includes_rexp = options[:include]
85
+ excludes_rexp = options[:exclude]
86
+
87
+ Dir.glob(path).each {|f|
88
+ next if excludes_rexp && match(f, excludes_rexp)
89
+ if !includes_rexp || match(f, includes_rexp)
90
+ puts_trace "require: #{f}", options
91
+ required_files << do_require(f)
92
+ end
93
+ }
94
+ end
95
+
96
+ required_files.flatten
97
+ end
98
+
99
+ def self.require_folder_list(name, folder_list, options)
100
+ puts_trace "require_folder_list:: name: #{name}, folders: #{folder_list.inspect}", options
101
+ required_files = []
102
+ if folder_list
103
+ # options.delete :ignore_root_files
104
+ options.delete :folders
105
+
106
+ folder_list.each do |folder|
107
+ sub_folder = File.join(name, folder)
108
+ required_files << folders(sub_folder, options)
109
+ end
110
+ end
111
+ required_files.flatten
112
+ end
113
+
114
+ def self.do_require(name)
115
+ require name
116
+ list_name name
117
+ end
118
+
119
+ def self.list_name(name)
120
+ if base_path && !(verbose == :on)
121
+ name.gsub(/#{Regexp.escape(base_path)}/, '')
122
+ else
123
+ name
124
+ end
125
+ end
126
+
127
+ def self.match(f, *rexp)
128
+ rexp.each{|e| return true if match_single(f, rexp)}
129
+ false
130
+ end
131
+
132
+ def self.match_single(f, rexp)
133
+ if rexp.kind_of? String
134
+ str = Regexp.escape(str)
135
+ str.gsub! '\*', '[a-zA-Z0-9\s_-]*'
136
+ str.gsub! '/', '\/'
137
+ end
138
+ if rexp.kind_of? Regexp
139
+ return f.match(re)
140
+ end
141
+ false
142
+ end
143
+ end
data/lib/util/util.rb ADDED
@@ -0,0 +1,13 @@
1
+ require 'pathname'
2
+
3
+ module Require
4
+ module Dir
5
+ def self.relative_path(base_path, path)
6
+ path.gsub! /#{Regexp.escape base_path}/
7
+ p1 = Pathname.new base_path
8
+ p2 = p1 + path
9
+ p4 = p2.relative_path_from(p1) # Pathname:lib/ruby/1.8
10
+ end
11
+ end
12
+ end
13
+
@@ -0,0 +1 @@
1
+ puts "Game was included"
@@ -0,0 +1 @@
1
+ puts "Graphics was included"
@@ -0,0 +1 @@
1
+ puts "Network was included"
@@ -0,0 +1 @@
1
+ puts "Sound was included"
@@ -0,0 +1,33 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "RequireMagic" do
4
+ it "works" do
5
+ Folder.enter '../spec/fixtures' do |folder|
6
+ folder.enter 'game' do |path|
7
+ list = folder.all('**/*.rb')
8
+ l1 = list.matching( 'sound', 'network').except(/sound/).do_require
9
+ l1_res = l1.show_require(:relative).inspect
10
+ l1_res.should include("network/network.rb")
11
+
12
+ l2 = list.matching( '*/sound', 'network').show_require(:relative).inspect
13
+ l2.should include("network/network.rb")
14
+ end
15
+ end
16
+ end
17
+
18
+ it "works with base folder " do
19
+ Folder.enter do |folder|
20
+ puts folder.current_path
21
+ folder.enter 'game' do |path|
22
+ list = folder.all # ('**/*.rb')
23
+ l1 = list.matching( 'sound', 'network').except(/sound/).show_require(:relative).inspect
24
+ l1.should include("network/network.rb")
25
+
26
+ l2 = list.matching( '*/sound', 'network').show_require(:relative).inspect
27
+ l2.should include("network/network.rb")
28
+ end
29
+ end
30
+ end
31
+
32
+
33
+ end
@@ -0,0 +1,6 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+ # require 'require-dsl'
4
+ require 'require-me'
5
+ require 'rspec'
6
+ require 'rspec/autorun'
@@ -0,0 +1,55 @@
1
+ require 'require-magic'
2
+ require "unit_test_require"
3
+
4
+ class TestRequireFolder < UnitTestRequire
5
+
6
+ def test_require_folder
7
+ required_files = Require.folder(@folder)
8
+
9
+ found0 = match? required_files[0], 'data_a.rb'
10
+
11
+ assert_equal 1, required_files.size, "Should require 1 file"
12
+ assert found0, "Should require data_a.rb in /"
13
+
14
+ end
15
+
16
+ def test_require_folder_recursive
17
+ required_files = Require.rfolder(@folder)
18
+ assert_equal 4, required_files.size, "Should require 4 files"
19
+ end
20
+
21
+ def test_require_folder_recursive_include
22
+ options = {:include => '_a'}
23
+ required_files = Require.folder(@folder, options)
24
+ assert_equal 1, required_files.size, "Should require 1 file"
25
+ end
26
+
27
+ def test_require_folder_recursive_include_base_path
28
+ options = {:include => '_a'}
29
+ Require.base_path = File.dirname(__FILE__) + "/../lib"
30
+ required_files = Require.folder(@folder, options)
31
+
32
+ assert_equal 1, required_files.size, "Should require 1 file"
33
+ assert_equal "/data/data_a.rb", required_files[0], "Path of required files should be from base_path when verbose not :on"
34
+ end
35
+
36
+
37
+ def test_require_folders_recursive_exclude_base_path
38
+ options = {:exclude => '_a'}
39
+ required_files = Require.folder(@folder, options)
40
+ assert_equal 0, required_files.size, "Should require 0 files"
41
+ end
42
+
43
+ def test_require_folder_recursive_default_base_path_override
44
+ options = {:folders => ['blip'], :base_path => File.dirname(__FILE__) + "/../lib"}
45
+ required_files = Require.folder(@folder, options)
46
+
47
+ assert_equal 3, required_files.size, "Should require 3 files"
48
+
49
+ found0 = match? required_files[0], 'data_a.rb'
50
+ assert found0, "Should require root files such as 'data_a.rb' first"
51
+ end
52
+
53
+
54
+ end
55
+
@@ -0,0 +1,46 @@
1
+ require 'require-magic'
2
+ require "unit_test_require"
3
+
4
+ class TestRequireFolders < UnitTestRequire
5
+
6
+ def test_require_folders
7
+ required_files = Require.folders(@folders)
8
+
9
+ found0 = match? required_files[0], 'data_a.rb'
10
+ found1 = match? required_files[1], 'data2/blap_a.rb'
11
+
12
+ assert_equal 2, required_files.size, "Should require 2 files"
13
+ assert found0, "Should require data_a.rb in /"
14
+ assert found1, "Should require blap_a.rb in /data"
15
+ end
16
+
17
+ def test_require_folders_recursive
18
+ options = {:recursive => true}
19
+ required_files = Require.folders(@folders, options)
20
+ assert_equal 5, required_files.size, "Should require 5 files"
21
+ end
22
+
23
+ def test_require_folders_recursive_include
24
+ options = {:recursive => true, :include => 'blip_'}
25
+ required_files = Require.folders(@folders, options)
26
+ assert_equal 2, required_files.size, "Should require 2 files"
27
+ end
28
+
29
+ def test_require_folders_recursive_exclude
30
+ options = {:recursive => true, :exclude => 'blip_'}
31
+ required_files = Require.folders(@folders, options)
32
+ assert_equal 3, required_files.size, "Should require 3 file"
33
+ end
34
+
35
+ def test_require_folders_recursive_default
36
+ options = {:folders => ['blip']}
37
+ required_files = Require.folders(@folders, options)
38
+ assert_equal 4, required_files.size, "Should require 4 files"
39
+
40
+ found0 = match? required_files[0], 'data_a.rb'
41
+ assert found0, "Should require root files such as 'data_a.rb' first"
42
+ end
43
+
44
+
45
+ end
46
+
@@ -0,0 +1,54 @@
1
+ require 'require-magic'
2
+ require "unit_test_require"
3
+
4
+ class TestRequireFoldersAdv < UnitTestRequire
5
+
6
+ def test_require_folders_recursive
7
+ options = {:folders => ['blip'], :ignore_root_files => true}
8
+ required_files = Require.folders(@folders, options)
9
+ assert_equal 3, required_files.size, "Should require 3 files"
10
+ end
11
+
12
+ def test_require_folders_root_folders_before
13
+ options = {:folders => ['blip'], :root_files => :before}
14
+ required_files = Require.folders(@folders, options)
15
+ assert_equal 4, required_files.size, "Should require 4 files"
16
+
17
+ root_first = match?(required_files[0], 'data_a.rb')
18
+ assert root_first, "First required file should be root file 'data_a.rb'"
19
+ end
20
+
21
+ def test_require_folders_root_folders_after
22
+ options = {:folders => ['blip'], :root_files => :after}
23
+ required_files = Require.folders(@folders, options)
24
+ assert_equal 4, required_files.size, "Should require 4 files"
25
+
26
+ root_last = match?(required_files[2], 'data_a.rb')
27
+ assert root_last, "Last required file of 'data' should be root file 'data_a.rb'"
28
+ end
29
+
30
+ def test_require_folders_root_folders_before_but_ignore
31
+ options = {:folders => ['blip'], :root_files => :before, :ignore_root_files => true}
32
+ required_files = Require.folders(@folders, options)
33
+
34
+ assert_equal 3, required_files.size, "Should require 3 files"
35
+ end
36
+
37
+ def test_require_folders_root_folders_after_but_ignore
38
+ options = {:folders => ['blip'], :root_files => :after, :ignore_root_files => true}
39
+ required_files = Require.folders(@folders, options)
40
+ assert_equal 3, required_files.size, "Should require 3 files"
41
+ end
42
+
43
+ def test_require_folders_recursive_data_root_folders_after
44
+ options = {:folders => ['blip'], :root_files => :after}
45
+ required_files = Require.folders('data', options)
46
+ assert_equal 3, required_files.size, "Should require 3 files"
47
+
48
+ root_last = match?(required_files[2], 'data_a.rb')
49
+
50
+ assert root_last, "Last required file should be root file 'data_a.rb'"
51
+ end
52
+
53
+
54
+ end
@@ -0,0 +1,17 @@
1
+ require "test/unit"
2
+
3
+ class UnitTestRequire < Test::Unit::TestCase
4
+
5
+ def setup
6
+ @folders = ['data', 'data2']
7
+ @folder = 'data'
8
+ end
9
+
10
+ def match?(expr, rexp)
11
+ !(expr =~ /#{Regexp.escape(rexp)}/).nil?
12
+ end
13
+
14
+ def test_me
15
+ assert true, "true"
16
+ end
17
+ end
metadata ADDED
@@ -0,0 +1,69 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: require-me
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.5.5
5
+ platform: ruby
6
+ authors:
7
+ - Kristian Mandrup
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2010-03-03 00:00:00 -04:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: Lets you easily define how to include hierarchies of ruby files, and also apply inclusion/exclusion filters for what to include
17
+ email: kmandrup@gmail.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - LICENSE
24
+ - README.markdown
25
+ files:
26
+ - lib/require-dsl.rb
27
+ - lib/require-me.rb
28
+ - lib/util/util.rb
29
+ - LICENSE
30
+ - README.markdown
31
+ has_rdoc: true
32
+ homepage: http://github.com/kristianmandrup/require-magic
33
+ licenses: []
34
+
35
+ post_install_message:
36
+ rdoc_options:
37
+ - --charset=UTF-8
38
+ require_paths:
39
+ - lib
40
+ required_ruby_version: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: "0"
45
+ version:
46
+ required_rubygems_version: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: "0"
51
+ version:
52
+ requirements: []
53
+
54
+ rubyforge_project:
55
+ rubygems_version: 1.3.5
56
+ signing_key:
57
+ specification_version: 3
58
+ summary: Facilitates requiring select ruby files in folders
59
+ test_files:
60
+ - spec/fixtures/game/game.rb
61
+ - spec/fixtures/game/graphics/graphics.rb
62
+ - spec/fixtures/game/network/network.rb
63
+ - spec/fixtures/game/sound/sound.rb
64
+ - spec/require-dsl_spec.rb
65
+ - spec/spec_helper.rb
66
+ - test/test_require_folder.rb
67
+ - test/test_require_folders.rb
68
+ - test/test_require_folders_adv.rb
69
+ - test/unit_test_require.rb