bundler-maglev- 1.0.21

Sign up to get free protection for your applications and to get access to all the features.
Files changed (144) hide show
  1. data/.gitignore +22 -0
  2. data/.travis.yml +32 -0
  3. data/CHANGELOG.md +805 -0
  4. data/ISSUES.md +62 -0
  5. data/LICENSE +23 -0
  6. data/README.md +29 -0
  7. data/Rakefile +212 -0
  8. data/UPGRADING.md +103 -0
  9. data/bin/bundle +22 -0
  10. data/bundler.gemspec +30 -0
  11. data/lib/bundler.rb +286 -0
  12. data/lib/bundler/capistrano.rb +11 -0
  13. data/lib/bundler/cli.rb +520 -0
  14. data/lib/bundler/definition.rb +438 -0
  15. data/lib/bundler/dependency.rb +134 -0
  16. data/lib/bundler/deployment.rb +58 -0
  17. data/lib/bundler/dsl.rb +257 -0
  18. data/lib/bundler/environment.rb +47 -0
  19. data/lib/bundler/gem_helper.rb +151 -0
  20. data/lib/bundler/gem_installer.rb +9 -0
  21. data/lib/bundler/gem_tasks.rb +2 -0
  22. data/lib/bundler/graph.rb +130 -0
  23. data/lib/bundler/index.rb +138 -0
  24. data/lib/bundler/installer.rb +97 -0
  25. data/lib/bundler/lazy_specification.rb +74 -0
  26. data/lib/bundler/lockfile_parser.rb +108 -0
  27. data/lib/bundler/remote_specification.rb +59 -0
  28. data/lib/bundler/resolver.rb +464 -0
  29. data/lib/bundler/rubygems_ext.rb +237 -0
  30. data/lib/bundler/rubygems_integration.rb +349 -0
  31. data/lib/bundler/runtime.rb +152 -0
  32. data/lib/bundler/settings.rb +115 -0
  33. data/lib/bundler/setup.rb +23 -0
  34. data/lib/bundler/shared_helpers.rb +71 -0
  35. data/lib/bundler/source.rb +708 -0
  36. data/lib/bundler/spec_set.rb +135 -0
  37. data/lib/bundler/templates/Executable +16 -0
  38. data/lib/bundler/templates/Gemfile +4 -0
  39. data/lib/bundler/templates/newgem/Gemfile.tt +4 -0
  40. data/lib/bundler/templates/newgem/Rakefile.tt +1 -0
  41. data/lib/bundler/templates/newgem/bin/newgem.tt +3 -0
  42. data/lib/bundler/templates/newgem/gitignore.tt +4 -0
  43. data/lib/bundler/templates/newgem/lib/newgem.rb.tt +9 -0
  44. data/lib/bundler/templates/newgem/lib/newgem/version.rb.tt +7 -0
  45. data/lib/bundler/templates/newgem/newgem.gemspec.tt +24 -0
  46. data/lib/bundler/ui.rb +73 -0
  47. data/lib/bundler/vendor/thor.rb +358 -0
  48. data/lib/bundler/vendor/thor/actions.rb +314 -0
  49. data/lib/bundler/vendor/thor/actions/create_file.rb +105 -0
  50. data/lib/bundler/vendor/thor/actions/create_link.rb +57 -0
  51. data/lib/bundler/vendor/thor/actions/directory.rb +93 -0
  52. data/lib/bundler/vendor/thor/actions/empty_directory.rb +134 -0
  53. data/lib/bundler/vendor/thor/actions/file_manipulation.rb +270 -0
  54. data/lib/bundler/vendor/thor/actions/inject_into_file.rb +109 -0
  55. data/lib/bundler/vendor/thor/base.rb +576 -0
  56. data/lib/bundler/vendor/thor/core_ext/file_binary_read.rb +9 -0
  57. data/lib/bundler/vendor/thor/core_ext/hash_with_indifferent_access.rb +75 -0
  58. data/lib/bundler/vendor/thor/core_ext/ordered_hash.rb +100 -0
  59. data/lib/bundler/vendor/thor/error.rb +30 -0
  60. data/lib/bundler/vendor/thor/group.rb +273 -0
  61. data/lib/bundler/vendor/thor/invocation.rb +168 -0
  62. data/lib/bundler/vendor/thor/parser.rb +4 -0
  63. data/lib/bundler/vendor/thor/parser/argument.rb +67 -0
  64. data/lib/bundler/vendor/thor/parser/arguments.rb +161 -0
  65. data/lib/bundler/vendor/thor/parser/option.rb +120 -0
  66. data/lib/bundler/vendor/thor/parser/options.rb +175 -0
  67. data/lib/bundler/vendor/thor/rake_compat.rb +66 -0
  68. data/lib/bundler/vendor/thor/runner.rb +309 -0
  69. data/lib/bundler/vendor/thor/shell.rb +88 -0
  70. data/lib/bundler/vendor/thor/shell/basic.rb +302 -0
  71. data/lib/bundler/vendor/thor/shell/color.rb +108 -0
  72. data/lib/bundler/vendor/thor/shell/html.rb +121 -0
  73. data/lib/bundler/vendor/thor/task.rb +113 -0
  74. data/lib/bundler/vendor/thor/util.rb +229 -0
  75. data/lib/bundler/vendor/thor/version.rb +3 -0
  76. data/lib/bundler/vendored_thor.rb +7 -0
  77. data/lib/bundler/version.rb +6 -0
  78. data/lib/bundler/vlad.rb +11 -0
  79. data/man/bundle-config.ronn +90 -0
  80. data/man/bundle-exec.ronn +111 -0
  81. data/man/bundle-install.ronn +317 -0
  82. data/man/bundle-package.ronn +59 -0
  83. data/man/bundle-update.ronn +176 -0
  84. data/man/bundle.ronn +80 -0
  85. data/man/gemfile.5.ronn +284 -0
  86. data/man/index.txt +6 -0
  87. data/spec/bundler/gem_helper_spec.rb +143 -0
  88. data/spec/cache/gems_spec.rb +230 -0
  89. data/spec/cache/git_spec.rb +12 -0
  90. data/spec/cache/path_spec.rb +27 -0
  91. data/spec/cache/platform_spec.rb +57 -0
  92. data/spec/install/deploy_spec.rb +197 -0
  93. data/spec/install/deprecated_spec.rb +37 -0
  94. data/spec/install/gems/c_ext_spec.rb +48 -0
  95. data/spec/install/gems/env_spec.rb +107 -0
  96. data/spec/install/gems/flex_spec.rb +313 -0
  97. data/spec/install/gems/groups_spec.rb +259 -0
  98. data/spec/install/gems/packed_spec.rb +84 -0
  99. data/spec/install/gems/platform_spec.rb +192 -0
  100. data/spec/install/gems/resolving_spec.rb +72 -0
  101. data/spec/install/gems/simple_case_spec.rb +770 -0
  102. data/spec/install/gems/sudo_spec.rb +74 -0
  103. data/spec/install/gems/win32_spec.rb +26 -0
  104. data/spec/install/gemspec_spec.rb +125 -0
  105. data/spec/install/git_spec.rb +570 -0
  106. data/spec/install/invalid_spec.rb +35 -0
  107. data/spec/install/path_spec.rb +405 -0
  108. data/spec/install/upgrade_spec.rb +26 -0
  109. data/spec/lock/git_spec.rb +35 -0
  110. data/spec/lock/lockfile_spec.rb +739 -0
  111. data/spec/other/check_spec.rb +221 -0
  112. data/spec/other/config_spec.rb +40 -0
  113. data/spec/other/console_spec.rb +54 -0
  114. data/spec/other/exec_spec.rb +248 -0
  115. data/spec/other/ext_spec.rb +37 -0
  116. data/spec/other/help_spec.rb +39 -0
  117. data/spec/other/init_spec.rb +40 -0
  118. data/spec/other/newgem_spec.rb +46 -0
  119. data/spec/other/open_spec.rb +35 -0
  120. data/spec/other/show_spec.rb +82 -0
  121. data/spec/quality_spec.rb +62 -0
  122. data/spec/resolver/basic_spec.rb +20 -0
  123. data/spec/resolver/platform_spec.rb +82 -0
  124. data/spec/runtime/executable_spec.rb +110 -0
  125. data/spec/runtime/load_spec.rb +107 -0
  126. data/spec/runtime/platform_spec.rb +90 -0
  127. data/spec/runtime/require_spec.rb +231 -0
  128. data/spec/runtime/setup_spec.rb +730 -0
  129. data/spec/runtime/with_clean_env_spec.rb +15 -0
  130. data/spec/spec_helper.rb +92 -0
  131. data/spec/support/builders.rb +597 -0
  132. data/spec/support/helpers.rb +239 -0
  133. data/spec/support/indexes.rb +112 -0
  134. data/spec/support/matchers.rb +77 -0
  135. data/spec/support/path.rb +71 -0
  136. data/spec/support/platforms.rb +53 -0
  137. data/spec/support/ruby_ext.rb +20 -0
  138. data/spec/support/rubygems_ext.rb +37 -0
  139. data/spec/support/rubygems_hax/platform.rb +11 -0
  140. data/spec/support/sudo.rb +21 -0
  141. data/spec/update/gems_spec.rb +122 -0
  142. data/spec/update/git_spec.rb +196 -0
  143. data/spec/update/source_spec.rb +51 -0
  144. metadata +296 -0
