From 68d4b89101955db34592d6b507f8112c3c65e143 Mon Sep 17 00:00:00 2001 From: George Dietrich Date: Tue, 9 Jun 2020 20:03:05 -0400 Subject: [PATCH] 0.35.0 Updates (#61) * Fix format list within help info * Use exhaustive case for `OQ::Format.converter` * Bump min required Crystal version * Remove link flag from build command; 0.35.0 will now properly handle linking `libxml2` --- .github/workflows/deployment.yml | 2 +- shard.yml | 2 +- spec/format_spec.cr | 9 +++++++++ src/oq.cr | 8 +++----- 4 files changed, 14 insertions(+), 7 deletions(-) create mode 100644 spec/format_spec.cr diff --git a/.github/workflows/deployment.yml b/.github/workflows/deployment.yml index 32f7229..a8d3946 100644 --- a/.github/workflows/deployment.yml +++ b/.github/workflows/deployment.yml @@ -16,7 +16,7 @@ jobs: run: apk add --update --upgrade --no-cache --force-overwrite libxml2-dev yaml-dev - name: Build run: | - shards build --production --release --static --no-debug --link-flags "$(pkg-config libxml-2.0 --libs --static)" + shards build --production --release --static --no-debug strip ./bin/oq - name: Upload uses: actions/upload-release-asset@v1.0.1 diff --git a/shard.yml b/shard.yml index b13659d..6c966de 100644 --- a/shard.yml +++ b/shard.yml @@ -8,7 +8,7 @@ version: 1.1.0 authors: - George Dietrich -crystal: 0.31.0 +crystal: 0.35.0 license: MIT diff --git a/spec/format_spec.cr b/spec/format_spec.cr new file mode 100644 index 0000000..d07c50c --- /dev/null +++ b/spec/format_spec.cr @@ -0,0 +1,9 @@ +require "./spec_helper" + +describe OQ::Format do + describe ".to_s" do + it "returns a comma separated list of the formats" do + OQ::Format.to_s.should eq "json, yaml, xml" + end + end +end diff --git a/src/oq.cr b/src/oq.cr index 2ff3de2..402d635 100644 --- a/src/oq.cr +++ b/src/oq.cr @@ -15,8 +15,8 @@ module OQ Xml # Returns the list of supported formats. - def self.to_s : String - names.map(&.downcase).join(", ") + def self.to_s(io : IO) : Nil + self.names.join(io, ", ") { |str, join_io| str.downcase join_io } end # Maps a given format to its converter. @@ -24,10 +24,8 @@ module OQ {% begin %} case self {% for format in @type.constants %} - when .{{format.downcase.id}}? then OQ::Converters::{{format.id}} + in .{{format.downcase.id}}? then OQ::Converters::{{format.id}} {% end %} - else - raise "Unsupported format: '#{self}'." end {% end %} end