feat: release Dever 0.1.4 with enforceable project guidance
This commit is contained in:
1 parent
201bdee372
commit
89629c2197
86 files changed
+2798
-338
No files matched your search
@@ -0,0 +1 @@
|
||||
{}
|
||||
@@ -0,0 +1 @@
|
||||
cmd summarize = app.summarize
|
||||
@@ -0,0 +1,18 @@
|
||||
type Article {
|
||||
title: Text
|
||||
published: Bool
|
||||
}
|
||||
|
||||
type Summary {
|
||||
titles: List<Text>
|
||||
title_length: Int
|
||||
}
|
||||
|
||||
summarize(articles: List<Article>) (summary: Summary) {
|
||||
published = filter(domain.is_published, articles)
|
||||
titles = each(domain.published_title, published)
|
||||
summary = Summary {
|
||||
titles = titles
|
||||
title_length = reduce(domain.add_title_length, titles, 0)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
is_published(article: app.Article) (selected: Bool) pure {
|
||||
selected = article.published and text.trim(article.title) != ""
|
||||
}
|
||||
|
||||
published_title(article: app.Article) (title: Text) pure {
|
||||
title = text.trim(article.title)
|
||||
}
|
||||
|
||||
add_title_length(title: Text, total: Int) (next: Int) pure {
|
||||
next = total + length(title)
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
type State {
|
||||
Draft
|
||||
Published
|
||||
Rejected(reason: Text)
|
||||
}
|
||||
|
||||
clauses() () {
|
||||
assert_eq(label(State.Draft), "draft")
|
||||
assert_eq(label(State.Published), "published")
|
||||
assert_eq(label(State.Rejected("needs revision")), "needs revision")
|
||||
assert_eq(display(null), "missing")
|
||||
assert_eq(display("present"), "present")
|
||||
assert_eq(grade(59), "fail")
|
||||
assert_eq(grade(60), "pass")
|
||||
}
|
||||
|
||||
label(state: State.Published) (text: Text) {
|
||||
text = "published"
|
||||
}
|
||||
|
||||
label(state: State.Rejected(reason)) (text: Text) {
|
||||
text = reason
|
||||
}
|
||||
|
||||
label(state: other) (text: Text) {
|
||||
text = "draft"
|
||||
}
|
||||
|
||||
display(value: Text) (text: Text) {
|
||||
text = value
|
||||
}
|
||||
|
||||
display(value: null) (text: Text) {
|
||||
text = "missing"
|
||||
}
|
||||
|
||||
grade(score: Int < 60) (text: Text) {
|
||||
text = "fail"
|
||||
}
|
||||
|
||||
grade(score: Int >= 60) (text: Text) {
|
||||
text = "pass"
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
summary() () {
|
||||
articles = [
|
||||
app.Article {
|
||||
title = " First "
|
||||
published = true
|
||||
},
|
||||
app.Article {
|
||||
title = "Hidden"
|
||||
published = false
|
||||
},
|
||||
app.Article {
|
||||
title = " "
|
||||
published = true
|
||||
},
|
||||
app.Article {
|
||||
title = "Second"
|
||||
published = true
|
||||
}
|
||||
]
|
||||
actual = app.summarize(articles)
|
||||
assert_eq(actual.titles, ["First", "Second"])
|
||||
assert_eq(actual.title_length, 11)
|
||||
each(assert_clean_title, actual.titles)
|
||||
empty = app.summarize([])
|
||||
assert_eq(empty.titles, [])
|
||||
assert_eq(empty.title_length, 0)
|
||||
}
|
||||
|
||||
assert_clean_title(title: Text) () {
|
||||
assert(title != "")
|
||||
assert_eq(title, text.trim(title))
|
||||
}
|
||||
Reference in new issue
Block a user