honkster-bundler 1.1.pre

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) hide show
  1. data/.gitignore +14 -0
  2. data/CHANGELOG.md +547 -0
  3. data/ISSUES.md +32 -0
  4. data/LICENSE +20 -0
  5. data/README.md +29 -0
  6. data/Rakefile +150 -0
  7. data/UPGRADING.md +103 -0
  8. data/bin/bundle +21 -0
  9. data/bundler.gemspec +30 -0
  10. data/lib/bundler.rb +268 -0
  11. data/lib/bundler/capistrano.rb +11 -0
  12. data/lib/bundler/cli.rb +515 -0
  13. data/lib/bundler/definition.rb +427 -0
  14. data/lib/bundler/dependency.rb +114 -0
  15. data/lib/bundler/deployment.rb +37 -0
  16. data/lib/bundler/dsl.rb +245 -0
  17. data/lib/bundler/environment.rb +47 -0
  18. data/lib/bundler/gem_helper.rb +145 -0
  19. data/lib/bundler/graph.rb +130 -0
  20. data/lib/bundler/index.rb +114 -0
  21. data/lib/bundler/installer.rb +84 -0
  22. data/lib/bundler/lazy_specification.rb +71 -0
  23. data/lib/bundler/lockfile_parser.rb +108 -0
  24. data/lib/bundler/remote_specification.rb +59 -0
  25. data/lib/bundler/resolver.rb +454 -0
  26. data/lib/bundler/rubygems_ext.rb +203 -0
  27. data/lib/bundler/runtime.rb +148 -0
  28. data/lib/bundler/settings.rb +117 -0
  29. data/lib/bundler/setup.rb +15 -0
  30. data/lib/bundler/shared_helpers.rb +151 -0
  31. data/lib/bundler/source.rb +662 -0
  32. data/lib/bundler/spec_set.rb +134 -0
  33. data/lib/bundler/templates/Executable +16 -0
  34. data/lib/bundler/templates/Gemfile +4 -0
  35. data/lib/bundler/templates/newgem/Gemfile.tt +4 -0
  36. data/lib/bundler/templates/newgem/Rakefile.tt +2 -0
  37. data/lib/bundler/templates/newgem/bin/newgem.tt +3 -0
  38. data/lib/bundler/templates/newgem/gitignore.tt +3 -0
  39. data/lib/bundler/templates/newgem/lib/newgem.rb.tt +7 -0
  40. data/lib/bundler/templates/newgem/lib/newgem/version.rb.tt +7 -0
  41. data/lib/bundler/templates/newgem/newgem.gemspec.tt +21 -0
  42. data/lib/bundler/ui.rb +60 -0
  43. data/lib/bundler/vendor/thor.rb +319 -0
  44. data/lib/bundler/vendor/thor/actions.rb +297 -0
  45. data/lib/bundler/vendor/thor/actions/create_file.rb +105 -0
  46. data/lib/bundler/vendor/thor/actions/directory.rb +93 -0
  47. data/lib/bundler/vendor/thor/actions/empty_directory.rb +134 -0
  48. data/lib/bundler/vendor/thor/actions/file_manipulation.rb +229 -0
  49. data/lib/bundler/vendor/thor/actions/inject_into_file.rb +104 -0
  50. data/lib/bundler/vendor/thor/base.rb +556 -0
  51. data/lib/bundler/vendor/thor/core_ext/file_binary_read.rb +9 -0
  52. data/lib/bundler/vendor/thor/core_ext/hash_with_indifferent_access.rb +75 -0
  53. data/lib/bundler/vendor/thor/core_ext/ordered_hash.rb +100 -0
  54. data/lib/bundler/vendor/thor/error.rb +30 -0
  55. data/lib/bundler/vendor/thor/invocation.rb +168 -0
  56. data/lib/bundler/vendor/thor/parser.rb +4 -0
  57. data/lib/bundler/vendor/thor/parser/argument.rb +67 -0
  58. data/lib/bundler/vendor/thor/parser/arguments.rb +161 -0
  59. data/lib/bundler/vendor/thor/parser/option.rb +120 -0
  60. data/lib/bundler/vendor/thor/parser/options.rb +174 -0
  61. data/lib/bundler/vendor/thor/shell.rb +88 -0
  62. data/lib/bundler/vendor/thor/shell/basic.rb +275 -0
  63. data/lib/bundler/vendor/thor/shell/color.rb +108 -0
  64. data/lib/bundler/vendor/thor/shell/html.rb +121 -0
  65. data/lib/bundler/vendor/thor/task.rb +114 -0
  66. data/lib/bundler/vendor/thor/util.rb +229 -0
  67. data/lib/bundler/vendor/thor/version.rb +3 -0
  68. data/lib/bundler/version.rb +6 -0
  69. data/lib/bundler/vlad.rb +9 -0
  70. data/man/bundle-config.ronn +90 -0
  71. data/man/bundle-exec.ronn +98 -0
  72. data/man/bundle-install.ronn +310 -0
  73. data/man/bundle-package.ronn +59 -0
  74. data/man/bundle-update.ronn +176 -0
  75. data/man/bundle.ronn +77 -0
  76. data/man/gemfile.5.ronn +273 -0
  77. data/man/index.txt +6 -0
  78. data/spec/cache/gems_spec.rb +205 -0
  79. data/spec/cache/git_spec.rb +9 -0
  80. data/spec/cache/path_spec.rb +27 -0
  81. data/spec/cache/platform_spec.rb +57 -0
  82. data/spec/install/deploy_spec.rb +197 -0
  83. data/spec/install/deprecated_spec.rb +43 -0
  84. data/spec/install/gems/c_ext_spec.rb +48 -0
  85. data/spec/install/gems/env_spec.rb +107 -0
  86. data/spec/install/gems/flex_spec.rb +272 -0
  87. data/spec/install/gems/groups_spec.rb +228 -0
  88. data/spec/install/gems/packed_spec.rb +72 -0
  89. data/spec/install/gems/platform_spec.rb +195 -0
  90. data/spec/install/gems/resolving_spec.rb +72 -0
  91. data/spec/install/gems/simple_case_spec.rb +749 -0
  92. data/spec/install/gems/sudo_spec.rb +77 -0
  93. data/spec/install/gems/win32_spec.rb +26 -0
  94. data/spec/install/gemspec_spec.rb +96 -0
  95. data/spec/install/git_spec.rb +553 -0
  96. data/spec/install/invalid_spec.rb +17 -0
  97. data/spec/install/path_spec.rb +329 -0
  98. data/spec/install/upgrade_spec.rb +26 -0
  99. data/spec/lock/flex_spec.rb +650 -0
  100. data/spec/lock/git_spec.rb +35 -0
  101. data/spec/other/check_spec.rb +221 -0
  102. data/spec/other/config_spec.rb +40 -0
  103. data/spec/other/console_spec.rb +54 -0
  104. data/spec/other/exec_spec.rb +241 -0
  105. data/spec/other/ext_spec.rb +16 -0
  106. data/spec/other/gem_helper_spec.rb +126 -0
  107. data/spec/other/help_spec.rb +36 -0
  108. data/spec/other/init_spec.rb +40 -0
  109. data/spec/other/newgem_spec.rb +24 -0
  110. data/spec/other/open_spec.rb +35 -0
  111. data/spec/other/show_spec.rb +82 -0
  112. data/spec/pack/gems_spec.rb +22 -0
  113. data/spec/quality_spec.rb +55 -0
  114. data/spec/resolver/basic_spec.rb +20 -0
  115. data/spec/resolver/platform_spec.rb +57 -0
  116. data/spec/runtime/environment_rb_spec.rb +162 -0
  117. data/spec/runtime/executable_spec.rb +110 -0
  118. data/spec/runtime/load_spec.rb +102 -0
  119. data/spec/runtime/platform_spec.rb +90 -0
  120. data/spec/runtime/require_spec.rb +231 -0
  121. data/spec/runtime/setup_spec.rb +412 -0
  122. data/spec/runtime/with_clean_env_spec.rb +15 -0
  123. data/spec/spec_helper.rb +82 -0
  124. data/spec/support/builders.rb +566 -0
  125. data/spec/support/helpers.rb +243 -0
  126. data/spec/support/indexes.rb +113 -0
  127. data/spec/support/matchers.rb +89 -0
  128. data/spec/support/path.rb +71 -0
  129. data/spec/support/platforms.rb +49 -0
  130. data/spec/support/ruby_ext.rb +19 -0
  131. data/spec/support/rubygems_ext.rb +30 -0
  132. data/spec/support/rubygems_hax/rubygems_plugin.rb +9 -0
  133. data/spec/support/sudo.rb +21 -0
  134. data/spec/update/gems_spec.rb +112 -0
  135. data/spec/update/git_spec.rb +159 -0
  136. data/spec/update/source_spec.rb +50 -0
  137. metadata +251 -0
