bundler 0.9.26 → 1.0.0.beta.1

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.

@@ -16,38 +16,98 @@ module Bundler
16
16
  @specs.length
17
17
  end
18
18
 
19
- def for(*deps)
20
- specs = {}
21
- deps.flatten.each do |dep|
22
- current = lookup[dep.respond_to?(:name) ? dep.name : dep]
23
- append_subgraph(specs, current)
19
+ def for(dependencies, skip = [], check = false, match_current_platform = false)
20
+ handled, deps, specs = {}, dependencies.dup, []
21
+
22
+ until deps.empty?
23
+ dep = deps.shift
24
+ next if handled[dep] || skip.include?(dep.name)
25
+
26
+ spec = lookup[dep.name].find do |s|
27
+ match_current_platform ?
28
+ Gem::Platform.match(s.platform) :
29
+ s.match_platform(dep.__platform)
30
+ end
31
+
32
+ handled[dep] = true
33
+
34
+ if spec
35
+ specs << spec
36
+
37
+ spec.dependencies.each do |d|
38
+ next if d.type == :development
39
+ d = DepProxy.new(d, dep.__platform) unless match_current_platform
40
+ deps << d
41
+ end
42
+ elsif check
43
+ return false
44
+ end
24
45
  end
25
46
 
26
- sorted.select { |s| specs[s.name] }
47
+ check ? true : SpecSet.new(specs)
48
+ end
49
+
50
+ def valid_for?(deps)
51
+ self.for(deps, [], true)
52
+ end
53
+
54
+ def [](key)
55
+ key = key.name if key.respond_to?(:name)
56
+ lookup[key].reverse
27
57
  end
28
58
 
29
59
  def to_a
30
60
  sorted.dup
31
61
  end
32
62
 
33
- private
63
+ def to_hash
64
+ lookup.dup
65
+ end
34
66
 
35
- def append_subgraph(specs, current)
36
- return if specs[current.name]
37
- specs[current.name] = true
38
- current.dependencies.each do |dep|
39
- next if dep.type == :development
40
- append_subgraph(specs, lookup[dep.name])
67
+ def materialize(deps, missing_specs = nil)
68
+ materialized = self.for(deps, [], false, true).to_a
69
+ materialized.map! do |s|
70
+ next s unless s.is_a?(LazySpecification)
71
+ spec = s.__materialize__
72
+ if missing_specs
73
+ missing_specs << s unless spec
74
+ else
75
+ raise GemNotFound, "Could not find #{s.full_name} in any of the sources" unless spec
76
+ end
77
+ spec if spec
41
78
  end
79
+ SpecSet.new(materialized.compact)
42
80
  end
43
81
 
82
+ def names
83
+ lookup.keys
84
+ end
85
+
86
+ def select!(names)
87
+ @lookup = nil
88
+ @sorted = nil
89
+
90
+ @specs.delete_if { |s| !names.include?(s.name) }
91
+ self
92
+ end
93
+
94
+ private
95
+
44
96
  def sorted
45
- @sorted ||= ([lookup['rake']] + tsort).compact.uniq
97
+ rake = @specs.find { |s| s.name == 'rake' }
98
+ @sorted ||= ([rake] + tsort).compact.uniq
46
99
  end
47
100
 
48
101
  def lookup
49
- @lookup ||= Hash.new do |h,k|
50
- h[k] = @specs.find { |s| s.name == k }
102
+ @lookup ||= begin
103
+ lookup = Hash.new { |h,k| h[k] = [] }
104
+ specs = @specs.sort_by do |s|
105
+ s.platform.to_s == 'ruby' ? "\0" : s.platform.to_s
106
+ end
107
+ specs.reverse_each do |s|
108
+ lookup[s.name] << s
109
+ end
110
+ lookup
51
111
  end
52
112
  end
53
113
 
@@ -58,7 +118,7 @@ module Bundler
58
118
  def tsort_each_child(s)
59
119
  s.dependencies.sort_by { |d| d.name }.each do |d|
60
120
  next if d.type == :development
61
- yield lookup[d.name]
121
+ lookup[d.name].each { |s| yield s }
62
122
  end
