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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fe31f6538f5062454273616edebfca14329c198f
4
- data.tar.gz: 5a33622275559fb7f1d6a8515d86606c46df541b
3
+ metadata.gz: 1b136a74a9a322c450767b4cd1a82fab1fd34fda
4
+ data.tar.gz: 254b83ccb707df522746d65f3b15bc9bd90535e1
5
5
  SHA512:
6
- metadata.gz: 4f12de3ffefc3cb0b411e60befd543a38b04b7a1aa4feb2fdd2a586d7ed42ef1a8cf5f390fac7e5cf3144f1949e835677bfecbbc2ba25db30771410db7451e29
7
- data.tar.gz: a273ea8d31884d91017fb29a1a332b3c7ed181ee1b4ffb08d986647512c123329ae2c4c6dd1526e92057941803fa006cf96f1f40a3842be5bd42f655c54a5362
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 want to write such a tool to preview `README` file in some git repository in terminal. And then I find [mdopen](https://github.com/romanyx/mdopen) witten in Golang before I start. Then I migrate it to Ruby.
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, so you'd better install it as:
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
- ```bash
18
- mdopen <markdown_file>
19
- ```
17
+ $ mdopen [markdown_file]
20
18
 
21
- "README" or "README.md" will be used as input filename if the <markdown_file> is omitted or not exists.
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
 
@@ -1,3 +1,3 @@
1
1
  module Mdopen
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
data/lib/mdopen.rb CHANGED
@@ -1,8 +1,8 @@
1
- require "os"
1
+ require 'os'
2
2
  require 'redcarpet'
3
3
  require 'tempfile'
4
- require "mdopen/version"
5
- require "mdopen/erb_template"
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
- erb_t = Mdopen::ErbTemplate.new(content, get_template)
18
- erb_t.save(html_file_path)
19
- end
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)
@@ -748,7 +748,7 @@
748
748
  </svg>
749
749
  </h3>
750
750
  <div class="markdown-body article">
751
- <%= @content %>
751
+ <%= content %>
752
752
  </div>
753
753
  </div>
754
754
  </body>
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.2
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-06-12 00:00:00.000000000 Z
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
@@ -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
-