@@ -0,0 +1,9 @@
1
+ require 'rubygems/installer'
2
+
3
+ module Bundler
4
+ class GemInstaller < Gem::Installer
5
+ def check_executable_overwrite(filename)
6
+ # Bundler needs to install gems regardless of binstub overwriting
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,2 @@
1
+ require 'bundler/gem_helper'
2
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,130 @@
1
+ module Bundler
2
+ class Graph
3
+
4
+ USER_OPTIONS = {:style => 'filled', :fillcolor => '#B9B9D5'}.freeze
5
+
6
+ def initialize(env)
7
+ @env = env
8
+ end
9
+
10
+ def nodes
11
+ populate
12
+ @nodes
13
+ end
14
+
15
+ def groups
16
+ populate
17
+ @groups
18
+ end
19
+
20
+ def viz(output_file, show_gem_versions = false, show_dependency_requirements = false)
21
+ require 'graphviz'
22
+ populate
23
+
24
+ graph_viz = GraphViz::new('Gemfile', {:concentrate => true, :normalize => true, :nodesep => 0.55})
25
+ graph_viz.edge[:fontname] = graph_viz.node[:fontname] = 'Arial, Helvetica, SansSerif'
26
+ graph_viz.edge[:fontsize] = 12
27
+
28
+ viz_nodes = {}
29
+
30
+ # populate all of the nodes
31
+ nodes.each do |name, node|
32
+ label = name.dup
33
+ label << "\n#{node.version}" if show_gem_versions
34
+ options = { :label => label }
35
+ options.merge!( USER_OPTIONS ) if node.is_user
36
+ viz_nodes[name] = graph_viz.add_node( name, options )
37
+ end
38
+
39
+ group_nodes = {}
40
+ @groups.each do |name, dependencies|
41
+ group_nodes[name] = graph_viz.add_node(name.to_s, { :shape => 'box3d', :fontsize => 16 }.merge(USER_OPTIONS))
42
+ dependencies.each do |dependency|
43
+ options = { :weight => 2 }
44
+ if show_dependency_requirements && (dependency.requirement.to_s != ">= 0")
45
+ options[:label] = dependency.requirement.to_s
46
+ end
47
+ graph_viz.add_edge( group_nodes[name], viz_nodes[dependency.name], options )
48
+ end
49
+ end
50
+
51
+ @groups.keys.select { |group| group != :default }.each do |group|
52
+ graph_viz.add_edge( group_nodes[group], group_nodes[:default], { :weight => 2 } )
53
+ end
54
+
55
+ viz_nodes.each do |name, node|
56
+ nodes[name].dependencies.each do |dependency|
57
+ options = { }
58
+ if nodes[dependency.name].is_user
59
+ options[:constraint] = false
60
+ end
61
+ if show_dependency_requirements && (dependency.requirement.to_s != ">= 0")
62
+ options[:label] = dependency.requirement.to_s
63
+ end
64
+
65
+ graph_viz.add_edge( node, viz_nodes[dependency.name], options )
66
+ end
67
+ end
68
+
69
+ graph_viz.output( :png => output_file )
70
+ end
71
+
72
+ private
73
+
74
+ def populate
75
+ return if @populated
76
+
77
+ # hash of name => GraphNode
78
+ @nodes = {}
79
+ @groups = {}
80
+
81
+ # Populate @nodes
82
+ @env.specs.each { |spec| @nodes[spec.name] = GraphNode.new(spec.name, spec.version) }
83
+
84
+ # For gems in Gemfile, add details
85
+ @env.current_dependencies.each do |dependency|
86
+ next unless node = @nodes[dependency.name]
87
+ node.is_user = true
88
+
89
+ dependency.groups.each do |group|
90
+ if @groups.has_key? group
91
+ group = @groups[group]
92
+ else
93
+ group = @groups[group] = []
94
+ end
95
+ group << dependency
96
+ end
97
+ end
98
+
99
+ # walk though a final time and add edges
100
+ @env.specs.each do |spec|
101
+
102
+ from = @nodes[spec.name]
103
+ spec.runtime_dependencies.each do |dependency|
104
+ from.dependencies << dependency
105
+ end
106
+
107
+ end
108
+
109
+ @nodes.freeze
110
+ @groups.freeze
111
+ @populated = true
112
+ end
113
+
114
+ end
115
+
116
+ # Add version info
117
+ class GraphNode
118
+
119
+ def initialize(name, version)
120
+ @name = name
121
+ @version = version
122
+ @is_user = false
123
+ @dependencies = []
124
+ end
125
+
126
+ attr_reader :name, :dependencies, :version
127
+ attr_accessor :is_user
128
+
129
+ end
130
+ end
@@ -0,0 +1,138 @@
1
+ module Bundler
2
+ class Index
3
+ include Enumerable
4
+
5
+ def self.build
6
+ i = new
7
+ yield i
8
+ i
9
+ end
10
+
11
+ attr_reader :specs
12
+ protected :specs
13
+
14
+ def initialize
15
+ @cache = {}
16
+ @specs = Hash.new { |h,k| h[k] = [] }
17
+ end
18
+
19
+ def initialize_copy(o)
20
+ super
21
+ @cache = {}
22
+ @specs = Hash.new { |h,k| h[k] = [] }
23
+
24
+ o.specs.each do |name, array|
25
+ @specs[name] = array.dup
26
+ end
27
+ end
28
+
29
+ def empty?
30
+ each { return false }
31
+ true
32
+ end
33
+
34
+ def search(query)
35
+ case query
36
+ when Gem::Specification, RemoteSpecification, LazySpecification then search_by_spec(query)
37
+ when String then @specs[query]
38
+ else search_by_dependency(query)
39
+ end
40
+ end
41
+
42
+ def search_for_all_platforms(dependency, base = [])
43
+ specs = @specs[dependency.name] + base
44
+
45
+ wants_prerelease = dependency.requirement.prerelease?
46
+ only_prerelease = specs.all? {|spec| spec.version.prerelease? }
47
+ found = specs.select { |spec| dependency.matches_spec?(spec) }
48
+
49
+ unless wants_prerelease || only_prerelease
50
+ found.reject! { |spec| spec.version.prerelease? }
51
+ end
52
+
53
+ found.sort_by {|s| [s.version, s.platform.to_s == 'ruby' ? "\0" : s.platform.to_s] }
54
+ end
55
+
56
+ def sources
57
+ @specs.values.map do |specs|
58
+ specs.map{|s| s.source.class }
59
+ end.flatten.uniq
60
+ end
61
+
62
+ alias [] search
63
+
64
+ def <<(spec)
65
+ arr = @specs[spec.name]
66
+
67
+ arr.delete_if do |s|
68
+ same_version?(s.version, spec.version) && s.platform == spec.platform
69
+ end
70
+
71
+ arr << spec
72
+ spec
73
+ end
74
+
75
+ def each(&blk)
76
+ @specs.values.each do |specs|
77
+ specs.each(&blk)
78
+ end
79
+ end
80
+
81
+ def use(other, override_dupes = false)
82
+ return unless other
83
+ other.each do |s|
84
+ if (dupes = search_by_spec(s)) && dupes.any?
85
+ next unless override_dupes
86
+ @specs[s.name] -= dupes
87
+ end
88
+ @specs[s.name] << s
89
+ end
90
+ self
91
+ end
92
+
93
+ def ==(o)
94
+ all? do |s|
95
+ s2 = o[s].first and (s.dependencies & s2.dependencies).empty?
96
+ end
97
+ end
98
+
99
+ private
100
+
101
+ def search_by_spec(spec)
102
+ @specs[spec.name].select do |s|
103
+ same_version?(s.version, spec.version) && Gem::Platform.new(s.platform) == Gem::Platform.new(spec.platform)
104
+ end
105
+ end
106
+
107
+ if RUBY_VERSION < '1.9'
108
+ def same_version?(a, b)
109
+ regex = /^(.*?)(?:\.0)*$/
110
+ a.to_s[regex, 1] == b.to_s[regex, 1]
111
+ end
112
+ else
113
+ def same_version?(a, b)
114
+ a == b
115
+ end
116
+ end
117
+
118
+ def spec_satisfies_dependency?(spec, dep)
119
+ return false unless dep.name === spec.name
120
+ dep.requirement.satisfied_by?(spec.version)
121
+ end
122
+
123
+ def search_by_dependency(dependency)
124
+ @cache[dependency.hash] ||= begin
125
+ specs = @specs[dependency.name]
126
+ found = specs.select { |spec| dependency.matches_spec?(spec) && Gem::Platform.match(spec.platform) }
127
+
128
+ wants_prerelease = dependency.requirement.prerelease?
129
+ only_prerelease = specs.all? {|spec| spec.version.prerelease? }
130
+ unless wants_prerelease || only_prerelease
131
+ found.reject! { |spec| spec.version.prerelease? }
132
+ end
133
+
134
+ found.sort_by {|s| [s.version, s.platform.to_s == 'ruby' ? "\0" : s.platform.to_s] }
135
+ end
136
+ end
137
+ end
138
+ end
@@ -0,0 +1,97 @@
1
+ require 'erb'
2
+ require 'rubygems/dependency_installer'
3
+
4
+ module Bundler
5
+ class Installer < Environment
6
+ def self.install(root, definition, options = {})
7
+ installer = new(root, definition)
8
+ installer.run(options)
9
+ installer
10
+ end
11
+
12
+ def run(options)
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
+ 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
+ # 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
+ install_gem_from_spec(spec)
51
+ end
52
+
53
+ lock
54
+ end
55
+
56
+ private
57
+
58
+ def install_gem_from_spec(spec)
59
+ # Download the gem to get the spec, because some specs that are returned
60
+ # by rubygems.org are broken and wrong.
61
+ spec.source.fetch(spec) if spec.source.respond_to?(:fetch)
62
+
63
+ # Fetch the build settings, if there are any
64
+ settings = Bundler.settings["build.#{spec.name}"]
65
+ Bundler.rubygems.with_build_args [settings] do
66
+ spec.source.install(spec)
67
+ Bundler.ui.debug "from #{spec.loaded_from} "
68
+ end
69
+
70
+ # newline comes after installing, some gems say "with native extensions"
71
+ Bundler.ui.info ""
72
+ generate_bundler_executable_stubs(spec) if Bundler.settings[:bin]
73
+ FileUtils.rm_rf(Bundler.tmp)
74
+ rescue Exception => e
75
+ Bundler.ui.info ""
76
+ Bundler.ui.warn "#{e.class}: #{e.message}"
77
+ msg = "An error occured while installing #{spec.name} (#{spec.version}),"
78
+ msg << " and Bundler cannot continue.\nMake sure that `gem install"
79
+ msg << " #{spec.name} -v '#{spec.version}'` succeeds before bundling."
80
+ raise Bundler::InstallError, msg
81
+ end
82
+
83
+ def generate_bundler_executable_stubs(spec)
84
+ bin_path = Bundler.bin_path
85
+ template = File.read(File.expand_path('../templates/Executable', __FILE__))
86
+ relative_gemfile_path = Bundler.default_gemfile.relative_path_from(bin_path)
87
+ ruby_command = Thor::Util.ruby_command
88
+
89
+ spec.executables.each do |executable|
90
+ next if executable == "bundle"
91
+ File.open "#{bin_path}/#{executable}", 'w', 0755 do |f|
92
+ f.puts ERB.new(template, nil, '-').result(binding)
93
+ end
94
+ end
95
+ end
96
+ end
97
+ end
@@ -0,0 +1,74 @@
1
+ require "uri"
2
+ require "rubygems/spec_fetcher"
3
+
4
+ module Bundler
5
+ class LazySpecification
6
+ include MatchPlatform
7
+
8
+ attr_reader :name, :version, :dependencies, :platform
9
+ attr_accessor :source
10
+
11
+ def initialize(name, version, platform, source = nil)
12
+ @name = name
13
+ @version = version
14
+ @dependencies = []
15
+ @platform = platform
16
+ @source = source
17
+ @specification = nil
18
+ end
19
+
20
+ def full_name
21
+ if platform == Gem::Platform::RUBY or platform.nil? then
22
+ "#{@name}-#{@version}"
23
+ else
24
+ "#{@name}-#{@version}-#{platform}"
25
+ end
26
+ end
27
+
28
+ def satisfies?(dependency)
29
+ @name == dependency.name && dependency.requirement.satisfied_by?(Gem::Version.new(@version))
30
+ end
31
+
32
+ def to_lock
33
+ if platform == Gem::Platform::RUBY or platform.nil?
34
+ out = " #{name} (#{version})\n"
35
+ else
36
+ out = " #{name} (#{version}-#{platform})\n"
37
+ end
38
+
39
+ dependencies.sort_by {|d| d.to_s }.each do |dep|
40
+ next if dep.type == :development
41
+ out << " #{dep.to_lock}\n"
42
+ end
43
+
44
+ out
45
+ end
46
+
47
+ def __materialize__
48
+ @specification = source.specs.search(Gem::Dependency.new(name, version)).last
49
+ end
50
+
51
+ def respond_to?(*args)
52
+ super || @specification.respond_to?(*args)
53
+ end
54
+
55
+ def to_s
56
+ "#{name} (#{version})"
57
+ end
58
+
59
+ private
60
+
61
+ def to_ary
62
+ nil
63
+ end
64
+
65
+ def method_missing(method, *args, &blk)
66
+ raise "LazySpecification has not been materialized yet (calling :#{method} #{args.inspect})" unless @specification
67
+
68
+ return super unless respond_to?(method)
69
+
70
+ @specification.send(method, *args, &blk)
71
+ end
72
+
73
+ end
74
+ end