bundler 1.13.7 → 1.14.0.pre.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.

Files changed (112) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/.rubocop_todo.yml +100 -18
  4. data/.travis.yml +32 -18
  5. data/CHANGELOG.md +64 -2
  6. data/DEVELOPMENT.md +5 -3
  7. data/ISSUES.md +17 -0
  8. data/README.md +7 -0
  9. data/Rakefile +34 -23
  10. data/bin/rubocop +1 -1
  11. data/bundler.gemspec +2 -2
  12. data/exe/bundle +4 -6
  13. data/lib/bundler.rb +57 -5
  14. data/lib/bundler/cli.rb +51 -38
  15. data/lib/bundler/cli/binstubs.rb +1 -1
  16. data/lib/bundler/cli/cache.rb +1 -1
  17. data/lib/bundler/cli/check.rb +1 -1
  18. data/lib/bundler/cli/clean.rb +1 -1
  19. data/lib/bundler/cli/common.rb +30 -0
  20. data/lib/bundler/cli/doctor.rb +17 -19
  21. data/lib/bundler/cli/exec.rb +6 -0
  22. data/lib/bundler/cli/gem.rb +18 -4
  23. data/lib/bundler/cli/install.rb +9 -25
  24. data/lib/bundler/cli/lock.rb +8 -7
  25. data/lib/bundler/cli/outdated.rb +163 -56
  26. data/lib/bundler/cli/platform.rb +1 -1
  27. data/lib/bundler/cli/show.rb +1 -1
  28. data/lib/bundler/cli/update.rb +10 -23
  29. data/lib/bundler/compact_index_client.rb +108 -0
  30. data/lib/bundler/compact_index_client/cache.rb +119 -0
  31. data/lib/bundler/compact_index_client/updater.rb +88 -0
  32. data/lib/bundler/current_ruby.rb +4 -3
  33. data/lib/bundler/definition.rb +107 -17
  34. data/lib/bundler/dependency.rb +6 -0
  35. data/lib/bundler/dsl.rb +3 -2
  36. data/lib/bundler/env.rb +27 -18
  37. data/lib/bundler/errors.rb +22 -0
  38. data/lib/bundler/feature_flag.rb +32 -0
  39. data/lib/bundler/fetcher.rb +2 -2
  40. data/lib/bundler/fetcher/compact_index.rb +17 -5
  41. data/lib/bundler/fetcher/dependency.rb +1 -1
  42. data/lib/bundler/fetcher/downloader.rb +11 -0
  43. data/lib/bundler/friendly_errors.rb +28 -7
  44. data/lib/bundler/gem_helper.rb +1 -1
  45. data/lib/bundler/gem_helpers.rb +69 -1
  46. data/lib/bundler/gemdeps.rb +28 -0
  47. data/lib/bundler/index.rb +9 -4
  48. data/lib/bundler/inline.rb +3 -3
  49. data/lib/bundler/installer.rb +3 -2
  50. data/lib/bundler/installer/gem_installer.rb +2 -2
  51. data/lib/bundler/installer/parallel_installer.rb +40 -9
  52. data/lib/bundler/lazy_specification.rb +16 -1
  53. data/lib/bundler/lockfile_parser.rb +1 -2
  54. data/lib/bundler/match_platform.rb +12 -3
  55. data/lib/bundler/plugin.rb +4 -2
  56. data/lib/bundler/plugin/api.rb +2 -1
  57. data/lib/bundler/plugin/api/source.rb +1 -1
  58. data/lib/bundler/postit_trampoline.rb +12 -7
  59. data/lib/bundler/remote_specification.rb +5 -0
  60. data/lib/bundler/resolver.rb +59 -49
  61. data/lib/bundler/retry.rb +4 -1
  62. data/lib/bundler/ruby_version.rb +5 -0
  63. data/lib/bundler/rubygems_ext.rb +5 -0
  64. data/lib/bundler/rubygems_gem_installer.rb +60 -0
  65. data/lib/bundler/rubygems_integration.rb +28 -2
  66. data/lib/bundler/runtime.rb +2 -1
  67. data/lib/bundler/settings.rb +29 -5
  68. data/lib/bundler/setup.rb +1 -1
  69. data/lib/bundler/shared_helpers.rb +26 -15
  70. data/lib/bundler/source.rb +5 -0
  71. data/lib/bundler/source/git.rb +1 -1
  72. data/lib/bundler/source/git/git_proxy.rb +5 -0
  73. data/lib/bundler/source/path.rb +6 -1
  74. data/lib/bundler/source/rubygems.rb +11 -1
  75. data/lib/bundler/spec_set.rb +32 -13
  76. data/lib/bundler/templates/newgem/README.md.tt +1 -1
  77. data/lib/bundler/templates/newgem/bin/console.tt +1 -1
  78. data/lib/bundler/templates/newgem/gitignore.tt +5 -0
  79. data/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt +1 -1
  80. data/lib/bundler/templates/newgem/spec/spec_helper.rb.tt +10 -1
  81. data/lib/bundler/ui/shell.rb +4 -0
  82. data/lib/bundler/ui/silent.rb +9 -0
  83. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +7 -0
  84. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/action.rb +1 -1
  85. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb +2 -2
  86. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_vertex.rb +2 -2
  87. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/delete_edge.rb +62 -0
  88. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb +1 -1
  89. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb +12 -1
  90. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/set_payload.rb +2 -2
  91. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb +2 -2
  92. data/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +1 -1
  93. data/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +22 -13
  94. data/lib/bundler/vendor/{net → net-http-persistent/lib/net}/http/faster.rb +1 -0
  95. data/lib/bundler/vendor/{net → net-http-persistent/lib/net}/http/persistent.rb +24 -23
  96. data/lib/bundler/vendor/{net → net-http-persistent/lib/net}/http/persistent/ssl_reuse.rb +2 -1
  97. data/lib/bundler/vendored_persistent.rb +9 -4
  98. data/lib/bundler/version.rb +1 -1
  99. data/lib/bundler/worker.rb +27 -5
  100. data/lib/bundler/yaml_serializer.rb +1 -1
  101. data/man/bundle-config.ronn +29 -2
  102. data/man/bundle-install.ronn +1 -1
  103. data/man/bundle-lock.ronn +47 -0
  104. data/man/bundle-outdated.ronn +107 -0
  105. data/man/bundle-update.ronn +152 -3
  106. data/man/bundle.ronn +27 -9
  107. data/man/gemfile.5.ronn +8 -0
  108. metadata +37 -31
  109. data/lib/bundler/vendor/compact_index_client/lib/compact_index_client.rb +0 -79
  110. data/lib/bundler/vendor/compact_index_client/lib/compact_index_client/cache.rb +0 -112
  111. data/lib/bundler/vendor/compact_index_client/lib/compact_index_client/updater.rb +0 -80
  112. data/lib/bundler/vendor/compact_index_client/lib/compact_index_client/version.rb +0 -4
