mdopen 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/mdopen.rb +11 -7
- data/lib/mdopen/version.rb +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2269634ac426dc7e2850c5df8bcb7ba19f312ea618f182bc51d8b229235df18b
|
4
|
+
data.tar.gz: 79c5d03e4c8d811c3625bf9eff9abec4567c470aeb66c2fff77a9bc4a3e5d71b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c8a3e8b1d8e9b215b37b5b6bc5538e4f1d9ae75e76c4c92763d54506ffe7ebee639591bc13f19e6ea1ba02b1e4edc52cd13252d47097d0f802b756f78af002e
|
7
|
+
data.tar.gz: 7eb80bb5adf92c4eca17234d46aa5177c69a31a12d265a6c939f67f72c0b683e806672712a0074ea3ebec54c496b062c9ff26fb7e5824c7a0955e554a85f5a54
|
data/lib/mdopen.rb
CHANGED
@@ -8,16 +8,18 @@ module Mdopen
|
|
8
8
|
class << self
|
9
9
|
def preview(md_file)
|
10
10
|
content = md2html(md_file)
|
11
|
-
|
12
|
-
|
11
|
+
tmp_file = new_tmpfile
|
12
|
+
html_file_path = tmp_file.path
|
13
|
+
erb_render(content, tmp_file)
|
13
14
|
system "#{open_cmd} file://#{html_file_path}"
|
14
15
|
end
|
15
16
|
|
16
|
-
def erb_render(content,
|
17
|
+
def erb_render(content, tmp_file)
|
17
18
|
template_path = File.join(__dir__, 'templates/github.html.erb')
|
18
19
|
template = Tilt::ERBTemplate.new(template_path)
|
19
20
|
output = template.render(self, content: content)
|
20
|
-
|
21
|
+
tmp_file.write(output)
|
22
|
+
tmp_file.close
|
21
23
|
end
|
22
24
|
|
23
25
|
def md2html(md_file)
|
@@ -45,10 +47,12 @@ module Mdopen
|
|
45
47
|
end
|
46
48
|
end
|
47
49
|
|
48
|
-
def
|
50
|
+
def new_tmpfile
|
49
51
|
filename = tmp_filename
|
50
|
-
|
51
|
-
|
52
|
+
tmp_file = Tempfile.new([filename, '.html'])
|
53
|
+
# prevent tempfile from deleting by GC
|
54
|
+
ObjectSpace.undefine_finalizer(tmp_file)
|
55
|
+
tmp_file
|
52
56
|
end
|
53
57
|
|
54
58
|
def tmp_filename
|
data/lib/mdopen/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mdopen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- B1nj0y
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-08-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: os
|
@@ -116,8 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
116
116
|
- !ruby/object:Gem::Version
|
117
117
|
version: '0'
|
118
118
|
requirements: []
|
119
|
-
|
120
|
-
rubygems_version: 2.5.2
|
119
|
+
rubygems_version: 3.0.3
|
121
120
|
signing_key:
|
122
121
|
specification_version: 4
|
123
122
|
summary: mdopen is a command to preview a markdown file.
|