Skip to content

Commit

Permalink
A little code cleanup. (#61)
Browse files Browse the repository at this point in the history
* A little code cleanup. Make sure things all run on latest stuff. Adding windows to the CI

* update ameba with latest suggestions
  • Loading branch information
jwoertink authored Feb 28, 2023
1 parent ce3c17a commit 91e5a00
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 10 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion shard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ license: MIT
development_dependencies:
ameba:
github: crystal-ameba/ameba
version: ~> 1.0.0
version: ~> 1.4.0
2 changes: 1 addition & 1 deletion src/lucky_router/fragment.cr
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class LuckyRouter::Fragment(T)
end
end

def dynamic?
def dynamic? : Bool
path_part.path_variable?
end

Expand Down
8 changes: 4 additions & 4 deletions src/lucky_router/path_part.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions src/lucky_router/path_reader.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -34,7 +34,7 @@ struct LuckerRouter::PathReader
end
end

private def each_segment
private def each_segment(&)
index = 0
offset = 0
decode = false
Expand Down

0 comments on commit 91e5a00

Please sign in to comment.