@@ -27,20 +27,20 @@ We divide `bundle` subcommands into primary commands and utilities.
27
27
 
28
28
  ## PRIMARY COMMANDS
29
29
 
30
- * [bundle install(1)][bundle-install]:
30
+ * [`bundle install(1)`][bundle-install]:
31
31
  Install the gems specified by the `Gemfile` or `Gemfile.lock`
32
32
 
33
- * [bundle update(1)][bundle-update]:
33
+ * [`bundle update(1)`][bundle-update]:
34
34
  Update dependencies to their latest versions
35
35
 
36
- * [bundle package(1)][bundle-package]:
36
+ * [`bundle package(1)`][bundle-package]:
37
37
  Package the .gem files required by your application into the
38
38
  `vendor/cache` directory
39
39
 
40
- * [bundle exec(1)][bundle-exec]:
40
+ * [`bundle exec(1)`][bundle-exec]:
41
41
  Execute a script in the context of the current bundle
42
42
 
43
- * [bundle config(1)][bundle-config]:
43
+ * [`bundle config(1)`][bundle-config]:
44
44
  Specify and read configuration options for bundler
45
45
 
46
46
  * `bundle help(1)`:
@@ -55,7 +55,7 @@ We divide `bundle` subcommands into primary commands and utilities.
55
55
  * `bundle show(1)`:
56
56
  Show the source location of a particular gem in the bundle
57
57
 
58
- * `bundle outdated(1)`:
58
+ * [`bundle outdated(1)`][bundle-outdated]:
59
59
  Show all of the outdated gems in the current bundle
60
60
 
61
61
  * `bundle console(1)`:
@@ -64,7 +64,7 @@ We divide `bundle` subcommands into primary commands and utilities.
64
64
  * `bundle open(1)`:
