pathological 0.2.6 → 0.3.0

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.
@@ -89,20 +89,23 @@ module Pathological
89
89
  #
90
90
  # @param [String] copy_outside_paths the directory to stage dependencies in
91
91
  # @param [String] dependency_directory the subdir within destination to put dependencies in
92
+ # @param [String] pathfile_search_path the directory at which to begin the search for the Pathfile by
93
+ # walking up the directory tree
92
94
  #
93
95
  # TODO(ev): Break this function up into a set of more functional primitives
94
- def self.copy_outside_paths!(destination, dependency_directory = "pathological_dependencies")
96
+ def self.copy_outside_paths!(destination, options = {})
97
+ options = { :dependency_directory => "pathological_dependencies" }.merge(options)
95
98
  saved_exclude_root = @@exclude_root
96
99
  begin
97
100
  self.excluderoot_mode
98
- pathfile = self.find_pathfile
101
+ pathfile = self.find_pathfile(options[:pathfile_search_path])
99
102
  # Nothing to do if there's no Pathfile
100
103
  return unless pathfile && File.file?(pathfile)
101
104
 
102
105
  foreign_paths = self.find_load_paths(pathfile).uniq
103
106
  return if foreign_paths.empty?
104
107
 
105
- path_root = File.join(destination, dependency_directory)
108
+ path_root = File.join(destination, options[:dependency_directory])
106
109
  FileUtils.mkdir_p path_root
107
110
 
108
111
  # Copy in each path and save the relative paths to write to the rewritten Pathfile. We copy each unique
@@ -116,7 +119,7 @@ module Pathological
116
119
  FileUtils.mkdir_p File.split(symlinked_name)[0]
117
120
  debug "About to move #{foreign_path} to #{symlinked_name}..."
118
121
  copy_directory(foreign_path, symlinked_name)
119
- File.join(dependency_directory, path_short_name)
122
+ File.join(options[:dependency_directory], path_short_name)
120
123
  end
121
124
  # Overwrite the Pathfile with the new relative paths.
122
125
  File.open(File.join(destination, "Pathfile"), "w") do |file|
@@ -131,7 +134,7 @@ module Pathological
131
134
 
132
135
  def self.debug_mode; @@debug = true; end
133
136
  def self.bundlerize_mode
134
- pathfile = Pathological.find_pathfile
137
+ pathfile = self.find_pathfile
135
138
  raise NoPathfileException unless pathfile
136
139
  bundle_gemfile = File.join(File.dirname(pathfile), "Gemfile")
137
140
  unless File.file? bundle_gemfile
@@ -187,7 +190,7 @@ module Pathological
187
190
  # Trim comments
