8000 More explicit types · porras/tlcr@c8f7499 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Apr 11, 2024. It is now read-only.

Commit c8f7499

Browse files
committed
More explicit types
1 parent bf66a7c commit c8f7499

File tree

7 files changed

+41
-23
lines changed

7 files changed

+41
-23
lines changed

src/tlcr/cache.cr

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
module Tlcr
22
class Cache
3-
def initialize(@directory = File.join(ENV["HOME"], ".tlcr"), @ttl : Time::Span = 30.days)
3+
@directory : String
4+
@ttl : Time::Span
5+
6+
def initialize(@directory = File.join(ENV["HOME"], ".tlcr"), @ttl = 30.days)
47
end
58

69
def get(keys)

src/tlcr/cli.cr

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ module Tlcr
1313

1414
@ttl : Time::Span
1515
@command : String?
16+
@local : Bool
17+
@download : Bool
18+
@version : Bool
1619

1720
def initialize
1821
@ttl = 30.days

src/tlcr/client.cr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ module Tlcr
2323
end
2424
end
2525

26-
private def page_content(command)
26+
private def page_content(command : Tlcr::Command)
2727
@cache.get([command.default_platform, command.name]) do
2828
puts "Fetching #{command.name}..."
2929
@http.page_content(command)

src/tlcr/download.cr

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ module Tlcr
99
new(cache).download
1010
end
1111

12-
def initialize(@cache : Tlcr::Cache)
12+
@cache : Tlcr::Cache
13+
14+
def initialize(@cache)
1315
end
1416

1517
def download

src/tlcr/entities.cr

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,25 @@ module Tlcr
1515
command.name == name
1616
end
1717
end
18+
end
1819

19-
class Command
20-
JSON.mapping({
21-
name: String,
22-
platform: Set(String),
23-
})
20+
class Command
21+
JSON.mapping({
22+
name: String,
23+
platform: Set(String),
24+
})
2425

25-
def available?
26-
@platform.includes?("common") || @platform.includes?(Tlcr.platform)
27-
end
26+
def available?
27+
@platform.includes?("common") || @platform.includes?(Tlcr.platform)
28+
end
2829

29-
def default_platform
30-
if @platform.includes?("common")
31-
"common"
32-
elsif @platform.includes?(Tlcr.platform)
33-
Tlcr.platform
34-
else
35-
@platform.first
36-
end
30+
def default_platform
31+
if @platform.includes?("common")
32+
"common"
33+
elsif @platform.includes?(Tlcr.platform)
34+
Tlcr.platform
35+
else
36+
@platform.first
3737
end
3838
end
3939
end

src/tlcr/http.cr

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,18 @@ require "http/client"
22

33
module Tlcr
44
class HTTP
5-
def initialize(@index_uri : URI = URI.parse("https://tldr-pages.github.io/assets/index.json"),
6-
@base_uri : URI = URI.parse("https://raw.githubusercontent.com/tldr-pages/tldr"))
5+
@index_uri : URI
6+
@base_uri : URI
7+
8+
def initialize(@index_uri = URI.parse("https://tldr-pages.github.io/assets/index.json"),
9+
@base_uri = URI.parse("https://raw.githubusercontent.com/tldr-pages/tldr"))
710
end
811

912
def index_content
1013
::HTTP::Client.get(@index_uri).body
1114
end
1215

13-
def page_content(command)
16+
def page_content(command : Tlcr::Command)
1417
::HTTP::Client.get(@base_uri.to_s + "/master/pages/#{command.default_platform}/#{command.name}.md").body
1518
end
1619
end

src/tlcr/render.cr

Lines changed: 8 additions & 1 deletion
CE78
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ require "colorize"
33

44
module Tlcr
55
class Page
6-
def initialize(@content : String)
6+
@content : String
7+
8+
def initialize(@content)
79
end
810

911
def to_s(io)
@@ -20,6 +22,11 @@ module Tlcr
2022
class Renderer
2123
include Markdown::Renderer
2224

25+
@io : IO
26+
@modes : Set(Symbol)
27+
@colors : Set(Symbol)
28+
@upcase : Bool
29+
2330
def initialize(@io : IO)
2431
@modes = Set(Symbol).new
2532
@colors = Set(Symbol).new

0 commit comments

Comments
 (0)
0