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
+ class File #:nodoc:
2
+
3
+ unless File.respond_to?(:binread)
4
+ def self.binread(file)
5
+ File.open(file, 'rb') { |f| f.read }
6
+ end
7
+ end
8
+
9
+ end
@@ -0,0 +1,75 @@
1
+ class Thor
2
+ module CoreExt #:nodoc:
3
+
4
+ # A hash with indifferent access and magic predicates.
5
+ #
6
+ # hash = Thor::CoreExt::HashWithIndifferentAccess.new 'foo' => 'bar', 'baz' => 'bee', 'force' => true
7
+ #
8
+ # hash[:foo] #=> 'bar'
9
+ # hash['foo'] #=> 'bar'
10
+ # hash.foo? #=> true
11
+ #
12
+ class HashWithIndifferentAccess < ::Hash #:nodoc:
13
+
14
+ def initialize(hash={})
15
+ super()
16
+ hash.each do |key, value|
17
+ self[convert_key(key)] = value
18
+ end
19
+ end
20
+
21
+ def [](key)
22
+ super(convert_key(key))
23
+ end
24
+
25
+ def []=(key, value)
26
+ super(convert_key(key), value)
27
+ end
28
+
29
+ def delete(key)
30
+ super(convert_key(key))
31
+ end
32
+
33
+ def values_at(*indices)
34
+ indices.collect { |key| self[convert_key(key)] }
35
+ end
36
+
37
+ def merge(other)
38
+ dup.merge!(other)
39
+ end
40
+
41
+ def merge!(other)
42
+ other.each do |key, value|
43
+ self[convert_key(key)] = value
44
+ end
45
+ self
46
+ end
47
+
48
+ protected
49
+
50
+ def convert_key(key)
51
+ key.is_a?(Symbol) ? key.to_s : key
52
+ end
53
+
54
+ # Magic predicates. For instance:
55
+ #
56
+ # options.force? # => !!options['force']
57
+ # options.shebang # => "/usr/lib/local/ruby"
58
+ # options.test_framework?(:rspec) # => options[:test_framework] == :rspec
59
+ #
60
+ def method_missing(method, *args, &block)
61
+ method = method.to_s
62
+ if method =~ /^(\w+)\?$/
63
+ if args.empty?
64
+ !!self[$1]
65
+ else
66
+ self[$1] == args.first
67
+ end
68
+ else
69
+ self[method]
70
+ end
71
+ end
72
+
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,100 @@
1
+ class Thor
2
+ module CoreExt #:nodoc:
3
+
4
+ if RUBY_VERSION >= '1.9'
5
+ class OrderedHash < ::Hash
6
+ end
7
+ else
8
+ # This class is based on the Ruby 1.9 ordered hashes.
9
+ #
10
+ # It keeps the semantics and most of the efficiency of normal hashes
11
+ # while also keeping track of the order in which elements were set.
12
+ #
13
+ class OrderedHash #:nodoc:
14
+ include Enumerable
15
+
16
+ Node = Struct.new(:key, :value, :next, :prev)
17
+
18
+ def initialize
19
+ @hash = {}
20
+ end
21
+
22
+ def [](key)
23
+ @hash[key] && @hash[key].value
24
+ end
25
+
26
+ def []=(key, value)
27
+ if node = @hash[key]
28
+ node.value = value
29
+ else
30
+ node = Node.new(key, value)
31
+
32
+ if @first.nil?
33
+ @first = @last = node
34
+ else
35
+ node.prev = @last
36
+ @last.next = node
37
+ @last = node
38
+ end
39
+ end
40
+
41
+ @hash[key] = node
42
+ value
43
+ end
44
+
45
+ def delete(key)
46
+ if node = @hash[key]
47
+ prev_node = node.prev
48
+ next_node = node.next
49
+
50
+ next_node.prev = prev_node if next_node
51
+ prev_node.next = next_node if prev_node
52
+
53
+ @first = next_node if @first == node
54
+ @last = prev_node if @last == node
55
+
56
+ value = node.value
57
+ end
58
+
59
+ @hash.delete(key)
60
+ value
61
+ end
62
+
63
+ def keys
64
+ self.map { |k, v| k }
65
+ end
66
+
67
+ def values
68
+ self.map { |k, v| v }
69
+ end
70
+
71
+ def each
72
+ return unless @first
73
+ yield [@first.key, @first.value]
74
+ node = @first
75
+ yield [node.key, node.value] while node = node.next
76
+ self
77
+ end
78
+
79
+ def merge(other)
80
+ hash = self.class.new
81
+
82
+ self.each do |key, value|
83
+ hash[key] = value
84
+ end
85
+
86
+ other.each do |key, value|
87
+ hash[key] = value
88
+ end
89
+
90
+ hash
91
+ end
92
+
93
+ def empty?
94
+ @hash.empty?
95
+ end
96
+ end
97
+ end
98
+
99
+ end
100
+ end
@@ -0,0 +1,30 @@
1
+ class Thor
2
+ # Thor::Error is raised when it's caused by wrong usage of thor classes. Those
3
+ # errors have their backtrace supressed and are nicely shown to the user.
4
+ #
5
+ # Errors that are caused by the developer, like declaring a method which
6
+ # overwrites a thor keyword, it SHOULD NOT raise a Thor::Error. This way, we
7
+ # ensure that developer errors are shown with full backtrace.
8
+ #
9
+ class Error < StandardError
10
+ end
11
+
12
+ # Raised when a task was not found.
13
+ #
14
+ class UndefinedTaskError < Error
15
+ end
16
+
17
+ # Raised when a task was found, but not invoked properly.
18
+ #
19
+ class InvocationError < Error
20
+ end
21
+
22
+ class UnknownArgumentError < Error
23
+ end
24
+
25
+ class RequiredArgumentMissingError < InvocationError
26
+ end
27
+
28
+ class MalformattedArgumentError < InvocationError
29
+ end
30
+ end
@@ -0,0 +1,273 @@
1
+ require 'thor/base'
2
+
3
+ # Thor has a special class called Thor::Group. The main difference to Thor class
4
+ # is that it invokes all tasks at once. It also include some methods that allows
5
+ # invocations to be done at the class method, which are not available to Thor
6
+ # tasks.
7
+ class Thor::Group
8
+ class << self
9
+ # The description for this Thor::Group. If none is provided, but a source root
10
+ # exists, tries to find the USAGE one folder above it, otherwise searches
11
+ # in the superclass.
12
+ #
13
+ # ==== Parameters
14
+ # description<String>:: The description for this Thor::Group.
15
+ #
16
+ def desc(description=nil)
17
+ case description
18
+ when nil
19
+ @desc ||= from_superclass(:desc, nil)
20
+ else
21
+ @desc = description
22
+ end
23
+ end
24
+
25
+ # Prints help information.
26
+ #
27
+ # ==== Options
28
+ # short:: When true, shows only usage.
29
+ #
30
+ def help(shell)
31
+ shell.say "Usage:"
32
+ shell.say " #{banner}\n"
33
+ shell.say
34
+ class_options_help(shell)
35
+ shell.say self.desc if self.desc
36
+ end
37
+
38
+ # Stores invocations for this class merging with superclass values.
39
+ #
40
+ def invocations #:nodoc:
41
+ @invocations ||= from_superclass(:invocations, {})
42
+ end
43
+
44
+ # Stores invocation blocks used on invoke_from_option.
45
+ #
46
+ def invocation_blocks #:nodoc:
47
+ @invocation_blocks ||= from_superclass(:invocation_blocks, {})
48
+ end
49
+
50
+ # Invoke the given namespace or class given. It adds an instance
51
+ # method that will invoke the klass and task. You can give a block to
52
+ # configure how it will be invoked.
53
+ #
54
+ # The namespace/class given will have its options showed on the help
55
+ # usage. Check invoke_from_option for more information.
56
+ #
57
+ def invoke(*names, &block)
58
+ options = names.last.is_a?(Hash) ? names.pop : {}
59
+ verbose = options.fetch(:verbose, true)
60
+
61
+ names.each do |name|
62
+ invocations[name] = false
63
+ invocation_blocks[name] = block if block_given?
64
+
65
+ class_eval <<-METHOD, __FILE__, __LINE__
66
+ def _invoke_#{name.to_s.gsub(/\W/, '_')}
67
+ klass, task = self.class.prepare_for_invocation(nil, #{name.inspect})
68
+
69
+ if klass
70
+ say_status :invoke, #{name.inspect}, #{verbose.inspect}
71
+ block = self.class.invocation_blocks[#{name.inspect}]
72
+ _invoke_for_class_method klass, task, &block
73
+ else
74
+ say_status :error, %(#{name.inspect} [not found]), :red
75
+ end
76
+ end
77
+ METHOD
78
+ end
79
+ end
80
+
81
+ # Invoke a thor class based on the value supplied by the user to the
82
+ # given option named "name". A class option must be created before this
83
+ # method is invoked for each name given.
84
+ #
85
+ # ==== Examples
86
+ #
87
+ # class GemGenerator < Thor::Group
88
+ # class_option :test_framework, :type => :string
89
+ # invoke_from_option :test_framework
90
+ # end
91
+ #
92
+ # ==== Boolean options
93
+ #
94
+ # In some cases, you want to invoke a thor class if some option is true or
95
+ # false. This is automatically handled by invoke_from_option. Then the
96
+ # option name is used to invoke the generator.
97
+ #
98
+ # ==== Preparing for invocation
99
+ #
100
+ # In some cases you want to customize how a specified hook is going to be
101
+ # invoked. You can do that by overwriting the class method
102
+ # prepare_for_invocation. The class method must necessarily return a klass
103
+ # and an optional task.
104
+ #
105
+ # ==== Custom invocations
106
+ #
107
+ # You can also supply a block to customize how the option is giong to be
108
+ # invoked. The block receives two parameters, an instance of the current
109
+ # class and the klass to be invoked.
110
+ #
111
+ def invoke_from_option(*names, &block)
112
+ options = names.last.is_a?(Hash) ? names.pop : {}
113
+ verbose = options.fetch(:verbose, :white)
114
+
115
+ names.each do |name|
116
+ unless class_options.key?(name)
117
+ raise ArgumentError, "You have to define the option #{name.inspect} " <<
118
+ "before setting invoke_from_option."
119
+ end
120
+
121
+ invocations[name] = true
122
+ invocation_blocks[name] = block if block_given?
123
+
124
+ class_eval <<-METHOD, __FILE__, __LINE__
125
+ def _invoke_from_option_#{name.to_s.gsub(/\W/, '_')}
126
+ return unless options[#{name.inspect}]
127
+
128
+ value = options[#{name.inspect}]
129
+ value = #{name.inspect} if TrueClass === value
130
+ klass, task = self.class.prepare_for_invocation(#{name.inspect}, value)
131
+
132
+ if klass
133
+ say_status :invoke, value, #{verbose.inspect}
134
+ block = self.class.invocation_blocks[#{name.inspect}]
135
+ _invoke_for_class_method klass, task, &block
136
+ else
137
+ say_status :error, %(\#{value} [not found]), :red
138
+ end
139
+ end
140
+ METHOD
141
+ end
142
+ end
143
+
144
+ # Remove a previously added invocation.
145
+ #
146
+ # ==== Examples
147
+ #
148
+ # remove_invocation :test_framework
149
+ #
150
+ def remove_invocation(*names)
151
+ names.each do |name|
152
+ remove_task(name)
153
+ remove_class_option(name)
154
+ invocations.delete(name)
155
+ invocation_blocks.delete(name)
156
+ end
157
+ end
158
+
159
+ # Overwrite class options help to allow invoked generators options to be
160
+ # shown recursively when invoking a generator.
161
+ #
162
+ def class_options_help(shell, groups={}) #:nodoc:
163
+ get_options_from_invocations(groups, class_options) do |klass|
164
+ klass.send(:get_options_from_invocations, groups, class_options)
165
+ end
166
+ super(shell, groups)
167
+ end
168
+
169
+ # Get invocations array and merge options from invocations. Those
170
+ # options are added to group_options hash. Options that already exists
171
+ # in base_options are not added twice.
172
+ #
173
+ def get_options_from_invocations(group_options, base_options) #:nodoc:
174
+ invocations.each do |name, from_option|
175
+ value = if from_option
176
+ option = class_options[name]
177
+ option.type == :boolean ? name : option.default
178
+ else
179
+ name
180
+ end
181
+ next unless value
182
+
183
+ klass, task = prepare_for_invocation(name, value)
184
+ next unless klass && klass.respond_to?(:class_options)
185
+
186
+ value = value.to_s
187
+ human_name = value.respond_to?(:classify) ? value.classify : value
188
+
189
+ group_options[human_name] ||= []
190
+ group_options[human_name] += klass.class_options.values.select do |option|
191
+ base_options[option.name.to_sym].nil? && option.group.nil? &&
192
+ !group_options.values.flatten.any? { |i| i.name == option.name }
193
+ end
194
+
195
+ yield klass if block_given?
196
+ end
197
+ end
198
+
199
+ # Returns tasks ready to be printed.
200
+ def printable_tasks(*)
201
+ item = []
202
+ item << banner
203
+ item << (desc ? "# #{desc.gsub(/\s+/m,' ')}" : "")
204
+ [item]
205
+ end
206
+
207
+ def handle_argument_error(task, error) #:nodoc:
208
+ raise error, "#{task.name.inspect} was called incorrectly. Are you sure it has arity equals to 0?"
209
+ end
210
+
211
+ protected
212
+
213
+ # The method responsible for dispatching given the args.
214
+ def dispatch(task, given_args, given_opts, config) #:nodoc:
215
+ if Thor::HELP_MAPPINGS.include?(given_args.first)
216
+ help(config[:shell])
217
+ return
218
+ end
219
+
220
+ args, opts = Thor::Options.split(given_args)
221
+ opts = given_opts || opts
222
+
223
+ if task
224
+ new(args, opts, config).invoke_task(all_tasks[task])
225
+ else
226
+ new(args, opts, config).invoke_all
227
+ end
228
+ end
229
+
230
+ # The banner for this class. You can customize it if you are invoking the
231
+ # thor class by another ways which is not the Thor::Runner.
232
+ def banner
233
+ "#{basename} #{self_task.formatted_usage(self, false)}"
234
+ end
235
+
236
+ # Represents the whole class as a task.
237
+ def self_task #:nodoc:
238
+ Thor::DynamicTask.new(self.namespace, class_options)
239
+ end
240
+
241
+ def baseclass #:nodoc:
242
+ Thor::Group
243
+ end
244
+
245
+ def create_task(meth) #:nodoc:
246
+ tasks[meth.to_s] = Thor::Task.new(meth, nil, nil, nil, nil)
247
+ true
248
+ end
249
+ end
250
+
251
+ include Thor::Base
252
+
253
+ protected
254
+
255
+ # Shortcut to invoke with padding and block handling. Use internally by
256
+ # invoke and invoke_from_option class methods.
257
+ def _invoke_for_class_method(klass, task=nil, *args, &block) #:nodoc:
258
+ with_padding do
259
+ if block
260
+ case block.arity
261
+ when 3
262
+ block.call(self, klass, task)
263
+ when 2
264
+ block.call(self, klass)
265
+ when 1
266
+ instance_exec(klass, &block)
267
+ end
268
+ else
269
+ invoke klass, task, *args
270
+ end
271
+ end
272
+ end
273
+ end