Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
GildedRose Refactoring Kata
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mirio Eggmann
GildedRose Refactoring Kata
Commits
9a2736d2
Commit
9a2736d2
authored
2 years ago
by
Nitsan Avni
Browse files
Options
Downloads
Patches
Plain Diff
use `foreach` for extra indentation
parent
9abe9550
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
jq/gilded-rose.jq
+45
-40
45 additions, 40 deletions
jq/gilded-rose.jq
jq/test-gilded-rose.sh
+1
-1
1 addition, 1 deletion
jq/test-gilded-rose.sh
jq/texttest_fixture.jq
+1
-1
1 addition, 1 deletion
jq/texttest_fixture.jq
with
47 additions
and
42 deletions
jq/gilded-rose.jq
+
45
−
40
View file @
9a2736d2
def update_quality:
def update_quality:
if .name != "Aged Brie" and .name != "Backstage passes to a TAFKAL80ETC concert" then
[
if .quality > 0 then
foreach .[] as $item (
if .name != "Sulfuras, Hand of Ragnaros" then
null;
.quality = .quality - 1
$item |
else . end
if .name != "Aged Brie" and .name != "Backstage passes to a TAFKAL80ETC concert" then
else . end
else
if .quality < 50 then
.quality = .quality + 1
|
if .name == "Backstage passes to a TAFKAL80ETC concert" then
if .sell_in < 11 then
if .quality < 50 then
.quality = .quality + 1
else . end
else . end
|
if .sell_in < 6 then
if .quality < 50 then
.quality = .quality + 1
else . end
else . end
else . end
else . end
end
|
if .name != "Sulfuras, Hand of Ragnaros" then
.sell_in = .sell_in - 1
else . end
|
if .sell_in < 0 then
if .name != "Aged Brie" then
if .name != "Backstage passes to a TAFKAL80ETC concert" then
if .quality > 0 then
if .quality > 0 then
if .name != "Sulfuras, Hand of Ragnaros" then
if .name != "Sulfuras, Hand of Ragnaros" then
.quality = .quality - 1
.quality = .quality - 1
else . end
else . end
else . end
else . end
else
else
.quality = .quality - .quality
if .quality < 50 then
.quality = .quality + 1
|
if .name == "Backstage passes to a TAFKAL80ETC concert" then
if .sell_in < 11 then
if .quality < 50 then
.quality = .quality + 1
else . end
else . end
|
if .sell_in < 6 then
if .quality < 50 then
.quality = .quality + 1
else . end
else . end
else . end
else . end
end
end
else
|
if .quality < 50 then
if .name != "Sulfuras, Hand of Ragnaros" then
.quality = .quality + 1
.sell_in = .sell_in - 1
else . end
|
if .sell_in < 0 then
if .name != "Aged Brie" then
if .name != "Backstage passes to a TAFKAL80ETC concert" then
if .quality > 0 then
if .name != "Sulfuras, Hand of Ragnaros" then
.quality = .quality - 1
else . end
else . end
else
.quality = .quality - .quality
end
else
if .quality < 50 then
.quality = .quality + 1
else . end
end
else . end
else . end
end
)
else . end
];
;
This diff is collapsed.
Click to expand it.
jq/test-gilded-rose.sh
+
1
−
1
View file @
9a2736d2
#!/usr/bin/env bash
#!/usr/bin/env bash
jaq
-en
"
$(
cat
gilded-rose.jq
)
"
'{name:"foo",sell_in:0,quality:0} | update_quality | .name == "fixme"'
jaq
-en
"
$(
cat
gilded-rose.jq
)
"
'
[
{name:"foo",sell_in:0,quality:0}
]
| update_quality |
.[]
.name == "fixme"'
This diff is collapsed.
Click to expand it.
jq/texttest_fixture.jq
+
1
−
1
View file @
9a2736d2
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
{ name: "Conjured Mana Cake", sell_in: 3, quality: 6} # <-- :O
{ name: "Conjured Mana Cake", sell_in: 3, quality: 6} # <-- :O
] |
] |
{ items: ., day: 0 } |
{ items: ., day: 0 } |
recurse(.day += 1 | .items =
[
.items
[]
| update_quality
]
; .day < ($ARGS.named.days // 2 | tonumber)) |
recurse(.day += 1 | .items =
(
.items | update_quality
)
; .day < ($ARGS.named.days // 2 | tonumber)) |
(
(
"",
"",
(["-------- day ", (.day | tostring), " --------"] | add),
(["-------- day ", (.day | tostring), " --------"] | add),
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment