Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Theodus committed Jul 28, 2017
1 parent a3b60e4 commit 4a9d294
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 54 deletions.
14 changes: 7 additions & 7 deletions changelog.pony
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ class Changelog

fun string(): String iso^ =>
let str = (recover String end)
.>append(_Util.changelog_heading())
.>append("\n")
.> append(_Util.changelog_heading())
.> append("\n")
if unreleased isnt None then str.append(unreleased.string()) end
for release in released.values() do
str.append(release.string())
Expand All @@ -73,7 +73,7 @@ class Release
changed = Section._emtpy(Changed)

fun string(): String iso^ =>
let str = recover String.>append(heading).>append("\n\n") end
let str = recover String .> append(heading) .> append("\n\n") end
for section in [fixed; added; changed].values() do
match section
| let s: this->Section =>
Expand Down Expand Up @@ -104,8 +104,8 @@ class Section
fun string(): String =>
recover
String
.>append("### ")
.>append(label.text())
.>append("\n\n")
.>append(entries)
.> append("### ")
.> append(label.text())
.> append("\n\n")
.> append(entries)
end
22 changes: 12 additions & 10 deletions changelog_tool.pony
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use "files"
use "time"
use "peg"
use "time"

class ChangelogTool
let _env: Env
Expand All @@ -13,17 +13,18 @@ class ChangelogTool
fun verify() =>
_env.out.print("verifying " + _filename + "...")
try
let ast = _parse()?
_parse()?
_env.out.print(_filename + " is a valid changelog")
end

fun release(version: String, edit: Bool) =>
try
_check_version(version)?
let date = Date(Time.seconds()).format("%Y-%m-%d")
let changelog: String = Changelog(_parse()?)?
.create_release(version, date)?
.string()
let changelog: String =
Changelog(_parse()?)?
.create_release(version, date)?
.string()
_edit_or_print(edit, changelog)
else
_env.err.print("unable to perform release prep")
Expand All @@ -40,9 +41,10 @@ class ChangelogTool

fun unreleased(edit: Bool) =>
try
let changelog: String = Changelog(_parse()?)?
.create_unreleased()
.string()
let changelog: String =
Changelog(_parse()?)?
.create_unreleased()
.string()
_edit_or_print(edit, changelog)
else
_env.out.print("error")
Expand All @@ -52,8 +54,8 @@ class ChangelogTool
if edit then
with file = File(_filepath) do
file
.>write(s)
.>flush()
.> write(s)
.> flush()
end
else
_env.out.print(s)
Expand Down
8 changes: 4 additions & 4 deletions main.pony
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ use "options"

actor Main
new create(env: Env) =>
// TODO use the new cli package
// https://github.com/ponylang/ponyc/issues/1737
let options = Options(env.args)
.>add("edit", "e", None)
// TODO use the cli package instead of options
let options =
Options(env.args)
.> add("edit", "e", None)

try
var edit = false
Expand Down
65 changes: 32 additions & 33 deletions tests/main.pony
Original file line number Diff line number Diff line change
Expand Up @@ -40,48 +40,48 @@ class iso _TestParseVersion is UnitTest
fun name(): String => "parse version"

fun apply(h: TestHelper) =>
ParseTest(h, ChangelogParser.version()).run([
("0.0.0", "(Version 0.0.0)\n")
("1.23.9", "(Version 1.23.9)\n")
("0..0", "")
(".0.0", "")
("0..", "")
("0", "")
])
ParseTest(h, ChangelogParser.version()).run(
[ ("0.0.0", "(Version 0.0.0)\n")
("1.23.9", "(Version 1.23.9)\n")
("0..0", "")
(".0.0", "")
("0..", "")
("0", "")
])

class iso _TestParseDate is UnitTest
fun name(): String => "parse date"

fun apply(h: TestHelper) =>
ParseTest(h, ChangelogParser.date()).run([
("2017-04-07", "(Date 2017-04-07)\n")
("0000-00-00", "(Date 0000-00-00)\n")
("0000-00-0", "")
("0000-0-00", "")
("000-00-00", "")
("00-0000-00", "")
])
ParseTest(h, ChangelogParser.date()).run(
[ ("2017-04-07", "(Date 2017-04-07)\n")
("0000-00-00", "(Date 0000-00-00)\n")
("0000-00-0", "")
("0000-0-00", "")
("000-00-00", "")
("00-0000-00", "")
])

class iso _TestParseEntries is UnitTest
fun name(): String => "parse entries"

fun apply(h: TestHelper) =>
ParseTest(h, ChangelogParser.entries()).run([
("32-bit ARM port.", "")
("- 32-bit ARM port.", "(Entries - 32-bit ARM port.)\n")
("- abc\n - def\n\n", "(Entries - abc\n - def)\n")
( """
- abc
- def
- ghi
- jkl
""",
"(Entries - abc\n - def\n - ghi\n - jkl)\n")
("- @fowles: handle regex empty match.",
"(Entries - @fowles: handle regex empty match.)\n")
("- Upgrade to LLVM 3.9.1 ([PR #1498](https://github.com/ponylang/ponyc/pull/1498))",
"(Entries - Upgrade to LLVM 3.9.1 ([PR #1498](https://github.com/ponylang/ponyc/pull/1498)))\n")
])
ParseTest(h, ChangelogParser.entries()).run(
[ ("32-bit ARM port.", "")
("- 32-bit ARM port.", "(Entries - 32-bit ARM port.)\n")
("- abc\n - def\n\n", "(Entries - abc\n - def)\n")
( """
- abc
- def
- ghi
- jkl
""",
"(Entries - abc\n - def\n - ghi\n - jkl)\n" )
( "- @fowles: handle regex empty match.",
"(Entries - @fowles: handle regex empty match.)\n" )
( "- Upgrade to LLVM 3.9.1 ([PR #1498](https://github.com/ponylang/ponyc/pull/1498))",
"(Entries - Upgrade to LLVM 3.9.1 ([PR #1498](https://github.com/ponylang/ponyc/pull/1498)))\n" )
])

class iso _TestParseChangelog is UnitTest
fun name(): String => "parse CHANGELOG"
Expand Down Expand Up @@ -122,7 +122,6 @@ primitive _Logv
match bs
| let s: String => s
| let a: Array[U8] val => String.from_array(a)
else ""
end)
end
h.log(consume str)

0 comments on commit 4a9d294

Please sign in to comment.