php-composer 0.1.1 → 0.2.0

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 (34) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +10 -10
  3. data/Gemfile +15 -15
  4. data/LICENSE.txt +21 -21
  5. data/README.md +35 -35
  6. data/Rakefile +1 -1
  7. data/lib/composer.rb +52 -52
  8. data/lib/composer/error.rb +8 -8
  9. data/lib/composer/json/json_file.rb +270 -270
  10. data/lib/composer/package/alias_package.rb +273 -273
  11. data/lib/composer/package/base_package.rb +130 -130
  12. data/lib/composer/package/complete_package.rb +55 -55
  13. data/lib/composer/package/dumper/hash_dumper.rb +169 -169
  14. data/lib/composer/package/link.rb +51 -51
  15. data/lib/composer/package/link_constraint/base_constraint.rb +35 -35
  16. data/lib/composer/package/link_constraint/empty_constraint.rb +34 -34
  17. data/lib/composer/package/link_constraint/multi_constraint.rb +66 -66
  18. data/lib/composer/package/link_constraint/specific_constraint.rb +40 -40
  19. data/lib/composer/package/link_constraint/version_constraint.rb +220 -220
  20. data/lib/composer/package/loader/hash_loader.rb +316 -316
  21. data/lib/composer/package/loader/json_loader.rb +47 -47
  22. data/lib/composer/package/loader/project_attributes_loader.rb +71 -71
  23. data/lib/composer/package/loader/project_root_package_loader.rb +28 -28
  24. data/lib/composer/package/package.rb +118 -118
  25. data/lib/composer/package/root_alias_package.rb +37 -37
  26. data/lib/composer/package/root_package.rb +37 -37
  27. data/lib/composer/package/version/version_parser.rb +583 -583
  28. data/lib/composer/package/version/version_selector.rb +106 -106
  29. data/lib/composer/repository/filesystem_repository.rb +84 -85
  30. data/lib/composer/repository/{array_repository.rb → hash_repository.rb} +195 -195
  31. data/lib/composer/repository/{writeable_array_repository.rb → writeable_hash_repository.rb} +57 -59
  32. data/lib/composer/version.rb +3 -3
  33. data/php-composer.gemspec +31 -31
  34. metadata +4 -4
