# File lib/bundler/source.rb, line 302 302: def self.from_lock(options) 303: new(options.merge("path" => options.delete("remote"))) 304: end
# File lib/bundler/source.rb, line 278 278: def initialize(options) 279: @options = options 280: @glob = options["glob"] || DEFAULT_GLOB 281: 282: @allow_cached = false 283: @allow_remote = false 284: 285: if options["path"] 286: @path = Pathname.new(options["path"]) 287: @path = @path.expand_path(Bundler.root) unless @path.relative? 288: end 289: 290: @name = options["name"] 291: @version = options["version"] 292: end
# File lib/bundler/source.rb, line 413 413: def cache(spec) 414: unless path.expand_path(Bundler.root).to_s.index(Bundler.root.to_s) == 0 415: Bundler.ui.warn " * #{spec.name} at `#{path}` will not be cached." 416: end 417: end
# File lib/bundler/source.rb, line 298 298: def cached! 299: @allow_cached = true 300: end
# File lib/bundler/source.rb, line 321 321: def eql?(o) 322: o.instance_of?(Path) && 323: path.expand_path(Bundler.root) == o.path.expand_path(Bundler.root) && 324: version == o.version 325: end
# File lib/bundler/source.rb, line 317 317: def hash 318: self.class.hash 319: end
# File lib/bundler/source.rb, line 401 401: def install(spec) 402: Bundler.ui.info "Using #{spec.name} (#{spec.version}) from #{to_s} " 403: # Let's be honest, when we're working from a path, we can't 404: # really expect native extensions to work because the whole point 405: # is to just be able to modify what's in that path and go. So, let's 406: # not put ourselves through the pain of actually trying to generate 407: # the full gem. 408: Installer.new(spec).generate_bin 409: end
# File lib/bundler/source.rb, line 333 333: def load_spec_files 334: index = Index.new 335: 336: expanded_path = path.expand_path(Bundler.root) 337: 338: if File.directory?(expanded_path) 339: Dir["#{expanded_path}/#{@glob}"].each do |file| 340: spec = Bundler.load_gemspec(file) 341: if spec 342: spec.loaded_from = file.to_s 343: spec.source = self 344: index << spec 345: end 346: end 347: 348: if index.empty? && @name && @version 349: index << Gem::Specification.new do |s| 350: s.name = @name 351: s.source = self 352: s.version = Gem::Version.new(@version) 353: s.platform = Gem::Platform::RUBY 354: s.summary = "Fake gemspec for #{@name}" 355: s.relative_loaded_from = "#{@name}.gemspec" 356: s.authors = ["no one"] 357: if expanded_path.join("bin").exist? 358: executables = expanded_path.join("bin").children 359: executables.reject!{|p| File.directory?(p) } 360: s.executables = executables.map{|c| c.basename.to_s } 361: end 362: end 363: end 364: else 365: raise PathError, "The path `#{expanded_path}` does not exist." 366: end 367: 368: index 369: end
# File lib/bundler/source.rb, line 371 371: def local_specs(*) 372: @local_specs ||= load_spec_files 373: end
# File lib/bundler/source.rb, line 329 329: def name 330: File.basename(path.expand_path(Bundler.root).to_s) 331: end
# File lib/bundler/source.rb, line 294 294: def remote! 295: @allow_remote = true 296: end
# File lib/bundler/source.rb, line 429 429: def generate_bin(spec) 430: gem_dir = Pathname.new(spec.full_gem_path) 431: 432: # Some gem authors put absolute paths in their gemspec 433: # and we have to save them from themselves 434: spec.files = spec.files.map do |p| 435: next if File.directory?(p) 436: begin 437: Pathname.new(p).relative_path_from(gem_dir).to_s 438: rescue ArgumentError 439: p 440: end 441: end.compact 442: 443: gem_file = Dir.chdir(gem_dir){ Gem::Builder.new(spec).build } 444: 445: installer = Installer.new(spec, :env_shebang => false) 446: run_hooks(:pre_install, installer) 447: installer.build_extensions 448: run_hooks(:post_build, installer) 449: installer.generate_bin 450: run_hooks(:post_install, installer) 451: rescue Gem::InvalidSpecificationException => e 452: 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." 453: 454: if !spec.extensions.empty? && !spec.email.empty? 455: 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`." 456: end 457: 458: Bundler.ui.warn "The validation message from Rubygems was:\n #{e.message}" 459: ensure 460: Dir.chdir(gem_dir){ FileUtils.rm_rf(gem_file) if gem_file && File.exist?(gem_file) } 461: end
# File lib/bundler/source.rb, line 421 421: def relative_path 422: if path.to_s.match(%{^#{Regexp.escape Bundler.root.to_s}}) 423: return path.relative_path_from(Bundler.root) 424: end 425: 426: path 427: end
# File lib/bundler/source.rb, line 467 467: def run_hooks(type, installer) 468: hooks_meth = "#{type}_hooks" 469: return unless Gem.respond_to?(hooks_meth) 470: Gem.send(hooks_meth).each do |hook| 471: result = hook.call(installer) 472: if result == false 473: location = " at #{$1}" if hook.inspect =~ /@(.*:\d+)/ 474: message = "#{type} hook#{location} failed for #{installer.spec.full_name}" 475: raise InstallHookError, message 476: end 477: end 478: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.