Skip to content

Commit

Permalink
0.35.0 Updates (#61)
Browse files Browse the repository at this point in the history
* 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`
  • Loading branch information
Blacksmoke16 authored Jun 10, 2020
1 parent e76ebce commit 68d4b89
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
Expand Down
2 changes: 1 addition & 1 deletion shard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ version: 1.1.0
authors:
- George Dietrich <[email protected]>

crystal: 0.31.0
crystal: 0.35.0

license: MIT

Expand Down
9 changes: 9 additions & 0 deletions spec/format_spec.cr
Original file line number Diff line number Diff line change
@@ -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
8 changes: 3 additions & 5 deletions src/oq.cr
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,17 @@ 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.
def converter
{% 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
Expand Down

0 comments on commit 68d4b89

Please sign in to comment.