diff --git a/CHANGELOG b/CHANGELOG index a2557917..09248c18 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,7 +1,7 @@ N.B.: You *must* run ruby bundle - rake upgrade_instiki + ruby bundle exec rake upgrade_instiki after installing the new software, to enjoy the benefits of this new version. diff --git a/Gemfile b/Gemfile index 79b9a314..fb74bead 100644 --- a/Gemfile +++ b/Gemfile @@ -7,5 +7,7 @@ gem "rubyzip" gem "RedCloth", ">=4.0.0" gem "erubis" gem "nokogiri" -gem "rake", "~>0.8.7" +gem "rake" +gem "rdoc" gem "json" +#gem "themes_for_rails" diff --git a/UPGRADING b/UPGRADING index b232de78..6eabda39 100644 --- a/UPGRADING +++ b/UPGRADING @@ -11,7 +11,7 @@ At a minimum, you need to backup your database. After installing the new software and restoring your database, you need to run ruby bundle - rake upgrade_instiki + ruby bundle exec rake upgrade_instiki from the commandline, to complete the upgrade. Doing a diff --git a/lib/chunks/chunk.rb b/lib/chunks/chunk.rb index c1a8e2ac..0a4b96db 100644 --- a/lib/chunks/chunk.rb +++ b/lib/chunks/chunk.rb @@ -48,11 +48,14 @@ module Chunk # chunk for it, and replace the occurance of the chunk # in this content with its mask. def self.apply_to(content) - content.gsub!( self.pattern ) do |match| + text = content.to_str + text.gsub!( self.pattern ) do |match| +# content.replace text new_chunk = self.new($~, content) content.add_chunk(new_chunk) new_chunk.mask - end + end + content.replace text end # should contain only [a-z0-9] @@ -61,7 +64,7 @@ module Chunk end def unmask - @content.sub!(mask){|s| s.replace @unmask_text} + @content.replace @content.sub(mask){|s| s.replace @unmask_text} end def rendered? @@ -73,7 +76,7 @@ module Chunk end def revert - @content.sub!(mask){|s| s.replace @text} + @content.replace @content.sub(mask){|s| s.replace @text} # unregister @content.delete_chunk(self) end diff --git a/lib/chunks/engines.rb b/lib/chunks/engines.rb index 9c7d07d0..1c72b266 100644 --- a/lib/chunks/engines.rb +++ b/lib/chunks/engines.rb @@ -114,7 +114,7 @@ module Engines class Mixed < AbstractEngine def mask @content.as_utf8 - redcloth = OldRedCloth.new(@content, @content.options[:engine_opts]) + redcloth = OldRedCloth.new(@content.to_str, @content.options[:engine_opts]) redcloth.filter_html = false redcloth.no_span_caps = false html = redcloth.to_html @@ -123,8 +123,7 @@ module Engines class RDoc < AbstractEngine def mask - @content.as_utf8 - html = RDocSupport::RDocFormatter.new(@content).to_html + html = RDocSupport::RDocFormatter.new(@content.as_utf8.to_str).to_html end end diff --git a/lib/chunks/literal.rb b/lib/chunks/literal.rb index 35adabcd..da17c9b9 100644 --- a/lib/chunks/literal.rb +++ b/lib/chunks/literal.rb @@ -30,9 +30,9 @@ module Literal # A literal chunk that protects equations from wiki rendering. class Math < AbstractLiteral - MATH_START = '(\${1,2}|' + Regexp.escape('\[') + '|\\begin\{equation\})' - MATH_END = '(\${1,2}|' + Regexp.escape('\]') + '|\\end\{equation\})' - MATH_PATTERN = Regexp.new(MATH_START + '([^$]|\\\$)+?' + MATH_END, Regexp::MULTILINE) + MATH_START = "(?:\\\\\\[|\\${1,2}|\\\\begin\\{equation\\})" + MATH_END = "(?:\\\\\\]|\\${1,2}|\\\\end\\{equation\\})" + MATH_PATTERN = Regexp.new( '(' + MATH_START + "(?:\\\\\\$|(?!\\$|\\\\\\]|\\\\end\\{equation\\}).)+?" + MATH_END + ')', Regexp::MULTILINE) def self.pattern() MATH_PATTERN end end diff --git a/lib/chunks/wiki.rb b/lib/chunks/wiki.rb index 193183b8..1f76b8a6 100644 --- a/lib/chunks/wiki.rb +++ b/lib/chunks/wiki.rb @@ -34,7 +34,8 @@ module WikiChunk end def self.apply_to(content) - content.as_utf8.gsub!( self.pattern ) do |matched_text| + text = content.as_utf8.to_str + text.gsub!( self.pattern ) do |matched_text| chunk = self.new($~, content) if chunk.textile_url? # do not substitute @@ -44,6 +45,7 @@ module WikiChunk chunk.mask end end + content.replace text end def textile_url? diff --git a/lib/rdocsupport.rb b/lib/rdocsupport.rb index b518a651..5f53c2bf 100644 --- a/lib/rdocsupport.rb +++ b/lib/rdocsupport.rb @@ -39,7 +39,7 @@ class RDocMarkup < SM::SimpleMarkup end def convert(text, handler) - super.sub(/^
\n/, '').sub(/<\/p>$/, '') + super.sub(/^\n{0,1}
\n{0,1}/, '').sub(/\n{0,1}<\/p>\n{0,1}$/, '') end end diff --git a/lib/tasks/upgrade_instiki.rake b/lib/tasks/upgrade_instiki.rake index 35b66954..c77add8f 100644 --- a/lib/tasks/upgrade_instiki.rake +++ b/lib/tasks/upgrade_instiki.rake @@ -31,4 +31,4 @@ class InstikiUpgrade end end -end \ No newline at end of file +end diff --git a/lib/wiki_content.rb b/lib/wiki_content.rb index 2f538443..a757501a 100644 --- a/lib/wiki_content.rb +++ b/lib/wiki_content.rb @@ -208,7 +208,8 @@ class WikiContent < ActiveSupport::SafeBuffer @options[:engine].apply_to(self) as_utf8 # unmask in one go. $~[1] is the chunk id - gsub!(MASK_RE[ACTIVE_CHUNKS]) do + text = self.to_str + text.gsub!(MASK_RE[ACTIVE_CHUNKS]) do chunk = @chunks_by_id[$~[1].to_i] if chunk.nil? # if we match a chunkmask that existed in the original content string @@ -218,7 +219,7 @@ class WikiContent < ActiveSupport::SafeBuffer chunk.unmask_text end end - self.replace xhtml_sanitize(self) + self.replace xhtml_sanitize(text) self.html_safe end diff --git a/rakefile.rb b/rakefile.rb index cffd19f0..b0fe9317 100755 --- a/rakefile.rb +++ b/rakefile.rb @@ -1,10 +1,17 @@ # Add your own tasks in files placed in lib/tasks ending in .rake, # for example lib/tasks/switchtower.rake, and they will automatically be available to Rake. -require(File.join(File.dirname(__FILE__), 'config', 'boot')) +require File.join(File.dirname(__FILE__), 'config', 'boot') require 'rake' +class Rails::Application + include Rake::DSL if defined?(Rake::DSL) +end require 'rake/testtask' -require 'rake/rdoctask' +begin + require 'rdoc/task' +rescue LoadError + require 'rake/rdoctask' +end -require 'tasks/rails' \ No newline at end of file +require 'tasks/rails' diff --git a/test/functional/wiki_controller_test.rb b/test/functional/wiki_controller_test.rb index e1c5a050..3c8ab806 100644 --- a/test/functional/wiki_controller_test.rb +++ b/test/functional/wiki_controller_test.rb @@ -123,7 +123,7 @@ class WikiControllerTest < ActionController::TestCase r = process 'edit', 'web' => 'wiki1', 'id' => 'With : Special /> symbols' assert_response(:success) - xml = REXML::Document.new(r.body) + xml = REXML::Document.new(r.body.to_str) form = REXML::XPath.first(xml, '//form') assert_equal '/wiki1/save/With+%3A+Special+%2F%3E+symbols', form.attributes['action'] end diff --git a/test/unit/page_renderer_test.rb b/test/unit/page_renderer_test.rb index 60a48848..c17fd4cb 100644 --- a/test/unit/page_renderer_test.rb +++ b/test/unit/page_renderer_test.rb @@ -414,7 +414,7 @@ END_THM :author => Author.new('DavidHeinemeierHansson')) assert_equal "hello that Smart Engine GUI" + - "?\n\n", + "?", x_test_renderer(@revision).display_content end diff --git a/vendor/plugins/bundler/bin/bundle b/vendor/plugins/bundler/bin/bundle index d6bad547..3d7e4838 100755 --- a/vendor/plugins/bundler/bin/bundle +++ b/vendor/plugins/bundler/bin/bundle @@ -1,4 +1,4 @@ -#!/usr/bin/env ruby +#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby # # This file was generated by RubyGems. # @@ -7,8 +7,6 @@ # require 'rubygems' -Gem.use_paths File.join(File.dirname(File.dirname(__FILE__))), Gem.path -Gem.refresh version = ">= 0" diff --git a/vendor/plugins/bundler/cache/bundler-1.0.15.gem b/vendor/plugins/bundler/cache/bundler-1.0.15.gem new file mode 100644 index 00000000..f64a9b2f Binary files /dev/null and b/vendor/plugins/bundler/cache/bundler-1.0.15.gem differ diff --git a/vendor/plugins/bundler/cache/bundler-1.0.7.gem b/vendor/plugins/bundler/cache/bundler-1.0.7.gem deleted file mode 100644 index 1cf9452e..00000000 Binary files a/vendor/plugins/bundler/cache/bundler-1.0.7.gem and /dev/null differ diff --git a/vendor/plugins/bundler/doc/bundler-1.0.7/rdoc/Bundler.html b/vendor/plugins/bundler/doc/bundler-1.0.15/rdoc/Bundler.html similarity index 80% rename from vendor/plugins/bundler/doc/bundler-1.0.7/rdoc/Bundler.html rename to vendor/plugins/bundler/doc/bundler-1.0.15/rdoc/Bundler.html index 29e77abd..1a14b739 100644 --- a/vendor/plugins/bundler/doc/bundler-1.0.7/rdoc/Bundler.html +++ b/vendor/plugins/bundler/doc/bundler-1.0.15/rdoc/Bundler.html @@ -83,6 +83,9 @@
- # File lib/bundler.rb, line 166 -166: def app_cache -167: root.join("vendor/cache") -168: end+ # File lib/bundler.rb, line 174 +174: def app_cache +175: root.join("vendor/cache") +176: 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 168 +168: def app_config_path +169: ENV['BUNDLE_APP_CONFIG'] ? +170: Pathname.new(ENV['BUNDLE_APP_CONFIG']).expand_path(root) : +171: root.join('.bundle') +172: 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 92 +92: def bin_path +93: @bin_path ||= begin +94: path = settings[:bin] || "bin" +95: path = Pathname.new(path).expand_path(root) +96: FileUtils.mkdir_p(path) +97: Pathname.new(path).expand_path +98: end +99: 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 88 +88: def bundle_path +89: @bundle_path ||= Pathname.new(settings.path).expand_path(root) +90: end
- # File lib/bundler.rb, line 152 -152: def cache -153: bundle_path.join("cache/bundler") -154: end+ # File lib/bundler.rb, line 160 +160: def cache +161: bundle_path.join("cache/bundler") +162: 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 77 +77: def configure +78: @configured ||= begin +79: configure_gem_home_and_path +80: true +81: end +82: end
- # File lib/bundler.rb, line 186 -186: def default_gemfile -187: SharedHelpers.default_gemfile -188: end+ # File lib/bundler.rb, line 194 +194: def default_gemfile +195: SharedHelpers.default_gemfile +196: end
- # File lib/bundler.rb, line 190 -190: def default_lockfile -191: SharedHelpers.default_lockfile -192: end+ # File lib/bundler.rb, line 198 +198: def default_lockfile +199: SharedHelpers.default_lockfile +200: 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 131 +131: def definition(unlock = nil) +132: @definition = nil if unlock +133: @definition ||= begin +134: configure +135: upgrade_lockfile +136: Definition.build(default_gemfile, default_lockfile, unlock) +137: end +138: end
- # File lib/bundler.rb, line 119 -119: def environment -120: Bundler::Environment.new(root, definition) -121: end+ # File lib/bundler.rb, line 127 +127: def environment +128: Bundler::Environment.new(root, definition) +129: end
- # File lib/bundler.rb, line 140 -140: def home -141: bundle_path.join("bundler") -142: end+ # File lib/bundler.rb, line 148 +148: def home +149: bundle_path.join("bundler") +150: end
- # File lib/bundler.rb, line 144 -144: def install_path -145: home.join("gems") -146: end+ # File lib/bundler.rb, line 152 +152: def install_path +153: home.join("gems") +154: end
- # File lib/bundler.rb, line 115 -115: def load -116: @load ||= Runtime.new(root, definition) -117: end+ # File lib/bundler.rb, line 123 +123: def load +124: @load ||= Runtime.new(root, definition) +125: end
- # File lib/bundler.rb, line 221 -221: def load_gemspec(file) -222: path = Pathname.new(file) -223: # Eval the gemspec from its parent directory -224: Dir.chdir(path.dirname) do -225: begin -226: Gem::Specification.from_yaml(path.basename) -227: # Raises ArgumentError if the file is not valid YAML -228: rescue ArgumentError, SyntaxError, Gem::EndOfYAMLException, Gem::Exception -229: begin -230: eval(File.read(path.basename), TOPLEVEL_BINDING, path.expand_path.to_s) -231: rescue LoadError => e -232: original_line = e.backtrace.find { |line| line.include?(path.to_s) } -233: msg = "There was a LoadError while evaluating #{path.basename}:\n #{e.message}" -234: msg << " from\n #{original_line}" if original_line -235: msg << "\n" -236: -237: if RUBY_VERSION >= "1.9.0" -238: msg << "\nDoes it try to require a relative path? That doesn't work in Ruby 1.9." -239: end -240: -241: raise GemspecError, msg -242: end -243: end -244: end -245: end+ # File lib/bundler.rb, line 229 +229: def load_gemspec(file) +230: path = Pathname.new(file) +231: # Eval the gemspec from its parent directory +232: Dir.chdir(path.dirname.to_s) do +233: contents = File.read(path.basename.to_s) +234: begin +235: Gem::Specification.from_yaml(contents) +236: # Raises ArgumentError if the file is not valid YAML +237: rescue ArgumentError, SyntaxError, Gem::EndOfYAMLException, Gem::Exception +238: begin +239: eval(contents, TOPLEVEL_BINDING, path.expand_path.to_s) +240: rescue LoadError => e +241: original_line = e.backtrace.find { |line| line.include?(path.to_s) } +242: msg = "There was a LoadError while evaluating #{path.basename}:\n #{e.message}" +243: msg << " from\n #{original_line}" if original_line +244: msg << "\n" +245: +246: if RUBY_VERSION >= "1.9.0" +247: msg << "\nDoes it try to require a relative path? That doesn't work in Ruby 1.9." +248: end +249: +250: raise GemspecError, msg +251: end +252: end +253: end +254: end
- # File lib/bundler.rb, line 205 -205: def mkdir_p(path) -206: if requires_sudo? -207: sudo "mkdir -p '#{path}'" unless File.exist?(path) -208: else -209: FileUtils.mkdir_p(path) -210: end -211: end+ # File lib/bundler.rb, line 213 +213: def mkdir_p(path) +214: if requires_sudo? +215: sudo "mkdir -p '#{path}'" unless File.exist?(path) +216: else +217: FileUtils.mkdir_p(path) +218: end +219: end
- # File lib/bundler.rb, line 217 -217: def read_file(file) -218: File.open(file, "rb") { |f| f.read } -219: end+ # File lib/bundler.rb, line 225 +225: def read_file(file) +226: File.open(file, "rb") { |f| f.read } +227: end
- # File lib/bundler.rb, line 111 -111: def require(*groups) -112: setup(*groups).require(*groups) -113: end+ # File lib/bundler.rb, line 119 +119: def require(*groups) +120: setup(*groups).require(*groups) +121: end
- # File lib/bundler.rb, line 194 -194: def requires_sudo? -195: return @requires_sudo if @checked_for_sudo -196: -197: path = bundle_path -198: path = path.parent until path.exist? -199: sudo_present = !(`which sudo` rescue '').empty? -200: -201: @checked_for_sudo = true -202: @requires_sudo = settings.allow_sudo? && !File.writable?(path) && sudo_present -203: end+ # File lib/bundler.rb, line 202 +202: def requires_sudo? +203: return @requires_sudo if defined?(@checked_for_sudo) && @checked_for_sudo +204: +205: path = bundle_path +206: path = path.parent until path.exist? +207: sudo_present = !(`which sudo` rescue '').empty? +208: +209: @checked_for_sudo = true +210: @requires_sudo = settings.allow_sudo? && !File.writable?(path) && sudo_present +211: end
- # File lib/bundler.rb, line 156 -156: def root -157: default_gemfile.dirname.expand_path -158: end+ # File lib/bundler.rb, line 164 +164: def root +165: default_gemfile.dirname.expand_path +166: 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 140 +140: def ruby_scope +141: "#{Bundler.rubygems.ruby_engine}/#{Gem::ConfigMap[:ruby_version]}" +142: end
- # File lib/bundler.rb, line 174 -174: def settings -175: @settings ||= Settings.new(app_config_path) -176: end+ # File lib/bundler.rb, line 182 +182: def settings +183: @settings ||= Settings.new(app_config_path) +184: 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 101 +101: def setup(*groups) +102: # Just return if all groups are already loaded +103: return @setup if defined?(@setup) +104: +105: if groups.empty? +106: # Load all groups, but only once +107: @setup = load.setup +108: else +109: @completed_groups ||= [] +110: # Figure out which groups haven't been loaded yet +111: unloaded = groups - @completed_groups +112: # Record groups that are now loaded +113: @completed_groups = groups +114: # Load any groups that are not yet loaded +115: unloaded.any? ? load.setup(*unloaded) : load +116: end +117: end
- # File lib/bundler.rb, line 148 -148: def specs_path -149: bundle_path.join("specifications") -150: end+ # File lib/bundler.rb, line 156 +156: def specs_path +157: bundle_path.join("specifications") +158: end
- # File lib/bundler.rb, line 213 -213: def sudo(str) -214: `sudo -p 'Enter your password to install the bundled RubyGems to your system: ' #{str}` -215: end+ # File lib/bundler.rb, line 221 +221: def sudo(str) +222: `sudo -p 'Enter your password to install the bundled RubyGems to your system: ' #{str}` +223: 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 178 +178: def tmp +179: user_bundle_path.join("tmp", Process.pid.to_s) +180: end
- # File lib/bundler.rb, line 77 -77: def ui -78: @ui ||= UI.new -79: end+ # File lib/bundler.rb, line 84 +84: def ui +85: @ui ||= UI.new +86: end
- # File lib/bundler.rb, line 136 -136: def user_bundle_path -137: Pathname.new(Gem.user_home).join(".bundler") -138: end+ # File lib/bundler.rb, line 144 +144: def user_bundle_path +145: Pathname.new(Bundler.rubygems.user_home).join(".bundler") +146: end
- # File lib/bundler.rb, line 178 -178: def with_clean_env -179: bundled_env = ENV.to_hash -180: ENV.replace(ORIGINAL_ENV) -181: yield -182: ensure -183: ENV.replace(bundled_env.to_hash) -184: end+ # File lib/bundler.rb, line 186 +186: def with_clean_env +187: bundled_env = ENV.to_hash +188: ENV.replace(ORIGINAL_ENV) +189: yield +190: ensure +191: ENV.replace(bundled_env.to_hash) +192: end
- # File lib/bundler.rb, line 249 -249: def configure_gem_home_and_path -250: if settings[:disable_shared_gems] -251: ENV['GEM_PATH'] = '' -252: ENV['GEM_HOME'] = File.expand_path(bundle_path, root) -253: elsif Gem.dir != bundle_path.to_s -254: paths = [Gem.dir, Gem.path].flatten.compact.uniq.reject{|p| p.empty? } -255: ENV["GEM_PATH"] = paths.join(File::PATH_SEPARATOR) -256: ENV["GEM_HOME"] = bundle_path.to_s -257: end -258: -259: FileUtils.mkdir_p bundle_path.to_s -260: Gem.clear_paths -261: end+ # File lib/bundler.rb, line 258 +258: def configure_gem_home_and_path +259: if settings[:disable_shared_gems] +260: ENV['GEM_PATH'] = '' +261: ENV['GEM_HOME'] = File.expand_path(bundle_path, root) +262: elsif Bundler.rubygems.gem_dir != bundle_path.to_s +263: possibles = [Bundler.rubygems.gem_dir, Bundler.rubygems.gem_path] +264: paths = possibles.flatten.compact.uniq.reject { |p| p.empty? } +265: ENV["GEM_PATH"] = paths.join(File::PATH_SEPARATOR) +266: ENV["GEM_HOME"] = bundle_path.to_s +267: end +268: +269: # TODO: This mkdir_p is only needed for JRuby <= 1.5 and should go away (GH #602) +270: FileUtils.mkdir_p bundle_path.to_s rescue nil +271: +272: Bundler.rubygems.clear_paths +273: end
- # File lib/bundler.rb, line 263 -263: def upgrade_lockfile -264: lockfile = default_lockfile -265: if lockfile.exist? && lockfile.read(3) == "---" -266: Bundler.ui.warn "Detected Gemfile.lock generated by 0.9, deleting..." -267: lockfile.rmtree -268: end -269: end+ # File lib/bundler.rb, line 275 +275: def upgrade_lockfile +276: lockfile = default_lockfile +277: if lockfile.exist? && lockfile.read(3) == "---" +278: Bundler.ui.warn "Detected Gemfile.lock generated by 0.9, deleting..." +279: lockfile.rmtree +280: end +281: end
- # File lib/bundler.rb, line 32 -32: def self.status_code(code = nil) -33: define_method(:status_code) { code } -34: end+ # File lib/bundler.rb, line 39 +39: def self.status_code(code = nil) +40: define_method(:status_code) { code } +41: end
- # File lib/bundler/cli.rb, line 13 -13: def initialize(*) -14: super -15: the_shell = (options["no-color"] ? Thor::Shell::Basic.new : shell) -16: Bundler.ui = UI::Shell.new(the_shell) -17: Bundler.ui.debug! if options["verbose"] -18: Gem::DefaultUserInteraction.ui = UI::RGProxy.new(Bundler.ui) -19: end+ # File lib/bundler/cli.rb, line 11 +11: def initialize(*) +12: super +13: the_shell = (options["no-color"] ? Thor::Shell::Basic.new : shell) +14: Bundler.ui = UI::Shell.new(the_shell) +15: Bundler.ui.debug! if options["verbose"] +16: Bundler.rubygems.ui = UI::RGProxy.new(Bundler.ui) +17: end
- # File lib/bundler/cli.rb, line 499 -499: def self.source_root -500: File.expand_path(File.join(File.dirname(__FILE__), 'templates')) -501: end+ # File lib/bundler/cli.rb, line 501 +501: def self.source_root +502: File.expand_path(File.join(File.dirname(__FILE__), 'templates')) +503: end
- # File lib/bundler/cli.rb, line 308 -308: def cache -309: Bundler.definition.resolve_with_cache! -310: Bundler.load.cache -311: Bundler.settings[:no_prune] = true if options[:no_prune] -312: Bundler.load.lock -313: rescue GemNotFound => e -314: Bundler.ui.error(e.message) -315: Bundler.ui.warn "Run `bundle install` to install missing gems." -316: exit 128 -317: end+ # File lib/bundler/cli.rb, line 307 +307: def cache +308: Bundler.definition.resolve_with_cache! +309: Bundler.load.cache +310: Bundler.settings[:no_prune] = true if options["no-prune"] +311: Bundler.load.lock +312: rescue GemNotFound => e +313: Bundler.ui.error(e.message) +314: Bundler.ui.warn "Run `bundle install` to install missing gems." +315: exit 128 +316: end
- # File lib/bundler/cli.rb, line 99 - 99: def check -100: ENV['BUNDLE_GEMFILE'] = File.expand_path(options[:gemfile]) if options[:gemfile] -101: begin -102: not_installed = Bundler.definition.missing_specs -103: rescue GemNotFound, VersionConflict -104: Bundler.ui.error "Your Gemfile's dependencies could not be satisfied" -105: Bundler.ui.warn "Install missing gems with `bundle install`" -106: exit 1 -107: end -108: -109: if not_installed.any? -110: Bundler.ui.error "The following gems are missing" -111: not_installed.each { |s| Bundler.ui.error " * #{s.name} (#{s.version})" } -112: Bundler.ui.warn "Install missing gems with `bundle install`" -113: exit 1 -114: else -115: Bundler.load.lock -116: Bundler.ui.info "The Gemfile's dependencies are satisfied" -117: end -118: end+ # File lib/bundler/cli.rb, line 97 + 97: def check + 98: ENV['BUNDLE_GEMFILE'] = File.expand_path(options[:gemfile]) if options[:gemfile] + 99: begin +100: not_installed = Bundler.definition.missing_specs +101: rescue GemNotFound, VersionConflict +102: Bundler.ui.error "Your Gemfile's dependencies could not be satisfied" +103: Bundler.ui.warn "Install missing gems with `bundle install`" +104: exit 1 +105: end +106: +107: if not_installed.any? +108: Bundler.ui.error "The following gems are missing" +109: not_installed.each { |s| Bundler.ui.error " * #{s.name} (#{s.version})" } +110: Bundler.ui.warn "Install missing gems with `bundle install`" +111: exit 1 +112: else +113: Bundler.load.lock +114: Bundler.ui.info "The Gemfile's dependencies are satisfied" +115: end +116: end
- # File lib/bundler/cli.rb, line 370 -370: def config(name = nil, *args) -371: values = ARGV.dup -372: values.shift # remove config -373: values.shift # remove the name -374: -375: unless name -376: Bundler.ui.confirm "Settings are listed in order of priority. The top value will be used.\n" -377: -378: Bundler.settings.all.each do |setting| -379: Bundler.ui.confirm "#{setting}" -380: with_padding do -381: Bundler.settings.pretty_values_for(setting).each do |line| -382: Bundler.ui.info line -383: end -384: end -385: Bundler.ui.confirm "" -386: end -387: return -388: end -389: -390: if values.empty? -391: Bundler.ui.confirm "Settings for `#{name}` in order of priority. The top value will be used" -392: with_padding do -393: Bundler.settings.pretty_values_for(name).each { |line| Bundler.ui.info line } -394: end -395: else -396: locations = Bundler.settings.locations(name) -397: -398: if local = locations[:local] -399: Bundler.ui.info "Your application has set #{name} to #{local.inspect}. This will override the " "system value you are currently setting" -400: end -401: -402: if global = locations[:global] -403: Bundler.ui.info "You are replacing the current system value of #{name}, which is currently #{global}" -404: end -405: -406: if env = locations[:env] -407: Bundler.ui.info "You have set a bundler environment variable for #{env}. This will take precedence " "over the system value you are setting" -408: end -409: -410: Bundler.settings.set_global(name, values.join(" ")) -411: end -412: end+ # File lib/bundler/cli.rb, line 369 +369: def config(name = nil, *args) +370: values = ARGV.dup +371: values.shift # remove config +372: values.shift # remove the name +373: +374: unless name +375: Bundler.ui.confirm "Settings are listed in order of priority. The top value will be used.\n" +376: +377: Bundler.settings.all.each do |setting| +378: Bundler.ui.confirm "#{setting}" +379: with_padding do +380: Bundler.settings.pretty_values_for(setting).each do |line| +381: Bundler.ui.info line +382: end +383: end +384: Bundler.ui.confirm "" +385: end +386: return +387: end +388: +389: if values.empty? +390: Bundler.ui.confirm "Settings for `#{name}` in order of priority. The top value will be used" +391: with_padding do +392: Bundler.settings.pretty_values_for(name).each { |line| Bundler.ui.info line } +393: end +394: else +395: locations = Bundler.settings.locations(name) +396: +397: if local = locations[:local] +398: Bundler.ui.info "Your application has set #{name} to #{local.inspect}. This will override the " "system value you are currently setting" +399: end +400: +401: if global = locations[:global] +402: Bundler.ui.info "You are replacing the current system value of #{name}, which is currently #{global}" +403: end +404: +405: if env = locations[:env] +406: Bundler.ui.info "You have set a bundler environment variable for #{env}. This will take precedence " "over the system value you are setting" +407: end +408: +409: Bundler.settings.set_global(name, values.join(" ")) +410: end +411: end
- # File lib/bundler/cli.rb, line 432 -432: def console(group = nil) -433: require 'bundler/setup' -434: group ? Bundler.require(:default, group) : Bundler.require -435: ARGV.clear -436: -437: require 'irb' -438: IRB.start -439: end+ # File lib/bundler/cli.rb, line 431 +431: def console(group = nil) +432: group ? Bundler.require(:default, *(group.split.map! {|g| g.to_sym })) : Bundler.require +433: ARGV.clear +434: +435: require 'irb' +436: IRB.start +437: end
- # File lib/bundler/cli.rb, line 340 -340: def exec(*) -341: ARGV.delete("exec") -342: -343: Bundler.setup -344: -345: begin -346: # Run -347: Kernel.exec(*ARGV) -348: rescue Errno::EACCES -349: Bundler.ui.error "bundler: not executable: #{ARGV.first}" -350: exit 126 -351: rescue Errno::ENOENT -352: Bundler.ui.error "bundler: command not found: #{ARGV.first}" -353: Bundler.ui.warn "Install missing gem binaries with `bundle install`" -354: exit 127 -355: end -356: end+ # File lib/bundler/cli.rb, line 339 +339: def exec(*) +340: ARGV.delete("exec") +341: +342: Bundler.setup +343: +344: begin +345: # Run +346: Kernel.exec(*ARGV) +347: rescue Errno::EACCES +348: Bundler.ui.error "bundler: not executable: #{ARGV.first}" +349: exit 126 +350: rescue Errno::ENOENT +351: Bundler.ui.error "bundler: command not found: #{ARGV.first}" +352: Bundler.ui.warn "Install missing gem binaries with `bundle install`" +353: exit 127 +354: end +355: end
- # File lib/bundler/cli.rb, line 479 -479: def gem(name) -480: target = File.join(Dir.pwd, name) -481: constant_name = name.split('_').map{|p| p.capitalize}.join -482: constant_name = constant_name.split('-').map{|q| q.capitalize}.join('::') if constant_name =~ /-/ -483: constant_array = constant_name.split('::') -484: FileUtils.mkdir_p(File.join(target, 'lib', name)) -485: opts = {:name => name, :constant_name => constant_name, :constant_array => constant_array} -486: template(File.join("newgem/Gemfile.tt"), File.join(target, "Gemfile"), opts) -487: template(File.join("newgem/Rakefile.tt"), File.join(target, "Rakefile"), opts) -488: template(File.join("newgem/gitignore.tt"), File.join(target, ".gitignore"), opts) -489: template(File.join("newgem/newgem.gemspec.tt"), File.join(target, "#{name}.gemspec"), opts) -490: template(File.join("newgem/lib/newgem.rb.tt"), File.join(target, "lib/#{name}.rb"), opts) -491: template(File.join("newgem/lib/newgem/version.rb.tt"), File.join(target, "lib/#{name}/version.rb"), opts) -492: if options[:bin] -493: template(File.join("newgem/bin/newgem.tt"), File.join(target, 'bin', name), opts) -494: end -495: Bundler.ui.info "Initializating git repo in #{target}" -496: Dir.chdir(target) { `git init`; `git add .` } -497: end+ # File lib/bundler/cli.rb, line 477 +477: def gem(name) +478: target = File.join(Dir.pwd, name) +479: constant_name = name.split('_').map{|p| p.capitalize}.join +480: constant_name = constant_name.split('-').map{|q| q.capitalize}.join('::') if constant_name =~ /-/ +481: constant_array = constant_name.split('::') +482: git_author_name = `git config user.name`.chomp +483: git_author_email = `git config user.email`.chomp +484: author_name = git_author_name.empty? ? "TODO: Write your name" : git_author_name +485: author_email = git_author_email.empty? ? "TODO: Write your email address" : git_author_email +486: FileUtils.mkdir_p(File.join(target, 'lib', name)) +487: opts = {:name => name, :constant_name => constant_name, :constant_array => constant_array, :author_name => author_name, :author_email => author_email} +488: template(File.join("newgem/Gemfile.tt"), File.join(target, "Gemfile"), opts) +489: template(File.join("newgem/Rakefile.tt"), File.join(target, "Rakefile"), opts) +490: template(File.join("newgem/gitignore.tt"), File.join(target, ".gitignore"), opts) +491: template(File.join("newgem/newgem.gemspec.tt"), File.join(target, "#{name}.gemspec"), opts) +492: template(File.join("newgem/lib/newgem.rb.tt"), File.join(target, "lib/#{name}.rb"), opts) +493: template(File.join("newgem/lib/newgem/version.rb.tt"), File.join(target, "lib/#{name}/version.rb"), opts) +494: if options[:bin] +495: template(File.join("newgem/bin/newgem.tt"), File.join(target, 'bin', name), opts) +496: end +497: Bundler.ui.info "Initializating git repo in #{target}" +498: Dir.chdir(target) { `git init`; `git add .` } +499: end
- # File lib/bundler/cli.rb, line 27 -27: def help(cli = nil) -28: case cli -29: when "gemfile" then command = "gemfile.5" -30: when nil then command = "bundle" -31: else command = "bundle-#{cli}" -32: end -33: -34: manpages = %( -35: bundle -36: bundle-config -37: bundle-exec -38: bundle-install -39: bundle-package -40: bundle-update -41: gemfile.5) -42: -43: if manpages.include?(command) -44: root = File.expand_path("../man", __FILE__) -45: -46: if have_groff? && root !~ %{^file:/.+!/META-INF/jruby.home/.+} -47: groff = "groff -Wall -mtty-char -mandoc -Tascii" -48: pager = ENV['MANPAGER'] || ENV['PAGER'] || 'more' -49: -50: Kernel.exec "#{groff} #{root}/#{command} | #{pager}" -51: else -52: puts File.read("#{root}/#{command}.txt") -53: end -54: else -55: super -56: end -57: end+ # File lib/bundler/cli.rb, line 25 +25: def help(cli = nil) +26: case cli +27: when "gemfile" then command = "gemfile.5" +28: when nil then command = "bundle" +29: else command = "bundle-#{cli}" +30: end +31: +32: manpages = %( +33: bundle +34: bundle-config +35: bundle-exec +36: bundle-install +37: bundle-package +38: bundle-update +39: gemfile.5) +40: +41: if manpages.include?(command) +42: root = File.expand_path("../man", __FILE__) +43: +44: if have_groff? && root !~ %{^file:/.+!/META-INF/jruby.home/.+} +45: groff = "groff -Wall -mtty-char -mandoc -Tascii" +46: pager = ENV['MANPAGER'] || ENV['PAGER'] || 'less -R' +47: +48: Kernel.exec "#{groff} #{root}/#{command} | #{pager}" +49: else +50: puts File.read("#{root}/#{command}.txt") +51: end +52: else +53: super +54: end +55: end
- # File lib/bundler/cli.rb, line 66 -66: def init -67: opts = options.dup -68: if File.exist?("Gemfile") -69: Bundler.ui.error "Gemfile already exists at #{Dir.pwd}/Gemfile" -70: exit 1 -71: end -72: -73: if opts[:gemspec] -74: gemspec = File.expand_path(opts[:gemspec]) -75: unless File.exist?(gemspec) -76: Bundler.ui.error "Gem specification #{gemspec} doesn't exist" -77: exit 1 -78: end -79: spec = Gem::Specification.load(gemspec) -80: puts "Writing new Gemfile to #{Dir.pwd}/Gemfile" -81: File.open('Gemfile', 'wb') do |file| -82: file << "# Generated from #{gemspec}\n" -83: file << spec.to_gemfile -84: end -85: else -86: puts "Writing new Gemfile to #{Dir.pwd}/Gemfile" -87: FileUtils.cp(File.expand_path('../templates/Gemfile', __FILE__), 'Gemfile') -88: end -89: end+ # File lib/bundler/cli.rb, line 64 +64: def init +65: opts = options.dup +66: if File.exist?("Gemfile") +67: Bundler.ui.error "Gemfile already exists at #{Dir.pwd}/Gemfile" +68: exit 1 +69: end +70: +71: if opts[:gemspec] +72: gemspec = File.expand_path(opts[:gemspec]) +73: unless File.exist?(gemspec) +74: Bundler.ui.error "Gem specification #{gemspec} doesn't exist" +75: exit 1 +76: end +77: spec = Gem::Specification.load(gemspec) +78: puts "Writing new Gemfile to #{Dir.pwd}/Gemfile" +79: File.open('Gemfile', 'wb') do |file| +80: file << "# Generated from #{gemspec}\n" +81: file << spec.to_gemfile +82: end +83: else +84: puts "Writing new Gemfile to #{Dir.pwd}/Gemfile" +85: FileUtils.cp(File.expand_path('../templates/Gemfile', __FILE__), 'Gemfile') +86: end +87: end
- # File lib/bundler/cli.rb, line 157 -157: def install(path = nil) -158: opts = options.dup -159: opts[:without] ||= [] -160: if opts[:without].size == 1 -161: opts[:without].map!{|g| g.split(" ") } -162: opts[:without].flatten! -163: end -164: opts[:without].map!{|g| g.to_sym } + # File lib/bundler/cli.rb, line 153 +153: def install(path = nil) +154: opts = options.dup +155: opts[:without] ||= [] +156: if opts[:without].size == 1 +157: opts[:without].map!{|g| g.split(" ") } +158: opts[:without].flatten! +159: end +160: opts[:without].map!{|g| g.to_sym } +161: +162: # Can't use Bundler.settings for this because settings needs gemfile.dirname +163: ENV['BUNDLE_GEMFILE'] = File.expand_path(opts[:gemfile]) if opts[:gemfile] +164: ENV['RB_USER_INSTALL'] = '1' if Bundler::FREEBSD 165: -166: ENV['BUNDLE_GEMFILE'] = File.expand_path(opts[:gemfile]) if opts[:gemfile] -167: ENV['RB_USER_INSTALL'] = '1' if Bundler::FREEBSD +166: # Just disable color in deployment mode +167: Bundler.ui.shell = Thor::Shell::Basic.new if opts[:deployment] 168: -169: # Just disable color in deployment mode -170: Bundler.ui.shell = Thor::Shell::Basic.new if opts[:deployment] -171: -172: if opts[:production] -173: opts[:deployment] = true -174: Bundler.ui.warn "The --production option is deprecated, and will be removed in " "the final release of Bundler 1.0. Please use --deployment instead." -175: end -176: -177: if (path || opts[:path] || opts[:deployment]) && opts[:system] -178: Bundler.ui.error "You have specified both a path to install your gems to, \n" "as well as --system. Please choose." -179: exit 1 -180: end -181: -182: if path && opts[:path] -183: 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." -184: exit 1 -185: end -186: -187: if opts["disable-shared-gems"] -188: 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`." -189: exit 1 -190: end -191: -192: if opts[:deployment] || opts[:frozen] -193: unless Bundler.default_lockfile.exist? -194: flag = opts[:deployment] ? '--deployment' : '--frozen' -195: raise ProductionError, "The #{flag} flag requires a Gemfile.lock. Please make " "sure you have checked your Gemfile.lock into version control " "before deploying." -196: end -197: -198: if Bundler.root.join("vendor/cache").exist? -199: opts[:local] = true -200: end -201: -202: Bundler.settings[:frozen] = '1' -203: end -204: -205: # Can't use Bundler.settings for this because settings needs gemfile.dirname -206: Bundler.settings[:path] = nil if opts[:system] -207: Bundler.settings[:path] = "vendor/bundle" if opts[:deployment] -208: Bundler.settings[:path] = path if path -209: Bundler.settings[:path] = opts[:path] if opts[:path] -210: Bundler.settings[:bin] = opts["binstubs"] if opts[:binstubs] -211: Bundler.settings[:disable_shared_gems] = '1' if Bundler.settings[:path] -212: Bundler.settings.without = opts[:without] unless opts[:without].empty? -213: Bundler.ui.be_quiet! if opts[:quiet] -214: -215: Installer.install(Bundler.root, Bundler.definition, opts) -216: Bundler.load.cache if Bundler.root.join("vendor/cache").exist? -217: -218: if Bundler.settings[:path] -219: relative_path = Bundler.settings[:path] -220: relative_path = "./" + relative_path unless relative_path[0] == // +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: unless Bundler.default_lockfile.exist? +186: flag = opts[:deployment] ? '--deployment' : '--frozen' +187: raise ProductionError, "The #{flag} flag requires a Gemfile.lock. Please make " "sure you have checked your Gemfile.lock into version control " "before deploying." +188: end +189: +190: if Bundler.root.join("vendor/cache").exist? +191: opts[:local] = true +192: end +193: +194: Bundler.settings[:frozen] = '1' +195: end +196: +197: # When install is called with --no-deployment, disable deployment mode +198: if opts[:deployment] == false +199: Bundler.settings.delete(:frozen) +200: opts[:system] = true +201: end +202: +203: Bundler.settings[:path] = nil if opts[:system] +204: Bundler.settings[:path] = "vendor/bundle" if opts[:deployment] +205: Bundler.settings[:path] = path if path +206: Bundler.settings[:path] = opts[:path] if opts[:path] +207: Bundler.settings[:bin] = opts["binstubs"] if opts[:binstubs] +208: Bundler.settings[:no_prune] = true if opts["no-prune"] +209: Bundler.settings[:disable_shared_gems] = Bundler.settings[:path] ? '1' : nil +210: Bundler.settings.without = opts[:without] unless opts[:without].empty? +211: Bundler.ui.be_quiet! if opts[:quiet] +212: +213: Installer.install(Bundler.root, Bundler.definition, opts) +214: Bundler.load.cache if Bundler.root.join("vendor/cache").exist? && !options["no-cache"] +215: +216: if Bundler.settings[:path] +217: relative_path = File.expand_path(Bundler.settings[:path]).sub(/^#{File.expand_path('.')}/, '.') +218: Bundler.ui.confirm "Your bundle is complete! " + +219: "It was installed into #{relative_path}" +220: else 221: Bundler.ui.confirm "Your bundle is complete! " + -222: "It was installed into #{relative_path}" -223: else -224: Bundler.ui.confirm "Your bundle is complete! " + -225: "Use `bundle show [gemname]` to see where a bundled gem is installed." -226: end -227: -228: if path -229: Bundler.ui.warn "The path argument to `bundle install` is deprecated. " + -230: "It will be removed in version 1.1. " + -231: "Please use `bundle install --path #{path}` instead." -232: end -233: rescue GemNotFound => e -234: if opts[:local] -235: Bundler.ui.warn "Some gems seem to be missing from your vendor/cache directory." -236: end -237: -238: if Bundler.definition.no_sources? -239: Bundler.ui.warn "Your Gemfile doesn't have any sources. You can add one with a line like 'source :rubygems'" -240: end -241: raise e -242: end+222: "Use `bundle show [gemname]` to see where a bundled gem is installed." +223: end +224: +225: if path +226: Bundler.ui.warn "The path argument to `bundle install` is deprecated. " + +227: "It will be removed in version 1.1. " + +228: "Please use `bundle install --path #{path}` instead." +229: end +230: rescue GemNotFound => e +231: if opts[:local] && Bundler.app_cache.exist? +232: Bundler.ui.warn "Some gems seem to be missing from your vendor/cache directory." +233: end +234: +235: if Bundler.definition.no_sources? +236: Bundler.ui.warn "Your Gemfile doesn't have any sources. You can add one with a line like 'source :rubygems'" +237: end +238: raise e +239: end
- # File lib/bundler/cli.rb, line 278 -278: def lock -279: Bundler.ui.warn "Lock is deprecated. Your bundle is now locked whenever you run `bundle install`." -280: end+ # File lib/bundler/cli.rb, line 277 +277: def lock +278: Bundler.ui.warn "Lock is deprecated. Your bundle is now locked whenever you run `bundle install`." +279: end
- # File lib/bundler/cli.rb, line 417 -417: def open(name) -418: editor = [ENV['BUNDLER_EDITOR'], ENV['VISUAL'], ENV['EDITOR']].find{|e| !e.nil? && !e.empty? } -419: if editor -420: gem_path = locate_gem(name) -421: Dir.chdir(gem_path) do -422: command = "#{editor} #{gem_path}" -423: success = system(command) -424: Bundler.ui.info "Could not run '#{command}'" unless success -425: end -426: else -427: Bundler.ui.info("To open a bundled gem, set $EDITOR or $BUNDLER_EDITOR") -428: end -429: end+ # File lib/bundler/cli.rb, line 416 +416: def open(name) +417: editor = [ENV['BUNDLER_EDITOR'], ENV['VISUAL'], ENV['EDITOR']].find{|e| !e.nil? && !e.empty? } +418: if editor +419: gem_path = locate_gem(name) +420: Dir.chdir(gem_path) do +421: command = "#{editor} #{gem_path}" +422: success = system(command) +423: Bundler.ui.info "Could not run '#{command}'" unless success +424: end +425: else +426: Bundler.ui.info("To open a bundled gem, set $EDITOR or $BUNDLER_EDITOR") +427: end +428: end
- # File lib/bundler/cli.rb, line 327 -327: def package -328: install -329: # TODO: move cache contents here now that all bundles are locked -330: Bundler.load.cache -331: end+ # File lib/bundler/cli.rb, line 326 +326: def package +327: install +328: # TODO: move cache contents here now that all bundles are locked +329: Bundler.load.cache +330: end
- # File lib/bundler/cli.rb, line 292 -292: def show(gem_name = nil) -293: Bundler.load.lock -294: -295: if gem_name -296: Bundler.ui.info locate_gem(gem_name) -297: else -298: Bundler.ui.info "Gems included by the bundle:" -299: Bundler.load.specs.sort_by { |s| s.name }.each do |s| -300: Bundler.ui.info " * #{s.name} (#{s.version}#{s.git_version})" -301: end -302: end -303: end+ # File lib/bundler/cli.rb, line 291 +291: def show(gem_name = nil) +292: Bundler.load.lock +293: +294: if gem_name +295: Bundler.ui.info locate_gem(gem_name) +296: else +297: Bundler.ui.info "Gems included by the bundle:" +298: Bundler.load.specs.sort_by { |s| s.name }.each do |s| +299: Bundler.ui.info " * #{s.name} (#{s.version}#{s.git_version})" +300: end +301: end +302: end
- # File lib/bundler/cli.rb, line 283 -283: def unlock -284: Bundler.ui.warn "Unlock is deprecated. To update to newer gem versions, use `bundle update`." -285: end+ # File lib/bundler/cli.rb, line 282 +282: def unlock +283: Bundler.ui.warn "Unlock is deprecated. To update to newer gem versions, use `bundle update`." +284: end
- # File lib/bundler/cli.rb, line 261 -261: def update(*gems) -262: sources = Array(options[:source]) -263: -264: if gems.empty? && sources.empty? -265: # We're doing a full update -266: Bundler.definition(true) -267: else -268: Bundler.definition(:gems => gems, :sources => sources) -269: end -270: -271: Installer.install Bundler.root, Bundler.definition, "update" => true -272: Bundler.load.cache if Bundler.root.join("vendor/cache").exist? -273: Bundler.ui.confirm "Your bundle is updated! " + -274: "Use `bundle show [gemname]` to see where a bundled gem is installed." -275: end+ # File lib/bundler/cli.rb, line 259 +259: def update(*gems) +260: sources = Array(options[:source]) +261: +262: if gems.empty? && sources.empty? +263: # We're doing a full update +264: Bundler.definition(true) +265: else +266: Bundler.definition(:gems => gems, :sources => sources) +267: end +268: +269: opts = {"update" => true, "local" => options[:local]} +270: Installer.install Bundler.root, Bundler.definition, opts +271: Bundler.load.cache if Bundler.root.join("vendor/cache").exist? +272: Bundler.ui.confirm "Your bundle is updated! " + +273: "Use `bundle show [gemname]` to see where a bundled gem is installed." +274: end
- # File lib/bundler/cli.rb, line 442 -442: def version -443: Bundler.ui.info "Bundler version #{Bundler::VERSION}" -444: end+ # File lib/bundler/cli.rb, line 440 +440: def version +441: Bundler.ui.info "Bundler version #{Bundler::VERSION}" +442: end
- # File lib/bundler/cli.rb, line 456 -456: def viz -457: output_file = File.expand_path(options[:file]) -458: graph = Graph.new( Bundler.load ) -459: -460: begin -461: graph.viz(output_file, options[:version], options[:requirements]) -462: Bundler.ui.info output_file -463: rescue LoadError => e -464: Bundler.ui.error e.inspect -465: Bundler.ui.warn "Make sure you have the graphviz ruby gem. You can install it with:" -466: Bundler.ui.warn "`gem install ruby-graphviz`" -467: rescue StandardError => e -468: if e.message =~ /GraphViz not installed or dot not in PATH/ -469: Bundler.ui.error e.message -470: Bundler.ui.warn "The ruby graphviz gem requires GraphViz to be installed" -471: else -472: raise -473: end -474: end -475: end+ # File lib/bundler/cli.rb, line 454 +454: def viz +455: output_file = File.expand_path(options[:file]) +456: graph = Graph.new( Bundler.load ) +457: +458: begin +459: graph.viz(output_file, options[:version], options[:requirements]) +460: Bundler.ui.info output_file +461: rescue LoadError => e +462: Bundler.ui.error e.inspect +463: Bundler.ui.warn "Make sure you have the graphviz ruby gem. You can install it with:" +464: Bundler.ui.warn "`gem install ruby-graphviz`" +465: rescue StandardError => e +466: if e.message =~ /GraphViz not installed or dot not in PATH/ +467: Bundler.ui.error e.message +468: Bundler.ui.warn "The ruby graphviz gem requires GraphViz to be installed" +469: else +470: raise +471: end +472: end +473: end
- # File lib/bundler/cli.rb, line 505 -505: def have_groff? -506: !(`which groff` rescue '').empty? -507: end+ # File lib/bundler/cli.rb, line 507 +507: def have_groff? +508: !(`which groff` rescue '').empty? +509: end
- # File lib/bundler/cli.rb, line 509 -509: def locate_gem(name) -510: spec = Bundler.load.specs.find{|s| s.name == name } -511: raise GemNotFound, "Could not find gem '#{name}' in the current bundle." unless spec -512: if spec.name == 'bundler' -513: return File.expand_path('../../../', __FILE__) -514: end -515: spec.full_gem_path -516: end+ # File lib/bundler/cli.rb, line 511 +511: def locate_gem(name) +512: spec = Bundler.load.specs.find{|s| s.name == name } +513: raise GemNotFound, "Could not find gem '#{name}' in the current bundle." unless spec +514: if spec.name == 'bundler' +515: return File.expand_path('../../../', __FILE__) +516: end +517: spec.full_gem_path +518: end
# File lib/bundler/definition.rb, line 238 -238: def ensure_equivalent_gemfile_and_lockfile +238: def ensure_equivalent_gemfile_and_lockfile(explicit_flag = false) 239: changes = false 240: -241: msg = "You have modified your Gemfile in development but did not check\n" "the resulting snapshot (Gemfile.lock) into version control" +241: msg = "You are trying to install in deployment mode after changing\n" "your Gemfile. Run `bundle install` elsewhere and add the\n" "updated Gemfile.lock to version control." 242: -243: added = [] -244: deleted = [] -245: changed = [] +243: unless explicit_flag +244: msg += "\n\nIf this is a development machine, remove the Gemfile " "freeze \nby running `bundle install --no-deployment`." +245: end 246: -247: if @locked_sources != @sources -248: new_sources = @sources - @locked_sources -249: deleted_sources = @locked_sources - @sources +247: added = [] +248: deleted = [] +249: changed = [] 250: -251: if new_sources.any? -252: added.concat new_sources.map { |source| "* source: #{source}" } -253: end +251: if @locked_sources != @sources +252: new_sources = @sources - @locked_sources +253: deleted_sources = @locked_sources - @sources 254: -255: if deleted_sources.any? -256: deleted.concat deleted_sources.map { |source| "* source: #{source}" } +255: if new_sources.any? +256: added.concat new_sources.map { |source| "* source: #{source}" } 257: end 258: -259: changes = true -260: end -261: -262: both_sources = Hash.new { |h,k| h[k] = ["no specified source", "no specified source"] } -263: @dependencies.each { |d| both_sources[d.name][0] = d.source if d.source } -264: @locked_deps.each { |d| both_sources[d.name][1] = d.source if d.source } -265: both_sources.delete_if { |k,v| v[0] == v[1] } -266: -267: if @dependencies != @locked_deps -268: new_deps = @dependencies - @locked_deps -269: deleted_deps = @locked_deps - @dependencies +259: if deleted_sources.any? +260: deleted.concat deleted_sources.map { |source| "* source: #{source}" } +261: end +262: +263: changes = true +264: end +265: +266: both_sources = Hash.new { |h,k| h[k] = ["no specified source", "no specified source"] } +267: @dependencies.each { |d| both_sources[d.name][0] = d.source if d.source } +268: @locked_deps.each { |d| both_sources[d.name][1] = d.source if d.source } +269: both_sources.delete_if { |k,v| v[0] == v[1] } 270: -271: if new_deps.any? -272: added.concat new_deps.map { |d| "* #{pretty_dep(d)}" } -273: end +271: if @dependencies != @locked_deps +272: new_deps = @dependencies - @locked_deps +273: deleted_deps = @locked_deps - @dependencies 274: -275: if deleted_deps.any? -276: deleted.concat deleted_deps.map { |d| "* #{pretty_dep(d)}" } +275: if new_deps.any? +276: added.concat new_deps.map { |d| "* #{pretty_dep(d)}" } 277: end 278: -279: both_sources.each do |name, sources| -280: changed << "* #{name} from `#{sources[0]}` to `#{sources[1]}`" +279: if deleted_deps.any? +280: deleted.concat deleted_deps.map { |d| "* #{pretty_dep(d)}" } 281: end 282: -283: changes = true -284: end -285: -286: msg << "\n\nYou have added to the Gemfile:\n" << added.join("\n") if added.any? -287: msg << "\n\nYou have deleted from the Gemfile:\n" << deleted.join("\n") if deleted.any? -288: msg << "\n\nYou have changed in the Gemfile:\n" << changed.join("\n") if changed.any? +283: both_sources.each do |name, sources| +284: changed << "* #{name} from `#{sources[0]}` to `#{sources[1]}`" +285: end +286: +287: changes = true +288: end 289: -290: raise ProductionError, msg if added.any? || deleted.any? || changed.any? -291: end+290: msg << "\n\nYou have added to the Gemfile:\n" << added.join("\n") if added.any? +291: msg << "\n\nYou have deleted from the Gemfile:\n" << deleted.join("\n") if deleted.any? +292: msg << "\n\nYou have changed in the Gemfile:\n" << changed.join("\n") if changed.any? +293: msg << "\n" +294: +295: raise ProductionError, msg if added.any? || deleted.any? || changed.any? +296: end @@ -1285,7 +1306,7 @@ 225: 226: handled = [] 227: dependencies. -228: sort_by { |d| d.name }. +228: sort_by { |d| d.to_s }. 229: each do |dep| 230: next if handled.include?(dep.name) 231: out << dep.to_lock @@ -1330,14 +1351,14 @@
- # File lib/bundler/definition.rb, line 320 -320: def converge_dependencies -321: (@dependencies + @locked_deps).each do |dep| -322: if dep.source -323: dep.source = @sources.find { |s| dep.source == s } -324: end -325: end -326: end+ # File lib/bundler/definition.rb, line 327 +327: def converge_dependencies +328: (@dependencies + @locked_deps).each do |dep| +329: if dep.source +330: dep.source = @sources.find { |s| dep.source == s } +331: end +332: end +333: end
- # File lib/bundler/definition.rb, line 331 -331: def converge_locked_specs -332: deps = [] -333: -334: # Build a list of dependencies that are the same in the Gemfile -335: # and Gemfile.lock. If the Gemfile modified a dependency, but -336: # the gem in the Gemfile.lock still satisfies it, this is fine -337: # too. -338: @dependencies.each do |dep| -339: locked_dep = @locked_deps.find { |d| dep == d } + # File lib/bundler/definition.rb, line 338 +338: def converge_locked_specs +339: deps = [] 340: -341: if in_locked_deps?(dep, locked_dep) || satisfies_locked_spec?(dep) -342: deps << dep -343: elsif dep.source.is_a?(Source::Path) && dep.current_platform? && (!locked_dep || dep.source != locked_dep.source) -344: @locked_specs.each do |s| -345: @unlock[:gems] << s.name if s.source == dep.source -346: end +341: # Build a list of dependencies that are the same in the Gemfile +342: # and Gemfile.lock. If the Gemfile modified a dependency, but +343: # the gem in the Gemfile.lock still satisfies it, this is fine +344: # too. +345: @dependencies.each do |dep| +346: locked_dep = @locked_deps.find { |d| dep == d } 347: -348: dep.source.unlock! if dep.source.respond_to?(:unlock!) -349: dep.source.specs.each { |s| @unlock[:gems] << s.name } -350: end -351: end -352: -353: converged = [] -354: @locked_specs.each do |s| -355: s.source = @sources.find { |src| s.source == src } -356: -357: # Don't add a spec to the list if its source is expired. For example, -358: # if you change a Git gem to Rubygems. -359: next if s.source.nil? || @unlock[:sources].include?(s.name) -360: # If the spec is from a path source and it doesn't exist anymore -361: # then we just unlock it. -362: -363: # Path sources have special logic -364: if s.source.instance_of?(Source::Path) -365: other = s.source.specs[s].first -366: -367: # If the spec is no longer in the path source, unlock it. This -368: # commonly happens if the version changed in the gemspec -369: next unless other -370: # If the dependencies of the path source have changed, unlock it -371: next unless s.dependencies.sort == other.dependencies.sort -372: end +348: if in_locked_deps?(dep, locked_dep) || satisfies_locked_spec?(dep) +349: deps << dep +350: elsif dep.source.is_a?(Source::Path) && dep.current_platform? && (!locked_dep || dep.source != locked_dep.source) +351: @locked_specs.each do |s| +352: @unlock[:gems] << s.name if s.source == dep.source +353: end +354: +355: dep.source.unlock! if dep.source.respond_to?(:unlock!) +356: dep.source.specs.each { |s| @unlock[:gems] << s.name } +357: end +358: end +359: +360: converged = [] +361: @locked_specs.each do |s| +362: s.source = @sources.find { |src| s.source == src } +363: +364: # Don't add a spec to the list if its source is expired. For example, +365: # if you change a Git gem to Rubygems. +366: next if s.source.nil? || @unlock[:sources].include?(s.name) +367: # If the spec is from a path source and it doesn't exist anymore +368: # then we just unlock it. +369: +370: # Path sources have special logic +371: if s.source.instance_of?(Source::Path) +372: other = s.source.specs[s].first 373: -374: converged << s -375: end -376: -377: resolve = SpecSet.new(converged) -378: resolve = resolve.for(expand_dependencies(deps, true), @unlock[:gems]) -379: diff = @locked_specs.to_a - resolve.to_a -380: -381: # Now, we unlock any sources that do not have anymore gems pinned to it -382: @sources.each do |source| -383: next unless source.respond_to?(:unlock!) -384: -385: unless resolve.any? { |s| s.source == source } -386: source.unlock! if !diff.empty? && diff.any? { |s| s.source == source } -387: end -388: end +374: # If the spec is no longer in the path source, unlock it. This +375: # commonly happens if the version changed in the gemspec +376: next unless other +377: +378: deps2 = other.dependencies.select { |d| d.type != :development } +379: # If the dependencies of the path source have changed, unlock it +380: next unless s.dependencies.sort == deps2.sort +381: end +382: +383: converged << s +384: end +385: +386: resolve = SpecSet.new(converged) +387: resolve = resolve.for(expand_dependencies(deps, true), @unlock[:gems]) +388: diff = @locked_specs.to_a - resolve.to_a 389: -390: resolve -391: end+390: # Now, we unlock any sources that do not have anymore gems pinned to it +391: @sources.each do |source| +392: next unless source.respond_to?(:unlock!) +393: +394: unless resolve.any? { |s| s.source == source } +395: source.unlock! if !diff.empty? && diff.any? { |s| s.source == source } +396: end +397: end +398: +399: resolve +400: end
- # File lib/bundler/definition.rb, line 303 -303: def converge_sources -304: locked_gem = @locked_sources.find { |s| Source::Rubygems === s } -305: actual_gem = @sources.find { |s| Source::Rubygems === s } -306: -307: if locked_gem && actual_gem -308: locked_gem.merge_remotes actual_gem -309: end -310: -311: @sources.map! do |source| -312: @locked_sources.find { |s| s == source } || source -313: end -314: -315: @sources.each do |source| -316: source.unlock! if source.respond_to?(:unlock!) && @unlock[:sources].include?(source.name) -317: end -318: end+ # File lib/bundler/definition.rb, line 310 +310: def converge_sources +311: locked_gem = @locked_sources.find { |s| Source::Rubygems === s } +312: actual_gem = @sources.find { |s| Source::Rubygems === s } +313: +314: if locked_gem && actual_gem +315: locked_gem.merge_remotes actual_gem +316: end +317: +318: @sources.map! do |source| +319: @locked_sources.find { |s| s == source } || source +320: end +321: +322: @sources.each do |source| +323: source.unlock! if source.respond_to?(:unlock!) && @unlock[:sources].include?(source.name) +324: end +325: end
- # File lib/bundler/definition.rb, line 405 -405: def expand_dependencies(dependencies, remote = false) -406: deps = [] -407: dependencies.each do |dep| -408: dep = Dependency.new(dep, ">= 0") unless dep.respond_to?(:name) -409: dep.gem_platforms(@platforms).each do |p| -410: deps << DepProxy.new(dep, p) if remote || p == generic(Gem::Platform.local) -411: end -412: end -413: deps -414: end+ # File lib/bundler/definition.rb, line 414 +414: def expand_dependencies(dependencies, remote = false) +415: deps = [] +416: dependencies.each do |dep| +417: dep = Dependency.new(dep, ">= 0") unless dep.respond_to?(:name) +418: dep.gem_platforms(@platforms).each do |p| +419: deps << DepProxy.new(dep, p) if remote || p == generic(Gem::Platform.local) +420: end +421: end +422: deps +423: end
- # File lib/bundler/definition.rb, line 401 -401: def expanded_dependencies -402: @expanded_dependencies ||= expand_dependencies(dependencies, @remote) -403: end+ # File lib/bundler/definition.rb, line 410 +410: def expanded_dependencies +411: @expanded_dependencies ||= expand_dependencies(dependencies, @remote) +412: end
- # File lib/bundler/definition.rb, line 393 -393: def in_locked_deps?(dep, d) -394: d && dep.source == d.source -395: end+ # File lib/bundler/definition.rb, line 402 +402: def in_locked_deps?(dep, d) +403: d && dep.source == d.source +404: end
- # File lib/bundler/definition.rb, line 296 -296: def pretty_dep(dep, source = false) -297: msg = "#{dep.name}" -298: msg << " (#{dep.requirement})" unless dep.requirement == Gem::Requirement.default -299: msg << " from the `#{dep.source}` source" if source && dep.source -300: msg -301: end+ # File lib/bundler/definition.rb, line 303 +303: def pretty_dep(dep, source = false) +304: msg = "#{dep.name}" +305: msg << " (#{dep.requirement})" unless dep.requirement == Gem::Requirement.default +306: msg << " from the `#{dep.source}` source" if source && dep.source +307: msg +308: end
- # File lib/bundler/definition.rb, line 423 -423: def requested_dependencies -424: groups = self.groups - Bundler.settings.without -425: groups.map! { |g| g.to_sym } -426: dependencies.reject { |d| !d.should_include? || (d.groups & groups).empty? } -427: end+ # File lib/bundler/definition.rb, line 432 +432: def requested_dependencies +433: groups = self.groups - Bundler.settings.without +434: groups.map! { |g| g.to_sym } +435: dependencies.reject { |d| !d.should_include? || (d.groups & groups).empty? } +436: end
- # File lib/bundler/definition.rb, line 397 -397: def satisfies_locked_spec?(dep) -398: @locked_specs.any? { |s| s.satisfies?(dep) && (!dep.source || s.source == dep.source) } -399: end+ # File lib/bundler/definition.rb, line 406 +406: def satisfies_locked_spec?(dep) +407: @locked_specs.any? { |s| s.satisfies?(dep) && (!dep.source || s.source == dep.source) } +408: end
- # File lib/bundler/definition.rb, line 416 -416: def sorted_sources -417: @sources.sort_by do |s| -418: # Place GEM at the top -419: [ s.is_a?(Source::Rubygems) ? 1 : 0, s.to_s ] -420: end -421: end+ # File lib/bundler/definition.rb, line 425 +425: def sorted_sources +426: @sources.sort_by do |s| +427: # Place GEM at the top +428: [ s.is_a?(Source::Rubygems) ? 1 : 0, s.to_s ] +429: end +430: end
- # File lib/bundler/rubygems_ext.rb, line 153 -153: def initialize(dep, platform) -154: @dep, @__platform, @required_by = dep, platform, [] -155: end+ # File lib/bundler/rubygems_ext.rb, line 167 +167: def initialize(dep, platform) +168: @dep, @__platform, @required_by = dep, platform, [] +169: end
- # File lib/bundler/rubygems_ext.rb, line 161 -161: def ==(o) -162: dep == o.dep && __platform == o.__platform -163: end+ # File lib/bundler/rubygems_ext.rb, line 175 +175: def ==(o) +176: dep == o.dep && __platform == o.__platform +177: end
- # File lib/bundler/rubygems_ext.rb, line 157 -157: def hash -158: @hash ||= dep.hash -159: end+ # File lib/bundler/rubygems_ext.rb, line 171 +171: def hash +172: @hash ||= dep.hash +173: end
- # File lib/bundler/rubygems_ext.rb, line 171 -171: def to_s -172: @dep.to_s -173: end+ # File lib/bundler/rubygems_ext.rb, line 185 +185: def to_s +186: @dep.to_s +187: end
- # File lib/bundler/rubygems_ext.rb, line 167 -167: def type -168: @dep.type -169: end+ # File lib/bundler/rubygems_ext.rb, line 181 +181: def type +182: @dep.type +183: end
- # File lib/bundler/rubygems_ext.rb, line 177 -177: def method_missing(*args) -178: @dep.send(*args) -179: end+ # File lib/bundler/rubygems_ext.rb, line 191 +191: def method_missing(*args) +192: @dep.send(*args) +193: end
- # File lib/bundler/dependency.rb, line 25 -25: def initialize(name, version, options = {}, &blk) -26: super(name, version) -27: -28: @autorequire = nil -29: @groups = Array(options["group"] || :default).map { |g| g.to_sym } -30: @source = options["source"] -31: @platforms = Array(options["platforms"]) -32: @env = options["env"] -33: -34: if options.key?('require') -35: @autorequire = Array(options['require'] || []) -36: end -37: end+ # File lib/bundler/dependency.rb, line 26 +26: def initialize(name, version, options = {}, &blk) +27: super(name, version) +28: +29: @autorequire = nil +30: @groups = Array(options["group"] || :default).map { |g| g.to_sym } +31: @source = options["source"] +32: @platforms = Array(options["platforms"]) +33: @env = options["env"] +34: +35: if options.key?('require') +36: @autorequire = Array(options['require'] || []) +37: end +38: end
- # File lib/bundler/dependency.rb, line 55 -55: def current_env? -56: return true unless @env -57: if Hash === @env -58: @env.all? do |key, val| -59: ENV[key.to_s] && (String === val ? ENV[key.to_s] == val : ENV[key.to_s] =~ val) -60: end -61: else -62: ENV[@env.to_s] -63: end -64: end+ # File lib/bundler/dependency.rb, line 56 +56: def current_env? +57: return true unless @env +58: if Hash === @env +59: @env.all? do |key, val| +60: ENV[key.to_s] && (String === val ? ENV[key.to_s] == val : ENV[key.to_s] =~ val) +61: end +62: else +63: ENV[@env.to_s] +64: end +65: end
- # File lib/bundler/dependency.rb, line 66 -66: def current_platform? -67: return true if @platforms.empty? -68: @platforms.any? { |p| send("#{p}?") } -69: end+ # File lib/bundler/dependency.rb, line 67 +67: def current_platform? +68: return true if @platforms.empty? +69: @platforms.any? { |p| send("#{p}?") } +70: end
- # File lib/bundler/dependency.rb, line 39 -39: def gem_platforms(valid_platforms) -40: return valid_platforms if @platforms.empty? -41: -42: platforms = [] -43: @platforms.each do |p| -44: platform = PLATFORM_MAP[p] -45: next unless valid_platforms.include?(platform) -46: platforms |= [platform] -47: end -48: platforms -49: end+ # File lib/bundler/dependency.rb, line 40 +40: def gem_platforms(valid_platforms) +41: return valid_platforms if @platforms.empty? +42: +43: platforms = [] +44: @platforms.each do |p| +45: platform = PLATFORM_MAP[p] +46: next unless valid_platforms.include?(platform) +47: platforms |= [platform] +48: end +49: platforms +50: end
- # File lib/bundler/dependency.rb, line 51 -51: def should_include? -52: current_env? && current_platform? -53: end+ # File lib/bundler/dependency.rb, line 52 +52: def should_include? +53: current_env? && current_platform? +54: end
- # File lib/bundler/dependency.rb, line 71 -71: def to_lock -72: out = " #{name}" -73: -74: unless requirement == Gem::Requirement.default -75: out << " (#{requirement.to_s})" -76: end -77: -78: out << '!' if source + # File lib/bundler/dependency.rb, line 72 +72: def to_lock +73: out = " #{name}" +74: +75: unless requirement == Gem::Requirement.default +76: reqs = requirement.requirements.map{|o,v| "#{o} #{v}" } +77: out << " (#{reqs.join(', ')})" +78: end 79: -80: out << "\n" -81: end+80: out << '!' if source +81: +82: out << "\n" +83: end
- # File lib/bundler/dependency.rb, line 109 -109: def jruby? -110: defined?(RUBY_ENGINE) && RUBY_ENGINE == "jruby" -111: end+ # File lib/bundler/dependency.rb, line 115 +115: def jruby? +116: defined?(RUBY_ENGINE) && RUBY_ENGINE == "jruby" +117: end
- # File lib/bundler/dependency.rb, line 117 -117: def mingw? -118: Bundler::WINDOWS && Gem::Platform.local.os == "mingw32" -119: end+ # File lib/bundler/dependency.rb, line 123 +123: def mingw? +124: Bundler::WINDOWS && Gem::Platform.local.os == "mingw32" +125: end
- # File lib/bundler/dependency.rb, line 121 -121: def mingw_18? -122: mingw? && RUBY_VERSION < "1.9" -123: end+ # File lib/bundler/dependency.rb, line 127 +127: def mingw_18? +128: mingw? && RUBY_VERSION < "1.9" +129: end
- # File lib/bundler/dependency.rb, line 125 -125: def mingw_19? -126: mingw? && RUBY_VERSION >= "1.9" -127: end+ # File lib/bundler/dependency.rb, line 131 +131: def mingw_19? +132: mingw? && RUBY_VERSION >= "1.9" +133: end
- # File lib/bundler/dependency.rb, line 97 -97: def mri? -98: !mswin? && (!defined?(RUBY_ENGINE) || RUBY_ENGINE == "ruby") -99: end+ # File lib/bundler/dependency.rb, line 99 + 99: def mri? +100: !mswin? && (!defined?(RUBY_ENGINE) || RUBY_ENGINE == "ruby") +101: end
- # File lib/bundler/dependency.rb, line 101 -101: def mri_18? -102: mri? && RUBY_VERSION < "1.9" -103: end+ # File lib/bundler/dependency.rb, line 103 +103: def mri_18? +104: mri? && RUBY_VERSION < "1.9" +105: end
- # File lib/bundler/dependency.rb, line 105 -105: def mri_19? -106: mri? && RUBY_VERSION >= "1.9" -107: end+ # File lib/bundler/dependency.rb, line 107 +107: def mri_19? +108: mri? && RUBY_VERSION >= "1.9" +109: end
- # File lib/bundler/dependency.rb, line 113 -113: def mswin? -114: Bundler::WINDOWS -115: end+ # File lib/bundler/dependency.rb, line 119 +119: def mswin? +120: Bundler::WINDOWS +121: end +
+ # File lib/bundler/dependency.rb, line 111 +111: def rbx? +112: ruby? && defined?(RUBY_ENGINE) && RUBY_ENGINE == "rbx" +113: end
- # File lib/bundler/dependency.rb, line 85 -85: def ruby? -86: !mswin? && (!defined?(RUBY_ENGINE) || RUBY_ENGINE == "ruby" || RUBY_ENGINE == "rbx") -87: end+ # File lib/bundler/dependency.rb, line 87 +87: def ruby? +88: !mswin? && (!defined?(RUBY_ENGINE) || RUBY_ENGINE == "ruby" || RUBY_ENGINE == "rbx") +89: end
- # File lib/bundler/dependency.rb, line 89 -89: def ruby_18? -90: ruby? && RUBY_VERSION < "1.9" -91: end+ # File lib/bundler/dependency.rb, line 91 +91: def ruby_18? +92: ruby? && RUBY_VERSION < "1.9" +93: end
- # File lib/bundler/dependency.rb, line 93 -93: def ruby_19? -94: ruby? && RUBY_VERSION >= "1.9" -95: end+ # File lib/bundler/dependency.rb, line 95 +95: def ruby_19? +96: ruby? && RUBY_VERSION >= "1.9" +97: end
# File lib/bundler/deployment.rb, line 3 3: def self.define_task(context, task_method = :task, opts = {}) - 4: if context.is_a?(Capistrano::Configuration) + 4: if defined?(Capistrano) && context.is_a?(Capistrano::Configuration) 5: context_name = "capistrano" 6: role_default = "{:except => {:no_release => true}}" 7: else @@ -336,7 +352,7 @@ 9: role_default = "[:app]" 10: end 11: -12: roles = context.fetch(:bundle_roles, nil) +12: roles = context.fetch(:bundle_roles, false) 13: opts[:roles] = roles if roles 14: 15: context.send :namespace, :bundle do @@ -353,7 +369,7 @@ 26: args << bundle_flags.to_s 27: args << "--without #{bundle_without.join(" ")}" unless bundle_without.empty? 28: -29: run "#{bundle_cmd} install #{args.join(' ')}" +29: run "cd #{context.fetch(:current_release)} && #{bundle_cmd} install #{args.join(' ')}" 30: end 31: end 32: enddiff --git a/vendor/plugins/bundler/doc/bundler-1.0.7/rdoc/Bundler/DeprecatedError.html b/vendor/plugins/bundler/doc/bundler-1.0.15/rdoc/Bundler/DeprecatedError.html similarity index 90% rename from vendor/plugins/bundler/doc/bundler-1.0.7/rdoc/Bundler/DeprecatedError.html rename to vendor/plugins/bundler/doc/bundler-1.0.15/rdoc/Bundler/DeprecatedError.html index 24575ae5..516a0087 100644 --- a/vendor/plugins/bundler/doc/bundler-1.0.7/rdoc/Bundler/DeprecatedError.html +++ b/vendor/plugins/bundler/doc/bundler-1.0.15/rdoc/Bundler/DeprecatedError.html @@ -79,6 +79,10 @@
- # File lib/bundler/dsl.rb, line 147 -147: def self.deprecate(name, replacement = nil) -148: define_method(name) do |*| -149: message = "'#{name}' has been removed from the Gemfile DSL, " -150: if replacement -151: message << "and has been replaced with '#{replacement}'." -152: else -153: message << "and is no longer supported." -154: end -155: message << "\nSee the README for more information on upgrading from Bundler 0.8." -156: raise DeprecatedError, message -157: end -158: end+ # File lib/bundler/dsl.rb, line 144 +144: def self.deprecate(name, replacement = nil) +145: define_method(name) do |*| +146: message = "'#{name}' has been removed from the Gemfile DSL, " +147: if replacement +148: message << "and has been replaced with '#{replacement}'." +149: else +150: message << "and is no longer supported." +151: end +152: message << "\nSee the README for more information on upgrading from Bundler 0.8." +153: raise DeprecatedError, message +154: end +155: end
- # File lib/bundler/dsl.rb, line 138 -138: def env(name) -139: @env, old = name, @env -140: yield -141: ensure -142: @env = old -143: end+ # File lib/bundler/dsl.rb, line 135 +135: def env(name) +136: @env, old = name, @env +137: yield +138: ensure +139: @env = old +140: end
- # File lib/bundler/dsl.rb, line 50 -50: def gem(name, *args) -51: if name.is_a?(Symbol) -52: raise GemfileError, %{You need to specify gem names as Strings. Use 'gem "#{name.to_s}"' instead.} -53: end + # File lib/bundler/dsl.rb, line 47 +47: def gem(name, *args) +48: if name.is_a?(Symbol) +49: raise GemfileError, %{You need to specify gem names as Strings. Use 'gem "#{name.to_s}"' instead.} +50: end +51: +52: options = Hash === args.last ? args.pop : {} +53: version = args || [">= 0"] 54: -55: options = Hash === args.last ? args.pop : {} -56: version = args || [">= 0"] +55: _deprecated_options(options) +56: _normalize_options(name, version, options) 57: -58: _deprecated_options(options) -59: _normalize_options(name, version, options) -60: -61: dep = Dependency.new(name, version, options) -62: -63: if current = @dependencies.find { |d| d.name == dep.name } -64: if current.requirement != dep.requirement -65: raise DslError, "You cannot specify the same gem twice with different version requirements. " "You specified: #{current.name} (#{current.requirement}) and " "#{dep.name} (#{dep.requirement})" -66: end -67: -68: if current.source != dep.source -69: 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}" -70: end -71: end -72: @dependencies << Dependency.new(name, version, options) -73: end+58: dep = Dependency.new(name, version, options) +59: +60: if current = @dependencies.find { |d| d.name == dep.name } +61: if current.requirement != dep.requirement +62: raise DslError, "You cannot specify the same gem twice with different version requirements. " "You specified: #{current.name} (#{current.requirement}) and " "#{dep.name} (#{dep.requirement})" +63: end +64: +65: if current.source != dep.source +66: 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}" +67: end +68: end +69: @dependencies << Dependency.new(name, version, options) +70: end
- # File lib/bundler/dsl.rb, line 102 -102: def git(uri, options = {}, source_options = {}, &blk) -103: unless block_given? -104: 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" -105: raise DeprecatedError, msg -106: end -107: -108: source Source::Git.new(_normalize_hash(options).merge("uri" => uri)), source_options, &blk -109: end+ # File lib/bundler/dsl.rb, line 99 + 99: def git(uri, options = {}, source_options = {}, &blk) +100: unless block_given? +101: 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" +102: raise DeprecatedError, msg +103: end +104: +105: source Source::Git.new(_normalize_hash(options).merge("uri" => uri)), source_options, &blk +106: end
- # File lib/bundler/dsl.rb, line 123 -123: def group(*args, &blk) -124: @groups.concat args -125: yield -126: ensure -127: args.each { @groups.pop } -128: end+ # File lib/bundler/dsl.rb, line 120 +120: def group(*args, &blk) +121: @groups.concat args +122: yield +123: ensure +124: args.each { @groups.pop } +125: end
- # File lib/bundler/dsl.rb, line 98 - 98: def path(path, options = {}, source_options = {}, &blk) - 99: source Source::Path.new(_normalize_hash(options).merge("path" => Pathname.new(path))), source_options, &blk -100: end+ # File lib/bundler/dsl.rb, line 95 +95: def path(path, options = {}, source_options = {}, &blk) +96: source Source::Path.new(_normalize_hash(options).merge("path" => Pathname.new(path))), source_options, &blk +97: end
- # File lib/bundler/dsl.rb, line 130 -130: def platforms(*platforms) -131: @platforms.concat platforms -132: yield -133: ensure -134: platforms.each { @platforms.pop } -135: end+ # File lib/bundler/dsl.rb, line 127 +127: def platforms(*platforms) +128: @platforms.concat platforms +129: yield +130: ensure +131: platforms.each { @platforms.pop } +132: end
- # File lib/bundler/dsl.rb, line 79 -79: def source(source, options = {}) -80: case source -81: when :gemcutter, :rubygems, :rubyforge then -82: rubygems_source "http://rubygems.org" + # File lib/bundler/dsl.rb, line 76 +76: def source(source, options = {}) +77: case source +78: when :gemcutter, :rubygems, :rubyforge then +79: rubygems_source "http://rubygems.org" +80: return +81: when String +82: rubygems_source source 83: return -84: when String -85: rubygems_source source -86: return -87: end +84: end +85: +86: @source = source +87: options[:prepend] ? @sources.unshift(@source) : @sources << @source 88: -89: @source = source -90: options[:prepend] ? @sources.unshift(@source) : @sources << @source -91: -92: yield if block_given? -93: @source -94: ensure -95: @source = nil -96: end+89: yield if block_given? +90: @source +91: ensure +92: @source = nil +93: end
- # File lib/bundler/dsl.rb, line 117 -117: def to_definition(lockfile, unlock) -118: @sources << @rubygems_source -119: @sources.uniq! -120: Definition.new(lockfile, @dependencies, @sources, unlock) -121: end+ # File lib/bundler/dsl.rb, line 114 +114: def to_definition(lockfile, unlock) +115: @sources << @rubygems_source +116: @sources.uniq! +117: Definition.new(lockfile, @dependencies, @sources, unlock) +118: end
- # File lib/bundler/dsl.rb, line 234 -234: def _deprecated_options(options) -235: if options.include?(:require_as) -236: raise DeprecatedError, "Please replace :require_as with :require" -237: elsif options.include?(:vendored_at) -238: raise DeprecatedError, "Please replace :vendored_at with :path" -239: elsif options.include?(:only) -240: raise DeprecatedError, "Please replace :only with :group" -241: elsif options.include?(:except) -242: raise DeprecatedError, "The :except option is no longer supported" -243: end -244: end+ # File lib/bundler/dsl.rb, line 231 +231: def _deprecated_options(options) +232: if options.include?(:require_as) +233: raise DeprecatedError, "Please replace :require_as with :require" +234: elsif options.include?(:vendored_at) +235: raise DeprecatedError, "Please replace :vendored_at with :path" +236: elsif options.include?(:only) +237: raise DeprecatedError, "Please replace :only with :group" +238: elsif options.include?(:except) +239: raise DeprecatedError, "The :except option is no longer supported" +240: end +241: end
- # File lib/bundler/dsl.rb, line 175 -175: def _normalize_hash(opts) -176: # Cannot modify a hash during an iteration in 1.9 -177: opts.keys.each do |k| -178: next if String === k -179: v = opts[k] -180: opts.delete(k) -181: opts[k.to_s] = v -182: end -183: opts -184: end+ # File lib/bundler/dsl.rb, line 172 +172: def _normalize_hash(opts) +173: # Cannot modify a hash during an iteration in 1.9 +174: opts.keys.each do |k| +175: next if String === k +176: v = opts[k] +177: opts.delete(k) +178: opts[k.to_s] = v +179: end +180: opts +181: end
- # File lib/bundler/dsl.rb, line 186 -186: def _normalize_options(name, version, opts) -187: _normalize_hash(opts) -188: -189: invalid_keys = opts.keys - %(group groups git path name branch ref tag require submodules platform platforms) -190: if invalid_keys.any? -191: plural = invalid_keys.size > 1 -192: message = "You passed #{invalid_keys.map{|k| ':'+k }.join(", ")} " -193: if plural -194: message << "as options for gem '#{name}', but they are invalid." -195: else -196: message << "as an option for gem '#{name}', but it is invalid." -197: end -198: raise InvalidOption, message -199: end -200: -201: groups = @groups.dup -202: opts["group"] = opts.delete("groups") || opts["group"] -203: groups.concat Array(opts.delete("group")) -204: groups = [:default] if groups.empty? -205: -206: platforms = @platforms.dup -207: opts["platforms"] = opts["platform"] || opts["platforms"] -208: platforms.concat Array(opts.delete("platforms")) -209: platforms.map! { |p| p.to_sym } -210: platforms.each do |p| -211: next if VALID_PLATFORMS.include?(p) -212: raise DslError, "`#{p}` is not a valid platform. The available options are: #{VALID_PLATFORMS.inspect}" -213: end -214: -215: # Normalize git and path options -216: ["git", "path"].each do |type| -217: if param = opts[type] -218: if version.first && version.first =~ /^\s*=?\s*(\d[^\s]*)\s*$/ -219: options = opts.merge("name" => name, "version" => $1) -220: else -221: options = opts.dup -222: end -223: source = send(type, param, options, :prepend => true) {} -224: opts["source"] = source -225: end -226: end -227: -228: opts["source"] ||= @source -229: opts["env"] ||= @env -230: opts["platforms"] = platforms.dup -231: opts["group"] = groups -232: end+ # File lib/bundler/dsl.rb, line 183 +183: def _normalize_options(name, version, opts) +184: _normalize_hash(opts) +185: +186: invalid_keys = opts.keys - %(group groups git path name branch ref tag require submodules platform platforms) +187: if invalid_keys.any? +188: plural = invalid_keys.size > 1 +189: message = "You passed #{invalid_keys.map{|k| ':'+k }.join(", ")} " +190: if plural +191: message << "as options for gem '#{name}', but they are invalid." +192: else +193: message << "as an option for gem '#{name}', but it is invalid." +194: end +195: raise InvalidOption, message +196: end +197: +198: groups = @groups.dup +199: opts["group"] = opts.delete("groups") || opts["group"] +200: groups.concat Array(opts.delete("group")) +201: groups = [:default] if groups.empty? +202: +203: platforms = @platforms.dup +204: opts["platforms"] = opts["platform"] || opts["platforms"] +205: platforms.concat Array(opts.delete("platforms")) +206: platforms.map! { |p| p.to_sym } +207: platforms.each do |p| +208: next if VALID_PLATFORMS.include?(p) +209: raise DslError, "`#{p}` is not a valid platform. The available options are: #{VALID_PLATFORMS.inspect}" +210: end +211: +212: # Normalize git and path options +213: ["git", "path"].each do |type| +214: if param = opts[type] +215: if version.first && version.first =~ /^\s*=?\s*(\d[^\s]*)\s*$/ +216: options = opts.merge("name" => name, "version" => $1) +217: else +218: options = opts.dup +219: end +220: source = send(type, param, options, :prepend => true) {} +221: opts["source"] = source +222: end +223: end +224: +225: opts["source"] ||= @source +226: opts["env"] ||= @env +227: opts["platforms"] = platforms.dup +228: opts["group"] = groups +229: end
- # File lib/bundler/dsl.rb, line 170 -170: def rubygems_source(source) -171: @rubygems_source.add_remote source -172: @sources << @rubygems_source -173: end+ # File lib/bundler/dsl.rb, line 167 +167: def rubygems_source(source) +168: @rubygems_source.add_remote source +169: @sources << @rubygems_source +170: end
- # File lib/bundler/gem_helper.rb, line 7 - 7: def self.install_tasks(opts = nil) - 8: dir = File.dirname(Rake.application.rakefile_location) - 9: self.new(dir, opts && opts[:name]).install -10: end+ # File lib/bundler/gem_helper.rb, line 9 + 9: def self.install_tasks(opts = {}) +10: dir = opts[:dir] || Dir.pwd +11: self.new(dir, opts[:name]).install +12: end
- # File lib/bundler/gem_helper.rb, line 14 -14: def initialize(base, name = nil) -15: Bundler.ui = UI::Shell.new(Thor::Base.shell.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 16 +16: def initialize(base, name = nil) +17: Bundler.ui = UI::Shell.new(Thor::Base.shell.new) +18: @base = base +19: gemspecs = name ? [File.join(base, "#{name}.gemspec")] : Dir[File.join(base, "*.gemspec")] +20: raise "Unable to determine name from existing gemspec. Use :name => 'gemname' in #install_tasks to manually set it." unless gemspecs.size == 1 +21: @spec_path = gemspecs.first +22: @gemspec = Bundler.load_gemspec(@spec_path) +23: end
- # File lib/bundler/gem_helper.rb, line 40 -40: def build_gem -41: file_name = nil -42: sh("gem build #{spec_path}") { |out, code| -43: raise out unless out[/Successfully/] -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 42 +42: def build_gem +43: file_name = nil +44: sh("gem build '#{spec_path}'") { |out, code| +45: raise out unless out[/Successfully/] +46: file_name = File.basename(built_gem_path) +47: FileUtils.mkdir_p(File.join(base, 'pkg')) +48: FileUtils.mv(built_gem_path, 'pkg') +49: Bundler.ui.confirm "#{name} #{version} built to pkg/#{file_name}" +50: } +51: File.join(base, 'pkg', file_name) +52: 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 25 +25: def install +26: desc "Build #{name}-#{version}.gem into the pkg directory" +27: task 'build' do +28: build_gem +29: end +30: +31: desc "Build and install #{name}-#{version}.gem into system gems" +32: task 'install' do +33: install_gem +34: end +35: +36: desc "Create tag #{version_tag} and build and push #{name}-#{version}.gem to Rubygems" +37: task 'release' do +38: release_gem +39: end +40: end
- # File lib/bundler/gem_helper.rb, line 52 -52: def install_gem -53: built_gem_path = build_gem -54: out, code = sh_with_code("gem install #{built_gem_path}") -55: raise "Couldn't install gem, run `gem install #{built_gem_path}' for more detailed output" unless out[/Successfully installed/] -56: Bundler.ui.confirm "#{name} (#{version}) installed" -57: end+ # File lib/bundler/gem_helper.rb, line 54 +54: def install_gem +55: built_gem_path = build_gem +56: out, _ = sh_with_code("gem install '#{built_gem_path}'") +57: raise "Couldn't install gem, run `gem install #{built_gem_path}' for more detailed output" unless out[/Successfully installed/] +58: Bundler.ui.confirm "#{name} (#{version}) installed" +59: end
- # File lib/bundler/gem_helper.rb, line 59 -59: def release_gem -60: guard_clean -61: guard_already_tagged -62: built_gem_path = build_gem -63: tag_version { -64: git_push -65: rubygem_push(built_gem_path) -66: } -67: end+ # File lib/bundler/gem_helper.rb, line 61 +61: def release_gem +62: guard_clean +63: guard_already_tagged +64: built_gem_path = build_gem +65: tag_version { +66: git_push +67: rubygem_push(built_gem_path) +68: } +69: end
- # File lib/bundler/gem_helper.rb, line 76 -76: def built_gem_path -77: Dir[File.join(base, "#{name}-*.gem")].sort_by{|f| File.mtime(f)}.last -78: 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 102 -102: def clean? -103: out, code = sh_with_code("git diff --exit-code") -104: code == 0 -105: end+ # File lib/bundler/gem_helper.rb, line 104 +104: def clean? +105: sh_with_code("git diff --exit-code")[1] == 0 +106: end
- # File lib/bundler/gem_helper.rb, line 80 -80: def git_push -81: perform_git_push -82: perform_git_push ' --tags' -83: Bundler.ui.confirm "Pushed git commits and tags" -84: 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 92 -92: def guard_already_tagged -93: if sh('git tag').split(/\n/).include?(version_tag) -94: raise("This tag has already been committed to the repo.") -95: end -96: end+ # File lib/bundler/gem_helper.rb, line 94 +94: def guard_already_tagged +95: if sh('git tag').split(/\n/).include?(version_tag) +96: raise("This tag has already been committed to the repo.") +97: end +98: end
- # File lib/bundler/gem_helper.rb, line 98 - 98: def guard_clean - 99: clean? or raise("There are files that need to be committed first.") -100: end+ # File lib/bundler/gem_helper.rb, line 100 +100: def guard_clean +101: clean? or raise("There are files that need to be committed first.") +102: end
- # File lib/bundler/gem_helper.rb, line 125 -125: def name -126: gemspec.name -127: end+ # File lib/bundler/gem_helper.rb, line 126 +126: def name +127: gemspec.name +128: end
- # File lib/bundler/gem_helper.rb, line 86 -86: def perform_git_push(options = '') -87: cmd = "git push #{options}" -88: out, code = sh_with_code(cmd) -89: raise "Couldn't git push. `#{cmd}' failed with the following output:\n\n#{out}\n" unless code == 0 -90: end+ # File lib/bundler/gem_helper.rb, line 88 +88: def perform_git_push(options = '') +89: cmd = "git push #{options}" +90: out, code = sh_with_code(cmd) +91: raise "Couldn't git push. `#{cmd}' failed with the following output:\n\n#{out}\n" unless code == 0 +92: end
- # File lib/bundler/gem_helper.rb, line 70 -70: def rubygem_push(path) -71: out, status = sh("gem push #{path}") -72: raise "Gem push failed due to lack of RubyGems.org credentials." if out[/Enter your RubyGems.org credentials/] -73: Bundler.ui.confirm "Pushed #{name} #{version} to rubygems.org" -74: end+ # File lib/bundler/gem_helper.rb, line 72 +72: def rubygem_push(path) +73: out, _ = sh("gem push '#{path}'") +74: raise "Gem push failed due to lack of RubyGems.org credentials." if out[/Enter your RubyGems.org credentials/] +75: Bundler.ui.confirm "Pushed #{name} #{version} to rubygems.org" +76: end
- # File lib/bundler/gem_helper.rb, line 129 -129: def sh(cmd, &block) -130: out, code = sh_with_code(cmd, &block) -131: code == 0 ? out : raise(out.empty? ? "Running `#{cmd}' failed. Run this command directly for more detailed output." : out) -132: end+ # File lib/bundler/gem_helper.rb, line 130 +130: def sh(cmd, &block) +131: out, code = sh_with_code(cmd, &block) +132: code == 0 ? out : raise(out.empty? ? "Running `#{cmd}' failed. Run this command directly for more detailed output." : out) +133: end
- # File lib/bundler/gem_helper.rb, line 134 -134: def sh_with_code(cmd, &block) -135: cmd << " 2>&1" -136: outbuf = '' -137: Bundler.ui.debug(cmd) -138: Dir.chdir(base) { -139: outbuf = `#{cmd}` -140: if $? == 0 -141: block.call(outbuf) if block -142: end -143: } -144: [outbuf, $?] -145: end+ # File lib/bundler/gem_helper.rb, line 135 +135: def sh_with_code(cmd, &block) +136: cmd << " 2>&1" +137: outbuf = '' +138: Bundler.ui.debug(cmd) +139: Dir.chdir(base) { +140: outbuf = `#{cmd}` +141: if $? == 0 +142: block.call(outbuf) if block +143: end +144: } +145: [outbuf, $?] +146: end
- # File lib/bundler/gem_helper.rb, line 107 -107: def tag_version -108: sh "git tag -a -m \"Version #{version}\" #{version_tag}" -109: Bundler.ui.confirm "Tagged #{version_tag}" -110: yield if block_given? -111: rescue -112: Bundler.ui.error "Untagged #{version_tag} due to error" -113: sh_with_code "git tag -d #{version_tag}" -114: raise -115: end+ # File lib/bundler/gem_helper.rb, line 108 +108: def tag_version +109: sh "git tag -a -m \"Version #{version}\" #{version_tag}" +110: Bundler.ui.confirm "Tagged #{version_tag}" +111: yield if block_given? +112: rescue +113: Bundler.ui.error "Untagged #{version_tag} due to error" +114: sh_with_code "git tag -d #{version_tag}" +115: raise +116: end
- # File lib/bundler/gem_helper.rb, line 117 -117: def version -118: gemspec.version -119: end+ # File lib/bundler/gem_helper.rb, line 118 +118: def version +119: gemspec.version +120: end
- # File lib/bundler/gem_helper.rb, line 121 -121: def version_tag -122: "v#{version}" -123: end+ # File lib/bundler/gem_helper.rb, line 122 +122: def version_tag +123: "v#{version}" +124: end
- # File lib/bundler/rubygems_ext.rb, line 193 -193: def generic(p) -194: return p if p == Gem::Platform::RUBY -195: -196: GENERIC_CACHE[p] ||= begin -197: found = GENERICS.find do |p2| -198: p2.is_a?(Gem::Platform) && p.os == p2.os -199: end -200: found || Gem::Platform::RUBY -201: end -202: end+ # File lib/bundler/rubygems_ext.rb, line 207 +207: def generic(p) +208: return p if p == Gem::Platform::RUBY +209: +210: GENERIC_CACHE[p] ||= begin +211: found = GENERICS.find do |p2| +212: p2.is_a?(Gem::Platform) && p.os == p2.os +213: end +214: found || Gem::Platform::RUBY +215: end +216: end
# 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 +13: # Create the BUNDLE_PATH directory +14: begin +15: Bundler.bundle_path.mkpath unless Bundler.bundle_path.exist? +16: rescue Errno::EEXIST +17: raise PathError, "Could not install to path `#{Bundler.settings[:path]}` " + +18: "because of an invalid symlink. Remove the symlink so the directory can be created." +19: end +20: +21: if Bundler.settings[:frozen] +22: @definition.ensure_equivalent_gemfile_and_lockfile(options[:deployment]) +23: end +24: +25: if dependencies.empty? +26: Bundler.ui.warn "The Gemfile specifies no dependencies" +27: return 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! +30: if Bundler.default_lockfile.exist? && !options["update"] +31: begin +32: tmpdef = Definition.build(Bundler.default_gemfile, Bundler.default_lockfile, nil) +33: local = true unless tmpdef.new_platform? || tmpdef.missing_specs.any? +34: rescue BundlerError +35: end 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 +38: # Since we are installing, we can resolve the definition +39: # using remote specs +40: unless local +41: options["local"] ? +42: @definition.resolve_with_cache! : +43: @definition.resolve_remotely! +44: end +45: +46: # Must install gems in the order that the resolver provides +47: # as dependencies might actually affect the installation of +48: # the gem. +49: specs.each do |spec| +50: spec.source.fetch(spec) if spec.source.respond_to?(:fetch) 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: Bundler.ui.debug "from #{spec.loaded_from} " -57: ensure -58: Gem::Command.build_args = old_args -59: end -60: -61: Bundler.ui.info "" -62: generate_bundler_executable_stubs(spec) if Bundler.settings[:bin] -63: FileUtils.rm_rf(Bundler.tmp) -64: end -65: -66: lock -67: end+52: # unless requested_specs.include?(spec) +53: # Bundler.ui.debug " * Not in requested group; skipping." +54: # next +55: # end +56: +57: Bundler.rubygems.with_build_args [Bundler.settings["build.#{spec.name}"]] do +58: spec.source.install(spec) +59: Bundler.ui.debug "from #{spec.loaded_from} " +60: end +61: +62: Bundler.ui.info "" +63: generate_bundler_executable_stubs(spec) if Bundler.settings[:bin] +64: FileUtils.rm_rf(Bundler.tmp) +65: end +66: +67: lock +68: end @@ -465,20 +482,20 @@
- # File lib/bundler/installer.rb, line 71 -71: def generate_bundler_executable_stubs(spec) -72: bin_path = Bundler.bin_path -73: template = File.read(File.expand_path('../templates/Executable', __FILE__)) -74: relative_gemfile_path = Bundler.default_gemfile.relative_path_from(bin_path) -75: ruby_command = Thor::Util.ruby_command -76: -77: spec.executables.each do |executable| -78: next if executable == "bundle" -79: File.open "#{bin_path}/#{executable}", 'w', 0755 do |f| -80: f.puts ERB.new(template, nil, '-').result(binding) -81: end -82: end -83: end+ # File lib/bundler/installer.rb, line 72 +72: def generate_bundler_executable_stubs(spec) +73: bin_path = Bundler.bin_path +74: template = File.read(File.expand_path('../templates/Executable', __FILE__)) +75: relative_gemfile_path = Bundler.default_gemfile.relative_path_from(bin_path) +76: ruby_command = Thor::Util.ruby_command +77: +78: spec.executables.each do |executable| +79: next if executable == "bundle" +80: File.open "#{bin_path}/#{executable}", 'w', 0755 do |f| +81: f.puts ERB.new(template, nil, '-').result(binding) +82: end +83: end +84: end
- # File lib/bundler/rubygems_ext.rb, line 208 -208: def match_platform(p) -209: Gem::Platform::RUBY == platform or -210: platform.nil? or p == platform or -211: generic(Gem::Platform.new(platform)) == p -212: end+ # File lib/bundler/rubygems_ext.rb, line 222 +222: def match_platform(p) +223: Gem::Platform::RUBY == platform or +224: platform.nil? or p == platform or +225: generic(Gem::Platform.new(platform)) == p +226: end
# File lib/bundler/resolver.rb, line 409 409: def error_message -410: output = errors.inject("") do |o, (conflict, (origin, requirement))| +410: errors.inject("") do |o, (conflict, (origin, requirement))| 411: 412: # origin is the SpecSet of specs from the Gemfile that is conflicted with 413: if origin @@ -592,7 +608,7 @@ If the list of dependencies can be resolved, a 422: o << " Current Bundler version:\n" 423: newer_bundler_required = requirement.requirement > Gem::Requirement.new(origin.version) 424: # If the origin is a LockfileParser, it does not respond_to :required_by -425: elsif !origin.respond_to?(:required_by) || !(required_by = origin.required_by.first) +425: elsif !origin.respond_to?(:required_by) || !(origin.required_by.first) 426: o << " In snapshot (Gemfile.lock):\n" 427: end 428: diff --git a/vendor/plugins/bundler/doc/bundler-1.0.7/rdoc/Bundler/Resolver/SpecGroup.html b/vendor/plugins/bundler/doc/bundler-1.0.15/rdoc/Bundler/Resolver/SpecGroup.html similarity index 95% rename from vendor/plugins/bundler/doc/bundler-1.0.7/rdoc/Bundler/Resolver/SpecGroup.html rename to vendor/plugins/bundler/doc/bundler-1.0.15/rdoc/Bundler/Resolver/SpecGroup.html index e37a38ca..c8611f71 100644 --- a/vendor/plugins/bundler/doc/bundler-1.0.7/rdoc/Bundler/Resolver/SpecGroup.html +++ b/vendor/plugins/bundler/doc/bundler-1.0.15/rdoc/Bundler/Resolver/SpecGroup.html @@ -117,6 +117,10 @@
Object
+ ++ # File lib/bundler/rubygems_integration.rb, line 72 +72: def bin_path(gem, bin, ver) +73: Gem.bin_path(gem, bin, ver) +74: end+
+ # File lib/bundler/rubygems_integration.rb, line 68 +68: def clear_paths +69: Gem.clear_paths +70: end+
+ # File lib/bundler/rubygems_integration.rb, line 24 +24: def configuration +25: Gem.configuration +26: end+
+ # File lib/bundler/rubygems_integration.rb, line 103 +103: def download_gem(spec, uri, path) +104: Gem::RemoteFetcher.fetcher.download(spec, uri, path) +105: end+
+ # File lib/bundler/rubygems_integration.rb, line 85 +85: def fetch_specs(all, pre, &blk) +86: Gem::SpecFetcher.new.list(all, pre).each(&blk) +87: end+
+ # File lib/bundler/rubygems_integration.rb, line 52 +52: def gem_bindir +53: Gem.bindir +54: end+
+ # File lib/bundler/rubygems_integration.rb, line 48 +48: def gem_dir +49: Gem.dir +50: end+
+ # File lib/bundler/rubygems_integration.rb, line 60 +60: def gem_path +61: Gem.path +62: end+
+ # File lib/bundler/rubygems_integration.rb, line 36 +36: def inflate(obj) +37: Gem.inflate(obj) +38: end+
+ # File lib/bundler/rubygems_integration.rb, line 8 + 8: def loaded_specs(name) + 9: Gem.loaded_specs[name] +10: end+
+ # File lib/bundler/rubygems_integration.rb, line 12 +12: def mark_loaded(spec) +13: Gem.loaded_specs[spec.name] = spec +14: end+
+ # File lib/bundler/rubygems_integration.rb, line 64 +64: def marshal_spec_dir +65: Gem::MARSHAL_SPEC_DIR +66: end+
+ # File lib/bundler/rubygems_integration.rb, line 16 +16: def path(obj) +17: obj.to_s +18: end+
+ # File lib/bundler/rubygems_integration.rb, line 20 +20: def platforms +21: Gem.platforms +22: end+
+ # File lib/bundler/rubygems_integration.rb, line 76 +76: def preserve_paths +77: # this is a no-op outside of Rubygems 1.8 +78: yield +79: end+
+ # File lib/bundler/rubygems_integration.rb, line 32 +32: def read_binary(path) +33: Gem.read_binary(path) +34: end+
+Used to make bin stubs that are not created by bundler work under bundler. +The new Gem.bin_path only considers gems in specs +
+ + + ++ # File lib/bundler/rubygems_integration.rb, line 204 +204: def replace_bin_path(specs) +205: gem_class = (class << Gem ; self ; end) +206: gem_class.send(:remove_method, :bin_path) +207: gem_class.send(:define_method, :bin_path) do |name, *args| +208: exec_name, *reqs = args +209: +210: if exec_name == 'bundle' +211: return ENV['BUNDLE_BIN_PATH'] +212: end +213: +214: spec = nil +215: +216: if exec_name +217: spec = specs.find { |s| s.executables.include?(exec_name) } +218: spec or raise Gem::Exception, "can't find executable #{exec_name}" +219: else +220: spec = specs.find { |s| s.name == name } +221: exec_name = spec.default_executable or raise Gem::Exception, "no default executable for #{spec.full_name}" +222: end +223: +224: gem_bin = File.join(spec.full_gem_path, spec.bindir, exec_name) +225: gem_from_path_bin = File.join(File.dirname(spec.loaded_from), spec.bindir, exec_name) +226: File.exist?(gem_bin) ? gem_bin : gem_from_path_bin +227: end +228: end+
+Replace or hook into Rubygems to provide a bundlerized view of the world. +
+ + + ++ # File lib/bundler/rubygems_integration.rb, line 240 +240: def replace_entrypoints(specs) +241: reverse_rubygems_kernel_mixin +242: +243: replace_gem(specs) +244: +245: stub_rubygems(specs) +246: +247: replace_bin_path(specs) +248: replace_refresh +249: +250: Gem.clear_paths +251: end+
+ # File lib/bundler/rubygems_integration.rb, line 119 +119: def replace_gem(specs) +120: executables = specs.map { |s| s.executables }.flatten +121: +122: ::Kernel.send(:define_method, :gem) do |dep, *reqs| +123: if executables.include? File.basename(caller.first.split(':').first) +124: return +125: end +126: opts = reqs.last.is_a?(Hash) ? reqs.pop : {} +127: +128: unless dep.respond_to?(:name) && dep.respond_to?(:requirement) +129: dep = Gem::Dependency.new(dep, reqs) +130: end +131: +132: spec = specs.find { |s| s.name == dep.name } +133: +134: if spec.nil? +135: +136: e = Gem::LoadError.new "#{dep.name} is not part of the bundle. Add it to Gemfile." +137: e.name = dep.name +138: if e.respond_to?(:requirement=) +139: e.requirement = dep.requirement +140: else +141: e.version_requirement = dep.requirement +142: end +143: raise e +144: elsif dep !~ spec +145: e = Gem::LoadError.new "can't activate #{dep}, already activated #{spec.full_name}. " "Make sure all dependencies are added to Gemfile." +146: e.name = dep.name +147: if e.respond_to?(:requirement=) +148: e.requirement = dep.requirement +149: else +150: e.version_requirement = dep.requirement +151: end +152: raise e +153: end +154: +155: true +156: end +157: end+
+Because Bundler has a static view of what +specs are available, we don’t reflesh, so stub it out. +
+ + + ++ # File lib/bundler/rubygems_integration.rb, line 232 +232: def replace_refresh +233: gem_class = (class << Gem ; self ; end) +234: gem_class.send(:remove_method, :refresh) +235: gem_class.send(:define_method, :refresh) { } +236: end+
+ # File lib/bundler/rubygems_integration.rb, line 107 +107: def reverse_rubygems_kernel_mixin +108: # Disable rubygems' gem activation system +109: ::Kernel.class_eval do +110: if private_method_defined?(:gem_original_require) +111: alias rubygems_require require +112: alias require gem_original_require +113: end +114: +115: undef gem +116: end +117: end+
+ # File lib/bundler/rubygems_integration.rb, line 28 +28: def ruby_engine +29: Gem.ruby_engine +30: end+
+ # File lib/bundler/rubygems_integration.rb, line 44 +44: def sources +45: Gem.sources +46: end+
+ # File lib/bundler/rubygems_integration.rb, line 40 +40: def sources=(val) +41: Gem.sources = val +42: end+
+ # File lib/bundler/rubygems_integration.rb, line 99 + 99: def spec_from_gem(path) +100: Gem::Format.from_file_by_path(path).spec +101: end+
+ # File lib/bundler/rubygems_integration.rb, line 170 +170: def stub_source_index137(specs) +171: # Rubygems versions lower than 1.7 use SourceIndex#from_gems_in +172: source_index_class = (class << Gem::SourceIndex ; self ; end) +173: source_index_class.send(:remove_method, :from_gems_in) +174: source_index_class.send(:define_method, :from_gems_in) do |*args| +175: source_index = Gem::SourceIndex.new +176: source_index.spec_dirs = *args +177: source_index.add_specs(*specs) +178: source_index +179: end +180: end+
+ # File lib/bundler/rubygems_integration.rb, line 182 +182: def stub_source_index170(specs) +183: Gem::SourceIndex.send(:define_method, :initialize) do |*args| +184: @gems = {} +185: # You're looking at this thinking: Oh! This is how I make those +186: # rubygems deprecations go away! +187: # +188: # You'd be correct BUT using of this method in production code +189: # must be approved by the rubygems team itself! +190: # +191: # This is your warning. If you use this and don't have approval +192: # we can't protect you. +193: # +194: Deprecate.skip_during do +195: self.spec_dirs = *args +196: add_specs(*specs) +197: end +198: end +199: end+
+ # File lib/bundler/rubygems_integration.rb, line 81 +81: def ui=(obj) +82: Gem::DefaultUserInteraction.ui = obj +83: end+
+ # File lib/bundler/rubygems_integration.rb, line 56 +56: def user_home +57: Gem.user_home +58: end+
+ # File lib/bundler/rubygems_integration.rb, line 89 +89: def with_build_args(args) +90: old_args = Gem::Command.build_args +91: begin +92: Gem::Command.build_args = args +93: yield +94: ensure +95: Gem::Command.build_args = old_args +96: end +97: end+
Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
++Rubygems 1.8.0 to 1.8.4 +
+ ++Rubygems [>= 1.8.0, < 1.8.5] has a bug that changes Gem.dir whenever you +call Gem::Installer#install with an :install_dir set. We have to change it +back for our sudo mode to work. +
+ + + ++ # File lib/bundler/rubygems_integration.rb, line 301 +301: def preserve_paths +302: old_dir, old_path = gem_dir, gem_path +303: yield +304: Gem.use_paths(old_dir, old_path) +305: 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.
++Rubygems versions 1.3.6 through 1.6.2 +
+ ++ # File lib/bundler/rubygems_integration.rb, line 259 +259: def all_specs +260: Gem.source_index.gems.values +261: end+
Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
++Rubygems 1.8.5 +
+ ++ # File lib/bundler/rubygems_integration.rb, line 287 +287: def all_specs +288: Gem::Specification.to_a +289: end+
+ # File lib/bundler/rubygems_integration.rb, line 291 +291: def find_name(name) +292: Gem::Specification.find_all_by_name name +293: end+
+ # File lib/bundler/rubygems_integration.rb, line 277 +277: def stub_rubygems(specs) +278: Gem::Specification.all = specs +279: +280: Gem.post_reset { +281: Gem::Specification.all = specs +282: } +283: +284: stub_source_index170(specs) +285: end+
Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
++Rubygems 1.7 +
+ +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 87 +87: def cache +88: FileUtils.mkdir_p(cache_path) unless File.exists?(cache_path) +89: +90: Bundler.ui.info "Updating .gem files in vendor/cache" +91: specs.each do |spec| +92: next if spec.name == 'bundler' +93: spec.source.cache(spec) if spec.source.respond_to?(:cache) +94: end +95: prune_cache unless Bundler.settings[:no_prune] +96: 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 77 +77: def dependencies_for(*groups) +78: if groups.empty? +79: dependencies +80: else +81: dependencies.select { |d| (groups & d.groups).any? } +82: end +83: 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 && !s.source.is_a?(Bundler::Source::Git) -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 98 + 98: def prune_cache + 99: FileUtils.mkdir_p(cache_path) unless File.exists?(cache_path) +100: +101: resolve = @definition.resolve +102: cached = Dir["#{cache_path}/*.gem"] +103: +104: cached = cached.delete_if do |path| +105: spec = Bundler.rubygems.spec_from_gem path +106: +107: resolve.any? do |s| +108: s.name == spec.name && s.version == spec.version && !s.source.is_a?(Bundler::Source::Git) +109: end +110: end +111: +112: if cached.any? +113: Bundler.ui.info "Removing outdated .gem files from vendor/cache" +114: +115: cached.each do |path| +116: Bundler.ui.info " * #{File.basename(path)}" +117: File.delete(path) +118: end +119: end +120: 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 51 +51: def require(*groups) +52: groups.map! { |g| g.to_sym } +53: groups = [:default] if groups.empty? +54: +55: @definition.dependencies.each do |dep| +56: # Skip the dependency if it is not in any of the requested +57: # groups +58: next unless ((dep.groups & groups).any? && dep.current_platform?) +59: +60: required_file = nil +61: +62: begin +63: # Loop through all the specified autorequires for the +64: # dependency. If there are none, use the dependency's name +65: # as the autorequire. +66: Array(dep.autorequire || dep.name).each do |file| +67: required_file = file +68: Kernel.require file +69: end +70: rescue LoadError => e +71: REGEXPS.find { |r| r =~ e.message } +72: raise if dep.autorequire || $1 != required_file +73: end +74: end +75: 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 cache_path +125: root.join("vendor/cache") +126: 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+ # File lib/bundler/runtime.rb, line 128 +128: def setup_environment +129: begin +130: ENV["BUNDLE_BIN_PATH"] = Bundler.rubygems.bin_path("bundler", "bundle", VERSION) +131: rescue Gem::GemNotFoundException +132: ENV["BUNDLE_BIN_PATH"] = File.expand_path("../../../bin/bundle", __FILE__) +133: end +134: +135: # Set PATH +136: paths = (ENV["PATH"] || "").split(File::PATH_SEPARATOR) +137: paths.unshift "#{Bundler.bundle_path}/bin" +138: ENV["PATH"] = paths.uniq.join(File::PATH_SEPARATOR) +139: +140: # Set BUNDLE_GEMFILE +141: ENV["BUNDLE_GEMFILE"] = default_gemfile.to_s +142: +143: # Set RUBYOPT +144: rubyopt = [ENV["RUBYOPT"]].compact +145: if rubyopt.empty? || rubyopt.first !~ /-rbundler\/setup/ +146: rubyopt.unshift "-rbundler/setup" +147: rubyopt.unshift "-I#{File.expand_path('../..', __FILE__)}" +148: ENV["RUBYOPT"] = rubyopt.join(' ') +149: end +150: end
# File lib/bundler/settings.rb, line 18 18: def delete(key) -19: @local_config +19: @local_config.delete(key_for(key)) 20: end@@ -624,7 +640,7 @@ ENV[“BUNDLE_PATH“] 79: if path = self[:path] 80: "#{path}/#{Bundler.ruby_scope}" 81: else -82: Gem.dir +82: Bundler.rubygems.gem_dir 83: end 84: end @@ -819,7 +835,7 @@ ENV[“BUNDLE_PATH“]
# File lib/bundler/settings.rb, line 108 108: def global_config_file -109: file = ENV["BUNDLE_CONFIG"] || File.join(Gem.user_home, ".bundle/config") +109: file = ENV["BUNDLE_CONFIG"] || File.join(Bundler.rubygems.user_home, ".bundle/config") 110: Pathname.new(file) 111: enddiff --git a/vendor/plugins/bundler/doc/bundler-1.0.15/rdoc/Bundler/SharedHelpers.html b/vendor/plugins/bundler/doc/bundler-1.0.15/rdoc/Bundler/SharedHelpers.html new file mode 100644 index 00000000..94099072 --- /dev/null +++ b/vendor/plugins/bundler/doc/bundler-1.0.15/rdoc/Bundler/SharedHelpers.html @@ -0,0 +1,572 @@ + + + + + + +
+ # File lib/bundler/shared_helpers.rb, line 20 +20: def default_gemfile +21: gemfile = find_gemfile +22: raise GemfileNotFound, "Could not locate Gemfile" unless gemfile +23: Pathname.new(gemfile) +24: end+
+ # File lib/bundler/shared_helpers.rb, line 56 +56: def clean_load_path +57: # handle 1.9 where system gems are always on the load path +58: if defined?(::Gem) +59: me = File.expand_path("../../", __FILE__) +60: $LOAD_PATH.reject! do |p| +61: next if File.expand_path(p) =~ /^#{Regexp.escape(me)}/ +62: p != File.dirname(__FILE__) && +63: Bundler.rubygems.gem_path.any?{|gp| p =~ /^#{Regexp.escape(gp)}/ } +64: end +65: $LOAD_PATH.uniq! +66: end +67: end+
+ # File lib/bundler/shared_helpers.rb, line 36 +36: def find_gemfile +37: given = ENV['BUNDLE_GEMFILE'] +38: return given if given && !given.empty? +39: +40: previous = nil +41: current = File.expand_path(Dir.pwd) +42: +43: until !File.directory?(current) || current == previous +44: if ENV['BUNDLE_SPEC_RUN'] +45: # avoid stepping above the tmp directory when testing +46: return nil if File.file?(File.join(current, 'bundler.gemspec')) +47: end +48: +49: # otherwise return the Gemfile if it's there +50: filename = File.join(current, 'Gemfile') +51: return filename if File.file?(filename) +52: current, previous = File.expand_path("..", current), current +53: end +54: end+
Disabled; run with --debug to generate this.
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
+- # File lib/bundler/source.rb, line 476 -476: def self.from_lock(options) -477: new(options.merge("uri" => options.delete("remote"))) -478: end+ # File lib/bundler/source.rb, line 489 +489: def self.from_lock(options) +490: new(options.merge("uri" => options.delete("remote"))) +491: end
- # File lib/bundler/source.rb, line 463 -463: def initialize(options) -464: super -465: -466: # stringify options that could be set as symbols -467: %(ref branch tag revision).each{|k| options[k] = options[k].to_s if options[k] } -468: -469: @uri = options["uri"] -470: @ref = options["ref"] || options["branch"] || options["tag"] || 'master' -471: @revision = options["revision"] -472: @submodules = options["submodules"] -473: @update = false -474: end+ # File lib/bundler/source.rb, line 476 +476: def initialize(options) +477: super +478: +479: # stringify options that could be set as symbols +480: %(ref branch tag revision).each{|k| options[k] = options[k].to_s if options[k] } +481: +482: @uri = options["uri"] +483: @ref = options["ref"] || options["branch"] || options["tag"] || 'master' +484: @revision = options["revision"] +485: @submodules = options["submodules"] +486: @update = false +487: end
- # File lib/bundler/source.rb, line 491 -491: def eql?(o) -492: Git === o && -493: uri == o.uri && -494: ref == o.ref && -495: name == o.name && -496: version == o.version && -497: submodules == o.submodules -498: end+ # File lib/bundler/source.rb, line 504 +504: def eql?(o) +505: Git === o && +506: uri == o.uri && +507: ref == o.ref && +508: name == o.name && +509: version == o.version && +510: submodules == o.submodules +511: end
- # File lib/bundler/source.rb, line 538 -538: def install(spec) -539: Bundler.ui.info "Using #{spec.name} (#{spec.version}) from #{to_s} " -540: -541: unless @installed -542: Bundler.ui.debug " * Checking out revision: #{ref}" -543: checkout if allow_git_ops? -544: @installed = true -545: end -546: generate_bin(spec) -547: end+ # File lib/bundler/source.rb, line 551 +551: def install(spec) +552: Bundler.ui.info "Using #{spec.name} (#{spec.version}) from #{to_s} " +553: +554: unless @installed +555: Bundler.ui.debug " * Checking out revision: #{ref}" +556: checkout if allow_git_ops? +557: @installed = true +558: end +559: generate_bin(spec) +560: end
- # File lib/bundler/source.rb, line 549 -549: def load_spec_files -550: super -551: rescue PathError, GitError -552: raise GitError, "#{to_s} is not checked out. Please run `bundle install`" -553: end+ # File lib/bundler/source.rb, line 562 +562: def load_spec_files +563: super +564: rescue PathError, GitError +565: raise GitError, "#{to_s} is not checked out. Please run `bundle install`" +566: end
- # File lib/bundler/source.rb, line 507 -507: def name -508: File.basename(@uri, '.git') -509: end+ # File lib/bundler/source.rb, line 520 +520: def name +521: File.basename(@uri, '.git') +522: end
- # File lib/bundler/source.rb, line 511 -511: def path -512: @install_path ||= begin -513: git_scope = "#{base_name}-#{shortref_for_path(revision)}" -514: -515: if Bundler.requires_sudo? -516: Bundler.user_bundle_path.join(Bundler.ruby_scope).join(git_scope) -517: else -518: Bundler.install_path.join(git_scope) -519: end -520: end -521: end+ # File lib/bundler/source.rb, line 524 +524: def path +525: @install_path ||= begin +526: git_scope = "#{base_name}-#{shortref_for_path(revision)}" +527: +528: if Bundler.requires_sudo? +529: Bundler.user_bundle_path.join(Bundler.ruby_scope).join(git_scope) +530: else +531: Bundler.install_path.join(git_scope) +532: end +533: end +534: end
- # File lib/bundler/source.rb, line 528 -528: def specs -529: if allow_git_ops? && !@update -530: # Start by making sure the git cache is up to date -531: cache -532: checkout -533: @update = true -534: end -535: local_specs -536: end+ # File lib/bundler/source.rb, line 541 +541: def specs +542: if allow_git_ops? && !@update +543: # Start by making sure the git cache is up to date +544: cache +545: checkout +546: @update = true +547: end +548: local_specs +549: end
- # File lib/bundler/source.rb, line 480 -480: def to_lock -481: out = "GIT\n" -482: out << " remote: #{@uri}\n" -483: out << " revision: #{revision}\n" -484: %(ref branch tag submodules).each do |opt| -485: out << " #{opt}: #{options[opt]}\n" if options[opt] -486: end -487: out << " glob: #{@glob}\n" unless @glob == DEFAULT_GLOB -488: out << " specs:\n" -489: end+ # File lib/bundler/source.rb, line 493 +493: def to_lock +494: out = "GIT\n" +495: out << " remote: #{@uri}\n" +496: out << " revision: #{revision}\n" +497: %(ref branch tag submodules).each do |opt| +498: out << " #{opt}: #{options[opt]}\n" if options[opt] +499: end +500: out << " glob: #{@glob}\n" unless @glob == DEFAULT_GLOB +501: out << " specs:\n" +502: end
- # File lib/bundler/source.rb, line 502 -502: def to_s -503: sref = options["ref"] ? shortref_for_display(options["ref"]) : ref -504: "#{uri} (at #{sref})" -505: end+ # File lib/bundler/source.rb, line 515 +515: def to_s +516: sref = options["ref"] ? shortref_for_display(options["ref"]) : ref +517: "#{uri} (at #{sref})" +518: end
- # File lib/bundler/source.rb, line 523 -523: def unlock! -524: @revision = nil -525: end+ # File lib/bundler/source.rb, line 536 +536: def unlock! +537: @revision = nil +538: end
- # File lib/bundler/source.rb, line 647 -647: def allow_git_ops? -648: @allow_remote || @allow_cached -649: end+ # File lib/bundler/source.rb, line 676 +676: def allow_git_ops? +677: @allow_remote || @allow_cached +678: end
- # File lib/bundler/source.rb, line 572 -572: def base_name -573: File.basename(uri.sub(%{^(\w+://)?([^/:]+:)},''), ".git") -574: end+ # File lib/bundler/source.rb, line 587 +587: def base_name +588: File.basename(uri.sub(%{^(\w+://)?([^/:]+:)},''), ".git") +589: end
- # File lib/bundler/source.rb, line 608 -608: def cache -609: if cached? -610: return if has_revision_cached? -611: Bundler.ui.info "Updating #{uri}" -612: in_cache do -613: git %fetch --force --quiet --tags "#{uri}" refs/heads/*:refs/heads/*| -614: end -615: else -616: Bundler.ui.info "Fetching #{uri}" -617: FileUtils.mkdir_p(cache_path.dirname) -618: git %clone "#{uri}" "#{cache_path}" --bare --no-hardlinks| -619: end -620: end+ # File lib/bundler/source.rb, line 636 +636: def cache +637: if cached? +638: return if has_revision_cached? +639: Bundler.ui.info "Updating #{uri}" +640: in_cache do +641: git %fetch --force --quiet --tags #{uri_escaped} "refs/heads/*:refs/heads/*"| +642: end +643: else +644: Bundler.ui.info "Fetching #{uri}" +645: FileUtils.mkdir_p(cache_path.dirname) +646: git %clone #{uri_escaped} "#{cache_path}" --bare --no-hardlinks| +647: end +648: end
- # File lib/bundler/source.rb, line 596 -596: def cache_path -597: @cache_path ||= begin -598: git_scope = "#{base_name}-#{uri_hash}" -599: -600: if Bundler.requires_sudo? -601: Bundler.user_bundle_path.join("cache/git", git_scope) -602: else -603: Bundler.cache.join("git", git_scope) -604: end -605: end -606: end+ # File lib/bundler/source.rb, line 624 +624: def cache_path +625: @cache_path ||= begin +626: git_scope = "#{base_name}-#{uri_hash}" +627: +628: if Bundler.requires_sudo? +629: Bundler.user_bundle_path.join("cache/git", git_scope) +630: else +631: Bundler.cache.join("git", git_scope) +632: end +633: end +634: end
- # File lib/bundler/source.rb, line 661 -661: def cached? -662: cache_path.exist? -663: end+ # File lib/bundler/source.rb, line 690 +690: def cached? +691: cache_path.exist? +692: end
- # File lib/bundler/source.rb, line 622 -622: def checkout -623: unless File.exist?(path.join(".git")) -624: FileUtils.mkdir_p(path.dirname) -625: FileUtils.rm_rf(path) -626: git %clone --no-checkout "#{cache_path}" "#{path}"| -627: end -628: Dir.chdir(path) do -629: git %fetch --force --quiet --tags "#{cache_path}"| -630: git "reset --hard #{revision}" -631: -632: if @submodules -633: git "submodule init" -634: git "submodule update" -635: end -636: end -637: end+ # File lib/bundler/source.rb, line 650 +650: def checkout +651: unless File.exist?(path.join(".git")) +652: FileUtils.mkdir_p(path.dirname) +653: FileUtils.rm_rf(path) +654: git %clone --no-checkout "#{cache_path}" "#{path}"| +655: File.chmod((0777 & ~File.umask), path) +656: end +657: Dir.chdir(path) do +658: git %fetch --force --quiet --tags "#{cache_path}"| +659: git "reset --hard #{revision}" +660: +661: if @submodules +662: git "submodule init" +663: git "submodule update" +664: end +665: end +666: end
- # File lib/bundler/source.rb, line 557 -557: def git(command) -558: if allow_git_ops? -559: out = %{git #{command}} -560: -561: if $? != 0 -562: raise GitError, "An error has occurred in git when running `git #{command}`. Cannot complete bundling." -563: end -564: out -565: else -566: 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")}" -567: end -568: end+ # File lib/bundler/source.rb, line 570 +570: def git(command) +571: if allow_git_ops? +572: out = %{git #{command}} +573: +574: if $?.exitstatus != 0 +575: msg = "Git error: command `git #{command}` in directory #{Dir.pwd} has failed." +576: msg << "\nIf this error persists you could try removing the cache directory '#{cache_path}'" if cached? +577: raise GitError, msg +578: end +579: out +580: else +581: 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")}" +582: end +583: end
- # File lib/bundler/source.rb, line 639 -639: def has_revision_cached? -640: return unless @revision -641: in_cache { git %cat-file -e #{@revision}| } -642: true -643: rescue GitError -644: false -645: end+ # File lib/bundler/source.rb, line 668 +668: def has_revision_cached? +669: return unless @revision +670: in_cache { git %cat-file -e #{@revision}| } +671: true +672: rescue GitError +673: false +674: end
- # File lib/bundler/source.rb, line 665 -665: def in_cache(&blk) -666: cache unless cached? -667: Dir.chdir(cache_path, &blk) -668: end+ # File lib/bundler/source.rb, line 694 +694: def in_cache(&blk) +695: cache unless cached? +696: Dir.chdir(cache_path, &blk) +697: end
- # File lib/bundler/source.rb, line 651 -651: def revision -652: @revision ||= begin -653: if allow_git_ops? -654: in_cache { git("rev-parse #{ref}").strip } -655: else -656: raise GitError, "The git source #{uri} is not yet checked out. Please run `bundle install` before trying to start your application" -657: end -658: end -659: end+ # File lib/bundler/source.rb, line 680 +680: def revision +681: @revision ||= begin +682: if allow_git_ops? +683: in_cache { git("rev-parse #{ref}").strip } +684: else +685: raise GitError, "The git source #{uri} is not yet checked out. Please run `bundle install` before trying to start your application" +686: end +687: end +688: end
- # File lib/bundler/source.rb, line 576 -576: def shortref_for_display(ref) -577: ref[0..6] -578: end+ # File lib/bundler/source.rb, line 591 +591: def shortref_for_display(ref) +592: ref[0..6] +593: end
- # File lib/bundler/source.rb, line 580 -580: def shortref_for_path(ref) -581: ref[0..11] -582: end+ # File lib/bundler/source.rb, line 595 +595: def shortref_for_path(ref) +596: ref[0..11] +597: end +
+Escape the URI for git commands +
+ + + ++ # File lib/bundler/source.rb, line 612 +612: def uri_escaped +613: if Bundler::WINDOWS +614: # Windows quoting requires double quotes only, with double quotes +615: # inside the string escaped by being doubled. +616: '"' + uri.gsub('"') {|s| '""'} + '"' +617: else +618: # Bash requires single quoted strings, with the single quotes escaped +619: # by ending the string, escaping the quote, and restarting the string. +620: "'" + uri.gsub("'") {|s| "'\\''"} + "'" +621: end +622: end
- # File lib/bundler/source.rb, line 584 -584: def uri_hash -585: if uri =~ %{^\w+://(\w+@)?} -586: # Downcase the domain component of the URI -587: # and strip off a trailing slash, if one is present -588: input = URI.parse(uri).normalize.to_s.sub(%{/$},'') -589: else -590: # If there is no URI scheme, assume it is an ssh/git URI -591: input = uri -592: end -593: Digest::SHA1.hexdigest(input) -594: end+ # File lib/bundler/source.rb, line 599 +599: def uri_hash +600: if uri =~ %{^\w+://(\w+@)?} +601: # Downcase the domain component of the URI +602: # and strip off a trailing slash, if one is present +603: input = URI.parse(uri).normalize.to_s.sub(%{/$},'') +604: else +605: # If there is no URI scheme, assume it is an ssh/git URI +606: input = uri +607: end +608: Digest::SHA1.hexdigest(input) +609: end
- # File lib/bundler/source.rb, line 297 -297: def self.from_lock(options) -298: new(options.merge("path" => options.delete("remote"))) -299: end+ # File lib/bundler/source.rb, line 309 +309: def self.from_lock(options) +310: new(options.merge("path" => options.delete("remote"))) +311: end
- # File lib/bundler/source.rb, line 273 -273: def initialize(options) -274: @options = options -275: @glob = options["glob"] || DEFAULT_GLOB -276: -277: @allow_cached = false -278: @allow_remote = false -279: -280: if options["path"] -281: @path = Pathname.new(options["path"]) -282: @path = @path.expand_path(Bundler.root) unless @path.relative? -283: end -284: -285: @name = options["name"] -286: @version = options["version"] -287: end+ # File lib/bundler/source.rb, line 285 +285: def initialize(options) +286: @options = options +287: @glob = options["glob"] || DEFAULT_GLOB +288: +289: @allow_cached = false +290: @allow_remote = false +291: +292: if options["path"] +293: @path = Pathname.new(options["path"]) +294: @path = @path.expand_path(Bundler.root) unless @path.relative? +295: end +296: +297: @name = options["name"] +298: @version = options["version"] +299: end
- # File lib/bundler/source.rb, line 407 -407: def cache(spec) -408: unless path.expand_path(Bundler.root).to_s.index(Bundler.root.to_s) == 0 -409: Bundler.ui.warn " * #{spec.name} at `#{path}` will not be cached." -410: end -411: end+ # File lib/bundler/source.rb, line 420 +420: def cache(spec) +421: unless path.expand_path(Bundler.root).to_s.index(Bundler.root.to_s) == 0 +422: Bundler.ui.warn " * #{spec.name} at `#{path}` will not be cached." +423: end +424: end
- # File lib/bundler/source.rb, line 293 -293: def cached! -294: @allow_cached = true -295: end+ # File lib/bundler/source.rb, line 305 +305: def cached! +306: @allow_cached = true +307: end
- # File lib/bundler/source.rb, line 316 -316: def eql?(o) -317: o.instance_of?(Path) && -318: path.expand_path(Bundler.root) == o.path.expand_path(Bundler.root) && -319: name == o.name && -320: version == o.version -321: end+ # File lib/bundler/source.rb, line 328 +328: def eql?(o) +329: o.instance_of?(Path) && +330: path.expand_path(Bundler.root) == o.path.expand_path(Bundler.root) && +331: version == o.version +332: end
- # File lib/bundler/source.rb, line 312 -312: def hash -313: self.class.hash -314: end+ # File lib/bundler/source.rb, line 324 +324: def hash +325: self.class.hash +326: end
- # File lib/bundler/source.rb, line 395 -395: def install(spec) -396: Bundler.ui.info "Using #{spec.name} (#{spec.version}) from #{to_s} " -397: # Let's be honest, when we're working from a path, we can't -398: # really expect native extensions to work because the whole point -399: # is to just be able to modify what's in that path and go. So, let's -400: # not put ourselves through the pain of actually trying to generate -401: # the full gem. -402: Installer.new(spec).generate_bin -403: end+ # File lib/bundler/source.rb, line 408 +408: def install(spec) +409: Bundler.ui.info "Using #{spec.name} (#{spec.version}) from #{to_s} " +410: # Let's be honest, when we're working from a path, we can't +411: # really expect native extensions to work because the whole point +412: # is to just be able to modify what's in that path and go. So, let's +413: # not put ourselves through the pain of actually trying to generate +414: # the full gem. +415: Installer.new(spec).generate_bin +416: end
- # File lib/bundler/source.rb, line 329 -329: def load_spec_files -330: index = Index.new -331: -332: expanded_path = path.expand_path(Bundler.root) -333: -334: if File.directory?(expanded_path) -335: Dir["#{expanded_path}/#{@glob}"].each do |file| -336: spec = Bundler.load_gemspec(file) -337: if spec -338: spec.loaded_from = file.to_s -339: spec.source = self -340: index << spec -341: end -342: end -343: -344: if index.empty? && @name && @version -345: index << Gem::Specification.new do |s| -346: s.name = @name -347: s.source = self -348: s.version = Gem::Version.new(@version) -349: s.platform = Gem::Platform::RUBY -350: s.summary = "Fake gemspec for #{@name}" -351: s.relative_loaded_from = "#{@name}.gemspec" -352: if expanded_path.join("bin").exist? -353: binaries = expanded_path.join("bin").children.map{|c| c.basename.to_s } -354: s.executables = binaries -355: end -356: end -357: end -358: else -359: raise PathError, "The path `#{expanded_path}` does not exist." -360: end -361: -362: index -363: end+ # File lib/bundler/source.rb, line 340 +340: def load_spec_files +341: index = Index.new +342: +343: expanded_path = path.expand_path(Bundler.root) +344: +345: if File.directory?(expanded_path) +346: Dir["#{expanded_path}/#{@glob}"].each do |file| +347: spec = Bundler.load_gemspec(file) +348: if spec +349: spec.loaded_from = file.to_s +350: spec.source = self +351: index << spec +352: end +353: end +354: +355: if index.empty? && @name && @version +356: index << Gem::Specification.new do |s| +357: s.name = @name +358: s.source = self +359: s.version = Gem::Version.new(@version) +360: s.platform = Gem::Platform::RUBY +361: s.summary = "Fake gemspec for #{@name}" +362: s.relative_loaded_from = "#{@name}.gemspec" +363: s.authors = ["no one"] +364: if expanded_path.join("bin").exist? +365: binaries = expanded_path.join("bin").children +366: binaries.reject!{|p| File.directory?(p) } +367: s.executables = binaries.map{|c| c.basename.to_s } +368: end +369: end +370: end +371: else +372: raise PathError, "The path `#{expanded_path}` does not exist." +373: end +374: +375: index +376: end
- # File lib/bundler/source.rb, line 365 -365: def local_specs -366: @local_specs ||= load_spec_files -367: end+ # File lib/bundler/source.rb, line 378 +378: def local_specs +379: @local_specs ||= load_spec_files +380: end
- # File lib/bundler/source.rb, line 325 -325: def name -326: File.basename(@path.to_s) -327: end+ # File lib/bundler/source.rb, line 336 +336: def name +337: File.basename(path.expand_path(Bundler.root).to_s) +338: end
- # File lib/bundler/source.rb, line 289 -289: def remote! -290: @allow_remote = true -291: end+ # File lib/bundler/source.rb, line 301 +301: def remote! +302: @allow_remote = true +303: end
- # File lib/bundler/source.rb, line 301 -301: def to_lock -302: out = "PATH\n" -303: out << " remote: #{relative_path}\n" -304: out << " glob: #{@glob}\n" unless @glob == DEFAULT_GLOB -305: out << " specs:\n" -306: end+ # File lib/bundler/source.rb, line 313 +313: def to_lock +314: out = "PATH\n" +315: out << " remote: #{relative_path}\n" +316: out << " glob: #{@glob}\n" unless @glob == DEFAULT_GLOB +317: out << " specs:\n" +318: end
- # File lib/bundler/source.rb, line 308 -308: def to_s -309: "source at #{@path}" -310: end+ # File lib/bundler/source.rb, line 320 +320: def to_s +321: "source at #{@path}" +322: end
- # File lib/bundler/source.rb, line 423 -423: def generate_bin(spec) -424: gem_dir = Pathname.new(spec.full_gem_path) -425: -426: # Some gem authors put absolute paths in their gemspec -427: # and we have to save them from themselves -428: spec.files = spec.files.map do |p| -429: next if File.directory?(p) -430: begin -431: Pathname.new(p).relative_path_from(gem_dir).to_s -432: rescue ArgumentError -433: p -434: end -435: end.compact -436: -437: gem_file = Dir.chdir(gem_dir){ Gem::Builder.new(spec).build } + # File lib/bundler/source.rb, line 436 +436: def generate_bin(spec) +437: gem_dir = Pathname.new(spec.full_gem_path) 438: -439: installer = Installer.new(spec, :env_shebang => false) -440: installer.build_extensions -441: installer.generate_bin -442: rescue Gem::InvalidSpecificationException => e -443: Bundler.ui.warn "\n#{spec.name} at #{spec.full_gem_path} did not have a valid gemspec.\n" "This prevents bundler from installing bins or native extensions, but " "that may not affect its functionality." -444: -445: if !spec.extensions.empty? && !spec.email.empty? -446: Bundler.ui.warn "If you need to use this package without installing it from a gem " "repository, please contact #{spec.email} and ask them " "to modify their .gemspec so it can work with `gem build`." -447: end -448: -449: Bundler.ui.warn "The validation message from Rubygems was:\n #{e.message}" -450: ensure -451: Dir.chdir(gem_dir){ FileUtils.rm_rf(gem_file) if gem_file && File.exist?(gem_file) } -452: end+439: # Some gem authors put absolute paths in their gemspec +440: # and we have to save them from themselves +441: spec.files = spec.files.map do |p| +442: next if File.directory?(p) +443: begin +444: Pathname.new(p).relative_path_from(gem_dir).to_s +445: rescue ArgumentError +446: p +447: end +448: end.compact +449: +450: gem_file = Dir.chdir(gem_dir){ Gem::Builder.new(spec).build } +451: +452: installer = Installer.new(spec, :env_shebang => false) +453: installer.build_extensions +454: installer.generate_bin +455: rescue Gem::InvalidSpecificationException => e +456: Bundler.ui.warn "\n#{spec.name} at #{spec.full_gem_path} did not have a valid gemspec.\n" "This prevents bundler from installing bins or native extensions, but " "that may not affect its functionality." +457: +458: if !spec.extensions.empty? && !spec.email.empty? +459: Bundler.ui.warn "If you need to use this package without installing it from a gem " "repository, please contact #{spec.email} and ask them " "to modify their .gemspec so it can work with `gem build`." +460: end +461: +462: Bundler.ui.warn "The validation message from Rubygems was:\n #{e.message}" +463: ensure +464: Dir.chdir(gem_dir){ FileUtils.rm_rf(gem_file) if gem_file && File.exist?(gem_file) } +465: end
- # File lib/bundler/source.rb, line 415 -415: def relative_path -416: if path.to_s.include?(Bundler.root.to_s) -417: return path.relative_path_from(Bundler.root) -418: end -419: -420: path -421: end+ # File lib/bundler/source.rb, line 428 +428: def relative_path +429: if path.to_s.include?(Bundler.root.to_s) +430: return path.relative_path_from(Bundler.root) +431: end +432: +433: path +434: end
- # File lib/bundler/source.rb, line 370 -370: def initialize(spec, options = {}) -371: @spec = spec -372: @bin_dir = Bundler.requires_sudo? ? "#{Bundler.tmp}/bin" : "#{Gem.dir}/bin" -373: @gem_dir = spec.full_gem_path -374: @wrappers = options[:wrappers] || true -375: @env_shebang = options[:env_shebang] || true -376: @format_executable = options[:format_executable] || false -377: end+ # File lib/bundler/source.rb, line 383 +383: def initialize(spec, options = {}) +384: @spec = spec +385: @bin_dir = Bundler.requires_sudo? ? "#{Bundler.tmp}/bin" : "#{Bundler.rubygems.gem_dir}/bin" +386: @gem_dir = Bundler.rubygems.path(spec.full_gem_path) +387: @wrappers = options[:wrappers] || true +388: @env_shebang = options[:env_shebang] || true +389: @format_executable = options[:format_executable] || false +390: end
- # File lib/bundler/source.rb, line 379 -379: def generate_bin -380: return if spec.executables.nil? || spec.executables.empty? -381: -382: if Bundler.requires_sudo? -383: FileUtils.mkdir_p("#{Bundler.tmp}/bin") unless File.exist?("#{Bundler.tmp}/bin") -384: end -385: super -386: if Bundler.requires_sudo? -387: Bundler.mkdir_p "#{Gem.dir}/bin" -388: spec.executables.each do |exe| -389: Bundler.sudo "cp -R #{Bundler.tmp}/bin/#{exe} #{Gem.dir}/bin/" -390: end -391: end -392: end+ # File lib/bundler/source.rb, line 392 +392: def generate_bin +393: return if spec.executables.nil? || spec.executables.empty? +394: +395: if Bundler.requires_sudo? +396: FileUtils.mkdir_p("#{Bundler.tmp}/bin") unless File.exist?("#{Bundler.tmp}/bin") +397: end +398: super +399: if Bundler.requires_sudo? +400: Bundler.mkdir_p "#{Bundler.rubygems.gem_dir}/bin" +401: spec.executables.each do |exe| +402: Bundler.sudo "cp -R #{Bundler.tmp}/bin/#{exe} #{Bundler.rubygems.gem_dir}/bin/" +403: end +404: end +405: end
- # File lib/bundler/source.rb, line 46 -46: def self.from_lock(options) -47: s = new(options) -48: Array(options["remote"]).each { |r| s.add_remote(r) } -49: s -50: end+ # File lib/bundler/source.rb, line 51 +51: def self.from_lock(options) +52: s = new(options) +53: Array(options["remote"]).each { |r| s.add_remote(r) } +54: s +55: 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 15 +15: def initialize(options = {}) +16: @options = options +17: @remotes = (options["remotes"] || []).map { |r| normalize_uri(r) } +18: @allow_remote = false +19: @allow_cached = false +20: +21: # Hardcode the paths for now +22: @caches = [ Bundler.app_cache ] + Bundler.rubygems.gem_path.map do |x| +23: File.expand_path("#{x}/cache") +24: end +25: +26: @spec_fetch_map = {} +27: end
- # File lib/bundler/source.rb, line 123 -123: def add_remote(source) -124: @remotes << normalize_uri(source) -125: end+ # File lib/bundler/source.rb, line 130 +130: def add_remote(source) +131: @remotes << normalize_uri(source) +132: end
- # File lib/bundler/source.rb, line 115 -115: def cache(spec) -116: cached_path = cached_gem(spec) -117: raise GemNotFound, "Missing gem file '#{spec.full_name}.gem'." unless cached_path -118: return if File.dirname(cached_path) == Bundler.app_cache.to_s -119: Bundler.ui.info " * #{File.basename(cached_path)}" -120: FileUtils.cp(cached_path, Bundler.app_cache) -121: end+ # File lib/bundler/source.rb, line 122 +122: def cache(spec) +123: cached_path = cached_gem(spec) +124: raise GemNotFound, "Missing gem file '#{spec.full_name}.gem'." unless cached_path +125: return if File.dirname(cached_path) == Bundler.app_cache.to_s +126: Bundler.ui.info " * #{File.basename(cached_path)}" +127: FileUtils.cp(cached_path, Bundler.app_cache) +128: end
- # File lib/bundler/source.rb, line 28 -28: def cached! -29: @allow_cached = true -30: end+ # File lib/bundler/source.rb, line 33 +33: def cached! +34: @allow_cached = true +35: end
- # File lib/bundler/source.rb, line 36 -36: def eql?(o) -37: Rubygems === o -38: end+ # File lib/bundler/source.rb, line 41 +41: def eql?(o) +42: Rubygems === o +43: end
- # File lib/bundler/source.rb, line 68 -68: def fetch(spec) -69: spec, uri = @spec_fetch_map[spec.full_name] -70: if spec -71: path = download_gem_from_uri(spec, uri) -72: s = Gem::Format.from_file_by_path(path).spec -73: spec.__swap__(s) -74: end -75: 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 = Bundler.rubygems.spec_from_gem(path) +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 37 +37: def hash +38: Rubygems.hash +39: end
- # File lib/bundler/source.rb, line 77 - 77: def install(spec) - 78: path = cached_gem(spec) - 79: - 80: if installed_specs[spec].any? - 81: Bundler.ui.info "Using #{spec.name} (#{spec.version}) " - 82: return - 83: end - 84: - 85: Bundler.ui.info "Installing #{spec.name} (#{spec.version}) " - 86: - 87: install_path = Bundler.requires_sudo? ? Bundler.tmp : Gem.dir - 88: options = { :install_dir => install_path, - 89: :ignore_dependencies => true, - 90: :wrappers => true, - 91: :env_shebang => true } - 92: options.merge!(:bin_dir => "#{install_path}/bin") unless spec.executables.nil? || spec.executables.empty? - 93: - 94: installer = Gem::Installer.new path, options - 95: installer.install - 96: - 97: # SUDO HAX - 98: if Bundler.requires_sudo? - 99: sudo "mkdir -p #{Gem.dir}/gems #{Gem.dir}/specifications" -100: sudo "cp -R #{Bundler.tmp}/gems/#{spec.full_name} #{Gem.dir}/gems/" -101: sudo "cp -R #{Bundler.tmp}/specifications/#{spec.full_name}.gemspec #{Gem.dir}/specifications/" -102: spec.executables.each do |exe| -103: sudo "mkdir -p #{Gem.bindir}" -104: sudo "cp -R #{Bundler.tmp}/bin/#{exe} #{Gem.bindir}" -105: end -106: end -107: -108: spec.loaded_from = "#{Gem.dir}/specifications/#{spec.full_name}.gemspec" -109: end+ # File lib/bundler/source.rb, line 82 + 82: def install(spec) + 83: if installed_specs[spec].any? + 84: Bundler.ui.info "Using #{spec.name} (#{spec.version}) " + 85: return + 86: end + 87: + 88: Bundler.ui.info "Installing #{spec.name} (#{spec.version}) " + 89: path = cached_gem(spec) + 90: + 91: Bundler.rubygems.preserve_paths do + 92: + 93: install_path = Bundler.requires_sudo? ? Bundler.tmp : Bundler.rubygems.gem_dir + 94: options = { :install_dir => install_path, + 95: :ignore_dependencies => true, + 96: :wrappers => true, + 97: :env_shebang => true } + 98: options.merge!(:bin_dir => "#{install_path}/bin") unless spec.executables.nil? || spec.executables.empty? + 99: +100: installer = Gem::Installer.new path, options +101: installer.install +102: end +103: +104: # SUDO HAX +105: if Bundler.requires_sudo? +106: sudo "mkdir -p #{Bundler.rubygems.gem_dir}/gems #{Bundler.rubygems.gem_dir}/specifications" +107: sudo "cp -R #{Bundler.tmp}/gems/#{spec.full_name} #{Bundler.rubygems.gem_dir}/gems/" +108: sudo "cp -R #{Bundler.tmp}/specifications/#{spec.full_name}.gemspec #{Bundler.rubygems.gem_dir}/specifications/" +109: spec.executables.each do |exe| +110: sudo "mkdir -p #{Bundler.rubygems.gem_bindir}" +111: sudo "cp -R #{Bundler.tmp}/bin/#{exe} #{Bundler.rubygems.gem_bindir}" +112: end +113: end +114: +115: spec.loaded_from = "#{Bundler.rubygems.gem_dir}/specifications/#{spec.full_name}.gemspec" +116: end
- # File lib/bundler/source.rb, line 127 -127: def merge_remotes(source) -128: @remotes = [] -129: source.remotes.each do |r| -130: add_remote r.to_s -131: end -132: end+ # File lib/bundler/source.rb, line 134 +134: def merge_remotes(source) +135: @remotes = [] +136: source.remotes.each do |r| +137: add_remote r.to_s +138: end +139: end
- # File lib/bundler/source.rb, line 42 -42: def options -43: { "remotes" => @remotes.map { |r| r.to_s } } -44: end+ # File lib/bundler/source.rb, line 47 +47: def options +48: { "remotes" => @remotes.map { |r| r.to_s } } +49: end
- # File lib/bundler/source.rb, line 24 -24: def remote! -25: @allow_remote = true -26: end+ # File lib/bundler/source.rb, line 29 +29: def remote! +30: @allow_remote = true +31: end
- # File lib/bundler/source.rb, line 64 -64: def specs -65: @specs ||= fetch_specs -66: end+ # File lib/bundler/source.rb, line 69 +69: def specs +70: @specs ||= fetch_specs +71: end
- # File lib/bundler/source.rb, line 111 -111: def sudo(str) -112: Bundler.sudo(str) -113: end+ # File lib/bundler/source.rb, line 118 +118: def sudo(str) +119: Bundler.sudo(str) +120: end
- # File lib/bundler/source.rb, line 52 -52: def to_lock -53: out = "GEM\n" -54: out << remotes.map {|r| " remote: #{r}\n" }.join -55: out << " specs:\n" -56: end+ # File lib/bundler/source.rb, line 57 +57: def to_lock +58: out = "GEM\n" +59: out << remotes.map {|r| " remote: #{r}\n" }.join +60: out << " specs:\n" +61: end
- # File lib/bundler/source.rb, line 58 -58: def to_s -59: remote_names = self.remotes.map { |r| r.to_s }.join(', ') -60: "rubygems repository #{remote_names}" -61: end+ # File lib/bundler/source.rb, line 63 +63: def to_s +64: remote_names = self.remotes.map { |r| r.to_s }.join(', ') +65: "rubygems repository #{remote_names}" +66: end
- # File lib/bundler/source.rb, line 136 -136: def cached_gem(spec) -137: possibilities = @caches.map { |p| "#{p}/#{spec.full_name}.gem" } -138: possibilities.find { |p| File.exist?(p) } -139: end+ # File lib/bundler/source.rb, line 143 +143: def cached_gem(spec) +144: possibilities = @caches.map { |p| "#{p}/#{spec.file_name}" } +145: cached_gem = possibilities.find { |p| File.exist?(p) } +146: unless cached_gem +147: raise Bundler::GemNotFound, "Could not find #{spec.file_name} for installation" +148: end +149: cached_gem +150: end
- # File lib/bundler/source.rb, line 186 -186: def cached_specs -187: @cached_specs ||= begin -188: idx = installed_specs.dup -189: -190: path = Bundler.app_cache -191: Dir["#{path}/*.gem"].each do |gemfile| -192: next if gemfile =~ /bundler\-[\d\.]+?\.gem/ -193: -194: begin -195: s ||= Gem::Format.from_file_by_path(gemfile).spec -196: rescue Gem::Package::FormatError -197: raise GemspecError, "Could not read gem at #{gemfile}. It may be corrupted." -198: end -199: -200: s.source = self -201: idx << s -202: end -203: end -204: -205: idx -206: end+ # File lib/bundler/source.rb, line 198 +198: def cached_specs +199: @cached_specs ||= begin +200: idx = installed_specs.dup +201: +202: path = Bundler.app_cache +203: Dir["#{path}/*.gem"].each do |gemfile| +204: next if gemfile =~ /^bundler\-[\d\.]+?\.gem/ +205: +206: begin +207: s ||= Bundler.rubygems.spec_from_gem(gemfile) +208: rescue Gem::Package::FormatError +209: raise GemspecError, "Could not read gem at #{gemfile}. It may be corrupted." +210: end +211: +212: s.source = self +213: idx << s +214: end +215: end +216: +217: idx +218: end
- # File lib/bundler/source.rb, line 247 -247: def download_gem_from_uri(spec, uri) -248: spec.fetch_platform -249: -250: download_path = Bundler.requires_sudo? ? Bundler.tmp : Gem.dir -251: gem_path = "#{Gem.dir}/cache/#{spec.full_name}.gem" -252: -253: FileUtils.mkdir_p("#{download_path}/cache") -254: Gem::RemoteFetcher.fetcher.download(spec, uri, download_path) -255: -256: if Bundler.requires_sudo? -257: sudo "mkdir -p #{Gem.dir}/cache" -258: sudo "mv #{Bundler.tmp}/cache/#{spec.full_name}.gem #{gem_path}" -259: end -260: -261: gem_path -262: end+ # File lib/bundler/source.rb, line 259 +259: def download_gem_from_uri(spec, uri) +260: spec.fetch_platform +261: +262: download_path = Bundler.requires_sudo? ? Bundler.tmp : Bundler.rubygems.gem_dir +263: gem_path = "#{Bundler.rubygems.gem_dir}/cache/#{spec.full_name}.gem" +264: +265: FileUtils.mkdir_p("#{download_path}/cache") +266: Bundler.rubygems.download_gem(spec, uri, download_path) +267: +268: if Bundler.requires_sudo? +269: sudo "mkdir -p #{Bundler.rubygems.gem_dir}/cache" +270: sudo "mv #{Bundler.tmp}/cache/#{spec.full_name}.gem #{gem_path}" +271: end +272: +273: gem_path +274: end
- # File lib/bundler/source.rb, line 232 -232: def fetch_all_remote_specs(&blk) -233: begin -234: # Fetch all specs, minus prerelease specs -235: Gem::SpecFetcher.new.list(true, false).each(&blk) -236: # Then fetch the prerelease specs -237: begin -238: Gem::SpecFetcher.new.list(false, true).each(&blk) -239: rescue Gem::RemoteFetcher::FetchError -240: Bundler.ui.warn "Could not fetch prerelease specs from #{self}" -241: end -242: rescue Gem::RemoteFetcher::FetchError -243: Bundler.ui.warn "Could not reach #{self}" -244: end -245: end+ # File lib/bundler/source.rb, line 244 +244: def fetch_all_remote_specs(&blk) +245: begin +246: # Fetch all specs, minus prerelease specs +247: Gem::SpecFetcher.new.list(true, false).each(&blk) +248: # Then fetch the prerelease specs +249: begin +250: Gem::SpecFetcher.new.list(false, true).each(&blk) +251: rescue Gem::RemoteFetcher::FetchError +252: Bundler.ui.warn "Could not fetch prerelease specs from #{self}" +253: end +254: rescue Gem::RemoteFetcher::FetchError +255: Bundler.ui.warn "Could not reach #{self}" +256: end +257: end
- # File lib/bundler/source.rb, line 149 -149: def fetch_specs -150: Index.build do |idx| -151: idx.use installed_specs -152: idx.use cached_specs if @allow_cached || @allow_remote -153: idx.use remote_specs if @allow_remote -154: end -155: end+ # File lib/bundler/source.rb, line 160 +160: def fetch_specs +161: Index.build do |idx| +162: idx.use installed_specs +163: idx.use cached_specs if @allow_cached || @allow_remote +164: idx.use remote_specs if @allow_remote +165: end +166: end
- # File lib/bundler/source.rb, line 157 -157: def installed_specs -158: @installed_specs ||= begin -159: idx = Index.new -160: have_bundler = false -161: Gem.source_index.to_a.reverse.each do |dont_use_this_var, spec| -162: next if spec.name == 'bundler' && spec.version.to_s != VERSION -163: have_bundler = true if spec.name == 'bundler' -164: spec.source = self -165: idx << spec -166: end -167: -168: # Always have bundler locally -169: unless have_bundler -170: # We're running bundler directly from the source -171: # so, let's create a fake gemspec for it (it's a path) -172: # gemspec -173: bundler = Gem::Specification.new do |s| -174: s.name = 'bundler' -175: s.version = VERSION -176: s.platform = Gem::Platform::RUBY -177: s.source = self -178: s.loaded_from = File.expand_path("..", __FILE__) -179: end -180: idx << bundler -181: end -182: idx -183: end -184: end+ # File lib/bundler/source.rb, line 168 +168: def installed_specs +169: @installed_specs ||= begin +170: idx = Index.new +171: have_bundler = false +172: Bundler.rubygems.all_specs.reverse.each do |spec| +173: next if spec.name == 'bundler' && spec.version.to_s != VERSION +174: have_bundler = true if spec.name == 'bundler' +175: spec.source = self +176: idx << spec +177: end +178: +179: # Always have bundler locally +180: unless have_bundler +181: # We're running bundler directly from the source +182: # so, let's create a fake gemspec for it (it's a path) +183: # gemspec +184: bundler = Gem::Specification.new do |s| +185: s.name = 'bundler' +186: s.version = VERSION +187: s.platform = Gem::Platform::RUBY +188: s.source = self +189: s.authors = ["bundler team"] +190: s.loaded_from = File.expand_path("..", __FILE__) +191: end +192: idx << bundler +193: end +194: idx +195: end +196: end
- # File lib/bundler/source.rb, line 141 -141: def normalize_uri(uri) -142: uri = uri.to_s -143: uri = "#{uri}/" unless uri =~ %/$' -144: uri = URI(uri) -145: raise ArgumentError, "The source must be an absolute URI" unless uri.absolute? -146: uri -147: end+ # File lib/bundler/source.rb, line 152 +152: def normalize_uri(uri) +153: uri = uri.to_s +154: uri = "#{uri}/" unless uri =~ %/$' +155: uri = URI(uri) +156: raise ArgumentError, "The source must be an absolute URI" unless uri.absolute? +157: uri +158: end
- # File lib/bundler/source.rb, line 208 -208: def remote_specs -209: @remote_specs ||= begin -210: idx = Index.new -211: old = Gem.sources -212: -213: remotes.each do |uri| -214: Bundler.ui.info "Fetching source index for #{uri}" -215: Gem.sources = ["#{uri}"] -216: fetch_all_remote_specs do |n,v| -217: v.each do |name, version, platform| -218: next if name == 'bundler' -219: spec = RemoteSpecification.new(name, version, platform, uri) -220: spec.source = self -221: @spec_fetch_map[spec.full_name] = [spec, uri] -222: idx << spec -223: end -224: end -225: end -226: idx -227: ensure -228: Gem.sources = old -229: end -230: end+ # File lib/bundler/source.rb, line 220 +220: def remote_specs +221: @remote_specs ||= begin +222: idx = Index.new +223: old = Bundler.rubygems.sources +224: +225: remotes.each do |uri| +226: Bundler.ui.info "Fetching source index for #{uri}" +227: Gem.sources = ["#{uri}"] +228: fetch_all_remote_specs do |n,v| +229: v.each do |name, version, platform| +230: next if name == 'bundler' +231: spec = RemoteSpecification.new(name, version, platform, uri) +232: spec.source = self +233: @spec_fetch_map[spec.full_name] = [spec, uri] +234: idx << spec +235: end +236: end +237: end +238: idx +239: ensure +240: Bundler.rubygems.sources = old +241: end +242: end
- # File lib/bundler/ui.rb, line 15 -15: def confirm(message) -16: end+ # File lib/bundler/ui.rb, line 17 +17: def confirm(message) +18: end
- # File lib/bundler/ui.rb, line 6 -6: def debug(message) -7: end+ # File lib/bundler/ui.rb, line 8 +8: def debug(message) +9: end
- # File lib/bundler/ui.rb, line 9 - 9: def error(message) -10: end+ # File lib/bundler/ui.rb, line 11 +11: def error(message) +12: end
- # File lib/bundler/ui.rb, line 12 -12: def info(message) -13: end+ # File lib/bundler/ui.rb, line 14 +14: def info(message) +15: end
- # File lib/bundler/ui.rb, line 3 -3: def warn(message) -4: end+ # File lib/bundler/ui.rb, line 5 +5: def warn(message) +6: end
Gem::SilentUI
+::Gem::SilentUI
- # File lib/bundler/ui.rb, line 57 -57: def initialize(ui) -58: @ui = ui -59: end+ # File lib/bundler/ui.rb, line 59 +59: def initialize(ui) +60: @ui = ui +61: super() +62: end
- # File lib/bundler/ui.rb, line 61 -61: def say(message) -62: if message =~ /native extensions/ -63: @ui.info "with native extensions " -64: else -65: @ui.debug(message) -66: end -67: end+ # File lib/bundler/ui.rb, line 64 +64: def say(message) +65: if message =~ /native extensions/ +66: @ui.info "with native extensions " +67: else +68: @ui.debug(message) +69: end +70: end
- # File lib/bundler/ui.rb, line 21 -21: def initialize(shell) -22: @shell = shell -23: @quiet = false -24: @debug = ENV['DEBUG'] -25: end+ # File lib/bundler/ui.rb, line 23 +23: def initialize(shell) +24: @shell = shell +25: @quiet = false +26: @debug = ENV['DEBUG'] +27: end
- # File lib/bundler/ui.rb, line 47 -47: def be_quiet! -48: @quiet = true -49: end+ # File lib/bundler/ui.rb, line 49 +49: def be_quiet! +50: @quiet = true +51: end
- # File lib/bundler/ui.rb, line 35 -35: def confirm(msg) -36: @shell.say(msg, :green) if !@quiet -37: end+ # File lib/bundler/ui.rb, line 37 +37: def confirm(msg) +38: @shell.say(msg, :green) if !@quiet +39: end
- # File lib/bundler/ui.rb, line 27 -27: def debug(msg) -28: @shell.say(msg) if @debug && !@quiet -29: end+ # File lib/bundler/ui.rb, line 29 +29: def debug(msg) +30: @shell.say(msg) if @debug && !@quiet +31: end
- # File lib/bundler/ui.rb, line 51 -51: def debug! -52: @debug = true -53: end+ # File lib/bundler/ui.rb, line 53 +53: def debug! +54: @debug = true +55: end
- # File lib/bundler/ui.rb, line 43 -43: def error(msg) -44: @shell.say(msg, :red) -45: end+ # File lib/bundler/ui.rb, line 45 +45: def error(msg) +46: @shell.say(msg, :red) +47: end
- # File lib/bundler/ui.rb, line 31 -31: def info(msg) -32: @shell.say(msg) if !@quiet -33: end+ # File lib/bundler/ui.rb, line 33 +33: def info(msg) +34: @shell.say(msg) if !@quiet +35: end
- # File lib/bundler/ui.rb, line 39 -39: def warn(msg) -40: @shell.say(msg, :yellow) -41: end+ # File lib/bundler/ui.rb, line 41 +41: def warn(msg) +42: @shell.say(msg, :yellow) +43: end
- # File lib/bundler.rb, line 57 -57: def initialize(conflicts, msg = nil) -58: super(msg) -59: @conflicts = conflicts -60: end+ # File lib/bundler.rb, line 64 +64: def initialize(conflicts, msg = nil) +65: super(msg) +66: @conflicts = conflicts +67: end
+ # File lib/bundler/rubygems_ext.rb, line 113 +113: def encode_with(coder) +114: to_yaml_properties.each do |ivar| +115: coder[ivar.to_s.sub(/^@/, '')] = instance_variable_get(ivar) +116: end +117: end+
+Backport of performance enhancement added to Rubygems 1.4 +
- # File lib/bundler/rubygems_ext.rb, line 120 -120: def matches_spec?(spec) -121: # name can be a Regexp, so use === -122: return false unless name === spec.name -123: return true if requirement.none? -124: -125: requirement.satisfied_by?(spec.version) -126: end+ # File lib/bundler/rubygems_ext.rb, line 133 +133: def matches_spec?(spec) +134: # name can be a Regexp, so use === +135: return false unless name === spec.name +136: return true if requirement.none? +137: +138: requirement.satisfied_by?(spec.version) +139: end
- # File lib/bundler/shared_helpers.rb, line 8 - 8: def requirement - 9: version_requirements -10: end+ # File lib/bundler/shared_helpers.rb, line 9 + 9: def requirement +10: version_requirements +11: end
- # File lib/bundler/rubygems_ext.rb, line 112 -112: def to_lock -113: out = " #{name}" -114: unless requirement == Gem::Requirement.default -115: out << " (#{requirement.to_s})" -116: end -117: out -118: end+ # File lib/bundler/rubygems_ext.rb, line 123 +123: def to_lock +124: out = " #{name}" +125: unless requirement == Gem::Requirement.default +126: reqs = requirement.requirements.map{|o,v| "#{o} #{v}" } +127: out << " (#{reqs.join(', ')})" +128: end +129: out +130: end
- # File lib/bundler/rubygems_ext.rb, line 108 -108: def to_yaml_properties -109: instance_variables.reject { |p| ["@source", "@groups"].include?(p.to_s) } -110: end+ # File lib/bundler/rubygems_ext.rb, line 119 +119: def to_yaml_properties +120: instance_variables.reject { |p| ["@source", "@groups"].include?(p.to_s) } +121: end
- # File lib/bundler/rubygems_ext.rb, line 140 -140: def hash -141: @cpu.hash ^ @os.hash ^ @version.hash -142: end+ # File lib/bundler/rubygems_ext.rb, line 154 +154: def hash +155: @cpu.hash ^ @os.hash ^ @version.hash +156: end
+Backport of performance enhancement added to Rubygems 1.4 +
- # File lib/bundler/rubygems_ext.rb, line 130 -130: def none? -131: @none ||= (to_s == ">= 0") -132: end+ # File lib/bundler/rubygems_ext.rb, line 144 +144: def none? +145: @none ||= (to_s == ">= 0") +146: end
- # 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 72 +72: def add_bundler_dependencies(*groups) +73: 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" +74: +75: groups = [:default] if groups.empty? +76: Bundler.definition.dependencies.each do |dep| +77: if dep.groups.include?(:development) +78: self.add_development_dependency(dep.name, dep.requirement.to_s) +79: elsif (dep.groups & groups).any? +80: self.add_dependency(dep.name, dep.requirement.to_s) +81: end +82: end +83: end
+RubyGems 1.8+ used only. +
+ + + ++ # File lib/bundler/rubygems_ext.rb, line 43 +43: def gem_dir +44: full_gem_path +45: 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 51 +51: def git_version +52: if @loaded_from && File.exist?(File.join(full_gem_path, ".git")) +53: sha = Dir.chdir(full_gem_path){ `git rev-parse HEAD`.strip } +54: " #{sha[0..6]}" +55: end +56: end
- # File lib/bundler/rubygems_ext.rb, line 42 -42: def groups -43: @groups ||= [] -44: end+ # File lib/bundler/rubygems_ext.rb, line 47 +47: def groups +48: @groups ||= [] +49: end
- # File lib/bundler/rubygems_ext.rb, line 63 -63: def nondevelopment_dependencies -64: dependencies - development_dependencies -65: end+ # File lib/bundler/rubygems_ext.rb, line 68 +68: def nondevelopment_dependencies +69: dependencies - development_dependencies +70: 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 58 +58: def to_gemfile(path = nil) +59: gemfile = "source :gemcutter\n" +60: gemfile << dependencies_to_gemfile(nondevelopment_dependencies) +61: unless development_dependencies.empty? +62: gemfile << "\n" +63: gemfile << dependencies_to_gemfile(development_dependencies, :development) +64: end +65: gemfile +66: 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+ # File lib/bundler/rubygems_ext.rb, line 90 + 90: def dependencies_to_gemfile(dependencies, group = nil) + 91: gemfile = '' + 92: if dependencies.any? + 93: gemfile << "group :#{group} do\n" if group + 94: dependencies.each do |dependency| + 95: gemfile << ' ' if group + 96: gemfile << %gem "#{dependency.name}"| + 97: req = dependency.requirements_list.first + 98: gemfile << %, "#{req}"| if req + 99: gemfile << "\n" +100: end +101: gemfile << "end\n" if group +102: end +103: gemfile +104: end
This is the API documentation for 'bundler-1.0.7 Documentation'.
+This is the API documentation for 'bundler-1.0.15 Documentation'.
@@ -32,6 +32,10 @@+." generated with Ronn/v0.7.3 ." github.com/rtomayko/ronn/tree/0.7.3 +. .TH “BUNDLE-BENCHMARK” “1” “May 2011” +“” “” . .SH “NAME” fBbundle-benchmarkfR +- Display the time taken for each gem to be loaded . .SH +“SYNOPSIS” fBbundle benchmarkfR [group] . .SH +“DESCRIPTION” This command loads all your required dependencies +as per Bundler.setup, and displays the total time spent in requiring each +gem and its dependencies. . .P Use this command to track down problems with +excessive boot time in your application, or to optimize specific groups in +your Gemfile for fast setup. . .SH “GROUP OPTION” To test the +load times for gems in a specific group, pass the group as an argument to +fBbundle benchmarkfR. Omitting this option loads all dependencies in your +Gemfile. +
+ +Generated with the Darkfish + Rdoc Generator 1.1.6.
++BUNDLE-BENCHMARK(1) +BUNDLE-BENCHMARK(1) +
++NAME +
++ bundle-benchmark - Display the time taken for each gem to be loaded ++
+SYNOPSIS +
++ bundle benchmark [group] ++
+DESCRIPTION +
++ This command loads all your required dependencies as per Bundler.setup, + and displays the total time spent in requiring each gem and its depen- + dencies. + + Use this command to track down problems with excessive boot time in + your application, or to optimize specific groups in your Gemfile for + fast setup. ++
+GROUP OPTION +
++ To test the load times for gems in a specific group, pass the group as + an argument to bundle benchmark. Omitting this option loads all depen- + dencies in your Gemfile. + + May 2011 BUNDLE-BENCHMARK(1)+ +
Generated with the Darkfish + Rdoc Generator 1.1.6.
+." generated with Ronn/v0.7.3 ." github.com/rtomayko/ronn/tree/0.7.3 -. .TH “BUNDLE-EXEC” “1” “November 2010” +. .TH “BUNDLE-EXEC” “1” “January 2011” “” “” . .SH “NAME” fBbundle-execfR - Execute a command in the context of the bundle . .SH “SYNOPSIS” fBbundle execfR fIcommandfR . .SH “DESCRIPTION” This command diff --git a/vendor/plugins/bundler/doc/bundler-1.0.7/rdoc/lib/bundler/man/bundle-exec_txt.html b/vendor/plugins/bundler/doc/bundler-1.0.15/rdoc/lib/bundler/man/bundle-exec_txt.html similarity index 91% rename from vendor/plugins/bundler/doc/bundler-1.0.7/rdoc/lib/bundler/man/bundle-exec_txt.html rename to vendor/plugins/bundler/doc/bundler-1.0.15/rdoc/lib/bundler/man/bundle-exec_txt.html index 50a1b056..22a5f332 100644 --- a/vendor/plugins/bundler/doc/bundler-1.0.7/rdoc/lib/bundler/man/bundle-exec_txt.html +++ b/vendor/plugins/bundler/doc/bundler-1.0.15/rdoc/lib/bundler/man/bundle-exec_txt.html @@ -6,7 +6,7 @@
-." generated with Ronn/v0.7.3 ." github.com/rtomayko/ronn/tree/0.7.3 -. .TH “BUNDLE-INSTALL” “1” “October -2010” “” “” . .SH “NAME” -fBbundle-installfR - Install the dependencies specified in your Gemfile . -.SH “SYNOPSIS” fBbundle installfR [-\-local] [-\-quiet] -[-\-gemfile=GEMFILE] [-\-system] . .IP “” 4 . .nf +. .TH “BUNDLE-INSTALL” “1” “May 2011” +“” “” . .SH “NAME” fBbundle-installfR - +Install the dependencies specified in your Gemfile . .SH +“SYNOPSIS” fBbundle installfR [-\-gemfile=GEMFILE] . .IP +“” 4 . .nf
- [\-\-deployment] [\-\-frozen] [\-\-path] - [\-\-binstubs[=DIRECTORY]] [\-\-without=GROUP1[ GROUP2\.\.\.]] + [\-\-path PATH] [\-\-system] + [\-\-without=GROUP1[ GROUP2\.\.\.]] + [\-\-local] [\-\-deployment] + [\-\-binstubs[=DIRECTORY]] + [\-\-quiet]
. .fi . .IP “” 0 . .SH “DESCRIPTION” Install the
@@ -283,64 +302,69 @@ optionfR. . .TP fB-\-localfR Do not attempt to connect to fBrubygems.orgfR,
instead using just the gems located in fBvendor/cache\fR. Note that if a
more appropriate platform-specific gem exists on fBrubygems.orgfR, this
will bypass the normal lookup. . .TP fB-\-deploymentfR Switches bundler's
-defaults into fIdeployment modefR. . .TP fB-\-binstubs[=
source “rubygems\.org“ diff --git a/vendor/plugins/bundler/doc/bundler-1.0.7/rdoc/lib/bundler/man/bundle-install_txt.html b/vendor/plugins/bundler/doc/bundler-1.0.15/rdoc/lib/bundler/man/bundle-install_txt.html similarity index 84% rename from vendor/plugins/bundler/doc/bundler-1.0.7/rdoc/lib/bundler/man/bundle-install_txt.html rename to vendor/plugins/bundler/doc/bundler-1.0.15/rdoc/lib/bundler/man/bundle-install_txt.html index 6754203c..b32c0ee6 100644 --- a/vendor/plugins/bundler/doc/bundler-1.0.7/rdoc/lib/bundler/man/bundle-install_txt.html +++ b/vendor/plugins/bundler/doc/bundler-1.0.15/rdoc/lib/bundler/man/bundle-install_txt.html @@ -6,7 +6,7 @@
-- bundle install [--local] [--quiet] [--gemfile=GEMFILE] [--system] + bundle install [--gemfile=GEMFILE] - [--deployment] [--frozen] [--path] - [--binstubs[=DIRECTORY]] [--without=GROUP1[ GROUP2...]] + [--path PATH] [--system] + [--without=GROUP1[ GROUP2...]] + [--local] [--deployment] + [--binstubs[=DIRECTORY]] + [--quiet]
DESCRIPTION @@ -312,13 +331,14 @@ OPTIONS bypass the normal lookup. --deployment - Switches bundler's defaults into deployment mode. + Switches bundler's defaults into deployment mode. Do not use + this flag on development machines. --binstubs[=<directory>] - Create a directory (defaults to bin) containing an executable - that runs in the context of the bundle. For instance, if the + Create a directory (defaults to bin) containing an executable + that runs in the context of the bundle. For instance, if the rails gem comes with a rails executable, this flag will create a - bin/rails executable that ensures that all dependencies used + bin/rails executable that ensures that all dependencies used come from the bundled gems.
@@ -326,53 +346,55 @@ DEPLOYMENT MODE
Bundler's defaults are optimized for development. To switch to defaults - optimized for deployment, use the --deployment flag. + optimized for deployment, use the --deployment flag. Do not activate + deployment mode on development machines, as it will cause in an error + when the Gemfile is modified. 1. A Gemfile.lock is required. To ensure that the same versions of the gems you developed with and - tested with are also used in deployments, a Gemfile.lock is + tested with are also used in deployments, a Gemfile.lock is required. - This is mainly to ensure that you remember to check your Gem- + This is mainly to ensure that you remember to check your Gem- file.lock into version control. 2. The Gemfile.lock must be up to date - In development, you can modify your Gemfile(5) and re-run bundle + In development, you can modify your Gemfile(5) and re-run bundle install to conservatively update your Gemfile.lock snapshot. - In deployment, your Gemfile.lock should be up-to-date with changes + In deployment, your Gemfile.lock should be up-to-date with changes made in your Gemfile(5). - 3. Gems are installed to vendor/bundle not your default system loca- + 3. Gems are installed to vendor/bundle not your default system loca- tion - In development, it's convenient to share the gems used in your - application with other applications and other scripts run on the + In development, it's convenient to share the gems used in your + application with other applications and other scripts run on the system. - In deployment, isolation is a more important default. In addition, - the user deploying the application may not have permission to - install gems to the system, or the web server may not have permis- + In deployment, isolation is a more important default. In addition, + the user deploying the application may not have permission to + install gems to the system, or the web server may not have permis- sion to read them. - As a result, bundle install --deployment installs gems to the ven- - dor/bundle directory in the application. This may be overridden + As a result, bundle install --deployment installs gems to the ven- + dor/bundle directory in the application. This may be overridden using the --path option.
SUDO USAGE
- By default, bundler installs gems to the same location as gem install. + By default, bundler installs gems to the same location as gem install. - In some cases, that location may not be writable by your Unix user. In + In some cases, that location may not be writable by your Unix user. In that case, bundler will stage everything in a temporary directory, then - ask you for your sudo password in order to copy the gems into their + ask you for your sudo password in order to copy the gems into their system location. - From your perspective, this is identical to installing them gems + From your perspective, this is identical to installing them gems directly into the system. You should never use sudo bundle install. This is because several other @@ -384,14 +406,15 @@ SUDO USAGE o Checking out private git repositories using your user's SSH keys - Of these three, the first two could theoretically be performed by - chowning the resulting files to $SUDO_USER. The third, however, can - only be performed by actually invoking the git command as the current - user. + Of these three, the first two could theoretically be performed by + chowning the resulting files to $SUDO_USER. The third, however, can + only be performed by actually invoking the git command as the current + user. Therefore, git gems are downloaded and installed into ~/.bundle + rather than $GEM_HOME or $BUNDLE_PATH. As a result, you should run bundle install as the current user, and - bundler will ask for your password if it is needed to perform the final - step. + bundler will ask for your password if it is needed to put the gems into + their final location.
INSTALLING GROUPS @@ -579,7 +602,7 @@ CONSERVATIVE UPDATING other gems in the Gemfile(5) are impacted by the change. If that does not work, run bundle update(1) bundle-update.1.html. - October 2010 BUNDLE-INSTALL(1) + May 2011 BUNDLE-INSTALL(1)
." generated with Ronn/v0.7.3 ." github.com/rtomayko/ronn/tree/0.7.3
-. .TH “BUNDLE” “1” “November 2010”
+. .TH “BUNDLE” “1” “May 2011”
“” “” . .SH “NAME” fBbundlefR - Ruby
Dependency Management . .SH “SYNOPSIS” fBbundlefR COMMAND
[-\-no-color] [-\-verbose] [ARGS] . .SH “DESCRIPTION”
-
- # File lib/bundler/shared_helpers.rb, line 19 -19: def default_gemfile -20: gemfile = find_gemfile -21: raise GemfileNotFound, "Could not locate Gemfile" unless gemfile -22: Pathname.new(gemfile) -23: end-
- # File lib/bundler/shared_helpers.rb, line 55 -55: def clean_load_path -56: # handle 1.9 where system gems are always on the load path -57: if defined?(::Gem) -58: me = File.expand_path("../../", __FILE__) -59: $LOAD_PATH.reject! do |p| -60: next if File.expand_path(p) =~ /^#{me}/ -61: p != File.dirname(__FILE__) && -62: Gem.path.any?{|gp| p =~ /^#{gp}/ } -63: end -64: $LOAD_PATH.uniq! -65: end -66: end-
- # File lib/bundler/shared_helpers.rb, line 80 - 80: def cripple_rubygems(specs) - 81: reverse_rubygems_kernel_mixin - 82: - 83: executables = specs.map { |s| s.executables }.flatten - 84: Gem.source_index # ensure RubyGems is fully loaded - 85: - 86: ::Kernel.send(:define_method, :gem) do |dep, *reqs| - 87: if executables.include? File.basename(caller.first.split(':').first) - 88: return - 89: end - 90: opts = reqs.last.is_a?(Hash) ? reqs.pop : {} - 91: - 92: unless dep.respond_to?(:name) && dep.respond_to?(:requirement) - 93: dep = Gem::Dependency.new(dep, reqs) - 94: end - 95: - 96: spec = specs.find { |s| s.name == dep.name } - 97: - 98: if spec.nil? - 99: e = Gem::LoadError.new "#{dep.name} is not part of the bundle. Add it to Gemfile." -100: e.name = dep.name -101: e.version_requirement = dep.requirement -102: raise e -103: elsif dep !~ spec -104: e = Gem::LoadError.new "can't activate #{dep}, already activated #{spec.full_name}. " "Make sure all dependencies are added to Gemfile." -105: e.name = dep.name -106: e.version_requirement = dep.requirement -107: raise e -108: end -109: -110: true -111: end -112: -113: # === Following hacks are to improve on the generated bin wrappers === -114: -115: # Yeah, talk about a hack -116: source_index_class = (class << Gem::SourceIndex ; self ; end) -117: source_index_class.send(:remove_method, :from_gems_in) -118: source_index_class.send(:define_method, :from_gems_in) do |*args| -119: source_index = Gem::SourceIndex.new -120: source_index.spec_dirs = *args -121: source_index.add_specs(*specs) -122: source_index -123: end -124: -125: # OMG more hacks -126: gem_class = (class << Gem ; self ; end) -127: gem_class.send(:remove_method, :refresh) -128: gem_class.send(:define_method, :refresh) { } -129: gem_class.send(:remove_method, :bin_path) -130: gem_class.send(:define_method, :bin_path) do |name, *args| -131: exec_name, *reqs = args -132: -133: if exec_name == 'bundle' -134: return ENV['BUNDLE_BIN_PATH'] -135: end -136: -137: spec = nil -138: -139: if exec_name -140: spec = specs.find { |s| s.executables.include?(exec_name) } -141: spec or raise Gem::Exception, "can't find executable #{exec_name}" -142: else -143: spec = specs.find { |s| s.name == name } -144: exec_name = spec.default_executable or raise Gem::Exception, "no default executable for #{spec.full_name}" -145: end -146: -147: gem_bin = File.join(spec.full_gem_path, spec.bindir, exec_name) -148: gem_from_path_bin = File.join(File.dirname(spec.loaded_from), spec.bindir, exec_name) -149: File.exist?(gem_bin) ? gem_bin : gem_from_path_bin -150: end -151: -152: Gem.clear_paths -153: end-
- # File lib/bundler/shared_helpers.rb, line 35 -35: def find_gemfile -36: given = ENV['BUNDLE_GEMFILE'] -37: return given if given && !given.empty? -38: -39: previous = nil -40: current = File.expand_path(Dir.pwd) -41: -42: until !File.directory?(current) || current == previous -43: if ENV['BUNDLE_SPEC_RUN'] -44: # avoid stepping above the tmp directory when testing -45: return nil if File.file?(File.join(current, 'bundler.gemspec')) -46: end -47: -48: # otherwise return the Gemfile if it's there -49: filename = File.join(current, 'Gemfile') -50: return filename if File.file?(filename) -51: current, previous = File.expand_path("..", current), current -52: end -53: end-
- # File lib/bundler/shared_helpers.rb, line 68 -68: def reverse_rubygems_kernel_mixin -69: # Disable rubygems' gem activation system -70: ::Kernel.class_eval do -71: if private_method_defined?(:gem_original_require) -72: alias rubygems_require require -73: alias require gem_original_require -74: end -75: -76: undef gem -77: end -78: end-
Disabled; run with --debug to generate this.
- -Generated with the Darkfish - Rdoc Generator 1.1.6.
-html
") + content = instance_variable_get(:"@content_for_testing") + assert content.html_safe? + end + + def test_content_for_should_escape_content + content_for(:testing, "Somehtml
") + content = instance_variable_get(:"@content_for_testing") + expected = %{Some <p>html</p>} + assert_dom_equal expected, content + end + + def test_content_for_should_not_escape_html_safe_content + content_for(:testing, "Somehtml
".html_safe) + content = instance_variable_get(:"@content_for_testing") + expected = %{Somehtml
} + assert_dom_equal expected, content + end + + def test_content_for_should_escape_content_from_block + content_for(:testing){ "Somehtml
" } + content = instance_variable_get(:"@content_for_testing") + expected = %{Some <p>html</p>} + assert_dom_equal expected, content + end + + def test_content_for_should_not_escape_html_safe_content_from_block + content_for(:testing){ "Somehtml
".html_safe } + content = instance_variable_get(:"@content_for_testing") + expected = %{Somehtml
} + assert_dom_equal expected, content + end + +end diff --git a/vendor/plugins/rails_xss/test/date_helper_test.rb b/vendor/plugins/rails_xss/test/date_helper_test.rb new file mode 100644 index 00000000..daf01027 --- /dev/null +++ b/vendor/plugins/rails_xss/test/date_helper_test.rb @@ -0,0 +1,29 @@ +require 'test_helper' + +class DateHelperTest < ActionView::TestCase + silence_warnings do + Post = Struct.new("Post", :id, :written_on, :updated_at) + end + + def test_select_html_safety + assert select_day(16).html_safe? + assert select_month(8).html_safe? + assert select_year(Time.mktime(2003, 8, 16, 8, 4, 18)).html_safe? + assert select_minute(Time.mktime(2003, 8, 16, 8, 4, 18)).html_safe? + assert select_second(Time.mktime(2003, 8, 16, 8, 4, 18)).html_safe? + + assert select_minute(8, :use_hidden => true).html_safe? + assert select_month(8, :prompt => 'Choose month').html_safe? + + assert select_time(Time.mktime(2003, 8, 16, 8, 4, 18), {}, :class => 'selector').html_safe? + assert select_date(Time.mktime(2003, 8, 16), :date_separator => " / ", :start_year => 2003, :end_year => 2005, :prefix => "date[first]").html_safe? + end + + def test_object_select_html_safety + @post = Post.new + @post.written_on = Date.new(2004, 6, 15) + + assert date_select("post", "written_on", :default => Time.local(2006, 9, 19, 15, 16, 35), :include_blank => true).html_safe? + assert time_select("post", "written_on", :ignore_date => true).html_safe? + end +end diff --git a/vendor/plugins/rails_xss/test/deprecated_output_safety_test.rb b/vendor/plugins/rails_xss/test/deprecated_output_safety_test.rb new file mode 100644 index 00000000..e16f7ce0 --- /dev/null +++ b/vendor/plugins/rails_xss/test/deprecated_output_safety_test.rb @@ -0,0 +1,112 @@ +require 'test_helper' + +class DeprecatedOutputSafetyTest < ActiveSupport::TestCase + def setup + @string = "hello" + end + + test "A string can be marked safe using html_safe!" do + assert_deprecated do + @string.html_safe! + assert @string.html_safe? + end + end + + test "Marking a string safe returns the string using html_safe!" do + assert_deprecated do + assert_equal @string, @string.html_safe! + end + end + + test "Adding a safe string to another safe string returns a safe string using html_safe!" do + assert_deprecated do + @other_string = "other".html_safe! + @string.html_safe! + @combination = @other_string + @string + + assert_equal "otherhello", @combination + assert @combination.html_safe? + end + end + + test "Adding an unsafe string to a safe string returns an unsafe string using html_safe!" do + assert_deprecated do + @other_string = "other".html_safe! + @combination = @other_string + "") + assert_equal "<p>", escaped + assert escaped.html_safe? + end + + def test_html_escape_passes_html_escpe_unmodified + escaped = h("
".html_safe) + assert_equal "
", escaped + assert escaped.html_safe? + end + + def test_rest_in_ascii + (0..127).to_a.map {|int| int.chr }.each do |chr| + next if %w(& " < >).include?(chr) + assert_equal chr, html_escape(chr) + end + end +end diff --git a/vendor/plugins/rails_xss/test/form_helper_test.rb b/vendor/plugins/rails_xss/test/form_helper_test.rb new file mode 100644 index 00000000..e5580d26 --- /dev/null +++ b/vendor/plugins/rails_xss/test/form_helper_test.rb @@ -0,0 +1,1447 @@ +require 'test_helper' + +silence_warnings do + Post = Struct.new(:title, :author_name, :body, :secret, :written_on, :cost) + Post.class_eval do + alias_method :title_before_type_cast, :title unless respond_to?(:title_before_type_cast) + alias_method :body_before_type_cast, :body unless respond_to?(:body_before_type_cast) + alias_method :author_name_before_type_cast, :author_name unless respond_to?(:author_name_before_type_cast) + alias_method :secret?, :secret + + def new_record=(boolean) + @new_record = boolean + end + + def new_record? + @new_record + end + + attr_accessor :author + def author_attributes=(attributes); end + + attr_accessor :comments + def comments_attributes=(attributes); end + + attr_accessor :tags + def tags_attributes=(attributes); end + end + + class Comment + attr_reader :id + attr_reader :post_id + def initialize(id = nil, post_id = nil); @id, @post_id = id, post_id end + def save; @id = 1; @post_id = 1 end + def new_record?; @id.nil? end + def to_param; @id; end + def name + @id.nil? ? "new #{self.class.name.downcase}" : "#{self.class.name.downcase} ##{@id}" + end + + attr_accessor :relevances + def relevances_attributes=(attributes); end + + end + + class Tag + attr_reader :id + attr_reader :post_id + def initialize(id = nil, post_id = nil); @id, @post_id = id, post_id end + def save; @id = 1; @post_id = 1 end + def new_record?; @id.nil? end + def to_param; @id; end + def value + @id.nil? ? "new #{self.class.name.downcase}" : "#{self.class.name.downcase} ##{@id}" + end + + attr_accessor :relevances + def relevances_attributes=(attributes); end + + end + + class CommentRelevance + attr_reader :id + attr_reader :comment_id + def initialize(id = nil, comment_id = nil); @id, @comment_id = id, comment_id end + def save; @id = 1; @comment_id = 1 end + def new_record?; @id.nil? end + def to_param; @id; end + def value + @id.nil? ? "new #{self.class.name.downcase}" : "#{self.class.name.downcase} ##{@id}" + end + end + + class TagRelevance + attr_reader :id + attr_reader :tag_id + def initialize(id = nil, tag_id = nil); @id, @tag_id = id, tag_id end + def save; @id = 1; @tag_id = 1 end + def new_record?; @id.nil? end + def to_param; @id; end + def value + @id.nil? ? "new #{self.class.name.downcase}" : "#{self.class.name.downcase} ##{@id}" + end + end + + class Author < Comment + attr_accessor :post + def post_attributes=(attributes); end + end +end + +class FormHelperTest < ActionView::TestCase + tests ActionView::Helpers::FormHelper + + def setup + super + + # Create "label" locale for testing I18n label helpers + I18n.backend.store_translations 'label', { + :helpers => { + :label => { + :post => { + :body => "Write entire text here" + } + } + } + } + + @post = Post.new + @comment = Comment.new + def @post.errors() + Class.new{ + def on(field); "can't be empty" if field == "author_name"; end + def empty?() false end + def count() 1 end + def full_messages() [ "Author name can't be empty" ] end + }.new + end + def @post.id; 123; end + def @post.id_before_type_cast; 123; end + def @post.to_param; '123'; end + + @post.title = "Hello World" + @post.author_name = "" + @post.body = "Back to the hill and over it again!" + @post.secret = 1 + @post.written_on = Date.new(2004, 6, 15) + + def Post.human_attribute_name(attribute) + attribute.to_s == "cost" ? "Total cost" : attribute.to_s.humanize + end + + @controller = Class.new do + attr_reader :url_for_options + def url_for(options) + @url_for_options = options + "http://www.example.com" + end + end + @controller = @controller.new + end + + def test_label + assert_dom_equal('', label("post", "title")) + assert_dom_equal('', label("post", "title", "The title goes here")) + assert_dom_equal( + '', + label("post", "title", nil, :class => 'title_label') + ) + assert_dom_equal('', label("post", "secret?")) + end + + def test_label_with_symbols + assert_dom_equal('', label(:post, :title)) + assert_dom_equal('', label(:post, :secret?)) + end + + def test_label_with_locales_strings + old_locale, I18n.locale = I18n.locale, :label + assert_dom_equal('', label("post", "body")) + ensure + I18n.locale = old_locale + end + + def test_label_with_human_attribute_name + old_locale, I18n.locale = I18n.locale, :label + assert_dom_equal('', label(:post, :cost)) + ensure + I18n.locale = old_locale + end + + def test_label_with_locales_symbols + old_locale, I18n.locale = I18n.locale, :label + assert_dom_equal('', label(:post, :body)) + ensure + I18n.locale = old_locale + end + + def test_label_with_for_attribute_as_symbol + assert_dom_equal('', label(:post, :title, nil, :for => "my_for")) + end + + def test_label_with_for_attribute_as_string + assert_dom_equal('', label(:post, :title, nil, "for" => "my_for")) + end + + def test_label_with_id_attribute_as_symbol + assert_dom_equal('', label(:post, :title, nil, :id => "my_id")) + end + + def test_label_with_id_attribute_as_string + assert_dom_equal('', label(:post, :title, nil, "id" => "my_id")) + end + + def test_label_with_for_and_id_attributes_as_symbol + assert_dom_equal('', label(:post, :title, nil, :for => "my_for", :id => "my_id")) + end + + def test_label_with_for_and_id_attributes_as_string + assert_dom_equal('', label(:post, :title, nil, "for" => "my_for", "id" => "my_id")) + end + + def test_label_for_radio_buttons_with_value + assert_dom_equal('', label("post", "title", "The title goes here", :value => "great_title")) + assert_dom_equal('', label("post", "title", "The title goes here", :value => "great title")) + end + + def test_text_field + assert_dom_equal( + '', text_field("post", "title") + ) + assert_dom_equal( + '', password_field("post", "title") + ) + assert_dom_equal( + '', password_field("person", "name") + ) + end + + def test_text_field_with_escapes + @post.title = "Hello World" + assert_dom_equal( + '', text_field("post", "title") + ) + end + + def test_text_field_with_html_entities + @post.title = "The HTML Entity for & is &" + assert_dom_equal( + '', + text_field("post", "title") + ) + end + + def test_text_field_with_options + expected = '' + assert_dom_equal expected, text_field("post", "title", "size" => 35) + assert_dom_equal expected, text_field("post", "title", :size => 35) + end + + def test_text_field_assuming_size + expected = '' + assert_dom_equal expected, text_field("post", "title", "maxlength" => 35) + assert_dom_equal expected, text_field("post", "title", :maxlength => 35) + end + + def test_text_field_removing_size + expected = '' + assert_dom_equal expected, text_field("post", "title", "maxlength" => 35, "size" => nil) + assert_dom_equal expected, text_field("post", "title", :maxlength => 35, :size => nil) + end + + def test_text_field_doesnt_change_param_values + object_name = 'post[]' + expected = '' + assert_equal expected, text_field(object_name, "title") + assert_equal object_name, "post[]" + end + + def test_hidden_field + assert_dom_equal '', + hidden_field("post", "title") + assert_dom_equal '', + hidden_field("post", "secret?") + end + + def test_hidden_field_with_escapes + @post.title = "Hello World" + assert_dom_equal '', + hidden_field("post", "title") + end + + def test_hidden_field_with_options + assert_dom_equal '', + hidden_field("post", "title", :value => "Something Else") + end + + def test_check_box + assert_dom_equal( + '', + check_box("post", "secret") + ) + @post.secret = 0 + assert_dom_equal( + '', + check_box("post", "secret") + ) + assert_dom_equal( + '', + check_box("post", "secret" ,{"checked"=>"checked"}) + ) + @post.secret = true + assert_dom_equal( + '', + check_box("post", "secret") + ) + assert_dom_equal( + '', + check_box("post", "secret?") + ) + + @post.secret = ['0'] + assert_dom_equal( + '', + check_box("post", "secret") + ) + @post.secret = ['1'] + assert_dom_equal( + '', + check_box("post", "secret") + ) + end + + def test_check_box_with_explicit_checked_and_unchecked_values + @post.secret = "on" + assert_dom_equal( + '', + check_box("post", "secret", {}, "on", "off") + ) + end + + def test_checkbox_disabled_still_submits_checked_value + assert_dom_equal( + '', + check_box("post", "secret", { :disabled => :true }) + ) + end + + def test_radio_button + assert_dom_equal('', + radio_button("post", "title", "Hello World") + ) + assert_dom_equal('', + radio_button("post", "title", "Goodbye World") + ) + assert_dom_equal('', + radio_button("item[subobject]", "title", "inside world") + ) + end + + def test_radio_button_is_checked_with_integers + assert_dom_equal('', + radio_button("post", "secret", "1") + ) + end + + def test_radio_button_respects_passed_in_id + assert_dom_equal('', + radio_button("post", "secret", "1", :id=>"foo") + ) + end + + def test_radio_button_with_booleans + assert_dom_equal('', + radio_button("post", "secret", true) + ) + + assert_dom_equal('', + radio_button("post", "secret", false) + ) + end + + def test_text_area + assert_dom_equal( + '', + text_area("post", "body") + ) + end + + def test_text_area_with_escapes + @post.body = "Back to the hill and over it again!" + assert_dom_equal( + '', + text_area("post", "body") + ) + end + + def test_text_area_with_alternate_value + assert_dom_equal( + '', + text_area("post", "body", :value => 'Testing alternate values.') + ) + end + + def test_text_area_with_html_entities + @post.body = "The HTML Entity for & is &" + assert_dom_equal( + '', + text_area("post", "body") + ) + end + + def test_text_area_with_size_option + assert_dom_equal( + '', + text_area("post", "body", :size => "183x820") + ) + end + + def test_explicit_name + assert_dom_equal( + '', text_field("post", "title", "name" => "dont guess") + ) + assert_dom_equal( + '', + text_area("post", "body", "name" => "really!") + ) + assert_dom_equal( + '', + check_box("post", "secret", "name" => "i mean it") + ) + assert_dom_equal text_field("post", "title", "name" => "dont guess"), + text_field("post", "title", :name => "dont guess") + assert_dom_equal text_area("post", "body", "name" => "really!"), + text_area("post", "body", :name => "really!") + assert_dom_equal check_box("post", "secret", "name" => "i mean it"), + check_box("post", "secret", :name => "i mean it") + end + + def test_explicit_id + assert_dom_equal( + '', text_field("post", "title", "id" => "dont guess") + ) + assert_dom_equal( + '', + text_area("post", "body", "id" => "really!") + ) + assert_dom_equal( + '', + check_box("post", "secret", "id" => "i mean it") + ) + assert_dom_equal text_field("post", "title", "id" => "dont guess"), + text_field("post", "title", :id => "dont guess") + assert_dom_equal text_area("post", "body", "id" => "really!"), + text_area("post", "body", :id => "really!") + assert_dom_equal check_box("post", "secret", "id" => "i mean it"), + check_box("post", "secret", :id => "i mean it") + end + + def test_auto_index + pid = @post.id + assert_dom_equal( + "", + label("post[]", "title") + ) + assert_dom_equal( + "", text_field("post[]","title") + ) + assert_dom_equal( + "", + text_area("post[]", "body") + ) + assert_dom_equal( + "", + check_box("post[]", "secret") + ) + assert_dom_equal( +"", + radio_button("post[]", "title", "Hello World") + ) + assert_dom_equal("", + radio_button("post[]", "title", "Goodbye World") + ) + end + + def test_form_for + form_for(:post, @post, :html => { :id => 'create-post' }) do |f| + concat f.label(:title) + concat f.text_field(:title) + concat f.text_area(:body) + concat f.check_box(:secret) + concat f.submit('Create post') + end + + expected = + "
" + + assert_dom_equal expected, output_buffer + end + + def test_form_for_with_method + form_for(:post, @post, :html => { :id => 'create-post', :method => :put }) do |f| + concat f.text_field(:title) + concat f.text_area(:body) + concat f.check_box(:secret) + end + + expected = + "" + + assert_dom_equal expected, output_buffer + end + + def test_form_for_without_object + form_for(:post, :html => { :id => 'create-post' }) do |f| + concat f.text_field(:title) + concat f.text_area(:body) + concat f.check_box(:secret) + end + + expected = + "" + + assert_dom_equal expected, output_buffer + end + + def test_form_for_with_index + form_for("post[]", @post) do |f| + concat f.label(:title) + concat f.text_field(:title) + concat f.text_area(:body) + concat f.check_box(:secret) + end + + expected = + "" + + assert_dom_equal expected, output_buffer + end + + def test_form_for_with_nil_index_option_override + form_for("post[]", @post, :index => nil) do |f| + concat f.text_field(:title) + concat f.text_area(:body) + concat f.check_box(:secret) + end + + expected = + "" + + assert_dom_equal expected, output_buffer + end + + def test_nested_fields_for + form_for(:post, @post) do |f| + f.fields_for(:comment, @post) do |c| + concat c.text_field(:title) + end + end + + expected = "" + + assert_dom_equal expected, output_buffer + end + + def test_nested_fields_for_with_nested_collections + form_for('post[]', @post) do |f| + concat f.text_field(:title) + f.fields_for('comment[]', @comment) do |c| + concat c.text_field(:name) + end + end + + expected = "" + + assert_dom_equal expected, output_buffer + end + + def test_nested_fields_for_with_index_and_parent_fields + form_for('post', @post, :index => 1) do |c| + concat c.text_field(:title) + c.fields_for('comment', @comment, :index => 1) do |r| + concat r.text_field(:name) + end + end + + expected = "" + + assert_dom_equal expected, output_buffer + end + + def test_form_for_with_index_and_nested_fields_for + form_for(:post, @post, :index => 1) do |f| + f.fields_for(:comment, @post) do |c| + concat c.text_field(:title) + end + end + + expected = "" + + assert_dom_equal expected, output_buffer + end + + def test_nested_fields_for_with_index_on_both + form_for(:post, @post, :index => 1) do |f| + f.fields_for(:comment, @post, :index => 5) do |c| + concat c.text_field(:title) + end + end + + expected = "" + + assert_dom_equal expected, output_buffer + end + + def test_nested_fields_for_with_auto_index + form_for("post[]", @post) do |f| + f.fields_for(:comment, @post) do |c| + concat c.text_field(:title) + end + end + + expected = "" + + assert_dom_equal expected, output_buffer + end + + def test_nested_fields_for_with_index_radio_button + form_for(:post, @post) do |f| + f.fields_for(:comment, @post, :index => 5) do |c| + concat c.radio_button(:title, "hello") + end + end + + expected = "" + + assert_dom_equal expected, output_buffer + end + + def test_nested_fields_for_with_auto_index_on_both + form_for("post[]", @post) do |f| + f.fields_for("comment[]", @post) do |c| + concat c.text_field(:title) + end + end + + expected = "" + + assert_dom_equal expected, output_buffer + end + + def test_nested_fields_for_with_index_and_auto_index + form_for("post[]", @post) do |f| + f.fields_for(:comment, @post, :index => 5) do |c| + concat c.text_field(:title) + end + end + + form_for(:post, @post, :index => 1) do |f| + f.fields_for("comment[]", @post) do |c| + concat c.text_field(:title) + end + end + + expected = "" + + "" + + assert_dom_equal expected, output_buffer + end + + def test_nested_fields_for_with_a_new_record_on_a_nested_attributes_one_to_one_association + @post.author = Author.new + + form_for(:post, @post) do |f| + concat f.text_field(:title) + f.fields_for(:author) do |af| + concat af.text_field(:name) + end + end + + expected = '' + + assert_dom_equal expected, output_buffer + end + + def test_nested_fields_for_with_explicitly_passed_object_on_a_nested_attributes_one_to_one_association + form_for(:post, @post) do |f| + f.fields_for(:author, Author.new(123)) do |af| + assert_not_nil af.object + assert_equal 123, af.object.id + end + end + end + + def test_nested_fields_for_with_an_existing_record_on_a_nested_attributes_one_to_one_association + @post.author = Author.new(321) + + form_for(:post, @post) do |f| + concat f.text_field(:title) + f.fields_for(:author) do |af| + concat af.text_field(:name) + end + end + + expected = '' + + assert_dom_equal expected, output_buffer + end + + def test_nested_fields_for_with_existing_records_on_a_nested_attributes_one_to_one_association_with_explicit_hidden_field_placement + @post.author = Author.new(321) + + form_for(:post, @post) do |f| + concat f.text_field(:title) + f.fields_for(:author) do |af| + concat af.hidden_field(:id) + concat af.text_field(:name) + end + end + + expected = '' + + assert_dom_equal expected, output_buffer + end + + def test_nested_fields_for_with_existing_records_on_a_nested_attributes_collection_association + @post.comments = Array.new(2) { |id| Comment.new(id + 1) } + + form_for(:post, @post) do |f| + concat f.text_field(:title) + @post.comments.each do |comment| + f.fields_for(:comments, comment) do |cf| + concat cf.text_field(:name) + end + end + end + + expected = '' + + assert_dom_equal expected, output_buffer + end + + def test_nested_fields_for_with_existing_records_on_a_nested_attributes_collection_association_with_explicit_hidden_field_placement + @post.comments = Array.new(2) { |id| Comment.new(id + 1) } + + form_for(:post, @post) do |f| + concat f.text_field(:title) + @post.comments.each do |comment| + f.fields_for(:comments, comment) do |cf| + concat cf.hidden_field(:id) + concat cf.text_field(:name) + end + end + end + + expected = '' + + assert_dom_equal expected, output_buffer + end + + def test_nested_fields_for_with_new_records_on_a_nested_attributes_collection_association + @post.comments = [Comment.new, Comment.new] + + form_for(:post, @post) do |f| + concat f.text_field(:title) + @post.comments.each do |comment| + f.fields_for(:comments, comment) do |cf| + concat cf.text_field(:name) + end + end + end + + expected = '' + + assert_dom_equal expected, output_buffer + end + + def test_nested_fields_for_with_existing_and_new_records_on_a_nested_attributes_collection_association + @post.comments = [Comment.new(321), Comment.new] + + form_for(:post, @post) do |f| + concat f.text_field(:title) + @post.comments.each do |comment| + f.fields_for(:comments, comment) do |cf| + concat cf.text_field(:name) + end + end + end + + expected = '' + + assert_dom_equal expected, output_buffer + end + + def test_nested_fields_for_with_an_empty_supplied_attributes_collection + form_for(:post, @post) do |f| + concat f.text_field(:title) + f.fields_for(:comments, []) do |cf| + concat cf.text_field(:name) + end + end + + expected = '' + + assert_dom_equal expected, output_buffer + end + + def test_nested_fields_for_with_existing_records_on_a_supplied_nested_attributes_collection + @post.comments = Array.new(2) { |id| Comment.new(id + 1) } + + form_for(:post, @post) do |f| + concat f.text_field(:title) + f.fields_for(:comments, @post.comments) do |cf| + concat cf.text_field(:name) + end + end + + expected = '' + + assert_dom_equal expected, output_buffer + end + + def test_nested_fields_for_on_a_nested_attributes_collection_association_yields_only_builder + @post.comments = [Comment.new(321), Comment.new] + yielded_comments = [] + + form_for(:post, @post) do |f| + concat f.text_field(:title) + f.fields_for(:comments) do |cf| + concat cf.text_field(:name) + yielded_comments << cf.object + end + end + + expected = '' + + assert_dom_equal expected, output_buffer + assert_equal yielded_comments, @post.comments + end + + def test_nested_fields_for_with_child_index_option_override_on_a_nested_attributes_collection_association + @post.comments = [] + + form_for(:post, @post) do |f| + f.fields_for(:comments, Comment.new(321), :child_index => 'abc') do |cf| + concat cf.text_field(:name) + end + end + + expected = '' + + assert_dom_equal expected, output_buffer + end + + def test_nested_fields_uses_unique_indices_for_different_collection_associations + @post.comments = [Comment.new(321)] + @post.tags = [Tag.new(123), Tag.new(456)] + @post.comments[0].relevances = [] + @post.tags[0].relevances = [] + @post.tags[1].relevances = [] + form_for(:post, @post) do |f| + f.fields_for(:comments, @post.comments[0]) do |cf| + concat cf.text_field(:name) + cf.fields_for(:relevances, CommentRelevance.new(314)) do |crf| + concat crf.text_field(:value) + end + end + f.fields_for(:tags, @post.tags[0]) do |tf| + concat tf.text_field(:value) + tf.fields_for(:relevances, TagRelevance.new(3141)) do |trf| + concat trf.text_field(:value) + end + end + f.fields_for('tags', @post.tags[1]) do |tf| + concat tf.text_field(:value) + tf.fields_for(:relevances, TagRelevance.new(31415)) do |trf| + concat trf.text_field(:value) + end + end + end + + expected = '' + + assert_dom_equal expected, output_buffer + end + + def test_fields_for + fields_for(:post, @post) do |f| + concat f.text_field(:title) + concat f.text_area(:body) + concat f.check_box(:secret) + end + + expected = + "" + + "" + + "" + + "" + + assert_dom_equal expected, output_buffer + end + + def test_fields_for_with_index + fields_for("post[]", @post) do |f| + concat f.text_field(:title) + concat f.text_area(:body) + concat f.check_box(:secret) + end + + expected = + "" + + "" + + "" + + "" + + assert_dom_equal expected, output_buffer + end + + def test_fields_for_with_nil_index_option_override + fields_for("post[]", @post, :index => nil) do |f| + concat f.text_field(:title) + concat f.text_area(:body) + concat f.check_box(:secret) + end + + expected = + "" + + "" + + "" + + "" + + assert_dom_equal expected, output_buffer + end + + def test_fields_for_with_index_option_override + fields_for("post[]", @post, :index => "abc") do |f| + concat f.text_field(:title) + concat f.text_area(:body) + concat f.check_box(:secret) + end + + expected = + "" + + "" + + "" + + "" + + assert_dom_equal expected, output_buffer + end + + def test_fields_for_without_object + fields_for(:post) do |f| + concat f.text_field(:title) + concat f.text_area(:body) + concat f.check_box(:secret) + end + + expected = + "" + + "" + + "" + + "" + + assert_dom_equal expected, output_buffer + end + + def test_fields_for_with_only_object + fields_for(@post) do |f| + concat f.text_field(:title) + concat f.text_area(:body) + concat f.check_box(:secret) + end + + expected = + "" + + "" + + "" + + "" + + assert_dom_equal expected, output_buffer + end + + def test_fields_for_object_with_bracketed_name + fields_for("author[post]", @post) do |f| + concat f.label(:title) + concat f.text_field(:title) + end + + assert_dom_equal "" + + "", + output_buffer + end + + def test_fields_for_object_with_bracketed_name_and_index + fields_for("author[post]", @post, :index => 1) do |f| + concat f.label(:title) + concat f.text_field(:title) + end + + assert_dom_equal "" + + "", + output_buffer + end + + def test_form_builder_does_not_have_form_for_method + assert ! ActionView::Helpers::FormBuilder.instance_methods.include?('form_for') + end + + def test_form_for_and_fields_for + form_for(:post, @post, :html => { :id => 'create-post' }) do |post_form| + concat post_form.text_field(:title) + concat post_form.text_area(:body) + + fields_for(:parent_post, @post) do |parent_fields| + concat parent_fields.check_box(:secret) + end + end + + expected = + "" + + assert_dom_equal expected, output_buffer + end + + def test_form_for_and_fields_for_with_object + form_for(:post, @post, :html => { :id => 'create-post' }) do |post_form| + concat post_form.text_field(:title) + concat post_form.text_area(:body) + + post_form.fields_for(@comment) do |comment_fields| + concat comment_fields.text_field(:name) + end + end + + expected = + "" + + assert_dom_equal expected, output_buffer + end + + class LabelledFormBuilder < ActionView::Helpers::FormBuilder + (field_helpers - %w(hidden_field)).each do |selector| + src, line = <<-END_SRC, __LINE__ + 1 + def #{selector}(field, *args, &proc) + (" " + super + "It's nice to have options.
), + simple_format("It's nice to have options.", :class=>"intro")) + end + + def test_simple_format_should_not_escape_safe_content + assert_dom_equal(%(This is .
), + simple_format('This is .'.html_safe)) + end + + def test_simple_format_escapes_unsafe_content + assert_dom_equal(%(This is <script>evil_js</script>.
), + simple_format('This is .')) + end + + def test_truncate_should_not_be_html_safe + assert !truncate("Hello World!", :length => 12).html_safe? + end +end diff --git a/vendor/plugins/rails_xss/test/url_for_test.rb b/vendor/plugins/rails_xss/test/url_for_test.rb new file mode 100644 index 00000000..b13451bf --- /dev/null +++ b/vendor/plugins/rails_xss/test/url_for_test.rb @@ -0,0 +1,39 @@ +require 'test_helper' + +class UrlHelperTest < ActionView::TestCase + + def abcd(hash = {}) + hash_for(:a => :b, :c => :d).merge(hash) + end + + def hash_for(opts = {}) + {:controller => "foo", :action => "bar"}.merge(opts) + end + + def test_url_for_does_not_escape_urls_if_explicitly_stated + assert_equal "/foo/bar?a=b&c=d", url_for(abcd(:escape => false)) + end + + def test_link_tag_with_img + link = link_to("".html_safe, "/") + expected = %{} + assert_dom_equal expected, link + end + + def test_link_to_should_not_escape_content_for_html_safe + link = link_to("Somehtml
".html_safe, "/") + expected = %{Somehtml
} + assert_dom_equal link, expected + end + + def test_link_to_escapes_content_for_non_safe + link = link_to("Somehtml
", "/") + expected = %{Some <p>html</p>} + assert_dom_equal link, expected + end + + def test_url_for_escaping_is_safety_aware + assert url_for(abcd(:escape => true)).html_safe?, "escaped urls should be html_safe?" + assert !url_for(abcd(:escape => false)).html_safe?, "non-escaped urls should not be html_safe?" + end +end diff --git a/vendor/rails/actionmailer/Rakefile b/vendor/rails/actionmailer/Rakefile index e7ef2b23..ba85056e 100644 --- a/vendor/rails/actionmailer/Rakefile +++ b/vendor/rails/actionmailer/Rakefile @@ -1,9 +1,9 @@ require 'rubygems' require 'rake' require 'rake/testtask' -require 'rake/rdoctask' +require 'rdoc/task' require 'rake/packagetask' -require 'rake/gempackagetask' +require 'rubygems/package_task' require File.join(File.dirname(__FILE__), 'lib', 'action_mailer', 'version') PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : '' @@ -29,7 +29,7 @@ Rake::TestTask.new { |t| # Generate the RDoc documentation -Rake::RDocTask.new { |rdoc| +RDoc::Task.new { |rdoc| rdoc.rdoc_dir = 'doc' rdoc.title = "Action Mailer -- Easy email delivery and testing" rdoc.options << '--line-numbers' << '--inline-source' << '-A cattr_accessor=object' @@ -54,19 +54,17 @@ spec = Gem::Specification.new do |s| s.rubyforge_project = "actionmailer" s.homepage = "http://www.rubyonrails.org" - s.add_dependency('actionpack', '= 2.3.11' + PKG_BUILD) + s.add_dependency('actionpack', '= 2.3.12' + PKG_BUILD) - s.has_rdoc = true s.requirements << 'none' s.require_path = 'lib' - s.autorequire = 'action_mailer' s.files = [ "Rakefile", "install.rb", "README", "CHANGELOG", "MIT-LICENSE" ] s.files = s.files + Dir.glob( "lib/**/*" ).delete_if { |item| item.include?( "\.svn" ) } s.files = s.files + Dir.glob( "test/**/*" ).delete_if { |item| item.include?( "\.svn" ) } end -Rake::GemPackageTask.new(spec) do |p| +Gem::PackageTask.new(spec) do |p| p.gem_spec = spec p.need_tar = true p.need_zip = true diff --git a/vendor/rails/actionmailer/lib/action_mailer/version.rb b/vendor/rails/actionmailer/lib/action_mailer/version.rb index da9b986a..ce0b782e 100644 --- a/vendor/rails/actionmailer/lib/action_mailer/version.rb +++ b/vendor/rails/actionmailer/lib/action_mailer/version.rb @@ -2,7 +2,7 @@ module ActionMailer module VERSION #:nodoc: MAJOR = 2 MINOR = 3 - TINY = 11 + TINY = 12 STRING = [MAJOR, MINOR, TINY].join('.') end diff --git a/vendor/rails/actionpack/Rakefile b/vendor/rails/actionpack/Rakefile index 4c7c4b7b..004ed541 100644 --- a/vendor/rails/actionpack/Rakefile +++ b/vendor/rails/actionpack/Rakefile @@ -1,9 +1,9 @@ require 'rubygems' require 'rake' require 'rake/testtask' -require 'rake/rdoctask' +require 'rdoc/task' require 'rake/packagetask' -require 'rake/gempackagetask' +require 'rubygems/package_task' require File.join(File.dirname(__FILE__), 'lib', 'action_pack', 'version') PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : '' @@ -45,7 +45,7 @@ end # Genereate the RDoc documentation -Rake::RDocTask.new { |rdoc| +RDoc::Task.new { |rdoc| rdoc.rdoc_dir = 'doc' rdoc.title = "Action Pack -- On rails from request to response" rdoc.options << '--line-numbers' << '--inline-source' @@ -76,14 +76,12 @@ spec = Gem::Specification.new do |s| s.rubyforge_project = "actionpack" s.homepage = "http://www.rubyonrails.org" - s.has_rdoc = true s.requirements << 'none' - s.add_dependency('activesupport', '= 2.3.11' + PKG_BUILD) + s.add_dependency('activesupport', '= 2.3.12' + PKG_BUILD) s.add_dependency('rack', '~> 1.1.0') s.require_path = 'lib' - s.autorequire = 'action_controller' s.files = [ "Rakefile", "install.rb", "README", "RUNNING_UNIT_TESTS", "CHANGELOG", "MIT-LICENSE" ] dist_dirs.each do |dir| @@ -91,7 +89,7 @@ spec = Gem::Specification.new do |s| end end -Rake::GemPackageTask.new(spec) do |p| +Gem::PackageTask.new(spec) do |p| p.gem_spec = spec p.need_tar = true p.need_zip = true diff --git a/vendor/rails/actionpack/lib/action_controller/request.rb b/vendor/rails/actionpack/lib/action_controller/request.rb index 98c5e8ce..dc462530 100755 --- a/vendor/rails/actionpack/lib/action_controller/request.rb +++ b/vendor/rails/actionpack/lib/action_controller/request.rb @@ -446,7 +446,9 @@ EOM end def reset_session - session.destroy if session + # session may be a hash, if so, we do not want to call destroy + # fixes issue 6440 + session.destroy if session and session.respond_to?(:destroy) self.session = {} end diff --git a/vendor/rails/actionpack/lib/action_controller/session/abstract_store.rb b/vendor/rails/actionpack/lib/action_controller/session/abstract_store.rb index de0163d2..1d2ee87f 100644 --- a/vendor/rails/actionpack/lib/action_controller/session/abstract_store.rb +++ b/vendor/rails/actionpack/lib/action_controller/session/abstract_store.rb @@ -196,6 +196,7 @@ module ActionController if (request_cookies.nil? || request_cookies[@key] != sid) || options[:expire_after] cookie = {:value => sid} + cookie[:expires] = Time.now + options[:expire_after] if options[:expire_after] Rack::Utils.set_cookie_header!(response[1], @key, cookie.merge(options)) end end diff --git a/vendor/rails/actionpack/lib/action_pack/version.rb b/vendor/rails/actionpack/lib/action_pack/version.rb index 227ef601..010bfcb0 100644 --- a/vendor/rails/actionpack/lib/action_pack/version.rb +++ b/vendor/rails/actionpack/lib/action_pack/version.rb @@ -2,7 +2,7 @@ module ActionPack #:nodoc: module VERSION #:nodoc: MAJOR = 2 MINOR = 3 - TINY = 11 + TINY = 12 STRING = [MAJOR, MINOR, TINY].join('.') end diff --git a/vendor/rails/actionpack/lib/action_view/template_handlers/erb.rb b/vendor/rails/actionpack/lib/action_view/template_handlers/erb.rb index a0131e13..41c88f59 100644 --- a/vendor/rails/actionpack/lib/action_view/template_handlers/erb.rb +++ b/vendor/rails/actionpack/lib/action_view/template_handlers/erb.rb @@ -15,6 +15,7 @@ module ActionView erb = "#{magic}<% __in_erb_template=true %>#{template.source}" if erb.respond_to?(:force_encoding) + erb.force_encoding(template.source.encoding) # erb.force_encoding(template.source.encoding) erb.force_encoding('UTF-8') end diff --git a/vendor/rails/actionpack/test/controller/session/abstract_store_test.rb b/vendor/rails/actionpack/test/controller/session/abstract_store_test.rb new file mode 100644 index 00000000..2df66a2e --- /dev/null +++ b/vendor/rails/actionpack/test/controller/session/abstract_store_test.rb @@ -0,0 +1,64 @@ +require 'abstract_unit' + +# You need to start a memcached server inorder to run these tests +class AbstractStoreTest < ActionController::IntegrationTest + SessionKey = '_myapp_session' + DispatcherApp = ActionController::Dispatcher.new + + class TestController < ActionController::Base + def get_session + session[:test] = 'test' + head :ok + end + end + + def test_expiry_after + with_test_route_set(:expire_after => 5 * 60) do + get 'get_session' + assert_response :success + assert_match /expires=\S+/, headers['Set-Cookie'] + end + end + +protected + + def with_test_route_set(options = {}) + with_routing do |set| + set.draw do |map| + map.with_options :controller => "abstract_store_test/test" do |c| + c.connect "/:action" + end + end + + options = { :key => SessionKey, :secret => 'SessionSecret' }.merge!(options) + @integration_session = open_session(TestStore.new(DispatcherApp, options)) + + yield + end + end + + class TestStore < ActionController::Session::AbstractStore + def initialize(app, options = {}) + super + @_store = Hash.new({}) + end + + private + + def get_session(env, sid) + sid ||= generate_sid + session = @_store[sid] + [sid, session] + end + + def set_session(env, sid, session_data) + @_store[sid] = session_data + end + + def destroy(env) + @_store.delete(sid) + end + end + +end + diff --git a/vendor/rails/actionpack/test/controller/session/cookie_store_test.rb b/vendor/rails/actionpack/test/controller/session/cookie_store_test.rb index b7b922c3..8d02fffa 100644 --- a/vendor/rails/actionpack/test/controller/session/cookie_store_test.rb +++ b/vendor/rails/actionpack/test/controller/session/cookie_store_test.rb @@ -42,6 +42,12 @@ class CookieStoreTest < ActionController::IntegrationTest head :ok end + def call_reset_session_twice + reset_session + reset_session + head :ok + end + def call_reset_session reset_session head :ok @@ -190,6 +196,44 @@ class CookieStoreTest < ActionController::IntegrationTest end end + def test_calling_session_reset_twice + with_test_route_set do + get '/set_session_value' + assert_response :success + session_payload = response.body + assert_equal "_myapp_session=#{response.body}; path=/; HttpOnly", + headers['Set-Cookie'] + + get '/call_reset_session_twice' + assert_response :success + assert_not_equal "", headers['Set-Cookie'] + assert_not_equal session_payload, cookies[SessionKey] + + get '/get_session_value' + assert_response :success + assert_equal 'foo: nil', response.body + end + end + + def test_setting_session_value_after_session_reset + with_test_route_set do + get '/set_session_value' + assert_response :success + session_payload = response.body + assert_equal "_myapp_session=#{response.body}; path=/; HttpOnly", + headers['Set-Cookie'] + + get '/call_reset_session' + assert_response :success + assert_not_equal "", headers['Set-Cookie'] + assert_not_equal session_payload, cookies[SessionKey] + + get '/get_session_value' + assert_response :success + assert_equal 'foo: nil', response.body + end + end + def test_setting_session_value_after_session_reset with_test_route_set do get '/set_session_value' diff --git a/vendor/rails/activemodel/Rakefile b/vendor/rails/activemodel/Rakefile index 4b60f8d6..6e7df2e7 100755 --- a/vendor/rails/activemodel/Rakefile +++ b/vendor/rails/activemodel/Rakefile @@ -1,7 +1,7 @@ #!/usr/bin/env ruby require 'rake' require 'rake/testtask' -require 'rake/rdoctask' +require 'rdoc/task' task :default => :test @@ -13,7 +13,7 @@ Rake::TestTask.new do |t| end # Generate the RDoc documentation -Rake::RDocTask.new do |rdoc| +RDoc::Task.new do |rdoc| rdoc.rdoc_dir = 'doc' rdoc.title = "Active Model" rdoc.options << '--line-numbers' << '--inline-source' << '-A cattr_accessor=object' diff --git a/vendor/rails/activerecord/Rakefile b/vendor/rails/activerecord/Rakefile index 613bda69..dcdff6ba 100644 --- a/vendor/rails/activerecord/Rakefile +++ b/vendor/rails/activerecord/Rakefile @@ -1,9 +1,9 @@ require 'rubygems' require 'rake' require 'rake/testtask' -require 'rake/rdoctask' +require 'rdoc/task' require 'rake/packagetask' -require 'rake/gempackagetask' +require 'rubygems/package_task' require File.join(File.dirname(__FILE__), 'lib', 'active_record', 'version') require File.expand_path(File.dirname(__FILE__)) + "/test/config" @@ -157,7 +157,7 @@ task :rebuild_frontbase_databases => 'frontbase:rebuild_databases' # Generate the RDoc documentation -Rake::RDocTask.new { |rdoc| +RDoc::Task.new { |rdoc| rdoc.rdoc_dir = 'doc' rdoc.title = "Active Record -- Object-relation mapping put on rails" rdoc.options << '--line-numbers' << '--inline-source' << '-A cattr_accessor=object' @@ -192,16 +192,14 @@ spec = Gem::Specification.new do |s| s.files = s.files + Dir.glob( "#{dir}/**/*" ).delete_if { |item| item.include?( "\.svn" ) } end - s.add_dependency('activesupport', '= 2.3.11' + PKG_BUILD) + s.add_dependency('activesupport', '= 2.3.12' + PKG_BUILD) s.files.delete FIXTURES_ROOT + "/fixture_database.sqlite" s.files.delete FIXTURES_ROOT + "/fixture_database_2.sqlite" s.files.delete FIXTURES_ROOT + "/fixture_database.sqlite3" s.files.delete FIXTURES_ROOT + "/fixture_database_2.sqlite3" s.require_path = 'lib' - s.autorequire = 'active_record' - s.has_rdoc = true s.extra_rdoc_files = %w( README ) s.rdoc_options.concat ['--main', 'README'] @@ -211,7 +209,7 @@ spec = Gem::Specification.new do |s| s.rubyforge_project = "activerecord" end -Rake::GemPackageTask.new(spec) do |p| +Gem::PackageTask.new(spec) do |p| p.gem_spec = spec p.need_tar = true p.need_zip = true diff --git a/vendor/rails/activerecord/lib/active_record/associations/association_collection.rb b/vendor/rails/activerecord/lib/active_record/associations/association_collection.rb index 3a602e49..c04110a9 100644 --- a/vendor/rails/activerecord/lib/active_record/associations/association_collection.rb +++ b/vendor/rails/activerecord/lib/active_record/associations/association_collection.rb @@ -381,7 +381,7 @@ module ActiveRecord when /^find_or_create_by_(.*)$/ rest = $1 find_args = pull_finder_args_from(DynamicFinderMatch.match(method).attribute_names, *args) - return send("find_by_#{rest}", find_args) || + return send("find_by_#{rest}", *find_args) || method_missing("create_by_#{rest}", *args, &block) when /^create_by_(.*)$/ return create($1.split('_and_').zip(args).inject({}) { |h,kv| k,v=kv ; h[k] = v ; h }, &block) diff --git a/vendor/rails/activerecord/lib/active_record/base.rb b/vendor/rails/activerecord/lib/active_record/base.rb index ac82cc1b..461007fd 100755 --- a/vendor/rails/activerecord/lib/active_record/base.rb +++ b/vendor/rails/activerecord/lib/active_record/base.rb @@ -1286,7 +1286,7 @@ module ActiveRecord #:nodoc: # Turns the +table_name+ back into a class name following the reverse rules of +table_name+. def class_name(table_name = table_name) # :nodoc: - ActiveSupport::Deprecation.warn("ActiveRecord::Base#class_name is deprecated and will be removed in Rails 2.3.9.", caller) + ActiveSupport::Deprecation.warn("ActiveRecord::Base#class_name is deprecated and will be removed in Rails 3.", caller) # remove any prefix and/or suffix from the table name class_name = table_name[table_name_prefix.length..-(table_name_suffix.length + 1)].camelize diff --git a/vendor/rails/activerecord/lib/active_record/version.rb b/vendor/rails/activerecord/lib/active_record/version.rb index f106e409..db0e08ef 100644 --- a/vendor/rails/activerecord/lib/active_record/version.rb +++ b/vendor/rails/activerecord/lib/active_record/version.rb @@ -2,7 +2,7 @@ module ActiveRecord module VERSION #:nodoc: MAJOR = 2 MINOR = 3 - TINY = 11 + TINY = 12 STRING = [MAJOR, MINOR, TINY].join('.') end diff --git a/vendor/rails/activerecord/test/cases/associations/has_many_associations_test.rb b/vendor/rails/activerecord/test/cases/associations/has_many_associations_test.rb index 3996b847..2f715a46 100644 --- a/vendor/rails/activerecord/test/cases/associations/has_many_associations_test.rb +++ b/vendor/rails/activerecord/test/cases/associations/has_many_associations_test.rb @@ -82,6 +82,15 @@ class HasManyAssociationsTest < ActiveRecord::TestCase assert_equal 4, post.comments.length end + def test_find_or_create_by_with_same_parameters_creates_a_single_record + author = Author.first + assert_difference "Post.count", +1 do + 2.times do + author.posts.find_or_create_by_body_and_title('one', 'two') + end + end + end + def test_find_or_create_by_with_block post = Post.create! :title => 'test_find_or_create_by_with_additional_parameters', :body => 'this is the body' comment = post.comments.find_or_create_by_body('other test comment body') { |comment| comment.type = 'test' } diff --git a/vendor/rails/activesupport/Rakefile b/vendor/rails/activesupport/Rakefile index d5ece391..f874efea 100644 --- a/vendor/rails/activesupport/Rakefile +++ b/vendor/rails/activesupport/Rakefile @@ -1,6 +1,6 @@ require 'rake/testtask' -require 'rake/rdoctask' -require 'rake/gempackagetask' +require 'rdoc/task' +require 'rubygems/package_task' require File.join(File.dirname(__FILE__), 'lib', 'active_support', 'version') @@ -27,7 +27,7 @@ dist_dirs = [ "lib", "test"] # Genereate the RDoc documentation -Rake::RDocTask.new { |rdoc| +RDoc::Task.new { |rdoc| rdoc.rdoc_dir = 'doc' rdoc.title = "Active Support -- Utility classes and standard library extensions from Rails" rdoc.options << '--line-numbers' << '--inline-source' @@ -48,7 +48,6 @@ spec = Gem::Specification.new do |s| s.files = [ "CHANGELOG", "README" ] + Dir.glob( "lib/**/*" ).delete_if { |item| item.include?( "\.svn" ) } s.require_path = 'lib' - s.has_rdoc = true s.author = "David Heinemeier Hansson" s.email = "david@loudthinking.com" @@ -56,7 +55,7 @@ spec = Gem::Specification.new do |s| s.rubyforge_project = "activesupport" end -Rake::GemPackageTask.new(spec) do |p| +Gem::PackageTask.new(spec) do |p| p.gem_spec = spec p.need_tar = true p.need_zip = true diff --git a/vendor/rails/activesupport/lib/active_support/version.rb b/vendor/rails/activesupport/lib/active_support/version.rb index 922d12ff..eee0a635 100644 --- a/vendor/rails/activesupport/lib/active_support/version.rb +++ b/vendor/rails/activesupport/lib/active_support/version.rb @@ -2,7 +2,7 @@ module ActiveSupport module VERSION #:nodoc: MAJOR = 2 MINOR = 3 - TINY = 11 + TINY = 12 STRING = [MAJOR, MINOR, TINY].join('.') end diff --git a/vendor/rails/railties/Rakefile b/vendor/rails/railties/Rakefile index ebf7c68e..01ac7019 100644 --- a/vendor/rails/railties/Rakefile +++ b/vendor/rails/railties/Rakefile @@ -1,7 +1,7 @@ require 'rake' require 'rake/testtask' -require 'rake/rdoctask' -require 'rake/gempackagetask' +require 'rdoc/task' +require 'rubygems/package_task' require 'date' require 'rbconfig' @@ -267,7 +267,7 @@ task :generate_app_doc do system %{cd #{PKG_DESTINATION}; rake doc:app} end -Rake::RDocTask.new { |rdoc| +RDoc::Task.new { |rdoc| rdoc.rdoc_dir = 'doc' rdoc.title = "Railties -- Gluing the Engine to the Rails" rdoc.options << '--line-numbers' << '--inline-source' << '--accessor' << 'cattr_accessor=object' @@ -313,20 +313,18 @@ spec = Gem::Specification.new do |s| EOF s.add_dependency('rake', '>= 0.8.3') - s.add_dependency('activesupport', '= 2.3.11' + PKG_BUILD) - s.add_dependency('activerecord', '= 2.3.11' + PKG_BUILD) - s.add_dependency('actionpack', '= 2.3.11' + PKG_BUILD) - s.add_dependency('actionmailer', '= 2.3.11' + PKG_BUILD) - s.add_dependency('activeresource', '= 2.3.11' + PKG_BUILD) + s.add_dependency('activesupport', '= 2.3.12' + PKG_BUILD) + s.add_dependency('activerecord', '= 2.3.12' + PKG_BUILD) + s.add_dependency('actionpack', '= 2.3.12' + PKG_BUILD) + s.add_dependency('actionmailer', '= 2.3.12' + PKG_BUILD) + s.add_dependency('activeresource', '= 2.3.12' + PKG_BUILD) s.rdoc_options << '--exclude' << '.' - s.has_rdoc = false s.files = PKG_FILES s.require_path = 'lib' s.bindir = "bin" # Use these for applications. s.executables = ["rails"] - s.default_executable = "rails" s.author = "David Heinemeier Hansson" s.email = "david@loudthinking.com" @@ -334,7 +332,7 @@ spec = Gem::Specification.new do |s| s.rubyforge_project = "rails" end -Rake::GemPackageTask.new(spec) do |pkg| +Gem::PackageTask.new(spec) do |pkg| pkg.gem_spec = spec end diff --git a/vendor/rails/railties/lib/rails/gem_dependency.rb b/vendor/rails/railties/lib/rails/gem_dependency.rb index 4a2418c1..1ff608a8 100644 --- a/vendor/rails/railties/lib/rails/gem_dependency.rb +++ b/vendor/rails/railties/lib/rails/gem_dependency.rb @@ -38,7 +38,7 @@ module Rails result = self.new(name, :version => version) spec_filename = File.join(directory_name, '.specification') if load_spec - raise "Missing specification file in #{File.dirname(spec_filename)}. Perhaps you need to do a 'rake gems:refresh_specs'?" unless File.exists?(spec_filename) + raise "Missing specification file in #{File.dirname(spec_filename)}. Perhaps you need to do a 'rake gems:refresh_specs'\?" unless File.exists?(spec_filename) spec = YAML::load_file(spec_filename) result.specification = spec end @@ -72,7 +72,15 @@ module Rails @load_paths_added = @loaded = @frozen = true return end - gem self + + begin + dep = Gem::Dependency.new(name, requirement) + spec = Gem.source_index.find { |_,s| s.satisfies_requirement?(dep) }.last + spec.activate # a way that exists + rescue + gem self.name, self.requirement # < 1.8 unhappy way + end + @spec = Gem.loaded_specs[name] @frozen = @spec.loaded_from.include?(self.class.unpacked_path) if @spec @load_paths_added = true @@ -117,18 +125,6 @@ module Rails @spec = s end - if method_defined?(:requirement) - def requirement - req = super - req unless req == Gem::Requirement.default - end - else - def requirement - req = version_requirements - req unless req == Gem::Requirement.default - end - end - def built? return false unless frozen? @@ -274,9 +270,10 @@ module Rails end def ==(other) - self.name == other.name && self.requirement == other.requirement + Gem::Dependency === other.class && + self.name == other.name && self.requirement == other.requirement end - alias_method :"eql?", :"==" + alias_method :eql?, :"==" private diff --git a/vendor/rails/railties/lib/rails/vendor_gem_source_index.rb b/vendor/rails/railties/lib/rails/vendor_gem_source_index.rb index ea5147a8..9324de98 100644 --- a/vendor/rails/railties/lib/rails/vendor_gem_source_index.rb +++ b/vendor/rails/railties/lib/rails/vendor_gem_source_index.rb @@ -31,7 +31,7 @@ module Rails def refresh! # reload the installed gems - @installed_source_index.refresh! + # HACK: I don't think this is needed: @installed_source_index.refresh! vendor_gems = {} # handle vendor Rails gems - they are identified by having loaded_from set to "" diff --git a/vendor/rails/railties/lib/rails/version.rb b/vendor/rails/railties/lib/rails/version.rb index 2f557201..94df7c10 100644 --- a/vendor/rails/railties/lib/rails/version.rb +++ b/vendor/rails/railties/lib/rails/version.rb @@ -2,7 +2,7 @@ module Rails module VERSION #:nodoc: MAJOR = 2 MINOR = 3 - TINY = 11 + TINY = 12 STRING = [MAJOR, MINOR, TINY].join('.') end diff --git a/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/Rakefile b/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/Rakefile index 85e8ff18..c56ce947 100644 --- a/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/Rakefile +++ b/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/Rakefile @@ -1,6 +1,6 @@ require 'rake' require 'rake/testtask' -require 'rake/rdoctask' +require 'rdoc/task' desc 'Default: run unit tests.' task :default => :test @@ -14,7 +14,7 @@ Rake::TestTask.new(:test) do |t| end desc 'Generate documentation for the <%= file_name %> plugin.' -Rake::RDocTask.new(:rdoc) do |rdoc| +RDoc::Task.new(:rdoc) do |rdoc| rdoc.rdoc_dir = 'rdoc' rdoc.title = '<%= class_name %>' rdoc.options << '--line-numbers' << '--inline-source' diff --git a/vendor/rails/railties/lib/tasks/documentation.rake b/vendor/rails/railties/lib/tasks/documentation.rake index 8b41478a..bc7887b7 100644 --- a/vendor/rails/railties/lib/tasks/documentation.rake +++ b/vendor/rails/railties/lib/tasks/documentation.rake @@ -1,6 +1,6 @@ namespace :doc do desc "Generate documentation for the application. Set custom template with TEMPLATE=/path/to/rdoc/template.rb or title with TITLE=\"Custom Title\"" - Rake::RDocTask.new("app") { |rdoc| + RDoc::Task.new("app") { |rdoc| rdoc.rdoc_dir = 'doc/app' rdoc.template = ENV['template'] if ENV['template'] rdoc.title = ENV['title'] || "Rails Application Documentation" @@ -12,7 +12,7 @@ namespace :doc do } desc "Generate documentation for the Rails framework" - Rake::RDocTask.new("rails") { |rdoc| + RDoc::Task.new("rails") { |rdoc| rdoc.rdoc_dir = 'doc/api' rdoc.template = "#{ENV['template']}.rb" if ENV['template'] rdoc.title = "Rails Framework Documentation" diff --git a/vendor/rails/railties/lib/tasks/framework.rake b/vendor/rails/railties/lib/tasks/framework.rake index 5dcdacef..76ee9aff 100644 --- a/vendor/rails/railties/lib/tasks/framework.rake +++ b/vendor/rails/railties/lib/tasks/framework.rake @@ -24,7 +24,7 @@ namespace :rails do begin chdir("vendor/rails") do rails.dependencies.select { |g| deps.include? g.name }.each do |g| - Gem::GemRunner.new.run(["unpack", g.name, "--version", g.version_requirements.to_s]) + Gem::GemRunner.new.run(["unpack", g.name, "--version", g.respond_to?(:requirement) ? g.requirement.to_s : g.version_requirements.to_s]) mv(Dir.glob("#{g.name}*").first, g.name) end