trackler 2.1.0.47 → 2.1.0.48
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/trackler/doc_file.rb +67 -65
- data/lib/trackler/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d041252955c6c56c8018a5504e9e7062006f8b53
|
4
|
+
data.tar.gz: 7692edb8a74dc2636d1233774a7ccff2882e35ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b8744b83b20e0983d1248537a8237a2a5660ddf8ea28561b28c4bd85db6eb39914fc26482b5d1dce8ffb6902a462e6d6b5d35fbfc40f174f1deabb8e40fe8dd
|
7
|
+
data.tar.gz: 4929da04a0244fbe9c0bb8474cddc85944d382fb1da4369c693f5362844733f185bf606fe403b91ad00a08a739286ebc5ab446014f239d9a94ca35106b6bd98a
|
data/lib/trackler/doc_file.rb
CHANGED
@@ -1,75 +1,77 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
1
|
+
module Trackler
|
2
|
+
class DocFile
|
3
|
+
DEFAULT_IMAGE_PATH = "/docs/img"
|
4
|
+
|
5
|
+
def self.find(basename:, track_dir:)
|
6
|
+
dir = File.join(track_dir, "docs")
|
7
|
+
|
8
|
+
[
|
9
|
+
MarkdownFile.new(basename: basename, docs_dir: dir),
|
10
|
+
OrgmodeFile.new(basename: basename, docs_dir: dir),
|
11
|
+
].detect(&:exist?) || NullDocFile.new(basename: basename, docs_dir: dir)
|
12
|
+
end
|
13
|
+
|
14
|
+
attr_reader :basename, :dir
|
15
|
+
def initialize(basename:, docs_dir:)
|
16
|
+
@basename = basename
|
17
|
+
@dir = docs_dir
|
18
|
+
end
|
19
|
+
|
20
|
+
def render(image_path: DEFAULT_IMAGE_PATH)
|
21
|
+
body.gsub(img_src, img_dst(image_path))
|
22
|
+
end
|
23
|
+
|
24
|
+
def name
|
25
|
+
"%s.%s" % [basename, extension]
|
26
|
+
end
|
27
|
+
|
28
|
+
def extension
|
29
|
+
"md"
|
30
|
+
end
|
31
|
+
|
32
|
+
def exist?
|
33
|
+
File.exist?(path)
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def body
|
39
|
+
File.read(path)
|
40
|
+
end
|
41
|
+
|
42
|
+
def path
|
43
|
+
File.join(dir, name)
|
44
|
+
end
|
45
|
+
|
46
|
+
def img_src
|
47
|
+
Regexp.new("]\\(%s" % DEFAULT_IMAGE_PATH)
|
48
|
+
end
|
49
|
+
|
50
|
+
def img_dst(image_path)
|
51
|
+
"](%s" % image_path.gsub(Regexp.new("/$"), "")
|
52
|
+
end
|
17
53
|
end
|
18
54
|
|
19
|
-
|
20
|
-
body
|
21
|
-
|
22
|
-
|
23
|
-
def name
|
24
|
-
"%s.%s" % [basename, extension]
|
25
|
-
end
|
55
|
+
class OrgmodeFile < DocFile
|
56
|
+
def body
|
57
|
+
Orgmode::Parser.new(File.read(path)).to_markdown
|
58
|
+
end
|
26
59
|
|
27
|
-
|
28
|
-
|
60
|
+
def extension
|
61
|
+
"org"
|
62
|
+
end
|
29
63
|
end
|
30
64
|
|
31
|
-
|
32
|
-
File.exist?(path)
|
65
|
+
class MarkdownFile < DocFile
|
33
66
|
end
|
34
67
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
end
|
40
|
-
|
41
|
-
def path
|
42
|
-
File.join(dir, name)
|
43
|
-
end
|
44
|
-
|
45
|
-
def img_src
|
46
|
-
Regexp.new("]\\(%s" % DEFAULT_IMAGE_PATH)
|
47
|
-
end
|
48
|
-
|
49
|
-
def img_dst(image_path)
|
50
|
-
"](%s" % image_path.gsub(Regexp.new("/$"), "")
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
class OrgmodeFile < DocFile
|
55
|
-
def body
|
56
|
-
Orgmode::Parser.new(File.read(path)).to_markdown
|
57
|
-
end
|
58
|
-
|
59
|
-
def extension
|
60
|
-
"org"
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
class MarkdownFile < DocFile
|
65
|
-
end
|
66
|
-
|
67
|
-
class NullFile < DocFile
|
68
|
-
def render(image_path:"")
|
69
|
-
""
|
70
|
-
end
|
68
|
+
class NullDocFile < DocFile
|
69
|
+
def render(image_path:"")
|
70
|
+
""
|
71
|
+
end
|
71
72
|
|
72
|
-
|
73
|
-
|
73
|
+
def exist?
|
74
|
+
false
|
75
|
+
end
|
74
76
|
end
|
75
77
|
end
|
data/lib/trackler/version.rb
CHANGED