188
191
  line = line.split(/#/, 2)[0].strip
189
192
  next if line.empty?
190
- raw_path = File.expand_path(File.join(root, line.strip))
193
+ raw_path = Pathname.new(line).absolute? ? line : File.expand_path(File.join(root, line))
191
194
  raw_paths << (@@add_parents ? File.dirname(raw_path) : raw_path)
192
195
  end
193
196
 
@@ -1,3 +1,3 @@
1
1
  module Pathological
2
- VERSION = "0.2.6"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -29,4 +29,5 @@ Gem::Specification.new do |s|
29
29
  s.add_development_dependency "scope", ">= 0.2.3"
30
30
  s.add_development_dependency "fakefs"
31
31
  s.add_development_dependency "rake"
32
+ s.add_development_dependency "dedent"
32
33
  end
@@ -4,6 +4,7 @@ require "rr"
4
4
  require "minitest/autorun"
5
5
  require "stringio"
6
6
  require "fakefs/safe"
7
+ require "dedent"
7
8
 
8
9
  # It's kind of funny that we need to do this hack, given that Pathological is intended to work around it...
9
10
  $:.unshift(File.join(File.dirname(__FILE__), "../../lib"))
@@ -102,29 +103,29 @@ module Pathological
102
103
 
103
104
  context "#requiring_filename" do
104
105
  setup do
105
- @full_19_stacktrace = %Q{
106
- /Users/test/ruby/gems/1.9.1/gems/pathological-0.2.2.1/lib/pathological/base.rb:61:in `find_pathfile'
107
- /Users/test/gems/pathological-0.2.2.1/lib/pathological/base.rb:36:in `find_load_paths'
108
- /Users/test/gems/pathological-0.2.2.1/lib/pathological/base.rb:15:in `add_paths!'
109
- /Users/test/gems/pathological-0.2.2.1/lib/pathological.rb:3:in `<top (required)>'
110
- /Users/test/ruby/1.9.1/rubygems/custom_require.rb:59:in `require'
111
- /Users/test/ruby/1.9.1/rubygems/custom_require.rb:59:in `rescue in require'
112
- /Users/test/ruby/1.9.1/rubygems/custom_require.rb:35:in `require'
113
- /Users/test/repos/pathological/test/rackup/app.rb:1:in `<top (required)>'
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").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?)
125
- @bad_stacktrace = %Q{
126
- /Users/test/repos/pathological/test/rackup/app.rb !!! `<top (required)>'
127
- }.split("\n").reject(&:empty?)
106
+ @full_19_stacktrace = <<-EOS.dedent.split("\n").reject(&:empty?)
107
+ /Users/test/ruby/gems/1.9.1/gems/pathological-0.2.2.1/lib/pathological/base.rb:61:in `find_pathfile'
108
+ /Users/test/gems/pathological-0.2.2.1/lib/pathological/base.rb:36:in `find_load_paths'
109
+ /Users/test/gems/pathological-0.2.2.1/lib/pathological/base.rb:15:in `add_paths!'
110
+ /Users/test/gems/pathological-0.2.2.1/lib/pathological.rb:3:in `<top (required)>'
111
+ /Users/test/ruby/1.9.1/rubygems/custom_require.rb:59:in `require'
112
+ /Users/test/ruby/1.9.1/rubygems/custom_require.rb:59:in `rescue in require'
113
+ /Users/test/ruby/1.9.1/rubygems/custom_require.rb:35:in `require'
114
+ /Users/test/repos/pathological/test/rackup/app.rb:1:in `<top (required)>'
115
+ /Users/test/.rubies/1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
116
+ EOS
117
+ @full_18_stacktrace = <<-EOS.dedent.split("\n").reject(&:empty?)
118
+ /Users/test/ruby/gems/1.8/gems/pathological-0.2.5/lib/pathological/base.rb:61:in `find_pathfile'
119
+ /Users/test/ruby/gems/1.8/gems/pathological-0.2.5/lib/pathological/base.rb:36:in `find_load_paths'
120
+ /Users/test/ruby/gems/1.8/gems/pathological-0.2.5/lib/pathological/base.rb:15:in `add_paths!'
121
+ /Users/test/ruby/gems/1.8/gems/pathological-0.2.5/lib/pathological.rb:3
122
+ /Users/test/ruby/site_ruby/1.8/rubygems/custom_require.rb:58:in `gem_original_require'
123
+ /Users/test/ruby/site_ruby/1.8/rubygems/custom_require.rb:58:in `require'
124
+ app.rb:2
125
+ EOS
126
+ @bad_stacktrace = <<-EOS.dedent.split("\n").reject(&:empty?)
127
+ /Users/test/repos/pathological/test/rackup/app.rb !!! `<top (required)>'
128
+ EOS
128
129
  @empty_stacktrace = []
129
130
  end
130
131
 
@@ -184,6 +185,16 @@ app.rb:2
184
185
  assert_raises(PathologicalException) { load_and_run! }
185
186
  end
186
187
 
188
+ should "respect absolute paths" do
189
+ other = "/a/b"
190
+ @pathfile = "/src/Pathfile"
191
+ FileUtils.mkdir "/src"
192
+ FileUtils.mkdir_p other
193
+ FileUtils.touch @pathfile
194
+ File.open(@pathfile, "w") { |f| f.write(other) }
195
+ assert Pathological.find_load_paths("/src/Pathfile").include? other
196
+ end
197
+
187
198
  should "print some debug info in debug mode" do
188
199
  Pathological.debug_mode
189
200
  mock(Pathological).puts(anything).at_least(3)
@@ -235,7 +246,7 @@ app.rb:2
235
246
  end
236
247
 
237
248
  should "return immediately if there is no Pathfile" do
238
- mock(Pathological).find_pathfile { nil }
249
+ mock(Pathological).find_pathfile(nil) { nil }
239
250
  Pathological.copy_outside_paths! @destination
240
251
  refute File.directory?(File.join(@destination, "pathological_dependencies"))
241
252
  end
@@ -261,6 +272,24 @@ app.rb:2
261
272
  end
262
273
  assert_equal destination_paths, File.read(File.join(@destination, "Pathfile")).split("\n")
263
274
  end
275
+
276
+ should "copy source dirs as links and rewrite Pathfile in a different directory" do
277
+ other = "other/dir"
278
+ FileUtils.mkdir_p other
279
+ File.open(File.join(other, "Pathfile"), "w") { |f| f.puts @source_paths.join("\n") }
280
+
281
+ final_path = File.join(@destination, "pathological_dependencies")
282
+ @source_paths.each do |source_path|
283
+ mock(Pathological).copy_directory(source_path, final_path + source_path.gsub("/src", "")).once
284
+ end
285
+ Pathological.copy_outside_paths! @destination, :pathfile_search_path => other
286
+
287
+ assert File.directory?(final_path)
288
+ destination_paths = @source_paths.map do |source_path|
289
+ "pathological_dependencies#{source_path.gsub("/src", "")}"
290
+ end
291
+ assert_equal destination_paths, File.read(File.join(@destination, "Pathfile")).split("\n")
292
+ end
264
293
  end
265
294
  end
266
295
  end
metadata CHANGED
@@ -1,73 +1,111 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: pathological
3
- version: !ruby/object:Gem::Version
4
- version: 0.2.6
3
+ version: !ruby/object:Gem::Version
4
+ hash: 19
5
5
  prerelease:
6
+ segments:
7
+ - 0
8
+ - 3
9
+ - 0
10
+ version: 0.3.0
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Daniel MacDougall
9
14
  - Caleb Spare
10
15
  - Evan Chan
11
16
  autorequire:
12
17
  bindir: bin
13
18
  cert_chain: []
14
- date: 2012-09-18 00:00:00.000000000Z
15
- dependencies:
16
- - !ruby/object:Gem::Dependency
19
+
20
+ date: 2012-09-20 00:00:00 -07:00
21
+ default_executable:
22
+ dependencies:
23
+ - !ruby/object:Gem::Dependency
17
24
  name: rr
18
- requirement: &19178940 !ruby/object:Gem::Requirement
25
+ prerelease: false
26
+ requirement: &id001 !ruby/object:Gem::Requirement
19
27
  none: false
20
- requirements:
21
- - - ! '>='
22
- - !ruby/object:Gem::Version
28
+ requirements:
29
+ - - ">="
30
+ - !ruby/object:Gem::Version
31
+ hash: 17
32
+ segments:
33
+ - 1
34
+ - 0
35
+ - 3
23
36
  version: 1.0.3
24
37
  type: :development
25
- prerelease: false
26
- version_requirements: *19178940
27
- - !ruby/object:Gem::Dependency
38
+ version_requirements: *id001
39
+ - !ruby/object:Gem::Dependency
28
40
  name: scope
29
- requirement: &19178380 !ruby/object:Gem::Requirement
41
+ prerelease: false
42
+ requirement: &id002 !ruby/object:Gem::Requirement
30
43
  none: false
31
- requirements:
32
- - - ! '>='
33
- - !ruby/object:Gem::Version
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ hash: 17
48
+ segments:
49
+ - 0
50
+ - 2
51
+ - 3
34
52
  version: 0.2.3
35
53
  type: :development
36
- prerelease: false
37
- version_requirements: *19178380
38
- - !ruby/object:Gem::Dependency
54
+ version_requirements: *id002
55
+ - !ruby/object:Gem::Dependency
39
56
  name: fakefs
40
- requirement: &19177920 !ruby/object:Gem::Requirement
57
+ prerelease: false
58
+ requirement: &id003 !ruby/object:Gem::Requirement
41
59
  none: false
42
- requirements:
43
- - - ! '>='
44
- - !ruby/object:Gem::Version
45
- version: '0'
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ hash: 3
64
+ segments:
65
+ - 0
66
+ version: "0"
46
67
  type: :development
47
- prerelease: false
48
- version_requirements: *19177920
49
- - !ruby/object:Gem::Dependency
68
+ version_requirements: *id003
69
+ - !ruby/object:Gem::Dependency
50
70
  name: rake
51
- requirement: &19171820 !ruby/object:Gem::Requirement
71
+ prerelease: false
72
+ requirement: &id004 !ruby/object:Gem::Requirement
52
73
  none: false
53
- requirements:
54
- - - ! '>='
55
- - !ruby/object:Gem::Version
56
- version: '0'
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ hash: 3
78
+ segments:
79
+ - 0
80
+ version: "0"
57
81
  type: :development
82
+ version_requirements: *id004
83
+ - !ruby/object:Gem::Dependency
84
+ name: dedent
58
85
  prerelease: false
59
- version_requirements: *19171820
60
- description: ! " Pathological provides a way to manage a project's require paths
61
- by using a small config file that\n indicates all directories to include in the
62
- load path.\n"
63
- email:
86
+ requirement: &id005 !ruby/object:Gem::Requirement
87
+ none: false
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ hash: 3
92
+ segments:
93
+ - 0
94
+ version: "0"
95
+ type: :development
96
+ version_requirements: *id005
97
+ description: " Pathological provides a way to manage a project's require paths by using a small config file that\n indicates all directories to include in the load path.\n"
98
+ email:
64
99
  - dmac@ooyala.com
65
100
  - caleb@ooyala.com
66
101
  - ev@ooyala.com
67
102
  executables: []
103
+
68
104
  extensions: []
105
+
69
106
  extra_rdoc_files: []
70
- files:
107
+
108
+ files:
71
109
  - .travis.yml
72
110
  - .yardopts
73
111
  - Gemfile
@@ -85,29 +123,39 @@ files:
85
123
  - lib/pathological/version.rb
86
124
  - pathological.gemspec
87
125
  - test/unit/pathological/base_test.rb
126
+ has_rdoc: true
88
127
  homepage: http://www.ooyala.com
89
128
  licenses: []
129
+
90
130
  post_install_message:
91
131
  rdoc_options: []
92
- require_paths:
132
+
133
+ require_paths:
93
134
  - lib
94
- required_ruby_version: !ruby/object:Gem::Requirement
135
+ required_ruby_version: !ruby/object:Gem::Requirement
95
136
  none: false
96
- requirements:
97
- - - ! '>='
98
- - !ruby/object:Gem::Version
99
- version: '0'
100
- required_rubygems_version: !ruby/object:Gem::Requirement
137
+ requirements:
138
+ - - ">="
139
+ - !ruby/object:Gem::Version
140
+ hash: 3
141
+ segments:
142
+ - 0
143
+ version: "0"
144
+ required_rubygems_version: !ruby/object:Gem::Requirement
101
145
  none: false
102
- requirements:
103
- - - ! '>='
104
- - !ruby/object:Gem::Version
105
- version: '0'
146
+ requirements:
147
+ - - ">="
148
+ - !ruby/object:Gem::Version
149
+ hash: 3
150
+ segments:
151
+ - 0
152
+ version: "0"
106
153
  requirements: []
154
+
107
155
  rubyforge_project: pathological
108
- rubygems_version: 1.8.10
156
+ rubygems_version: 1.6.2
109
157
  signing_key:
110
158
  specification_version: 2
111
159
  summary: A nice way to manage your project's require paths.
112
160
  test_files: []
113
- has_rdoc:
161
+