65
65
  Open an installed gem in the editor
66
66
 
67
- * `bundle lock(1)`:
67
+ * [`bundle lock(1)`][bundle-lock]:
68
68
  Generate a lockfile for your dependencies
69
69
 
70
70
  * `bundle viz(1)`:
@@ -73,10 +73,10 @@ We divide `bundle` subcommands into primary commands and utilities.
73
73
  * `bundle init(1)`:
74
74
  Generate a simple `Gemfile`, placed in the current directory
75
75
 
76
- * [bundle gem(1)][bundle-gem]:
76
+ * [`bundle gem(1)`][bundle-gem]:
77
77
  Create a simple gem, suitable for development with bundler
78
78
 
79
- * [bundle platform(1)][bundle-platform]:
79
+ * [`bundle platform(1)`][bundle-platform]:
80
80
  Display platform compatibility information
81
81
 
82
82
  * `bundle clean(1)`:
@@ -91,6 +91,24 @@ When running a command that isn't listed in PRIMARY COMMANDS or UTILITIES,
91
91
  Bundler will try to find an executable on your path named `bundler-<command>`
92
92
  and execute it, passing down any extra arguments to it.
93
93
 
94
+ ## BUNDLER TRAMPOLINING
95
+
96
+ Bundler includes a feature called trampolining, designed to allow a single
97
+ developer to work on multiple projects, each on different Bundler versions.
98
+ The trampoline will infer the correct version of Bundler to use for each project
99
+ and load that version instead of the version directly invoked (which is almost
100
+ always the newest version installed locally).
101
+
102
+ Bundler by default will use the Bundler version in the current directory to
103
+ determine the version to trampoline to, reading from the `BUNDLED WITH` section.
104
+ However, if the `BUNDLER_VERSION` environment variable is set, that version will
105
+ override the lockfile inference and can be used in directories without a
106
+ lockfile.
107
+
108
+ Until the target version is Bundler 2 or later, `BUNDLE_TRAMPOLINE_FORCE` must
109
+ be set for the trampoline to be used. Additionally, `BUNDLE_TRAMPOLINE_DISABLE` can
110
+ be set to completely disable the trampoline.
111
+
94
112
  ## OBSOLETE
95
113
 
96
114
  These commands are obsolete and should no longer be used
@@ -187,6 +187,8 @@ There are a number of `Gemfile` platforms:
187
187
  _ruby_ `AND` version 2.3
188
188
  * `ruby_24`:
189
189
  _ruby_ `AND` version 2.4
190
+ * `ruby_25`:
191
+ _ruby_ `AND` version 2.5
190
192
  * `mri`:
191
193
  Same as _ruby_, but not Rubinius
192
194
  * `mri_18`:
@@ -203,6 +205,8 @@ There are a number of `Gemfile` platforms:
203
205
  _mri_ `AND` version 2.3
204
206
  * `mri_24`:
205
207
  _mri_ `AND` version 2.4
208
+ * `mri_25`:
209
+ _mri_ `AND` version 2.5
206
210
  * `rbx`:
207
211
  Same as _ruby_, but only Rubinius (not MRI)
208
212
  * `jruby`:
@@ -225,6 +229,8 @@ There are a number of `Gemfile` platforms:
225
229
  _mingw_ `AND` version 2.3
226
230
  * `mingw_24`:
227
231
  _mingw_ `AND` version 2.4
232
+ * `mingw_25`:
233
+ _mingw_ `AND` version 2.5
228
234
  * `x64_mingw`:
229
235
  Windows 64 bit 'mingw32' platform (aka RubyInstaller x64)
230
236
  * `x64_mingw_20`:
@@ -237,6 +243,8 @@ There are a number of `Gemfile` platforms:
237
243
  _x64_mingw_ `AND` version 2.3
238
244
  * `x64_mingw_24`:
239
245
  _x64_mingw_ `AND` version 2.4
246
+ * `x64_mingw_25`:
247
+ _x64_mingw_ `AND` version 2.5
240
248
 
241
249
  As with groups, you can specify one or more platforms:
242
250
 
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: 1.13.7
4
+ version: 1.14.0.pre.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - André Arko
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2016-12-25 00:00:00.000000000 Z
12
+ date: 2016-12-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: automatiek
@@ -152,6 +152,9 @@ files:
152
152
  - lib/bundler/cli/show.rb
