mdopen 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -6
- data/lib/mdopen/version.rb +1 -1
- data/lib/mdopen.rb +7 -10
- data/lib/templates/github.html.erb +1 -1
- data/mdopen.gemspec +1 -0
- metadata +16 -3
- data/lib/mdopen/erb_template.rb +0 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1b136a74a9a322c450767b4cd1a82fab1fd34fda
|
4
|
+
data.tar.gz: 254b83ccb707df522746d65f3b15bc9bd90535e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e0a8c5771c6688be7f6d2b4627d6531e6f697b1d8164d0a43306b7af447f644f584aec3966ea753dd75c7372ea9b53e303e4bf7192001c4ebc7aec5a907618f0
|
7
|
+
data.tar.gz: 2b8cc6cb156642f3023bd023f19dc3665e3027e9d34505693630fd84ee689e806cf9e7e97d58cfbd704ebd8c0980129337bdd7ba636f0c058e837269748906ea
|
data/README.md
CHANGED
@@ -2,23 +2,21 @@
|
|
2
2
|
|
3
3
|
`mdopen` is a command tool to preview your Markdown file.
|
4
4
|
|
5
|
-
I ever
|
5
|
+
I ever thought to write such a tool to preview `README` file in a git repository when working in terminal. And then I find [mdopen](https://github.com/romanyx/mdopen) written in Golang before I start. Now I migrate it to Ruby.
|
6
6
|
|
7
7
|
Hope it helpful~
|
8
8
|
|
9
9
|
## Installation
|
10
10
|
|
11
|
-
`mdopen` is a command tool,
|
11
|
+
`mdopen` is mainly a command tool, you can just install it as:
|
12
12
|
|
13
13
|
$ gem install mdopen
|
14
14
|
|
15
15
|
## Usage
|
16
16
|
|
17
|
-
|
18
|
-
mdopen <markdown_file>
|
19
|
-
```
|
17
|
+
$ mdopen [markdown_file]
|
20
18
|
|
21
|
-
|
19
|
+
`README` or `README.md` will be used in turn as an input filename if the [markdown_file] is omitted or not exists. So run `mdopen` when you only want to view the `README` file.
|
22
20
|
|
23
21
|
## Development
|
24
22
|
|
data/lib/mdopen/version.rb
CHANGED
data/lib/mdopen.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
require
|
1
|
+
require 'os'
|
2
2
|
require 'redcarpet'
|
3
3
|
require 'tempfile'
|
4
|
-
require
|
5
|
-
require
|
4
|
+
require 'tilt/erb'
|
5
|
+
require 'mdopen/version'
|
6
6
|
|
7
7
|
module Mdopen
|
8
8
|
class << self
|
@@ -14,13 +14,10 @@ module Mdopen
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def erb_render(content, html_file_path)
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
def get_template
|
22
|
-
template_file = File.join(__dir__, 'templates/github.html.erb')
|
23
|
-
File.read(template_file)
|
17
|
+
template_path = File.join(__dir__, 'templates/github.html.erb')
|
18
|
+
template = Tilt::ERBTemplate.new(template_path)
|
19
|
+
output = template.render(self, content: content)
|
20
|
+
File.write(html_file_path, output)
|
24
21
|
end
|
25
22
|
|
26
23
|
def md2html(md_file)
|
data/mdopen.gemspec
CHANGED
@@ -19,6 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
|
20
20
|
spec.add_dependency "os", "~> 1.0"
|
21
21
|
spec.add_dependency "redcarpet", "~> 3.4"
|
22
|
+
spec.add_dependency "tilt", "~> 2.0"
|
22
23
|
|
23
24
|
spec.add_development_dependency "bundler", "~> 1.16"
|
24
25
|
spec.add_development_dependency "rake", "~> 10.0"
|
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.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- B1nj0y
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-08-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: os
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '3.4'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: tilt
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: bundler
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,7 +94,6 @@ files:
|
|
80
94
|
- bin/mdopen
|
81
95
|
- bin/setup
|
82
96
|
- lib/mdopen.rb
|
83
|
-
- lib/mdopen/erb_template.rb
|
84
97
|
- lib/mdopen/version.rb
|
85
98
|
- lib/templates/github.html.erb
|
86
99
|
- mdopen.gemspec
|
data/lib/mdopen/erb_template.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
require 'erb'
|
2
|
-
|
3
|
-
module Mdopen
|
4
|
-
class ErbTemplate
|
5
|
-
include ERB::Util
|
6
|
-
attr_accessor :content, :template
|
7
|
-
|
8
|
-
def initialize(content, template)
|
9
|
-
@content = content
|
10
|
-
@template = template
|
11
|
-
end
|
12
|
-
|
13
|
-
def render()
|
14
|
-
ERB.new(@template).result(binding)
|
15
|
-
end
|
16
|
-
|
17
|
-
def save(file)
|
18
|
-
File.write(file, render)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|