requirer 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.coveralls.yml +1 -0
- data/.gitignore +14 -0
- data/.travis.yml +17 -0
- data/Gemfile +4 -0
- data/Guardfile +11 -0
- data/LICENSE.txt +22 -0
- data/README.md +33 -0
- data/Rakefile +7 -0
- data/lib/requirer.rb +62 -0
- data/lib/requirer/version.rb +3 -0
- data/requirer.gemspec +31 -0
- data/spec/dirs_to_require/dir_depth_1/depth1.rb +1 -0
- data/spec/dirs_to_require/dir_depth_1_only/depth1.rb +1 -0
- data/spec/dirs_to_require/dir_depth_3/depth1/depth1.rb +1 -0
- data/spec/dirs_to_require/dir_depth_3/depth1/depth2/depth2.rb +1 -0
- data/spec/dirs_to_require/dir_depth_3/depth1/depth2/depth3/depth3.rb +1 -0
- data/spec/requirer_spec.rb +34 -0
- data/spec/spec_helper.rb +7 -0
- metadata +209 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 91d015723f1ca0247de1080510189ce95e83ec20
|
4
|
+
data.tar.gz: 6122f047d0ed1372f48784b10de17d6ff00d772e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ad62d2e43e4bad173a4ac3f049d8b46c0448c73e75c25127402cd0ceff49f8c812c0f9f2884954785afa668dad4183783fc72cc571cb994a064e6c35b9103441
|
7
|
+
data.tar.gz: 8b58e49bcca92df28c99344a286f370a593fbea13e8c6b63a1c7dc0356e49580f445aa8917e43e5efe164b3394818e4911e80cdb101e06b8ff56abd703a33610
|
data/.coveralls.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
service_name: travis-ci
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Guardfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Brian Murphy-Dye
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# Requirer
|
2
|
+
|
3
|
+
- Perform #require on every ruby file in a directory.
|
4
|
+
- Optionally reload changes on directory tree.
|
5
|
+
- Optionally set specs to run upon save.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'requirer'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install requirer
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Contributing
|
28
|
+
|
29
|
+
1. Fork it ( https://github.com/[my-github-username]/requirer/fork )
|
30
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
31
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
32
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
33
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/lib/requirer.rb
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
require "requirer/version"
|
2
|
+
|
3
|
+
class DirUtilsException < StandardError ; end
|
4
|
+
|
5
|
+
module Requirer
|
6
|
+
def dir_tree(path)
|
7
|
+
# "dir_tree #{path}".logit
|
8
|
+
path = find_dir_with(path, $LOAD_PATH)
|
9
|
+
on_dir_tree(path) do |dir_path|
|
10
|
+
require_absolute_dir dir_path
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def require_dir(path)
|
15
|
+
# "require_dir #{path}".logit
|
16
|
+
require_absolute_dir find_dir_with(path, $LOAD_PATH)
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
def require_absolute_dir(path)
|
21
|
+
return nil unless path
|
22
|
+
|
23
|
+
# "requiring_absolute_dir #{path}".logit
|
24
|
+
Dir["#{path}/[^_]*.rb"].each do |file|
|
25
|
+
next unless File.file?(file)
|
26
|
+
# "requiring #{file}".logit
|
27
|
+
require file
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def find_dir_with(path, search_dirs=$LOAD_PATH)
|
32
|
+
raise DirUtilsException.new("No such path: #{path}") unless path
|
33
|
+
path = path.to_s
|
34
|
+
return path if path[0]=='/'
|
35
|
+
search_dirs.each do |dir|
|
36
|
+
dirname = File.expand_path(path, dir)
|
37
|
+
return dirname if File.directory?(dirname)
|
38
|
+
end
|
39
|
+
raise DirUtilsException.new("No such path: #{path}")
|
40
|
+
end
|
41
|
+
|
42
|
+
def find_file_with(path, search_dirs=$LOAD_PATH)
|
43
|
+
raise DirUtilsException.new("No such path: #{path}") unless path
|
44
|
+
return path if path[0]=='/'
|
45
|
+
search_dirs.each do |dir|
|
46
|
+
filename = File.expand_path(path, dir)
|
47
|
+
return filename if File.file?(filename)
|
48
|
+
end
|
49
|
+
raise DirUtilsException.new("No such path: #{path}")
|
50
|
+
end
|
51
|
+
|
52
|
+
def where_is?(path)
|
53
|
+
find_file_with path
|
54
|
+
end
|
55
|
+
|
56
|
+
def on_dir_tree(path, &block)
|
57
|
+
return nil unless path
|
58
|
+
block.call path
|
59
|
+
dirs = Dir["#{path}/*"].select{ |f| File.directory?(f) }
|
60
|
+
dirs.each{ |dir| on_dir_tree dir, &block }
|
61
|
+
end
|
62
|
+
end
|
data/requirer.gemspec
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'requirer/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "requirer"
|
8
|
+
spec.version = Requirer::VERSION
|
9
|
+
spec.authors = ["Brian Murphy-Dye"]
|
10
|
+
spec.email = ["brian@murphydye.com"]
|
11
|
+
spec.summary = %q{Require all files in a directory tree}
|
12
|
+
spec.description = %q{}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
spec.add_development_dependency 'rspec'
|
24
|
+
spec.add_development_dependency "rspec-nc"
|
25
|
+
spec.add_development_dependency "guard"
|
26
|
+
spec.add_development_dependency "guard-rspec"
|
27
|
+
spec.add_development_dependency "pry"
|
28
|
+
spec.add_development_dependency "pry-remote"
|
29
|
+
spec.add_development_dependency "pry-nav"
|
30
|
+
spec.add_development_dependency "coveralls"
|
31
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
$bucket << 'depth_one'
|
@@ -0,0 +1 @@
|
|
1
|
+
$bucket << 'depth_one'
|
@@ -0,0 +1 @@
|
|
1
|
+
$bucket << 'depth_one(2)'
|
@@ -0,0 +1 @@
|
|
1
|
+
$bucket << 'depth_two'
|
@@ -0,0 +1 @@
|
|
1
|
+
$bucket << 'depth_three'
|
@@ -0,0 +1,34 @@
|
|
1
|
+
warn 'in requirer_spec'
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
$LOAD_PATH.unshift 'spec/dirs_to_require'
|
5
|
+
|
6
|
+
describe Requirer do
|
7
|
+
before { $bucket = [] }
|
8
|
+
|
9
|
+
describe 'require directory with depth 1' do
|
10
|
+
it 'is loaded' do
|
11
|
+
dir_tree 'dir_depth_1'
|
12
|
+
expect($bucket).to eq(['depth_one'])
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'is loaded only once even though required twice' do
|
16
|
+
dir_tree 'dir_depth_1_only'
|
17
|
+
dir_tree 'dir_depth_1_only'
|
18
|
+
expect($bucket).to eq(['depth_one'])
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe 'require directory with depth 1' do
|
23
|
+
it 'is breadth first' do
|
24
|
+
dir_tree 'dir_depth_3'
|
25
|
+
expect($bucket).to eq(['depth_one(2)', 'depth_two', 'depth_three'])
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe 'require non-existent directory' do
|
30
|
+
it 'expect error' do
|
31
|
+
expect{ dir_tree('nobody-is-home') }.to raise_error(DirUtilsException)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,209 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: requirer
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Brian Murphy-Dye
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-07-15 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec-nc
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: guard
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: guard-rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: pry
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: pry-remote
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: pry-nav
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: coveralls
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
description: ''
|
154
|
+
email:
|
155
|
+
- brian@murphydye.com
|
156
|
+
executables: []
|
157
|
+
extensions: []
|
158
|
+
extra_rdoc_files: []
|
159
|
+
files:
|
160
|
+
- ".coveralls.yml"
|
161
|
+
- ".gitignore"
|
162
|
+
- ".travis.yml"
|
163
|
+
- Gemfile
|
164
|
+
- Guardfile
|
165
|
+
- LICENSE.txt
|
166
|
+
- README.md
|
167
|
+
- Rakefile
|
168
|
+
- lib/requirer.rb
|
169
|
+
- lib/requirer/version.rb
|
170
|
+
- requirer.gemspec
|
171
|
+
- spec/dirs_to_require/dir_depth_1/depth1.rb
|
172
|
+
- spec/dirs_to_require/dir_depth_1_only/depth1.rb
|
173
|
+
- spec/dirs_to_require/dir_depth_3/depth1/depth1.rb
|
174
|
+
- spec/dirs_to_require/dir_depth_3/depth1/depth2/depth2.rb
|
175
|
+
- spec/dirs_to_require/dir_depth_3/depth1/depth2/depth3/depth3.rb
|
176
|
+
- spec/requirer_spec.rb
|
177
|
+
- spec/spec_helper.rb
|
178
|
+
homepage: ''
|
179
|
+
licenses:
|
180
|
+
- MIT
|
181
|
+
metadata: {}
|
182
|
+
post_install_message:
|
183
|
+
rdoc_options: []
|
184
|
+
require_paths:
|
185
|
+
- lib
|
186
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
187
|
+
requirements:
|
188
|
+
- - ">="
|
189
|
+
- !ruby/object:Gem::Version
|
190
|
+
version: '0'
|
191
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
192
|
+
requirements:
|
193
|
+
- - ">="
|
194
|
+
- !ruby/object:Gem::Version
|
195
|
+
version: '0'
|
196
|
+
requirements: []
|
197
|
+
rubyforge_project:
|
198
|
+
rubygems_version: 2.4.8
|
199
|
+
signing_key:
|
200
|
+
specification_version: 4
|
201
|
+
summary: Require all files in a directory tree
|
202
|
+
test_files:
|
203
|
+
- spec/dirs_to_require/dir_depth_1/depth1.rb
|
204
|
+
- spec/dirs_to_require/dir_depth_1_only/depth1.rb
|
205
|
+
- spec/dirs_to_require/dir_depth_3/depth1/depth1.rb
|
206
|
+
- spec/dirs_to_require/dir_depth_3/depth1/depth2/depth2.rb
|
207
|
+
- spec/dirs_to_require/dir_depth_3/depth1/depth2/depth3/depth3.rb
|
208
|
+
- spec/requirer_spec.rb
|
209
|
+
- spec/spec_helper.rb
|