153
153
  - lib/bundler/cli/update.rb
154
154
  - lib/bundler/cli/viz.rb
155
+ - lib/bundler/compact_index_client.rb
156
+ - lib/bundler/compact_index_client/cache.rb
157
+ - lib/bundler/compact_index_client/updater.rb
155
158
  - lib/bundler/constants.rb
156
159
  - lib/bundler/current_ruby.rb
157
160
  - lib/bundler/definition.rb
@@ -164,6 +167,7 @@ files:
164
167
  - lib/bundler/env.rb
165
168
  - lib/bundler/environment_preserver.rb
166
169
  - lib/bundler/errors.rb
170
+ - lib/bundler/feature_flag.rb
167
171
  - lib/bundler/fetcher.rb
168
172
  - lib/bundler/fetcher/base.rb
169
173
  - lib/bundler/fetcher/compact_index.rb
@@ -176,6 +180,7 @@ files:
176
180
  - lib/bundler/gem_remote_fetcher.rb
177
181
  - lib/bundler/gem_tasks.rb
178
182
  - lib/bundler/gem_version_promoter.rb
183
+ - lib/bundler/gemdeps.rb
179
184
  - lib/bundler/graph.rb
180
185
  - lib/bundler/index.rb
181
186
  - lib/bundler/injector.rb
@@ -186,28 +191,6 @@ files:
186
191
  - lib/bundler/installer/standalone.rb
187
192
  - lib/bundler/lazy_specification.rb
188
193
  - lib/bundler/lockfile_parser.rb
189
- - lib/bundler/man/bundle
190
- - lib/bundler/man/bundle-binstubs
191
- - lib/bundler/man/bundle-binstubs.txt
192
- - lib/bundler/man/bundle-config
193
- - lib/bundler/man/bundle-config.txt
194
- - lib/bundler/man/bundle-exec
195
- - lib/bundler/man/bundle-exec.txt
196
- - lib/bundler/man/bundle-gem
197
- - lib/bundler/man/bundle-gem.txt
198
- - lib/bundler/man/bundle-install
199
- - lib/bundler/man/bundle-install.txt
200
- - lib/bundler/man/bundle-lock
201
- - lib/bundler/man/bundle-lock.txt
202
- - lib/bundler/man/bundle-package
203
- - lib/bundler/man/bundle-package.txt
204
- - lib/bundler/man/bundle-platform
205
- - lib/bundler/man/bundle-platform.txt
206
- - lib/bundler/man/bundle-update
207
- - lib/bundler/man/bundle-update.txt
208
- - lib/bundler/man/bundle.txt
209
- - lib/bundler/man/gemfile.5
210
- - lib/bundler/man/gemfile.5.txt
211
194
  - lib/bundler/match_platform.rb
212
195
  - lib/bundler/mirror.rb
213
196
  - lib/bundler/plugin.rb
@@ -279,10 +262,6 @@ files:
279
262
  - lib/bundler/ui/shell.rb
280
263
  - lib/bundler/ui/silent.rb
281
264
  - lib/bundler/uri_credentials_filter.rb
282
- - lib/bundler/vendor/compact_index_client/lib/compact_index_client.rb
283
- - lib/bundler/vendor/compact_index_client/lib/compact_index_client/cache.rb
284
- - lib/bundler/vendor/compact_index_client/lib/compact_index_client/updater.rb
285
- - lib/bundler/vendor/compact_index_client/lib/compact_index_client/version.rb
286
265
  - lib/bundler/vendor/molinillo/lib/molinillo.rb
287
266
  - lib/bundler/vendor/molinillo/lib/molinillo/delegates/resolution_state.rb
288
267
  - lib/bundler/vendor/molinillo/lib/molinillo/delegates/specification_provider.rb
@@ -290,6 +269,7 @@ files:
290
269
  - lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/action.rb
291
270
  - lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb
292
271
  - lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_vertex.rb
272
+ - lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/delete_edge.rb
293
273
  - lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb
294
274
  - lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb
295
275
  - lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/set_payload.rb
@@ -302,9 +282,9 @@ files:
302
282
  - lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb
303
283
  - lib/bundler/vendor/molinillo/lib/molinillo/resolver.rb
304
284
  - lib/bundler/vendor/molinillo/lib/molinillo/state.rb
