require_all 1.3.0 → 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e06fe7ba5ebad8808e535a57c68d3493d254b0a4
4
- data.tar.gz: af66530c89f609f806f875dec3f630e8a40b4ca9
3
+ metadata.gz: 94b3a76320c4d23cda85ab8502101938a784e381
4
+ data.tar.gz: 8272f8a59cf18e4e5ea0de477136ac57fe5fea96
5
5
  SHA512:
6
- metadata.gz: 8a8ed5bda5ed3f5db20d536925de3164c96205dff8734a117702abc6869a567d3fcc86886094953b6d838c9b73f60ce25426179d2b15ec934fa819775ab518da
7
- data.tar.gz: d0edb85d06904dbcf63d91d12020c21d9439c70990ba53c327b44c9be5727eaedabb900a1aee16e5927404a5a66346cb960230f12c175a86007ea3d444296dfc
6
+ metadata.gz: 789a8ce1369441410a9f1b9e6ce7181eb47c41e91f17d281dbfdc13252199aac75dd981cdb44e5e3dbbbdde65491d38392735069e2ec26452cd7932f1dce3de6
7
+ data.tar.gz: a68153b0df9104a8226e85190515c793c15ce07562b1e0b849451d38a914e30e0babe0330073cbdc1cf7977c9bccf641d63fdfed320edb1f63b2e8d3a907d577
data/.travis.yml ADDED
@@ -0,0 +1,13 @@
1
+ rvm:
2
+ - 1.9.3
3
+ - 2.0.0
4
+ - jruby-19mode
5
+ - rbx-19mode
6
+ - ruby-head
7
+ notifications:
8
+ recipients:
9
+ - jarmo.p@gmail.com
10
+ matrix:
11
+ allow_failures:
12
+ - rvm: ruby-head
13
+
data/CHANGES CHANGED
@@ -1,3 +1,7 @@
1
+ 1.3.1:
2
+
3
+ * README improvements.
4
+
1
5
  1.3.0:
2
6
 
3
7
  * Make everything work with Ruby 1.9 and 2.0. Awesome! Thanks to Aaron Klaassen.
