This repository was archived by the owner on Apr 11, 2024. It is now read-only.
File tree 7 files changed +41
-23
lines changed
7 files changed +41
-23
lines changed Original file line number Diff line number Diff line change 1
1
module Tlcr
2
2
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)
4
7
end
5
8
6
9
def get (keys )
Original file line number Diff line number Diff line change @@ -13,6 +13,9 @@ module Tlcr
13
13
14
14
@ttl : Time ::Span
15
15
@command : String ?
16
+ @local : Bool
17
+ @download : Bool
18
+ @version : Bool
16
19
17
20
def initialize
18
21
@ttl = 30 .days
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ module Tlcr
23
23
end
24
24
end
25
25
26
- private def page_content (command )
26
+ private def page_content (command : Tlcr :: Command )
27
27
@cache .get([command.default_platform, command.name]) do
28
28
puts " Fetching #{ command.name } ..."
29
29
@http .page_content(command)
Original file line number Diff line number Diff line change @@ -9,7 +9,9 @@ module Tlcr
9
9
new(cache).download
10
10
end
11
11
12
- def initialize (@cache : Tlcr ::Cache )
12
+ @cache : Tlcr ::Cache
13
+
14
+ def initialize (@cache )
13
15
end
14
16
15
17
def download
Original file line number Diff line number Diff line change @@ -15,25 +15,25 @@ module Tlcr
15
15
command.name == name
16
16
end
17
17
end
18
+ end
18
19
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
+ })
24
25
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
28
29
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
37
37
end
38
38
end
39
39
end
Original file line number Diff line number Diff line change @@ -2,15 +2,18 @@ require "http/client"
2
2
3
3
module Tlcr
4
4
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" ))
7
10
end
8
11
9
12
def index_content
10
13
::HTTP ::Client .get(@index_uri ).body
11
14
end
12
15
13
- def page_content (command )
16
+ def page_content (command : Tlcr :: Command )
14
17
::HTTP ::Client .get(@base_uri .to_s + " /master/pages/#{ command.default_platform } /#{ command.name } .md" ).body
15
18
end
16
19
end
Original file line number Diff line number Diff line change
CE78
@@ -3,7 +3,9 @@ require "colorize"
3
3
4
4
module Tlcr
5
5
class Page
6
- def initialize (@content : String )
6
+ @content : String
7
+
8
+ def initialize (@content )
7
9
end
8
10
9
11
def to_s (io )
@@ -20,6 +22,11 @@ module Tlcr
20
22
class Renderer
21
23
include Markdown ::Renderer
22
24
25
+ @io : IO
26
+ @modes : Set (Symbol )
27
+ @colors : Set (Symbol )
28
+ @upcase : Bool
29
+
23
30
def initialize (@io : IO )
24
31
@modes = Set (Symbol ).new
25
32
@colors = Set (Symbol ).new
You can’t perform that action at this time.
0 commit comments