63
123
  end
64
124
  end
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env ruby
2
+ # This is not actually required by the actual library
3
+ # loads the bundled environment
4
+ require 'rubygems'
5
+
6
+ begin
7
+ require 'bundler/setup'
8
+ rescue LoadError
9
+ # Let's not complain if bundler isn't around
10
+ end
11
+
12
+ base = File.basename($0)
13
+ paths = ENV['PATH'].split(File::PATH_SEPARATOR)
14
+ here = File.expand_path(File.dirname(__FILE__))
15
+
16
+ gem_stub = paths.find do |path|
17
+ path = File.expand_path(path)
18
+
19
+ next if path == here
20
+
21
+ File.exist?("#{path}/#{base}")
22
+ end
23
+
24
+ if gem_stub
25
+ load "#{gem_stub}/#{base}"
26
+ else
27
+ abort "The gem stub #{base} could not be found"
28
+ end
@@ -35,6 +35,20 @@ class Thor
35
35
  end
36
36
  end
37
37
 
38
+ # Defines the long description of the next task.
39
+ #
40
+ # ==== Parameters
41
+ # long description<String>
42
+ #
43
+ def long_desc(long_description, options={})
44
+ if options[:for]
45
+ task = find_and_refresh_task(options[:for])
46
+ task.long_description = long_description if long_description
47
+ else
48
+ @long_desc = long_description
49
+ end
50
+ end
51
+
38
52
  # Maps an input to a task. If you define:
39
53
  #
40
54
  # map "-T" => "list"
@@ -122,7 +136,15 @@ class Thor
122
136
  #
123
137
  def start(original_args=ARGV, config={})
124
138
  super do |given_args|
125
- meth = normalize_task_name(given_args.shift)
139
+ meth = given_args.first.to_s
140
+
141
+ if !meth.empty? && (map[meth] || meth !~ /^\-/)
142
+ given_args.shift
143
+ else
144
+ meth = nil
145
+ end
146
+
147
+ meth = normalize_task_name(meth)
126
148
  task = all_tasks[meth]
127
149
 
128
150
  if task
@@ -153,7 +175,12 @@ class Thor
153
175
  shell.say " #{banner(task)}"
154
176
  shell.say
155
177
  class_options_help(shell, nil => task.options.map { |_, o| o })
156
- shell.say task.description
178
+ if task.long_description
179
+ shell.say "Description:"
180
+ shell.print_wrapped(task.long_description, :ident => 2)
181
+ else
182
+ shell.say task.description
183
+ end
157
184
  end
158
185
 
159
186
  # Prints help information for this class.
@@ -205,8 +232,8 @@ class Thor
205
232
 
206
233
  def create_task(meth) #:nodoc:
207
234
  if @usage && @desc
208
- tasks[meth.to_s] = Thor::Task.new(meth, @desc, @usage, method_options)
209
- @usage, @desc, @method_options = nil
235
+ tasks[meth.to_s] = Thor::Task.new(meth, @desc, @long_desc, @usage, method_options)
236
+ @usage, @desc, @long_desc, @method_options = nil
210
237
  true
211
238
  elsif self.all_tasks[meth.to_s] || meth.to_sym == :method_missing
212
239
  true
@@ -11,7 +11,7 @@ class Thor
11
11
  def prepare_for_invocation(key, name) #:nodoc:
12
12
  case name
13
13
  when Symbol, String
14
- Thor::Util.find_class_and_task_by_namespace(name.to_s)
14
+ Thor::Util.find_class_and_task_by_namespace(name.to_s, !key)
15
15
  else
16
16
  name
17
17
  end
@@ -51,6 +51,11 @@ class Thor
51
51
 
52
52
  private
53
53
 
54
+ def no_or_skip?(arg)
55
+ arg =~ /^--(no|skip)-([-\w]+)$/
56
+ $2
57
+ end
58
+
54
59
  def last?
55
60
  @pile.empty?
56
61
  end
@@ -114,7 +119,7 @@ class Thor
114
119
  array
115
120
  end
116
121
 
117
- # Check if the peel is numeric ofrmat and return a Float or Integer.
122
+ # Check if the peek is numeric format and return a Float or Integer.
118
123
  # Otherwise raises an error.
