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,427 @@
1
+ require "digest/sha1"
2
+
3
+ module Bundler
4
+ class Definition
5
+ include GemHelpers
6
+
7
+ attr_reader :dependencies, :platforms, :sources
8
+
9
+ def self.build(gemfile, lockfile, unlock)
10
+ unlock ||= {}
11
+ gemfile = Pathname.new(gemfile).expand_path
12
+
13
+ unless gemfile.file?
14
+ raise GemfileNotFound, "#{gemfile} not found"
15
+ end
16
+
17
+ Dsl.evaluate(gemfile, lockfile, unlock)
18
+ end
19
+
20
+ =begin
21
+ How does the new system work?
22
+ ===
23
+ * Load information from Gemfile and Lockfile
24
+ * Invalidate stale locked specs
25
+ * All specs from stale source are stale
26
+ * All specs that are reachable only through a stale
27
+ dependency are stale.
28
+ * If all fresh dependencies are satisfied by the locked
29
+ specs, then we can try to resolve locally.
30
+ =end
31
+
32
+ def initialize(lockfile, dependencies, sources, unlock)
33
+ @dependencies, @sources, @unlock = dependencies, sources, unlock
34
+ @remote = false
35
+ @specs = nil
36
+ @lockfile_contents = ""
37
+
38
+ if lockfile && File.exists?(lockfile)
39
+ @lockfile_contents = Bundler.read_file(lockfile)
40
+ locked = LockfileParser.new(@lockfile_contents)
41
+ @platforms = locked.platforms
42
+
43
+ if unlock != true
44
+ @locked_deps = locked.dependencies
45
+ @locked_specs = SpecSet.new(locked.specs)
46
+ @locked_sources = locked.sources
47
+ else
48
+ @unlock = {}
49
+ @locked_deps = []
50
+ @locked_specs = SpecSet.new([])
51
+ @locked_sources = []
52
+ end
53
+ else
54
+ @unlock = {}
55
+ @platforms = []
56
+ @locked_deps = []
57
+ @locked_specs = SpecSet.new([])
58
+ @locked_sources = []
59
+ end
60
+
61
+ @unlock[:gems] ||= []
62
+ @unlock[:sources] ||= []
63
+
64
+ current_platform = Gem.platforms.map { |p| generic(p) }.compact.last
65
+ @new_platform = !@platforms.include?(current_platform)
66
+ @platforms |= [current_platform]
67
+
68
+ eager_unlock = expand_dependencies(@unlock[:gems])
69
+ @unlock[:gems] = @locked_specs.for(eager_unlock).map { |s| s.name }
70
+
71
+ converge_sources
72
+ converge_dependencies
73
+ end
74
+
75
+ def resolve_with_cache!
76
+ raise "Specs already loaded" if @specs
77
+ @sources.each { |s| s.cached! }
78
+ specs
79
+ end
80
+
81
+ def resolve_remotely!
82
+ raise "Specs already loaded" if @specs
83
+ @remote = true
84
+ @sources.each { |s| s.remote! }
85
+ specs
86
+ end
87
+
88
+ def specs
89
+ @specs ||= begin
90
+ specs = resolve.materialize(requested_dependencies)
91
+
92
+ unless specs["bundler"].any?
93
+ local = Bundler.settings[:frozen] ? rubygems_index : index
94
+ bundler = local.search(Gem::Dependency.new('bundler', VERSION)).last
95
+ specs["bundler"] = bundler if bundler
96
+ end
97
+
98
+ specs
99
+ end
100
+ end
101
+
102
+ def new_specs
103
+ specs - @locked_specs
104
+ end
105
+
106
+ def removed_specs
107
+ @locked_specs - specs
108
+ end
109
+
110
+ def new_platform?
111
+ @new_platform
112
+ end
113
+
114
+ def missing_specs
115
+ missing = []
116
+ resolve.materialize(requested_dependencies, missing)
117
+ missing
118
+ end
119
+
120
+ def requested_specs
121
+ @requested_specs ||= begin
122
+ groups = self.groups - Bundler.settings.without
123
+ groups.map! { |g| g.to_sym }
124
+ specs_for(groups)
125
+ end
126
+ end
127
+
128
+ def current_dependencies
129
+ dependencies.reject { |d| !d.should_include? }
130
+ end
131
+
132
+ def specs_for(groups)
133
+ deps = dependencies.select { |d| (d.groups & groups).any? }
134
+ deps.delete_if { |d| !d.should_include? }
135
+ specs.for(expand_dependencies(deps))
136
+ end
137
+
138
+ def resolve
139
+ @resolve ||= begin
140
+ if Bundler.settings[:frozen]
141
+ @locked_specs
142
+ else
143
+ last_resolve = converge_locked_specs
144
+ source_requirements = {}
145
+ dependencies.each do |dep|
146
+ next unless dep.source
147
+ source_requirements[dep.name] = dep.source.specs
148
+ end
149
+
150
+ # Run a resolve against the locally available gems
151
+ last_resolve.merge Resolver.resolve(expanded_dependencies, index, source_requirements, last_resolve)
152
+ end
153
+ end
154
+ end
155
+
156
+ def index
157
+ @index ||= Index.build do |idx|
158
+ @sources.each do |s|
159
+ idx.use s.specs
160
+ end
161
+ end
162
+ end
163
+
164
+ def rubygems_index
165
+ @rubygems_index ||= Index.build do |idx|
166
+ @sources.find_all{|s| s.is_a?(Source::Rubygems) }.each do |s|
167
+ idx.use s.specs
168
+ end
169
+ end
170
+ end
171
+
172
+ def no_sources?
173
+ @sources.length == 1 && @sources.first.remotes.empty?
174
+ end
175
+
176
+ def groups
177
+ dependencies.map { |d| d.groups }.flatten.uniq
178
+ end
179
+
180
+ def lock(file)
181
+ contents = to_lock
182
+
183
+ return if @lockfile_contents == contents
184
+
185
+ if Bundler.settings[:frozen]
186
+ # TODO: Warn here if we got here.
187
+ return
188
+ end
189
+
190
+ File.open(file, 'wb') do |f|
191
+ f.puts contents
192
+ end
193
+ end
194
+
195
+ def to_lock
196
+ out = ""
197
+
198
+ sorted_sources.each do |source|
199
+ # Add the source header
200
+ out << source.to_lock
201
+ # Find all specs for this source
202
+ resolve.
203
+ select { |s| s.source == source }.
204
+ # This needs to be sorted by full name so that
205
+ # gems with the same name, but different platform
206
+ # are ordered consistantly
207
+ sort_by { |s| s.full_name }.
208
+ each do |spec|
209
+ next if spec.name == 'bundler'
210
+ out << spec.to_lock
211
+ end
212
+ out << "\n"
213
+ end
214
+
215
+ out << "PLATFORMS\n"
216
+
217
+ platforms.map { |p| p.to_s }.sort.each do |p|
218
+ out << " #{p}\n"
219
+ end
220
+
221
+ out << "\n"
222
+ out << "DEPENDENCIES\n"
223
+
224
+ handled = []
225
+ dependencies.
226
+ sort_by { |d| d.name }.
227
+ each do |dep|
228
+ next if handled.include?(dep.name)
229
+ out << dep.to_lock
230
+ handled << dep.name
231
+ end
232
+
233
+ out
234
+ end
235
+
236
+ def ensure_equivalent_gemfile_and_lockfile
237
+ changes = false
238
+
239
+ msg = "You have modified your Gemfile in development but did not check\n" \
240
+ "the resulting snapshot (Gemfile.lock) into version control"
241
+
242
+ added = []
243
+ deleted = []
244
+ changed = []
245
+
246
+ if @locked_sources != @sources
247
+ new_sources = @sources - @locked_sources
248
+ deleted_sources = @locked_sources - @sources
249
+
250
+ if new_sources.any?
251
+ added.concat new_sources.map { |source| "* source: #{source}" }
252
+ end
253
+
254
+ if deleted_sources.any?
255
+ deleted.concat deleted_sources.map { |source| "* source: #{source}" }
256
+ end
257
+
258
+ changes = true
259
+ end
260
+
261
+ both_sources = Hash.new { |h,k| h[k] = ["no specified source", "no specified source"] }
262
+ @dependencies.each { |d| both_sources[d.name][0] = d.source if d.source }
263
+ @locked_deps.each { |d| both_sources[d.name][1] = d.source if d.source }
264
+ both_sources.delete_if { |k,v| v[0] == v[1] }
265
+
266
+ if @dependencies != @locked_deps
267
+ new_deps = @dependencies - @locked_deps
268
+ deleted_deps = @locked_deps - @dependencies
269
+
270
+ if new_deps.any?
271
+ added.concat new_deps.map { |d| "* #{pretty_dep(d)}" }
272
+ end
273
+
274
+ if deleted_deps.any?
275
+ deleted.concat deleted_deps.map { |d| "* #{pretty_dep(d)}" }
276
+ end
277
+
278
+ both_sources.each do |name, sources|
279
+ changed << "* #{name} from `#{sources[0]}` to `#{sources[1]}`"
280
+ end
281
+
282
+ changes = true
283
+ end
284
+
285
+ msg << "\n\nYou have added to the Gemfile:\n" << added.join("\n") if added.any?
286
+ msg << "\n\nYou have deleted from the Gemfile:\n" << deleted.join("\n") if deleted.any?
287
+ msg << "\n\nYou have changed in the Gemfile:\n" << changed.join("\n") if changed.any?
288
+
289
+ raise ProductionError, msg if added.any? || deleted.any? || changed.any?
290
+ end
291
+
292
+ private
293
+
294
+ def pretty_dep(dep, source = false)
295
+ msg = "#{dep.name}"
296
+ msg << " (#{dep.requirement})" unless dep.requirement == Gem::Requirement.default
297
+ msg << " from the `#{dep.source}` source" if source && dep.source
298
+ msg
299
+ end
300
+
301
+ def converge_sources
302
+ locked_gem = @locked_sources.find { |s| Source::Rubygems === s }
303
+ actual_gem = @sources.find { |s| Source::Rubygems === s }
304
+
305
+ if locked_gem && actual_gem
306
+ locked_gem.merge_remotes actual_gem
307
+ end
308
+
309
+ @sources.map! do |source|
310
+ @locked_sources.find { |s| s == source } || source
311
+ end
312
+
313
+ @sources.each do |source|
314
+ source.unlock! if source.respond_to?(:unlock!) && @unlock[:sources].include?(source.name)
315
+ end
316
+ end
317
+
318
+ def converge_dependencies
319
+ (@dependencies + @locked_deps).each do |dep|
320
+ if dep.source
321
+ dep.source = @sources.find { |s| dep.source == s }
322
+ end
323
+ end
324
+ end
325
+
326
+ # Remove elements from the locked specs that are expired. This will most
327
+ # commonly happen if the Gemfile has changed since the lockfile was last
328
+ # generated
329
+ def converge_locked_specs
330
+ deps = []
331
+
332
+ # Build a list of dependencies that are the same in the Gemfile
333
+ # and Gemfile.lock. If the Gemfile modified a dependency, but
334
+ # the gem in the Gemfile.lock still satisfies it, this is fine
335
+ # too.
336
+ @dependencies.each do |dep|
337
+ locked_dep = @locked_deps.find { |d| dep == d }
338
+
339
+ if in_locked_deps?(dep, locked_dep) || satisfies_locked_spec?(dep)
340
+ deps << dep
341
+ elsif dep.source.is_a?(Source::Path) && (!locked_dep || dep.source != locked_dep.source)
342
+ @locked_specs.each do |s|
343
+ @unlock[:gems] << s.name if s.source == dep.source
344
+ end
345
+
346
+ dep.source.unlock! if dep.source.respond_to?(:unlock!)
347
+ dep.source.specs.each { |s| @unlock[:gems] << s.name }
348
+ end
349
+ end
350
+
351
+ converged = []
352
+ @locked_specs.each do |s|
353
+ s.source = @sources.find { |src| s.source == src }
354
+
355
+ # Don't add a spec to the list if its source is expired. For example,
356
+ # if you change a Git gem to Rubygems.
357
+ next if s.source.nil? || @unlock[:sources].include?(s.name)
358
+ # If the spec is from a path source and it doesn't exist anymore
359
+ # then we just unlock it.
360
+
361
+ # Path sources have special logic
362
+ if s.source.instance_of?(Source::Path)
363
+ other = s.source.specs[s].first
364
+
365
+ # If the spec is no longer in the path source, unlock it. This
366
+ # commonly happens if the version changed in the gemspec
367
+ next unless other
368
+ # If the dependencies of the path source have changed, unlock it
369
+ next unless s.dependencies.sort == other.dependencies.sort
370
+ end
371
+
372
+ converged << s
373
+ end
374
+
375
+ resolve = SpecSet.new(converged)
376
+ resolve = resolve.for(expand_dependencies(deps, true), @unlock[:gems])
377
+ diff = @locked_specs.to_a - resolve.to_a
378
+
379
+ # Now, we unlock any sources that do not have anymore gems pinned to it
380
+ @sources.each do |source|
381
+ next unless source.respond_to?(:unlock!)
382
+
383
+ unless resolve.any? { |s| s.source == source }
384
+ source.unlock! if diff.any? { |s| s.source == source }
385
+ end
386
+ end
387
+
388
+ resolve
389
+ end
390
+
391
+ def in_locked_deps?(dep, d)
392
+ d && dep.source == d.source
393
+ end
394
+
395
+ def satisfies_locked_spec?(dep)
396
+ @locked_specs.any? { |s| s.satisfies?(dep) && (!dep.source || s.source == dep.source) }
397
+ end
398
+
399
+ def expanded_dependencies
400
+ @expanded_dependencies ||= expand_dependencies(dependencies, @remote)
401
+ end
402
+
403
+ def expand_dependencies(dependencies, remote = false)
404
+ deps = []
405
+ dependencies.each do |dep|
406
+ dep = Dependency.new(dep, ">= 0") unless dep.respond_to?(:name)
407
+ dep.gem_platforms(@platforms).each do |p|
408
+ deps << DepProxy.new(dep, p) if remote || p == generic(Gem::Platform.local)
409
+ end
410
+ end
411
+ deps
412
+ end
413
+
414
+ def sorted_sources
415
+ @sources.sort_by do |s|
416
+ # Place GEM at the top
417
+ [ s.is_a?(Source::Rubygems) ? 1 : 0, s.to_s ]
418
+ end
419
+ end
420
+
421
+ def requested_dependencies
422
+ groups = self.groups - Bundler.settings.without
423
+ groups.map! { |g| g.to_sym }
424
+ dependencies.reject { |d| !d.should_include? || (d.groups & groups).empty? }
425
+ end
426
+ end
427
+ end
@@ -0,0 +1,114 @@
1
+ require 'rubygems/dependency'
2
+ require 'bundler/shared_helpers'
3
+ require 'bundler/rubygems_ext'
4
+
5
+ module Bundler
6
+ class Dependency < Gem::Dependency
7
+ attr_reader :autorequire
8
+ attr_reader :groups
9
+ attr_reader :platforms
10
+
11
+ PLATFORM_MAP = {
12
+ :ruby => Gem::Platform::RUBY,
13
+ :ruby_18 => Gem::Platform::RUBY,
14
+ :ruby_19 => Gem::Platform::RUBY,
15
+ :mri => Gem::Platform::RUBY,
16
+ :mri_18 => Gem::Platform::RUBY,
17
+ :mri_19 => Gem::Platform::RUBY,
18
+ :jruby => Gem::Platform::JAVA,
19
+ :mswin => Gem::Platform::MSWIN
20
+ }.freeze
21
+
22
+ def initialize(name, version, options = {}, &blk)
23
+ super(name, version)
24
+
25
+ @autorequire = nil
26
+ @groups = Array(options["group"] || :default).map { |g| g.to_sym }
27
+ @source = options["source"]
28
+ @platforms = Array(options["platforms"])
29
+ @env = options["env"]
30
+
31
+ if options.key?('require')
32
+ @autorequire = Array(options['require'] || [])
33
+ end
34
+ end
35
+
36
+ def gem_platforms(valid_platforms)
37
+ return valid_platforms if @platforms.empty?
38
+
39
+ platforms = []
40
+ @platforms.each do |p|
41
+ platform = PLATFORM_MAP[p]
42
+ next unless valid_platforms.include?(platform)
43
+ platforms |= [platform]
44
+ end
45
+ platforms
46
+ end
47
+
48
+ def should_include?
49
+ current_env? && current_platform?
50
+ end
51
+
52
+ def current_env?
53
+ return true unless @env
54
+ if Hash === @env
55
+ @env.all? do |key, val|
56
+ ENV[key.to_s] && (String === val ? ENV[key.to_s] == val : ENV[key.to_s] =~ val)
57
+ end
58
+ else
59
+ ENV[@env.to_s]
60
+ end
61
+ end
62
+
63
+ def current_platform?
64
+ return true if @platforms.empty?
65
+ @platforms.any? { |p| send("#{p}?") }
66
+ end
67
+
68
+ def to_lock
69
+ out = " #{name}"
70
+
71
+ unless requirement == Gem::Requirement.default
72
+ out << " (#{requirement.to_s})"
73
+ end
74
+
75
+ out << '!' if source
76
+
77
+ out << "\n"
78
+ end
79
+
80
+ private
81
+
82
+ def ruby?
83
+ !mswin? && (!defined?(RUBY_ENGINE) || RUBY_ENGINE == "ruby" || RUBY_ENGINE == "rbx")
84
+ end
85
+
86
+ def ruby_18?
87
+ ruby? && RUBY_VERSION < "1.9"
88
+ end
89
+
90
+ def ruby_19?
91
+ ruby? && RUBY_VERSION >= "1.9"
92
+ end
93
+
94
+ def mri?
95
+ !mswin? && (!defined?(RUBY_ENGINE) || RUBY_ENGINE == "ruby")
96
+ end
97
+
98
+ def mri_18?
99
+ mri? && RUBY_VERSION < "1.9"
100
+ end
101
+
102
+ def mri_19?
103
+ mri? && RUBY_VERSION >= "1.9"
104
+ end
105
+
106
+ def jruby?
107
+ defined?(RUBY_ENGINE) && RUBY_ENGINE == "jruby"
108
+ end
109
+
110
+ def mswin?
111
+ # w0t?
112
+ end
113
+ end
114
+ end