305
- - lib/bundler/vendor/net/http/faster.rb
306
- - lib/bundler/vendor/net/http/persistent.rb
307
- - lib/bundler/vendor/net/http/persistent/ssl_reuse.rb
285
+ - lib/bundler/vendor/net-http-persistent/lib/net/http/faster.rb
286
+ - lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb
287
+ - lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/ssl_reuse.rb
308
288
  - lib/bundler/vendor/postit/lib/postit.rb
309
289
  - lib/bundler/vendor/postit/lib/postit/environment.rb
310
290
  - lib/bundler/vendor/postit/lib/postit/installer.rb
@@ -350,17 +330,42 @@ files:
350
330
  - lib/bundler/vlad.rb
351
331
  - lib/bundler/worker.rb
352
332
  - lib/bundler/yaml_serializer.rb
333
+ - man/bundle-binstubs.1
334
+ - man/bundle-binstubs.1.txt
353
335
  - man/bundle-binstubs.ronn
336
+ - man/bundle-config.1
337
+ - man/bundle-config.1.txt
354
338
  - man/bundle-config.ronn
339
+ - man/bundle-exec.1
340
+ - man/bundle-exec.1.txt
355
341
  - man/bundle-exec.ronn
342
+ - man/bundle-gem.1
343
+ - man/bundle-gem.1.txt
356
344
  - man/bundle-gem.ronn
345
+ - man/bundle-install.1
346
+ - man/bundle-install.1.txt
357
347
  - man/bundle-install.ronn
348
+ - man/bundle-lock.1
349
+ - man/bundle-lock.1.txt
358
350
  - man/bundle-lock.ronn
351
+ - man/bundle-outdated.1
352
+ - man/bundle-outdated.1.txt
353
+ - man/bundle-outdated.ronn
354
+ - man/bundle-package.1
355
+ - man/bundle-package.1.txt
359
356
  - man/bundle-package.ronn
357
+ - man/bundle-platform.1
358
+ - man/bundle-platform.1.txt
360
359
  - man/bundle-platform.ronn
360
+ - man/bundle-update.1
361
+ - man/bundle-update.1.txt
361
362
  - man/bundle-update.ronn
363
+ - man/bundle.1
364
+ - man/bundle.1.txt
362
365
  - man/bundle.ronn
366
+ - man/gemfile.5
363
367
  - man/gemfile.5.ronn
368
+ - man/gemfile.5.txt
364
369
  - man/index.txt
365
370
  homepage: http://bundler.io
366
371
  licenses:
@@ -387,3 +392,4 @@ signing_key:
387
392
  specification_version: 4
388
393
  summary: The best way to manage your application's dependencies
389
394
  test_files: []
