php-composer 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +10 -0
  3. data/.rspec +2 -0
  4. data/.rubocop.yml +1006 -0
  5. data/Gemfile +15 -0
  6. data/LICENSE.txt +21 -0
  7. data/README.md +35 -0
  8. data/Rakefile +1 -0
  9. data/lib/composer.rb +52 -0
  10. data/lib/composer/error.rb +8 -0
  11. data/lib/composer/json/json_file.rb +270 -0
  12. data/lib/composer/json/json_formatter.rb +159 -0
  13. data/lib/composer/json/json_validaton_error.rb +29 -0
  14. data/lib/composer/manager.rb +79 -0
  15. data/lib/composer/package/alias_package.rb +273 -0
  16. data/lib/composer/package/base_package.rb +130 -0
  17. data/lib/composer/package/complete_package.rb +55 -0
  18. data/lib/composer/package/dumper/hash_dumper.rb +169 -0
  19. data/lib/composer/package/link.rb +51 -0
  20. data/lib/composer/package/link_constraint/base_constraint.rb +36 -0
  21. data/lib/composer/package/link_constraint/empty_constraint.rb +35 -0
  22. data/lib/composer/package/link_constraint/multi_constraint.rb +67 -0
  23. data/lib/composer/package/link_constraint/specific_constraint.rb +41 -0
  24. data/lib/composer/package/link_constraint/version_constraint.rb +221 -0
  25. data/lib/composer/package/loader/hash_loader.rb +316 -0
  26. data/lib/composer/package/loader/json_loader.rb +47 -0
  27. data/lib/composer/package/loader/project_attributes_loader.rb +71 -0
  28. data/lib/composer/package/loader/project_root_package_loader.rb +28 -0
  29. data/lib/composer/package/package.rb +118 -0
  30. data/lib/composer/package/root_alias_package.rb +37 -0
  31. data/lib/composer/package/root_package.rb +37 -0
  32. data/lib/composer/package/version/version_parser.rb +583 -0
  33. data/lib/composer/package/version/version_selector.rb +106 -0
  34. data/lib/composer/provider.rb +94 -0
  35. data/lib/composer/repository/array_repository.rb +195 -0
  36. data/lib/composer/repository/filesystem_repository.rb +86 -0
  37. data/lib/composer/repository/writeable_array_repository.rb +60 -0
  38. data/lib/composer/version.rb +3 -0
  39. data/php-composer.gemspec +31 -0
  40. data/resources/composer-schema.json +421 -0
  41. metadata +188 -0
