wing 0.1.0 → 0.1.1
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/README.md +11 -0
- data/lib/wing.rb +25 -20
- data/lib/wing/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: 0c7dadda60c5f494c06f70d432c491541d75a38c
|
4
|
+
data.tar.gz: 6a0e45df984f92ced30984e3b655b59299eec6ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d617d96c9c26e26662c032a071a604c6e112a7aa5188aaa4f3ac20b8510eca87686fa163592f24a296dbc62440798c62cf5498a4837b5e62f594d52908200ab2
|
7
|
+
data.tar.gz: abb341eef1f9b5d744f9dd54c2e8f5bde5fc464959226197ce2b1228983eeeebc8e273cbeda9d64dcfd54eccf1573c400d304007abbb355dca8afdb3455541bc
|
data/README.md
CHANGED
data/lib/wing.rb
CHANGED
@@ -10,17 +10,19 @@ module Wing
|
|
10
10
|
SCRIPTS = File.expand_path("../wing/scripts", __FILE__)
|
11
11
|
|
12
12
|
def self.run(argv)
|
13
|
+
files = if argv.size > 1
|
14
|
+
argv.drop(1)
|
15
|
+
else
|
16
|
+
Dir.glob("**/*.md")
|
17
|
+
end
|
18
|
+
|
13
19
|
case argv[0]
|
14
20
|
when "init"
|
15
21
|
init
|
22
|
+
when "html"
|
23
|
+
Generator.new(files).gen_html
|
16
24
|
when "gen"
|
17
|
-
files
|
18
|
-
argv.drop(1)
|
19
|
-
else
|
20
|
-
Dir.glob("**/*.md")
|
21
|
-
end
|
22
|
-
|
23
|
-
Generator.new(files).call
|
25
|
+
Generator.new(files).gen_pdf
|
24
26
|
else
|
25
27
|
help
|
26
28
|
end
|
@@ -63,28 +65,31 @@ Usage: wing [init|gen] [OPTIONS] [FILES]
|
|
63
65
|
end
|
64
66
|
|
65
67
|
|
66
|
-
def
|
67
|
-
|
68
|
+
def gen_pdf
|
69
|
+
prepare
|
70
|
+
gen_html
|
71
|
+
|
72
|
+
# Convert to pdf
|
73
|
+
system "phantomjs #{phantom_script_path} file://#{@html_path} #{Shellwords.escape(title)}.pdf A4"
|
74
|
+
puts "#{title}.pdf generated"
|
75
|
+
end
|
76
|
+
|
77
|
+
def gen_html
|
78
|
+
# Write html to file
|
79
|
+
@html_path = File.expand_path(File.join("build", "page.html"))
|
80
|
+
File.open(@html_path, "w") {|f| f.write html }
|
68
81
|
end
|
69
82
|
|
70
|
-
def
|
83
|
+
def prepare
|
71
84
|
# Prepare build dir
|
72
85
|
FileUtils.rm_r "build" if File.exists?("build")
|
73
86
|
FileUtils.mkdir_p "build"
|
74
87
|
|
75
88
|
# Copy assets
|
76
89
|
FileUtils.cp_r ASSETS, File.join("build", "assets")
|
77
|
-
|
78
|
-
# Write html to file
|
79
|
-
html_path = File.expand_path(File.join("build", "page.html"))
|
80
|
-
File.open(html_path, "w") {|f| f.write html }
|
81
|
-
|
82
|
-
# Convert to pdf
|
83
|
-
system "phantomjs #{phantom_script_path} file://#{html_path} #{Shellwords.escape(title)}.pdf A4"
|
84
|
-
|
85
|
-
puts "#{title}.pdf generated"
|
86
90
|
end
|
87
91
|
|
92
|
+
|
88
93
|
def phantom_script_path
|
89
94
|
File.join(SCRIPTS, "rasterize.js")
|
90
95
|
end
|
@@ -101,7 +106,7 @@ Usage: wing [init|gen] [OPTIONS] [FILES]
|
|
101
106
|
require "github/markdown"
|
102
107
|
|
103
108
|
GitHub::Markdown.to_html(content, :markdown) do |code, lang|
|
104
|
-
if lang == "
|
109
|
+
if lang == "diagram"
|
105
110
|
%Q|<div class="mermaid">\n#{code}\n</div>\n|
|
106
111
|
end
|
107
112
|
end
|
data/lib/wing/version.rb
CHANGED