Skip to content

Commit b91dafd

Browse files
Allow use of dashes in .blueprint (#272)
1 parent 0e31025 commit b91dafd

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

src/Blueprint.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,13 @@ public static function appPath()
2929
return str_replace('\\', '/', config('blueprint.app_path'));
3030
}
3131

32-
public function parse($content)
32+
public function parse($content, $strip_dashes = true)
3333
{
3434
$content = str_replace(["\r\n", "\r"], "\n", $content);
35-
$content = preg_replace('/^(\s*)-\s*/m', '\1', $content);
35+
36+
if ($strip_dashes) {
37+
$content = preg_replace('/^(\s*)-\s*/m', '\1', $content);
38+
}
3639

3740
$content = preg_replace_callback('/^(\s+)(id|timestamps(Tz)?|softDeletes(Tz)?)$/mi', function ($matches) {
3841
return $matches[1].strtolower($matches[2]).': '.$matches[2];

src/Commands/EraseCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function handle()
4747
$contents = $this->files->get('.blueprint');
4848

4949
$blueprint = new Blueprint();
50-
$generated = $blueprint->parse($contents);
50+
$generated = $blueprint->parse($contents, false);
5151

5252
collect($generated)->each(function ($files, $action) {
5353
if ($action === 'created') {

tests/Feature/BlueprintTest.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ public function it_parses_the_readme_example_with_different_platform_eols()
278278
/**
279279
* @test
280280
*/
281-
public function it_parses_yaml_using_dashed_syntax()
281+
public function it_parses_yaml_with_dashed_syntax()
282282
{
283283
$definition = $this->fixture('drafts/readme-example-dashes.yaml');
284284

@@ -307,6 +307,18 @@ public function it_parses_yaml_using_dashed_syntax()
307307
$this->assertEquals($expected, $this->subject->parse($definition));
308308
}
309309

310+
/**
311+
* @test
312+
*/
313+
public function it_allows_parsing_without_stripping_dashes()
314+
{
315+
$sequence = [
316+
'numbers' => range(3, 11),
317+
];
318+
319+
$this->assertEquals($sequence, $this->subject->parse($this->subject->dump($sequence), false));
320+
}
321+
310322
/**
311323
* @test
312324
*/

0 commit comments

Comments
 (0)