mdpage 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +20 -20
- data/.travis.yml +3 -4
- data/ChangeLog.md +15 -0
- data/Gemfile +8 -7
- data/LICENSE +22 -22
- data/README.md +31 -14
- data/Rakefile +20 -21
- data/bin/mdpage +31 -14
- data/lib/mdpage.rb +6 -50
- data/lib/mdpage/default.html.erb +54 -54
- data/lib/mdpage/optparser.rb +25 -0
- data/lib/mdpage/page.rb +58 -0
- data/lib/mdpage/version.rb +3 -3
- data/mdpage.gemspec +20 -19
- data/test/sample.md +6 -0
- data/test/sample2.md +6 -0
- data/test/sample_cp932.md +6 -0
- data/test/test_helper.rb +9 -0
- data/test/test_mdpage.rb +25 -0
- metadata +32 -11
- data/spec/.gitignore +0 -2
- data/spec/mdpage_spec.rb +0 -61
- data/spec/sample.md +0 -33
- data/spec/sample2.md +0 -6
data/.gitignore
CHANGED
@@ -1,20 +1,20 @@
|
|
1
|
-
*.gem
|
2
|
-
*.rbc
|
3
|
-
.bundle
|
4
|
-
.config
|
5
|
-
.yardoc
|
6
|
-
Gemfile.lock
|
7
|
-
InstalledFiles
|
8
|
-
_yardoc
|
9
|
-
coverage
|
10
|
-
doc/
|
11
|
-
lib/bundler/man
|
12
|
-
pkg
|
13
|
-
rdoc
|
14
|
-
|
15
|
-
|
16
|
-
test/
|
17
|
-
|
18
|
-
|
19
|
-
.DS_Store
|
20
|
-
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
test/*.html
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
experimental/
|
19
|
+
.DS_Store
|
20
|
+
|
data/.travis.yml
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
rvm:
|
2
|
-
- 1.
|
3
|
-
- 1.9.
|
4
|
-
- 1.9.3
|
1
|
+
rvm:
|
2
|
+
- 1.9.2
|
3
|
+
- 1.9.3
|
data/ChangeLog.md
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# mdpage change log
|
2
|
+
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
3
|
+
## 0.0.3
|
4
|
+
- custom template option
|
5
|
+
- fix gemspec dependency
|
6
|
+
|
7
|
+
## 0.0.2
|
8
|
+
- namespace changed MdPage to MdPage::Page
|
9
|
+
- added method **MdPage::Page.to_html_objects** which return path and htmldata as Hash objects.
|
10
|
+
|
11
|
+
## 0.0.1
|
12
|
+
- just release.
|
13
|
+
- Usage:
|
14
|
+
mdpage <file1> <file2> ....
|
15
|
+
|
data/Gemfile
CHANGED
@@ -1,7 +1,8 @@
|
|
1
|
-
# A sample Gemfile
|
2
|
-
source "https://rubygems.org"
|
3
|
-
|
4
|
-
# gem "rails"
|
5
|
-
gem 'rdiscount'
|
6
|
-
gem 'rake'
|
7
|
-
gem '
|
1
|
+
# A sample Gemfile
|
2
|
+
source "https://rubygems.org"
|
3
|
+
|
4
|
+
# gem "rails"
|
5
|
+
gem 'rdiscount'
|
6
|
+
gem 'rake'
|
7
|
+
gem 'test-unit'
|
8
|
+
gem 'shoulda'
|
data/LICENSE
CHANGED
@@ -1,22 +1,22 @@
|
|
1
|
-
Copyright (c) 2012 Masahiro Arakane
|
2
|
-
|
3
|
-
MIT License
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
-
a copy of this software and associated documentation files (the
|
7
|
-
"Software"), to deal in the Software without restriction, including
|
8
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
-
permit persons to whom the Software is furnished to do so, subject to
|
11
|
-
the following conditions:
|
12
|
-
|
13
|
-
The above copyright notice and this permission notice shall be
|
14
|
-
included in all copies or substantial portions of the Software.
|
15
|
-
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
1
|
+
Copyright (c) 2012 Masahiro Arakane
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,14 +1,31 @@
|
|
1
|
-
# mdpage : html generater for markdown files.
|
2
|
-
[![Build Status](https://secure.travis-ci.org/arafine/mdpage.png?branch=master)](http://travis-ci.org/arafine/mdpage)
|
3
|
-
|
4
|
-
## Usage
|
5
|
-
mdpage <file1> <file2>...
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
:
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
1
|
+
# mdpage : html generater for markdown files.
|
2
|
+
[![Build Status](https://secure.travis-ci.org/arafine/mdpage.png?branch=master)](http://travis-ci.org/arafine/mdpage)
|
3
|
+
|
4
|
+
## Usage
|
5
|
+
mdpage <file1> <file2>...
|
6
|
+
|
7
|
+
options:
|
8
|
+
-h, --help : show this messages
|
9
|
+
-t, --template <name> : use custom template <name>.html.erb under ~/.mdpage/
|
10
|
+
-v, --version : show version infomation
|
11
|
+
|
12
|
+
- all files encodings should be **UTF-8**.
|
13
|
+
- if you use template option, set your template file to ~/.mdpage
|
14
|
+
- naming convention of the custom template file: **name**.html.erb
|
15
|
+
|
16
|
+
### Custom template example
|
17
|
+
template files should have two variables.
|
18
|
+
- @page[:title] : First match line which start with "# ", will be set to @page[:title].
|
19
|
+
- @page[:contents] : Compiled markdown contents will be set to @page[:contents].
|
20
|
+
|
21
|
+
#### example
|
22
|
+
$ cat ~/.mdpage/hoge.html.erb
|
23
|
+
|
24
|
+
## Dependency
|
25
|
+
:default
|
26
|
+
- rdiscount (markdown parser)
|
27
|
+
|
28
|
+
:development
|
29
|
+
- rake
|
30
|
+
- test-unit
|
31
|
+
- shoulda
|
data/Rakefile
CHANGED
@@ -1,21 +1,20 @@
|
|
1
|
-
#!/usr/bin/env rake
|
2
|
-
|
3
|
-
require 'rubygems'
|
4
|
-
require 'bundler/gem_tasks'
|
5
|
-
require 'bundler'
|
6
|
-
|
7
|
-
begin
|
8
|
-
Bundler.setup(:default, :development)
|
9
|
-
rescue Bundler::BundlerError => e
|
10
|
-
$stderr.puts e.message
|
11
|
-
$stderr.puts "Run `bundle install` to install missing gems"
|
12
|
-
exit e.status_code
|
13
|
-
end
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
RSpec::Core::RakeTask.new(:spec)
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler/gem_tasks'
|
5
|
+
require 'bundler'
|
6
|
+
|
7
|
+
begin
|
8
|
+
Bundler.setup(:default, :development)
|
9
|
+
rescue Bundler::BundlerError => e
|
10
|
+
$stderr.puts e.message
|
11
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
12
|
+
exit e.status_code
|
13
|
+
end
|
14
|
+
|
15
|
+
task :test do
|
16
|
+
$:.unshift(File.dirname(__FILE__) + "/test")
|
17
|
+
require "test_helper"
|
18
|
+
end
|
19
|
+
|
20
|
+
task :default => :test
|
data/bin/mdpage
CHANGED
@@ -1,14 +1,31 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
exit
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
$:.unshift(File.dirname(__FILE__) + "/../lib")
|
4
|
+
require 'mdpage'
|
5
|
+
require "mdpage/optparser"
|
6
|
+
require "mdpage/version"
|
7
|
+
|
8
|
+
MdPage::OptParser.new do |opt|
|
9
|
+
opt.on('-h', '--help') {|v| puts opt.help; exit}
|
10
|
+
opt.on('-t name', '--template name') {|n| opt.template_name = n if n}
|
11
|
+
opt.on('-v', '--version') {|v| puts "MdPage::VERSION => #{MdPage::VERSION}"; exit}
|
12
|
+
|
13
|
+
begin
|
14
|
+
opt.parse!(ARGV)
|
15
|
+
if ARGV.empty?
|
16
|
+
puts opt.help
|
17
|
+
exit 0
|
18
|
+
end
|
19
|
+
unless opt.template_name
|
20
|
+
MdPage::Page.new(ARGV).to_html_files
|
21
|
+
else
|
22
|
+
MdPage::Page.new(ARGV).set_template(opt.template_name).to_html_files
|
23
|
+
end
|
24
|
+
puts "Done!"
|
25
|
+
rescue OptionParser::InvalidOption => e
|
26
|
+
MdPage::OptionError.new(e.message)
|
27
|
+
puts opt.help
|
28
|
+
exit 3
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
data/lib/mdpage.rb
CHANGED
@@ -1,50 +1,6 @@
|
|
1
|
-
require "rdiscount"
|
2
|
-
require "erb"
|
3
|
-
|
4
|
-
module MdPage
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
def initialize(argv)
|
9
|
-
@argv = argv
|
10
|
-
check_results = @argv.map {|av| File.exist? av}
|
11
|
-
@path_check = check_results.include?(false) ? false : true
|
12
|
-
tpl_path = File.dirname(__FILE__) + "/mdpage/default.html.erb"
|
13
|
-
@template = File.open(tpl_path, "r:utf-8") {|f| f.read}
|
14
|
-
@doc = Hash.new
|
15
|
-
@result = nil
|
16
|
-
end
|
17
|
-
|
18
|
-
def md2html(file)
|
19
|
-
begin
|
20
|
-
raw_contents = File.open(file, "r:utf-8") {|f| f.read}
|
21
|
-
rescue
|
22
|
-
raise "#{file} encoding should be UTF-8."
|
23
|
-
end
|
24
|
-
raw_contents =~ /^.*#\s?(.+)\n.+/
|
25
|
-
@doc[:title] = $1 || ''
|
26
|
-
contents = RDiscount.new(raw_contents).to_html
|
27
|
-
return contents
|
28
|
-
end
|
29
|
-
|
30
|
-
def to_html_files
|
31
|
-
path_data = to_html_objects
|
32
|
-
path_data.each do |k, v|
|
33
|
-
File.open(k, "w:utf-8") {|f| f.write v}
|
34
|
-
end
|
35
|
-
@result = true
|
36
|
-
end
|
37
|
-
|
38
|
-
def to_html_objects
|
39
|
-
erb = ERB.new(@template)
|
40
|
-
html_objects = Hash.new
|
41
|
-
@argv.each do |file|
|
42
|
-
@doc[:contents] = md2html(file)
|
43
|
-
html = erb.result(binding)
|
44
|
-
out_path = File.expand_path(file) + ".html"
|
45
|
-
html_objects.store(out_path, html)
|
46
|
-
end
|
47
|
-
return html_objects
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
1
|
+
require "rdiscount"
|
2
|
+
require "erb"
|
3
|
+
|
4
|
+
module MdPage
|
5
|
+
require "mdpage/page"
|
6
|
+
end
|
data/lib/mdpage/default.html.erb
CHANGED
@@ -1,54 +1,54 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<meta charset='utf-8'>
|
5
|
-
<title><%= @
|
6
|
-
<style type="text/css">
|
7
|
-
body {
|
8
|
-
font: 14px Helvetica, arial, freesans, clean, Meiryo, sans-serif;
|
9
|
-
margin: 0;
|
10
|
-
padding: 0;
|
11
|
-
line-height: 1.4em;
|
12
|
-
}
|
13
|
-
div#markdown-body {
|
14
|
-
width: 880px;
|
15
|
-
margin: 0 auto;
|
16
|
-
}
|
17
|
-
#markdown-body h1, #markdown-body h2 {
|
18
|
-
border-bottom: 1px solid #ccc;
|
19
|
-
}
|
20
|
-
#markdown-body h3, #markdown-body h4 {
|
21
|
-
border-left: 2px solid #ccc;
|
22
|
-
padding-left: 3px;
|
23
|
-
}
|
24
|
-
#markdown-body table {
|
25
|
-
border-collapse: collapse;
|
26
|
-
border: 1px solid #eee;
|
27
|
-
}
|
28
|
-
#markdown-body table thead {
|
29
|
-
background: #eee;
|
30
|
-
}
|
31
|
-
#markdown-body th, #markdown-body td {
|
32
|
-
padding: 2px 3px;
|
33
|
-
border: 1px solid #ccc;
|
34
|
-
}
|
35
|
-
#markdown-body blockquote {
|
36
|
-
background: #eee;
|
37
|
-
border-left: 4px double #ccc;
|
38
|
-
margin: 5px 40px;
|
39
|
-
padding: 8px;
|
40
|
-
}
|
41
|
-
#markdown-body pre {
|
42
|
-
background: #efefef;
|
43
|
-
border: 1px solid #e7e7e7;
|
44
|
-
border-radius: 3px;
|
45
|
-
padding: 14px;
|
46
|
-
}
|
47
|
-
</style>
|
48
|
-
</head>
|
49
|
-
<body>
|
50
|
-
<div id="markdown-body">
|
51
|
-
<%= @
|
52
|
-
</div>
|
53
|
-
</body>
|
54
|
-
</html>
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset='utf-8'>
|
5
|
+
<title><%= @page[:title] %></title>
|
6
|
+
<style type="text/css">
|
7
|
+
body {
|
8
|
+
font: 14px Helvetica, arial, freesans, clean, Meiryo, sans-serif;
|
9
|
+
margin: 0;
|
10
|
+
padding: 0;
|
11
|
+
line-height: 1.4em;
|
12
|
+
}
|
13
|
+
div#markdown-body {
|
14
|
+
width: 880px;
|
15
|
+
margin: 0 auto;
|
16
|
+
}
|
17
|
+
#markdown-body h1, #markdown-body h2 {
|
18
|
+
border-bottom: 1px solid #ccc;
|
19
|
+
}
|
20
|
+
#markdown-body h3, #markdown-body h4 {
|
21
|
+
border-left: 2px solid #ccc;
|
22
|
+
padding-left: 3px;
|
23
|
+
}
|
24
|
+
#markdown-body table {
|
25
|
+
border-collapse: collapse;
|
26
|
+
border: 1px solid #eee;
|
27
|
+
}
|
28
|
+
#markdown-body table thead {
|
29
|
+
background: #eee;
|
30
|
+
}
|
31
|
+
#markdown-body th, #markdown-body td {
|
32
|
+
padding: 2px 3px;
|
33
|
+
border: 1px solid #ccc;
|
34
|
+
}
|
35
|
+
#markdown-body blockquote {
|
36
|
+
background: #eee;
|
37
|
+
border-left: 4px double #ccc;
|
38
|
+
margin: 5px 40px;
|
39
|
+
padding: 8px;
|
40
|
+
}
|
41
|
+
#markdown-body pre {
|
42
|
+
background: #efefef;
|
43
|
+
border: 1px solid #e7e7e7;
|
44
|
+
border-radius: 3px;
|
45
|
+
padding: 14px;
|
46
|
+
}
|
47
|
+
</style>
|
48
|
+
</head>
|
49
|
+
<body>
|
50
|
+
<div id="markdown-body">
|
51
|
+
<%= @page[:contents] %>
|
52
|
+
</div>
|
53
|
+
</body>
|
54
|
+
</html>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module MdPage
|
2
|
+
require "optparse"
|
3
|
+
|
4
|
+
class OptParser < OptionParser
|
5
|
+
attr_reader :help
|
6
|
+
attr_accessor :template_name
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
@template_name
|
10
|
+
@help = <<-HELP
|
11
|
+
Usage:
|
12
|
+
-h, --help : show this messages
|
13
|
+
-t, --template <name> : use custom template <name>.html.erb under ~/.mdpage/
|
14
|
+
-v, --version : show version infomation
|
15
|
+
HELP
|
16
|
+
super
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
class OptionError
|
21
|
+
def initialize(message)
|
22
|
+
$stderr.puts "!!! " << message << " !!!"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/mdpage/page.rb
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
module MdPage
|
2
|
+
class Page
|
3
|
+
attr_reader :argv, :path_check, :doc, :result
|
4
|
+
|
5
|
+
def initialize(argv)
|
6
|
+
@argv = argv
|
7
|
+
check_results = @argv.map {|av| File.exist? av}
|
8
|
+
@path_check = check_results.include?(false) ? false : true
|
9
|
+
tpl_path = File.dirname(__FILE__) + "/default.html.erb"
|
10
|
+
@template = File.open(tpl_path, "r:utf-8") {|f| f.read}
|
11
|
+
@page = Hash.new
|
12
|
+
@result = nil
|
13
|
+
end
|
14
|
+
|
15
|
+
def md2html(file)
|
16
|
+
begin
|
17
|
+
raw_contents = File.open(file, "r:utf-8") {|f| f.read}
|
18
|
+
rescue
|
19
|
+
raise "#{file} encoding should be UTF-8."
|
20
|
+
end
|
21
|
+
raw_contents =~ /^.*#\s?(.+)\n.+/
|
22
|
+
@page[:title] = $1 || ''
|
23
|
+
contents = RDiscount.new(raw_contents).to_html
|
24
|
+
return contents
|
25
|
+
end
|
26
|
+
|
27
|
+
def to_html_files
|
28
|
+
path_data = to_html_objects
|
29
|
+
path_data.each do |k, v|
|
30
|
+
File.open(k, "w:utf-8") {|f| f.write v}
|
31
|
+
end
|
32
|
+
@result = true
|
33
|
+
end
|
34
|
+
|
35
|
+
def to_html_objects
|
36
|
+
erb = ERB.new(@template)
|
37
|
+
html_objects = Hash.new
|
38
|
+
@argv.each do |file|
|
39
|
+
@page[:contents] = md2html(file)
|
40
|
+
html = erb.result(binding)
|
41
|
+
out_path = File.expand_path(file) + ".html"
|
42
|
+
html_objects.store(out_path, html)
|
43
|
+
end
|
44
|
+
return html_objects
|
45
|
+
end
|
46
|
+
|
47
|
+
def set_template(template_name)
|
48
|
+
begin
|
49
|
+
home = ENV["HOME"]
|
50
|
+
template_path = "#{home}/.mdpage/#{template_name}.html.erb"
|
51
|
+
@template = File.open(template_path, "r:utf-8") {|f| f.read}
|
52
|
+
return self
|
53
|
+
rescue
|
54
|
+
raise "Missing template: #{template_path}"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
data/lib/mdpage/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
module MdPage
|
2
|
-
VERSION = "0.0.
|
3
|
-
end
|
1
|
+
module MdPage
|
2
|
+
VERSION = "0.0.3"
|
3
|
+
end
|
data/mdpage.gemspec
CHANGED
@@ -1,19 +1,20 @@
|
|
1
|
-
require File.expand_path('../lib/mdpage/version', __FILE__)
|
2
|
-
|
3
|
-
Gem::Specification.new do |gem|
|
4
|
-
gem.authors = ["Masahiro Arakane"]
|
5
|
-
gem.email = ["arafine@me.com"]
|
6
|
-
gem.description = <<-DESC
|
7
|
-
Simple styled document generator for markdown files
|
8
|
-
Usage:
|
9
|
-
mdpage <file1> <file2> ...
|
10
|
-
DESC
|
11
|
-
gem.summary = %q{Simple styled document generator for markdown files}
|
12
|
-
gem.homepage = "https://github.com/arafine/mdpage.git"
|
13
|
-
gem.files = `git ls-files`.split($\)
|
14
|
-
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
15
|
-
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
16
|
-
gem.name = "mdpage"
|
17
|
-
gem.require_paths = ["lib"]
|
18
|
-
gem.version = MdPage::VERSION
|
19
|
-
|
1
|
+
require File.expand_path('../lib/mdpage/version', __FILE__)
|
2
|
+
|
3
|
+
Gem::Specification.new do |gem|
|
4
|
+
gem.authors = ["Masahiro Arakane"]
|
5
|
+
gem.email = ["arafine@me.com"]
|
6
|
+
gem.description = <<-DESC
|
7
|
+
Simple styled document generator for markdown files
|
8
|
+
Usage:
|
9
|
+
mdpage <file1> <file2> ...
|
10
|
+
DESC
|
11
|
+
gem.summary = %q{Simple styled document generator for markdown files}
|
12
|
+
gem.homepage = "https://github.com/arafine/mdpage.git"
|
13
|
+
gem.files = `git ls-files`.split($\)
|
14
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
15
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
16
|
+
gem.name = "mdpage"
|
17
|
+
gem.require_paths = ["lib"]
|
18
|
+
gem.version = MdPage::VERSION
|
19
|
+
gem.add_dependency('rdiscount', '>=1.6.8')
|
20
|
+
end
|
data/test/sample.md
ADDED
data/test/sample2.md
ADDED
data/test/test_helper.rb
ADDED
data/test/test_mdpage.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
class MdPageTest < Test::Unit::TestCase
|
2
|
+
context 'MdPage::Page' do
|
3
|
+
setup do
|
4
|
+
cur_dir = File.dirname(__FILE__)
|
5
|
+
exist_files = ["#{cur_dir}/sample.md", "#{cur_dir}/sample2.md"]
|
6
|
+
unexist_file = ["#{cur_dir}/hoge.md"]
|
7
|
+
invalid_file = ["#{cur_dir}/sample_cp932.md"]
|
8
|
+
@mdp_exist = MdPage::Page.new(exist_files)
|
9
|
+
@mdp_unexist = MdPage::Page.new(unexist_file)
|
10
|
+
@mdp_invalid = MdPage::Page.new(invalid_file)
|
11
|
+
end
|
12
|
+
|
13
|
+
context 'when initialize' do
|
14
|
+
should '@path_check is true' do
|
15
|
+
assert_true @mdp_exist.path_check
|
16
|
+
assert_true @mdp_invalid.path_check
|
17
|
+
end
|
18
|
+
should '@path_check is false' do
|
19
|
+
assert_false @mdp_unexist.path_check
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mdpage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,8 +9,24 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-06-
|
13
|
-
dependencies:
|
12
|
+
date: 2012-06-07 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rdiscount
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 1.6.8
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 1.6.8
|
14
30
|
description: ! " Simple styled document generator for markdown
|
15
31
|
files\n Usage:\n mdpage <file1>
|
16
32
|
<file2> ...\n"
|
@@ -23,6 +39,7 @@ extra_rdoc_files: []
|
|
23
39
|
files:
|
24
40
|
- .gitignore
|
25
41
|
- .travis.yml
|
42
|
+
- ChangeLog.md
|
26
43
|
- Gemfile
|
27
44
|
- LICENSE
|
28
45
|
- README.md
|
@@ -30,12 +47,15 @@ files:
|
|
30
47
|
- bin/mdpage
|
31
48
|
- lib/mdpage.rb
|
32
49
|
- lib/mdpage/default.html.erb
|
50
|
+
- lib/mdpage/optparser.rb
|
51
|
+
- lib/mdpage/page.rb
|
33
52
|
- lib/mdpage/version.rb
|
34
53
|
- mdpage.gemspec
|
35
|
-
-
|
36
|
-
-
|
37
|
-
-
|
38
|
-
-
|
54
|
+
- test/sample.md
|
55
|
+
- test/sample2.md
|
56
|
+
- test/sample_cp932.md
|
57
|
+
- test/test_helper.rb
|
58
|
+
- test/test_mdpage.rb
|
39
59
|
homepage: https://github.com/arafine/mdpage.git
|
40
60
|
licenses: []
|
41
61
|
post_install_message:
|
@@ -61,8 +81,9 @@ signing_key:
|
|
61
81
|
specification_version: 3
|
62
82
|
summary: Simple styled document generator for markdown files
|
63
83
|
test_files:
|
64
|
-
-
|
65
|
-
-
|
66
|
-
-
|
67
|
-
-
|
84
|
+
- test/sample.md
|
85
|
+
- test/sample2.md
|
86
|
+
- test/sample_cp932.md
|
87
|
+
- test/test_helper.rb
|
88
|
+
- test/test_mdpage.rb
|
68
89
|
has_rdoc:
|
data/spec/.gitignore
DELETED
data/spec/mdpage_spec.rb
DELETED
@@ -1,61 +0,0 @@
|
|
1
|
-
$:.unshift(File.dirname(__FILE__) + "/../lib")
|
2
|
-
require "mdpage"
|
3
|
-
require "rspec"
|
4
|
-
|
5
|
-
describe MdPage::Page do
|
6
|
-
before(:each) do
|
7
|
-
files = [
|
8
|
-
"#{File.dirname(__FILE__)}/sample.md"
|
9
|
-
]
|
10
|
-
files2 = [
|
11
|
-
"#{File.dirname(__FILE__)}/sample.md",
|
12
|
-
"#{File.dirname(__FILE__)}/sample2.md"
|
13
|
-
]
|
14
|
-
@mdp = MdPage::Page.new(files)
|
15
|
-
@mdp_invalid_enc = MdPage::Page.new(files2)
|
16
|
-
end
|
17
|
-
|
18
|
-
context 'path_chekc should be return true' do
|
19
|
-
it "as init with file path as Array" do
|
20
|
-
argv = ["#{File.dirname(__FILE__)}/sample.md"]
|
21
|
-
mdp = MdPage::Page.new(argv)
|
22
|
-
mdp.path_check.should == true
|
23
|
-
end
|
24
|
-
|
25
|
-
it "as init with invalid file path" do
|
26
|
-
argv = ["#{File.dirname(__FILE__)}/faff/sample.md"]
|
27
|
-
mdp = MdPage::Page.new(argv)
|
28
|
-
mdp.path_check.should == false
|
29
|
-
end
|
30
|
-
|
31
|
-
it "as init with one or more valid file path" do
|
32
|
-
argv = [
|
33
|
-
"#{File.dirname(__FILE__)}/sample.md",
|
34
|
-
"#{File.dirname(__FILE__)}/sample2.md"
|
35
|
-
]
|
36
|
-
mdp = MdPage::Page.new(argv)
|
37
|
-
mdp.path_check.should == true
|
38
|
-
end
|
39
|
-
|
40
|
-
it "as init with one or more invalid file path" do
|
41
|
-
argv = [
|
42
|
-
"#{File.dirname(__FILE__)}/sample.md",
|
43
|
-
"#{File.dirname(__FILE__)}/rere/sample2.md"
|
44
|
-
]
|
45
|
-
mdp = MdPage::Page.new(argv)
|
46
|
-
mdp.path_check.should == false
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
context 'Generating html objects' do
|
51
|
-
it "should be return Hash" do
|
52
|
-
@mdp.to_html_objects.class.should == Hash.new.class
|
53
|
-
end
|
54
|
-
|
55
|
-
it "result should be true as generate html files" do
|
56
|
-
@mdp.to_html_files
|
57
|
-
@mdp.result.should == true
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
data/spec/sample.md
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
# mdpage
|
2
|
-
mdpage is a styled html generator for markdown files.
|
3
|
-
|
4
|
-
## \*.md files should be encoded "utf-8"
|
5
|
-
mdpage processes to assume utf-8 character encoding of the file.
|
6
|
-
|
7
|
-
## customize
|
8
|
-
if exist ~/.mdpage/default.html.erb , mdpage use your template.
|
9
|
-
|
10
|
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
11
|
-
|
12
|
-
## Default css style
|
13
|
-
|
14
|
-
# h1
|
15
|
-
## h2
|
16
|
-
### h3
|
17
|
-
#### h4
|
18
|
-
##### h5
|
19
|
-
###### h6
|
20
|
-
|
21
|
-
p
|
22
|
-
|
23
|
-
table style|header|
|
24
|
-
-----------|------|
|
25
|
-
td |td
|
26
|
-
|
27
|
-
>block quote
|
28
|
-
>block quote
|
29
|
-
|
30
|
-
def code_tag
|
31
|
-
puts "Hello mdpage"
|
32
|
-
end
|
33
|
-
|