Skip to content

Commit 9cf4303

Browse files
Release 0.5.0.0
2 parents 03cd1c5 + e466024 commit 9cf4303

File tree

14 files changed

+549
-278
lines changed

14 files changed

+549
-278
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,16 @@ following conventions:
2424

2525
[KaC]: <https://keepachangelog.com/en/1.0.0/>
2626

27+
## 0.5.0.0 (2020-11-08)
28+
29+
### Breaking
30+
31+
* Add simplified CSV support for tags and items
32+
33+
### Non-Breaking
34+
35+
* Rename Git default branch to `main`
36+
2737
## 0.4.0.0 (2020-09-12)
2838

2939
### Breaking

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ repl: # enter a REPL *
139139
source-git: # create source tarball of git TREE
140140
> $(eval TREE := "HEAD")
141141
> $(eval BRANCH := $(shell git rev-parse --abbrev-ref $(TREE)))
142-
> @test "${BRANCH}" = "master" || echo "WARNING: Not in master branch!" >&2
142+
> @test "${BRANCH}" = "main" || echo "WARNING: Not in main branch!" >&2
143143
> $(eval VERSION := $(shell \
144144
grep '^version:' $(CABAL_FILE) | sed 's/^version: *//'))
145145
> @mkdir -p build

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Queue Sheet
22

