Object
# File lib/bundler/source.rb, line 297
297: def self.from_lock(options)
298: new(options.merge("path" => options.delete("remote")))
299: end
# File lib/bundler/source.rb, line 273
273: def initialize(options)
274: @options = options
275: @glob = options["glob"] || DEFAULT_GLOB
276:
277: @allow_cached = false
278: @allow_remote = false
279:
280: if options["path"]
281: @path = Pathname.new(options["path"])
282: @path = @path.expand_path(Bundler.root) unless @path.relative?
283: end
284:
285: @name = options["name"]
286: @version = options["version"]
287: end
# File lib/bundler/source.rb, line 407
407: def cache(spec)
408: unless path.expand_path(Bundler.root).to_s.index(Bundler.root.to_s) == 0
409: Bundler.ui.warn " * #{spec.name} at `#{path}` will not be cached."
410: end
411: end
# File lib/bundler/source.rb, line 293
293: def cached!
294: @allow_cached = true
295: end
# File lib/bundler/source.rb, line 316
316: def eql?(o)
317: o.instance_of?(Path) &&
318: path.expand_path(Bundler.root) == o.path.expand_path(Bundler.root) &&
319: name == o.name &&
320: version == o.version
321: end
# File lib/bundler/source.rb, line 312
312: def hash
313: self.class.hash
314: end
# File lib/bundler/source.rb, line 395
395: def install(spec)
396: Bundler.ui.info "Using #{spec.name} (#{spec.version}) from #{to_s} "
397: # Let's be honest, when we're working from a path, we can't
398: # really expect native extensions to work because the whole point
399: # is to just be able to modify what's in that path and go. So, let's
400: # not put ourselves through the pain of actually trying to generate
401: # the full gem.
402: Installer.new(spec).generate_bin
403: end
# File lib/bundler/source.rb, line 329
329: def load_spec_files
330: index = Index.new
331:
332: expanded_path = path.expand_path(Bundler.root)
333:
334: if File.directory?(expanded_path)
335: Dir["#{expanded_path}/#{@glob}"].each do |file|
336: spec = Bundler.load_gemspec(file)
337: if spec
338: spec.loaded_from = file.to_s
339: spec.source = self
340: index << spec
341: end
342: end
343:
344: if index.empty? && @name && @version
345: index << Gem::Specification.new do |s|
346: s.name = @name
347: s.source = self
348: s.version = Gem::Version.new(@version)
349: s.platform = Gem::Platform::RUBY
350: s.summary = "Fake gemspec for #{@name}"
351: s.relative_loaded_from = "#{@name}.gemspec"
352: if expanded_path.join("bin").exist?
353: binaries = expanded_path.join("bin").children.map{|c| c.basename.to_s }
354: s.executables = binaries
355: end
356: end
357: end
358: else
359: raise PathError, "The path `#{expanded_path}` does not exist."
360: end
361:
362: index
363: end
# File lib/bundler/source.rb, line 365
365: def local_specs
366: @local_specs ||= load_spec_files
367: end
# File lib/bundler/source.rb, line 325
325: def name
326: File.basename(@path.to_s)
327: end
# File lib/bundler/source.rb, line 289
289: def remote!
290: @allow_remote = true
291: end
# File lib/bundler/source.rb, line 423
423: def generate_bin(spec)
424: gem_dir = Pathname.new(spec.full_gem_path)
425:
426: # Some gem authors put absolute paths in their gemspec
427: # and we have to save them from themselves
428: spec.files = spec.files.map do |p|
429: next if File.directory?(p)
430: begin
431: Pathname.new(p).relative_path_from(gem_dir).to_s
432: rescue ArgumentError
433: p
434: end
435: end.compact
436:
437: gem_file = Dir.chdir(gem_dir){ Gem::Builder.new(spec).build }
438:
439: installer = Installer.new(spec, :env_shebang => false)
440: installer.build_extensions
441: installer.generate_bin
442: rescue Gem::InvalidSpecificationException => e
443: Bundler.ui.warn "\n#{spec.name} at #{spec.full_gem_path} did not have a valid gemspec.\n" "This prevents bundler from installing bins or native extensions, but " "that may not affect its functionality."
444:
445: if !spec.extensions.empty? && !spec.email.empty?
446: Bundler.ui.warn "If you need to use this package without installing it from a gem " "repository, please contact #{spec.email} and ask them " "to modify their .gemspec so it can work with `gem build`."
447: end
448:
449: Bundler.ui.warn "The validation message from Rubygems was:\n #{e.message}"
450: ensure
451: Dir.chdir(gem_dir){ FileUtils.rm_rf(gem_file) if gem_file && File.exist?(gem_file) }
452: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.