aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanilo Šegan <danilo@segan.org>2012-05-31 16:25:23 +0800
committerDanilo Šegan <danilo@segan.org>2012-05-31 16:25:23 +0800
commitc2bb2a285df7cb808c84ed7cf0a567105b862618 (patch)
tree195c35e1d7b2716d5bc9b7a42394b45b8e3ea06d
parentb406198965f5101f2272dcbf714c68bf43c81a08 (diff)
Implement continuationfor license.
-rw-r--r--licenses/BuildInfo.php21
-rw-r--r--tests/BuildInfoTest.php21
2 files changed, 42 insertions, 0 deletions
diff --git a/licenses/BuildInfo.php b/licenses/BuildInfo.php
index aae8e1d..3a4ef9a 100644
--- a/licenses/BuildInfo.php
+++ b/licenses/BuildInfo.php
@@ -206,6 +206,27 @@ class BuildInfo
throw new InvalidArgumentException("Data in incorrect format.");
}
$result = array("Format-Version" => $values["Format-Version"]);
+
+ $line_no = 0;
+ while ($line_no < count($data)) {
+ $line = $data[$line_no];
+ $values = $this->parseLine($line);
+ if (array_key_exists("License-Text", $values)) {
+ $text = $values["License-Text"];
+ $total_lines = count($data);
+ while (($line_no + 1) < $total_lines &&
+ strlen($data[$line_no + 1]) > 0) {
+ if ($data[$line_no + 1][0] == ' ') {
+ $text .= "\n" . substr($data[$line_no + 1], 1);
+ $line_no++;
+ }
+ }
+ $result["License-Text"] = $text;
+ } else {
+ $result = array_merge($result, $values);
+ }
+ $line_no++;
+ }
return $result;
}
}
diff --git a/tests/BuildInfoTest.php b/tests/BuildInfoTest.php
index 0b8e4b9..abe7998 100644
--- a/tests/BuildInfoTest.php
+++ b/tests/BuildInfoTest.php
@@ -91,6 +91,27 @@ class BuildInfoTest extends PHPUnit_Framework_TestCase
$values);
}
+ public function test_parseData_extra_fields() {
+ $buildinfo = new BuildInfo("");
+ $values = $buildinfo->parseData(array(
+ "Format-Version: 2.0",
+ "Build-Name: woohoo"));
+ $this->assertEquals(array("Format-Version" => "2.0",
+ "Build-Name" => "woohoo"),
+ $values);
+ }
+
+ public function test_parseData_license() {
+ $buildinfo = new BuildInfo("");
+ $values = $buildinfo->parseData(array(
+ "Format-Version: 2.0",
+ "License-Text: line1",
+ " line2"));
+ $this->assertEquals(array("Format-Version" => "2.0",
+ "License-Text" => "line1\nline2"),
+ $values);
+ }
+
/**
* @expectedException InvalidArgumentException
*/