@@ -1,51 +1,51 @@
1
- #
2
- # This file was ported to ruby from Composer php source code file.
3
- # Original Source: Composer\Package\Link.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 Package
14
-
15
- # Represents a link between two packages, represented by their names
16
- class Link
17
-
18
- attr_reader :source, :target, :constraint
19
-
20
- # Creates a new package link.
21
- # @param string source
22
- # @param string target
23
- # @param LinkConstraintInterface constraint Constraint applying to the target of this link
24
- # @param string description Used to create a descriptive string representation
25
- # @param string prettyConstraint
26
- def initialize(source, target, constraint = nil, description = 'relates to', pretty_constraint = nil)
27
- @source = source.downcase
28
- @target = target.downcase
29
- @constraint = constraint
30
- @description = description
31
- @pretty_constraint = pretty_constraint
32
- end
33
-
34
- def pretty_constraint
35
- unless @pretty_constraint
36
- raise UnexpectedValueError, "Link #{self} has been misconfigured and had no pretty constraint given."
37
- end
38
- @pretty_constraint
39
- end
40
-
41
- def pretty_string(source_package)
42
- "#{source_package.pretty_string} #{@description} #{@target} #{@constraint.pretty_string}"
43
- end
44
-
45
- def to_s
46
- "#{@source} #{@description} #{@target} (#{@constraint})"
47
- end
48
-
49
- end
50
- end
51
- end
1
+ #
2
+ # This file was ported to ruby from Composer php source code file.
3
+ # Original Source: Composer\Package\Link.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 Package
14
+
15
+ # Represents a link between two packages, represented by their names
16
+ class Link
17
+
18
+ attr_reader :source, :target, :constraint
19
+
20
+ # Creates a new package link.
21
+ # @param string source
22
+ # @param string target
23
+ # @param LinkConstraintInterface constraint Constraint applying to the target of this link
24
+ # @param string description Used to create a descriptive string representation
25
+ # @param string prettyConstraint
26
+ def initialize(source, target, constraint = nil, description = 'relates to', pretty_constraint = nil)
27
+ @source = source.downcase
28
+ @target = target.downcase
29
+ @constraint = constraint
30
+ @description = description
31
+ @pretty_constraint = pretty_constraint
32
+ end
33
+
34
+ def pretty_constraint
35
+ unless @pretty_constraint
36
+ raise UnexpectedValueError, "Link #{self} has been misconfigured and had no pretty constraint given."
37
+ end
38
+ @pretty_constraint
39
+ end
40
+
41
+ def pretty_string(source_package)
42
+ "#{source_package.pretty_string} #{@description} #{@target} #{@constraint.pretty_string}"
43
+ end
44
+
45
+ def to_s
46
+ "#{@source} #{@description} #{@target} (#{@constraint})"
47
+ end
48
+
49
+ end
50
+ end
51
+ end
@@ -1,36 +1,36 @@
1
- #
2
- # This file was ported to ruby from Composer php source code file.
3
- # Original Source: Composer\Package\AliasPackage.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 Package
14
- module LinkConstraint
15
- class BaseConstraint
16
-
17
- def matches(provider)
18
- raise NotImplementedError
19
- end
20
-
21
- def pretty_string=(pretty_string)
22
- raise NotImplementedError
23
- end
24
-
25
- def pretty_string
26
- raise NotImplementedError
27
- end
28
-
29
- def to_s
30
- raise NotImplementedError
31
- end
32
-
33
- end
34
- end
35
- end
1
+ #
2
+ # This file was ported to ruby from Composer php source code file.
3
+ # Original Source: Composer\Package\AliasPackage.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 Package
14
+ module LinkConstraint
15
+ class BaseConstraint
16
+
17
+ def matches(provider)
18
+ raise NotImplementedError
19
+ end
20
+
21
+ def pretty_string=(pretty_string)
22
+ raise NotImplementedError
23
+ end
24
+
25
+ def pretty_string
26
+ raise NotImplementedError
27
+ end
28
+
29
+ def to_s
30
+ raise NotImplementedError
31
+ end
32
+
33
+ end
34
+ end
35
+ end
36
36
  end
@@ -1,35 +1,35 @@
1
- #
2
- # This file was ported to ruby from Composer php source code file.
3
- # Original Source: Composer\Package\AliasPackage.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 Package
14
- module LinkConstraint
15
- class EmptyConstraint < BaseConstraint
16
- def matches(provider)
17
- true
18
- end
19
-
20
- def pretty_string=(pretty_string)
21
- @pretty_string = pretty_string
22
- end
23
-
24
- def pretty_string
25
- return to_s unless @pretty_string
26
- @pretty_string
27
- end
28
-
29
- def to_s
30
- '[]'
31
- end
32
- end
33
- end
34
- end
1
+ #
2
+ # This file was ported to ruby from Composer php source code file.
3
+ # Original Source: Composer\Package\AliasPackage.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 Package
14
+ module LinkConstraint
15
+ class EmptyConstraint < BaseConstraint
16
+ def matches(provider)
17
+ true
18
+ end
19
+
20
+ def pretty_string=(pretty_string)
21
+ @pretty_string = pretty_string
22
+ end
23
+
24
+ def pretty_string
25
+ return to_s unless @pretty_string
26
+ @pretty_string
27
+ end
28
+
29
+ def to_s
30
+ '[]'
31
+ end
32
+ end
33
+ end
34
+ end
35
35
  end