@@ -0,0 +1,60 @@
1
+ #
2
+ # This file was ported to ruby from Composer php source code.
3
+ # Original Source: Composer\Repository\WritableArrayRepository.php
4
+ #
5
+ # (c) Nils Adermann <naderman@naderman.de>
6
+ # Jordi Boggiano <j.boggiano@seld.be>
7
+ #
8
+ # For the full copyright and license information, please view the LICENSE
9
+ # file that was distributed with this source code.
10
+ #
11
+
12
+ module Composer
13
+ module Repository
14
+ # Writable array repository.
15
+ #
16
+ # PHP Authors:
17
+ # Jordi Boggiano <j.boggiano@seld.be>
18
+ #
19
+ # Ruby Authors:
20
+ # Ioannis Kappas <ikappas@devworks.gr>
21
+ class WritableArrayRepository < Composer::Repository::ArrayRepository
22
+
23
+ def initialize(packages = [])
24
+ super
25
+ end
26
+
27
+ def write
28
+ end
29
+
30
+ def reload
31
+ end
32
+
33
+ def canonical_packages
34
+ packages_uncanonicalized = packages
35
+
36
+ # get at most one package of each name, prefering non-aliased ones
37
+ packages_by_name = {}
38
+ packages_uncanonicalized.each do |package|
39
+ if !packages_by_name.key?(package.name) ||
40
+ packages_by_name[package.name].instance_of(Composer::Package::AliasPackage)
41
+
42
+ packages_by_name[package.name] = package
43
+
44
+ end
45
+ end
46
+
47
+ # unfold aliased packages
48
+ results = []
49
+ packages_by_name.each do |name, package|
50
+ while package.instance_of(Composer::Package::AliasPackage)
51
+ package = package.alias_of
52
+ end
53
+ results[] = package
54
+ end
55
+
56
+ results
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,3 @@
1
+ module Composer
2
+ VERSION = '0.1.0'
3
+ end
@@ -0,0 +1,31 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'composer/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'php-composer'
8
+ spec.version = Composer::VERSION
9
+ spec.authors = ['Ioannis Kappas']
10
+ spec.email = ['ikappas@devworks.gr']
11
+
12
+ spec.summary = %q{PHP Composer Ruby Gem}
13
+ spec.description = %q{A ruby gem library for consistent interactions with php composer dependency manager.}
14
+ spec.homepage = %q{http://github.com/ikappas/php-composer/tree/master}
15
+ spec.license = 'MIT'
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.require_paths = ['lib']
19
+
20
+ spec.required_ruby_version = '>= 1.8.7'
21
+ spec.required_rubygems_version = '>= 1.8'
22
+
23
+ spec.add_runtime_dependency 'json', '~> 1.8'
24
+ spec.add_runtime_dependency 'json-schema', '~> 2.5'
25
+
26
+ spec.add_development_dependency 'bundler', '~> 1.8'
27
+ spec.add_development_dependency 'rake', '~> 10.0'
28
+ spec.add_development_dependency 'rspec', '~> 5.0'
29
+ spec.add_development_dependency 'rubocop', '~> 0.28', '>= 0.28.0'
30
+ spec.add_development_dependency 'simplecov', '~> 0.9'
31
+ end
@@ -0,0 +1,421 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-04/schema#",
3
+ "name": "Package",
4
+ "type": "object",
5
+ "additionalProperties": false,
6
+ "required": [ "name", "description" ],
7
+ "properties": {
8
+ "name": {
9
+ "type": "string",
10
+ "description": "Package name, including 'vendor-name/' prefix."
11
+ },
12
+ "type": {
13
+ "description": "Package type, either 'library' for common packages, 'composer-plugin' for plugins, 'metapackage' for empty packages, or a custom type ([a-z0-9-]+) defined by whatever project this package applies to.",
14
+ "type": "string"
15
+ },
16
+ "target-dir": {
17
+ "description": "DEPRECATED: Forces the package to be installed into the given subdirectory path. This is used for autoloading PSR-0 packages that do not contain their full path. Use forward slashes for cross-platform compatibility.",
18
+ "type": "string"
19
+ },
20
+ "description": {
21
+ "type": "string",
22
+ "description": "Short package description."
23
+ },
24
+ "keywords": {
25
+ "type": "array",
26
+ "items": {
27
+ "type": "string",
28
+ "description": "A tag/keyword that this package relates to."
29
+ }
30
+ },
31
+ "homepage": {
32
+ "type": "string",
33
+ "description": "Homepage URL for the project.",
34
+ "format": "uri"
35
+ },
36
+ "version": {
37
+ "type": "string",
38
+ "description": "Package version, see http://getcomposer.org/doc/04-schema.md#version for more info on valid schemes."
39
+ },
40
+ "time": {
41
+ "type": "string",
42
+ "description": "Package release date, in 'YYYY-MM-DD', 'YYYY-MM-DD HH:MM:SS' or 'YYYY-MM-DDTHH:MM:SSZ' format."
43
+ },
44
+ "license": {
45
+ "type": ["string", "array"],
46
+ "description": "License name. Or an array of license names."
47
+ },
48
+ "authors": {
49
+ "type": "array",
50
+ "description": "List of authors that contributed to the package. This is typically the main maintainers, not the full list.",
51
+ "items": {
52
+ "type": "object",
53
+ "additionalProperties": false,
54
+ "required": [ "name"],
55
+ "properties": {
56
+ "name": {
57
+ "type": "string",
58
+ "description": "Full name of the author."
59
+ },
60
+ "email": {
61
+ "type": "string",
62
+ "description": "Email address of the author.",
63
+ "format": "email"
64
+ },
65
+ "homepage": {
66
+ "type": "string",
67
+ "description": "Homepage URL for the author.",
68
+ "format": "uri"
69
+ },
70
+ "role": {
71
+ "type": "string",
72
+ "description": "Author's role in the project."
73
+ }
74
+ }
75
+ }
76
+ },
77
+ "require": {
78
+ "type": "object",
79
+ "description": "This is a hash of package name (keys) and version constraints (values) that are required to run this package.",
80
+ "additionalProperties": true
81
+ },
82
+ "replace": {
83
+ "type": "object",
84
+ "description": "This is a hash of package name (keys) and version constraints (values) that can be replaced by this package.",
85
+ "additionalProperties": true
86
+ },
87
+ "conflict": {
88
+ "type": "object",
89
+ "description": "This is a hash of package name (keys) and version constraints (values) that conflict with this package.",
90
+ "additionalProperties": true
91
+ },
92
+ "provide": {
93
+ "type": "object",
94
+ "description": "This is a hash of package name (keys) and version constraints (values) that this package provides in addition to this package's name.",
95
+ "additionalProperties": true
96
+ },
97
+ "require-dev": {
98
+ "type": "object",
99
+ "description": "This is a hash of package name (keys) and version constraints (values) that this package requires for developing it (testing tools and such).",
100
+ "additionalProperties": true
101
+ },
102
+ "suggest": {
103
+ "type": "object",
104
+ "description": "This is a hash of package name (keys) and descriptions (values) that this package suggests work well with it (this will be suggested to the user during installation).",
105
+ "additionalProperties": true
106
+ },
107
+ "config": {
108
+ "type": "object",
109
+ "description": "Composer options.",
110
+ "properties": {
111
+ "process-timeout": {
112
+ "type": "integer",
113
+ "description": "The timeout in seconds for process executions, defaults to 300 (5mins)."
114
+ },
115
+ "use-include-path": {
116
+ "type": "boolean",
117
+ "description": "If true, the Composer autoloader will also look for classes in the PHP include path."
118
+ },
119
+ "preferred-install": {
120
+ "type": "string",
121
+ "description": "The install method Composer will prefer to use, defaults to auto and can be any of source, dist or auto."
122
+ },
123
+ "notify-on-install": {
124
+ "type": "boolean",
125
+ "description": "Composer allows repositories to define a notification URL, so that they get notified whenever a package from that repository is installed. This option allows you to disable that behaviour, defaults to true."
126
+ },
127
+ "github-protocols": {
128
+ "type": "array",
129
+ "description": "A list of protocols to use for github.com clones, in priority order, defaults to [\"git\", \"https\", \"http\"].",
130
+ "items": {
131
+ "type": "string"
132
+ }
133
+ },
134
+ "github-oauth": {
135
+ "type": "object",
136
+ "description": "A hash of domain name => github API oauth tokens, typically {\"github.com\":\"<token>\"}.",
137
+ "additionalProperties": true
138
+ },
139
+ "http-basic": {
140
+ "type": "object",
141
+ "description": "A hash of domain name => {\"username\": \"...\", \"password\": \"...\"}.",
142
+ "additionalProperties": true
143
+ },
144
+ "store-auths": {
145
+ "type": ["string", "boolean"],
146
+ "description": "What to do after prompting for authentication, one of: true (store), false (do not store) or \"prompt\" (ask every time), defaults to prompt."
147
+ },
148
+ "vendor-dir": {
149
+ "type": "string",
150
+ "description": "The location where all packages are installed, defaults to \"vendor\"."
151
+ },
152
+ "bin-dir": {
153
+ "type": "string",
154
+ "description": "The location where all binaries are linked, defaults to \"vendor/bin\"."
155
+ },
156
+ "cache-dir": {
157
+ "type": "string",
158
+ "description": "The location where all caches are located, defaults to \"~/.composer/cache\" on *nix and \"%LOCALAPPDATA%\\Composer\" on windows."
159
+ },
160
+ "cache-files-dir": {
161
+ "type": "string",
162
+ "description": "The location where files (zip downloads) are cached, defaults to \"{$cache-dir}/files\"."
163
+ },
164
+ "cache-repo-dir": {
165
+ "type": "string",
166
+ "description": "The location where repo (git/hg repo clones) are cached, defaults to \"{$cache-dir}/repo\"."
167
+ },
168
+ "cache-vcs-dir": {
169
+ "type": "string",
170
+ "description": "The location where vcs infos (git clones, github api calls, etc. when reading vcs repos) are cached, defaults to \"{$cache-dir}/vcs\"."
171
+ },
172
+ "cache-ttl": {
173
+ "type": "integer",
174
+ "description": "The default cache time-to-live, defaults to 15552000 (6 months)."
175
+ },
176
+ "cache-files-ttl": {
177
+ "type": "integer",
178
+ "description": "The cache time-to-live for files, defaults to the value of cache-ttl."
179
+ },
180
+ "cache-files-maxsize": {
181
+ "type": ["string", "integer"],
182
+ "description": "The cache max size for the files cache, defaults to \"300MiB\"."
183
+ },
184
+ "discard-changes": {
185
+ "type": ["string", "boolean"],
186
+ "description": "The default style of handling dirty updates, defaults to false and can be any of true, false or \"stash\"."
187
+ },
188
+ "autoloader-suffix": {
189
+ "type": "string",
190
+ "description": "Optional string to be used as a suffix for the generated Composer autoloader. When null a random one will be generated."
191
+ },
192
+ "optimize-autoloader": {
193
+ "type": "boolean",
194
+ "description": "Always optimize when dumping the autoloader."
195
+ },
196
+ "prepend-autoloader": {
197
+ "type": "boolean",
198
+ "description": "If false, the composer autoloader will not be prepended to existing autoloaders, defaults to true."
199
+ },
200
+ "classmap-authoritative": {
201
+ "type": "boolean",
202
+ "description": "If true, the composer autoloader will not scan the filesystem for classes that are not found in the class map, defaults to false."
203
+ },
204
+ "github-domains": {
205
+ "type": "array",
206
+ "description": "A list of domains to use in github mode. This is used for GitHub Enterprise setups, defaults to [\"github.com\"].",
207
+ "items": {
208
+ "type": "string"
209
+ }
210
+ },
211
+ "github-expose-hostname": {
212
+ "type": "boolean",
213
+ "description": "Defaults to true. If set to false, the OAuth tokens created to access the github API will have a date instead of the machine hostname."
214
+ }
215
+ }
216
+ },
217
+ "extra": {
218
+ "type": ["object", "array"],
219
+ "description": "Arbitrary extra data that can be used by plugins, for example, package of type composer-plugin may have a 'class' key defining an installer class name.",
220
+ "additionalProperties": true
221
+ },
222
+ "autoload": {
223
+ "type": "object",
224
+ "description": "Description of how the package can be autoloaded.",
225
+ "properties": {
226
+ "psr-0": {
227
+ "type": "object",
228
+ "description": "This is a hash of namespaces (keys) and the directories they can be found into (values, can be arrays of paths) by the autoloader.",
229
+ "additionalProperties": true
230
+ },
231
+ "psr-4": {
232
+ "type": "object",
233
+ "description": "This is a hash of namespaces (keys) and the PSR-4 directories they can map to (values, can be arrays of paths) by the autoloader.",
234
+ "additionalProperties": true
235
+ },
236
+ "classmap": {
237
+ "type": "array",
238
+ "description": "This is an array of directories that contain classes to be included in the class-map generation process."
239
+ },
240
+ "files": {
241
+ "type": "array",
242
+ "description": "This is an array of files that are always required on every request."
243
+ }
244
+ }
245
+ },
246
+ "autoload-dev": {
247
+ "type": "object",
248
+ "description": "Description of additional autoload rules for development purpose (eg. a test suite).",
249
+ "properties": {
250
+ "psr-0": {
251
+ "type": "object",
252
+ "description": "This is a hash of namespaces (keys) and the directories they can be found into (values, can be arrays of paths) by the autoloader.",
253
+ "additionalProperties": true
254
+ },
255
+ "psr-4": {
256
+ "type": "object",
257
+ "description": "This is a hash of namespaces (keys) and the PSR-4 directories they can map to (values, can be arrays of paths) by the autoloader.",
258
+ "additionalProperties": true
259
+ },
260
+ "classmap": {
261
+ "type": "array",
262
+ "description": "This is an array of directories that contain classes to be included in the class-map generation process."
263
+ },
264
+ "files": {
265
+ "type": "array",
266
+ "description": "This is an array of files that are always required on every request."
267
+ }
268
+ }
269
+ },
270
+ "archive": {
271
+ "type": ["object"],
272
+ "description": "Options for creating package archives for distribution.",
273
+ "properties": {
274
+ "exclude": {
275
+ "type": "array",
276
+ "description": "A list of patterns for paths to exclude or include if prefixed with an exclamation mark."
277
+ }
278
+ }
279
+ },
280
+ "repositories": {
281
+ "type": ["object", "array"],
282
+ "description": "A set of additional repositories where packages can be found.",
283
+ "additionalProperties": true
284
+ },
285
+ "minimum-stability": {
286
+ "type": ["string"],
287
+ "description": "The minimum stability the packages must have to be install-able. Possible values are: dev, alpha, beta, RC, stable.",
288
+ "pattern": "^dev|alpha|beta|rc|RC|stable$"
289
+ },
290
+ "prefer-stable": {
291
+ "type": ["boolean"],
292
+ "description": "If set to true, stable packages will be prefered to dev packages when possible, even if the minimum-stability allows unstable packages."
293
+ },
294
+ "bin": {
295
+ "type": ["array"],
296
+ "description": "A set of files that should be treated as binaries and symlinked into bin-dir (from config).",
297
+ "items": {
298
+ "type": "string"
299
+ }
300
+ },
301
+ "include-path": {
302
+ "type": ["array"],
303
+ "description": "DEPRECATED: A list of directories which should get added to PHP's include path. This is only present to support legacy projects, and all new code should preferably use autoloading.",
304
+ "items": {
305
+ "type": "string"
306
+ }
307
+ },
308
+ "scripts": {
309
+ "type": ["object"],
310
+ "description": "Scripts listeners that will be executed before/after some events.",
311
+ "properties": {
312
+ "pre-install-cmd": {
313
+ "type": ["array", "string"],
314
+ "description": "Occurs before the install command is executed, contains one or more Class::method callables or shell commands."
315
+ },
316
+ "post-install-cmd": {
317
+ "type": ["array", "string"],
318
+ "description": "Occurs after the install command is executed, contains one or more Class::method callables or shell commands."
319
+ },
320
+ "pre-update-cmd": {
321
+ "type": ["array", "string"],
322
+ "description": "Occurs before the update command is executed, contains one or more Class::method callables or shell commands."
323
+ },
324
+ "post-update-cmd": {
325
+ "type": ["array", "string"],
326
+ "description": "Occurs after the update command is executed, contains one or more Class::method callables or shell commands."
327
+ },
328
+ "pre-status-cmd": {
329
+ "type": ["array", "string"],
330
+ "description": "Occurs before the status command is executed, contains one or more Class::method callables or shell commands."
331
+ },
332
+ "post-status-cmd": {
333
+ "type": ["array", "string"],
334
+ "description": "Occurs after the status command is executed, contains one or more Class::method callables or shell commands."
335
+ },
336
+ "pre-package-install": {
337
+ "type": ["array", "string"],
338
+ "description": "Occurs before a package is installed, contains one or more Class::method callables or shell commands."
339
+ },
340
+ "post-package-install": {
341
+ "type": ["array", "string"],
342
+ "description": "Occurs after a package is installed, contains one or more Class::method callables or shell commands."
343
+ },
344
+ "pre-package-update": {
345
+ "type": ["array", "string"],
346
+ "description": "Occurs before a package is updated, contains one or more Class::method callables or shell commands."
347
+ },
348
+ "post-package-update": {
349
+ "type": ["array", "string"],
350
+ "description": "Occurs after a package is updated, contains one or more Class::method callables or shell commands."
351
+ },
352
+ "pre-package-uninstall": {
353
+ "type": ["array", "string"],
354
+ "description": "Occurs before a package has been uninstalled, contains one or more Class::method callables or shell commands."
355
+ },
356
+ "post-package-uninstall": {
357
+ "type": ["array", "string"],
358
+ "description": "Occurs after a package has been uninstalled, contains one or more Class::method callables or shell commands."
359
+ },
360
+ "pre-autoload-dump": {
361
+ "type": ["array", "string"],
362
+ "description": "Occurs before the autoloader is dumped, contains one or more Class::method callables or shell commands."
363
+ },
364
+ "post-autoload-dump": {
365
+ "type": ["array", "string"],
366
+ "description": "Occurs after the autoloader is dumped, contains one or more Class::method callables or shell commands."
367
+ },
368
+ "post-root-package-install": {
369
+ "type": ["array", "string"],
370
+ "description": "Occurs after the root-package is installed, contains one or more Class::method callables or shell commands."
371
+ },
372
+ "post-create-project-cmd": {
373
+ "type": ["array", "string"],
374
+ "description": "Occurs after the create-project command is executed, contains one or more Class::method callables or shell commands."
375
+ }
376
+ }
377
+ },
378
+ "support": {
379
+ "type": "object",
380
+ "properties": {
381
+ "email": {
382
+ "type": "string",
383
+ "description": "Email address for support.",
384
+ "format": "email"
385
+ },
386
+ "issues": {
387
+ "type": "string",
388
+ "description": "URL to the Issue Tracker.",
389
+ "format": "uri"
390
+ },
391
+ "forum": {
392
+ "type": "string",
393
+ "description": "URL to the Forum.",
394
+ "format": "uri"
395
+ },
396
+ "wiki": {
397
+ "type": "string",
398
+ "description": "URL to the Wiki.",
399
+ "format": "uri"
400
+ },
401
+ "irc": {
402
+ "type": "string",
403
+ "description": "IRC channel for support, as irc://server/channel.",
404
+ "format": "uri"
405
+ },
406
+ "source": {
407
+ "type": "string",
408
+ "description": "URL to browse or download the sources.",
409
+ "format": "uri"
410
+ }
411
+ }
412
+ },
413
+ "non-feature-branches": {
414
+ "type": ["array"],
415
+ "description": "A set of string or regex patterns for non-numeric branch names that will not be handles as feature branches.",
416
+ "items": {
417
+ "type": "string"
418
+ }
419
+ }
420
+ }
421
+ }