bundler_package_git 1.1.pre.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (149) hide show
  1. data/.gitignore +22 -0
  2. data/.rvmrc +1 -0
  3. data/CHANGELOG.md +659 -0
  4. data/ISSUES.md +47 -0
  5. data/LICENSE +23 -0
  6. data/README.md +29 -0
  7. data/Rakefile +167 -0
  8. data/UPGRADING.md +103 -0
  9. data/bin/bundle +22 -0
  10. data/bundler.gemspec +30 -0
  11. data/lib/bundler.rb +283 -0
  12. data/lib/bundler/capistrano.rb +11 -0
  13. data/lib/bundler/cli.rb +490 -0
  14. data/lib/bundler/definition.rb +429 -0
  15. data/lib/bundler/dependency.rb +130 -0
  16. data/lib/bundler/deployment.rb +53 -0
  17. data/lib/bundler/dsl.rb +243 -0
  18. data/lib/bundler/environment.rb +47 -0
  19. data/lib/bundler/fetcher.rb +101 -0
  20. data/lib/bundler/gem_helper.rb +146 -0
  21. data/lib/bundler/graph.rb +130 -0
  22. data/lib/bundler/index.rb +131 -0
  23. data/lib/bundler/installer.rb +117 -0
  24. data/lib/bundler/lazy_specification.rb +71 -0
  25. data/lib/bundler/lockfile_parser.rb +108 -0
  26. data/lib/bundler/remote_specification.rb +57 -0
  27. data/lib/bundler/resolver.rb +470 -0
  28. data/lib/bundler/rubygems_ext.rb +226 -0
  29. data/lib/bundler/runtime.rb +201 -0
  30. data/lib/bundler/settings.rb +117 -0
  31. data/lib/bundler/setup.rb +16 -0
  32. data/lib/bundler/shared_helpers.rb +167 -0
  33. data/lib/bundler/source.rb +675 -0
  34. data/lib/bundler/spec_set.rb +134 -0
  35. data/lib/bundler/templates/Executable +16 -0
  36. data/lib/bundler/templates/Gemfile +4 -0
  37. data/lib/bundler/templates/newgem/Gemfile.tt +4 -0
  38. data/lib/bundler/templates/newgem/Rakefile.tt +2 -0
  39. data/lib/bundler/templates/newgem/bin/newgem.tt +3 -0
  40. data/lib/bundler/templates/newgem/gitignore.tt +4 -0
  41. data/lib/bundler/templates/newgem/lib/newgem.rb.tt +7 -0
  42. data/lib/bundler/templates/newgem/lib/newgem/version.rb.tt +7 -0
  43. data/lib/bundler/templates/newgem/newgem.gemspec.tt +21 -0
  44. data/lib/bundler/ui.rb +73 -0
  45. data/lib/bundler/vendor/net/http/faster.rb +27 -0
  46. data/lib/bundler/vendor/net/http/persistent.rb +464 -0
  47. data/lib/bundler/vendor/thor.rb +319 -0
  48. data/lib/bundler/vendor/thor/actions.rb +297 -0
  49. data/lib/bundler/vendor/thor/actions/create_file.rb +105 -0
  50. data/lib/bundler/vendor/thor/actions/directory.rb +93 -0
  51. data/lib/bundler/vendor/thor/actions/empty_directory.rb +134 -0
  52. data/lib/bundler/vendor/thor/actions/file_manipulation.rb +229 -0
  53. data/lib/bundler/vendor/thor/actions/inject_into_file.rb +104 -0
  54. data/lib/bundler/vendor/thor/base.rb +556 -0
  55. data/lib/bundler/vendor/thor/core_ext/file_binary_read.rb +9 -0
  56. data/lib/bundler/vendor/thor/core_ext/hash_with_indifferent_access.rb +75 -0
  57. data/lib/bundler/vendor/thor/core_ext/ordered_hash.rb +100 -0
  58. data/lib/bundler/vendor/thor/error.rb +30 -0
  59. data/lib/bundler/vendor/thor/invocation.rb +168 -0
  60. data/lib/bundler/vendor/thor/parser.rb +4 -0
  61. data/lib/bundler/vendor/thor/parser/argument.rb +67 -0
  62. data/lib/bundler/vendor/thor/parser/arguments.rb +161 -0
  63. data/lib/bundler/vendor/thor/parser/option.rb +120 -0
  64. data/lib/bundler/vendor/thor/parser/options.rb +174 -0
  65. data/lib/bundler/vendor/thor/shell.rb +88 -0
  66. data/lib/bundler/vendor/thor/shell/basic.rb +275 -0
  67. data/lib/bundler/vendor/thor/shell/color.rb +108 -0
  68. data/lib/bundler/vendor/thor/shell/html.rb +121 -0
  69. data/lib/bundler/vendor/thor/task.rb +114 -0
  70. data/lib/bundler/vendor/thor/util.rb +229 -0
  71. data/lib/bundler/vendor/thor/version.rb +3 -0
  72. data/lib/bundler/version.rb +6 -0
  73. data/lib/bundler/vlad.rb +9 -0
  74. data/man/bundle-config.ronn +90 -0
  75. data/man/bundle-exec.ronn +111 -0
  76. data/man/bundle-install.ronn +314 -0
  77. data/man/bundle-package.ronn +59 -0
  78. data/man/bundle-update.ronn +176 -0
  79. data/man/bundle.ronn +80 -0
  80. data/man/gemfile.5.ronn +279 -0
  81. data/man/index.txt +6 -0
  82. data/spec/cache/gems_spec.rb +219 -0
  83. data/spec/cache/git_spec.rb +9 -0
  84. data/spec/cache/path_spec.rb +27 -0
  85. data/spec/cache/platform_spec.rb +57 -0
  86. data/spec/install/deploy_spec.rb +197 -0
  87. data/spec/install/deprecated_spec.rb +37 -0
  88. data/spec/install/gems/c_ext_spec.rb +48 -0
  89. data/spec/install/gems/dependency_api_spec.rb +85 -0
  90. data/spec/install/gems/env_spec.rb +107 -0
  91. data/spec/install/gems/flex_spec.rb +313 -0
  92. data/spec/install/gems/groups_spec.rb +245 -0
  93. data/spec/install/gems/packed_spec.rb +84 -0
  94. data/spec/install/gems/platform_spec.rb +208 -0
  95. data/spec/install/gems/resolving_spec.rb +72 -0
  96. data/spec/install/gems/simple_case_spec.rb +715 -0
  97. data/spec/install/gems/standalone_spec.rb +162 -0
  98. data/spec/install/gems/sudo_spec.rb +73 -0
  99. data/spec/install/gems/win32_spec.rb +26 -0
  100. data/spec/install/gemspec_spec.rb +108 -0
  101. data/spec/install/git_spec.rb +571 -0
  102. data/spec/install/invalid_spec.rb +17 -0
  103. data/spec/install/path_spec.rb +353 -0
  104. data/spec/install/upgrade_spec.rb +26 -0
  105. data/spec/lock/git_spec.rb +35 -0
  106. data/spec/lock/lockfile_spec.rb +683 -0
  107. data/spec/other/check_spec.rb +221 -0
  108. data/spec/other/clean_spec.rb +202 -0
  109. data/spec/other/config_spec.rb +40 -0
  110. data/spec/other/console_spec.rb +54 -0
  111. data/spec/other/exec_spec.rb +241 -0
  112. data/spec/other/ext_spec.rb +16 -0
  113. data/spec/other/gem_helper_spec.rb +128 -0
  114. data/spec/other/help_spec.rb +38 -0
  115. data/spec/other/init_spec.rb +40 -0
  116. data/spec/other/newgem_spec.rb +24 -0
  117. data/spec/other/open_spec.rb +35 -0
  118. data/spec/other/show_spec.rb +82 -0
  119. data/spec/pack/gems_spec.rb +54 -0
  120. data/spec/quality_spec.rb +58 -0
  121. data/spec/resolver/basic_spec.rb +20 -0
  122. data/spec/resolver/platform_spec.rb +82 -0
  123. data/spec/runtime/executable_spec.rb +110 -0
  124. data/spec/runtime/load_spec.rb +107 -0
  125. data/spec/runtime/platform_spec.rb +90 -0
  126. data/spec/runtime/require_spec.rb +231 -0
  127. data/spec/runtime/setup_spec.rb +688 -0
  128. data/spec/runtime/with_clean_env_spec.rb +15 -0
  129. data/spec/spec_helper.rb +85 -0
  130. data/spec/support/artifice/endpoint.rb +50 -0
  131. data/spec/support/artifice/endpoint_fallback.rb +22 -0
  132. data/spec/support/artifice/endpoint_marshal_fail.rb +11 -0
  133. data/spec/support/artifice/endpoint_redirect.rb +11 -0
  134. data/spec/support/builders.rb +574 -0
  135. data/spec/support/fakeweb/rack-1.0.0.marshal +2 -0
  136. data/spec/support/fakeweb/windows.rb +23 -0
  137. data/spec/support/helpers.rb +246 -0
  138. data/spec/support/indexes.rb +112 -0
  139. data/spec/support/matchers.rb +89 -0
  140. data/spec/support/path.rb +73 -0
  141. data/spec/support/platforms.rb +53 -0
  142. data/spec/support/ruby_ext.rb +20 -0
  143. data/spec/support/rubygems_ext.rb +35 -0
  144. data/spec/support/rubygems_hax/platform.rb +11 -0
  145. data/spec/support/sudo.rb +21 -0
  146. data/spec/update/gems_spec.rb +121 -0
  147. data/spec/update/git_spec.rb +196 -0
  148. data/spec/update/source_spec.rb +51 -0
  149. metadata +294 -0
