bundler 0.9.0.pre5 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of bundler might be problematic. Click here for more details.

@@ -4,7 +4,7 @@ require 'yaml'
4
4
  require 'bundler/rubygems'
5
5
 
6
6
  module Bundler
7
- VERSION = "0.9.0.pre5"
7
+ VERSION = "0.9.0"
8
8
 
9
9
  autoload :Definition, 'bundler/definition'
10
10
  autoload :Dependency, 'bundler/dependency'
@@ -10,16 +10,12 @@ module Bundler
10
10
  class CLI < Thor
11
11
  ARGV = ::ARGV.dup
12
12
 
13
- def self.banner(task)
14
- task.formatted_usage(self, false)
15
- end
16
-
17
13
  desc "init", "Generates a Gemfile into the current working directory"
18
14
  def init
19
15
  if File.exist?("Gemfile")
20
- puts "Gemfile already exists at `#{Dir.pwd}/Gemfile`"
16
+ puts "Gemfile already exists at #{Dir.pwd}/Gemfile"
21
17
  else
22
- puts "Writing new Gemfile to `#{Dir.pwd}/Gemfile`"
18
+ puts "Writing new Gemfile to #{Dir.pwd}/Gemfile"
23
19
  FileUtils.cp(File.expand_path('../templates/Gemfile', __FILE__), 'Gemfile')
24
20
  end
25
21
  end
@@ -97,4 +93,4 @@ module Bundler
97
93
  end
98
94
 
99
95
  end
100
- end
96
+ end
@@ -4,7 +4,7 @@ module Bundler
4
4
  gemfile = Pathname.new(gemfile).expand_path
5
5
 
6
6
  unless gemfile.file?
7
- raise GemfileNotFound, "`#{gemfile}` not found"
7
+ raise GemfileNotFound, "#{gemfile} not found"
8
8
  end
9
9
 
10
10
  Dsl.evaluate(gemfile)
@@ -77,4 +77,4 @@ module Bundler
77
77
  end
78
78
  end
79
79
  end
80
- end
80
+ end
@@ -1,3 +1,5 @@
1
+ require 'erb'
2
+
1
3
  module Bundler
2
4
  class Environment
3
5
  attr_reader :root
@@ -17,7 +17,8 @@ module Bundler
17
17
  end
18
18
 
19
19
  def empty?
20
- @specs.values.flatten.empty?
20
+ each { return false }
21
+ true
21
22
  end
22
23
 
23
24
  def search(query)
@@ -41,9 +42,9 @@ module Bundler
41
42
  spec
42
43
  end
43
44
 
44
- def each
45
- @specs.values.flatten.each do |spec|
46
- yield spec
45
+ def each(&blk)
46
+ @specs.values.each do |specs|
47
+ specs.each(&blk)
47
48
  end
48
49
  end
49
50
 
@@ -25,7 +25,7 @@ module Bundler
25
25
  # end
26
26
 
27
27
  if (spec.groups & options[:without]).any?
28
- Bundler.ui.debug " * Not in requested group... skipping."
28
+ Bundler.ui.debug " * Not in requested group; skipping."
29
29
  next
30
30
  end
31
31
  spec.source.install(spec)
@@ -71,7 +71,7 @@ module Bundler
71
71
 
72
72
  def resolve_remotely
73
73
  index # trigger building the index
74
- Bundler.ui.info "Resolving dependencies... "
74
+ Bundler.ui.info "Resolving dependencies"
75
75
  source_requirements = {}
76
76
  dependencies.each do |dep|
77
77
  next unless dep.source
@@ -79,7 +79,6 @@ module Bundler
79
79
  end
80
80
 
81
81
  specs = Resolver.resolve(dependencies, index, source_requirements)
82
- Bundler.ui.info "Done."
83
82
  specs
84
83
  end
85
84
 
@@ -117,18 +116,16 @@ module Bundler
117
116
 
118
117
  other_sources.each do |source|
119
118
  i = source.specs
120
- Bundler.ui.debug "Source: Processing index... "
119
+ Bundler.ui.debug "Source: Processing index"
121
120
  index = i.merge(index).freeze
122
- Bundler.ui.debug "Done."
123
121
  end
124
122
 
125
123
  index = Index.from_installed_gems.merge(index)
126
124
 
127
125
  rg_sources.each do |source|
128
126
  i = source.specs
129
- Bundler.ui.debug "Source: Processing index... "
127
+ Bundler.ui.debug "Source: Processing index"
130
128
  index = i.merge(index).freeze
131
- Bundler.ui.debug "Done."
132
129
  end
133
130
 
134
131
  index
@@ -157,4 +154,4 @@ module Bundler
157
154
  end
158
155
 
159
156
  end
160
- end
157
+ end
@@ -47,7 +47,11 @@ module Bundler
47
47
  end
48
48
 
49
49
  def method_missing(method, *args, &blk)
50
- _remote_specification.send(method, *args, &blk)
50
+ if Gem::Specification.new.respond_to?(method)
51
+ _remote_specification.send(method, *args, &blk)
52
+ else
53
+ super
54
+ end
51
55
  end
52
56
  end
53
57
  end
@@ -16,7 +16,7 @@ module Bundler
16
16
  end
17
17
 
18
18
  def to_s
19
- "rubygems repository at `#{uri}`"
19
+ "rubygems repository at #{uri}"
20
20
  end
21
21
 
22
22
  def specs
@@ -26,9 +26,9 @@ module Bundler
26
26
  def install(spec)
27
27
  destination = Gem.dir
28
28
 
29
- Bundler.ui.debug " * Downloading..."
29
+ Bundler.ui.debug " * Downloading"
30
30
  gem_path = Gem::RemoteFetcher.fetcher.download(spec, uri, destination)
31
- Bundler.ui.debug " * Installing..."
31
+ Bundler.ui.debug " * Installing"
32
32
  installer = Gem::Installer.new gem_path,
33
33
  :install_dir => Gem.dir,
34
34
  :ignore_dependencies => true
@@ -40,14 +40,13 @@ module Bundler
40
40
 
41
41
  def fetch_specs
42
42
  index = Index.new
43
- Bundler.ui.info "Fetching source index from `#{uri}`... "
43
+ Bundler.ui.info "Fetching source index from #{uri}"
44
44
  (main_specs + prerelease_specs).each do |name, version, platform|
45
45
  next unless Gem::Platform.match(platform)
46
46
  spec = RemoteSpecification.new(name, version, platform, @uri)
47
47
  spec.source = self
48
48
  index << spec
49
49
  end
50
- Bundler.ui.info "Done."
51
50
  index.freeze
52
51
  end
53
52
 
@@ -84,7 +83,7 @@ module Bundler
84
83
  end
85
84
 
86
85
  def install(spec)
87
- Bundler.ui.debug " * already installed... skipping"
86
+ Bundler.ui.debug " * already installed; skipping"
88
87
  end
89
88
  end
90
89
 
@@ -114,7 +113,7 @@ module Bundler
114
113
  def install(spec)
115
114
  destination = Gem.dir
116
115
 
117
- Bundler.ui.debug " * Installing from pack..."
116
+ Bundler.ui.debug " * Installing from pack"
118
117
  installer = Gem::Installer.new "#{@path}/#{spec.full_name}.gem",
119
118
  :install_dir => Gem.dir,
120
119
  :ignore_dependencies => true
@@ -173,7 +172,7 @@ module Bundler
173
172
  end
174
173
 
175
174
  def install(spec)
176
- Bundler.ui.debug " * Using path `#{path}`..."
175
+ Bundler.ui.debug " * Using path #{path}"
177
176
  end
178
177
 
179
178
  alias specs local_specs
@@ -234,12 +233,12 @@ module Bundler
234
233
  end
235
234
 
236
235
  def install(spec)
237
- Bundler.ui.debug " * Using git `#{uri}`..."
236
+ Bundler.ui.debug " * Using git #{uri}"
238
237
 
239
238
  if @installed
240
- Bundler.ui.debug " * Already checked out revision: #{ref}..."
239
+ Bundler.ui.debug " * Already checked out revision: #{ref}"
241
240
  else