data/README.md ADDED
@@ -0,0 +1,127 @@
1
+ # require_all
2
+ [![Gem Version](https://badge.fury.io/rb/require_all.png)](http://badge.fury.io/rb/require_all)
3
+ [![Build Status](https://secure.travis-ci.org/jarmo/require_all.png)](http://travis-ci.org/jarmo/require_all)
4
+
5
+ A wonderfully simple way to load your code.
6
+
7
+ Tired of futzing around with `require` statements everywhere, littering your code
8
+ with `require File.dirname(__FILE__)` crap? What if you could just
9
+ point something at a big directory full of code and have everything just
10
+ automagically load regardless of the dependency structure?
11
+
12
+ Wouldn't that be nice? Well, now you can!
13
+
14
+ ## Installation
15
+
16
+ Add this line to your application's Gemfile:
17
+
18
+ gem 'require_all'
19
+
20
+ And then execute:
21
+
22
+ $ bundle
23
+
24
+ Or install it yourself as:
25
+
26
+ $ gem install require_all
27
+
28
+ ## Usage
29
+
30
+ ```ruby
31
+ require 'require_all'
32
+
33
+ # load all ruby files in the directory "lib" and its subdirectories
34
+ require_all 'lib'
35
+
36
+ # or load all files by using glob
37
+ require_all 'lib/**/*.rb'
38
+
39
+ # or load files in an Array
40
+ require_all Dir.glob("blah/**/*.rb").reject { |f| stupid_file? f }
41
+
42
+ # or load manually specified files
43
+ require_all 'lib/a.rb', 'lib/b.rb', 'lib/c.rb', 'lib/d.rb'
44
+ ```
45
+
46
+ You can also load files relative to the current file by using `require_rel`:
47
+
48
+ ```ruby
49
+ # Instead of
50
+ require File.dirname(__FILE__) + '/foobar'
51
+
52
+ # you can do simply like this
53
+ require_rel 'foobar'
54
+ ```
55
+
56
+ You can give all the same argument types to the `require_rel` as for `require_all`.
57
+
58
+ It is recommended to use `require_rel` instead of `require_all` since it will require files relatively
59
+ to the current file (`__FILE__`) as opposed to loading files relative from the working directory.
60
+
61
+ `load_all` and `load_rel` methods also exist to use `Kernel#load` instead of `Kernel#require`!
62
+
63
+ The proper order to in which to load files is determined automatically for you.
64
+
65
+ It's just that easy! Code loading shouldn't be hard.
66
+
67
+ ## autoload_all
68
+
69
+ This library also includes methods for performing `autoload` - what a bargain!
70
+
71
+ Similar syntax is used as for `require_(all|rel)` and `load_(all|rel)` methods with some caveats:
72
+
73
+ * Directory and file names have to reflect namespaces and/or constant names:
74
+
75
+ ```ruby
76
+ # lib/dir1/dir2/my_file.rb
77
+ module Dir1
78
+ module Dir2
79
+ class MyFile
80
+ end
81
+ end
82
+ end
83
+
84
+ # lib/loader.rb
85
+ autoload_all File.dirname(__FILE__) + "/dir1"
86
+ ```
87
+
88
+ * A `base_dir` option has to be specified if loading directories or files from some other location
89
+ than top-level directory:
90
+
91
+ ```ruby
92
+ # lib/dir1/other_file.rb
93
+ autoload_all File.dirname(__FILE__) + "/dir2/my_file.rb",
94
+ :base_dir => File.dirname(__FILE__) + "/../dir1"
95
+ ```
96
+
97
+ * All namespaces will be created dynamically by `autoload_all` - this means that `defined?(Dir1)` will
98
+ return `"constant"` even if `my_file.rb` is not yet loaded!
99
+
100
+ Of course there's also an `autoload_rel` method:
101
+ ```ruby
102
+ autoload_rel "dir2/my_file.rb", :base_dir => File.dirname(__FILE__) + "/../dir1"
103
+ ```
104
+
105
+ If having some problems with `autoload_all` or `autoload_rel` then set `$DEBUG=true` to see how files
106
+ are mapped to their respective modules and classes.
107
+
108
+ ## Methodology (except for autoload_{all|rel})
109
+
110
+ * Enumerate the files to be loaded
111
+ * Try to load all of the files. If we encounter a `NameError` loading a
112
+ particular file, store that file in a "try to load it later" list.
113
+ * If all the files loaded, great, we're done! If not, go through the
114
+ "try to load it later" list again rescuing `NameError` the same way.
115
+ * If we walk the whole "try to load it later" list and it doesn't shrink
116
+ at all, we've encountered an unresolvable dependency. In this case,
117
+ `require_all` will rethrow the first `NameError` it encountered.
118
+
119
+ ## Questions? Comments? Concerns?
120
+
121
+ You can reach the author on github or by email [jarmo.p@gmail.com](mailto:jarmo.p@gmail.com)
122
+
123
+ ## License
124
+
125
+ Jarmo Pertman
126
+
127
+ MIT (see the LICENSE file for details)
data/require_all.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "require_all"
3
- s.version = "1.3.0"
3
+ s.version = "1.3.1"
4
4
  s.authors = ["Jarmo Pertman", "Tony Arcieri"]
5
5
  s.email = "jarmo.p@gmail.com"
6
6
  s.summary = "A wonderfully simple way to load your code"
@@ -12,8 +12,8 @@ Gem::Specification.new do |s|
12
12
  s.homepage = "http://github.com/jarmo/require_all"
13
13
 
14
14
  s.has_rdoc = true
15
- s.rdoc_options = %w(--title require_all --main README.textile --line-numbers)
16
- s.extra_rdoc_files = ["LICENSE", "README.textile", "CHANGES"]
15
+ s.rdoc_options = %w(--title require_all --main README.md --line-numbers)
16
+ s.extra_rdoc_files = ["LICENSE", "README.md", "CHANGES"]
17
17
 
18
18
  s.add_development_dependency "rake", "~>0.9"
19
19
  s.add_development_dependency "rspec", "~>2.14"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: require_all
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jarmo Pertman
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-09-03 00:00:00.000000000 Z
12
+ date: 2013-09-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -59,14 +59,15 @@ executables: []
59
59
  extensions: []
60
60
  extra_rdoc_files:
61
61
  - LICENSE
62
- - README.textile
62
+ - README.md
63
63
  - CHANGES
64
64
  files:
65
65
  - .gitignore
66
+ - .travis.yml
66
67
  - CHANGES
67
68
  - Gemfile
68
69
  - LICENSE
69
- - README.textile
70
+ - README.md
70
71
  - Rakefile
71
72
  - lib/require_all.rb
72
73
  - require_all.gemspec
@@ -103,7 +104,7 @@ rdoc_options:
103
104
  - --title
104
105
  - require_all
105
106
  - --main
106
- - README.textile
107
+ - README.md
107
108
  - --line-numbers
108
109
  require_paths:
109
110
  - lib
data/README.textile DELETED
@@ -1,140 +0,0 @@
1
- h1. require_all
2
-
3
- A wonderfully simple way to load your code.
4
-
5
- Tired of futzing around with require statements everywhere, littering your code
6
- with <code>require File.dirname(__FILE__)</code> crap? What if you could just
7
- point something at a big directory full of code and have everything just
8
- automagically load regardless of the dependency structure?
9
-
10
- Wouldn't that be nice? Well, now you can!
11
-
12
- <code>require 'require_all'</code>
13
-
14
- You can use require_all in a multitude of different ways.
15
-
16
- The easiest way to use require_all is to just point it at a directory
17
- containing a bunch of .rb files:
18
-
19
- <code>require_all 'lib'</code>
20
-
21
- This will find all the .rb files under the lib directory (including all
22
- subdirectories as well) and load them.
23
-
24
- The proper order to in which to load them is determined automatically. If the
25
- dependencies between the matched files are unresolvable, it will throw the
26
- first unresolvable NameError.
27
-
28
- You can also give it a glob, which will enumerate all the matching files:
29
-
30
- <code>require_all 'lib/**/*.rb'</code>
31
-
32
- It will also accept an array of files:
33
-
34
- <code>require_all Dir.glob("blah/**/*.rb").reject { |f| stupid_file? f }</code>
35
-
36
- Or if you want, just list the files directly as arguments:
37
-
38
- <code>require_all 'lib/a.rb', 'lib/b.rb', 'lib/c.rb', 'lib/d.rb'</code>
39
-
40
- Still have the require <code>File.dirname(__FILE__)</code> blues? The require_all gem also
41
- provides a require_rel statement which requires files to relative to the
42
- current file. So you can replace statements like:
43
-
44
- <code>require File.dirname(__FILE__) + '/foobar'</code>
45
-
46
- with just a simple require_rel:
47
-
48
- <code>require_rel 'foobar'</code>
49
-
50
- Even better, require_rel still has the full power of require_all, so you can
51
- use require_rel to load entire directories of code too. If "foobar" is a
52
- directory this will load all the .rb files found under that directory with
53
- automagic dependency handling.
54
-
55
- The difference between <code>require_all</code> and <code>require_rel</code> is that the former loads from the
56
- working directory and latter from the directory relative to the <code>__FILE__</code>.
57
- So, if your working directory is let's say /home, and there is /lib/a/b.rb and /lib/c.rb, then
58
-
59
- <code>require_all "lib/"</code> loads every ruby file from the lib directory in the working directory (pwd)
60
-
61
- and in /lib/c.rb <code>require_rel "a/"</code> loads every ruby file from the a/ directory not paying any attention
62
- to the working directory itself.
63
-
64
- It's recommended to use require_rel since it is not affected by the working directory.
65
-
66
- Also load_all and load_rel methods exist to use Kernel#load instead of Kernel#require!
67
-
68
- It's just that easy! Code loading shouldn't be hard.
69
-
70
- h2. autoload_all
71
-
72
- There's also a methods for performing autoloading - what a bargain!
73
- Similar syntax is used as for require and load methods although some things have to be
74
- kept in mind:
75
-
76
- * Directory and file names have to reflect namespaces and/or constant names - e.g.
77
- a file called my_file.rb in directories dir1/dir2 has to be defined like this:
78
- <pre>
79
- <code>
80
- module Dir1
81
- module Dir2
82
- class MyFile
83
- end
84
- end
85
- end
86
- </code>
87
- </pre>
88
-
89
- in a loader.rb, which is in a parent directory for dir1:
90
- <code>autoload_all File.dirname(__FILE__) + "/dir1"</code>
91
-
92
- * A :base_dir option has to be specified if loading directories or files from some other location
93
- than top-level directory.
94
-
95
- in dir1/other_file.rb:
96
- <pre>
97
- <code>
98
- autoload_all File.dirname(__FILE__) + "/dir2/my_file.rb",
99
- :base_dir => File.dirname(__FILE__) + "/../dir1" # top-level namespace starts from dir1
100
- </code>
101
- </pre>
102
-
103
- * All namespaces will be created dynamically by autoload_all - this means that defined?(Dir1) will
104
- return "constant" even if my_file.rb is not loaded!
105
-
106
- Of course there's also an autoload_rel method:
107
- <code>autoload_rel "dir2/my_file.rb", :base_dir => File.dirname(__FILE__) + "/../dir1"</code>
108
-
109
- If having some problems with autoload_all or autoload_rel then set $DEBUG to true to see how files
110
- are mapped to their respective modules and classes.
111
-
112
- h2. Methodology (except for autoload_{all|rel})
113
-
114
- I didn't invent the approach this gem uses. It was shamelessly stolen from
115
- Merb (which apparently stole it from elsewhere). Here's how it works:
116
-
117
- # Enumerate the files to be loaded
118
- # Try to load all of the files. If we encounter a NameError loading a
119
- particular file, store that file in a "try to load it later" list.
120
- # If all the files loaded, great, we're done! If not, go through the
121
- "try to load it later" list again rescuing NameErrors the same way.
122
- # If we walk the whole "try to load it later" list and it doesn't shrink
123
- at all, we've encountered an unresolvable dependency. In this case,
124
- require_all will rethrow the first NameError it encountered.
125
-
126
- h2. Questions? Comments? Concerns?
127
-
128
- You can reach the author on github or freenode: "jarm0"
129
-
130
- Or by email: "jarmo.p@gmail.com":mailto:jarmo.p@gmail.com
131
-
132
- Got issues with require_all to report? Post 'em here:
133
-
134
- "Github Tracker":http://github.com/jarmo/require_all/issues
135
-
136
- h2. License
137
-
138
- require_all was done originally by Tony Arcieri who asked me to maintain the gem.
139
-
140
- MIT (see the LICENSE file for details)