119
124
  #
120
125
  def parse_numeric(name)
@@ -127,10 +132,16 @@ class Thor
127
132
  $&.index('.') ? shift.to_f : shift.to_i
128
133
  end
129
134
 
130
- # Parse string, i.e., just return the current value in the pile.
135
+ # Parse string:
136
+ # for --string-arg, just return the current value in the pile
137
+ # for --no-string-arg, nil
131
138
  #
132
139
  def parse_string(name)
133
- shift
140
+ if no_or_skip?(name)
141
+ nil
142
+ else
143
+ shift
144
+ end
134
145
  end
135
146
 
136
147
  # Raises an error if @non_assigned_required array is not empty.
@@ -124,11 +124,6 @@ class Thor
124
124
  end
125
125
  end
126
126
 
127
- def no_or_skip?(arg)
128
- arg =~ /^--(no|skip)-([-\w]+)$/
129
- $2
130
- end
131
-
132
127
  # Check if the given argument is actually a shortcut.
133
128
  #
134
129
  def normalize_switch(arg)
@@ -109,6 +109,34 @@ class Thor
109
109
  end
110
110
  end
111
111
 
112
+ # Prints a long string, word-wrapping the text to the current width of the
113
+ # terminal display. Ideal for printing heredocs.
114
+ #
115
+ # ==== Parameters
116
+ # String
117
+ #
118
+ # ==== Options
119
+ # ident<Integer>:: Indent each line of the printed paragraph by ident value.
120
+ #
121
+ def print_wrapped(message, options={})
122
+ ident = options[:ident] || 0
123
+ width = terminal_width - ident
124
+ paras = message.split("\n\n")
125
+
126
+ paras.map! do |unwrapped|
127
+ unwrapped.strip.gsub(/\n/, " ").squeeze(" ").
128
+ gsub(/.{1,#{width}}(?:\s|\Z)/){($& + 5.chr).
129
+ gsub(/\n\005/,"\n").gsub(/\005/,"\n")}
130
+ end
131
+
132
+ paras.each do |para|
133
+ para.split("\n").each do |line|
134
+ $stdout.puts line.insert(0, " " * ident)
135
+ end
136
+ $stdout.puts unless para == paras.last
137
+ end
138
+ end
139
+
112
140
  # Deals with file collision and returns true if the file should be
113
141
  # overwriten and false otherwise. If a block is given, it uses the block
114
142
  # response as the content for the diff.
@@ -1,11 +1,11 @@
1
1
  class Thor
2
- class Task < Struct.new(:name, :description, :usage, :options)
2
+ class Task < Struct.new(:name, :description, :long_description, :usage, :options)
3
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
7
7
  def initialize(name, options=nil)
8
- super(name.to_s, "A dynamically-generated task", name.to_s, options)
8
+ super(name.to_s, "A dynamically-generated task", name.to_s, name.to_s, options)
9
9
  end
10
10
 
11
11
  def run(instance, args=[])
@@ -17,8 +17,8 @@ class Thor
17
17
  end
18
18
  end
19
19
 
20
- def initialize(name, description, usage, options=nil)
21
- super(name.to_s, description, usage, options || {})
20
+ def initialize(name, description, long_description, usage, options=nil)
21
+ super(name.to_s, description, long_description, usage, options || {})
22
22
  end
23
23
 
24
24
  def initialize_copy(other) #:nodoc:
@@ -39,7 +39,7 @@ class Thor
39
39
  instance.class.handle_no_task_error(name) : (raise e)
40
40
  end
41
41
 
42
- # Returns the formatted usage by injecting given required arguments
42
+ # Returns the formatted usage by injecting given required arguments
43
43
  # and required options into the given usage.
44
44
  def formatted_usage(klass, namespace=true)
45
45
  namespace = klass.namespace unless namespace == false
@@ -99,4 +99,4 @@ class Thor
99
99
  end
100
100
 
101
101
  end
102
- end
102
+ end
@@ -128,38 +128,37 @@ class Thor
128
128
  # ==== Parameters
129
129
  # namespace<String>
130
130
  #
131
- def self.find_class_and_task_by_namespace(namespace)
132
- if namespace.include?(?:)
131
+ def self.find_class_and_task_by_namespace(namespace, fallback = true)
132
+ if namespace.include?(?:) # look for a namespaced task
133
133
  pieces = namespace.split(":")
134
134
  task = pieces.pop
135
135
  klass = Thor::Util.find_by_namespace(pieces.join(":"))
136
136
  end
137
-
138
- unless klass
137
+ unless klass # look for a Thor::Group with the right name
139
138
  klass, task = Thor::Util.find_by_namespace(namespace), nil
140
139
  end
141
-
142
- return klass, task
143
- end
144
-
145
- # The same as namespace_to_thor_class_and_task!, but raises an error if a klass
146
- # could not be found.
147
- def self.find_class_and_task_by_namespace!(namespace)
148
- klass, task = find_class_and_task_by_namespace(namespace)
149
- raise Error, "Could not find namespace or task #{namespace.inspect}." unless klass
140
+ if !klass && fallback # try a task in the default namespace
141
+ task = namespace
142
+ klass = Thor::Util.find_by_namespace('')
143
+ end
150
144
  return klass, task
151
145
  end
152
146
 
153
147
  # Receives a path and load the thor file in the path. The file is evaluated
154
148
  # inside the sandbox to avoid namespacing conflicts.
155
149
  #
156
- def self.load_thorfile(path, content=nil)
150
+ def self.load_thorfile(path, content=nil, debug=false)
157
151
  content ||= File.binread(path)
158
152
 
159
153
  begin
160
154
  Thor::Sandbox.class_eval(content, path)
161
155
  rescue Exception => e
162
156
  $stderr.puts "WARNING: unable to load thorfile #{path.inspect}: #{e.message}"
157
+ if debug
158
+ $stderr.puts *e.backtrace
159
+ else
160
+ $stderr.puts e.backtrace.first
161
+ end
163
162
  end
164
163
  end
165
164
 
@@ -1,3 +1,3 @@
1
1
  class Thor
2
- VERSION = "0.13.4".freeze
2
+ VERSION = "0.13.6".freeze
3
3
  end
@@ -1,3 +1,3 @@
1
1
  module Bundler
2
- VERSION = "0.9.26"
2
+ VERSION = "1.0.0.beta.1"
3
3
  end
metadata CHANGED
@@ -1,12 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bundler
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
4
+ prerelease: true
5
5
  segments:
6
+ - 1
7
+ - 0
6
8
  - 0
7
- - 9
8
- - 26
9
- version: 0.9.26
9
+ - beta
10
+ - 1
11
+ version: 1.0.0.beta.1
10
12
  platform: ruby
11
13
  authors:
12
14
  - Carl Lerche
@@ -47,8 +49,11 @@ files:
47
49
  - lib/bundler/dependency.rb
48
50
  - lib/bundler/dsl.rb
49
51
  - lib/bundler/environment.rb
52
+ - lib/bundler/graph.rb
50
53
  - lib/bundler/index.rb
51
54
  - lib/bundler/installer.rb
55
+ - lib/bundler/lazy_specification.rb
56
+ - lib/bundler/lockfile_parser.rb
52
57
  - lib/bundler/remote_specification.rb
53
58
  - lib/bundler/resolver.rb
54
59
  - lib/bundler/rubygems_ext.rb
@@ -58,7 +63,7 @@ files:
58
63
  - lib/bundler/shared_helpers.rb
59
64
  - lib/bundler/source.rb
60
65
  - lib/bundler/spec_set.rb
61
- - lib/bundler/templates/environment.erb
66
+ - lib/bundler/templates/Executable
62
67
  - lib/bundler/templates/Gemfile
63
68
  - lib/bundler/ui.rb
64
69
  - lib/bundler/vendor/thor/base.rb
@@ -85,6 +90,7 @@ files:
85
90
  - README.md
86
91
  - ROADMAP.md
87
92
  - CHANGELOG.md
93
+ - TODO.md
88
94
  has_rdoc: true
89
95
  homepage: http://github.com/carlhuda/bundler
90
96
  licenses: []