3-
[![Build Status](https://travis-ci.com/ExtremaIS/queue-sheet-haskell.svg?branch=master)](https://travis-ci.com/ExtremaIS/queue-sheet-haskell)
3+
[![Build Status](https://travis-ci.com/ExtremaIS/queue-sheet-haskell.svg?branch=main)](https://travis-ci.com/ExtremaIS/queue-sheet-haskell)
44

55
* [Overview](#overview)
66
* [Requirements](#requirements)
@@ -66,7 +66,7 @@ no plans to put the package on Hackage.
6666

6767
### Releases
6868

69-
All releases are tagged in the `master` branch. Release tags are signed using
69+
All releases are tagged in the `main` branch. Release tags are signed using
7070
the
7171
[`[email protected]` GPG key](http://keys.gnupg.net/pks/lookup?op=vindex&fingerprint=on&search=0x1D484E4B4705FADF).
7272

default.nix

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,35 @@
1-
{ nixpkgs ? import <nixpkgs> {}, compiler ? "ghc883" }:
2-
nixpkgs.pkgs.haskell.packages.${compiler}.callPackage ./queue-sheet.nix { }
1+
let
2+
3+
nixpkgsRev = "cd63096d6d88";
4+
compilerVersion = "ghc884";
5+
6+
githubTarball = owner: repo: rev:
7+
builtins.fetchTarball { url = "https://github.com/${owner}/${repo}/archive/${rev}.tar.gz"; };
8+
9+
gitIgnore = pkgs.nix-gitignore.gitignoreSourcePure;
10+
11+
config = {
12+
packageOverrides = super: let self = super.pkgs; in rec {
13+
haskell = super.haskell // {
14+
packageOverrides = self: super: {
15+
haskell-nix = super.callCabal2nix "haskell-nix" (gitIgnore [./.gitignore] ./.) {};
16+
};
17+
};
18+
};
19+
};
20+
21+
pkgs = import (githubTarball "NixOS" "nixpkgs" nixpkgsRev) { inherit config; };
22+
compilerSet = pkgs.haskell.packages."${compilerVersion}";
23+
24+
in {
25+
26+
inherit pkgs;
27+
28+
shell = compilerSet.shellFor {
29+
packages = p: [p.haskell-nix];
30+
buildInputs = with pkgs; [
31+
compilerSet.cabal-install
32+
];
33+
};
34+
35+
}

doc/queue-sheet.1.md

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Queues are specified in YAML format. They may be specified in a few different
5050
ways, depending on how you want to organize them.
5151

5252
To create a queue sheet of queues without sections, the YAML file consists of
53-
a list of queue objects, which have the following properties:
53+
an array of queue objects, which have the following properties:
5454

5555
*name*
5656
: queue name (string, required)
@@ -62,27 +62,34 @@ a list of queue objects, which have the following properties:
6262
: date of last update (string, optional)
6363

6464
*tags*
65-
: list of tags (list of string, optional)
65+
: list of tags (simplified CSV string or array of strings, optional)
6666

6767
*prev*
6868
: previous item (item, optional)
6969

7070
*next*
71-
: list of next items (list of items, optional)
71+
: list of next items (simplified CSV string or array of items, optional)
7272

7373
The only required property is *name*.
7474

75-
The *tags* property is a list of string tags that are associated with the
76-
queue. A tag must consist of at least one ASCII letter, number, period,
77-
underscore, or dash. For example, tag "complete" can be used to indicate that
78-
there will be no new episodes of a podcast that is complete.
75+
The *tags* property associates one or more string tags with the queue. Tags
76+
can be specified using a string in simplified CSV format or an array of
77+
strings. A simplified CSV string is split on commas, and leading/trailing
78+
whitespace is stripped from each item. A tag must consist of at least one
79+
ASCII letter, number, period, underscore, or dash. For example, tag
80+
"complete" can be used to indicate that there will be no new episodes of a
81+
podcast that is complete.
7982

8083
The *next* property is a list of next items in the queue. When the list is
8184
exhausted, the previous item can be specified using the *prev* property. If
8285
both *prev* and *next* are specified, *prev* is ignored.
8386

84-
Items can be specified by name only, using a string or a number. To associate
85-
a URL or tags with an item, use an object with the following properties:
87+
Next items can be specified using a string in simplified CSV format or an
88+
array or items. A simplified CSV string is split on commas, and
89+
leading/trailing whitespace is stripped from each item. When specifying items
90+
using an array, the item name can be specified using a string or a number, or
91+
an object with the following properties can be used in order to specify more
92+
item information:
8693

8794
*name*
8895
: name of the item (string, required)
@@ -91,19 +98,19 @@ a URL or tags with an item, use an object with the following properties:
9198
: item URL (string, optional)
9299

93100
*tags*
94-
: list of tags (list of string, optional)
101+
: list of tags (simplified CSV string or array of strings, optional)
95102

96103
To organize queues into sections, the YAML file should be written as an object
97104
with two properties:
98105

99106
*sections*
100-
: list of sections names (optional)
107+
: list of sections names (array of strings, optional)
101108

102109
*queues*
103-
: list of queue objects (required)
110+
: list of queue objects (array of queue objects, required)
104111

105112
Sections names are specified using strings. The order that the sections are
106-
listed determines the order that they are displayed on the queue sheet.
113+
specified determines the order that they are displayed on the queue sheet.
107114

108115
Queue objects are as above, with an additional property to specify the
109116
section:
@@ -115,8 +122,8 @@ Queues that are not explicitly associated with a section are associated with
115122
an implicit default section.
116123

117124
To make it easier to share queue files, imports are also supported. Import
118-
another queue file using an import object instead of a queue object in a list
119-
of queues. An import object has the following properties:
125+
another queue file using an import object instead of a queue object in an
126+
array of queues. An import object has the following properties:
120127

121128
*import*
122129
: path to the queue file to import (string, required)

examples/podcasts.pdf

0 Bytes
Binary file not shown.

examples/podcasts.yaml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,7 @@ queues:
5252
url: https://www.preposterousuniverse.com/podcast/
5353
date: 2020-08-17
5454
section: Other
55-
next:
56-
- 108
57-
- 109
58-
- 110
55+
next: 108,109,110
5956

6057
- name: Quanta
6158
url: https://www.quantamagazine.org/tag/podcast/
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# `queue-sheet-haskell` `0.5.0.0` Release Notes
2+
3+
Date
4+
: 2020-11-08
5+
6+
## Overview
7+
8+
This release of Queue Sheet adds support for specifying lists of tags or items
9+
as a string in a simplified CSV format. Use of the CSV format can result in
10+
fewer changes when updating a file, making the update slightly easier to
11+
perform and the `git diff` output easier to read. See the updated man page
12+
for details.
13+
14+
This release also switches the Git default branch to `main`.
15+
16+
YAML files used with version `0.4.0.0` work with version `0.5.0.0` without
17+
change, but YAML files that the new CSV format will not work with version
18+
`0.4.0.0` or before.

queue-sheet.cabal

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: queue-sheet
2-
version: 0.4.0.0
2+
version: 0.5.0.0
33
category: Utils
44
synopsis: queue sheet utility
55
description:
@@ -53,6 +53,7 @@ library
5353
, text
5454
, transformers
5555
, ttc
56+
, vector
5657
, yaml
5758
default-language: Haskell2010
5859
ghc-options: -Wall

queue-sheet.nix

Lines changed: 0 additions & 19 deletions
This file was deleted.

shell.nix

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
{ nixpkgs ? import <nixpkgs> {}, compiler ? "ghc883" }:
2-
(import ./default.nix { inherit nixpkgs compiler; }).env
1+
(import ./default.nix).shell

src/QueueSheet/Types.hs

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ import Data.Text (Text)
6969
-- https://hackage.haskell.org/package/ttc
7070
import qualified Data.TTC as TTC
7171

72+
-- https://hackage.haskell.org/package/vector
73+
import qualified Data.Vector as V
74+
7275
------------------------------------------------------------------------------
7376
-- $Name
7477

@@ -174,7 +177,7 @@ instance FromJSON Item where
174177
(A.Object o) -> do
175178
itemName <- o .: "name"
176179
itemUrl <- o .:? "url"
177-
itemTags <- o .:? "tags" .!= []
180+
itemTags <- maybe (pure []) parseCSV =<< (o .:? "tags")
178181
return Item{..}
179182
value -> do
180183
itemName <- Name <$> parseToString value
@@ -209,13 +212,13 @@ instance FromJSON Queue where
209212
queueUrl <- o .:? "url"
210213
queueDate <- o .:? "date"
211214
queueSection <- o .:? "section" .!= defaultSection
212-
queueTags <- o .:? "tags" .!= []
215+
queueTags <- maybe (pure []) parseCSV =<< (o .:? "tags")
213216
mPrevItem <- o .:? "prev"
214-
mNextItems <- o .:? "next"
215-
let queueItems = case (mPrevItem, mNextItems) of
216-
(_, Just items) -> Just $ Right items
217-
(Just item, Nothing) -> Just $ Left item
218-
(Nothing, Nothing) -> Nothing
217+
mNextValue <- o .:? "next"
218+
queueItems <- case (mPrevItem, mNextValue) of
219+
(_, Just nextValue) -> Just . Right <$> parseCSV nextValue
220+
(Just item, Nothing) -> pure . Just $ Left item
221+
(Nothing, Nothing) -> pure Nothing
219222
return Queue{..}
220223

221224
------------------------------------------------------------------------------
@@ -306,6 +309,17 @@ escapeTeX = T.foldl go ""
306309
'~' -> acc <> "\\textasciitilde{}"
307310
c -> acc `T.snoc` c
308311

312+
-- | Parse an array or string in simplified CSV format
313+
--
314+
-- Strings are split on commas, and leading/trailing whitespace is removed
315+
-- from each item.
316+
parseCSV :: A.FromJSON a => A.Value -> AT.Parser [a]
317+
parseCSV = \case
318+
(A.String t) -> mapM (parseJSON . A.String . T.strip) $ T.splitOn "," t
319+
(A.Array v) -> mapM parseJSON $ V.toList v
320+
A.Object{} -> fail "unexpected object"
321+
value -> (: []) <$> parseJSON value
322+
309323
-- | Parse any scalar value as a string
310324
--
311325
-- Strings, numbers, booleans, and null are parsed as a string. Empty

stack.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
resolver: lts-16.13
1+
resolver: lts-16.20
22

33
packages:
44
- .

0 commit comments

Comments
 (0)