242
- Bundler.ui.debug " * Checking out revision: #{ref}..."
241
+ Bundler.ui.debug " * Checking out revision: #{ref}"
243
242
  FileUtils.mkdir_p(path)
244
243
  Dir.chdir(path) do
245
244
  unless File.exist?(".git")
@@ -276,14 +275,13 @@ module Bundler
276
275
 
277
276
  def cache
278
277
  if cache_path.exist?
279
- Bundler.ui.info "Updating `#{uri}`... "
278
+ Bundler.ui.info "Updating #{uri}"
280
279
  in_cache { git "fetch --quiet #{uri} master:master" }
281
280
  else
282
- Bundler.ui.info "Fetching `#{uri}`... "
281
+ Bundler.ui.info "Fetching #{uri}"
283
282
  FileUtils.mkdir_p(cache_path.dirname)
284
283
  git "clone #{uri} #{cache_path} --bare --no-hardlinks"
285
284
  end
286
- Bundler.ui.info "Done."
287
285
  end
288
286
 
289
287
  def revision
@@ -295,4 +293,4 @@ module Bundler
295
293
  end
296
294
  end
297
295
  end
298
- end
296
+ end
@@ -1,6 +1,4 @@
1
1
  require 'thor/base'
2
- require 'thor/group'
3
- require 'thor/actions'
4
2
 
5
3
  # TODO: Update thor to allow for git-style CLI (git bisect run)
6
4
  class Thor
@@ -193,7 +191,8 @@ class Thor
193
191
  # the namespace should be displayed as arguments.
194
192
  #
195
193
  def banner(task)
196
- "thor " + task.formatted_usage(self)
194
+ base = $thor_runner ? "thor" : File.basename($0.split(" ").first)
195
+ "#{base} #{task.formatted_usage(self, base == "thor")}"
197
196
  end
198
197
 
199
198
  def baseclass #:nodoc:
@@ -8,6 +8,9 @@ require 'thor/task'
8
8
  require 'thor/util'
9
9
 
10
10
  class Thor
11
+ autoload :Actions, 'thor/actions'
12
+ autoload :RakeCompat, 'thor/rake_compat'
13
+
11
14
  # Shortcuts for help.
12
15
  HELP_MAPPINGS = %w(-h -? --help -D)
13
16
 
@@ -94,6 +97,18 @@ class Thor
94
97
  module ClassMethods
95
98
  attr_accessor :debugging
96
99
 
100
+ def attr_reader(*) #:nodoc:
101
+ no_tasks { super }
102
+ end
103
+
104
+ def attr_writer(*) #:nodoc:
105
+ no_tasks { super }
106
+ end
107
+
108
+ def attr_accessor(*) #:nodoc:
109
+ no_tasks { super }
110
+ end
111
+
97
112
  # Adds an argument to the class and creates an attr_accessor for it.
98
113
  #
99
114
  # Arguments are different from options in several aspects. The first one
@@ -1,6 +1,6 @@
1
1
  class Thor
2
2
  class Task < Struct.new(:name, :description, :usage, :options)
3
- FILE_REGEXP = /^#{Regexp.escape(File.expand_path(__FILE__))}:[\w:]+ `run'$/
3
+ FILE_REGEXP = /^#{Regexp.escape(File.dirname(__FILE__))}/
4
4
 
5
5
  # A dynamic task that handles method missing scenarios.
6
6
  class Dynamic < Task
@@ -40,8 +40,8 @@ class Thor
40
40
 
41
41
  # Returns the formatted usage by injecting given required arguments
42
42
  # and required options into the given usage.
43
- def formatted_usage(klass, namespace=nil)
44
- namespace = klass.namespace if namespace.nil?
43
+ def formatted_usage(klass, namespace=true)
44
+ namespace = klass.namespace unless namespace == false
45
45
 
46
46
  # Add namespace
47
47
  formatted = if namespace
@@ -78,15 +78,15 @@ class Thor
78
78
  (collection & [name.to_s, name.to_sym]).empty?
79
79
  end
80
80
 
