diff --git a/Gemfile b/Gemfile new file mode 100644 index 00000000..98b96bad --- /dev/null +++ b/Gemfile @@ -0,0 +1,7 @@ +source "http://rubygems.org" +gem "sqlite3-ruby", :require => "sqlite3" +gem "itextomml", ">=1.4.2" +gem "mongrel", ">=1.2.0.pre2" +gem "nokogiri" +gem "rake" +gem "json" diff --git a/bundle b/bundle new file mode 100755 index 00000000..0aba2f43 --- /dev/null +++ b/bundle @@ -0,0 +1,21 @@ +#!/usr/bin/env ruby +# +# This file was generated by RubyGems. +# +# The application 'bundler' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require 'rubygems' +vend = File.join(File.dirname(__FILE__), 'vendor') +Gem.use_paths File.join(vend, 'bundle', File.basename(Gem.dir)), (Gem.path + [File.join(vend, 'plugins', 'bundler')]) + +version = ">= 0" + +if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then + version = $1 + ARGV.shift +end + +gem 'bundler', version +load Gem.bin_path('bundler', 'bundle', version) diff --git a/config/boot.rb b/config/boot.rb index cd21fb9e..7c5c0d46 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -1,7 +1,7 @@ # Don't change this file! # Configure your app in config/environment.rb and config/environments/*.rb -RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT) +RAILS_ROOT = File.join(File.dirname(__FILE__), '..') unless defined?(RAILS_ROOT) module Rails class << self @@ -21,7 +21,7 @@ module Rails end def vendor_rails? - File.exist?("#{RAILS_ROOT}/vendor/rails") + File.exist?(File.join(RAILS_ROOT, 'vendor', 'rails')) end def preinitialize @@ -29,7 +29,7 @@ module Rails end def preinitializer_path - "#{RAILS_ROOT}/config/preinitializer.rb" + File.join(RAILS_ROOT, 'config', 'preinitializer.rb') end end @@ -42,8 +42,9 @@ module Rails class VendorBoot < Boot def load_initializer - require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer" + require File.join(RAILS_ROOT, 'vendor', 'rails', 'railties', 'lib', 'initializer') Rails::Initializer.run(:install_gem_spec_stubs) + Rails::GemDependency.add_frozen_gem_path end end @@ -67,7 +68,7 @@ module Rails class << self def rubygems_version - Gem::RubyGemsVersion if defined? Gem::RubyGemsVersion + Gem::RubyGemsVersion rescue nil end def gem_version @@ -81,15 +82,15 @@ module Rails end def load_rubygems + min_version = '1.3.6' require 'rubygems' - - unless rubygems_version >= '0.9.4' - $stderr.puts %(Rails requires RubyGems >= 0.9.4 (you have #{rubygems_version}). Please `gem update --system` and try again.) + unless rubygems_version >= min_version + $stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.) exit 1 end rescue LoadError - $stderr.puts %(Rails requires RubyGems >= 0.9.4. Please install RubyGems and try again: http://rubygems.rubyforge.org) + $stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org) exit 1 end @@ -99,11 +100,25 @@ module Rails private def read_environment_rb - File.read("#{RAILS_ROOT}/config/environment.rb") + File.read(File.join(RAILS_ROOT, 'config', 'environment.rb')) end end end end +class Rails::Boot + def run + load_initializer + + Rails::Initializer.class_eval do + def load_gems + @bundler_loaded ||= Bundler.require :default, Rails.env + end + end + + Rails::Initializer.run(:set_load_path) + end +end + # All that for this: Rails.boot! diff --git a/config/preinitializer.rb b/config/preinitializer.rb new file mode 100644 index 00000000..d67060aa --- /dev/null +++ b/config/preinitializer.rb @@ -0,0 +1,23 @@ +begin + require "rubygems" + vend = File.join(File.dirname(__FILE__), '..', 'vendor') + Gem.use_paths File.join(vend, 'bundle', File.basename(Gem.dir)), (Gem.path + [File.join(vend, 'plugins', 'bundler')]) + require "bundler" +rescue LoadError + raise "Could not load the bundler gem. Install it with `gem install bundler`." +end + +if Gem::Version.new(Bundler::VERSION) <= Gem::Version.new("0.9.24") + raise RuntimeError, "Your bundler version is too old for Rails 2.3." + + "Run `gem install bundler` to upgrade." +end + +begin + # Set up load paths for all bundled gems + ENV["BUNDLE_GEMFILE"] = File.join(File.dirname(File.dirname(__FILE__)), 'Gemfile') + Bundler.setup +rescue Bundler::GemNotFound + raise RuntimeError, "Bundler couldn't find some gems." + + "Did you run `bundle install`?" +end + diff --git a/vendor/plugins/bundler/bin/bundle b/vendor/plugins/bundler/bin/bundle new file mode 100755 index 00000000..d6bad547 --- /dev/null +++ b/vendor/plugins/bundler/bin/bundle @@ -0,0 +1,21 @@ +#!/usr/bin/env ruby +# +# This file was generated by RubyGems. +# +# The application 'bundler' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require 'rubygems' +Gem.use_paths File.join(File.dirname(File.dirname(__FILE__))), Gem.path +Gem.refresh + +version = ">= 0" + +if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then + version = $1 + ARGV.shift +end + +gem 'bundler', version +load Gem.bin_path('bundler', 'bundle', version) diff --git a/vendor/plugins/bundler/cache/bundler-1.0.0.gem b/vendor/plugins/bundler/cache/bundler-1.0.0.gem new file mode 100644 index 00000000..dab490fc Binary files /dev/null and b/vendor/plugins/bundler/cache/bundler-1.0.0.gem differ diff --git a/vendor/plugins/bundler/doc/bundler-1.0.0/rdoc/Bundler.html b/vendor/plugins/bundler/doc/bundler-1.0.0/rdoc/Bundler.html new file mode 100644 index 00000000..f12c5588 --- /dev/null +++ b/vendor/plugins/bundler/doc/bundler-1.0.0/rdoc/Bundler.html @@ -0,0 +1,1704 @@ + + + +
+ + ++We’re doing this because we might write tests that deal with other +versions of bundler and we are unsure how to handle this better. +
+ # File lib/bundler.rb, line 166 +166: def app_cache +167: root.join("vendor/cache") +168: end+
+ # File lib/bundler.rb, line 160 +160: def app_config_path +161: ENV['BUNDLE_APP_CONFIG'] ? +162: Pathname.new(ENV['BUNDLE_APP_CONFIG']).expand_path(root) : +163: root.join('.bundle') +164: end+
+ # File lib/bundler.rb, line 86 +86: def bin_path +87: @bin_path ||= begin +88: path = settings[:bin] || "bin" +89: path = Pathname.new(path).expand_path(root) +90: FileUtils.mkdir_p(path) +91: Pathname.new(path).expand_path +92: end +93: end+
+ # File lib/bundler.rb, line 81 +81: def bundle_path +82: # STDERR.puts settings.path +83: @bundle_path ||= Pathname.new(settings.path).expand_path(root) +84: end+
+ # File lib/bundler.rb, line 152 +152: def cache +153: bundle_path.join("cache/bundler") +154: end+
+ # File lib/bundler.rb, line 70 +70: def configure +71: @configured ||= begin +72: configure_gem_home_and_path +73: true +74: end +75: end+
+ # File lib/bundler.rb, line 186 +186: def default_gemfile +187: SharedHelpers.default_gemfile +188: end+
+ # File lib/bundler.rb, line 190 +190: def default_lockfile +191: SharedHelpers.default_lockfile +192: end+
+ # File lib/bundler.rb, line 123 +123: def definition(unlock = nil) +124: @definition = nil if unlock +125: @definition ||= begin +126: configure +127: upgrade_lockfile +128: Definition.build(default_gemfile, default_lockfile, unlock) +129: end +130: end+
+ # File lib/bundler.rb, line 119 +119: def environment +120: Bundler::Environment.new(root, definition) +121: end+
+ # File lib/bundler.rb, line 140 +140: def home +141: bundle_path.join("bundler") +142: end+
+ # File lib/bundler.rb, line 144 +144: def install_path +145: home.join("gems") +146: end+
+ # File lib/bundler.rb, line 115 +115: def load +116: @load ||= Runtime.new(root, definition) +117: end+
+ # File lib/bundler.rb, line 218 +218: def load_gemspec(file) +219: path = Pathname.new(file) +220: # Eval the gemspec from its parent directory +221: Dir.chdir(path.dirname) do +222: begin +223: Gem::Specification.from_yaml(path.basename) +224: # Raises ArgumentError if the file is not valid YAML +225: rescue ArgumentError, SyntaxError, Gem::EndOfYAMLException, Gem::Exception +226: begin +227: eval(File.read(path.basename), TOPLEVEL_BINDING, path.expand_path.to_s) +228: rescue LoadError => e +229: original_line = e.backtrace.find { |line| line.include?(path.to_s) } +230: msg = "There was a LoadError while evaluating #{path.basename}:\n #{e.message}" +231: msg << " from\n #{original_line}" if original_line +232: msg << "\n" +233: +234: if RUBY_VERSION >= "1.9.0" +235: msg << "\nDoes it try to require a relative path? That doesn't work in Ruby 1.9." +236: end +237: +238: raise GemspecError, msg +239: end +240: end +241: end +242: end+
+ # File lib/bundler.rb, line 202 +202: def mkdir_p(path) +203: if requires_sudo? +204: sudo "mkdir -p '#{path}'" unless File.exist?(path) +205: else +206: FileUtils.mkdir_p(path) +207: end +208: end+
+ # File lib/bundler.rb, line 214 +214: def read_file(file) +215: File.open(file, "rb") { |file| file.read } +216: end+
+ # File lib/bundler.rb, line 111 +111: def require(*groups) +112: setup(*groups).require(*groups) +113: end+
+ # File lib/bundler.rb, line 194 +194: def requires_sudo? +195: path = bundle_path +196: path = path.parent until path.exist? +197: sudo_present = !`which sudo 2>#{NULL}`.empty? +198: +199: settings.allow_sudo? && !File.writable?(path) && sudo_present +200: end+
+ # File lib/bundler.rb, line 156 +156: def root +157: default_gemfile.dirname.expand_path +158: end+
+ # File lib/bundler.rb, line 132 +132: def ruby_scope +133: "#{Gem.ruby_engine}/#{Gem::ConfigMap[:ruby_version]}" +134: end+
+ # File lib/bundler.rb, line 174 +174: def settings +175: @settings ||= Settings.new(app_config_path) +176: end+
+ # File lib/bundler.rb, line 95 + 95: def setup(*groups) + 96: return @setup if defined?(@setup) && @setup + 97: + 98: if groups.empty? + 99: # Load all groups, but only once +100: @setup = load.setup +101: else +102: # Figure out which groups haven't been loaded yet +103: unloaded = groups - (@completed_groups || []) +104: # Record groups that are now loaded +105: @completed_groups = groups | (@completed_groups || []) +106: # Load any groups that are not yet loaded +107: unloaded.any? ? load.setup(*unloaded) : load +108: end +109: end+
+ # File lib/bundler.rb, line 148 +148: def specs_path +149: bundle_path.join("specifications") +150: end+
+ # File lib/bundler.rb, line 210 +210: def sudo(str) +211: `sudo -p 'Enter your password to install the bundled RubyGems to your system: ' #{str}` +212: end+
+ # File lib/bundler.rb, line 170 +170: def tmp +171: user_bundle_path.join("tmp", Process.pid.to_s) +172: end+
+ # File lib/bundler.rb, line 77 +77: def ui +78: @ui ||= UI.new +79: end+
+ # File lib/bundler.rb, line 246 +246: def configure_gem_home_and_path +247: if settings[:disable_shared_gems] +248: ENV['GEM_PATH'] = '' +249: ENV['GEM_HOME'] = File.expand_path(bundle_path, root) +250: elsif Gem.dir != bundle_path.to_s +251: paths = [Gem.dir, Gem.path].flatten.compact.uniq.reject{|p| p.empty? } +252: ENV["GEM_PATH"] = paths.join(File::PATH_SEPARATOR) +253: ENV["GEM_HOME"] = bundle_path.to_s +254: end +255: +256: Gem.clear_paths +257: end+
+ # File lib/bundler.rb, line 259 +259: def upgrade_lockfile +260: lockfile = default_lockfile +261: if lockfile.exist? && lockfile.read(3) == "---" +262: Bundler.ui.warn "Detected Gemfile.lock generated by 0.9, deleting..." +263: lockfile.rmtree +264: # lock = YAML.load_file(lockfile) +265: # +266: # source_uris = lock["sources"].map{|s| s["Rubygems"]["uri"] } +267: # sources = [Bundler::Source::Rubygems.new({"remotes" => source_uris})] +268: # +269: # deps = lock["dependencies"].map do |name, opts| +270: # version = opts.delete("version") +271: # Bundler::Dependency.new(name, version, opts) +272: # end +273: # +274: # definition = Bundler::Definition.new(nil, deps, sources, {}) +275: # +276: # File.open(lockfile, 'w') do |f| +277: # f.write definition.to_lock +278: # end +279: end +280: end+
Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
+StandardError
+ +Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
++ # File lib/bundler/cli.rb, line 13 +13: def initialize(*) +14: super +15: use_shell = options["no-color"] ? Thor::Shell::Basic.new : shell +16: +17: Bundler.ui = UI::Shell.new(use_shell) +18: Gem::DefaultUserInteraction.ui = UI::RGProxy.new(Bundler.ui) +19: end+
+ # File lib/bundler/cli.rb, line 289 +289: def cache +290: Bundler.definition.resolve_with_cache! +291: Bundler.load.cache +292: Bundler.settings[:no_prune] = true if options[:no_prune] +293: Bundler.load.lock +294: rescue GemNotFound => e +295: Bundler.ui.error(e.message) +296: Bundler.ui.warn "Run `bundle install` to install missing gems." +297: exit 128 +298: end+
+ # File lib/bundler/cli.rb, line 98 + 98: def check + 99: ENV['BUNDLE_GEMFILE'] = File.expand_path(options[:gemfile]) if options[:gemfile] +100: begin +101: not_installed = Bundler.definition.missing_specs +102: rescue GemNotFound, VersionConflict +103: Bundler.ui.error "Your Gemfile's dependencies could not be satisfied" +104: Bundler.ui.warn "Install missing gems with `bundle install`" +105: exit 1 +106: end +107: +108: if not_installed.any? +109: Bundler.ui.error "The following gems are missing" +110: not_installed.each { |s| Bundler.ui.error " * #{s.name} (#{s.version})" } +111: Bundler.ui.warn "Install missing gems with `bundle install`" +112: exit 1 +113: else +114: Bundler.load.lock +115: Bundler.ui.info "The Gemfile's dependencies are satisfied" +116: end +117: end+
+ # File lib/bundler/cli.rb, line 351 +351: def config(name = nil, *args) +352: values = ARGV.dup +353: values.shift # remove config +354: values.shift # remove the name +355: +356: unless name +357: Bundler.ui.confirm "Settings are listed in order of priority. The top value will be used.\n" +358: +359: Bundler.settings.all.each do |setting| +360: Bundler.ui.confirm "#{setting}" +361: with_padding do +362: Bundler.settings.pretty_values_for(setting).each do |line| +363: Bundler.ui.info line +364: end +365: end +366: Bundler.ui.confirm "" +367: end +368: return +369: end +370: +371: if values.empty? +372: Bundler.ui.confirm "Settings for `#{name}` in order of priority. The top value will be used" +373: with_padding do +374: Bundler.settings.pretty_values_for(name).each { |line| Bundler.ui.info line } +375: end +376: else +377: locations = Bundler.settings.locations(name) +378: +379: if local = locations[:local] +380: Bundler.ui.info "Your application has set #{name} to #{local.inspect}. This will override the " "system value you are currently setting" +381: end +382: +383: if global = locations[:global] +384: Bundler.ui.info "You are replacing the current system value of #{name}, which is currently #{global}" +385: end +386: +387: if env = locations[:env] +388: Bundler.ui.info "You have set a bundler environment variable for #{env}. This will take precedence " "over the system value you are setting" +389: end +390: +391: Bundler.settings.set_global(name, values.join(" ")) +392: end +393: end+
+ # File lib/bundler/cli.rb, line 410 +410: def console(group = nil) +411: require 'bundler/setup' +412: group ? Bundler.require(:default, group) : Bundler.require +413: ARGV.clear +414: +415: require 'irb' +416: IRB.start +417: end+
+ # File lib/bundler/cli.rb, line 321 +321: def exec(*) +322: ARGV.delete("exec") +323: +324: Bundler.setup +325: +326: begin +327: # Run +328: Kernel.exec(*ARGV) +329: rescue Errno::EACCES +330: Bundler.ui.error "bundler: not executable: #{ARGV.first}" +331: exit 126 +332: rescue Errno::ENOENT +333: Bundler.ui.error "bundler: command not found: #{ARGV.first}" +334: Bundler.ui.warn "Install missing gem binaries with `bundle install`" +335: exit 127 +336: end +337: end+
+ # File lib/bundler/cli.rb, line 456 +456: def gem(name) +457: target = File.join(Dir.pwd, name) +458: if File.exist?(name) +459: Bundler.ui.error "File already exists at #{File.join(Dir.pwd, name)}" +460: exit 1 +461: end +462: +463: constant_name = name.split('_').map{|p| p.capitalize}.join +464: constant_name = constant_name.split('-').map{|q| q.capitalize}.join('::') if constant_name =~ /-/ +465: constant_array = constant_name.split('::') +466: FileUtils.mkdir_p(File.join(target, 'lib', name)) +467: opts = {:name => name, :constant_name => constant_name, :constant_array => constant_array} +468: template(File.join('newgem', 'Gemfile.tt'), File.join(target, 'Gemfile'), opts) +469: template(File.join('newgem', 'Rakefile.tt'), File.join(target, 'Rakefile'), opts) +470: template(File.join('newgem', 'gitignore.tt'), File.join(target, '.gitignore'), opts) +471: template(File.join('newgem', 'newgem.gemspec.tt'), File.join(target, "#{name}.gemspec"), opts) +472: template(File.join('newgem', 'lib', 'newgem.rb.tt'), File.join(target, 'lib', "#{name}.rb"), opts) +473: template(File.join('newgem', 'lib', 'newgem', 'version.rb.tt'), File.join(target, 'lib', name, 'version.rb'), opts) +474: Bundler.ui.info "Initializating git repo in #{target}" +475: Dir.chdir(target) { `git init`; `git add .` } +476: end+
+ # File lib/bundler/cli.rb, line 26 +26: def help(cli = nil) +27: case cli +28: when "gemfile" then command = "gemfile.5" +29: when nil then command = "bundle" +30: else command = "bundle-#{cli}" +31: end +32: +33: manpages = %( +34: bundle +35: bundle-config +36: bundle-exec +37: bundle-install +38: bundle-package +39: bundle-update +40: gemfile.5) +41: +42: if manpages.include?(command) +43: root = File.expand_path("../man", __FILE__) +44: +45: if have_groff? +46: groff = "groff -Wall -mtty-char -mandoc -Tascii" +47: pager = ENV['MANPAGER'] || ENV['PAGER'] || 'more' +48: +49: Kernel.exec "#{groff} #{root}/#{command} | #{pager}" +50: else +51: puts File.read("#{root}/#{command}.txt") +52: end +53: else +54: super +55: end +56: end+
+ # File lib/bundler/cli.rb, line 65 +65: def init +66: opts = options.dup +67: if File.exist?("Gemfile") +68: Bundler.ui.error "Gemfile already exists at #{Dir.pwd}/Gemfile" +69: exit 1 +70: end +71: +72: if opts[:gemspec] +73: gemspec = File.expand_path(opts[:gemspec]) +74: unless File.exist?(gemspec) +75: Bundler.ui.error "Gem specification #{gemspec} doesn't exist" +76: exit 1 +77: end +78: spec = Gem::Specification.load(gemspec) +79: puts "Writing new Gemfile to #{Dir.pwd}/Gemfile" +80: File.open('Gemfile', 'wb') do |file| +81: file << "# Generated from #{gemspec}\n" +82: file << spec.to_gemfile +83: end +84: else +85: puts "Writing new Gemfile to #{Dir.pwd}/Gemfile" +86: FileUtils.cp(File.expand_path('../templates/Gemfile', __FILE__), 'Gemfile') +87: end +88: end+
+ # File lib/bundler/cli.rb, line 156 +156: def install(path = nil) +157: opts = options.dup +158: opts[:without] ||= [] +159: opts[:without].map! { |g| g.to_sym } +160: +161: +162: ENV['BUNDLE_GEMFILE'] = File.expand_path(opts[:gemfile]) if opts[:gemfile] +163: +164: if opts[:production] +165: opts[:deployment] = true +166: Bundler.ui.warn "The --production option is deprecated, and will be removed in " "the final release of Bundler 1.0. Please use --deployment instead." +167: end +168: +169: if (path || opts[:path] || opts[:deployment]) && opts[:system] +170: Bundler.ui.error "You have specified both a path to install your gems to, \n" "as well as --system. Please choose." +171: exit 1 +172: end +173: +174: if path && opts[:path] +175: Bundler.ui.error "You have specified a path via `bundle install #{path}` as well as\n" "by `bundle install --path #{options[:path]}`. These options are\n" "equivalent, so please use one or the other." +176: exit 1 +177: end +178: +179: if opts["disable-shared-gems"] +180: Bundler.ui.error "The disable-shared-gem option is no longer available.\n\n" "Instead, use `bundle install` to install to your system,\n" "or `bundle install --path path/to/gems` to install to an isolated\n" "location. Bundler will resolve relative paths relative to\n" "your `Gemfile`." +181: exit 1 +182: end +183: +184: if opts[:deployment] || opts[:frozen] +185: Bundler.settings[:frozen] = '1' +186: +187: unless Bundler.default_lockfile.exist? +188: flag = opts[:deployment] ? '--deployment' : '--frozen' +189: raise ProductionError, "The #{flag} flag requires a Gemfile.lock. Please make " "sure you have checked your Gemfile.lock into version control " "before deploying." +190: end +191: +192: if Bundler.root.join("vendor/cache").exist? +193: opts[:local] = true +194: end +195: end +196: +197: # Can't use Bundler.settings for this because settings needs gemfile.dirname +198: Bundler.settings[:path] = nil if opts[:system] +199: Bundler.settings[:path] = "vendor/bundle" if opts[:deployment] +200: Bundler.settings[:path] = path if path +201: Bundler.settings[:path] = opts[:path] if opts[:path] +202: Bundler.settings[:bin] = opts["binstubs"] if opts[:binstubs] +203: Bundler.settings[:disable_shared_gems] = '1' if Bundler.settings[:path] +204: Bundler.settings.without = opts[:without] +205: Bundler.ui.be_quiet! if opts[:quiet] +206: +207: Installer.install(Bundler.root, Bundler.definition, opts) +208: Bundler.load.cache if Bundler.root.join("vendor/cache").exist? +209: Bundler.ui.confirm "Your bundle is complete! " + +210: "Use `bundle show [gemname]` to see where a bundled gem is installed." +211: +212: Bundler.ui.confirm "\nYour bundle was installed to `#{Bundler.settings[:path]}`" if Bundler.settings[:path] +213: +214: if path +215: Bundler.ui.warn "\nIf you meant to install it to your system, please remove the\n" "`#{path}` directory and run `bundle install --system`" +216: end +217: rescue GemNotFound => e +218: if Bundler.definition.no_sources? +219: Bundler.ui.warn "Your Gemfile doesn't have any sources. You can add one with a line like 'source :gemcutter'" +220: end +221: raise e +222: end+
+ # File lib/bundler/cli.rb, line 259 +259: def lock +260: Bundler.ui.warn "Lock is deprecated. Your bundle is now locked whenever you run `bundle install`." +261: end+
+ # File lib/bundler/cli.rb, line 398 +398: def open(name) +399: editor = [ENV['BUNDLER_EDITOR'], ENV['VISUAL'], ENV['EDITOR']].find{|e| !e.nil? && !e.empty? } +400: if editor +401: command = "#{editor} #{locate_gem(name)}" +402: success = system(command) +403: Bundler.ui.info "Could not run '#{command}'" unless success +404: else +405: Bundler.ui.info("To open a bundled gem, set $EDITOR or $BUNDLER_EDITOR") +406: end +407: end+
+ # File lib/bundler/cli.rb, line 308 +308: def package +309: install +310: # TODO: move cache contents here now that all bundles are locked +311: Bundler.load.cache +312: end+
+ # File lib/bundler/cli.rb, line 273 +273: def show(gem_name = nil) +274: Bundler.load.lock +275: +276: if gem_name +277: Bundler.ui.info locate_gem(gem_name) +278: else +279: Bundler.ui.info "Gems included by the bundle:" +280: Bundler.load.specs.sort_by { |s| s.name }.each do |s| +281: Bundler.ui.info " * #{s.name} (#{s.version}#{s.git_version})" +282: end +283: end +284: end+
+ # File lib/bundler/cli.rb, line 264 +264: def unlock +265: Bundler.ui.warn "Unlock is deprecated. To update to newer gem versions, use `bundle update`." +266: end+
+ # File lib/bundler/cli.rb, line 242 +242: def update(*gems) +243: sources = Array(options[:source]) +244: +245: if gems.empty? && sources.empty? +246: # We're doing a full update +247: Bundler.definition(true) +248: else +249: Bundler.definition(:gems => gems, :sources => sources) +250: end +251: +252: Installer.install Bundler.root, Bundler.definition, "update" => true +253: Bundler.load.cache if Bundler.root.join("vendor/cache").exist? +254: Bundler.ui.confirm "Your bundle is updated! " + +255: "Use `bundle show [gemname]` to see where a bundled gem is installed." +256: end+
+ # File lib/bundler/cli.rb, line 420 +420: def version +421: Bundler.ui.info "Bundler version #{Bundler::VERSION}" +422: end+
+ # File lib/bundler/cli.rb, line 434 +434: def viz +435: output_file = File.expand_path(options[:file]) +436: graph = Graph.new( Bundler.load ) +437: +438: begin +439: graph.viz(output_file, options[:version], options[:requirements]) +440: Bundler.ui.info output_file +441: rescue LoadError => e +442: Bundler.ui.error e.inspect +443: Bundler.ui.warn "Make sure you have the graphviz ruby gem. You can install it with:" +444: Bundler.ui.warn "`gem install ruby-graphviz`" +445: rescue StandardError => e +446: if e.message =~ /GraphViz not installed or dot not in PATH/ +447: Bundler.ui.error e.message +448: Bundler.ui.warn "The ruby graphviz gem requires GraphViz to be installed" +449: else +450: raise +451: end +452: end +453: end+
+ # File lib/bundler/cli.rb, line 484 +484: def have_groff? +485: `which groff 2>#{NULL}` +486: $? == 0 +487: end+
+ # File lib/bundler/cli.rb, line 489 +489: def locate_gem(name) +490: spec = Bundler.load.specs.find{|s| s.name == name } +491: raise GemNotFound, "Could not find gem '#{name}' in the current bundle." unless spec +492: if spec.name == 'bundler' +493: return File.expand_path('../../../', __FILE__) +494: end +495: spec.full_gem_path +496: end+
Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
+Object
+ ++ # File lib/bundler/definition.rb, line 9 + 9: def self.build(gemfile, lockfile, unlock) +10: unlock ||= {} +11: gemfile = Pathname.new(gemfile).expand_path +12: +13: unless gemfile.file? +14: raise GemfileNotFound, "#{gemfile} not found" +15: end +16: +17: # TODO: move this back into DSL +18: builder = Dsl.new +19: builder.instance_eval(Bundler.read_file(gemfile.to_s), gemfile.to_s, 1) +20: builder.to_definition(lockfile, unlock) +21: end+
+ # File lib/bundler/definition.rb, line 35 +35: def initialize(lockfile, dependencies, sources, unlock) +36: @dependencies, @sources, @unlock = dependencies, sources, unlock +37: @remote = false +38: @specs = nil +39: @lockfile_contents = "" +40: +41: if lockfile && File.exists?(lockfile) +42: @lockfile_contents = Bundler.read_file(lockfile) +43: locked = LockfileParser.new(@lockfile_contents) +44: @platforms = locked.platforms +45: +46: if unlock != true +47: @locked_deps = locked.dependencies +48: @locked_specs = SpecSet.new(locked.specs) +49: @locked_sources = locked.sources +50: else +51: @unlock = {} +52: @locked_deps = [] +53: @locked_specs = SpecSet.new([]) +54: @locked_sources = [] +55: end +56: else +57: @unlock = {} +58: @platforms = [] +59: @locked_deps = [] +60: @locked_specs = SpecSet.new([]) +61: @locked_sources = [] +62: end +63: +64: @unlock[:gems] ||= [] +65: @unlock[:sources] ||= [] +66: +67: current_platform = Gem.platforms.map { |p| generic(p) }.compact.last +68: @new_platform = !@platforms.include?(current_platform) +69: @platforms |= [current_platform] +70: +71: eager_unlock = expand_dependencies(@unlock[:gems]) +72: @unlock[:gems] = @locked_specs.for(eager_unlock).map { |s| s.name } +73: +74: converge_sources +75: converge_dependencies +76: end+
+ # File lib/bundler/definition.rb, line 130 +130: def current_dependencies +131: dependencies.reject { |d| !d.should_include? } +132: end+
+ # File lib/bundler/definition.rb, line 230 +230: def ensure_equivalent_gemfile_and_lockfile +231: changes = false +232: +233: msg = "You have modified your Gemfile in development but did not check\n" "the resulting snapshot (Gemfile.lock) into version control" +234: +235: added = [] +236: deleted = [] +237: changed = [] +238: +239: if @locked_sources != @sources +240: new_sources = @sources - @locked_sources +241: deleted_sources = @locked_sources - @sources +242: +243: if new_sources.any? +244: added.concat new_sources.map { |source| "* source: #{source}" } +245: end +246: +247: if deleted_sources.any? +248: deleted.concat deleted_sources.map { |source| "* source: #{source}" } +249: end +250: +251: changes = true +252: end +253: +254: both_sources = Hash.new { |h,k| h[k] = ["no specified source", "no specified source"] } +255: @dependencies.each { |d| both_sources[d.name][0] = d.source if d.source } +256: @locked_deps.each { |d| both_sources[d.name][1] = d.source if d.source } +257: both_sources.delete_if { |k,v| v[0] == v[1] } +258: +259: if @dependencies != @locked_deps +260: new_deps = @dependencies - @locked_deps +261: deleted_deps = @locked_deps - @dependencies +262: +263: if new_deps.any? +264: added.concat new_deps.map { |d| "* #{pretty_dep(d)}" } +265: end +266: +267: if deleted_deps.any? +268: deleted.concat deleted_deps.map { |d| "* #{pretty_dep(d)}" } +269: end +270: +271: both_sources.each do |name, sources| +272: changed << "* #{name} from `#{sources[0]}` to `#{sources[1]}`" +273: end +274: +275: changes = true +276: end +277: +278: msg << "\n\nYou have added to the Gemfile:\n" << added.join("\n") if added.any? +279: msg << "\n\nYou have deleted from the Gemfile:\n" << deleted.join("\n") if deleted.any? +280: msg << "\n\nYou have changed in the Gemfile:\n" << changed.join("\n") if changed.any? +281: +282: raise ProductionError, msg if added.any? || deleted.any? || changed.any? +283: end+
+ # File lib/bundler/definition.rb, line 170 +170: def groups +171: dependencies.map { |d| d.groups }.flatten.uniq +172: end+
+ # File lib/bundler/definition.rb, line 158 +158: def index +159: @index ||= Index.build do |idx| +160: @sources.each do |s| +161: idx.use s.specs +162: end +163: end +164: end+
+ # File lib/bundler/definition.rb, line 174 +174: def lock(file) +175: contents = to_lock +176: +177: return if @lockfile_contents == contents +178: +179: if Bundler.settings[:frozen] +180: # TODO: Warn here if we got here. +181: return +182: end +183: +184: File.open(file, 'wb') do |f| +185: f.puts contents +186: end +187: end+
+ # File lib/bundler/definition.rb, line 116 +116: def missing_specs +117: missing = [] +118: resolve.materialize(requested_dependencies, missing) +119: missing +120: end+
+ # File lib/bundler/definition.rb, line 112 +112: def new_platform? +113: @new_platform +114: end+
+ # File lib/bundler/definition.rb, line 104 +104: def new_specs +105: specs - @locked_specs +106: end+
+ # File lib/bundler/definition.rb, line 166 +166: def no_sources? +167: @sources.length == 1 && @sources.first.remotes.empty? +168: end+
+ # File lib/bundler/definition.rb, line 108 +108: def removed_specs +109: @locked_specs - specs +110: end+
+ # File lib/bundler/definition.rb, line 122 +122: def requested_specs +123: @requested_specs ||= begin +124: groups = self.groups - Bundler.settings.without +125: groups.map! { |g| g.to_sym } +126: specs_for(groups) +127: end +128: end+
+ # File lib/bundler/definition.rb, line 140 +140: def resolve +141: @resolve ||= begin +142: if Bundler.settings[:frozen] +143: @locked_specs +144: else +145: last_resolve = converge_locked_specs +146: source_requirements = {} +147: dependencies.each do |dep| +148: next unless dep.source +149: source_requirements[dep.name] = dep.source.specs +150: end +151: +152: # Run a resolve against the locally available gems +153: last_resolve.merge Resolver.resolve(expanded_dependencies, index, source_requirements, last_resolve) +154: end +155: end +156: end+
+ # File lib/bundler/definition.rb, line 84 +84: def resolve_remotely! +85: raise "Specs already loaded" if @specs +86: @remote = true +87: @sources.each { |s| s.remote! } +88: specs +89: end+
+ # File lib/bundler/definition.rb, line 78 +78: def resolve_with_cache! +79: raise "Specs already loaded" if @specs +80: @sources.each { |s| s.cached! } +81: specs +82: end+
+ # File lib/bundler/definition.rb, line 91 + 91: def specs + 92: @specs ||= begin + 93: specs = resolve.materialize(requested_dependencies) + 94: + 95: unless specs["bundler"].any? + 96: bundler = index.search(Gem::Dependency.new('bundler', VERSION)).last + 97: specs["bundler"] = bundler if bundler + 98: end + 99: +100: specs +101: end +102: end+
+ # File lib/bundler/definition.rb, line 134 +134: def specs_for(groups) +135: deps = dependencies.select { |d| (d.groups & groups).any? } +136: deps.delete_if { |d| !d.should_include? } +137: specs.for(expand_dependencies(deps)) +138: end+
+ # File lib/bundler/definition.rb, line 189 +189: def to_lock +190: out = "" +191: +192: sorted_sources.each do |source| +193: # Add the source header +194: out << source.to_lock +195: # Find all specs for this source +196: resolve. +197: select { |s| s.source == source }. +198: # This needs to be sorted by full name so that +199: # gems with the same name, but different platform +200: # are ordered consistantly +201: sort_by { |s| s.full_name }. +202: each do |spec| +203: next if spec.name == 'bundler' +204: out << spec.to_lock +205: end +206: out << "\n" +207: end +208: +209: out << "PLATFORMS\n" +210: +211: platforms.map { |p| p.to_s }.sort.each do |p| +212: out << " #{p}\n" +213: end +214: +215: out << "\n" +216: out << "DEPENDENCIES\n" +217: +218: handled = [] +219: dependencies. +220: sort_by { |d| d.name }. +221: each do |dep| +222: next if handled.include?(dep.name) +223: out << dep.to_lock +224: handled << dep.name +225: end +226: +227: out +228: end+
+ # File lib/bundler/definition.rb, line 312 +312: def converge_dependencies +313: (@dependencies + @locked_deps).each do |dep| +314: if dep.source +315: dep.source = @sources.find { |s| dep.source == s } +316: end +317: end +318: end+
+Remove elements from the locked specs that are expired. This will most +commonly happen if the Gemfile has changed since the lockfile was last +generated +
+ + + ++ # File lib/bundler/definition.rb, line 323 +323: def converge_locked_specs +324: deps = [] +325: +326: # Build a list of dependencies that are the same in the Gemfile +327: # and Gemfile.lock. If the Gemfile modified a dependency, but +328: # the gem in the Gemfile.lock still satisfies it, this is fine +329: # too. +330: @dependencies.each do |dep| +331: locked_dep = @locked_deps.find { |d| dep == d } +332: +333: if in_locked_deps?(dep, locked_dep) || satisfies_locked_spec?(dep) +334: deps << dep +335: elsif dep.source.is_a?(Source::Path) && (!locked_dep || dep.source != locked_dep.source) +336: @locked_specs.each do |s| +337: @unlock[:gems] << s.name if s.source == dep.source +338: end +339: +340: dep.source.unlock! if dep.source.respond_to?(:unlock!) +341: dep.source.specs.each { |s| @unlock[:gems] << s.name } +342: end +343: end +344: +345: converged = [] +346: @locked_specs.each do |s| +347: s.source = @sources.find { |src| s.source == src } +348: +349: # Don't add a spec to the list if its source is expired. For example, +350: # if you change a Git gem to Rubygems. +351: next if s.source.nil? || @unlock[:sources].include?(s.name) +352: # If the spec is from a path source and it doesn't exist anymore +353: # then we just unlock it. +354: +355: # Path sources have special logic +356: if s.source.instance_of?(Source::Path) +357: other = s.source.specs[s].first +358: +359: # If the spec is no longer in the path source, unlock it. This +360: # commonly happens if the version changed in the gemspec +361: next unless other +362: # If the dependencies of the path source have changed, unlock it +363: next unless s.dependencies.sort == other.dependencies.sort +364: end +365: +366: converged << s +367: end +368: +369: resolve = SpecSet.new(converged) +370: resolve = resolve.for(expand_dependencies(deps, true), @unlock[:gems]) +371: diff = @locked_specs.to_a - resolve.to_a +372: +373: # Now, we unlock any sources that do not have anymore gems pinned to it +374: @sources.each do |source| +375: next unless source.respond_to?(:unlock!) +376: +377: unless resolve.any? { |s| s.source == source } +378: source.unlock! if diff.any? { |s| s.source == source } +379: end +380: end +381: +382: resolve +383: end+
+ # File lib/bundler/definition.rb, line 295 +295: def converge_sources +296: locked_gem = @locked_sources.find { |s| Source::Rubygems === s } +297: actual_gem = @sources.find { |s| Source::Rubygems === s } +298: +299: if locked_gem && actual_gem +300: locked_gem.merge_remotes actual_gem +301: end +302: +303: @sources.map! do |source| +304: @locked_sources.find { |s| s == source } || source +305: end +306: +307: @sources.each do |source| +308: source.unlock! if source.respond_to?(:unlock!) && @unlock[:sources].include?(source.name) +309: end +310: end+
+ # File lib/bundler/definition.rb, line 397 +397: def expand_dependencies(dependencies, remote = false) +398: deps = [] +399: dependencies.each do |dep| +400: dep = Dependency.new(dep, ">= 0") unless dep.respond_to?(:name) +401: dep.gem_platforms(@platforms).each do |p| +402: deps << DepProxy.new(dep, p) if remote || p == generic(Gem::Platform.local) +403: end +404: end +405: deps +406: end+
+ # File lib/bundler/definition.rb, line 393 +393: def expanded_dependencies +394: @expanded_dependencies ||= expand_dependencies(dependencies, @remote) +395: end+
+ # File lib/bundler/definition.rb, line 385 +385: def in_locked_deps?(dep, d) +386: d && dep.source == d.source +387: end+
+ # File lib/bundler/definition.rb, line 288 +288: def pretty_dep(dep, source = false) +289: msg = "#{dep.name}" +290: msg << " (#{dep.requirement})" unless dep.requirement == Gem::Requirement.default +291: msg << " from the `#{dep.source}` source" if source && dep.source +292: msg +293: end+
+ # File lib/bundler/definition.rb, line 415 +415: def requested_dependencies +416: groups = self.groups - Bundler.settings.without +417: groups.map! { |g| g.to_sym } +418: dependencies.reject { |d| !d.should_include? || (d.groups & groups).empty? } +419: end+
Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
+Object
+ ++ # File lib/bundler/rubygems_ext.rb, line 147 +147: def ==(o) +148: dep == o.dep && __platform == o.__platform +149: end+
+ # File lib/bundler/rubygems_ext.rb, line 143 +143: def hash +144: @hash ||= dep.hash +145: end+
Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
++ # File lib/bundler/dependency.rb, line 22 +22: def initialize(name, version, options = {}, &blk) +23: super(name, version) +24: +25: @autorequire = nil +26: @groups = Array(options["group"] || :default).map { |g| g.to_sym } +27: @source = options["source"] +28: @platforms = Array(options["platforms"]) +29: @env = options["env"] +30: +31: if options.key?('require') +32: @autorequire = Array(options['require'] || []) +33: end +34: end+
+ # File lib/bundler/dependency.rb, line 52 +52: def current_env? +53: return true unless @env +54: if Hash === @env +55: @env.all? do |key, val| +56: ENV[key.to_s] && (String === val ? ENV[key.to_s] == val : ENV[key.to_s] =~ val) +57: end +58: else +59: ENV[@env.to_s] +60: end +61: end+
+ # File lib/bundler/dependency.rb, line 63 +63: def current_platform? +64: return true if @platforms.empty? +65: @platforms.any? { |p| send("#{p}?") } +66: end+
+ # File lib/bundler/dependency.rb, line 36 +36: def gem_platforms(valid_platforms) +37: return valid_platforms if @platforms.empty? +38: +39: platforms = [] +40: @platforms.each do |p| +41: platform = PLATFORM_MAP[p] +42: next unless valid_platforms.include?(platform) +43: platforms |= [platform] +44: end +45: platforms +46: end+
+ # File lib/bundler/dependency.rb, line 48 +48: def should_include? +49: current_env? && current_platform? +50: end+
+ # File lib/bundler/dependency.rb, line 68 +68: def to_lock +69: out = " #{name}" +70: +71: unless requirement == Gem::Requirement.default +72: out << " (#{requirement.to_s})" +73: end +74: +75: out << '!' if source +76: +77: out << "\n" +78: end+
+ # File lib/bundler/dependency.rb, line 106 +106: def jruby? +107: defined?(RUBY_ENGINE) && RUBY_ENGINE == "jruby" +108: end+
+ # File lib/bundler/dependency.rb, line 94 +94: def mri? +95: !mswin? && (!defined?(RUBY_ENGINE) || RUBY_ENGINE == "ruby") +96: end+
+ # File lib/bundler/dependency.rb, line 98 + 98: def mri_18? + 99: mri? && RUBY_VERSION < "1.9" +100: end+
+ # File lib/bundler/dependency.rb, line 102 +102: def mri_19? +103: mri? && RUBY_VERSION >= "1.9" +104: end+
+ # File lib/bundler/dependency.rb, line 110 +110: def mswin? +111: # w0t? +112: end+
+ # File lib/bundler/dependency.rb, line 82 +82: def ruby? +83: !mswin? && (!defined?(RUBY_ENGINE) || RUBY_ENGINE == "ruby" || RUBY_ENGINE == "rbx") +84: end+
Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
+Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
+Object
+ ++Deprecated methods +
+ + + ++ # File lib/bundler/dsl.rb, line 148 +148: def self.deprecate(name, replacement = nil) +149: define_method(name) do |*| +150: message = "'#{name}' has been removed from the Gemfile DSL, " +151: if replacement +152: message << "and has been replaced with '#{replacement}'." +153: else +154: message << "and is no longer supported." +155: end +156: message << "\nSee the README for more information on upgrading from Bundler 0.8." +157: raise DeprecatedError, message +158: end +159: end+
+ # File lib/bundler/dsl.rb, line 5 +5: def self.evaluate(gemfile) +6: builder = new +7: builder.instance_eval(Bundler.read_file(gemfile.to_s), gemfile.to_s, 1) +8: builder.to_definition +9: end+
+ # File lib/bundler/dsl.rb, line 13 +13: def initialize +14: @rubygems_source = Source::Rubygems.new +15: @source = nil +16: @sources = [] +17: @dependencies = [] +18: @groups = [] +19: @platforms = [] +20: @env = nil +21: end+
+ # File lib/bundler/dsl.rb, line 139 +139: def env(name) +140: @env, old = name, @env +141: yield +142: ensure +143: @env = old +144: end+
+ # File lib/bundler/dsl.rb, line 49 +49: def gem(name, *args) +50: if name.is_a?(Symbol) +51: raise GemfileError, %{You need to specify gem names as Strings. Use 'gem "#{name.to_s}"' instead.} +52: end +53: +54: options = Hash === args.last ? args.pop : {} +55: version = args || [">= 0"] +56: if group = options[:groups] || options[:group] +57: options[:group] = group +58: end +59: +60: _deprecated_options(options) +61: _normalize_options(name, version, options) +62: +63: dep = Dependency.new(name, version, options) +64: +65: if current = @dependencies.find { |d| d.name == dep.name } +66: if current.requirement != dep.requirement +67: raise DslError, "You cannot specify the same gem twice with different version requirements. " "You specified: #{current.name} (#{current.requirement}) and " "#{dep.name} (#{dep.requirement})" +68: end +69: +70: if current.source != dep.source +71: raise DslError, "You cannot specify the same gem twice coming from different sources. You " "specified that #{dep.name} (#{dep.requirement}) should come from " "#{current.source || 'an unspecfied source'} and #{dep.source}" +72: end +73: end +74: @dependencies << Dependency.new(name, version, options) +75: end+
+ # File lib/bundler/dsl.rb, line 23 +23: def gemspec(opts = nil) +24: path = opts && opts[:path] || '.' +25: name = opts && opts[:name] || '*' +26: development_group = opts && opts[:development_group] || :development +27: path = File.expand_path(path, Bundler.default_gemfile.dirname) +28: gemspecs = Dir[File.join(path, "#{name}.gemspec")] +29: +30: case gemspecs.size +31: when 1 +32: spec = Gem::Specification.load(gemspecs.first) +33: gem spec.name, :path => path +34: spec.runtime_dependencies.each do |dep| +35: gem dep.name, dep.requirement.to_s +36: end +37: group(development_group) do +38: spec.development_dependencies.each do |dep| +39: gem dep.name, dep.requirement.to_s +40: end +41: end +42: when 0 +43: raise InvalidOption, "There are no gemspecs at #{path}." +44: else +45: raise InvalidOption, "There are multiple gemspecs at #{path}. Please use the :name option to specify which one." +46: end +47: end+
+ # File lib/bundler/dsl.rb, line 104 +104: def git(uri, options = {}, source_options = {}, &blk) +105: unless block_given? +106: msg = "You can no longer specify a git source by itself. Instead, \n" "either use the :git option on a gem, or specify the gems that \n" "bundler should find in the git source by passing a block to \n" "the git method, like: \n\n" " git 'git://github.com/rails/rails.git' do\n" " gem 'rails'\n" " end" +107: raise DeprecatedError, msg +108: end +109: +110: source Source::Git.new(_normalize_hash(options).merge("uri" => uri)), source_options, &blk +111: end+
+ # File lib/bundler/dsl.rb, line 125 +125: def group(*args, &blk) +126: @groups.concat args +127: yield +128: ensure +129: args.each { @groups.pop } +130: end+
+ # File lib/bundler/dsl.rb, line 100 +100: def path(path, options = {}, source_options = {}, &blk) +101: source Source::Path.new(_normalize_hash(options).merge("path" => Pathname.new(path))), source_options, &blk +102: end+
+ # File lib/bundler/dsl.rb, line 132 +132: def platforms(*platforms) +133: @platforms.concat platforms +134: yield +135: ensure +136: platforms.each { @platforms.pop } +137: end+
+ # File lib/bundler/dsl.rb, line 81 +81: def source(source, options = {}) +82: case source +83: when :gemcutter, :rubygems, :rubyforge then +84: rubygems_source "http://rubygems.org" +85: return +86: when String +87: rubygems_source source +88: return +89: end +90: +91: @source = source +92: options[:prepend] ? @sources.unshift(@source) : @sources << @source +93: +94: yield if block_given? +95: @source +96: ensure +97: @source = nil +98: end+
+ # File lib/bundler/dsl.rb, line 119 +119: def to_definition(lockfile, unlock) +120: @sources << @rubygems_source +121: @sources.uniq! +122: Definition.new(lockfile, @dependencies, @sources, unlock) +123: end+
+ # File lib/bundler/dsl.rb, line 233 +233: def _deprecated_options(options) +234: if options.include?(:require_as) +235: raise DeprecatedError, "Please replace :require_as with :require" +236: elsif options.include?(:vendored_at) +237: raise DeprecatedError, "Please replace :vendored_at with :path" +238: elsif options.include?(:only) +239: raise DeprecatedError, "Please replace :only with :group" +240: elsif options.include?(:except) +241: raise DeprecatedError, "The :except option is no longer supported" +242: end +243: end+
+ # File lib/bundler/dsl.rb, line 176 +176: def _normalize_hash(opts) +177: # Cannot modify a hash during an iteration in 1.9 +178: opts.keys.each do |k| +179: next if String === k +180: v = opts[k] +181: opts.delete(k) +182: opts[k.to_s] = v +183: end +184: opts +185: end+
+ # File lib/bundler/dsl.rb, line 187 +187: def _normalize_options(name, version, opts) +188: _normalize_hash(opts) +189: +190: invalid_keys = opts.keys - %(group git path name branch ref tag require submodules platforms) +191: if invalid_keys.any? +192: plural = invalid_keys.size > 1 +193: message = "You passed #{invalid_keys.map{|k| ':'+k }.join(", ")} " +194: if plural +195: message << "as options for gem '#{name}', but they are invalid." +196: else +197: message << "as an option for gem '#{name}', but it is invalid." +198: end +199: raise InvalidOption, message +200: end +201: +202: groups = @groups.dup +203: groups.concat Array(opts.delete("group")) +204: groups = [:default] if groups.empty? +205: +206: platforms = @platforms.dup +207: platforms.concat Array(opts.delete("platforms")) +208: platforms.map! { |p| p.to_sym } +209: platforms.each do |p| +210: next if VALID_PLATFORMS.include?(p) +211: raise DslError, "`#{p}` is not a valid platform. The available options are: #{VALID_PLATFORMS.inspect}" +212: end +213: +214: # Normalize git and path options +215: ["git", "path"].each do |type| +216: if param = opts[type] +217: if version.first && version.first =~ /^\s*=?\s*(\d[^\s]*)\s*$/ +218: options = opts.merge("name" => name, "version" => $1) +219: else +220: options = opts.dup +221: end +222: source = send(type, param, options, :prepend => true) {} +223: opts["source"] = source +224: end +225: end +226: +227: opts["source"] ||= @source +228: opts["env"] ||= @env +229: opts["platforms"] = @platforms.dup +230: opts["group"] = groups +231: end+
Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
+Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
+Object
+ ++ # File lib/bundler/environment.rb, line 5 + 5: def initialize(root, definition) + 6: @root = root + 7: @definition = definition + 8: + 9: env_file = Bundler.app_config_path.join('environment.rb') +10: env_file.rmtree if env_file.exist? +11: end+
+ # File lib/bundler/environment.rb, line 34 +34: def current_dependencies +35: @definition.current_dependencies +36: end+
+ # File lib/bundler/environment.rb, line 30 +30: def dependencies +31: @definition.dependencies +32: end+
+TODO: Remove this method. It’s used in cli.rb still +
+ + + ++ # File lib/bundler/environment.rb, line 18 +18: def index +19: @definition.index +20: end+
+ # File lib/bundler/environment.rb, line 13 +13: def inspect +14: @definition.to_lock.inspect +15: end+
+ # File lib/bundler/environment.rb, line 38 +38: def lock +39: @definition.lock(Bundler.default_lockfile) +40: end+
+ # File lib/bundler/environment.rb, line 22 +22: def requested_specs +23: @definition.requested_specs +24: end+
Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
+Object
+ ++ # File lib/bundler/gem_helper.rb, line 7 + 7: def self.install_tasks(opts = nil) + 8: dir = caller.find{|c| /Rakefile:/}[/^(.*?)\/Rakefile:/, 1] + 9: GemHelper.new(dir, opts && opts[:name]).install +10: end+
+ # File lib/bundler/gem_helper.rb, line 14 +14: def initialize(base, name = nil) +15: Bundler.ui = UI::Shell.new(Thor::Shell::Color.new) +16: @base = base +17: gemspecs = name ? [File.join(base, "#{name}.gemspec")] : Dir[File.join(base, "*.gemspec")] +18: raise "Unable to determine name from existing gemspec. Use :name => 'gemname' in #install_tasks to manually set it." unless gemspecs.size == 1 +19: @spec_path = gemspecs.first +20: @gemspec = Bundler.load_gemspec(@spec_path) +21: end+
+ # File lib/bundler/gem_helper.rb, line 40 +40: def build_gem +41: file_name = nil +42: sh("gem build #{spec_path}") { |out, err| +43: raise err if err[/ERROR/] +44: file_name = File.basename(built_gem_path) +45: FileUtils.mkdir_p(File.join(base, 'pkg')) +46: FileUtils.mv(built_gem_path, 'pkg') +47: Bundler.ui.confirm "#{name} #{version} built to pkg/#{file_name}" +48: } +49: File.join(base, 'pkg', file_name) +50: end+
+ # File lib/bundler/gem_helper.rb, line 23 +23: def install +24: desc "Build #{name}-#{version}.gem into the pkg directory" +25: task 'build' do +26: build_gem +27: end +28: +29: desc "Build and install #{name}-#{version}.gem into system gems" +30: task 'install' do +31: install_gem +32: end +33: +34: desc "Create tag #{version_tag} and build and push #{name}-#{version}.gem to Rubygems" +35: task 'release' do +36: release_gem +37: end +38: end+
+ # File lib/bundler/gem_helper.rb, line 52 +52: def install_gem +53: built_gem_path = build_gem +54: out, err, code = sh_with_code("gem install #{built_gem_path}") +55: if err[/ERROR/] +56: Bundler.ui.error err +57: else +58: Bundler.ui.confirm "#{name} (#{version}) installed" +59: end +60: end+
+ # File lib/bundler/gem_helper.rb, line 62 +62: def release_gem +63: guard_clean +64: guard_already_tagged +65: built_gem_path = build_gem +66: tag_version { +67: git_push +68: rubygem_push(built_gem_path) +69: } +70: end+
+ # File lib/bundler/gem_helper.rb, line 78 +78: def built_gem_path +79: Dir[File.join(base, "#{name}-*.gem")].sort_by{|f| File.mtime(f)}.last +80: end+
+ # File lib/bundler/gem_helper.rb, line 103 +103: def clean? +104: sh("git ls-files -dm").split("\n").size.zero? +105: end+
+ # File lib/bundler/gem_helper.rb, line 82 +82: def git_push +83: perform_git_push +84: perform_git_push ' --tags' +85: Bundler.ui.confirm "Pushed git commits and tags" +86: end+
+ # File lib/bundler/gem_helper.rb, line 93 +93: def guard_already_tagged +94: if sh('git tag').split(/\n/).include?(version_tag) +95: raise("This tag has already been committed to the repo.") +96: end +97: end+
+ # File lib/bundler/gem_helper.rb, line 99 + 99: def guard_clean +100: clean? or raise("There are files that need to be committed first.") +101: end+
+ # File lib/bundler/gem_helper.rb, line 129 +129: def name +130: gemspec.name +131: end+
+ # File lib/bundler/gem_helper.rb, line 88 +88: def perform_git_push(options = '') +89: out, err, code = sh_with_code "git push --quiet#{options}" +90: raise err unless err == '' +91: end+
+ # File lib/bundler/gem_helper.rb, line 73 +73: def rubygem_push(path) +74: sh("gem push #{path}") +75: Bundler.ui.confirm "Pushed #{name} #{version} to rubygems.org" +76: end+
+ # File lib/bundler/gem_helper.rb, line 133 +133: def sh(cmd, &block) +134: out, err, code = sh_with_code(cmd, &block) +135: code == 0 ? out : raise(out.empty? ? err : out) +136: end+
+ # File lib/bundler/gem_helper.rb, line 138 +138: def sh_with_code(cmd, &block) +139: outbuf, errbuf = '', '' +140: Dir.chdir(base) { +141: stdin, stdout, stderr = *Open3.popen3(cmd) +142: if $? == 0 +143: outbuf, errbuf = stdout.read, stderr.read +144: block.call(outbuf, errbuf) if block +145: end +146: } +147: [outbuf, errbuf, $?] +148: end+
+ # File lib/bundler/gem_helper.rb, line 107 +107: def tag_version +108: sh "git tag -am 'Version #{version}' #{version_tag}" +109: Bundler.ui.confirm "Tagged #{tagged_sha} with #{version_tag}" +110: yield if block_given? +111: rescue +112: Bundler.ui.error "Untagged #{tagged_sha} with #{version_tag} due to error" +113: sh "git tag -d #{version_tag}" +114: raise +115: end+
+ # File lib/bundler/gem_helper.rb, line 117 +117: def tagged_sha +118: sh("git show-ref --tags #{version_tag}").split(' ').first[0, 8] +119: end+
Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
++ # File lib/bundler/rubygems_ext.rb, line 179 +179: def generic(p) +180: if p == Gem::Platform::RUBY +181: return p +182: end +183: +184: GENERIC_CACHE[p] ||= GENERICS.find { |p2| p =~ p2 } || Gem::Platform::RUBY +185: end+
Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
+Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
+Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
+Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
+Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
+Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
+Object
+ ++ # File lib/bundler/graph.rb, line 15 +15: def groups +16: populate +17: @groups +18: end+
+ # File lib/bundler/graph.rb, line 10 +10: def nodes +11: populate +12: @nodes +13: end+
+ # File lib/bundler/graph.rb, line 20 +20: def viz(output_file, show_gem_versions = false, show_dependency_requirements = false) +21: require 'graphviz' +22: populate +23: +24: graph_viz = GraphViz::new('Gemfile', {:concentrate => true, :dpi => 65 } ) +25: graph_viz.edge[:fontname] = graph_viz.node[:fontname] = 'Arial, Helvetica, SansSerif' +26: graph_viz.edge[:fontsize] = 12 +27: +28: viz_nodes = {} +29: +30: # populate all of the nodes +31: nodes.each do |name, node| +32: label = name.dup +33: label << "\n#{node.version}" if show_gem_versions +34: options = { :label => label } +35: options.merge!( USER_OPTIONS ) if node.is_user +36: viz_nodes[name] = graph_viz.add_node( name, options ) +37: end +38: +39: group_nodes = {} +40: @groups.each do |name, dependencies| +41: group_nodes[name] = graph_viz.add_node(name.to_s, { :shape => 'folder', :fontsize => 16 }.merge(USER_OPTIONS)) +42: dependencies.each do |dependency| +43: options = { :weight => 2 } +44: if show_dependency_requirements && (dependency.requirement.to_s != ">= 0") +45: options[:label] = dependency.requirement.to_s +46: end +47: graph_viz.add_edge( group_nodes[name], viz_nodes[dependency.name], options ) +48: end +49: end +50: +51: @groups.keys.select { |group| group != :default }.each do |group| +52: graph_viz.add_edge( group_nodes[group], group_nodes[:default], { :weight => 2 } ) +53: end +54: +55: viz_nodes.each do |name, node| +56: nodes[name].dependencies.each do |dependency| +57: options = { } +58: if nodes[dependency.name].is_user +59: options[:constraint] = false +60: end +61: if show_dependency_requirements && (dependency.requirement.to_s != ">= 0") +62: options[:label] = dependency.requirement.to_s +63: end +64: +65: graph_viz.add_edge( node, viz_nodes[dependency.name], options ) +66: end +67: end +68: +69: graph_viz.output( :png => output_file ) +70: end+
+ # File lib/bundler/graph.rb, line 74 + 74: def populate + 75: return if @populated + 76: + 77: # hash of name => GraphNode + 78: @nodes = {} + 79: @groups = {} + 80: + 81: # Populate @nodes + 82: @env.specs.each { |spec| @nodes[spec.name] = GraphNode.new(spec.name, spec.version) } + 83: + 84: # For gems in Gemfile, add details + 85: @env.current_dependencies.each do |dependency| + 86: node = @nodes[dependency.name] + 87: node.is_user = true + 88: + 89: dependency.groups.each do |group| + 90: if @groups.has_key? group + 91: group = @groups[group] + 92: else + 93: group = @groups[group] = [] + 94: end + 95: group << dependency + 96: end + 97: end + 98: + 99: # walk though a final time and add edges +100: @env.specs.each do |spec| +101: +102: from = @nodes[spec.name] +103: spec.runtime_dependencies.each do |dependency| +104: from.dependencies << dependency +105: end +106: +107: end +108: +109: @nodes.freeze +110: @groups.freeze +111: @populated = true +112: end+
Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
+Object
+ ++Add version info +
+ +Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
+Object
+ ++ # File lib/bundler/index.rb, line 58 +58: def <<(spec) +59: arr = @specs[spec.name] +60: +61: arr.delete_if do |s| +62: s.version == spec.version && s.platform == spec.platform +63: end +64: +65: arr << spec +66: spec +67: end+
+ # File lib/bundler/index.rb, line 84 +84: def ==(o) +85: all? do |s| +86: s2 = o[s].first and (s.dependencies & s2.dependencies).empty? +87: end +88: end+
+ # File lib/bundler/index.rb, line 69 +69: def each(&blk) +70: @specs.values.each do |specs| +71: specs.each(&blk) +72: end +73: end+
+ # File lib/bundler/index.rb, line 23 +23: def empty? +24: each { return false } +25: true +26: end+
+ # File lib/bundler/index.rb, line 16 +16: def initialize_copy(o) +17: super +18: @cache = {} +19: @specs = Hash.new { |h,k| h[k] = [] } +20: merge!(o) +21: end+
+ # File lib/bundler/index.rb, line 28 +28: def search(query) +29: case query +30: when Gem::Specification, RemoteSpecification, LazySpecification then search_by_spec(query) +31: when String then @specs[query] +32: else search_by_dependency(query) +33: end +34: end+
+ # File lib/bundler/index.rb, line 36 +36: def search_for_all_platforms(dependency, base = []) +37: specs = @specs[dependency.name] + base +38: +39: wants_prerelease = dependency.requirement.prerelease? +40: only_prerelease = specs.all? {|spec| spec.version.prerelease? } +41: found = specs.select { |spec| dependency =~ spec } +42: +43: unless wants_prerelease || only_prerelease +44: found.reject! { |spec| spec.version.prerelease? } +45: end +46: +47: found.sort_by {|s| [s.version, s.platform.to_s == 'ruby' ? "\00"" : s.platform.to_s] } +48: end+
+ # File lib/bundler/index.rb, line 98 + 98: def search_by_dependency(dependency) + 99: @cache[dependency.hash] ||= begin +100: specs = @specs[dependency.name] +101: +102: wants_prerelease = dependency.requirement.prerelease? +103: only_prerelease = specs.all? {|spec| spec.version.prerelease? } +104: found = specs.select { |spec| dependency =~ spec && Gem::Platform.match(spec.platform) } +105: +106: unless wants_prerelease || only_prerelease +107: found.reject! { |spec| spec.version.prerelease? } +108: end +109: +110: found.sort_by {|s| [s.version, s.platform.to_s == 'ruby' ? "\00"" : s.platform.to_s] } +111: end +112: end+
+ # File lib/bundler/index.rb, line 92 +92: def search_by_spec(spec) +93: @specs[spec.name].select do |s| +94: s.version == spec.version && Gem::Platform.new(s.platform) == Gem::Platform.new(spec.platform) +95: end +96: end+
Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
++ # File lib/bundler/installer.rb, line 12 +12: def run(options) +13: if Bundler.settings[:frozen] +14: @definition.ensure_equivalent_gemfile_and_lockfile +15: end +16: +17: if dependencies.empty? +18: Bundler.ui.warn "The Gemfile specifies no dependencies" +19: return +20: end +21: +22: if Bundler.default_lockfile.exist? && !options["update"] +23: begin +24: tmpdef = Definition.build(Bundler.default_gemfile, Bundler.default_lockfile, nil) +25: local = true unless tmpdef.new_platform? || tmpdef.missing_specs.any? +26: rescue BundlerError +27: end +28: end +29: +30: # Since we are installing, we can resolve the definition +31: # using remote specs +32: unless local +33: options["local"] ? +34: @definition.resolve_with_cache! : +35: @definition.resolve_remotely! +36: end +37: +38: # Ensure that BUNDLE_PATH exists +39: Bundler.mkdir_p(Bundler.bundle_path) unless File.exist?(Bundler.bundle_path) +40: +41: # Must install gems in the order that the resolver provides +42: # as dependencies might actually affect the installation of +43: # the gem. +44: specs.each do |spec| +45: spec.source.fetch(spec) if spec.source.respond_to?(:fetch) +46: +47: # unless requested_specs.include?(spec) +48: # Bundler.ui.debug " * Not in requested group; skipping." +49: # next +50: # end +51: +52: begin +53: old_args = Gem::Command.build_args +54: Gem::Command.build_args = [Bundler.settings["build.#{spec.name}"]] +55: spec.source.install(spec) +56: ensure +57: Gem::Command.build_args = old_args +58: end +59: +60: Bundler.ui.info "" +61: generate_bundler_executable_stubs(spec) if Bundler.settings[:bin] +62: FileUtils.rm_rf(Bundler.tmp) +63: end +64: +65: lock +66: end+
+ # File lib/bundler/installer.rb, line 70 +70: def generate_bundler_executable_stubs(spec) +71: bin_path = Bundler.bin_path +72: template = File.read(File.expand_path('../templates/Executable', __FILE__)) +73: relative_gemfile_path = Bundler.default_gemfile.relative_path_from(bin_path) +74: +75: spec.executables.each do |executable| +76: next if executable == "bundle" +77: File.open "#{bin_path}/#{executable}", 'w', 0755 do |f| +78: f.puts ERB.new(template, nil, '-').result(binding) +79: end +80: end +81: end+
Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
+Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
+StandardError
+ ++Internal errors, should be rescued +
+ +Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
+Object
+ ++ # File lib/bundler/lazy_specification.rb, line 11 +11: def initialize(name, version, platform, source = nil) +12: @name = name +13: @version = version +14: @dependencies = [] +15: @platform = platform +16: @source = source +17: @specification = nil +18: end+
+ # File lib/bundler/lazy_specification.rb, line 47 +47: def __materialize__ +48: @specification = source.specs.search(Gem::Dependency.new(name, version)).last +49: end+
+ # File lib/bundler/lazy_specification.rb, line 20 +20: def full_name +21: if platform == Gem::Platform::RUBY or platform.nil? then +22: "#{@name}-#{@version}" +23: else +24: "#{@name}-#{@version}-#{platform}" +25: end +26: end+
+ # File lib/bundler/lazy_specification.rb, line 51 +51: def respond_to?(*args) +52: super || @specification.respond_to?(*args) +53: end+
+ # File lib/bundler/lazy_specification.rb, line 28 +28: def satisfies?(dependency) +29: @name == dependency.name && dependency.requirement.satisfied_by?(Gem::Version.new(@version)) +30: end+
+ # File lib/bundler/lazy_specification.rb, line 32 +32: def to_lock +33: if platform == Gem::Platform::RUBY or platform.nil? +34: out = " #{name} (#{version})\n" +35: else +36: out = " #{name} (#{version}-#{platform})\n" +37: end +38: +39: dependencies.sort_by {|d| d.name }.each do |dep| +40: next if dep.type == :development +41: out << " #{dep.to_lock}\n" +42: end +43: +44: out +45: end+
+ # File lib/bundler/lazy_specification.rb, line 61 +61: def method_missing(method, *args, &blk) +62: if Gem::Specification.new.respond_to?(method) +63: raise "LazySpecification has not been materialized yet (calling :#{method} #{args.inspect})" unless @specification +64: @specification.send(method, *args, &blk) +65: else +66: super +67: end +68: end+
Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
+Object
+ ++ # File lib/bundler/lockfile_parser.rb, line 7 + 7: def initialize(lockfile) + 8: @platforms = [] + 9: @sources = [] +10: @dependencies = [] +11: @specs = [] +12: @state = :source +13: +14: lockfile.split(/\n+/).each do |line| +15: if line == "DEPENDENCIES" +16: @state = :dependency +17: elsif line == "PLATFORMS" +18: @state = :platform +19: else +20: send("parse_#{@state}", line) +21: end +22: end +23: end+
+ # File lib/bundler/lockfile_parser.rb, line 61 +61: def parse_dependency(line) +62: if line =~ %{^ {2}#{NAME_VERSION}(!)?$} +63: name, version, pinned = $1, $2, $4 +64: version = version.split(",").map { |d| d.strip } if version +65: +66: dep = Bundler::Dependency.new(name, version) +67: +68: if pinned && dep.name != 'bundler' +69: spec = @specs.find { |s| s.name == dep.name } +70: dep.source = spec.source if spec +71: +72: # Path sources need to know what the default name / version +73: # to use in the case that there are no gemspecs present. A fake +74: # gemspec is created based on the version set on the dependency +75: # TODO: Use the version from the spec instead of from the dependency +76: if version && version.size == 1 && version.first =~ /^\s*= (.+)\s*$/ && dep.source.is_a?(Bundler::Source::Path) +77: dep.source.name = name +78: dep.source.version = $1 +79: end +80: end +81: +82: @dependencies << dep +83: end +84: end+
+ # File lib/bundler/lockfile_parser.rb, line 101 +101: def parse_platform(line) +102: if line =~ /^ (.*)$/ +103: @platforms << Gem::Platform.new($1) +104: end +105: end+
+ # File lib/bundler/lockfile_parser.rb, line 33 +33: def parse_source(line) +34: case line +35: when "GIT", "GEM", "PATH" +36: @current_source = nil +37: @opts, @type = {}, line +38: when " specs:" +39: @current_source = TYPES[@type].from_lock(@opts) +40: @sources << @current_source +41: when /^ ([a-z]+): (.*)$/ +42: value = $2 +43: value = true if value == "true" +44: value = false if value == "false" +45: +46: key = $1 +47: +48: if @opts[key] +49: @opts[key] = Array(@opts[key]) +50: @opts[key] << value +51: else +52: @opts[key] = value +53: end +54: else +55: parse_spec(line) +56: end +57: end+
+ # File lib/bundler/lockfile_parser.rb, line 86 +86: def parse_spec(line) +87: if line =~ %{^ {4}#{NAME_VERSION}$} +88: name, version = $1, Gem::Version.new($2) +89: platform = $3 ? Gem::Platform.new($3) : Gem::Platform::RUBY +90: @current_spec = LazySpecification.new(name, version, platform) +91: @current_spec.source = @current_source +92: @specs << @current_spec +93: elsif line =~ %{^ {6}#{NAME_VERSION}$} +94: name, version = $1, $2 +95: version = version.split(',').map { |d| d.strip } if version +96: dep = Gem::Dependency.new(name, version) +97: @current_spec.dependencies << dep +98: end +99: end+
Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
++ # File lib/bundler/rubygems_ext.rb, line 191 +191: def match_platform(p) +192: Gem::Platform::RUBY == platform or +193: platform.nil? or p == platform or +194: generic(Gem::Platform.new(platform)) == p +195: end+
Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
+Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
+Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
+Object
+ ++Represents a lazily loaded gem specification, where the full specification +is on the source server in rubygems’ “quick” index. The +proxy object is to be seeded with what we’re given from the +source’s abbreviated index - the full specification will only be +fetched when necesary. +
+ ++ # File lib/bundler/remote_specification.rb, line 15 +15: def initialize(name, version, platform, source_uri) +16: @name = name +17: @version = version +18: @platform = platform +19: @source_uri = source_uri +20: end+
+Because Rubyforge cannot be trusted to provide valid specifications once +the remote gem is downloaded, the backend specification will be swapped +out. +
+ + + ++ # File lib/bundler/remote_specification.rb, line 39 +39: def __swap__(spec) +40: @specification = spec +41: end+
+Needed before installs, since the arch matters then and quick specs +don’t bother to include the arch in the platform string +
+ + + ++ # File lib/bundler/remote_specification.rb, line 24 +24: def fetch_platform +25: @platform = _remote_specification.platform +26: end+
+ # File lib/bundler/remote_specification.rb, line 28 +28: def full_name +29: if platform == Gem::Platform::RUBY or platform.nil? then +30: "#{@name}-#{@version}" +31: else +32: "#{@name}-#{@version}-#{platform}" +33: end +34: end+
+ # File lib/bundler/remote_specification.rb, line 45 +45: def _remote_specification +46: @specification ||= begin +47: Gem::SpecFetcher.new.fetch_spec([@name, @version, @platform], URI(@source_uri.to_s)) +48: end +49: end+
+ # File lib/bundler/remote_specification.rb, line 51 +51: def method_missing(method, *args, &blk) +52: if Gem::Specification.new.respond_to?(method) +53: _remote_specification.send(method, *args, &blk) +54: else +55: super +56: end +57: end+
Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
+Object
+ ++ # File lib/bundler/resolver.rb, line 138 +138: def initialize(index, source_requirements, base) +139: @errors = {} +140: @stack = [] +141: @base = base +142: @index = index +143: @missing_gems = Hash.new(0) +144: @source_requirements = source_requirements +145: end+
+Figures out the best possible configuration of gems that satisfies the list +of passed dependencies and any child dependencies without causing any gem +activation errors. +
+*dependencies | +The list of dependencies to resolve + + |
+If the list of dependencies can be resolved, a + + |
+ collection of gemspecs is returned. Otherwise, nil is returned.+ + + +
+ # File lib/bundler/resolver.rb, line 127 +127: def self.resolve(requirements, index, source_requirements = {}, base = []) +128: base = SpecSet.new(base) unless base.is_a?(SpecSet) +129: resolver = new(index, source_requirements, base) +130: result = catch(:success) do +131: resolver.start(requirements) +132: raise resolver.version_conflict +133: nil +134: end +135: SpecSet.new(result) +136: end+
+ # File lib/bundler/resolver.rb, line 378 +378: def clean_req(req) +379: if req.to_s.include?(">= 0") +380: req.to_s.gsub(/ \(.*?\)$/, '') +381: else +382: req.to_s.gsub(/\, (runtime|development)\)$/, ')') +383: end +384: end+
+ # File lib/bundler/resolver.rb, line 147 +147: def debug +148: if ENV['DEBUG_RESOLVER'] +149: debug_info = yield +150: debug_info = debug_info.inpsect unless debug_info.is_a?(String) +151: $stderr.puts debug_info +152: end +153: end+
+ # File lib/bundler/resolver.rb, line 405 +405: def error_message +406: output = errors.inject("") do |o, (conflict, (origin, requirement))| +407: +408: # origin is the SpecSet of specs from the Gemfile that is conflicted with +409: if origin +410: +411: o << %{Bundler could not find compatible versions for gem "#{origin.name}":\n} +412: o << " In Gemfile:\n" +413: +414: o << gem_message(requirement) +415: +416: # If the origin is a LockfileParser, it does not respond_to :required_by +417: unless origin.respond_to?(:required_by) && required_by = origin.required_by.first +418: o << " In snapshot (Gemfile.lock):\n" +419: end +420: +421: o << gem_message(origin) +422: +423: # origin is nil if the required gem and version cannot be found in any of +424: # the specified sources +425: else +426: +427: # if the gem cannot be found because of a version conflict between lockfile and gemfile, +428: # print a useful error that suggests running `bundle update`, which may fix things +429: # +430: # @base is a SpecSet of the gems in the lockfile +431: # conflict is the name of the gem that could not be found +432: if locked = @base[conflict].first +433: o << "Bundler could not find compatible versions for gem #{conflict.inspect}:\n" +434: o << " In snapshot (Gemfile.lock):\n" +435: o << " #{clean_req(locked)}\n\n" +436: +437: o << " In Gemfile:\n" +438: o << gem_message(requirement) +439: o << "Running `bundle update` will rebuild your snapshot from scratch, using only\n" +440: o << "the gems in your Gemfile, which may resolve the conflict.\n" +441: +442: # the rest of the time, the gem cannot be found because it does not exist in the known sources +443: else +444: if requirement.required_by.first +445: o << "Could not find gem '#{clean_req(requirement)}', required by '#{clean_req(requirement.required_by.first)}', in any of the sources\n" +446: else +447: o << "Could not find gem '#{clean_req(requirement)} in any of the sources\n" +448: end +449: end +450: +451: end +452: end +453: end+
+For a given conflicted requirement, print out what exactly went wrong +
+ + + ++ # File lib/bundler/resolver.rb, line 391 +391: def gem_message(requirement) +392: m = "" +393: +394: # A requirement that is required by itself is actually in the Gemfile, and does +395: # not "depend on" itself +396: if requirement.required_by.first && requirement.required_by.first.name != requirement.name +397: m << " #{clean_req(requirement.required_by.first)} depends on\n" +398: m << " #{clean_req(requirement)}\n" +399: else +400: m << " #{clean_req(requirement)}\n" +401: end +402: m << "\n" +403: end+
+ # File lib/bundler/resolver.rb, line 165 +165: def resolve(reqs, activated) +166: # If the requirements are empty, then we are in a success state. Aka, all +167: # gem dependencies have been resolved. +168: throw :success, successify(activated) if reqs.empty? +169: +170: debug { print "\e[2J\e[f" ; "==== Iterating ====\n\n" } +171: +172: # Sort dependencies so that the ones that are easiest to resolve are first. +173: # Easiest to resolve is defined by: +174: # 1) Is this gem already activated? +175: # 2) Do the version requirements include prereleased gems? +176: # 3) Sort by number of gems available in the source. +177: reqs = reqs.sort_by do |a| +178: [ activated[a.name] ? 0 : 1, +179: a.requirement.prerelease? ? 0 : 1, +180: @errors[a.name] ? 0 : 1, +181: activated[a.name] ? 0 : search(a).size ] +182: end +183: +184: debug { "Activated:\n" + activated.values.map { |a| " #{a.name} (#{a.version})" }.join("\n") } +185: debug { "Requirements:\n" + reqs.map { |r| " #{r.name} (#{r.requirement})"}.join("\n") } +186: +187: activated = activated.dup +188: +189: # Pull off the first requirement so that we can resolve it +190: current = reqs.shift +191: +192: debug { "Attempting:\n #{current.name} (#{current.requirement})"} +193: +194: # Check if the gem has already been activated, if it has, we will make sure +195: # that the currently activated gem satisfies the requirement. +196: existing = activated[current.name] +197: if existing || current.name == 'bundler' +198: # Force the current +199: if current.name == 'bundler' && !existing +200: existing = search(DepProxy.new(Gem::Dependency.new('bundler', VERSION), Gem::Platform::RUBY)).first +201: activated['bundler'] = existing +202: raise GemNotFound, %{Bundler could not find gem "bundler" (#{VERSION})} unless existing +203: end +204: +205: if current.requirement.satisfied_by?(existing.version) +206: debug { " * [SUCCESS] Already activated" } +207: @errors.delete(existing.name) +208: # Since the current requirement is satisfied, we can continue resolving +209: # the remaining requirements. +210: +211: # I have no idea if this is the right way to do it, but let's see if it works +212: # The current requirement might activate some other platforms, so let's try +213: # adding those requirements here. +214: reqs.concat existing.activate_platform(current.__platform) +215: +216: resolve(reqs, activated) +217: else +218: debug { " * [FAIL] Already activated" } +219: @errors[existing.name] = [existing, current] +220: debug { current.required_by.map {|d| " * #{d.name} (#{d.requirement})" }.join("\n") } +221: # debug { " * All current conflicts:\n" + @errors.keys.map { |c| " - #{c}" }.join("\n") } +222: # Since the current requirement conflicts with an activated gem, we need +223: # to backtrack to the current requirement's parent and try another version +224: # of it (maybe the current requirement won't be present anymore). If the +225: # current requirement is a root level requirement, we need to jump back to +226: # where the conflicting gem was activated. +227: parent = current.required_by.last +228: # `existing` could not respond to required_by if it is part of the base set +229: # of specs that was passed to the resolver (aka, instance of LazySpecification) +230: parent ||= existing.required_by.last if existing.respond_to?(:required_by) +231: # We track the spot where the current gem was activated because we need +232: # to keep a list of every spot a failure happened. +233: debug { " -> Jumping to: #{parent.name}" } +234: if parent +235: throw parent.name, existing.respond_to?(:required_by) && existing.required_by.last.name +236: else +237: # The original set of dependencies conflict with the base set of specs +238: # passed to the resolver. This is by definition an impossible resolve. +239: raise version_conflict +240: end +241: end +242: else +243: # There are no activated gems for the current requirement, so we are going +244: # to find all gems that match the current requirement and try them in decending +245: # order. We also need to keep a set of all conflicts that happen while trying +246: # this gem. This is so that if no versions work, we can figure out the best +247: # place to backtrack to. +248: conflicts = Set.new +249: +250: # Fetch all gem versions matching the requirement +251: # +252: # TODO: Warn / error when no matching versions are found. +253: matching_versions = search(current) +254: +255: if matching_versions.empty? +256: if current.required_by.empty? +257: if base = @base[current.name] and !base.empty? +258: version = base.first.version +259: message = "You have requested:\n" " #{current.name} #{current.requirement}\n\n" "The bundle currently has #{current.name} locked at #{version}.\n" "Try running `bundle update #{current.name}`" +260: elsif current.source +261: name = current.name +262: versions = @source_requirements[name][name].map { |s| s.version } +263: message = "Could not find gem '#{current}' in #{current.source}.\n" +264: if versions.any? +265: message << "Source contains '#{name}' at: #{versions.join(', ')}" +266: else +267: message << "Source does not contain any versions of '#{current}'" +268: end +269: else +270: message = "Could not find gem '#{current}' " +271: if @index.sources.include?(Bundler::Source::Rubygems) +272: message << "in any of the gem sources." +273: else +274: message << "in the gems available on this machine." +275: end +276: end +277: raise GemNotFound, message +278: else +279: if @missing_gems[current] >= 5 +280: message = "Bundler could not find find gem #{current.required_by.last}," +281: message << "which is required by gem #{current}." +282: raise GemNotFound, message +283: end +284: @missing_gems[current] += 1 +285: +286: debug { " Could not find #{current} by #{current.required_by.last}" } +287: @errors[current.name] = [nil, current] +288: end +289: end +290: +291: matching_versions.reverse_each do |spec_group| +292: conflict = resolve_requirement(spec_group, current, reqs.dup, activated.dup) +293: conflicts << conflict if conflict +294: end +295: # If the current requirement is a root level gem and we have conflicts, we +296: # can figure out the best spot to backtrack to. +297: if current.required_by.empty? && !conflicts.empty? +298: # Check the current "catch" stack for the first one that is included in the +299: # conflicts set. That is where the parent of the conflicting gem was required. +300: # By jumping back to this spot, we can try other version of the parent of +301: # the conflicting gem, hopefully finding a combination that activates correctly. +302: @stack.reverse_each do |savepoint| +303: if conflicts.include?(savepoint) +304: debug { " -> Jumping to: #{savepoint}" } +305: throw savepoint +306: end +307: end +308: end +309: end +310: end+
+ # File lib/bundler/resolver.rb, line 315 +315: def resolve_requirement(spec_group, requirement, reqs, activated) +316: # We are going to try activating the spec. We need to keep track of stack of +317: # requirements that got us to the point of activating this gem. +318: spec_group.required_by.replace requirement.required_by +319: spec_group.required_by << requirement +320: +321: activated[spec_group.name] = spec_group +322: debug { " Activating: #{spec_group.name} (#{spec_group.version})" } +323: debug { spec_group.required_by.map { |d| " * #{d.name} (#{d.requirement})" }.join("\n") } +324: +325: dependencies = spec_group.activate_platform(requirement.__platform) +326: +327: # Now, we have to loop through all child dependencies and add them to our +328: # array of requirements. +329: debug { " Dependencies"} +330: dependencies.each do |dep| +331: next if dep.type == :development +332: debug { " * #{dep.name} (#{dep.requirement})" } +333: dep.required_by.replace(requirement.required_by) +334: dep.required_by << requirement +335: reqs << dep +336: end +337: +338: # We create a savepoint and mark it by the name of the requirement that caused +339: # the gem to be activated. If the activated gem ever conflicts, we are able to +340: # jump back to this point and try another version of the gem. +341: length = @stack.length +342: @stack << requirement.name +343: retval = catch(requirement.name) do +344: resolve(reqs, activated) +345: end +346: # Since we're doing a lot of throw / catches. A push does not necessarily match +347: # up to a pop. So, we simply slice the stack back to what it was before the catch +348: # block. +349: @stack.slice!(length..1) +350: retval +351: end+
+ # File lib/bundler/resolver.rb, line 353 +353: def search(dep) +354: if base = @base[dep.name] and base.any? +355: d = Gem::Dependency.new(base.first.name, *[dep.requirement.as_list, base.first.version].flatten) +356: else +357: d = dep.dep +358: end +359: index = @source_requirements[d.name] || @index +360: results = index.search_for_all_platforms(d, @base[d.name]) +361: +362: if results.any? +363: version = results.first.version +364: nested = [[]] +365: results.each do |spec| +366: if spec.version != version +367: nested << [] +368: version = spec.version +369: end +370: nested.last << spec +371: end +372: nested.map { |a| SpecGroup.new(a) }.select { |sg| sg.for?(dep.__platform) } +373: else +374: [] +375: end +376: end+
+ # File lib/bundler/resolver.rb, line 159 +159: def start(reqs) +160: activated = {} +161: +162: resolve(reqs, activated) +163: end+
Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
+Array
+ ++ # File lib/bundler/resolver.rb, line 34 +34: def initialize(a) +35: super +36: @required_by = [] +37: @activated = [] +38: @dependencies = nil +39: @specs = {} +40: +41: ALL.each do |p| +42: @specs[p] = reverse.find { |s| s.match_platform(p) } +43: end +44: end+
+ # File lib/bundler/resolver.rb, line 68 +68: def activate_platform(platform) +69: unless @activated.include?(platform) +70: @activated << platform +71: return __dependencies[platform] || [] +72: end +73: [] +74: end+
+ # File lib/bundler/resolver.rb, line 88 +88: def for?(platform) +89: @specs[platform] +90: end+
+ # File lib/bundler/resolver.rb, line 46 +46: def initialize_copy(o) +47: super +48: @required_by = o.required_by.dup +49: @activated = o.activated.dup +50: end+
+ # File lib/bundler/resolver.rb, line 76 +76: def name +77: @name ||= first.name +78: end+
+ # File lib/bundler/resolver.rb, line 84 +84: def source +85: @source ||= first.source +86: end+
+ # File lib/bundler/resolver.rb, line 92 +92: def to_s +93: "#{name} (#{version})" +94: end+
+ # File lib/bundler/resolver.rb, line 52 +52: def to_specs +53: specs = {} +54: +55: @activated.each do |p| +56: if s = @specs[p] +57: platform = generic(Gem::Platform.new(s.platform)) +58: next if specs[platform] +59: +60: lazy_spec = LazySpecification.new(name, version, platform, source) +61: lazy_spec.dependencies.replace s.dependencies +62: specs[platform] = lazy_spec +63: end +64: end +65: specs.values +66: end+
+ # File lib/bundler/resolver.rb, line 98 + 98: def __dependencies + 99: @dependencies ||= begin +100: dependencies = {} +101: ALL.each do |p| +102: if spec = @specs[p] +103: dependencies[p] = [] +104: spec.dependencies.each do |dep| +105: next if dep.type == :development +106: dependencies[p] << DepProxy.new(dep, p) +107: end +108: end +109: end +110: dependencies +111: end +112: end+
Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
++ # File lib/bundler/runtime.rb, line 83 +83: def cache +84: FileUtils.mkdir_p(cache_path) +85: +86: Bundler.ui.info "Updating .gem files in vendor/cache" +87: specs.each do |spec| +88: next if spec.name == 'bundler' +89: spec.source.cache(spec) if spec.source.respond_to?(:cache) +90: end +91: prune_cache unless Bundler.settings[:no_prune] +92: end+
+ # File lib/bundler/runtime.rb, line 73 +73: def dependencies_for(*groups) +74: if groups.empty? +75: dependencies +76: else +77: dependencies.select { |d| (groups & d.groups).any? } +78: end +79: end+
+ # File lib/bundler/runtime.rb, line 94 + 94: def prune_cache + 95: FileUtils.mkdir_p(cache_path) + 96: + 97: resolve = @definition.resolve + 98: cached = Dir["#{cache_path}/*.gem"] + 99: +100: cached = cached.delete_if do |path| +101: spec = Gem::Format.from_file_by_path(path).spec +102: +103: resolve.any? do |s| +104: s.name == spec.name && s.version == spec.version +105: end +106: end +107: +108: if cached.any? +109: Bundler.ui.info "Removing outdated .gem files from vendor/cache" +110: +111: cached.each do |path| +112: Bundler.ui.info " * #{File.basename(path)}" +113: File.delete(path) +114: end +115: end +116: end+
+ # File lib/bundler/runtime.rb, line 47 +47: def require(*groups) +48: groups.map! { |g| g.to_sym } +49: groups = [:default] if groups.empty? +50: +51: @definition.dependencies.each do |dep| +52: # Skip the dependency if it is not in any of the requested +53: # groups +54: next unless ((dep.groups & groups).any? && dep.current_platform?) +55: +56: required_file = nil +57: +58: begin +59: # Loop through all the specified autorequires for the +60: # dependency. If there are none, use the dependency's name +61: # as the autorequire. +62: Array(dep.autorequire || dep.name).each do |file| +63: required_file = file +64: Kernel.require file +65: end +66: rescue LoadError => e +67: REGEXPS.find { |r| r =~ e.message } +68: raise if dep.autorequire || $1 != required_file +69: end +70: end +71: end+
+ # File lib/bundler/runtime.rb, line 7 + 7: def setup(*groups) + 8: # Has to happen first + 9: clean_load_path +10: +11: specs = groups.any? ? @definition.specs_for(groups) : requested_specs +12: +13: setup_environment +14: cripple_rubygems(specs) +15: +16: # Activate the specs +17: specs.each do |spec| +18: unless spec.loaded_from +19: raise GemNotFound, "#{spec.full_name} is missing. Run `bundle` to get it." +20: end +21: +22: if activated_spec = Gem.loaded_specs[spec.name] and activated_spec.version != spec.version +23: e = Gem::LoadError.new "You have already activated #{activated_spec.name} #{activated_spec.version}, " "but your Gemfile requires #{spec.name} #{spec.version}. Consider using bundle exec." +24: e.name = spec.name +25: e.version_requirement = Gem::Requirement.new(spec.version.to_s) +26: raise e +27: end +28: +29: Gem.loaded_specs[spec.name] = spec +30: load_paths = spec.load_paths.reject {|path| $LOAD_PATH.include?(path)} +31: $LOAD_PATH.unshift(*load_paths) +32: end +33: +34: lock +35: +36: self +37: end+
+ # File lib/bundler/runtime.rb, line 120 +120: def cache_path +121: root.join("vendor/cache") +122: end+
+ # File lib/bundler/runtime.rb, line 124 +124: def setup_environment +125: begin +126: ENV["BUNDLE_BIN_PATH"] = Gem.bin_path("bundler", "bundle", VERSION) +127: rescue Gem::GemNotFoundException +128: ENV["BUNDLE_BIN_PATH"] = File.expand_path("../../../bin/bundle", __FILE__) +129: end +130: +131: # Set PATH +132: paths = (ENV["PATH"] || "").split(File::PATH_SEPARATOR) +133: paths.unshift "#{Bundler.bundle_path}/bin" +134: ENV["PATH"] = paths.uniq.join(File::PATH_SEPARATOR) +135: +136: # Set BUNDLE_GEMFILE +137: ENV["BUNDLE_GEMFILE"] = default_gemfile.to_s +138: +139: # Set RUBYOPT +140: rubyopt = [ENV["RUBYOPT"]].compact +141: if rubyopt.empty? || rubyopt.first !~ /-rbundler\/setup/ +142: rubyopt.unshift "-rbundler/setup" +143: rubyopt.unshift "-I#{File.expand_path('../..', __FILE__)}" +144: ENV["RUBYOPT"] = rubyopt.join(' ') +145: end +146: end+
Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
+Object
+ ++ # File lib/bundler/settings.rb, line 3 +3: def initialize(root) +4: @root = root +5: @local_config = File.exist?(local_config_file) ? YAML.load_file(local_config_file) : {} +6: @global_config = File.exist?(global_config_file) ? YAML.load_file(global_config_file) : {} +7: end+
+ # File lib/bundler/settings.rb, line 9 + 9: def [](key) +10: key = key_for(key) +11: @local_config[key] || ENV[key] || @global_config[key] +12: end+
+ # File lib/bundler/settings.rb, line 14 +14: def []=(key, value) +15: set_key(key, value, @local_config, local_config_file) +16: end+
+ # File lib/bundler/settings.rb, line 26 +26: def all +27: env_keys = ENV.keys.select { |k| k =~ /BUNDLE_.*/ } +28: keys = @global_config.keys | @local_config.keys | env_keys +29: +30: keys.map do |key| +31: key.sub(/^BUNDLE_/, '').gsub(/__/, ".").downcase +32: end +33: end+
+ # File lib/bundler/settings.rb, line 86 +86: def allow_sudo? +87: !@local_config.key?(key_for(:path)) +88: end+
+ # File lib/bundler/settings.rb, line 18 +18: def delete(key) +19: @local_config +20: end+
+ # File lib/bundler/settings.rb, line 35 +35: def locations(key) +36: locations = {} +37: +38: locations[:local] = @local_config[key] if @local_config.key?(key) +39: locations[:env] = ENV[key] if ENV[key] +40: locations[:global] = @global_config[key] if @global_config.key?(key) +41: locations +42: end+
+@local_config[“BUNDLE_PATH“] should be prioritized over +ENV[“BUNDLE_PATH“] +
+ + + ++ # File lib/bundler/settings.rb, line 75 +75: def path +76: path = ENV[key_for(:path)] || @global_config[key_for(:path)] +77: return path if path && !@local_config.key?(key_for(:path)) +78: +79: if path = self[:path] +80: "#{path}/#{Bundler.ruby_scope}" +81: else +82: Gem.dir +83: end +84: end+
+ # File lib/bundler/settings.rb, line 44 +44: def pretty_values_for(exposed_key) +45: key = key_for(exposed_key) +46: +47: locations = [] +48: if @local_config.key?(key) +49: locations << "Set for your local app (#{local_config_file}): #{@local_config[key].inspect}" +50: end +51: +52: if value = ENV[key] +53: locations << "Set via $#{key_for(key)}: #{value.inspect}" +54: end +55: +56: if @global_config.key?(key) +57: locations << "Set for the current user (#{global_config_file}): #{@global_config[key].inspect}" +58: end +59: +60: return ["You have not configured a value for `#{exposed_key}`"] if locations.empty? +61: locations +62: end+
+ # File lib/bundler/settings.rb, line 22 +22: def set_global(key, value) +23: set_key(key, value, @global_config, global_config_file) +24: end+
+ # File lib/bundler/settings.rb, line 108 +108: def global_config_file +109: file = ENV["BUNDLE_CONFIG"] || File.join(Gem.user_home, ".bundle/config") +110: Pathname.new(file) +111: end+
+ # File lib/bundler/settings.rb, line 91 +91: def key_for(key) +92: key = key.to_s.sub(".", "__").upcase +93: "BUNDLE_#{key}" +94: end+
+ # File lib/bundler/settings.rb, line 113 +113: def local_config_file +114: Pathname.new("#{@root}/config") +115: end+
+ # File lib/bundler/settings.rb, line 96 + 96: def set_key(key, value, hash, file) + 97: key = key_for(key) + 98: + 99: unless hash[key] == value +100: hash[key] = value +101: hash.delete(key) if value.nil? +102: FileUtils.mkdir_p(file.dirname) +103: File.open(file, "w") { |f| f.puts hash.to_yaml } +104: end +105: value +106: end+
Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
++ # File lib/bundler/shared_helpers.rb, line 19 +19: def default_gemfile +20: gemfile = find_gemfile +21: gemfile or raise GemfileNotFound, "Could not locate Gemfile" +22: Pathname.new(gemfile) +23: end+
+ # File lib/bundler/shared_helpers.rb, line 48 +48: def clean_load_path +49: # handle 1.9 where system gems are always on the load path +50: if defined?(::Gem) +51: me = File.expand_path("../../", __FILE__) +52: $LOAD_PATH.reject! do |p| +53: next if File.expand_path(p).include?(me) +54: p != File.dirname(__FILE__) && +55: Gem.path.any? { |gp| p.include?(gp) } +56: end +57: $LOAD_PATH.uniq! +58: end +59: end+
+ # File lib/bundler/shared_helpers.rb, line 73 + 73: def cripple_rubygems(specs) + 74: reverse_rubygems_kernel_mixin + 75: + 76: executables = specs.map { |s| s.executables }.flatten + 77: Gem.source_index # ensure RubyGems is fully loaded + 78: + 79: ::Kernel.class_eval do + 80: private + 81: def gem(*) ; end + 82: end + 83: + 84: ::Kernel.send(:define_method, :gem) do |dep, *reqs| + 85: if executables.include? File.basename(caller.first.split(':').first) + 86: return + 87: end + 88: opts = reqs.last.is_a?(Hash) ? reqs.pop : {} + 89: + 90: unless dep.respond_to?(:name) && dep.respond_to?(:requirement) + 91: dep = Gem::Dependency.new(dep, reqs) + 92: end + 93: + 94: spec = specs.find { |s| s.name == dep.name } + 95: + 96: if spec.nil? + 97: e = Gem::LoadError.new "#{dep.name} is not part of the bundle. Add it to Gemfile." + 98: e.name = dep.name + 99: e.version_requirement = dep.requirement +100: raise e +101: elsif dep !~ spec +102: e = Gem::LoadError.new "can't activate #{dep}, already activated #{spec.full_name}. " "Make sure all dependencies are added to Gemfile." +103: e.name = dep.name +104: e.version_requirement = dep.requirement +105: raise e +106: end +107: +108: true +109: end +110: +111: # === Following hacks are to improve on the generated bin wrappers === +112: +113: # Yeah, talk about a hack +114: source_index_class = (class << Gem::SourceIndex ; self ; end) +115: source_index_class.send(:define_method, :from_gems_in) do |*args| +116: source_index = Gem::SourceIndex.new +117: source_index.spec_dirs = *args +118: source_index.add_specs(*specs) +119: source_index +120: end +121: +122: # OMG more hacks +123: gem_class = (class << Gem ; self ; end) +124: gem_class.send(:define_method, :refresh) { } +125: gem_class.send(:define_method, :bin_path) do |name, *args| +126: exec_name, *reqs = args +127: +128: if exec_name == 'bundle' +129: return ENV['BUNDLE_BIN_PATH'] +130: end +131: +132: spec = nil +133: +134: if exec_name +135: spec = specs.find { |s| s.executables.include?(exec_name) } +136: spec or raise Gem::Exception, "can't find executable #{exec_name}" +137: else +138: spec = specs.find { |s| s.name == name } +139: exec_name = spec.default_executable or raise Gem::Exception, "no default executable for #{spec.full_name}" +140: end +141: +142: gem_bin = File.join(spec.full_gem_path, spec.bindir, exec_name) +143: gem_from_path_bin = File.join(File.dirname(spec.loaded_from), spec.bindir, exec_name) +144: File.exist?(gem_bin) ? gem_bin : gem_from_path_bin +145: end +146: +147: Gem.clear_paths +148: end+
+ # File lib/bundler/shared_helpers.rb, line 35 +35: def find_gemfile +36: return ENV['BUNDLE_GEMFILE'] if ENV['BUNDLE_GEMFILE'] +37: +38: previous = nil +39: current = File.expand_path(Dir.pwd) +40: +41: until !File.directory?(current) || current == previous +42: filename = File.join(current, 'Gemfile') +43: return filename if File.file?(filename) +44: current, previous = File.expand_path("..", current), current +45: end +46: end+
+ # File lib/bundler/shared_helpers.rb, line 81 +81: def gem(*) ; end+
+ # File lib/bundler/shared_helpers.rb, line 61 +61: def reverse_rubygems_kernel_mixin +62: # Disable rubygems' gem activation system +63: ::Kernel.class_eval do +64: if private_method_defined?(:gem_original_require) +65: alias rubygems_require require +66: alias require gem_original_require +67: end +68: +69: undef gem +70: end +71: end+
Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
+Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
+Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
+Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
++ # File lib/bundler/source.rb, line 468 +468: def self.from_lock(options) +469: new(options.merge("uri" => options.delete("remote"))) +470: end+
+ # File lib/bundler/source.rb, line 459 +459: def initialize(options) +460: super +461: @uri = options["uri"] +462: @ref = options["ref"] || options["branch"] || options["tag"] || 'master' +463: @revision = options["revision"] +464: @submodules = options["submodules"] +465: @update = false +466: end+
+ # File lib/bundler/source.rb, line 483 +483: def eql?(o) +484: Git === o && +485: uri == o.uri && +486: ref == o.ref && +487: name == o.name && +488: version == o.version && +489: submodules == o.submodules +490: end+
+ # File lib/bundler/source.rb, line 530 +530: def install(spec) +531: Bundler.ui.info "Using #{spec.name} (#{spec.version}) from #{to_s} " +532: +533: unless @installed +534: Bundler.ui.debug " * Checking out revision: #{ref}" +535: checkout if allow_git_ops? +536: @installed = true +537: end +538: generate_bin(spec) +539: end+
+ # File lib/bundler/source.rb, line 541 +541: def load_spec_files +542: super +543: rescue PathError, GitError +544: raise GitError, "#{to_s} is not checked out. Please run `bundle install`" +545: end+
+ # File lib/bundler/source.rb, line 499 +499: def name +500: File.basename(@uri, '.git') +501: end+
+ # File lib/bundler/source.rb, line 503 +503: def path +504: @install_path ||= begin +505: git_scope = "#{base_name}-#{shortref_for_path(revision)}" +506: +507: if Bundler.requires_sudo? +508: Bundler.user_bundle_path.join(Bundler.ruby_scope).join(git_scope) +509: else +510: Bundler.install_path.join(git_scope) +511: end +512: end +513: end+
+TODO: actually cache git specs +
+ + + ++ # File lib/bundler/source.rb, line 520 +520: def specs +521: if allow_git_ops? && !@update +522: # Start by making sure the git cache is up to date +523: cache +524: checkout +525: @update = true +526: end +527: local_specs +528: end+
+ # File lib/bundler/source.rb, line 472 +472: def to_lock +473: out = "GIT\n" +474: out << " remote: #{@uri}\n" +475: out << " revision: #{revision}\n" +476: %(ref branch tag submodules).each do |opt| +477: out << " #{opt}: #{options[opt]}\n" if options[opt] +478: end +479: out << " glob: #{@glob}\n" unless @glob == DEFAULT_GLOB +480: out << " specs:\n" +481: end+
+ # File lib/bundler/source.rb, line 636 +636: def allow_git_ops? +637: @allow_remote || @allow_cached +638: end+
+ # File lib/bundler/source.rb, line 564 +564: def base_name +565: File.basename(uri.sub(%{^(\w+://)?([^/:]+:)},''), ".git") +566: end+
+ # File lib/bundler/source.rb, line 600 +600: def cache +601: if cached? +602: return if has_revision_cached? +603: Bundler.ui.info "Updating #{uri}" +604: in_cache { git %fetch --force --quiet "#{uri}" refs/heads/*:refs/heads/*| } +605: else +606: Bundler.ui.info "Fetching #{uri}" +607: FileUtils.mkdir_p(cache_path.dirname) +608: git %clone "#{uri}" "#{cache_path}" --bare --no-hardlinks| +609: end +610: end+
+ # File lib/bundler/source.rb, line 588 +588: def cache_path +589: @cache_path ||= begin +590: git_scope = "#{base_name}-#{uri_hash}" +591: +592: if Bundler.requires_sudo? +593: Bundler.user_bundle_path.join("cache/git", git_scope) +594: else +595: Bundler.cache.join("git", git_scope) +596: end +597: end +598: end+
+ # File lib/bundler/source.rb, line 650 +650: def cached? +651: cache_path.exist? +652: end+
+ # File lib/bundler/source.rb, line 612 +612: def checkout +613: unless File.exist?(path.join(".git")) +614: FileUtils.mkdir_p(path.dirname) +615: git %clone --no-checkout "#{cache_path}" "#{path}"| +616: end +617: Dir.chdir(path) do +618: git %fetch --force --quiet "#{cache_path}"| +619: git "reset --hard #{revision}" +620: +621: if @submodules +622: git "submodule init" +623: git "submodule update" +624: end +625: end +626: end+
+ # File lib/bundler/source.rb, line 549 +549: def git(command) +550: if allow_git_ops? +551: out = %{git #{command}} +552: +553: if $? != 0 +554: raise GitError, "An error has occurred in git when running `git #{command}. Cannot complete bundling." +555: end +556: out +557: else +558: raise GitError, "Bundler is trying to run a `git #{command}` at runtime. You probably need to run `bundle install`. However, " "this error message could probably be more useful. Please submit a ticket at http://github.com/carlhuda/bundler/issues " "with steps to reproduce as well as the following\n\nCALLER: #{caller.join("\n")}" +559: end +560: end+
+ # File lib/bundler/source.rb, line 628 +628: def has_revision_cached? +629: return unless @revision +630: in_cache { git %cat-file -e #{@revision}| } +631: true +632: rescue GitError +633: false +634: end+
+ # File lib/bundler/source.rb, line 654 +654: def in_cache(&blk) +655: cache unless cached? +656: Dir.chdir(cache_path, &blk) +657: end+
+ # File lib/bundler/source.rb, line 640 +640: def revision +641: @revision ||= begin +642: if allow_git_ops? +643: in_cache { git("rev-parse #{ref}").strip } +644: else +645: raise GitError, "The git source #{uri} is not yet checked out. Please run `bundle install` before trying to start your application" +646: end +647: end +648: end+
+ # File lib/bundler/source.rb, line 568 +568: def shortref_for_display(ref) +569: ref[0..6] +570: end+
+ # File lib/bundler/source.rb, line 572 +572: def shortref_for_path(ref) +573: ref[0..11] +574: end+
+ # File lib/bundler/source.rb, line 576 +576: def uri_hash +577: if uri =~ %{^\w+://(\w+@)?} +578: # Downcase the domain component of the URI +579: # and strip off a trailing slash, if one is present +580: input = URI.parse(uri).normalize.to_s.sub(%{/$},'') +581: else +582: # If there is no URI scheme, assume it is an ssh/git URI +583: input = uri +584: end +585: Digest::SHA1.hexdigest(input) +586: end+
Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
+Object
+ ++ # File lib/bundler/source.rb, line 295 +295: def self.from_lock(options) +296: new(options.merge("path" => options.delete("remote"))) +297: end+
+ # 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+
+ # 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+
+ # File lib/bundler/source.rb, line 291 +291: def cached! +292: @allow_cached = true +293: end+
+ # 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+
+ # File lib/bundler/source.rb, line 310 +310: def hash +311: self.class.hash +312: end+
+ # 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+
+ # 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+
+ # File lib/bundler/source.rb, line 361 +361: def local_specs +362: @local_specs ||= load_spec_files +363: end+
+ # File lib/bundler/source.rb, line 323 +323: def name +324: File.basename(@path.to_s) +325: end+
+ # File lib/bundler/source.rb, line 287 +287: def remote! +288: @allow_remote = true +289: end+
+ # 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+
+ # 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+
Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
+Gem::Installer
+ ++ # File lib/bundler/source.rb, line 366 +366: def initialize(spec, options = {}) +367: @spec = spec +368: @bin_dir = Bundler.requires_sudo? ? "#{Bundler.tmp}/bin" : "#{Gem.dir}/bin" +369: @gem_dir = spec.full_gem_path +370: @wrappers = options[:wrappers] || true +371: @env_shebang = options[:env_shebang] || true +372: @format_executable = options[:format_executable] || false +373: end+
+ # File lib/bundler/source.rb, line 375 +375: def generate_bin +376: return if spec.executables.nil? || spec.executables.empty? +377: +378: if Bundler.requires_sudo? +379: FileUtils.mkdir_p("#{Bundler.tmp}/bin") unless File.exist?("#{Bundler.tmp}/bin") +380: end +381: super +382: if Bundler.requires_sudo? +383: Bundler.mkdir_p "#{Gem.dir}/bin" +384: spec.executables.each do |exe| +385: Bundler.sudo "cp -R #{Bundler.tmp}/bin/#{exe} #{Gem.dir}/bin/" +386: end +387: end +388: end+
Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
+Object
+ ++TODO: Refactor this class +
+ ++ # File lib/bundler/source.rb, line 52 +52: def self.from_lock(options) +53: s = new(options) +54: Array(options["remote"]).each { |r| s.add_remote(r) } +55: s +56: end+
+ # File lib/bundler/source.rb, line 14 +14: def initialize(options = {}) +15: @options = options +16: @remotes = (options["remotes"] || []).map { |r| normalize_uri(r) } +17: @allow_remote = false +18: @allow_cached = false +19: # Hardcode the paths for now +20: @caches = [ Bundler.app_cache ] + Gem.path.map { |p| File.expand_path("#{p}/cache") } +21: @spec_fetch_map = {} +22: end+
+ # File lib/bundler/source.rb, line 128 +128: def add_remote(source) +129: @remotes << normalize_uri(source) +130: end+
+ # File lib/bundler/source.rb, line 120 +120: def cache(spec) +121: cached_path = cached_gem(spec) +122: raise GemNotFound, "Missing gem file '#{spec.full_name}.gem'." unless cached_path +123: return if File.dirname(cached_path) == Bundler.app_cache.to_s +124: Bundler.ui.info " * #{File.basename(cached_path)}" +125: FileUtils.cp(cached_path, Bundler.app_cache) +126: end+
+ # File lib/bundler/source.rb, line 28 +28: def cached! +29: @allow_cached = true +30: end+
+ # File lib/bundler/source.rb, line 36 +36: def eql?(o) +37: Rubygems === o +38: end+
+ # File lib/bundler/source.rb, line 73 +73: def fetch(spec) +74: spec, uri = @spec_fetch_map[spec.full_name] +75: if spec +76: path = download_gem_from_uri(spec, uri) +77: s = Gem::Format.from_file_by_path(path).spec +78: spec.__swap__(s) +79: end +80: end+
+ # File lib/bundler/source.rb, line 32 +32: def hash +33: Rubygems.hash +34: end+
+ # File lib/bundler/source.rb, line 82 + 82: def install(spec) + 83: path = cached_gem(spec) + 84: + 85: if installed_specs[spec].any? + 86: Bundler.ui.info "Using #{spec.name} (#{spec.version}) " + 87: return + 88: end + 89: + 90: Bundler.ui.info "Installing #{spec.name} (#{spec.version}) " + 91: + 92: install_path = Bundler.requires_sudo? ? Bundler.tmp : Gem.dir + 93: options = { :install_dir => install_path, + 94: :ignore_dependencies => true, + 95: :wrappers => true, + 96: :env_shebang => true } + 97: options.merge!(:bin_dir => "#{install_path}/bin") unless spec.executables.nil? || spec.executables.empty? + 98: + 99: installer = Gem::Installer.new path, options +100: installer.install +101: +102: # SUDO HAX +103: if Bundler.requires_sudo? +104: sudo "mkdir -p #{Gem.dir}/gems #{Gem.dir}/specifications" +105: sudo "cp -R #{Bundler.tmp}/gems/#{spec.full_name} #{Gem.dir}/gems/" +106: sudo "cp -R #{Bundler.tmp}/specifications/#{spec.full_name}.gemspec #{Gem.dir}/specifications/" +107: spec.executables.each do |exe| +108: sudo "mkdir -p #{Gem.bindir}" +109: sudo "cp -R #{Bundler.tmp}/bin/#{exe} #{Gem.bindir}" +110: end +111: end +112: +113: spec.loaded_from = "#{Gem.dir}/specifications/#{spec.full_name}.gemspec" +114: end+
+ # File lib/bundler/source.rb, line 132 +132: def merge_remotes(source) +133: @remotes = [] +134: source.remotes.each do |r| +135: add_remote r.to_s +136: end +137: end+
+ # File lib/bundler/source.rb, line 48 +48: def options +49: { "remotes" => @remotes.map { |r| r.to_s } } +50: end+
+ # File lib/bundler/source.rb, line 24 +24: def remote! +25: @allow_remote = true +26: end+
+ # File lib/bundler/source.rb, line 69 +69: def specs +70: @specs ||= fetch_specs +71: end+
+ # File lib/bundler/source.rb, line 116 +116: def sudo(str) +117: Bundler.sudo(str) +118: end+
+ # File lib/bundler/source.rb, line 141 +141: def cached_gem(spec) +142: possibilities = @caches.map { |p| "#{p}/#{spec.full_name}.gem" } +143: possibilities.find { |p| File.exist?(p) } +144: end+
+ # File lib/bundler/source.rb, line 192 +192: def cached_specs +193: @cached_specs ||= begin +194: idx = Index.new +195: @caches.each do |path| +196: Dir["#{path}/*.gem"].each do |gemfile| +197: next if name == 'bundler' +198: s = Gem::Format.from_file_by_path(gemfile).spec +199: s.source = self +200: idx << s +201: end +202: end +203: idx +204: end +205: end+
+ # File lib/bundler/source.rb, line 246 +246: def download_gem_from_uri(spec, uri) +247: spec.fetch_platform +248: +249: download_path = Bundler.requires_sudo? ? Bundler.tmp : Gem.dir +250: gem_path = "#{Gem.dir}/cache/#{spec.full_name}.gem" +251: +252: FileUtils.mkdir_p("#{download_path}/cache") +253: Gem::RemoteFetcher.fetcher.download(spec, uri, download_path) +254: +255: if Bundler.requires_sudo? +256: sudo "mkdir -p #{Gem.dir}/cache" +257: sudo "mv #{Bundler.tmp}/cache/#{spec.full_name}.gem #{gem_path}" +258: end +259: +260: gem_path +261: end+
+ # File lib/bundler/source.rb, line 231 +231: def fetch_all_remote_specs(&blk) +232: begin +233: # Fetch all specs, minus prerelease specs +234: Gem::SpecFetcher.new.list(true, false).each(&blk) +235: # Then fetch the prerelease specs +236: begin +237: Gem::SpecFetcher.new.list(false, true).each(&blk) +238: rescue Gem::RemoteFetcher::FetchError +239: Bundler.ui.warn "Could not fetch prerelease specs from #{self}" +240: end +241: rescue Gem::RemoteFetcher::FetchError +242: Bundler.ui.warn "Could not reach #{self}" +243: end +244: end+
+ # File lib/bundler/source.rb, line 154 +154: def fetch_specs +155: Index.build do |idx| +156: idx.use installed_specs +157: idx.use cached_specs if @allow_cached || @allow_remote +158: idx.use remote_specs if @allow_remote +159: end +160: end+
+ # File lib/bundler/source.rb, line 162 +162: def installed_specs +163: @installed_specs ||= begin +164: idx = Index.new +165: have_bundler = false +166: Gem::SourceIndex.from_installed_gems.to_a.reverse.each do |dont_use_this_var, spec| +167: next if spec.name == 'bundler' && spec.version.to_s != VERSION +168: have_bundler = true if spec.name == 'bundler' +169: spec.source = self +170: idx << spec +171: end +172: +173: # Always have bundler locally +174: unless have_bundler +175: # We're running bundler directly from the source +176: # so, let's create a fake gemspec for it (it's a path) +177: # gemspec +178: bundler = Gem::Specification.new do |s| +179: s.name = 'bundler' +180: s.version = VERSION +181: s.platform = Gem::Platform::RUBY +182: s.source = self +183: # TODO: Remove this +184: s.loaded_from = 'w0t' +185: end +186: idx << bundler +187: end +188: idx +189: end +190: end+
+ # File lib/bundler/source.rb, line 146 +146: def normalize_uri(uri) +147: uri = uri.to_s +148: uri = "#{uri}/" unless uri =~ %/$' +149: uri = URI(uri) +150: raise ArgumentError, "The source must be an absolute URI" unless uri.absolute? +151: uri +152: end+
+ # File lib/bundler/source.rb, line 207 +207: def remote_specs +208: @remote_specs ||= begin +209: idx = Index.new +210: old = Gem.sources +211: +212: remotes.each do |uri| +213: Bundler.ui.info "Fetching source index for #{uri}" +214: Gem.sources = ["#{uri}"] +215: fetch_all_remote_specs do |n,v| +216: v.each do |name, version, platform| +217: next if name == 'bundler' +218: spec = RemoteSpecification.new(name, version, platform, uri) +219: spec.source = self +220: @spec_fetch_map[spec.full_name] = [spec, uri] +221: idx << spec +222: end +223: end +224: end +225: idx +226: ensure +227: Gem.sources = old +228: end +229: end+
Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
+Object
+ ++ # File lib/bundler/spec_set.rb, line 59 +59: def [](key) +60: key = key.name if key.respond_to?(:name) +61: lookup[key].reverse +62: end+
+ # File lib/bundler/spec_set.rb, line 64 +64: def []=(key, value) +65: @specs << value +66: @lookup = nil +67: @sorted = nil +68: value +69: end+
+ # File lib/bundler/spec_set.rb, line 11 +11: def each +12: sorted.each { |s| yield s } +13: end+
+ # File lib/bundler/spec_set.rb, line 19 +19: def for(dependencies, skip = [], check = false, match_current_platform = false) +20: handled, deps, specs = {}, dependencies.dup, [] +21: skip << 'bundler' +22: +23: until deps.empty? +24: dep = deps.shift +25: next if handled[dep] || skip.include?(dep.name) +26: +27: spec = lookup[dep.name].find do |s| +28: match_current_platform ? +29: Gem::Platform.match(s.platform) : +30: s.match_platform(dep.__platform) +31: end +32: +33: handled[dep] = true +34: +35: if spec +36: specs << spec +37: +38: spec.dependencies.each do |d| +39: next if d.type == :development +40: d = DepProxy.new(d, dep.__platform) unless match_current_platform +41: deps << d +42: end +43: elsif check +44: return false +45: end +46: end +47: +48: if spec = lookup['bundler'].first +49: specs << spec +50: end +51: +52: check ? true : SpecSet.new(specs) +53: end+
+ # File lib/bundler/spec_set.rb, line 15 +15: def length +16: @specs.length +17: end+
+ # File lib/bundler/spec_set.rb, line 79 +79: def materialize(deps, missing_specs = nil) +80: materialized = self.for(deps, [], false, true).to_a +81: materialized.map! do |s| +82: next s unless s.is_a?(LazySpecification) +83: spec = s.__materialize__ +84: if missing_specs +85: missing_specs << s unless spec +86: else +87: raise GemNotFound, "Could not find #{s.full_name} in any of the sources" unless spec +88: end +89: spec if spec +90: end +91: SpecSet.new(materialized.compact) +92: end+
+ # File lib/bundler/spec_set.rb, line 94 + 94: def merge(set) + 95: arr = sorted.dup + 96: set.each do |s| + 97: next if arr.any? { |s2| s2.name == s.name && s2.version == s.version && s2.platform == s.platform } + 98: arr << s + 99: end +100: SpecSet.new(arr) +101: end+
+ # File lib/bundler/spec_set.rb, line 71 +71: def to_a +72: sorted.dup +73: end+
+ # File lib/bundler/spec_set.rb, line 110 +110: def lookup +111: @lookup ||= begin +112: lookup = Hash.new { |h,k| h[k] = [] } +113: specs = @specs.sort_by do |s| +114: s.platform.to_s == 'ruby' ? "\00"" : s.platform.to_s +115: end +116: specs.reverse_each do |s| +117: lookup[s.name] << s +118: end +119: lookup +120: end +121: end+
+ # File lib/bundler/spec_set.rb, line 105 +105: def sorted +106: rake = @specs.find { |s| s.name == 'rake' } +107: @sorted ||= ([rake] + tsort).compact.uniq +108: end+
+ # File lib/bundler/spec_set.rb, line 127 +127: def tsort_each_child(s) +128: s.dependencies.sort_by { |d| d.name }.each do |d| +129: next if d.type == :development +130: lookup[d.name].each { |s2| yield s2 } +131: end +132: end+
Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
+Object
+ ++ # File lib/bundler/ui.rb, line 12 +12: def confirm(message) +13: end+
+ # File lib/bundler/ui.rb, line 6 +6: def error(message) +7: end+
Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
+Gem::SilentUI
+ +Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
++ # File lib/bundler/ui.rb, line 41 +41: def be_quiet! +42: @quiet = true +43: end+
+ # File lib/bundler/ui.rb, line 29 +29: def confirm(msg) +30: @shell.say(msg, :green) if !@quiet +31: end+
+ # File lib/bundler/ui.rb, line 21 +21: def debug(msg) +22: @shell.say(msg) if ENV['DEBUG'] && !@quiet +23: end+
+ # File lib/bundler/ui.rb, line 37 +37: def error(msg) +38: @shell.say(msg, :red) +39: end+
Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
+Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
+Object
+ +Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
++Extending Gem classes to add necessary tracking +information +
+ +Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
+Object
+ ++ # File lib/bundler/resolver.rb, line 16 +16: def required_by +17: @required_by ||= [] +18: end+
+ # File lib/bundler/shared_helpers.rb, line 8 + 8: def requirement + 9: version_requirements +10: end+
Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
+Object
+ +Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
+Object
+ ++ # File lib/bundler/rubygems_ext.rb, line 67 +67: def add_bundler_dependencies(*groups) +68: Bundler.ui.warn "#add_bundler_dependencies is deprecated and will " "be removed in Bundler 1.0. Instead, please use the #gemspec method " "in your Gemfile, which will pull in any dependencies specified in " "your gemspec" +69: +70: groups = [:default] if groups.empty? +71: Bundler.definition.dependencies.each do |dep| +72: if dep.groups.include?(:development) +73: self.add_development_dependency(dep.name, dep.requirement.to_s) +74: elsif (dep.groups & groups).any? +75: self.add_dependency(dep.name, dep.requirement.to_s) +76: end +77: end +78: end+
+ # File lib/bundler/rubygems_ext.rb, line 20 +20: def full_gem_path +21: source.respond_to?(:path) ? +22: Pathname.new(loaded_from).dirname.expand_path.to_s : +23: rg_full_gem_path +24: end+
+ # File lib/bundler/rubygems_ext.rb, line 46 +46: def git_version +47: if @loaded_from && File.exist?(File.join(full_gem_path, ".git")) +48: sha = Dir.chdir(full_gem_path){ `git rev-parse HEAD`.strip } +49: " #{sha[0..6]}" +50: end +51: end+
+ # File lib/bundler/rubygems_ext.rb, line 42 +42: def groups +43: @groups ||= [] +44: end+
+ # File lib/bundler/rubygems_ext.rb, line 32 +32: def load_paths +33: require_paths.map do |require_path| +34: if require_path.include?(full_gem_path) +35: require_path +36: else +37: File.join(full_gem_path, require_path) +38: end +39: end +40: end+
+ # File lib/bundler/rubygems_ext.rb, line 26 +26: def loaded_from +27: relative_loaded_from ? +28: source.path.join(relative_loaded_from).to_s : +29: rg_loaded_from +30: end+
+ # File lib/bundler/rubygems_ext.rb, line 63 +63: def nondevelopment_dependencies +64: dependencies - development_dependencies +65: end+
+ # File lib/bundler/resolver.rb, line 11 +11: def required_by +12: @required_by ||= [] +13: end+
+ # File lib/bundler/rubygems_ext.rb, line 53 +53: def to_gemfile(path = nil) +54: gemfile = "source :gemcutter\n" +55: gemfile << dependencies_to_gemfile(nondevelopment_dependencies) +56: unless development_dependencies.empty? +57: gemfile << "\n" +58: gemfile << dependencies_to_gemfile(development_dependencies, :development) +59: end +60: gemfile +61: end+
+ # File lib/bundler/rubygems_ext.rb, line 85 +85: def dependencies_to_gemfile(dependencies, group = nil) +86: gemfile = '' +87: if dependencies.any? +88: gemfile << "group :#{group} do\n" if group +89: dependencies.each do |dependency| +90: gemfile << ' ' if group +91: gemfile << %gem "#{dependency.name}"| +92: req = dependency.requirements_list.first +93: gemfile << %, "#{req}"| if req +94: gemfile << "\n" +95: end +96: gemfile << "end\n" if group +97: end +98: gemfile +99: end+
Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
+Object
+ ++Shortcuts for help. +
+Thor methods that should not be overwritten by the +user. +
+Extend check unknown options to accept a hash of conditions. +
+
+options
+ # File lib/bundler/vendor/thor.rb, line 195 +195: def check_unknown_options!(options={}) +196: @check_unknown_options ||= Hash.new +197: options.each do |key, value| +198: if value +199: @check_unknown_options[key] = Array(value) +200: else +201: @check_unknown_options.delete(key) +202: end +203: end +204: @check_unknown_options +205: end+
+Sets the default task when thor is executed without an explicit task to be +called. +
+meth | +name of the defaut task + + |
+ # File lib/bundler/vendor/thor.rb, line 10 +10: def default_task(meth=nil) +11: case meth +12: when :none +13: @default_task = 'help' +14: when nil +15: @default_task ||= from_superclass(:default_task, 'help') +16: else +17: @default_task = meth.to_s +18: end +19: end+
+Defines the usage and the description of the next task. +
+
+usage
+ # File lib/bundler/vendor/thor.rb, line 28 +28: def desc(usage, description, options={}) +29: if options[:for] +30: task = find_and_refresh_task(options[:for]) +31: task.usage = usage if usage +32: task.description = description if description +33: else +34: @usage, @desc, @hide = usage, description, options[:hide] || false +35: end +36: end+
+Prints help information for this class. +
+
+shell
+ # File lib/bundler/vendor/thor.rb, line 157 +157: def help(shell, subcommand = false) +158: list = printable_tasks(true, subcommand) +159: Thor::Util.thor_classes_in(self).each do |klass| +160: list += klass.printable_tasks(false) +161: end +162: list.sort!{ |a,b| a[0] <=> b[0] } +163: +164: shell.say "Tasks:" +165: shell.print_table(list, :ident => 2, :truncate => true) +166: shell.say +167: class_options_help(shell) +168: end+
+Defines the long description of the next task. +
+
+long description
+ # File lib/bundler/vendor/thor.rb, line 43 +43: def long_desc(long_description, options={}) +44: if options[:for] +45: task = find_and_refresh_task(options[:for]) +46: task.long_description = long_description if long_description +47: else +48: @long_desc = long_description +49: end +50: end+
+Maps an input to a task. If you define: +
++ map "-T" => "list" ++
+Running: +
++ thor -T ++
+Will invoke the list task. +
+Hash[String|Array => Symbol] | +Maps the string or the strings in the array to the given task. + + |
+ # File lib/bundler/vendor/thor.rb, line 65 +65: def map(mappings=nil) +66: @map ||= from_superclass(:map, {}) +67: +68: if mappings +69: mappings.each do |key, value| +70: if key.respond_to?(:each) +71: key.each {|subkey| @map[subkey] = value} +72: else +73: @map[key] = value +74: end +75: end +76: end +77: +78: @map +79: end+
+Adds an option to the set of method options. If :for is given as option, it +allows you to change the options from a previous defined task. +
++ def previous_task + # magic + end + + method_option :foo => :bar, :for => :previous_task + + def next_task + # magic + end ++
name | +The name of the argument. + + |
options | +Described below. + + |
+:desc - Description for the argument. :required - If the argument is +required or not. :default - Default value for this argument. It cannot be +required and have default values. :aliases - Aliases for this option. +:type - The type of the argument, can be :string, :hash, :array, +:numeric or :boolean. :banner - String to show on usage notes. +
+ + + ++ # File lib/bundler/vendor/thor.rb, line 119 +119: def method_option(name, options={}) +120: scope = if options[:for] +121: find_and_refresh_task(options[:for]).options +122: else +123: method_options +124: end +125: +126: build_option(name, options, scope) +127: end+
+Declares the options for the next task to be declared. +
+Hash[Symbol => Object] | +The hash key is the name of the option and the value + + |
+is the type of the option. Can be :string, :array, :hash, :boolean, +:numeric or :required (string). If you give a value, the type of the value +is used. +
+ + + ++ # File lib/bundler/vendor/thor.rb, line 88 +88: def method_options(options=nil) +89: @method_options ||= {} +90: build_options(options, @method_options) if options +91: @method_options +92: end+
+Returns tasks ready to be printed. +
+ + + ++ # File lib/bundler/vendor/thor.rb, line 171 +171: def printable_tasks(all = true, subcommand = false) +172: (all ? all_tasks : tasks).map do |_, task| +173: next if task.hidden? +174: item = [] +175: item << banner(task, false, subcommand) +176: item << (task.description ? "# #{task.description.gsub(/\s+/m,' ')}" : "") +177: item +178: end.compact +179: end+
+ # File lib/bundler/vendor/thor.rb, line 185 +185: def subcommand(subcommand, subcommand_class) +186: self.subcommands << subcommand.to_s +187: subcommand_class.subcommand_help subcommand +188: define_method(subcommand) { |*args| invoke subcommand_class, args } +189: end+
+ # File lib/bundler/vendor/thor.rb, line 181 +181: def subcommands +182: @subcommands ||= from_superclass(:subcommands, []) +183: end+
+Prints help information for the given task. +
+
+shell
+ # File lib/bundler/vendor/thor.rb, line 135 +135: def task_help(shell, task_name) +136: meth = normalize_task_name(task_name) +137: task = all_tasks[meth] +138: handle_no_task_error(meth) unless task +139: +140: shell.say "Usage:" +141: shell.say " #{banner(task)}" +142: shell.say +143: class_options_help(shell, nil => task.options.map { |_, o| o }) +144: if task.long_description +145: shell.say "Description:" +146: shell.print_wrapped(task.long_description, :ident => 2) +147: else +148: shell.say task.description +149: end +150: end+
+ # File lib/bundler/vendor/thor.rb, line 302 +302: def subcommand_help(cmd) +303: desc "help [COMMAND]", "Describe subcommands or one specific subcommand" +304: class_eval def help(task = nil, subcommand = true); super; end +305: end+
Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
++Extends initializer to add more configuration options. +
+behavior | +The actions default behavior. Can be :invoke or :revoke. It also accepts +:force, :skip and :pretend to set the behavior and the respective option. + + |
destination_root | +The root directory needed for some actions. + + |
+ # File lib/bundler/vendor/thor/actions.rb, line 72 +72: def initialize(args=[], options={}, config={}) +73: self.behavior = case config[:behavior].to_s +74: when "force", "skip" +75: _cleanup_options_and_set(options, config[:behavior]) +76: :invoke +77: when "revoke" +78: :revoke +79: else +80: :invoke +81: end +82: +83: super +84: self.destination_root = config[:destination_root] +85: end+
+Append text to a file. Since it depends on inject_into_file, +it’s reversible. +
+path | +path of the file to be changed + + |
data | +the data to append to the file, can be also given as a block. + + |
config | +give :verbose => false to not log the status. + + |
+ append_file 'config/environments/test.rb', 'config.gem "rspec"' + + append_file 'config/environments/test.rb' do + 'config.gem "rspec"' + end+ + + +
+ # File lib/bundler/vendor/thor/actions/file_manipulation.rb, line 149 +149: def append_file(path, *args, &block) +150: config = args.last.is_a?(Hash) ? args.pop : {} +151: config.merge!(:before => /\z/) +152: inject_into_file(path, *(args << config), &block) +153: end+
+Loads an external file and execute it in the instance binding. +
+path | +The path to the file to execute. Can be a web address or a relative path +from the source root. + + |
+ apply "http://gist.github.com/103208" + + apply "recipes/jquery.rb"+ + + +
+ # File lib/bundler/vendor/thor/actions.rb, line 191 +191: def apply(path, config={}) +192: verbose = config.fetch(:verbose, true) +193: is_uri = path =~ /^https?\:\/\// +194: path = find_in_source_paths(path) unless is_uri +195: +196: say_status :apply, path, verbose +197: shell.padding += 1 if verbose +198: +199: if is_uri +200: contents = open(path, "Accept" => "application/x-thor-template") {|io| io.read } +201: else +202: contents = open(path) {|io| io.read } +203: end +204: +205: instance_eval(contents, path) +206: shell.padding -= 1 if verbose +207: end+
+Changes the mode of the given file or directory. +
+mode | +the file mode + + |
path | +the name of the file to change mode + + |
config | +give :verbose => false to not log the status. + + |
+ chmod "script/*", 0755+ + + +
+ # File lib/bundler/vendor/thor/actions/file_manipulation.rb, line 106 +106: def chmod(path, mode, config={}) +107: return unless behavior == :invoke +108: path = File.expand_path(path, destination_root) +109: say_status :chmod, relative_to_original_destination_root(path), config.fetch(:verbose, true) +110: FileUtils.chmod_R(mode, path) unless options[:pretend] +111: end+
+Copies the file from the relative source to the relative destination. If +the destination is not given it’s assumed to be equal to the source. +
+source | +the relative path to the source root. + + |
destination | +the relative path to the destination root. + + |
config | +give :verbose => false to not log the status. + + |
+ copy_file "README", "doc/README" + + copy_file "doc/README"+ + + +
+ # File lib/bundler/vendor/thor/actions/file_manipulation.rb, line 21 +21: def copy_file(source, *args, &block) +22: config = args.last.is_a?(Hash) ? args.pop : {} +23: destination = args.first || source +24: source = File.expand_path(find_in_source_paths(source.to_s)) +25: +26: create_file destination, nil, config do +27: content = File.binread(source) +28: content = block.call(content) if block +29: content +30: end +31: end+
+Create a new file relative to the destination root with the given data, +which is the return value of a block or a data string. +
+destination | +the relative path to the destination root. + + |
data | +the data to append to the file. + + |
config | +give :verbose => false to not log the status. + + |
+ create_file "lib/fun_party.rb" do + hostname = ask("What is the virtual hostname I should use?") + "vhost.name = #{hostname}" + end + + create_file "config/apach.conf", "your apache config"+ + + +
+ # File lib/bundler/vendor/thor/actions/create_file.rb, line 23 +23: def create_file(destination, *args, &block) +24: config = args.last.is_a?(Hash) ? args.pop : {} +25: data = args.first +26: action CreateFile.new(self, destination, block || data.to_s, config) +27: end+
+Returns the root for this thor class (also aliased as destination root). +
+ + + ++ # File lib/bundler/vendor/thor/actions.rb, line 99 + 99: def destination_root +100: @destination_stack.last +101: end+
+Sets the root for this thor class. Relatives path are added to the +directory where the script was invoked and expanded. +
+ + + ++ # File lib/bundler/vendor/thor/actions.rb, line 106 +106: def destination_root=(root) +107: @destination_stack ||= [] +108: @destination_stack[0] = File.expand_path(root || '') +109: end+
+Copies recursively the files from source directory to root directory. If +any of the files finishes with .tt, it’s considered to be a template +and is placed in the destination without the extension .tt. If any empty +directory is found, it’s copied and all .empty_directory files are +ignored. Remember that file paths can also be encoded, let’s suppose +a doc directory with the following files: +
++ doc/ + components/.empty_directory + README + rdoc.rb.tt + %app_name%.rb ++
+When invoked as: +
++ directory "doc" ++
+It will create a doc directory in the destination with the following files +(assuming that the app_name is “blog”): +
++ doc/ + components/ + README + rdoc.rb + blog.rb ++
source | +the relative path to the source root. + + |
destination | +the relative path to the destination root. + + |
config | +give :verbose => false to not log the status. If :recursive => false, does +not look for paths recursively. + + |
+ directory "doc" + directory "doc", "docs", :recursive => false+ + + +
+ # File lib/bundler/vendor/thor/actions/directory.rb, line 43 +43: def directory(source, *args, &block) +44: config = args.last.is_a?(Hash) ? args.pop : {} +45: destination = args.first || source +46: action Directory.new(self, source, destination || source, config, &block) +47: end+
+Creates an empty directory. +
+destination | +the relative path to the destination root. + + |
config | +give :verbose => false to not log the status. + + |
+ empty_directory "doc"+ + + +
+ # File lib/bundler/vendor/thor/actions/empty_directory.rb, line 14 +14: def empty_directory(destination, config={}) +15: action EmptyDirectory.new(self, destination, config) +16: end+
+Receives a file or directory and search for it in the source paths. +
+ + + ++ # File lib/bundler/vendor/thor/actions.rb, line 127 +127: def find_in_source_paths(file) +128: relative_root = relative_to_original_destination_root(destination_root, false) +129: +130: source_paths.each do |source| +131: source_file = File.expand_path(file, File.join(source, relative_root)) +132: return source_file if File.exists?(source_file) +133: end +134: +135: message = "Could not find #{file.inspect} in any of your source paths. " +136: +137: unless self.class.source_root +138: message << "Please invoke #{self.class.name}.source_root(PATH) with the PATH containing your templates. " +139: end +140: +141: if source_paths.empty? +142: message << "Currently you have no source paths." +143: else +144: message << "Your current source paths are: \n#{source_paths.join("\n")}" +145: end +146: +147: raise Error, message +148: end+
+Gets the content at the given address and places it at the given relative +destination. If a block is given instead of destination, the content of the +url is yielded and used as location. +
+source | +the address of the given content. + + |
destination | +the relative path to the destination root. + + |
config | +give :verbose => false to not log the status. + + |
+ get "http://gist.github.com/103208", "doc/README" + + get "http://gist.github.com/103208" do |content| + content.split("\n").first + end+ + + +
+ # File lib/bundler/vendor/thor/actions/file_manipulation.rb, line 50 +50: def get(source, *args, &block) +51: config = args.last.is_a?(Hash) ? args.pop : {} +52: destination = args.first +53: +54: source = File.expand_path(find_in_source_paths(source.to_s)) unless source =~ /^http\:\/\// +55: render = open(source) {|input| input.binmode.read } +56: +57: destination ||= if block_given? +58: block.arity == 1 ? block.call(render) : block.call +59: else +60: File.basename(source) +61: end +62: +63: create_file destination, render, config +64: end+
+Run a regular expression replacement on a file. +
+path | +path of the file to be changed + + |
flag | +the regexp or string to be replaced + + |
replacement | +the replacement, can be also given as a block + + |
config | +give :verbose => false to not log the status. + + |
+ gsub_file 'app/controllers/application_controller.rb', /#\s*(filter_parameter_logging :password)/, '\1' + + gsub_file 'README', /rake/, :green do |match| + match << " no more. Use thor!" + end+ + + +
+ # File lib/bundler/vendor/thor/actions/file_manipulation.rb, line 194 +194: def gsub_file(path, flag, *args, &block) +195: return unless behavior == :invoke +196: config = args.last.is_a?(Hash) ? args.pop : {} +197: +198: path = File.expand_path(path, destination_root) +199: say_status :gsub, relative_to_original_destination_root(path), config.fetch(:verbose, true) +200: +201: unless options[:pretend] +202: content = File.binread(path) +203: content.gsub!(flag, *args, &block) +204: File.open(path, 'wb') { |file| file.write(content) } +205: end +206: end+
+Goes to the root and execute the given block. +
+ + + ++ # File lib/bundler/vendor/thor/actions.rb, line 175 +175: def in_root +176: inside(@destination_stack.first) { yield } +177: end+
+Injects text right after the class definition. Since it depends on inject_into_file, +it’s reversible. +
+path | +path of the file to be changed + + |
klass | +the class to be manipulated + + |
data | +the data to append to the class, can be also given as a block. + + |
config | +give :verbose => false to not log the status. + + |
+ inject_into_class "app/controllers/application_controller.rb", " filter_parameter :password\n" + + inject_into_class "app/controllers/application_controller.rb", ApplicationController do + " filter_parameter :password\n" + end+ + + +
+ # File lib/bundler/vendor/thor/actions/file_manipulation.rb, line 172 +172: def inject_into_class(path, klass, *args, &block) +173: config = args.last.is_a?(Hash) ? args.pop : {} +174: config.merge!(:after => /class #{klass}\n|class #{klass} .*\n/) +175: inject_into_file(path, *(args << config), &block) +176: end+
+Injects the given content into a file. Different from gsub_file, this method is +reversible. +
+destination | +Relative path to the destination root + + |
data | +Data to add to the file. Can be given as a block. + + |
config | +give :verbose => false to not log the status and the flag for injection +(:after or :before) or :force => true for insert two or more times the +same content. + + |
+ inject_into_file "config/environment.rb", "config.gem :thor", :after => "Rails::Initializer.run do |config|\n" + + inject_into_file "config/environment.rb", :after => "Rails::Initializer.run do |config|\n" do + gems = ask "Which gems would you like to add?" + gems.split(" ").map{ |gem| " config.gem :#{gem}" }.join("\n") + end+ + + +
+ # File lib/bundler/vendor/thor/actions/inject_into_file.rb, line 25 +25: def inject_into_file(destination, *args, &block) +26: if block_given? +27: data, config = block, args.shift +28: else +29: data, config = args.shift, args.shift +30: end +31: action InjectIntoFile.new(self, destination, data, config) +32: end+
+Do something in the root or on a provided subfolder. If a relative path is +given it’s referenced from the current root. The full path is yielded +to the block you provide. The path is set back to the previous path when +the method exits. +
+dir | +the directory to move to. + + |
config | +give :verbose => true to log and use padding. + + |
+ # File lib/bundler/vendor/thor/actions.rb, line 159 +159: def inside(dir='', config={}, &block) +160: verbose = config.fetch(:verbose, false) +161: +162: say_status :inside, dir, verbose +163: shell.padding += 1 if verbose +164: @destination_stack.push File.expand_path(dir, destination_root) +165: +166: FileUtils.mkdir_p(destination_root) unless File.exist?(destination_root) +167: FileUtils.cd(destination_root) { block.arity == 1 ? yield(destination_root) : yield } +168: +169: @destination_stack.pop +170: shell.padding -= 1 if verbose +171: end+
+Prepend text to a file. Since it depends on inject_into_file, +it’s reversible. +
+path | +path of the file to be changed + + |
data | +the data to prepend to the file, can be also given as a block. + + |
config | +give :verbose => false to not log the status. + + |
+ prepend_file 'config/environments/test.rb', 'config.gem "rspec"' + + prepend_file 'config/environments/test.rb' do + 'config.gem "rspec"' + end+ + + +
+ # File lib/bundler/vendor/thor/actions/file_manipulation.rb, line 128 +128: def prepend_file(path, *args, &block) +129: config = args.last.is_a?(Hash) ? args.pop : {} +130: config.merge!(:after => /\A/) +131: inject_into_file(path, *(args << config), &block) +132: end+
+Returns the given path relative to the absolute root (ie, root where the +script started). +
+ + + ++ # File lib/bundler/vendor/thor/actions.rb, line 114 +114: def relative_to_original_destination_root(path, remove_dot=true) +115: path = path.gsub(@destination_stack[0], '.') +116: remove_dot ? (path[2..1] || '') : path +117: end+
+Removes a file at the given location. +
+path | +path of the file to be changed + + |
config | +give :verbose => false to not log the status. + + |
+ remove_file 'README' + remove_file 'app/controllers/application_controller.rb'+ + + +
+ # File lib/bundler/vendor/thor/actions/file_manipulation.rb, line 219 +219: def remove_file(path, config={}) +220: return unless behavior == :invoke +221: path = File.expand_path(path, destination_root) +222: +223: say_status :remove, relative_to_original_destination_root(path), config.fetch(:verbose, true) +224: ::FileUtils.rm_rf(path) if !options[:pretend] && File.exists?(path) +225: end+
+Executes a command returning the contents of the command. +
+command | +the command to be executed. + + |
config | +give :verbose => false to not log the status. Specify :with to append an +executable to command executation. + + |
+ inside('vendor') do + run('ln -s ~/edge rails') + end+ + + +
+ # File lib/bundler/vendor/thor/actions.rb, line 222 +222: def run(command, config={}) +223: return unless behavior == :invoke +224: +225: destination = relative_to_original_destination_root(destination_root, false) +226: desc = "#{command} from #{destination.inspect}" +227: +228: if config[:with] +229: desc = "#{File.basename(config[:with].to_s)} #{desc}" +230: command = "#{config[:with]} #{command}" +231: end +232: +233: say_status :run, desc, config.fetch(:verbose, true) +234: `#{command}` unless options[:pretend] +235: end+
+Executes a ruby script (taking into account WIN32 platform quirks). +
+command | +the command to be executed. + + |
config | +give :verbose => false to not log the status. + + |
+ # File lib/bundler/vendor/thor/actions.rb, line 243 +243: def run_ruby_script(command, config={}) +244: return unless behavior == :invoke +245: run command, config.merge(:with => Thor::Util.ruby_command) +246: end+
+Holds source paths in instance so they can be manipulated. +
+ + + ++ # File lib/bundler/vendor/thor/actions.rb, line 121 +121: def source_paths +122: @source_paths ||= self.class.source_paths_for_search +123: end+
+Gets an ERB template at the relative source, executes it and makes a copy +at the relative destination. If the destination is not given it’s +assumed to be equal to the source removing .tt from the filename. +
+source | +the relative path to the source root. + + |
destination | +the relative path to the destination root. + + |
config | +give :verbose => false to not log the status. + + |
+ template "README", "doc/README" + + template "doc/README"+ + + +
+ # File lib/bundler/vendor/thor/actions/file_manipulation.rb, line 81 +81: def template(source, *args, &block) +82: config = args.last.is_a?(Hash) ? args.pop : {} +83: destination = args.first || source +84: +85: source = File.expand_path(find_in_source_paths(source.to_s)) +86: context = instance_eval('binding') +87: +88: create_file destination, nil, config do +89: content = ERB.new(::File.binread(source), nil, '-').result(context) +90: content = block.call(content) if block +91: content +92: end +93: end+
+Run a thor command. A hash of options can be given and it’s converted +to switches. +
+task | +the task to be invoked + + |
args | +arguments to the task + + |
config | +give :verbose => false to not log the status. Other options are given as +parameter to Thor. + + |
+ thor :install, "http://gist.github.com/103208" + #=> thor install http://gist.github.com/103208 + + thor :list, :all => true, :substring => 'rails' + #=> thor list --all --substring=rails+ + + +
+ # File lib/bundler/vendor/thor/actions.rb, line 265 +265: def thor(task, *args) +266: config = args.last.is_a?(Hash) ? args.pop : {} +267: verbose = config.key?(:verbose) ? config.delete(:verbose) : true +268: pretend = config.key?(:pretend) ? config.delete(:pretend) : false +269: +270: args.unshift task +271: args.push Thor::Options.to_switches(config) +272: command = args.join(' ').strip +273: +274: run command, :with => :thor, :verbose => verbose, :pretend => pretend +275: end+
Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
++Add runtime options that help actions execution. +
+ + + ++ # File lib/bundler/vendor/thor/actions.rb, line 48 +48: def add_runtime_options! +49: class_option :force, :type => :boolean, :aliases => "-f", :group => :runtime, +50: :desc => "Overwrite files that already exist" +51: +52: class_option :pretend, :type => :boolean, :aliases => "-p", :group => :runtime, +53: :desc => "Run but do not make any changes" +54: +55: class_option :quiet, :type => :boolean, :aliases => "-q", :group => :runtime, +56: :desc => "Supress status output" +57: +58: class_option :skip, :type => :boolean, :aliases => "-s", :group => :runtime, +59: :desc => "Skip files that already exist" +60: end+
+Hold source paths for one Thor instance. source_paths_for_search +is the method responsible to gather source_paths from this +current class, inherited paths and the source root. +
+ + + ++ # File lib/bundler/vendor/thor/actions.rb, line 22 +22: def source_paths +23: @_source_paths ||= [] +24: end+
+Returns the source paths in the following order: +
++ 1) This class source paths + 2) Source root + 3) Parents source paths+ + + +
+ # File lib/bundler/vendor/thor/actions.rb, line 38 +38: def source_paths_for_search +39: paths = [] +40: paths += self.source_paths +41: paths << self.source_root if self.source_root +42: paths += from_superclass(:source_paths, []) +43: paths +44: end+
Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
++AddFile is a subset of Template, which instead of rendering a file with +ERB, it gets the content from the user. +
+ +Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
+Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
+Object
+ ++Class which holds create directory logic. This is the base class for other +actions like create_file and directory. +
++This implementation is based in Templater actions, created by Jonas Nicklas +and Michael S. Klishin under MIT LICENSE. +
+ +Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
+Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
+Object
+ +Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
+Object
+ +Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
++It receives arguments in an Array and two hashes, one for options and other +for configuration. +
++Notice that it does not check if all required arguments were supplied. It +should be done by the parser. +
+args | +An array of objects. The objects are applied to their respective accessors +declared with argument. + + |
options | +An options hash that will be available as self.options. The hash given is +converted to a hash with indifferent access, magic predicates +(options.skip?) and then frozen. + + |
config | +Configuration for this Thor class. + + |
+ # File lib/bundler/vendor/thor/base.rb, line 40 +40: def initialize(args=[], options={}, config={}) +41: args = Thor::Arguments.parse(self.class.arguments, args) +42: args.each { |key, value| send("#{key}=", value) } +43: +44: parse_options = self.class.class_options +45: +46: if options.is_a?(Array) +47: task_options = config.delete(:task_options) # hook for start +48: parse_options = parse_options.merge(task_options) if task_options +49: array_options, hash_options = options, {} +50: else +51: array_options, hash_options = [], options +52: end +53: +54: opts = Thor::Options.new(parse_options, hash_options) +55: self.options = opts.parse(array_options) +56: opts.check_unknown! if self.class.check_unknown_options?(config) +57: end+
+Returns the shell used in all Thor classes. If +you are in a Unix platform it will use a colored log, otherwise it will use +a basic one without color. +
+ + + ++ # File lib/bundler/vendor/thor/shell.rb, line 8 + 8: def self.shell + 9: @shell ||= if ENV['THOR_SHELL'] && ENV['THOR_SHELL'].size > 0 +10: Thor::Shell.const_get(ENV['THOR_SHELL']) +11: elsif RbConfig::CONFIG['host_os'] =~ /mswin|mingw/ +12: Thor::Shell::Basic +13: else +14: Thor::Shell::Color +15: end +16: end+
+Sets the shell used in all Thor classes. +
+ + + ++ # File lib/bundler/vendor/thor/shell.rb, line 20 +20: def self.shell=(klass) +21: @shell = klass +22: end+
+Returns the files where the subclasses are kept. +
+
+Hash[path
+ # File lib/bundler/vendor/thor/base.rb, line 80 +80: def subclass_files +81: @subclass_files ||= Hash.new{ |h,k| h[k] = [] } +82: end+
+Returns the classes that inherits from Thor or +Thor::Group. +
++Array[Class] +
+ + + ++ # File lib/bundler/vendor/thor/base.rb, line 71 +71: def subclasses +72: @subclasses ||= [] +73: end+
Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
++Returns the tasks for this Thor class and all +subclasses. +
+OrderedHash | +An ordered hash with tasks names as keys and Thor::Task objects as values. + + |
+ # File lib/bundler/vendor/thor/base.rb, line 294 +294: def all_tasks +295: @all_tasks ||= from_superclass(:all_tasks, Thor::CoreExt::OrderedHash.new) +296: @all_tasks.merge(tasks) +297: end+
+Adds an argument to the class and creates an attr_accessor for it. +
++Arguments are different from options in several aspects. The first one is +how they are parsed from the command line, arguments are retrieved from +position: +
++ thor task NAME ++
+Instead of: +
++ thor task --name=NAME ++
+Besides, arguments are used inside your code as an accessor +(self.argument), while options are all kept in a hash (self.options). +
++Finally, arguments cannot have type :default or :boolean but can be +optional (supplying :optional => :true or :required => false), although you +cannot have a required argument after a non-required argument. If you try +it, an error is raised. +
+name | +The name of the argument. + + |
options | +Described below. + + |
+:desc - Description for the argument. :required - If the argument is +required or not. :optional - If the argument is optional or not. :type +- The type of the argument, can be :string, :hash, :array, :numeric. +:default - Default value for this argument. It cannot be required and have +default values. :banner - String to show on usage notes. +
+ArgumentError | +Raised if you supply a required argument after a non required one. + + |
+ # File lib/bundler/vendor/thor/base.rb, line 160 +160: def argument(name, options={}) +161: is_thor_reserved_word?(name, :argument) +162: no_tasks { attr_accessor name } +163: +164: required = if options.key?(:optional) +165: !options[:optional] +166: elsif options.key?(:required) +167: options[:required] +168: else +169: options[:default].nil? +170: end +171: +172: remove_argument name +173: +174: arguments.each do |argument| +175: next if argument.required? +176: raise ArgumentError, "You cannot have #{name.to_s.inspect} as required argument after " << +177: "the non-required argument #{argument.human_name.inspect}." +178: end if required +179: +180: arguments << Thor::Argument.new(name, options[:desc], required, options[:type], +181: options[:default], options[:banner]) +182: end+
+Returns this class arguments, looking up in the ancestors chain. +
++Array[Thor::Argument] +
+ + + ++ # File lib/bundler/vendor/thor/base.rb, line 189 +189: def arguments +190: @arguments ||= from_superclass(:arguments, []) +191: end+
+If you want to raise an error for unknown options, call +check_unknown_options! This is disabled by default to allow dynamic +invocations. +
+ + + ++ # File lib/bundler/vendor/thor/base.rb, line 113 +113: def check_unknown_options! +114: @check_unknown_options = true +115: end+
+Adds an option to the set of class options +
+name | +The name of the argument. + + |
options | +Described below. + + |
+:desc - Description for the argument. :required - If the argument is +required or not. :default - Default value for this argument. :group - +The group for this options. Use by class options to output options in +different levels. :aliases - Aliases for this option. :type - The type +of the argument, can be :string, :hash, :array, :numeric or :boolean. +:banner - String to show on usage notes. +
+ + + ++ # File lib/bundler/vendor/thor/base.rb, line 223 +223: def class_option(name, options={}) +224: build_option(name, options, class_options) +225: end+
+Adds a bunch of options to the set of class options. +
++ class_options :foo => false, :bar => :required, :baz => :string ++
+If you prefer more detailed declaration, check class_option. +
++Hash[Symbol => Object] +
+ + + ++ # File lib/bundler/vendor/thor/base.rb, line 202 +202: def class_options(options=nil) +203: @class_options ||= from_superclass(:class_options, {}) +204: build_options(options, @class_options) if options +205: @class_options +206: end+
+Defines the group. This is used when thor list is invoked so you can +specify that only tasks from a pre-defined group will be shown. Defaults to +standard. +
+
+name
+ # File lib/bundler/vendor/thor/base.rb, line 269 +269: def group(name=nil) +270: case name +271: when nil +272: @group ||= from_superclass(:group, 'standard') +273: else +274: @group = name.to_s +275: end +276: end+
+Sets the namespace for the Thor or +Thor::Group class. By default the namespace is retrieved from the class +name. If your Thor class is named +Scripts::MyScript, the help method, for example, will be called as: +
++ thor scripts:my_script -h ++
+If you change the namespace: +
++ namespace :my_scripts ++
+You change how your tasks are invoked: +
++ thor my_scripts -h ++
+Finally, if you change your namespace to default: +
++ namespace :default ++
+Your tasks can be invoked with a shortcut. Instead of: +
++ thor :my_task+ + + +
+ # File lib/bundler/vendor/thor/base.rb, line 369 +369: def namespace(name=nil) +370: case name +371: when nil +372: @namespace ||= Thor::Util.namespace_from_thor_class(self) +373: else +374: @namespace = name.to_s +375: end +376: end+
+All methods defined inside the given block are not added as tasks. +
++So you can do: +
++ class MyScript < Thor + no_tasks do + def this_is_not_a_task + end + end + end ++
+You can also add the method and remove it from the task list: +
++ class MyScript < Thor + def this_is_not_a_task + end + remove_task :this_is_not_a_task + end+ + + +
+ # File lib/bundler/vendor/thor/base.rb, line 340 +340: def no_tasks +341: @no_tasks = true +342: yield +343: ensure +344: @no_tasks = false +345: end+
+Removes a previous defined argument. If :undefine is given, undefine +accessors as well. +
+names | +Arguments to be removed + + |
+ remove_argument :foo + remove_argument :foo, :bar, :baz, :undefine => true+ + + +
+ # File lib/bundler/vendor/thor/base.rb, line 238 +238: def remove_argument(*names) +239: options = names.last.is_a?(Hash) ? names.pop : {} +240: +241: names.each do |name| +242: arguments.delete_if { |a| a.name == name.to_s } +243: undef_method name, "#{name}=" if options[:undefine] +244: end +245: end+
+Removes a previous defined class option. +
+names | +Class options to be removed + + |
+ remove_class_option :foo + remove_class_option :foo, :bar, :baz+ + + +
+ # File lib/bundler/vendor/thor/base.rb, line 257 +257: def remove_class_option(*names) +258: names.each do |name| +259: class_options.delete(name) +260: end +261: end+
+Removes a given task from this Thor class. +This is usually done if you are inheriting from another class and +don’t want it to be available anymore. +
++By default it only remove the mapping to the task. But you can supply +:undefine => true to undefine the method from the class as well. +
+name | +The name of the task to be removed + + |
options | +You can give :undefine => true if you want tasks the method to be undefined +from the class as well. + + |
+ # File lib/bundler/vendor/thor/base.rb, line 311 +311: def remove_task(*names) +312: options = names.last.is_a?(Hash) ? names.pop : {} +313: +314: names.each do |name| +315: tasks.delete(name.to_s) +316: all_tasks.delete(name.to_s) +317: undef_method name if options[:undefine] +318: end +319: end+
+Parses the task and options from the given args, instantiate the class and +invoke the task. This method is used when the arguments must be parsed from +an array. If you are inside Ruby and want to use a Thor class, you can simply initialize it: +
++ script = MyScript.new(args, options, config) + script.invoke(:task, first_arg, second_arg, third_arg)+ + + +
+ # File lib/bundler/vendor/thor/base.rb, line 386 +386: def start(given_args=ARGV, config={}) +387: self.debugging = given_args.delete("--debug") +388: config[:shell] ||= Thor::Base.shell.new +389: dispatch(nil, given_args.dup, nil, config) +390: rescue Thor::Error => e +391: debugging ? (raise e) : config[:shell].error(e.message) +392: exit(1) if exit_on_failure? +393: end+
+Returns the tasks for this Thor class. +
+OrderedHash | +An ordered hash with tasks names as keys and Thor::Task objects as values. + + |
+ # File lib/bundler/vendor/thor/base.rb, line 284 +284: def tasks +285: @tasks ||= Thor::CoreExt::OrderedHash.new +286: end+
+A flag that makes the process exit with status 1 if any error happens. +
+ + + ++ # File lib/bundler/vendor/thor/base.rb, line 530 +530: def exit_on_failure? +531: false +532: end+
+Retrieves a value from superclass. If it reaches the baseclass, returns +default. +
+ + + ++ # File lib/bundler/vendor/thor/base.rb, line 520 +520: def from_superclass(method, default=nil) +521: if self == baseclass || !superclass.respond_to?(method, true) +522: default +523: else +524: value = superclass.send(method) +525: value.dup if value +526: end +527: end+
+Everytime someone inherits from a Thor class, +register the klass and file into baseclass. +
+ + + ++ # File lib/bundler/vendor/thor/base.rb, line 494 +494: def inherited(klass) +495: Thor::Base.register_klass_file(klass) +496: end+
+Fire this callback whenever a method is added. Added methods are tracked as +tasks by invoking the create_task method. +
+ + + ++ # File lib/bundler/vendor/thor/base.rb, line 500 +500: def method_added(meth) +501: meth = meth.to_s +502: +503: if meth == "initialize" +504: initialize_added +505: return +506: end +507: +508: # Return if it's not a public instance method +509: return unless public_instance_methods.include?(meth) || +510: public_instance_methods.include?(meth.to_sym) +511: +512: return if @no_tasks || !create_task(meth) +513: +514: is_thor_reserved_word?(meth, :task) +515: Thor::Base.register_klass_file(self) +516: end+
+Receives a set of options and print them. +
+ + + ++ # File lib/bundler/vendor/thor/base.rb, line 430 +430: def print_options(shell, options, group_name=nil) +431: return if options.empty? +432: +433: list = [] +434: padding = options.collect{ |o| o.aliases.size }.max.to_i * 4 +435: +436: options.each do |option| +437: item = [ option.usage(padding) ] +438: item.push(option.description ? "# #{option.description}" : "") +439: +440: list << item +441: list << [ "", "# Default: #{option.default}" ] if option.show_default? +442: end +443: +444: shell.say(group_name ? "#{group_name} options:" : "Options:") +445: shell.print_table(list, :ident => 2) +446: shell.say "" +447: end+
Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
+Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
+::Hash
+ ++A hash with indifferent access and magic predicates. +
++ hash = Thor::CoreExt::HashWithIndifferentAccess.new 'foo' => 'bar', 'baz' => 'bee', 'force' => true + + hash[:foo] #=> 'bar' + hash['foo'] #=> 'bar' + hash.foo? #=> true+ +
Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
+::Hash
+ ++This class is based on the Ruby 1.9 ordered hashes. +
++It keeps the semantics and most of the efficiency of normal hashes while +also keeping track of the order in which elements were set. +
+ +Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
++A dynamic task that handles method missing scenarios. +
+ ++ # File lib/bundler/vendor/thor/task.rb, line 106 +106: def run(instance, args=[]) +107: if (instance.methods & [name.to_s, name.to_sym]).empty? +108: super +109: else +110: instance.class.handle_no_task_error(name) +111: end +112: end+
Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
+StandardError
+ ++Thor::Error is raised when it’s caused by +wrong usage of thor classes. Those errors have their backtrace supressed +and are nicely shown to the user. +
++Errors that are caused by the developer, like declaring a method which +overwrites a thor keyword, it SHOULD NOT raise a Thor::Error. This way, we ensure that developer +errors are shown with full backtrace. +
+ +Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
++A task that is hidden in help messages but still invocable. +
+ +Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
++Receives a name and invokes it. The name can be a string (either +“task” or “namespace:task”), a Thor::Task, a Class or a Thor instance. If the task cannot be guessed by +name, it can also be supplied as second argument. +
++You can also supply the arguments, options and configuration values for the +task to be invoked, if none is given, the same values used to initialize +the invoker are used to initialize the invoked. +
++When no name is given, it will invoke the default task of the current +class. +
++ class A < Thor + def foo + invoke :bar + invoke "b:hello", ["José"] + end + + def bar + invoke "b:hello", ["José"] + end + end + + class B < Thor + def hello(name) + puts "hello #{name}" + end + end ++
+You can notice that the method “foo” above invokes two tasks: +“bar”, which belongs to the same class and “hello” +which belongs to the class B. +
++By using an invocation system you ensure that a task is invoked only once. +In the example above, invoking “foo” will invoke +“b:hello” just once, even if it’s invoked later by +“bar” method. +
++When class A invokes class B, all arguments used on A initialization are +supplied to B. This allows lazy parse of options. Let’s suppose you +have some rspec tasks: +
++ class Rspec < Thor::Group + class_option :mock_framework, :type => :string, :default => :rr + + def invoke_mock_framework + invoke "rspec:#{options[:mock_framework]}" + end + end ++
+As you noticed, it invokes the given mock framework, which might have its +own options: +
++ class Rspec::RR < Thor::Group + class_option :style, :type => :string, :default => :mock + end ++
+Since it’s not rspec concern to parse mock framework options, when RR +is invoked all options are parsed again, so RR can extract only the options +that it’s going to use. +
++If you want Rspec::RR to be initialized with its own set of options, you +have to do that explicitely: +
++ invoke "rspec:rr", [], :style => :foo ++
+Besides giving an instance, you can also give a class to invoke: +
++ invoke Rspec::RR, [], :style => :foo+ + + +
+ # File lib/bundler/vendor/thor/invocation.rb, line 96 + 96: def invoke(name=nil, *args) + 97: if name.nil? + 98: warn "[Thor] Calling invoke() without argument is deprecated. Please use invoke_all instead.\n#{caller.join("\n")}" + 99: return invoke_all +100: end +101: +102: args.unshift(nil) if Array === args.first || NilClass === args.first +103: task, args, opts, config = args +104: +105: klass, task = _retrieve_class_and_task(name, task) +106: raise "Expected Thor class, got #{klass}" unless klass <= Thor::Base +107: +108: args, opts, config = _parse_initialization_options(args, opts, config) +109: klass.send(:dispatch, task, args, opts, config) +110: end+
Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
+Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
++Raised when a task was found, but not invoked properly. +
+ +Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
+Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
+Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
++This is a modified version of Daniel Berger’s Getopt::Long class, +licensed under Ruby’s license. +
+ +Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
+Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
+Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
++Add shell to initialize config values. +
+shell | +An instance of the shell to be used. + + |
+ class MyScript < Thor + argument :first, :type => :numeric + end + + MyScript.new [1.0], { :foo => :bar }, :shell => Thor::Shell::Basic.new+ + + +
+ # File lib/bundler/vendor/thor/shell.rb, line 45 +45: def initialize(args=[], options={}, config={}) +46: super +47: self.shell = config[:shell] +48: self.shell.base ||= self if self.shell.respond_to?(:base) +49: end+
+Holds the shell for the given Thor instance. If +no shell is given, it gets a default shell from Thor::Base.shell. +
+ + + ++ # File lib/bundler/vendor/thor/shell.rb, line 53 +53: def shell +54: @shell ||= Thor::Base.shell.new +55: end+
Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
+Object
+ ++Ask something to the user and receives a response. +
++ask(“What is your name?”) +
+ + + ++ # File lib/bundler/vendor/thor/shell/basic.rb, line 25 +25: def ask(statement, color=nil) +26: say("#{statement} ", color) +27: $stdin.gets.strip +28: end+
+Called if something goes wrong during the execution. This is used by Thor internally and should not be used inside +your scripts. If someone went wrong, you can always raise an exception. If +you raise a Thor::Error, it will be rescued and +wrapped in the method below. +
+ + + ++ # File lib/bundler/vendor/thor/shell/basic.rb, line 187 +187: def error(statement) +188: $stderr.puts statement +189: end+
+Deals with file collision and returns true if the file should be overwriten +and false otherwise. If a block is given, it uses the block response as the +content for the diff. +
+destination | +the destination file to solve conflicts + + |
block | +an optional block that returns the value to be used in diff + + |
+ # File lib/bundler/vendor/thor/shell/basic.rb, line 156 +156: def file_collision(destination) +157: return true if @always_force +158: options = block_given? ? "[Ynaqdh]" : "[Ynaqh]" +159: +160: while true +161: answer = ask %[Overwrite #{destination}? (enter "h" for help) #{options}] +162: +163: case answer +164: when is?(:yes), is?(:force), "" +165: return true +166: when is?(:no), is?(:skip) +167: return false +168: when is?(:always) +169: return @always_force = true +170: when is?(:quit) +171: say 'Aborting...' +172: raise SystemExit +173: when is?(:diff) +174: show_diff(destination, yield) if block_given? +175: say 'Retrying...' +176: else +177: say file_collision_help +178: end +179: end +180: end+
+Make a question the to user and returns true if the user replies +“n” or “no”. +
+ + + ++ # File lib/bundler/vendor/thor/shell/basic.rb, line 78 +78: def no?(statement, color=nil) +79: !yes?(statement, color) +80: end+
+Sets the output padding, not allowing less than zero values. +
+ + + ++ # File lib/bundler/vendor/thor/shell/basic.rb, line 16 +16: def padding=(value) +17: @padding = [0, value].max +18: end+
+Prints a table. +
++Array[Array[String, String, …]] +
+ident | +Indent the first column by ident value. + + |
colwidth | +Force the first column to colwidth spaces wide. + + |
+ # File lib/bundler/vendor/thor/shell/basic.rb, line 91 + 91: def print_table(table, options={}) + 92: return if table.empty? + 93: + 94: formats, ident, colwidth = [], options[:ident].to_i, options[:colwidth] + 95: options[:truncate] = terminal_width if options[:truncate] == true + 96: + 97: formats << "%-#{colwidth + 2}s" if colwidth + 98: start = colwidth ? 1 : 0 + 99: +100: start.upto(table.first.length - 2) do |i| +101: maxima ||= table.max{|a,b| a[i].size <=> b[i].size }[i].size +102: formats << "%-#{maxima + 2}s" +103: end +104: +105: formats[0] = formats[0].insert(0, " " * ident) +106: formats << "%s" +107: +108: table.each do |row| +109: sentence = "" +110: +111: row.each_with_index do |column, i| +112: sentence << formats[i] % column.to_s +113: end +114: +115: sentence = truncate(sentence, options[:truncate]) if options[:truncate] +116: $stdout.puts sentence +117: end +118: end+
+Prints a long string, word-wrapping the text to the current width of the +terminal display. Ideal for printing heredocs. +
++String +
+ident | +Indent each line of the printed paragraph by ident value. + + |
+ # File lib/bundler/vendor/thor/shell/basic.rb, line 129 +129: def print_wrapped(message, options={}) +130: ident = options[:ident] || 0 +131: width = terminal_width - ident +132: paras = message.split("\n\n") +133: +134: paras.map! do |unwrapped| +135: unwrapped.strip.gsub(/\n/, " ").squeeze(" "). +136: gsub(/.{1,#{width}}(?:\s|\Z)/){($& + 5.chr). +137: gsub(/\n\0005/,"\n").gsub(/\0005/,"\n")} +138: end +139: +140: paras.each do |para| +141: para.split("\n").each do |line| +142: $stdout.puts line.insert(0, " " * ident) +143: end +144: $stdout.puts unless para == paras.last +145: end +146: end+
+Say (print) something to the user. If the sentence ends with a whitespace +or tab character, a new line is not appended (print + flush). Otherwise are +passed straight to puts (behavior got from Highline). +
++say(“I know you knew that.”) +
+ + + ++ # File lib/bundler/vendor/thor/shell/basic.rb, line 37 +37: def say(message="", color=nil, force_new_line=(message.to_s !~ /( |\t)$/)) +38: message = message.to_s +39: message = set_color(message, color) if color +40: +41: spaces = " " * padding +42: +43: if force_new_line +44: $stdout.puts(spaces + message) +45: else +46: $stdout.print(spaces + message) +47: end +48: $stdout.flush +49: end+
+Say a status with the given color and appends the message. Since this +method is used frequently by actions, it allows nil or false to be given in +log_status, avoiding the message from being shown. If a Symbol is given in +log_status, it’s used as the color. +
+ + + ++ # File lib/bundler/vendor/thor/shell/basic.rb, line 56 +56: def say_status(status, message, log_status=true) +57: return if quiet? || log_status == false +58: spaces = " " * (padding + 1) +59: color = log_status.is_a?(Symbol) ? log_status : :green +60: +61: status = status.to_s.rjust(12) +62: status = set_color status, color, true if color +63: +64: $stdout.puts "#{status}#{spaces}#{message}" +65: $stdout.flush +66: end+
+Make a question the to user and returns true if the user replies +“y” or “yes”. +
+ + + ++ # File lib/bundler/vendor/thor/shell/basic.rb, line 71 +71: def yes?(statement, color=nil) +72: ask(statement, color) =~ is?(:yes) +73: end+
+Calculate the dynamic width of the terminal +
+ + + ++ # File lib/bundler/vendor/thor/shell/basic.rb, line 249 +249: def dynamic_width +250: @dynamic_width ||= (dynamic_width_stty.nonzero? || dynamic_width_tput) +251: end+
+ # File lib/bundler/vendor/thor/shell/basic.rb, line 253 +253: def dynamic_width_stty +254: %{stty size 2>/dev/null}.split[1].to_i +255: end+
+ # File lib/bundler/vendor/thor/shell/basic.rb, line 257 +257: def dynamic_width_tput +258: %{tput cols 2>/dev/null}.to_i +259: end+
+This code was copied from Rake, available under MIT-LICENSE Copyright +© 2003, 2004 Jim Weirich +
+ + + ++ # File lib/bundler/vendor/thor/shell/basic.rb, line 237 +237: def terminal_width +238: if ENV['THOR_COLUMNS'] +239: result = ENV['THOR_COLUMNS'].to_i +240: else +241: result = unix? ? dynamic_width : 80 +242: end +243: (result < 10) ? 80 : result +244: rescue +245: 80 +246: end+
+ # File lib/bundler/vendor/thor/shell/basic.rb, line 265 +265: def truncate(string, width) +266: if string.length <= width +267: string +268: else +269: ( string[0, width-3] || "" ) + "..." +270: end +271: end+
Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
++Inherit from Thor::Shell::Basic and add set_color behavior. Check Thor::Shell::Basic to see all available methods. +
+ ++Embed in a String to clear all previous ANSI sequences. +
+The start of an ANSI bold sequence. +
+Set the terminal’s foreground ANSI color to black. +
+Set the terminal’s foreground ANSI color to red. +
+Set the terminal’s foreground ANSI color to green. +
+Set the terminal’s foreground ANSI color to yellow. +
+Set the terminal’s foreground ANSI color to blue. +
+Set the terminal’s foreground ANSI color to magenta. +
+Set the terminal’s foreground ANSI color to cyan. +
+Set the terminal’s foreground ANSI color to white. +
+Set the terminal’s background ANSI color to black. +
+Set the terminal’s background ANSI color to red. +
+Set the terminal’s background ANSI color to green. +
+Set the terminal’s background ANSI color to yellow. +
+Set the terminal’s background ANSI color to blue. +
+Set the terminal’s background ANSI color to magenta. +
+Set the terminal’s background ANSI color to cyan. +
+Set the terminal’s background ANSI color to white. +
+Set color by using a string or one of the defined constants. If a third +option is set to true, it also adds bold to the string. This is based on +Highline implementation and it automatically appends CLEAR to the end of the returned String. +
+ + + ++ # File lib/bundler/vendor/thor/shell/color.rb, line 53 +53: def set_color(string, color, bold=false) +54: color = self.class.const_get(color.to_s.upcase) if color.is_a?(Symbol) +55: bold = bold ? BOLD : "" +56: "#{bold}#{color}#{string}#{CLEAR}" +57: end+
Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
++Inherit from Thor::Shell::Basic and add set_color behavior. Check Thor::Shell::Basic to see all available methods. +
+ ++The start of an HTML bold sequence. +
+The end of an HTML bold sequence. +
+Embed in a String to clear previous color selection. +
+Set the terminal’s foreground HTML color to +black. +
+Set the terminal’s foreground HTML color to +red. +
+Set the terminal’s foreground HTML color to +green. +
+Set the terminal’s foreground HTML color to +yellow. +
+Set the terminal’s foreground HTML color to +blue. +
+Set the terminal’s foreground HTML color to +magenta. +
+Set the terminal’s foreground HTML color to +cyan. +
+Set the terminal’s foreground HTML color to +white. +
+Set the terminal’s background HTML color to +black. +
+Set the terminal’s background HTML color to +red. +
+Set the terminal’s background HTML color to +green. +
+Set the terminal’s background HTML color to +yellow. +
+Set the terminal’s background HTML color to +blue. +
+Set the terminal’s background HTML color to +magenta. +
+Set the terminal’s background HTML color to +cyan. +
+Set the terminal’s background HTML color to +white. +
+Ask something to the user and receives a response. +
++ask(“What is your name?”) +
++TODO: Implement ask for Thor::Shell::HTML +
+ + + ++ # File lib/bundler/vendor/thor/shell/html.rb, line 68 +68: def ask(statement, color=nil) +69: raise NotImplementedError, "Implement #ask for Thor::Shell::HTML" +70: end+
+Set color by using a string or one of the defined constants. If a third +option is set to true, it also adds bold to the string. This is based on +Highline implementation and it automatically appends CLEAR to the end of the returned String. +
+ + + ++ # File lib/bundler/vendor/thor/shell/html.rb, line 56 +56: def set_color(string, color, bold=false) +57: color = self.class.const_get(color.to_s.upcase) if color.is_a?(Symbol) +58: bold, end_bold = bold ? [BOLD, END_BOLD] : ['', ''] +59: "#{bold}#{color}#{string}#{CLEAR}#{end_bold}" +60: end+
Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
+Struct.new(:name, :description, :long_description, :usage, :options)
+ ++ # File lib/bundler/vendor/thor/task.rb, line 5 +5: def initialize(name, description, long_description, usage, options=nil) +6: super(name.to_s, description, long_description, usage, options || {}) +7: end+
+Returns the formatted usage by injecting given required arguments and +required options into the given usage. +
+ + + ++ # File lib/bundler/vendor/thor/task.rb, line 33 +33: def formatted_usage(klass, namespace = true, subcommand = false) +34: if namespace +35: namespace = klass.namespace +36: formatted = "#{namespace.gsub(/^(default)/,'')}:" +37: formatted.sub!(/.$/, ' ') if subcommand +38: end +39: +40: formatted ||= "" +41: +42: # Add usage with required arguments +43: formatted << if klass && !klass.arguments.empty? +44: usage.to_s.gsub(/^#{name}/) do |match| +45: match << " " << klass.arguments.map{ |a| a.usage }.compact.join(' ') +46: end +47: else +48: usage.to_s +49: end +50: +51: # Add required options +52: formatted << " #{required_options}" +53: +54: # Strip and go! +55: formatted.strip +56: end+
+By default, a task invokes a method in the thor class. You can change this +implementation to create custom tasks. +
+ + + ++ # File lib/bundler/vendor/thor/task.rb, line 20 +20: def run(instance, args=[]) +21: public_method?(instance) ? +22: instance.send(name, *args) : instance.class.handle_no_task_error(name) +23: rescue ArgumentError => e +24: handle_argument_error?(instance, e, caller) ? +25: instance.class.handle_argument_error(self, e) : (raise e) +26: rescue NoMethodError => e +27: handle_no_method_error?(instance, e, caller) ? +28: instance.class.handle_no_task_error(name) : (raise e) +29: end+
+ # File lib/bundler/vendor/thor/task.rb, line 79 +79: def handle_argument_error?(instance, error, caller) +80: not_debugging?(instance) && error.message =~ /wrong number of arguments/ && begin +81: saned = sans_backtrace(error.backtrace, caller) +82: # Ruby 1.9 always include the called method in the backtrace +83: saned.empty? || (saned.size == 1 && RUBY_VERSION >= "1.9") +84: end +85: end+
+ # File lib/bundler/vendor/thor/task.rb, line 87 +87: def handle_no_method_error?(instance, error, caller) +88: not_debugging?(instance) && +89: error.message =~ /^undefined method `#{name}' for #{Regexp.escape(instance.to_s)}$/ +90: end+
Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
++Raised when a task was not found. +
+ +Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
+Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
++This module holds several utilities: +
++1) Methods to convert thor namespaces to constants and vice-versa. +
++ Thor::Utils.namespace_from_thor_class(Foo::Bar::Baz) #=> "foo:bar:baz" ++
+2) Loading thor files and sandboxing: +
++ Thor::Utils.load_thorfile("~/.thor/foo")+ +
+Receives a string and convert it to camel case. camel_case returns CamelCase. +
++String +
++String +
+ + + ++ # File lib/bundler/vendor/thor/util.rb, line 104 +104: def self.camel_case(str) +105: return str if str !~ /_/ && str =~ /[A-Z]+.*/ +106: str.split('_').map { |i| i.capitalize }.join +107: end+
+Receives a namespace and search for it in the Thor::Base subclasses. +
+namespace | +The namespace to search for. + + |
+ # File lib/bundler/vendor/thor/util.rb, line 24 +24: def self.find_by_namespace(namespace) +25: namespace = "default#{namespace}" if namespace.empty? || namespace =~ /^:/ +26: Thor::Base.subclasses.find { |klass| klass.namespace == namespace } +27: end+
+Receives a namespace and tries to retrieve a Thor or Thor::Group class from it. It first +searches for a class using the all the given namespace, if it’s not +found, removes the highest entry and searches for the class again. If +found, returns the highest entry as the class name. +
++ class Foo::Bar < Thor + def baz + end + end + + class Baz::Foo < Thor::Group + end + + Thor::Util.namespace_to_thor_class("foo:bar") #=> Foo::Bar, nil # will invoke default task + Thor::Util.namespace_to_thor_class("baz:foo") #=> Baz::Foo, nil + Thor::Util.namespace_to_thor_class("foo:bar:baz") #=> Foo::Bar, "baz" ++
+namespace
+ # File lib/bundler/vendor/thor/util.rb, line 131 +131: def self.find_class_and_task_by_namespace(namespace, fallback = true) +132: if namespace.include?(::) # look for a namespaced task +133: pieces = namespace.split(":") +134: task = pieces.pop +135: klass = Thor::Util.find_by_namespace(pieces.join(":")) +136: end +137: unless klass # look for a Thor::Group with the right name +138: klass, task = Thor::Util.find_by_namespace(namespace), nil +139: end +140: if !klass && fallback # try a task in the default namespace +141: task = namespace +142: klass = Thor::Util.find_by_namespace('') +143: end +144: return klass, task +145: end+
+Where to look for Thor files. +
+ + + ++ # File lib/bundler/vendor/thor/util.rb, line 210 +210: def self.globs_for(path) +211: ["#{path}/Thorfile", "#{path}/*.thor", "#{path}/tasks/*.thor", "#{path}/lib/tasks/*.thor"] +212: end+
+Receives a path and load the thor file in the path. The file is evaluated +inside the sandbox to avoid namespacing conflicts. +
+ + + ++ # File lib/bundler/vendor/thor/util.rb, line 150 +150: def self.load_thorfile(path, content=nil, debug=false) +151: content ||= File.binread(path) +152: +153: begin +154: Thor::Sandbox.class_eval(content, path) +155: rescue Exception => e +156: $stderr.puts "WARNING: unable to load thorfile #{path.inspect}: #{e.message}" +157: if debug +158: $stderr.puts *e.backtrace +159: else +160: $stderr.puts e.backtrace.first +161: end +162: end +163: end+
+Receives a constant and converts it to a Thor +namespace. Since Thor tasks can be added to a +sandbox, this method is also responsable for removing the sandbox +namespace. +
++This method should not be used in general because it’s used to deal +with older versions of Thor. On current +versions, if you need to get the namespace from a class, just call +namespace on it. +
+constant | +The constant to be converted to the thor path. + + |
String | +If we receive Foo::Bar::Baz it returns “foo:bar:baz“ + + |
+ # File lib/bundler/vendor/thor/util.rb, line 43 +43: def self.namespace_from_thor_class(constant) +44: constant = constant.to_s.gsub(/^Thor::Sandbox::/, "") +45: constant = snake_case(constant).squeeze(":") +46: constant +47: end+
+Given the contents, evaluate it inside the sandbox and returns the +namespaces defined in the sandbox. +
+
+contents
+Array[Object] +
+ + + ++ # File lib/bundler/vendor/thor/util.rb, line 58 +58: def self.namespaces_in_content(contents, file=__FILE__) +59: old_constants = Thor::Base.subclasses.dup +60: Thor::Base.subclasses.clear +61: +62: load_thorfile(file, contents) +63: +64: new_constants = Thor::Base.subclasses.dup +65: Thor::Base.subclasses.replace(old_constants) +66: +67: new_constants.map!{ |c| c.namespace } +68: new_constants.compact! +69: new_constants +70: end+
+Return the path to the ruby interpreter taking into account multiple +installations and windows extensions. +
+ + + ++ # File lib/bundler/vendor/thor/util.rb, line 217 +217: def self.ruby_command +218: @ruby_command ||= begin +219: ruby = File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name']) +220: ruby << RbConfig::CONFIG['EXEEXT'] +221: +222: # escape string in case path to ruby executable contain spaces. +223: ruby.sub!(/.*\s.*/, '"\&"') +224: ruby +225: end +226: end+
+Receives a string and convert it to snake case. SnakeCase returns +snake_case. +
++String +
++String +
+ + + ++ # File lib/bundler/vendor/thor/util.rb, line 90 +90: def self.snake_case(str) +91: return str.downcase if str =~ /^[A-Z_]+$/ +92: str.gsub(/\B[A-Z]/, '_\&').squeeze('_') =~ /_*(.*)/ +93: return $+.downcase +94: end+
+Returns the thor classes declared inside the given class. +
+ + + ++ # File lib/bundler/vendor/thor/util.rb, line 74 +74: def self.thor_classes_in(klass) +75: stringfied_constants = klass.constants.map { |c| c.to_s } +76: Thor::Base.subclasses.select do |subclass| +77: next unless subclass.name +78: stringfied_constants.include?(subclass.name.gsub("#{klass.name}::", '')) +79: end +80: end+
+Returns the root where thor files are located, dependending on the OS. +
+ + + ++ # File lib/bundler/vendor/thor/util.rb, line 189 +189: def self.thor_root +190: File.join(user_home, ".thor").gsub(/\\/, '/') +191: end+
+Returns the files in the thor root. On Windows thor_root will be something like +this: +
++ C:\Documents and Settings\james\.thor ++
+If we don’t gsub the \ character, Dir.glob will fail. +
+ + + ++ # File lib/bundler/vendor/thor/util.rb, line 200 +200: def self.thor_root_glob +201: files = Dir["#{thor_root}/*"] +202: +203: files.map! do |file| +204: File.directory?(file) ? File.join(file, "main.thor") : file +205: end +206: end+
+ # File lib/bundler/vendor/thor/util.rb, line 165 +165: def self.user_home +166: @@user_home ||= if ENV["HOME"] +167: ENV["HOME"] +168: elsif ENV["USERPROFILE"] +169: ENV["USERPROFILE"] +170: elsif ENV["HOMEDRIVE"] && ENV["HOMEPATH"] +171: File.join(ENV["HOMEDRIVE"], ENV["HOMEPATH"]) +172: elsif ENV["APPDATA"] +173: ENV["APPDATA"] +174: else +175: begin +176: File.expand_path("~") +177: rescue +178: if File::ALT_SEPARATOR +179: "C:/" +180: else +181: "/" +182: end +183: end +184: end +185: end+
Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
+This is the API documentation for 'bundler-1.0.0 Documentation'.
+ + + + +Generated with the Darkfish + Rdoc Generator 1.1.6.
+