loadable 1.2.0 → 1.2.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.
@@ -0,0 +1,22 @@
1
+ BSD-2-Clause License
2
+
3
+ Redistribution and use in source and binary forms, with or without modification, are
4
+ permitted provided that the following conditions are met:
5
+
6
+ 1. Redistributions of source code must retain the above copyright notice, this list of
7
+ conditions and the following disclaimer.
8
+
9
+ 2. Redistributions in binary form must reproduce the above copyright notice, this list
10
+ of conditions and the following disclaimer in the documentation and/or other materials
11
+ provided with the distribution.
12
+
13
+ THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND ANY EXPRESS OR IMPLIED
14
+ WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
15
+ FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> OR
16
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
17
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
18
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
19
+ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
20
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
21
+ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22
+
data/README.md CHANGED
@@ -1,28 +1,32 @@
1
- # Loadable
1
+ [Website](http://github.com/rubyworks/loadable) /
2
+ [Report Issue](http://github.com/rubyworks/loadable/issues) /
3
+ [Source Code](http://github.com/rubyworks/loadable)
4
+ ( [![Build Status](https://secure.travis-ci.org/rubyworks/loadable.png)](http://travis-ci.org/rubyworks/loadable) )
2
5
 
3
- ## 1 Overview
6
+ # Loadable
4
7
 
5
- | Project | Loadable |
6
- |--------------|----------------------------------------------------------|
7
- | Author | Thomas Sawyer |
8
- | License | BSD-2-Clause |
9
- | Copyright | (c) 2010 Thomas Sawyer |
10
- | Website | http://github.com/rubyworks/loadable |
11
- | Development | http://github.com/rubyworks/loadable |
12
- | Mailing-List | http://groups.google.com/group/rubyworks-mailinglist |
8
+ *Safely Customize Ruby's Load System*
13
9
 
10
+ <br/>
14
11
 
15
- ## 2 Description
12
+ ## 1 Description
16
13
 
17
- The Loadable gem provides a more robust and convenient means of augmenting
14
+ The Loadable gem provides a robust and convenient means of augmenting
18
15
  Ruby's load system, namely the `load` and `require` methods. Rather than
19
- alias and override these methods, Loadable keeps a list of *load wedges*
20
- that control the routing of require and load calls.
16
+ alias and override these methods, Loadable keeps a list of load hooks
17
+ (also called *load wedges*) that control the routing of require and load calls.
21
18
 
22
- In addition, the Loadable gem includes two pre-made load wedges that can be
19
+ In addition, the Loadable gem includes two pre-made load hooks that can be
23
20
  used to prevent name clashes between Ruby's standard library and gem packages
24
- (see INFRACTIONS.rdoc for more on this). There is also a load wedge for
25
- for developers to make it trivial to make vendored sub-projects loadable.
21
+ (see INFRACTIONS.md for more on this). There is also a load hook for
22
+ developers to make vendored sub-projects loadable.
23
+
24
+
25
+ ## 2 Features
26
+
27
+ * Safely augment Ruby's load system.
28
+ * Prevent library name clashes.
29
+ * Search load locations.
26
30
 
27
31
 
28
32
  ## 3 Usage
@@ -31,14 +35,17 @@ for developers to make it trivial to make vendored sub-projects loadable.
31
35
 
32
36
  Installing via RubyGems follows the usual pattern.
33
37
 
34
- $ gem install loadable
38
+ gem install loadable
35
39
 
36
- To automatically load both the Gem and Ruby wedges, and the entire Loadable
40
+ To automatically load both the Gem and Ruby hooks, and the entire Loadable
37
41
  system, add `loadable` to your RUBYOPT environment variable.
38
42
 
39
- $ export RUBYOPT="-rloadable"
43
+ export RUBYOPT="-rloadable"
44
+
45
+ Place this in your shell's configuration file, such as `~/.bashrc`. For csh
46
+ syntax (e.g. in `~/.cshrc`) use:
40
47
 
41
- Place this in your shell's configuration file, such as `~/.bashrc`.
48
+ setenv RUBYOPT "-rloadable"
42
49
 
43
50
  If you do not want the default setup you can `require 'loadable/system'` instead.
44
51
  This will load in Loadable system, but only add an `OriginalLoader` to the
@@ -48,12 +55,12 @@ This will load in Loadable system, but only add an `OriginalLoader` to the
48
55
 
49
56
  Loadable was written initially to provide the specific capability of loading
50
57
  Ruby standard libraries without potential interference from libraries
51
- installed via RubyGems (see INFRACTIONS.rdoc). The code ultimately evolved
58
+ installed via RubyGems (see INFRACTIONS.md). The code ultimately evolved
52
59
  into a more generic tool, useful for writing any kind of plug-in load
53
60
  router.
54
61
 
55
- The code for the Ruby wedge serves as a good example of writing a load wedge.
56
- (Note this is leaves out a few details of the real class for simplicity sake.)
62
+ The code for the Ruby hook serves as a good example of writing a load hook.
63
+ (Note this is leaves out a few details of the real class for simplicity's sake.)
57
64
 
58
65
  require 'rbconfig'
59
66
  require 'loadable/mixin'
@@ -89,42 +96,42 @@ domain.
89
96
 
90
97
  Under the hood, this simply appends the instance to the `$LOADERS` global variable.
91
98
 
92
- Loaders, also called load wedges, are easy to write as their interface is very
93
- simple. Any object the responds to #call, taking parameters of
94
- <code>(fname, options={})</code>, can be used as a load wedge. A load wedge
99
+ Loaders, also called load hooks or wedges, are easy to write as their interface
100
+ is very simple. Any object that responds to #call, taking parameters of
101
+ <code>(fname, options={})</code>, can be used as a load hook. A load hook
95
102
  should also support `#each(options={}, &block)` which is used to iterate over
96
103
  all requirable files a loader supports.
97
104
 
98
105
  The `Loadable` mixin is just a convenience module that makes writing loaders
99
- a bit easier. Load wedges can be written without it, however the mixin
100
- provides a few methods that are often useful to any load wedge. An example is
106
+ a bit easier. Load hooks can be written without it, however the mixin
107
+ provides a few methods that are often useful to any load hook. An example is
101
108
  the `lookup` method used in the above example, which will search a
102
109
  load path in accordance with the Ruby's built-in require and load lookup
103
- procedures, i.e. automatically trying defualt extensions like `.rb`.
110
+ procedures, i.e. automatically trying default extensions like `.rb`.
104
111
 
105
112
  You might wonder how the single method, `#call`, handles both load and require
106
113
  operations. The secret is in the `options` hash. If <code>options[:load]</code>
107
114
  resolves to true, then it is a *load* operation, otherwise it is a *require*
108
115
  operation. The `$LOADERS` global variable is iterated over in order.
109
- When `#load` or `#require` is called each wedge is tried in turn. The return
116
+ When `#load` or `#require` is called each hook is tried in turn. The return
110
117
  value of `#call` controls how this loop proceeds. If the return value is `true`
111
118
  then the load was successful, and the loop can break. If it is `false` it means
112
119
  the loading has already been handled and the loop can also break. But if the
113
- return value is `nil`, it means the wedge does not apply and the loop should
114
- continue. If all wedges have been tried and all have returned `nil` then it
115
- falls back to the original `#load` and `#require` calls, via an instance
120
+ return value is `nil`, it means the hook does not apply and the loop should
121
+ continue. If all hooks have been tried and all have returned `nil` then it
122
+ falls back to the original `#load` and `#require` calls, via an instance of
116
123
  `OriginalLoader` which should always be the last loader in the `$LOADERS` list.
117
124
 
118
125
 
119
126
  ## 4 Built-in Loaders
120
127
 
121
- The Loadable gem provides three special loaders out-of-the-box, the `RubyLoader`,
122
- the `GemLoader` and the `VendorLoader`. The first two are probably not exaclty
128
+ The Loadable gem provides three special loaders out-of-the-box: the `RubyLoader`,
129
+ the `GemLoader` and the `VendorLoader`. The first two are probably not exactly
123
130
  what you think they are, going just by their names, so keep reading...
124
131
 
125
132
  ### 4.1 RubyLoader
126
133
 
127
- The Ruby wedge makes it possible to load a Ruby standard library without
134
+ The Ruby hook makes it possible to load a Ruby standard library without
128
135
  interference from installed gems or other package systems. It does this by
129
136
  checking for a `:from` option passed to the require or load methods.
130
137
 
@@ -136,7 +143,7 @@ directory without understanding the potential consequences.
136
143
 
137
144
  ### 4.2 GemLoader
138
145
 
139
- The Gem wedge is similar to the Ruby wedge, in that it isolates the loading
146
+ The Gem hook is similar to the Ruby hook, in that it isolates the loading
140
147
  of a gem's files from other gems.
141
148
 
142
149
  gem 'facets', '~>2.8'
@@ -151,14 +158,14 @@ raise a load error.
151
158
 
152
159
  require 'string/does_not_exit', :gem=>'facets'
153
160
 
154
- The Gem wedge also supports version constraints, so you do not have to use
155
- `gem()` method for one off requires from a given gem.
161
+ The Gem hook also supports version constraints, so you do not have to use
162
+ `gem()` method for one-off requires from a given gem.
156
163
 
157
164
  require 'string/margin', :from=>'facets', :version=>'~>2.8'
158
165
 
159
166
  ### 4.3 VendorLoader
160
167
 
161
- The Vendor wedge is used to add vendored projects to the load system.
168
+ The Vendor hook is used to add vendored projects to the load system.
162
169
  This is especially useful for development. Vendored projects can be added
163
170
  in two ways, by registering an instance of VendorLoader, e.g.
164
171
 
@@ -172,11 +179,11 @@ to make this more convenient.
172
179
 
173
180
  ## 5 Development
174
181
 
175
- Source code for Loadbable is hosted by [GitHub](http://github.com/rubyworks/loadable).
182
+ Source code for Loadable is hosted by [GitHub](http://github.com/rubyworks/loadable).
176
183
 
177
- If you has come across and issues, we encourage you to fork the repository and
184
+ If you come across any issues, we encourage you to fork the repository and
178
185
  submit a pull request with the fix. When submitting a pull request, it is best
179
- if the changes are orgnanized into a new topic branch.
186
+ if the changes are organized into a new topic branch.
180
187
 
181
188
  If you don't have time to code up patches yourself, please do not hesitate to
182
189
  simply report the issue on the [issue tracker](http://github.com/rubyworks/loadable/issues).
@@ -184,9 +191,10 @@ simply report the issue on the [issue tracker](http://github.com/rubyworks/loada
184
191
 
185
192
  ## 6 Copyrights
186
193
 
187
- Copyright (c) 2010 Thomas Sawyer, Rubyworks
194
+ Loadable if copyrighted open source software.
188
195
 
189
- Load is distributed under the terms of the **FreeBSD** license.
196
+ Copyright (c) 2010 Rubyworks
190
197
 
191
- See COPYING.rdoc file for details.
198
+ Load is distributed under the terms of the **BSD-2-Clause** license.
192
199
 
200
+ See LICENSE.txt file for details.
@@ -1,12 +1,7 @@
1
1
  module Gem
2
2
 
3
- # TODO: Below are two implementations of the same feature. Currently
4
- # we are using `Gem.search` code which calls `Gem::Specification.current_specs`.
5
- # Possibly this could be replaced by simply calling `GemPathSearcher.current_files`.
6
- # Hoverver, it is unclear to me at this time which is the best course of action.
7
-
8
3
  # Search RubyGems for matching paths in current gem versions.
9
- def self.search(fname, options={})
4
+ def self.search(match, options={})
10
5
  return unless defined?(::Gem)
11
6
  matches = []
12
7
  Gem::Specification.current_specs.each do |spec|
@@ -19,7 +14,7 @@ module Gem
19
14
  end
20
15
 
21
16
  class Specification
22
- # Return a list of actives specs, or latest version if not active.
17
+ # Return a list of active specs or latest version of spec if not active.
23
18
  def self.current_specs
24
19
  named = Hash.new{|h,k| h[k] = [] }
25
20
  each{ |spec| named[spec.name] << spec }
@@ -51,6 +46,10 @@ module Gem
51
46
  end
52
47
  end
53
48
 
49
+ end
50
+
51
+
52
+
54
53
  =begin
55
54
  class GemPathSearcher
56
55
  # Return a list of matching files among active or latest gems.
@@ -78,4 +77,3 @@ module Gem
78
77
  end
79
78
  =end
80
79
 
81
- end
@@ -19,7 +19,7 @@ module Loadable
19
19
 
20
20
  # Iterate over all requirable files.
21
21
  #
22
- # LoadSystem.each{ |file| p file }
22
+ # Loadable.each{ |file| p file }
23
23
  #
24
24
  # Note that esoteric load wedges may return a symbolic path rather than
25
25
  # an actual file path.
@@ -32,7 +32,7 @@ module Loadable
32
32
 
33
33
  # Search wedges for all matching paths.
34
34
  #
35
- # LoadSystem.search('detroit-*.rb')
35
+ # Loadable.search('detroit-*.rb')
36
36
  #
37
37
  # Note that "esoteric" wedges might return a symbolic identifier rather
38
38
  # than an actual file path.
@@ -13,7 +13,7 @@ module Loadable
13
13
  # require 'tracepoint', :from=>'tracepoint'
14
14
  #
15
15
  # The example would load the tracepoint file from the tracepoint gem.
16
- # It will also fallback to the RubyWedge if 'tracepoint' is not found
16
+ # It will also fallback to the RubyLoader if 'tracepoint' is not found
17
17
  # among available gems. Loading can be limited to gems only by using
18
18
  # the `:gem` options instead.
19
19
  #
@@ -80,7 +80,7 @@ module Loadable
80
80
  end
81
81
  end
82
82
 
83
- # Determine if this load4 wedge is applicable given the +fname+
83
+ # Determine if this load wedge is applicable given the +fname+
84
84
  # and +options+.
85
85
  #
86
86
  def apply?(fname, options={})
@@ -0,0 +1,5 @@
1
+ # Load all specs.
2
+ Dir['./spec/*_spec.rb'].each do |spec|
3
+ require spec
4
+ end
5
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: loadable
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-10-17 00:00:00.000000000 Z
12
+ date: 2012-12-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: detroit
16
- requirement: &21512620 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,15 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *21512620
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: minitest
27
- requirement: &21517660 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ! '>='
@@ -32,10 +37,15 @@ dependencies:
32
37
  version: '0'
33
38
  type: :development
34
39
  prerelease: false
35
- version_requirements: *21517660
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
36
46
  - !ruby/object:Gem::Dependency
37
47
  name: minitap
38
- requirement: &21751300 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
39
49
  none: false
40
50
  requirements:
41
51
  - - ! '>='
@@ -43,10 +53,15 @@ dependencies:
43
53
  version: '0'
44
54
  type: :development
45
55
  prerelease: false
46
- version_requirements: *21751300
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
47
62
  - !ruby/object:Gem::Dependency
48
63
  name: rake
49
- requirement: &21755040 !ruby/object:Gem::Requirement
64
+ requirement: !ruby/object:Gem::Requirement
50
65
  none: false
51
66
  requirements:
52
67
  - - ! '>='
@@ -54,7 +69,12 @@ dependencies:
54
69
  version: '0'
55
70
  type: :development
56
71
  prerelease: false
57
- version_requirements: *21755040
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
58
78
  description: Loadable modifieds Ruby's load/require system to handle "load wedges",
59
79
  which work much like routes in web frameworks, but in this case determine which
60
80
  files get loaded.
@@ -63,11 +83,12 @@ email:
63
83
  executables: []
64
84
  extensions: []
65
85
  extra_rdoc_files:
66
- - HISTORY.rdoc
67
- - COPYING.rdoc
68
- - INFRACTIONS.rdoc
86
+ - LICENSE.txt
87
+ - HISTORY.md
69
88
  - README.md
89
+ - INFRACTIONS.md
70
90
  files:
91
+ - .index
71
92
  - .yardopts
72
93
  - .ruby
73
94
  - lib/loadable/class_require.rb
@@ -87,16 +108,18 @@ files:
87
108
  - spec/fixture/ansi.rb
88
109
  - spec/fixture/subpro/.ruby
89
110
  - spec/fixture/subpro/lib/subpro.rb
90
- - spec/gem_loader_spec.rb
91
111
  - spec/helper.rb
92
- - spec/ruby_loader_spec.rb
93
- - spec/vendor_loader_spec.rb
94
- - HISTORY.rdoc
112
+ - spec/runner.rb
113
+ - spec/spec_gem_loader.rb
114
+ - spec/spec_ruby_loader.rb
115
+ - spec/spec_vendor_loader.rb
116
+ - LICENSE.txt
117
+ - HISTORY.md
95
118
  - README.md
96
- - COPYING.rdoc
97
- - INFRACTIONS.rdoc
119
+ - INFRACTIONS.md
98
120
  homepage: http://rubyworks.github.com/loadable
99
- licenses: []
121
+ licenses:
122
+ - BSD-2-Clause
100
123
  post_install_message:
101
124
  rdoc_options: []
102
125
  require_paths:
@@ -115,11 +138,16 @@ required_rubygems_version: !ruby/object:Gem::Requirement
115
138
  version: '0'
116
139
  requirements: []
117
140
  rubyforge_project:
118
- rubygems_version: 1.8.5
141
+ rubygems_version: 1.8.23
119
142
  signing_key:
120
143
  specification_version: 3
121
144
  summary: Safely Customize Ruby's Load System
122
145
  test_files:
123
- - spec/gem_loader_spec.rb
124
- - spec/vendor_loader_spec.rb
125
- - spec/ruby_loader_spec.rb
146
+ - spec/runner.rb
147
+ - spec/helper.rb
148
+ - spec/spec_gem_loader.rb
149
+ - spec/spec_vendor_loader.rb
150
+ - spec/spec_ruby_loader.rb
151
+ - spec/fixture/abbrev.rb
152
+ - spec/fixture/subpro/lib/subpro.rb
153
+ - spec/fixture/ansi.rb