81
- # For Ruby <= 1.8.7, we have to match the method name that we are trying to call.
82
- # In Ruby >= 1.9.1, we have to match the method run in this file.
83
- def backtrace_match?(backtrace) #:nodoc:
84
- method_name = /`#{Regexp.escape(name.split(':').last)}'/
85
- backtrace =~ method_name || backtrace =~ FILE_REGEXP
81
+ def sans_backtrace(backtrace, caller) #:nodoc:
82
+ saned = backtrace.reject { |frame| frame =~ FILE_REGEXP }
83
+ saned -= caller
86
84
  end
87
85
 
88
86
  def parse_argument_error(instance, e, caller) #:nodoc:
89
- if e.message =~ /wrong number of arguments/ && backtrace_match?(e.backtrace.first.to_s)
87
+ backtrace = sans_backtrace(e.backtrace, caller)
88
+
89
+ if backtrace.empty? && e.message =~ /wrong number of arguments/
90
90
  if instance.is_a?(Thor::Group)
91
91
  raise e, "'#{name}' was called incorrectly. Are you sure it has arity equals to 0?"
92
92
  else
@@ -1,3 +1,3 @@
1
1
  class Thor
2
- VERSION = "0.12.2".freeze
2
+ VERSION = "0.12.4".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bundler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0.pre5
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carl Lerche
@@ -42,26 +42,17 @@ files:
42
42
  - lib/bundler/templates/environment.erb
43
43
  - lib/bundler/templates/Gemfile
44
44
  - lib/bundler/ui.rb
45
- - lib/bundler/vendor/thor/actions/create_file.rb
46
- - lib/bundler/vendor/thor/actions/directory.rb
47
- - lib/bundler/vendor/thor/actions/empty_directory.rb
48
- - lib/bundler/vendor/thor/actions/file_manipulation.rb
49
- - lib/bundler/vendor/thor/actions/inject_into_file.rb
50
- - lib/bundler/vendor/thor/actions.rb
51
45
  - lib/bundler/vendor/thor/base.rb
52
46
  - lib/bundler/vendor/thor/core_ext/file_binary_read.rb
53
47
  - lib/bundler/vendor/thor/core_ext/hash_with_indifferent_access.rb
54
48
  - lib/bundler/vendor/thor/core_ext/ordered_hash.rb
55
49
  - lib/bundler/vendor/thor/error.rb
56
- - lib/bundler/vendor/thor/group.rb
57
50
  - lib/bundler/vendor/thor/invocation.rb
58
51
  - lib/bundler/vendor/thor/parser/argument.rb
59
52
  - lib/bundler/vendor/thor/parser/arguments.rb
60
53
  - lib/bundler/vendor/thor/parser/option.rb
61
54
  - lib/bundler/vendor/thor/parser/options.rb
62
55
  - lib/bundler/vendor/thor/parser.rb
63
- - lib/bundler/vendor/thor/rake_compat.rb
64
- - lib/bundler/vendor/thor/runner.rb
65
56
  - lib/bundler/vendor/thor/shell/basic.rb
66
57
  - lib/bundler/vendor/thor/shell/color.rb
67
58
  - lib/bundler/vendor/thor/shell.rb
@@ -1,274 +0,0 @@
1
- require 'fileutils'
2
- require 'thor/core_ext/file_binary_read'
3
-
4
- Dir[File.join(File.dirname(__FILE__), "actions", "*.rb")].each do |action|
5
- require action
6
- end
7
-
8
- class Thor
9
- module Actions
10
- attr_accessor :behavior
11
-
12
- def self.included(base) #:nodoc:
13
- base.extend ClassMethods
14
- end
15
-
16
- module ClassMethods
17
- # Hold source paths for one Thor instance. source_paths_for_search is the
18
- # method responsible to gather source_paths from this current class,
19
- # inherited paths and the source root.
20
- #
21
- def source_paths
22
- @source_paths ||= []
23
- end
24
-
25
- # Returns the source paths in the following order:
26
- #
27
- # 1) This class source paths
28
- # 2) Source root
29
- # 3) Parents source paths
30
- #
31
- def source_paths_for_search
32
- paths = []
33
- paths += self.source_paths
34
- paths << self.source_root if self.respond_to?(:source_root)
35
- paths += from_superclass(:source_paths, [])
36
- paths
37
- end
38
-
39
- # Add runtime options that help actions execution.
40
- #
41
- def add_runtime_options!
42
- class_option :force, :type => :boolean, :aliases => "-f", :group => :runtime,
43
- :desc => "Overwrite files that already exist"
44
-
45
- class_option :pretend, :type => :boolean, :aliases => "-p", :group => :runtime,
46
- :desc => "Run but do not make any changes"
47
-
48
- class_option :quiet, :type => :boolean, :aliases => "-q", :group => :runtime,
49
- :desc => "Supress status output"
50
-
51
- class_option :skip, :type => :boolean, :aliases => "-s", :group => :runtime,
52
- :desc => "Skip files that already exist"
53
- end
54
- end
55
-
56
- # Extends initializer to add more configuration options.
57
- #
58
- # ==== Configuration
59
- # behavior<Symbol>:: The actions default behavior. Can be :invoke or :revoke.
60
- # It also accepts :force, :skip and :pretend to set the behavior
61
- # and the respective option.
62
- #
63
- # destination_root<String>:: The root directory needed for some actions.
64
- #
65
- def initialize(args=[], options={}, config={})
66
- self.behavior = case config[:behavior].to_s
67
- when "force", "skip"
68
- _cleanup_options_and_set(options, config[:behavior])
69
- :invoke
70
- when "revoke"
71
- :revoke
72
- else
73
- :invoke
74
- end
75
-
76
- super
77
- self.destination_root = config[:destination_root]
78
- end
79
-
80
- # Wraps an action object and call it accordingly to the thor class behavior.
81
- #
82
- def action(instance) #:nodoc:
83
- if behavior == :revoke
84
- instance.revoke!
85
- else
86
- instance.invoke!
87
- end
88
- end
89
-
90
- # Returns the root for this thor class (also aliased as destination root).
91
- #
92
- def destination_root
93
- @destination_stack.last
94
- end
95
-
96
- # Sets the root for this thor class. Relatives path are added to the
97
- # directory where the script was invoked and expanded.
98
- #
99
- def destination_root=(root)
100
- @destination_stack ||= []
101
- @destination_stack[0] = File.expand_path(root || '')
102
- end
103
-
104
- # Returns the given path relative to the absolute root (ie, root where
105
- # the script started).
106
- #
107
- def relative_to_original_destination_root(path, remove_dot=true)
108
- path = path.gsub(@destination_stack[0], '.')
109
- remove_dot ? (path[2..-1] || '') : path
110
- end
111
-
112
- # Holds source paths in instance so they can be manipulated.
113
- #
114
- def source_paths
115
- @source_paths ||= self.class.source_paths_for_search
116
- end
117
-
118
- # Receives a file or directory and search for it in the source paths.
119
- #
120
- def find_in_source_paths(file)
121
- relative_root = relative_to_original_destination_root(destination_root, false)
122
-
123
- source_paths.each do |source|
124
- source_file = File.expand_path(file, File.join(source, relative_root))
125
- return source_file if File.exists?(source_file)
126
- end
127
-
128
- if source_paths.empty?
129
- raise Error, "You don't have any source path defined for class #{self.class.name}. To fix this, " <<
130
- "you can define a source_root in your class."
131
- else
132
- raise Error, "Could not find #{file.inspect} in source paths."
133
- end
134
- end
135
-
136
- # Do something in the root or on a provided subfolder. If a relative path
137
- # is given it's referenced from the current root. The full path is yielded
138
- # to the block you provide. The path is set back to the previous path when
139
- # the method exits.
140
- #
141
- # ==== Parameters
142
- # dir<String>:: the directory to move to.
143
- # config<Hash>:: give :verbose => true to log and use padding.
144
- #
145
- def inside(dir='', config={}, &block)
146
- verbose = config.fetch(:verbose, false)
147
-
148
- say_status :inside, dir, verbose
149
- shell.padding += 1 if verbose
150
- @destination_stack.push File.expand_path(dir, destination_root)
151
-
152
- FileUtils.mkdir_p(destination_root) unless File.exist?(destination_root)
153
- FileUtils.cd(destination_root) { block.arity == 1 ? yield(destination_root) : yield }
154
-
155
- @destination_stack.pop
156
- shell.padding -= 1 if verbose
157
- end
158
-
159
- # Goes to the root and execute the given block.
160
- #
161
- def in_root
162
- inside(@destination_stack.first) { yield }
163
- end
164
-
165
- # Loads an external file and execute it in the instance binding.
166
- #
167
- # ==== Parameters
168
- # path<String>:: The path to the file to execute. Can be a web address or
169
- # a relative path from the source root.
170
- #
171
- # ==== Examples
172
- #
173
- # apply "http://gist.github.com/103208"
174
- #
175
- # apply "recipes/jquery.rb"
176
- #
177
- def apply(path, config={})
178
- verbose = config.fetch(:verbose, true)
179
- path = find_in_source_paths(path) unless path =~ /^http\:\/\//
180
-
181
- say_status :apply, path, verbose
182
- shell.padding += 1 if verbose
183
- instance_eval(open(path).read)
184
- shell.padding -= 1 if verbose
185
- end
186
-
187
- # Executes a command.
188
- #
189
- # ==== Parameters
190
- # command<String>:: the command to be executed.
191
- # config<Hash>:: give :verbose => false to not log the status. Specify :with
192
- # to append an executable to command executation.
193
- #
194
- # ==== Example
195
- #
196
- # inside('vendor') do
197
- # run('ln -s ~/edge rails')
198
- # end
199
- #
200
- def run(command, config={})
201
- return unless behavior == :invoke
202
-
203
- destination = relative_to_original_destination_root(destination_root, false)
204
- desc = "#{command} from #{destination.inspect}"
205
-
206
- if config[:with]
207
- desc = "#{File.basename(config[:with].to_s)} #{desc}"
208
- command = "#{config[:with]} #{command}"
209
- end
210
-
211
- say_status :run, desc, config.fetch(:verbose, true)
212
- system(command) unless options[:pretend]
213
- end
214
-
215
- # Executes a ruby script (taking into account WIN32 platform quirks).
216
- #
217
- # ==== Parameters
218
- # command<String>:: the command to be executed.
219
- # config<Hash>:: give :verbose => false to not log the status.
220
- #
221
- def run_ruby_script(command, config={})
222
- return unless behavior == :invoke
223
- run "#{command}", config.merge(:with => Thor::Util.ruby_command)
224
- end
225
-
226
- # Run a thor command. A hash of options can be given and it's converted to
227
- # switches.
228
- #
229
- # ==== Parameters
230
- # task<String>:: the task to be invoked
231
- # args<Array>:: arguments to the task
232
- # config<Hash>:: give :verbose => false to not log the status. Other options
233
- # are given as parameter to Thor.
234
- #
235
- # ==== Examples
236
- #
237
- # thor :install, "http://gist.github.com/103208"
238
- # #=> thor install http://gist.github.com/103208
239
- #
240
- # thor :list, :all => true, :substring => 'rails'
241
- # #=> thor list --all --substring=rails
242
- #
243
- def thor(task, *args)
244
- config = args.last.is_a?(Hash) ? args.pop : {}
245
- verbose = config.key?(:verbose) ? config.delete(:verbose) : true
246
-
247
- args.unshift task
248
- args.push Thor::Options.to_switches(config)
249
- command = args.join(' ').strip
250
-
251
- run command, :with => :thor, :verbose => verbose
252
- end
253
-
254
- protected
255
-
256
- # Allow current root to be shared between invocations.
257
- #
258
- def _shared_configuration #:nodoc:
259
- super.merge!(:destination_root => self.destination_root)
260
- end
261
-
262
- def _cleanup_options_and_set(options, key) #:nodoc:
263
- case options
264
- when Array
265
- %w(--force -f --skip -s).each { |i| options.delete(i) }
266
- options << "--#{key}"
267
- when Hash
268
- [:force, :skip, "force", "skip"].each { |i| options.delete(i) }
269
- options.merge!(key => true)
270
- end
271
- end
272
-
273
- end
274
- end