@@ -1,67 +1,67 @@
1
- #
2
- # This file was ported to ruby from Composer php source code file.
3
- # Original Source: Composer\Package\AliasPackage.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 Package
14
- module LinkConstraint
15
- class MultiConstraint < BaseConstraint
16
- # Sets operator and version to compare a package with
17
- # @param array $constraints A set of constraints
18
- # @param bool $conjunctive Whether the constraints should be treated as conjunctive or disjunctive
19
- def initialize(constraints, conjunctive = true)
20
- @constraints = constraints
21
- @conjunctive = conjunctive
22
- end
23
-
24
- def matches(provider)
25
- if @conjunctive === false
26
- @constraints.each do |constraint|
27
- if constraint.matches(provider)
28
- return true
29
- end
30
- end
31
- return false
32
- end
33
-
34
- @constraints.each do |constraint|
35
- if !constraint.matches(provider)
36
- return false
37
- end
38
- end
39
-
40
- true
41
- end
42
-
43
- def pretty_string=(pretty_string)
44
- @pretty_string = pretty_string
45
- end
46
-
47
- def pretty_string
48
- return to_s unless @pretty_string
49
- @pretty_string
50
- end
51
-
52
- def to_s
53
- constraints = []
54
- @constraints.each do |constraint|
55
- if constraint.is_a?(Array)
56
- constraints << String(constraint[0])
57
- else
58
- constraints << String(constraint)
59
- end
60
- end
61
- separator = @conjunctive ? ' ' : ' || '
62
- "[#{constraints.join(separator)}]"
63
- end
64
- end
65
- end
66
- end
1
+ #
2
+ # This file was ported to ruby from Composer php source code file.
3
+ # Original Source: Composer\Package\AliasPackage.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 Package
14
+ module LinkConstraint
15
+ class MultiConstraint < BaseConstraint
16
+ # Sets operator and version to compare a package with
17
+ # @param array $constraints A set of constraints
18
+ # @param bool $conjunctive Whether the constraints should be treated as conjunctive or disjunctive
19
+ def initialize(constraints, conjunctive = true)
20
+ @constraints = constraints
21
+ @conjunctive = conjunctive
22
+ end
23
+
24
+ def matches(provider)
25
+ if @conjunctive === false
26
+ @constraints.each do |constraint|
27
+ if constraint.matches(provider)
28
+ return true
29
+ end
30
+ end
31
+ return false
32
+ end
33
+
34
+ @constraints.each do |constraint|
35
+ if !constraint.matches(provider)
36
+ return false
37
+ end
38
+ end
39
+
40
+ true
41
+ end
42
+
43
+ def pretty_string=(pretty_string)
44
+ @pretty_string = pretty_string
45
+ end
46
+
47
+ def pretty_string
48
+ return to_s unless @pretty_string
49
+ @pretty_string
50
+ end
51
+
52
+ def to_s
53
+ constraints = []
54
+ @constraints.each do |constraint|
55
+ if constraint.is_a?(Array)
56
+ constraints << String(constraint[0])
57
+ else
58
+ constraints << String(constraint)
59
+ end
60
+ end
61
+ separator = @conjunctive ? ' ' : ' || '
62
+ "[#{constraints.join(separator)}]"
63
+ end
64
+ end
65
+ end
66
+ end
67
67
  end
@@ -1,41 +1,41 @@
1
- #
2
- # This file was ported to ruby from Composer php source code file.
3
- # Original Source: Composer\Package\AliasPackage.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 Package
14
- module LinkConstraint
15
- class SpecificConstraint < BaseConstraint
16
-
17
- def matches(provider)
18
-
19
- if provider.is_a?(MultiConstraint)
20
- # turn matching around to find a match
21
- return provider.matches(self)
22
- elsif provider.is_a?(SpecificConstraint)
23
- return match_specific(provider)
24
- end
25
-
26
- true
27
- end
28
-
29
- def pretty_string=(pretty_string)
30
- @prettyString = pretty_string
31
- end
32
-
33
- def pretty_string
34
- return to_s unless @pretty_string
35
- @pretty_string
36
- end
37
-
38
- end
39
- end
40
- end
1
+ #
2
+ # This file was ported to ruby from Composer php source code file.
3
+ # Original Source: Composer\Package\AliasPackage.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 Package
14
+ module LinkConstraint
15
+ class SpecificConstraint < BaseConstraint
16
+
17
+ def matches(provider)
18
+
19
+ if provider.is_a?(MultiConstraint)
20
+ # turn matching around to find a match
21
+ return provider.matches(self)
22
+ elsif provider.is_a?(SpecificConstraint)
23
+ return match_specific(provider)
24
+ end
25
+
26
+ true
27
+ end
28
+
29
+ def pretty_string=(pretty_string)
30
+ @prettyString = pretty_string
31
+ end
32
+
33
+ def pretty_string
34
+ return to_s unless @pretty_string
35
+ @pretty_string
36
+ end
37
+
38
+ end
39
+ end
40
+ end
41
41
  end