@@ -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,131 @@
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)
82
+ return unless other
83
+ other.each do |s|
84
+ next if search_by_spec(s).any?
85
+ @specs[s.name] << s
86
+ end
87
+ self
88
+ end
89
+
90
+ def ==(o)
91
+ all? do |s|
92
+ s2 = o[s].first and (s.dependencies & s2.dependencies).empty?
93
+ end
94
+ end
95
+
96
+ private
97
+
98
+ def search_by_spec(spec)
99
+ @specs[spec.name].select do |s|
100
+ same_version?(s.version, spec.version) && Gem::Platform.new(s.platform) == Gem::Platform.new(spec.platform)
101
+ end
102
+ end
103
+
104
+ def same_version?(a, b)
105
+ regex = /^(.*?)(?:\.0)*$/
106
+
107
+ a.to_s[regex, 1] == b.to_s[regex, 1]
108
+ end
109
+
110
+ def spec_satisfies_dependency?(spec, dep)
111
+ return false unless dep.name === spec.name
112
+ dep.requirement.satisfied_by?(spec.version)
113
+ end
114
+
115
+ def search_by_dependency(dependency)
116
+ @cache[dependency.hash] ||= begin
117
+ specs = @specs[dependency.name]
118
+
119
+ wants_prerelease = dependency.requirement.prerelease?
120
+ only_prerelease = specs.all? {|spec| spec.version.prerelease? }
121
+ found = specs.select { |spec| dependency.matches_spec?(spec) && Gem::Platform.match(spec.platform) }
122
+
123
+ unless wants_prerelease || only_prerelease
124
+ found.reject! { |spec| spec.version.prerelease? }
125
+ end
126
+
127
+ found.sort_by {|s| [s.version, s.platform.to_s == 'ruby' ? "\0" : s.platform.to_s] }
128
+ end
129
+ end
130
+ end
131
+ end
@@ -0,0 +1,117 @@
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
+ if Bundler.settings[:frozen]
14
+ @definition.ensure_equivalent_gemfile_and_lockfile
15
+ end
16
+
17
+ if dependencies.empty?
18
+ Bundler.ui.warn "The Gemfile specifies no dependencies"
19
+ return
20
+ end
21
+
22
+ if Bundler.default_lockfile.exist? && !options["update"]
23
+ begin
24
+ tmpdef = Definition.build(Bundler.default_gemfile, Bundler.default_lockfile, nil)
25
+ local = true unless tmpdef.new_platform? || tmpdef.missing_specs.any?
26
+ rescue BundlerError
27
+ end
28
+ end
29
+
30
+ # Since we are installing, we can resolve the definition
31
+ # using remote specs
32
+ unless local
33
+ options["local"] ?
34
+ @definition.resolve_with_cache! :
35
+ @definition.resolve_remotely!
36
+ end
37
+
38
+ # Ensure that BUNDLE_PATH exists
39
+ Bundler.mkdir_p(Bundler.bundle_path) unless File.exist?(Bundler.bundle_path)
40
+
41
+ # Must install gems in the order that the resolver provides
42
+ # as dependencies might actually affect the installation of
43
+ # the gem.
44
+ specs.each do |spec|
45
+ spec.source.fetch(spec) if spec.source.respond_to?(:fetch)
46
+
47
+ # unless requested_specs.include?(spec)
48
+ # Bundler.ui.debug " * Not in requested group; skipping."
49
+ # next
50
+ # end
51
+
52
+ begin
53
+ old_args = Gem::Command.build_args
54
+ Gem::Command.build_args = [Bundler.settings["build.#{spec.name}"]]
55
+ spec.source.install(spec)
56
+ 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
+ generate_standalone(options[:standalone]) if options[:standalone]
68
+ end
69
+
70
+ private
71
+
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
85
+
86
+ def generate_standalone(groups)
87
+ path = Bundler.settings[:path]
88
+ bundler_path = File.join(path, "bundler")
89
+ FileUtils.mkdir_p(bundler_path)
90
+
91
+ paths = []
92
+
93
+ if groups.empty?
94
+ specs = Bundler.definition.requested_specs
95
+ else
96
+ specs = Bundler.definition.specs_for groups.map { |g| g.to_sym }
97
+ end
98
+
99
+ specs.each do |spec|
100
+ next if spec.name == "bundler"
101
+
102
+ spec.require_paths.each do |path|
103
+ full_path = File.join(spec.full_gem_path, path)
104
+ paths << Pathname.new(full_path).relative_path_from(Bundler.root.join("bundle/bundler"))
105
+ end
106
+ end
107
+
108
+
109
+ File.open File.join(bundler_path, "setup.rb"), "w" do |file|
110
+ file.puts "path = File.expand_path('..', __FILE__)"
111
+ paths.each do |path|
112
+ file.puts %{$:.unshift File.expand_path("\#{path}/#{path}")}
113
+ end
114
+ end
115
+ end
116
+ end
117
+ end
@@ -0,0 +1,71 @@
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.name }.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 method_missing(method, *args, &blk)
62
+ if Gem::Specification.new.respond_to?(method)
63
+ raise "LazySpecification has not been materialized yet (calling :#{method} #{args.inspect})" unless @specification
64
+ @specification.send(method, *args, &blk)
65
+ else
66
+ super
67
+ end
68
+ end
69
+
70
+ end
71
+ end