From 91e5a006eea3e5926f5ac5493c508a2587a2362c Mon Sep 17 00:00:00 2001 From: Jeremy Woertink Date: Mon, 27 Feb 2023 17:09:46 -0800 Subject: [PATCH] A little code cleanup. (#61) * A little code cleanup. Make sure things all run on latest stuff. Adding windows to the CI * update ameba with latest suggestions --- .github/workflows/ci.yml | 9 +++++++-- shard.yml | 2 +- src/lucky_router/fragment.cr | 2 +- src/lucky_router/path_part.cr | 8 ++++---- src/lucky_router/path_reader.cr | 4 ++-- 5 files changed, 15 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e8da115..dde8ff8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,12 +32,17 @@ jobs: strategy: fail-fast: false matrix: + os: [ubuntu-latest] crystal_version: - - 1.4.0 + - 1.6.2 - latest experimental: - false - runs-on: ubuntu-latest + include: + - os: windows-latest + crystal_version: latest + experimental: true + runs-on: ${{ matrix.os }} continue-on-error: ${{ matrix.experimental }} steps: - uses: actions/checkout@v2 diff --git a/shard.yml b/shard.yml index 219aecd..50ac90c 100644 --- a/shard.yml +++ b/shard.yml @@ -10,4 +10,4 @@ license: MIT development_dependencies: ameba: github: crystal-ameba/ameba - version: ~> 1.0.0 + version: ~> 1.4.0 diff --git a/src/lucky_router/fragment.cr b/src/lucky_router/fragment.cr index 20404d9..671341f 100644 --- a/src/lucky_router/fragment.cr +++ b/src/lucky_router/fragment.cr @@ -81,7 +81,7 @@ class LuckyRouter::Fragment(T) end end - def dynamic? + def dynamic? : Bool path_part.path_variable? end diff --git a/src/lucky_router/path_part.cr b/src/lucky_router/path_part.cr index 71917fb..20ace62 100644 --- a/src/lucky_router/path_part.cr +++ b/src/lucky_router/path_part.cr @@ -37,20 +37,20 @@ struct LuckyRouter::PathPart def initialize(@part) end - def name + def name : String name = part.lchop('?').lchop('*').lchop(':') unnamed_glob?(name) ? "glob" : name end - def optional? + def optional? : Bool part.starts_with?('?') end - def path_variable? + def path_variable? : Bool part.starts_with?(':') || part.starts_with?("?:") || glob? end - def glob? + def glob? : Bool part.starts_with?('*') end diff --git a/src/lucky_router/path_reader.cr b/src/lucky_router/path_reader.cr index 8a3244d..e7bc83a 100644 --- a/src/lucky_router/path_reader.cr +++ b/src/lucky_router/path_reader.cr @@ -23,7 +23,7 @@ struct LuckerRouter::PathReader def initialize(@path : String) end - def each + def each(&) each_segment do |offset, length, decode| segment = String.new(@path.to_unsafe + offset, length) if decode @@ -34,7 +34,7 @@ struct LuckerRouter::PathReader end end - private def each_segment + private def each_segment(&) index = 0 offset = 0 decode = false