@@ -0,0 +1,203 @@
1
+ require 'pathname'
2
+
3
+ if defined?(Gem::QuickLoader)
4
+ # Gem Prelude makes me a sad panda :'(
5
+ Gem::QuickLoader.load_full_rubygems_library
6
+ end
7
+
8
+ require 'rubygems'
9
+ require 'rubygems/specification'
10
+
11
+ module Gem
12
+ @loaded_stacks = Hash.new { |h,k| h[k] = [] }
13
+
14
+ class Specification
15
+ attr_accessor :source, :location, :relative_loaded_from
16
+
17
+ alias_method :rg_full_gem_path, :full_gem_path
18
+ alias_method :rg_loaded_from, :loaded_from
19
+
20
+ def full_gem_path
21
+ source.respond_to?(:path) ?
22
+ Pathname.new(loaded_from).dirname.expand_path.to_s :
23
+ rg_full_gem_path
24
+ end
25
+
26
+ def loaded_from
27
+ relative_loaded_from ?
28
+ source.path.join(relative_loaded_from).to_s :
29
+ rg_loaded_from
30
+ end
31
+
32
+ def load_paths
33
+ require_paths.map do |require_path|
34
+ if require_path.include?(full_gem_path)
35
+ require_path
36
+ else
37
+ File.join(full_gem_path, require_path)
38
+ end
39
+ end
40
+ end
41
+
42
+ def groups
43
+ @groups ||= []
44
+ end
45
+
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
52
+
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
62
+
63
+ def nondevelopment_dependencies
64
+ dependencies - development_dependencies
65
+ end
66
+
67
+ def add_bundler_dependencies(*groups)
68
+ Bundler.ui.warn "#add_bundler_dependencies is deprecated and will " \
69
+ "be removed in Bundler 1.0. Instead, please use the #gemspec method " \
70
+ "in your Gemfile, which will pull in any dependencies specified in " \
71
+ "your gemspec"
72
+
73
+ groups = [:default] if groups.empty?
74
+ Bundler.definition.dependencies.each do |dep|
75
+ if dep.groups.include?(:development)
76
+ self.add_development_dependency(dep.name, dep.requirement.to_s)
77
+ elsif (dep.groups & groups).any?
78
+ self.add_dependency(dep.name, dep.requirement.to_s)
79
+ end
80
+ end
81
+ end
82
+
83
+ private
84
+
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
100
+
101
+ end
102
+
103
+ class Dependency
104
+ attr_accessor :source, :groups
105
+
106
+ alias eql? ==
107
+
108
+ def to_yaml_properties
109
+ instance_variables.reject { |p| ["@source", "@groups"].include?(p.to_s) }
110
+ end
111
+
112
+ def to_lock
113
+ out = " #{name}"
114
+ unless requirement == Gem::Requirement.default
115
+ out << " (#{requirement.to_s})"
116
+ end
117
+ out
118
+ end
119
+ end
120
+
121
+ class Platform
122
+ JAVA = Gem::Platform.new('java')
123
+ MSWIN = Gem::Platform.new('mswin32')
124
+ MING = Gem::Platform.new('x86-mingw32')
125
+
126
+ def hash
127
+ @cpu.hash ^ @os.hash ^ @version.hash
128
+ end
129
+
130
+ alias eql? ==
131
+ end
132
+ end
133
+
134
+ module Bundler
135
+ class DepProxy
136
+
137
+ attr_reader :required_by, :__platform, :dep
138
+
139
+ def initialize(dep, platform)
140
+ @dep, @__platform, @required_by = dep, platform, []
141
+ end
142
+
143
+ def hash
144
+ @hash ||= dep.hash
145
+ end
146
+
147
+ def ==(o)
148
+ dep == o.dep && __platform == o.__platform
149
+ end
150
+
151
+ alias eql? ==
152
+
153
+ def type
154
+ @dep.type
155
+ end
156
+
157
+ def to_s
158
+ @dep.to_s
159
+ end
160
+
161
+ private
162
+
163
+ def method_missing(*args)
164
+ @dep.send(*args)
165
+ end
166
+
167
+ end
168
+
169
+ module GemHelpers
170
+
171
+ GENERIC_CACHE = {}
172
+ GENERICS = [
173
+ Gem::Platform::JAVA,
174
+ Gem::Platform::MSWIN,
175
+ Gem::Platform::MING,
176
+ Gem::Platform::RUBY
177
+ ]
178
+
179
+ def generic(p)
180
+ if p == Gem::Platform::RUBY
181
+ return p
182
+ end
183
+
184
+ GENERIC_CACHE[p] ||= GENERICS.find { |p2| p =~ p2 } || Gem::Platform::RUBY
185
+ end
186
+ end
187
+
188
+ module MatchPlatform
189
+ include GemHelpers
190
+
191
+ def match_platform(p)
192
+ Gem::Platform::RUBY == platform or
193
+ platform.nil? or p == platform or
194
+ generic(Gem::Platform.new(platform)) == p
195
+ end
196
+ end
197
+ end
198
+
199
+ module Gem
200
+ class Specification
201
+ include Bundler::MatchPlatform
202
+ end
203
+ end
@@ -0,0 +1,148 @@
1
+ require "digest/sha1"
2
+
3
+ module Bundler
4
+ class Runtime < Environment
5
+ include SharedHelpers
6
+
7
+ def setup(*groups)
8
+ # Has to happen first
9
+ clean_load_path
10
+
11
+ specs = groups.any? ? @definition.specs_for(groups) : requested_specs
12
+
13
+ setup_environment
14
+ cripple_rubygems(specs)
15
+
16
+ # Activate the specs
17
+ specs.each do |spec|
18
+ unless spec.loaded_from
19
+ raise GemNotFound, "#{spec.full_name} is missing. Run `bundle` to get it."
20
+ end
21
+
22
+ if activated_spec = Gem.loaded_specs[spec.name] and activated_spec.version != spec.version
23
+ e = Gem::LoadError.new "You have already activated #{activated_spec.name} #{activated_spec.version}, " \
24
+ "but your Gemfile requires #{spec.name} #{spec.version}. Consider using bundle exec."
25
+ e.name = spec.name
26
+ e.version_requirement = Gem::Requirement.new(spec.version.to_s)
27
+ raise e
28
+ end
29
+
30
+ Gem.loaded_specs[spec.name] = spec
31
+ load_paths = spec.load_paths.reject {|path| $LOAD_PATH.include?(path)}
32
+ $LOAD_PATH.unshift(*load_paths)
33
+ end
34
+
35
+ lock
36
+
37
+ self
38
+ end
39
+
40
+ REGEXPS = [
41
+ /^no such file to load -- (.+)$/i,
42
+ /^Missing \w+ (?:file\s*)?([^\s]+.rb)$/i,
43
+ /^Missing API definition file in (.+)$/i,
44
+ /^cannot load such file -- (.+)$/i,
45
+ ]
46
+
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
72
+
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
80
+
81
+ alias gems specs
82
+
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
93
+
94
+ def prune_cache
95
+ FileUtils.mkdir_p(cache_path)
96
+
97
+ resolve = @definition.resolve
98
+ cached = Dir["#{cache_path}/*.gem"]
99
+
100
+ cached = cached.delete_if do |path|
101
+ spec = Gem::Format.from_file_by_path(path).spec
102
+
103
+ resolve.any? do |s|
104
+ s.name == spec.name && s.version == spec.version
105
+ end
106
+ end
107
+
108
+ if cached.any?
109
+ Bundler.ui.info "Removing outdated .gem files from vendor/cache"
110
+
111
+ cached.each do |path|
112
+ Bundler.ui.info " * #{File.basename(path)}"
113
+ File.delete(path)
114
+ end
115
+ end
116
+ end
117
+
118
+ private
119
+
120
+ def cache_path
121
+ root.join("vendor/cache")
122
+ end
123
+
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
147
+ end
148
+ end
@@ -0,0 +1,117 @@
1
+ module Bundler
2
+ class Settings
3
+ def initialize(root)
4
+ @root = root
5
+ @local_config = File.exist?(local_config_file) ? YAML.load_file(local_config_file) : {}
6
+ @global_config = File.exist?(global_config_file) ? YAML.load_file(global_config_file) : {}
7
+ end
8
+
9
+ def [](key)
10
+ key = key_for(key)
11
+ @local_config[key] || ENV[key] || @global_config[key]
12
+ end
13
+
14
+ def []=(key, value)
15
+ set_key(key, value, @local_config, local_config_file)
16
+ end
17
+
18
+ def delete(key)
19
+ @local_config
20
+ end
21
+
22
+ def set_global(key, value)
23
+ set_key(key, value, @global_config, global_config_file)
24
+ end
25
+
26
+ def all
27
+ env_keys = ENV.keys.select { |k| k =~ /BUNDLE_.*/ }
28
+ keys = @global_config.keys | @local_config.keys | env_keys
29
+
30
+ keys.map do |key|
31
+ key.sub(/^BUNDLE_/, '').gsub(/__/, ".").downcase
32
+ end
33
+ end
34
+
35
+ def locations(key)
36
+ locations = {}
37
+
38
+ locations[:local] = @local_config[key] if @local_config.key?(key)
39
+ locations[:env] = ENV[key] if ENV[key]
40
+ locations[:global] = @global_config[key] if @global_config.key?(key)
41
+ locations
42
+ end
43
+
44
+ def pretty_values_for(exposed_key)
45
+ key = key_for(exposed_key)
46
+
47
+ locations = []
48
+ if @local_config.key?(key)
49
+ locations << "Set for your local app (#{local_config_file}): #{@local_config[key].inspect}"
50
+ end
51
+
52
+ if value = ENV[key]
53
+ locations << "Set via #{key}: #{value.inspect}"
54
+ end
55
+
56
+ if @global_config.key?(key)
57
+ locations << "Set for the current user (#{global_config_file}): #{@global_config[key].inspect}"
58
+ end
59
+
60
+ return ["You have not configured a value for `#{exposed_key}`"] if locations.empty?
61
+ locations
62
+ end
63
+
64
+ def without=(array)
65
+ unless array.empty?
66
+ self[:without] = array.join(":")
67
+ end
68
+ end
69
+
70
+ def without
71
+ self[:without] ? self[:without].split(":").map { |w| w.to_sym } : []
72
+ end
73
+
74
+ # @local_config["BUNDLE_PATH"] should be prioritized over ENV["BUNDLE_PATH"]
75
+ def path
76
+ path = ENV[key_for(:path)] || @global_config[key_for(:path)]
77
+ return path if path && !@local_config.key?(key_for(:path))
78
+
79
+ if path = self[:path]
80
+ "#{path}/#{Bundler.ruby_scope}"
81
+ else
82
+ Gem.dir
83
+ end
84
+ end
85
+
86
+ def allow_sudo?
87
+ !@local_config.key?(key_for(:path))
88
+ end
89
+
90
+ private
91
+ def key_for(key)
92
+ key = key.to_s.sub(".", "__").upcase
93
+ "BUNDLE_#{key}"
94
+ end
95
+
96
+ def set_key(key, value, hash, file)
97
+ key = key_for(key)
98
+
99
+ unless hash[key] == value
100
+ hash[key] = value
101
+ hash.delete(key) if value.nil?
102
+ FileUtils.mkdir_p(file.dirname)
103
+ File.open(file, "w") { |f| f.puts hash.to_yaml }
104
+ end
105
+ value
106
+ end
107
+
108
+ def global_config_file
109
+ file = ENV["BUNDLE_CONFIG"] || File.join(Gem.user_home, ".bundle/config")
110
+ Pathname.new(file)
111
+ end
112
+
113
+ def local_config_file
114
+ Pathname.new("#{@root}/config")
115
+ end
116
+ end
117
+ end