395
+ has_rdoc:
@@ -1,79 +0,0 @@
1
- # frozen_string_literal: true
2
- require "pathname"
3
- require "set"
4
-
5
- class Bundler::CompactIndexClient
6
- class Error < StandardError; end
7
-
8
- require "bundler/vendor/compact_index_client/lib/compact_index_client/cache"
9
- require "bundler/vendor/compact_index_client/lib/compact_index_client/updater"
10
- require "bundler/vendor/compact_index_client/lib/compact_index_client/version"
11
-
12
- attr_reader :directory
13
-
14
- # @return [Lambda] A lambda that takes an array of inputs and a block, and
15
- # maps the inputs with the block in parallel.
16
- #
17
- attr_accessor :in_parallel
18
-
19
- def initialize(directory, fetcher)
20
- @directory = Pathname.new(directory)
21
- @updater = Updater.new(fetcher)
22
- @cache = Cache.new(@directory)
23
- @endpoints = Set.new
24
- @info_checksums_by_name = {}
25
- @parsed_checksums = false
26
- @in_parallel = lambda do |inputs, &blk|
27
- inputs.map(&blk)
28
- end
29
- end
30
-
31
- def names
32
- update(@cache.names_path, "names")
33
- @cache.names
34
- end
35
-
36
- def versions
37
- update(@cache.versions_path, "versions")
38
- versions, @info_checksums_by_name = @cache.versions
39
- versions
40
- end
41
-
42
- def dependencies(names)
43
- in_parallel.call(names) do |name|
44
- update_info(name)
45
- @cache.dependencies(name).map {|d| d.unshift(name) }
46
- end.flatten(1)
47
- end
48
-
49
- def spec(name, version, platform = nil)
50
- update_info(name)
51
- @cache.specific_dependency(name, version, platform)
52
- end
53
-
54
- def update_and_parse_checksums!
55
- return @info_checksums_by_name if @parsed_checksums
56
- update(@cache.versions_path, "versions")
57
- @info_checksums_by_name = @cache.checksums
58
- @parsed_checksums = true
59
- end
60
-
61
- private
62
-
63
- def update(local_path, remote_path)
64
- return unless @endpoints.add?(remote_path)
65
- @updater.update(local_path, url(remote_path))
66
- end
67
-
68
- def update_info(name)
69
- path = @cache.info_path(name)
70
- checksum = @updater.checksum_for_file(path)
71
- return unless existing = @info_checksums_by_name[name]
72
- return if checksum == existing
73
- update(path, "info/#{name}")
74
- end
75
-
76
- def url(path)
77
- path
78
- end
79
- end
@@ -1,112 +0,0 @@
1
- # frozen_string_literal: true
2
- require "digest/md5"
3
- class Bundler::CompactIndexClient
4
- class Cache
5
- attr_reader :directory
6
-
7
- def initialize(directory)
8
- @directory = Pathname.new(directory).expand_path
9
- info_roots.each {|dir| FileUtils.mkdir_p(dir) }
10
- end
11
-
12
- def names
13
- lines(names_path)
14
- end
15
-
16
- def names_path
17
- directory.join("names")
18
- end
19
-
20
- def versions
21
- versions_by_name = Hash.new {|hash, key| hash[key] = [] }
22
- info_checksums_by_name = {}
23
-
24
- lines(versions_path).each do |line|
25
- name, versions_string, info_checksum = line.split(" ", 3)
26
- info_checksums_by_name[name] = info_checksum || ""
27
- versions_string.split(",").each do |version|
28
- if version.start_with?("-")
29
- version = version[1..-1].split("-", 2).unshift(name)
30
- versions_by_name[name].delete(version)
31
- else
32
- version = version.split("-", 2).unshift(name)
33
- versions_by_name[name] << version
34
- end
35
- end
36
- end
37
-
38
- [versions_by_name, info_checksums_by_name]
39
- end
40
-
41
- def versions_path
42
- directory.join("versions")
43
- end
44
-
45
- def checksums
46
- checksums = {}
47
-
48
- lines(versions_path).each do |line|
49
- name, _, checksum = line.split(" ", 3)
50
- checksums[name] = checksum
51
- end
52
-
53
- checksums
54
- end
55
-
56
- def dependencies(name)
57
- lines(info_path(name)).map do |line|
58
- parse_gem(line)
59
- end
60
- end
61
-
62
- def info_path(name)
63
- name = name.to_s
64
- if name =~ /[^a-z0-9_-]/
65
- name += "-#{Digest::MD5.hexdigest(name).downcase}"
66
- info_roots.last.join(name)
67
- else
68
- info_roots.first.join(name)
69
- end
70
- end
71
-
72
- def specific_dependency(name, version, platform)
73
- pattern = [version, platform].compact.join("-")
74
- return nil if pattern.empty?
75
-
76
- gem_lines = info_path(name).read
77
- gem_line = gem_lines[/^#{Regexp.escape(pattern)}\b.*/, 0]
78
- gem_line ? parse_gem(gem_line) : nil
79
- end
80
-
81
- private
82
-
83
- def lines(path)
84
- return [] unless path.file?
85
- lines = path.read.split("\n")
86
- header = lines.index("---")
87
- lines = header ? lines[header + 1..-1] : lines
88
- end
89
-
90
- def parse_gem(string)
91
- version_and_platform, rest = string.split(" ", 2)
92
- version, platform = version_and_platform.split("-", 2)
93
- dependencies, requirements = rest.split("|", 2).map {|s| s.split(",") } if rest
94
- dependencies = dependencies ? dependencies.map {|d| parse_dependency(d) } : []
95
- requirements = requirements ? requirements.map {|r| parse_dependency(r) } : []
96
- [version, platform, dependencies, requirements]
97
- end
98
-
99
- def parse_dependency(string)
100
- dependency = string.split(":")
101
- dependency[-1] = dependency[-1].split("&") if dependency.size > 1
102
- dependency
103
- end
104
-
105
- def info_roots
106
- [
107
- directory.join("info"),
108
- directory.join("info-special-characters"),
109
- ]
110
- end
111
- end
112
- end