Parent

Bundler::Source::Path

Constants

DEFAULT_GLOB

Attributes

path[R]
options[R]
name[W]

Kind of a hack, but needed for the lock file parser

version[RW]

Public Class Methods

from_lock(options) click to toggle source
     # File lib/bundler/source.rb, line 295
295:       def self.from_lock(options)
296:         new(options.merge("path" => options.delete("remote")))
297:       end
new(options) click to toggle source
     # File lib/bundler/source.rb, line 272
272:       def initialize(options)
273:         @options = options
274:         @glob = options["glob"] || DEFAULT_GLOB
275: 
276:         @allow_cached = false
277:         @allow_remote = false
278: 
279:         if options["path"]
280:           @path = Pathname.new(options["path"]).expand_path(Bundler.root)
281:         end
282: 
283:         @name = options["name"]
284:         @version = options["version"]
285:       end

Public Instance Methods

==(o) click to toggle source
Alias for: eql?
cache(spec) click to toggle source
     # File lib/bundler/source.rb, line 403
403:       def cache(spec)
404:         unless path.to_s.index(Bundler.root.to_s) == 0
405:           Bundler.ui.warn "  * #{spec.name} at `#{path}` will not be cached."
406:         end
407:       end
cached!() click to toggle source
     # File lib/bundler/source.rb, line 291
291:       def cached!
292:         @allow_cached = true
293:       end
eql?(o) click to toggle source
     # File lib/bundler/source.rb, line 314
314:       def eql?(o)
315:         o.instance_of?(Path) &&
316:         path == o.path &&
317:         name == o.name &&
318:         version == o.version
319:       end
Also aliased as: ==
hash() click to toggle source
     # File lib/bundler/source.rb, line 310
310:       def hash
311:         self.class.hash
312:       end
install(spec) click to toggle source
     # File lib/bundler/source.rb, line 391
391:       def install(spec)
392:         Bundler.ui.info "Using #{spec.name} (#{spec.version}) from #{to_s} "
393:         # Let's be honest, when we're working from a path, we can't
394:         # really expect native extensions to work because the whole point
395:         # is to just be able to modify what's in that path and go. So, let's
396:         # not put ourselves through the pain of actually trying to generate
397:         # the full gem.
398:         Installer.new(spec).generate_bin
399:       end
load_spec_files() click to toggle source
     # File lib/bundler/source.rb, line 327
327:       def load_spec_files
328:         index = Index.new
329: 
330:         if File.directory?(path)
331:           Dir["#{path}/#{@glob}"].each do |file|
332:             spec = Bundler.load_gemspec(file)
333:             if spec
334:               spec.loaded_from = file.to_s
335:               spec.source = self
336:               index << spec
337:             end
338:           end
339: 
340:           if index.empty? && @name && @version
341:             index << Gem::Specification.new do |s|
342:               s.name     = @name
343:               s.source   = self
344:               s.version  = Gem::Version.new(@version)
345:               s.platform = Gem::Platform::RUBY
346:               s.summary  = "Fake gemspec for #{@name}"
347:               s.relative_loaded_from = "#{@name}.gemspec"
348:               if path.join("bin").exist?
349:                 binaries = path.join("bin").children.map{|c| c.basename.to_s }
350:                 s.executables = binaries
351:               end
352:             end
353:           end
354:         else
355:           raise PathError, "The path `#{path}` does not exist."
356:         end
357: 
358:         index
359:       end
local_specs() click to toggle source
     # File lib/bundler/source.rb, line 361
361:       def local_specs
362:         @local_specs ||= load_spec_files
363:       end
Also aliased as: specs
name() click to toggle source
     # File lib/bundler/source.rb, line 323
323:       def name
324:         File.basename(@path.to_s)
325:       end
remote!() click to toggle source
     # File lib/bundler/source.rb, line 287
287:       def remote!
288:         @allow_remote = true
289:       end
specs() click to toggle source
Alias for: local_specs
to_lock() click to toggle source
     # File lib/bundler/source.rb, line 299
299:       def to_lock
300:         out = "PATH\n"
301:         out << "  remote: #{relative_path}\n"
302:         out << "  glob: #{@glob}\n" unless @glob == DEFAULT_GLOB
303:         out << "  specs:\n"
304:       end
to_s() click to toggle source
     # File lib/bundler/source.rb, line 306
306:       def to_s
307:         "source at #{@path}"
308:       end

Private Instance Methods

generate_bin(spec) click to toggle source
     # File lib/bundler/source.rb, line 419
419:       def generate_bin(spec)
420:         gem_dir  = Pathname.new(spec.full_gem_path)
421: 
422:         # Some gem authors put absolute paths in their gemspec
423:         # and we have to save them from themselves
424:         spec.files = spec.files.map do |p|
425:           next if File.directory?(p)
426:           begin
427:             Pathname.new(p).relative_path_from(gem_dir).to_s
428:           rescue ArgumentError
429:             p
430:           end
431:         end.compact
432: 
433:         gem_file = Dir.chdir(gem_dir){ Gem::Builder.new(spec).build }
434: 
435:         installer = Installer.new(spec, :env_shebang => false)
436:         installer.build_extensions
437:         installer.generate_bin
438:       rescue Gem::InvalidSpecificationException => e
439:         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."
440: 
441:         if !spec.extensions.empty? && !spec.email.empty?
442:           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`."
443:         end
444: 
445:         Bundler.ui.warn "The validation message from Rubygems was:\n  #{e.message}"
446:       ensure
447:         Dir.chdir(gem_dir){ FileUtils.rm_rf(gem_file) if gem_file && File.exist?(gem_file) }
448:       end
relative_path() click to toggle source
     # File lib/bundler/source.rb, line 411
411:       def relative_path
412:         if path.to_s.include?(Bundler.root.to_s)
413:           return path.relative_path_from(Bundler.root)
414:         end
415: 
416:         path
417:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.