pathological 0.2.5 → 0.2.6
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.
- data/.travis.yml +5 -0
- data/README.md +34 -25
- data/Rakefile +1 -0
- data/lib/pathological/base.rb +6 -3
- data/lib/pathological/version.rb +1 -1
- data/test/unit/pathological/base_test.rb +17 -4
- metadata +11 -11
- data/Gemfile.lock +0 -24
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
Pathological
|
2
|
-
============
|
1
|
+
# Pathological
|
3
2
|
|
4
3
|
Pathological is a Ruby tool that provides a lightweight mechanism for managing your project's load path.
|
5
4
|
|
6
|
-
|
7
|
-
|
5
|
+
[](http://travis-ci.org/ooyala/pathological)
|
6
|
+
|
7
|
+
## The problem
|
8
8
|
|
9
9
|
When you're writing a gem, you don't have to worry about paths much, because Rubygems makes sure that `lib/`
|
10
10
|
makes it into your path for you. On the other hand, if you have large Ruby projects which aren't organized as
|
@@ -22,8 +22,7 @@ gems, you may encounter some of the following problems:
|
|
22
22
|
|
23
23
|
Pathological provides one way to manage these issues.
|
24
24
|
|
25
|
-
Using pathological
|
26
|
-
------------------
|
25
|
+
## Using pathological
|
27
26
|
|
28
27
|
Getting started with pathological is easy. First, make a file called `Pathfile` at your project root:
|
29
28
|
|
@@ -51,8 +50,7 @@ Pathological (and of course you should have `gem "pathological"` in your `Gemfil
|
|
51
50
|
|
52
51
|
`Pathfile`s should be kept in version control.
|
53
52
|
|
54
|
-
Adding other paths to your load path
|
55
|
-
------------------------------------
|
53
|
+
## Adding other paths to your load path
|
56
54
|
|
57
55
|
To add more paths to your load path, just put the paths in your `Pathfile`. The paths are relative to the
|
58
56
|
location of the `Pathfile`. The paths will be inserted in the order they appear; the project root itself will
|
@@ -84,15 +82,13 @@ require "common"
|
|
84
82
|
# ...
|
85
83
|
```
|
86
84
|
|
87
|
-
Installation
|
88
|
-
------------
|
85
|
+
## Installation
|
89
86
|
|
90
87
|
Pathological is packaged as a Rubygem and hence can be trivially installed with
|
91
88
|
|
92
89
|
$ gem install pathological
|
93
90
|
|
94
|
-
Advanced usage
|
95
|
-
--------------
|
91
|
+
## Advanced usage
|
96
92
|
|
97
93
|
In some cases, you might want slightly different behavior. This customization is done through the use of
|
98
94
|
custom modes. You may use any combination of modes.
|
@@ -139,11 +135,10 @@ A quicker way is also provided: if you only need to use one special mode, then t
|
|
139
135
|
can require:
|
140
136
|
|
141
137
|
``` ruby
|
142
|
-
require "pathological/
|
138
|
+
require "pathological/debug"
|
143
139
|
```
|
144
140
|
|
145
|
-
Public API
|
146
|
-
----------
|
141
|
+
## Public API
|
147
142
|
|
148
143
|
For even more configurable custom integration with Pathological, a public API is provided. See the generated
|
149
144
|
documentation for details on the following public methods:
|
@@ -154,8 +149,26 @@ documentation for details on the following public methods:
|
|
154
149
|
* `Pathological#reset!`
|
155
150
|
* `Pathological#copy_outside_paths!`
|
156
151
|
|
157
|
-
|
158
|
-
|
152
|
+
## Notes and gotchas
|
153
|
+
|
154
|
+
Pathological is intended as a replacement for manually munging the load path in your application when you want
|
155
|
+
to load code from other locations. If you can turn each of your dependencies into a gem and then use bundler
|
156
|
+
to manage the dependencies, **do that instead**.
|
157
|
+
|
158
|
+
Pathological does its best to figure out where the Pathfile it should use is located, based on the call stack.
|
159
|
+
For instance, if you run `/foo/bar.rb` and that requires Pathological, then it will search for `/foo/Pathfile`
|
160
|
+
and -- failing that -- `/Pathfile`. However, if `/foo/bar.rb` does not require Pathological, but loads a ruby
|
161
|
+
file in `/baz/quux.rb`, and *that* file requires Pathological, then Pathological searches for `/baz/Pathfile`
|
162
|
+
and then `/Pathfile`.
|
163
|
+
|
164
|
+
Any code loading situation which does not preserve a sane load path will be incompatible with Pathological.
|
165
|
+
For instance, if you `eval()` some code that requires Pathological, Pathological has no way of telling where
|
166
|
+
that code originally lived, and will probably behave in an unexpected way. One place this commonly occurs is
|
167
|
+
with rack webservers (e.g., Rackup, Unicorn) that load a `config.ru`. This file is `instance_eval`ed and so
|
168
|
+
requiring Pathological from your `config.ru` will not work as expected. In these cases, require Pathological
|
169
|
+
in your app directly.
|
170
|
+
|
171
|
+
## Authors
|
159
172
|
|
160
173
|
Pathological was written by the following Ooyala engineers:
|
161
174
|
|
@@ -164,25 +177,21 @@ Pathological was written by the following Ooyala engineers:
|
|
164
177
|
* [Sami Abu-El-Haija](mailto:sami@ooyala.com)
|
165
178
|
* [Evan Chan](mailto:ev@ooyala.com)
|
166
179
|
|
167
|
-
Credits
|
168
|
-
-------
|
180
|
+
## Credits
|
169
181
|
|
170
182
|
* Harry Robertson for the idea to *not* use a dot-prefixed configuration file
|
171
183
|
|
172
|
-
Metadata
|
173
|
-
--------
|
184
|
+
## Metadata
|
174
185
|
|
175
186
|
* [Hosted on Github](https://github.com/ooyala/pathological)
|
176
187
|
* [Rubygems page](https://rubygems.org/gems/pathological)
|
177
188
|
* [Documentation](http://rubydoc.info/github/ooyala/pathological/master/frames)
|
178
189
|
|
179
|
-
Contributing
|
180
|
-
------------
|
190
|
+
## Contributing
|
181
191
|
|
182
192
|
If you would like to commit a patch, great! Just do the usual github pull request stuff and we'll check it
|
183
193
|
out[.](http://www.randomkittengenerator.com/)
|
184
194
|
|
185
|
-
License
|
186
|
-
-------
|
195
|
+
## License
|
187
196
|
|
188
197
|
Pathological is licensed under the MIT license.
|
data/Rakefile
CHANGED
data/lib/pathological/base.rb
CHANGED
@@ -234,17 +234,20 @@ module Pathological
|
|
234
234
|
|
235
235
|
# Searches the call stack for the file that required pathological. If no file can be found, falls back to
|
236
236
|
# the currently executing file ($0). This handles the case where the app was launched by another executable
|
237
|
-
# (rake, thin,
|
237
|
+
# (rake, thin, etc.)
|
238
238
|
#
|
239
239
|
# @return [String] name of file requiring pathological, or the currently executing file.
|
240
240
|
def self.requiring_filename
|
241
|
+
# Match paths like .../gems/pathological-0.2.2.1/lib/pathological/base.rb and also
|
242
|
+
# .../gems/pathological-0.2.2.1/lib/pathological.rb
|
243
|
+
pathological_file_pattern = %r{/pathological(/[^/]+|)\.rb}
|
241
244
|
requiring_file = Kernel.caller.find do |stack_line|
|
242
245
|
if RUBY_VERSION.start_with?("1.9")
|
243
246
|
# In Ruby 1.9, top-level files will have the string "top (required)" included in the stack listing.
|
244
|
-
stack_line.include?("top (required)") &&
|
247
|
+
stack_line.include?("top (required)") && stack_line !~ pathological_file_pattern
|
245
248
|
else
|
246
249
|
# In Ruby 1.8, top-level files are listed with their relative path and without a line number.
|
247
|
-
|
250
|
+
stack_line !~ /:\d+:in/ && stack_line !~ pathological_file_pattern
|
248
251
|
end
|
249
252
|
end
|
250
253
|
requiring_file ? requiring_file.match(/(.+):\d+/)[1] : $0 rescue $0
|
data/lib/pathological/version.rb
CHANGED
@@ -102,7 +102,7 @@ module Pathological
|
|
102
102
|
|
103
103
|
context "#requiring_filename" do
|
104
104
|
setup do
|
105
|
-
@
|
105
|
+
@full_19_stacktrace = %Q{
|
106
106
|
/Users/test/ruby/gems/1.9.1/gems/pathological-0.2.2.1/lib/pathological/base.rb:61:in `find_pathfile'
|
107
107
|
/Users/test/gems/pathological-0.2.2.1/lib/pathological/base.rb:36:in `find_load_paths'
|
108
108
|
/Users/test/gems/pathological-0.2.2.1/lib/pathological/base.rb:15:in `add_paths!'
|
@@ -112,15 +112,28 @@ module Pathological
|
|
112
112
|
/Users/test/ruby/1.9.1/rubygems/custom_require.rb:35:in `require'
|
113
113
|
/Users/test/repos/pathological/test/rackup/app.rb:1:in `<top (required)>'
|
114
114
|
/Users/test/.rubies/1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
|
115
|
-
}.split("\n")
|
115
|
+
}.split("\n").reject(&:empty?)
|
116
|
+
@full_18_stacktrace = %Q{
|
117
|
+
/Users/test/ruby/gems/1.8/gems/pathological-0.2.5/lib/pathological/base.rb:61:in `find_pathfile'
|
118
|
+
/Users/test/ruby/gems/1.8/gems/pathological-0.2.5/lib/pathological/base.rb:36:in `find_load_paths'
|
119
|
+
/Users/test/ruby/gems/1.8/gems/pathological-0.2.5/lib/pathological/base.rb:15:in `add_paths!'
|
120
|
+
/Users/test/ruby/gems/1.8/gems/pathological-0.2.5/lib/pathological.rb:3
|
121
|
+
/Users/test/ruby/site_ruby/1.8/rubygems/custom_require.rb:58:in `gem_original_require'
|
122
|
+
/Users/test/ruby/site_ruby/1.8/rubygems/custom_require.rb:58:in `require'
|
123
|
+
app.rb:2
|
124
|
+
}.split("\n").reject(&:empty?)
|
116
125
|
@bad_stacktrace = %Q{
|
117
126
|
/Users/test/repos/pathological/test/rackup/app.rb !!! `<top (required)>'
|
118
|
-
}.split("\n")
|
127
|
+
}.split("\n").reject(&:empty?)
|
119
128
|
@empty_stacktrace = []
|
120
129
|
end
|
121
130
|
|
122
131
|
should "find root file from a stacktrace" do
|
123
|
-
|
132
|
+
if RUBY_VERSION.start_with?("1.9")
|
133
|
+
stub(Kernel).caller { @full_19_stacktrace }
|
134
|
+
else
|
135
|
+
stub(Kernel).caller { @full_18_stacktrace }
|
136
|
+
end
|
124
137
|
assert_equal "app.rb", File.basename(Pathological.requiring_filename)
|
125
138
|
end
|
126
139
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pathological
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,11 +11,11 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2012-09-
|
14
|
+
date: 2012-09-18 00:00:00.000000000Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rr
|
18
|
-
requirement: &
|
18
|
+
requirement: &19178940 !ruby/object:Gem::Requirement
|
19
19
|
none: false
|
20
20
|
requirements:
|
21
21
|
- - ! '>='
|
@@ -23,10 +23,10 @@ dependencies:
|
|
23
23
|
version: 1.0.3
|
24
24
|
type: :development
|
25
25
|
prerelease: false
|
26
|
-
version_requirements: *
|
26
|
+
version_requirements: *19178940
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: scope
|
29
|
-
requirement: &
|
29
|
+
requirement: &19178380 !ruby/object:Gem::Requirement
|
30
30
|
none: false
|
31
31
|
requirements:
|
32
32
|
- - ! '>='
|
@@ -34,10 +34,10 @@ dependencies:
|
|
34
34
|
version: 0.2.3
|
35
35
|
type: :development
|
36
36
|
prerelease: false
|
37
|
-
version_requirements: *
|
37
|
+
version_requirements: *19178380
|
38
38
|
- !ruby/object:Gem::Dependency
|
39
39
|
name: fakefs
|
40
|
-
requirement: &
|
40
|
+
requirement: &19177920 !ruby/object:Gem::Requirement
|
41
41
|
none: false
|
42
42
|
requirements:
|
43
43
|
- - ! '>='
|
@@ -45,10 +45,10 @@ dependencies:
|
|
45
45
|
version: '0'
|
46
46
|
type: :development
|
47
47
|
prerelease: false
|
48
|
-
version_requirements: *
|
48
|
+
version_requirements: *19177920
|
49
49
|
- !ruby/object:Gem::Dependency
|
50
50
|
name: rake
|
51
|
-
requirement: &
|
51
|
+
requirement: &19171820 !ruby/object:Gem::Requirement
|
52
52
|
none: false
|
53
53
|
requirements:
|
54
54
|
- - ! '>='
|
@@ -56,7 +56,7 @@ dependencies:
|
|
56
56
|
version: '0'
|
57
57
|
type: :development
|
58
58
|
prerelease: false
|
59
|
-
version_requirements: *
|
59
|
+
version_requirements: *19171820
|
60
60
|
description: ! " Pathological provides a way to manage a project's require paths
|
61
61
|
by using a small config file that\n indicates all directories to include in the
|
62
62
|
load path.\n"
|
@@ -68,9 +68,9 @@ executables: []
|
|
68
68
|
extensions: []
|
69
69
|
extra_rdoc_files: []
|
70
70
|
files:
|
71
|
+
- .travis.yml
|
71
72
|
- .yardopts
|
72
73
|
- Gemfile
|
73
|
-
- Gemfile.lock
|
74
74
|
- LICENSE
|
75
75
|
- README.md
|
76
76
|
- Rakefile
|
data/Gemfile.lock
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
pathological (0.2.5)
|
5
|
-
|
6
|
-
GEM
|
7
|
-
remote: http://rubygems.org/
|
8
|
-
specs:
|
9
|
-
fakefs (0.4.0)
|
10
|
-
minitest (2.5.1)
|
11
|
-
rake (0.9.2.2)
|
12
|
-
rr (1.0.3)
|
13
|
-
scope (0.2.3)
|
14
|
-
minitest
|
15
|
-
|
16
|
-
PLATFORMS
|
17
|
-
ruby
|
18
|
-
|
19
|
-
DEPENDENCIES
|
20
|
-
fakefs
|
21
|
-
pathological!
|
22
|
-
rake
|
23
|
-
rr (>= 1.0.3)
|
24
|
-
scope (>= 0.2.3)
|