Parent

Class Index [+]

Quicksearch

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 309
309:       def self.from_lock(options)
310:         new(options.merge("path" => options.delete("remote")))
311:       end
new(options) click to toggle source
     # File lib/bundler/source.rb, line 285
285:       def initialize(options)
286:         @options = options
287:         @glob = options["glob"] || DEFAULT_GLOB
288: 
289:         @allow_cached = false
290:         @allow_remote = false
291: 
292:         if options["path"]
293:           @path = Pathname.new(options["path"])
294:           @path = @path.expand_path(Bundler.root) unless @path.relative?
295:         end
296: 
297:         @name = options["name"]
298:         @version = options["version"]
299:       end

Public Instance Methods

==(o) click to toggle source
Alias for: eql?
cache(spec) click to toggle source
     # File lib/bundler/source.rb, line 420
420:       def cache(spec)
421:         unless path.expand_path(Bundler.root).to_s.index(Bundler.root.to_s) == 0
422:           Bundler.ui.warn "  * #{spec.name} at `#{path}` will not be cached."
423:         end
424:       end
cached!() click to toggle source
     # File lib/bundler/source.rb, line 305
305:       def cached!
306:         @allow_cached = true
307:       end
eql?(o) click to toggle source
     # File lib/bundler/source.rb, line 328
328:       def eql?(o)
329:         o.instance_of?(Path) &&
330:         path.expand_path(Bundler.root) == o.path.expand_path(Bundler.root) &&
331:         version == o.version
332:       end
Also aliased as: ==
hash() click to toggle source
     # File lib/bundler/source.rb, line 324
324:       def hash
325:         self.class.hash
326:       end
install(spec) click to toggle source
     # File lib/bundler/source.rb, line 408
408:       def install(spec)
409:         Bundler.ui.info "Using #{spec.name} (#{spec.version}) from #{to_s} "
410:         # Let's be honest, when we're working from a path, we can't
411:         # really expect native extensions to work because the whole point
412:         # is to just be able to modify what's in that path and go. So, let's
413:         # not put ourselves through the pain of actually trying to generate
414:         # the full gem.
415:         Installer.new(spec).generate_bin
416:       end
load_spec_files() click to toggle source
     # File lib/bundler/source.rb, line 340
340:       def load_spec_files
341:         index = Index.new
342: 
343:         expanded_path = path.expand_path(Bundler.root)
344: 
345:         if File.directory?(expanded_path)
346:           Dir["#{expanded_path}/#{@glob}"].each do |file|
347:             spec = Bundler.load_gemspec(file)
348:             if spec
349:               spec.loaded_from = file.to_s
350:               spec.source = self
351:               index << spec
352:             end
353:           end
354: 
355:           if index.empty? && @name && @version
356:             index << Gem::Specification.new do |s|
357:               s.name     = @name
358:               s.source   = self
359:               s.version  = Gem::Version.new(@version)
360:               s.platform = Gem::Platform::RUBY
361:               s.summary  = "Fake gemspec for #{@name}"
362:               s.relative_loaded_from = "#{@name}.gemspec"
363:               s.authors  = ["no one"]
364:               if expanded_path.join("bin").exist?
365:                 binaries = expanded_path.join("bin").children
366:                 binaries.reject!{|p| File.directory?(p) }
367:                 s.executables = binaries.map{|c| c.basename.to_s }
368:               end
369:             end
370:           end
371:         else
372:           raise PathError, "The path `#{expanded_path}` does not exist."
373:         end
374: 
375:         index
376:       end
local_specs() click to toggle source
     # File lib/bundler/source.rb, line 378
378:       def local_specs
379:         @local_specs ||= load_spec_files
380:       end
Also aliased as: specs
name() click to toggle source
     # File lib/bundler/source.rb, line 336
336:       def name
337:         File.basename(path.expand_path(Bundler.root).to_s)
338:       end
remote!() click to toggle source
     # File lib/bundler/source.rb, line 301
301:       def remote!
302:         @allow_remote = true
303:       end
specs() click to toggle source
Alias for: local_specs
to_lock() click to toggle source
     # File lib/bundler/source.rb, line 313
313:       def to_lock
314:         out = "PATH\n"
315:         out << "  remote: #{relative_path}\n"
316:         out << "  glob: #{@glob}\n" unless @glob == DEFAULT_GLOB
317:         out << "  specs:\n"
318:       end
to_s() click to toggle source
     # File lib/bundler/source.rb, line 320
320:       def to_s
321:         "source at #{@path}"
322:       end

Private Instance Methods

generate_bin(spec) click to toggle source
     # File lib/bundler/source.rb, line 436
436:       def generate_bin(spec)
437:         gem_dir  = Pathname.new(spec.full_gem_path)
438: 
439:         # Some gem authors put absolute paths in their gemspec
440:         # and we have to save them from themselves
441:         spec.files = spec.files.map do |p|
442:           next if File.directory?(p)
443:           begin
444:             Pathname.new(p).relative_path_from(gem_dir).to_s
445:           rescue ArgumentError
446:             p
447:           end
448:         end.compact
449: 
450:         gem_file = Dir.chdir(gem_dir){ Gem::Builder.new(spec).build }
451: 
452:         installer = Installer.new(spec, :env_shebang => false)
453:         installer.build_extensions
454:         installer.generate_bin
455:       rescue Gem::InvalidSpecificationException => e
456:         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."
457: 
458:         if !spec.extensions.empty? && !spec.email.empty?
459:           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`."
460:         end
461: 
462:         Bundler.ui.warn "The validation message from Rubygems was:\n  #{e.message}"
463:       ensure
464:         Dir.chdir(gem_dir){ FileUtils.rm_rf(gem_file) if gem_file && File.exist?(gem_file) }
465:       end
relative_path() click to toggle source
     # File lib/bundler/source.rb, line 428
428:       def relative_path
429:         if path.to_s.include?(Bundler.root.to_s)
430:           return path.relative_path_from(Bundler.root)
431:         end
432: 
433:         path
434:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.