krammer 1.0.2 → 1.1.0
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/bin/krammer +48 -20
- data/lib/krammer/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8c5ca84aec32f339b226b1c914e94e2091b88913
|
4
|
+
data.tar.gz: bf815344ec9b210ea5bb62961c9161fa9c5e2baf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0b9797d63b18a066fd57cdc6c0b78625f7b60ba47d4b24b004e142fd09e3a14f446ae07223fe3c8aac22361d0a346584fe9472904696aac68024a33b2173fab4
|
7
|
+
data.tar.gz: ef230c59c041bbf69d04efef0df7a237262d56589d2b8f404d877068af4db19f6b3cb79e075c9d1507658093f246c42f64286c67056904de2553ca574459f371
|
data/bin/krammer
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
+
require "optparse"
|
3
4
|
require "pathname"
|
4
5
|
require "yaml"
|
5
6
|
require "date"
|
@@ -18,32 +19,58 @@ class Info
|
|
18
19
|
end
|
19
20
|
end
|
20
21
|
|
21
|
-
|
22
|
-
directory = ""
|
22
|
+
options = {}
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
path = Pathname.new(result)
|
24
|
+
optparse = OptionParser.new do|opts|
|
25
|
+
opts.banner = "Usage: krammer [options] ..."
|
26
|
+
|
27
|
+
opts.on("-t", "--template TEMPLATE", "Use TEMPLATE as the template") do |t|
|
28
|
+
options[:template] = t
|
30
29
|
end
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
path = Pathname.new(Dir.pwd + "/" + ARGV[0])
|
30
|
+
|
31
|
+
opts.on("-i", "--input INPUT", "Use INPUT as the input file") do |i|
|
32
|
+
options[:input] = i
|
35
33
|
end
|
36
34
|
|
37
|
-
|
38
|
-
|
39
|
-
exit 1
|
35
|
+
opts.on("-o", "--output OUTPUT", "Use OUTPUT as the basename") do |o|
|
36
|
+
options[:output] = o
|
40
37
|
end
|
41
38
|
|
42
|
-
|
43
|
-
|
39
|
+
opts.on("-h", "--help", "Display the help screen" ) do
|
40
|
+
puts opts
|
41
|
+
exit 1
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
optparse.parse!
|
46
|
+
|
47
|
+
path = ""
|
48
|
+
directory = ""
|
49
|
+
|
50
|
+
unless input = options[:input]
|
51
|
+
unless input = Dir.glob("*.markdown")[0]
|
52
|
+
puts "\nInput file not found..."
|
53
|
+
exit 1
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
if (path = Pathname.new(input)).relative?
|
58
|
+
path = Pathname.new(Dir.pwd + "/" + input)
|
59
|
+
end
|
60
|
+
|
61
|
+
unless path.exist?
|
62
|
+
puts "\nInvalid path..."
|
44
63
|
exit 1
|
45
64
|
end
|
46
65
|
|
66
|
+
unless output = options[:output]
|
67
|
+
output = "output"
|
68
|
+
end
|
69
|
+
|
70
|
+
unless template = options[:template]
|
71
|
+
template = `echo $KRAMMER_TEMPLATE`.strip
|
72
|
+
end
|
73
|
+
|
47
74
|
Dir.chdir(path.parent)
|
48
75
|
|
49
76
|
fm = /^-{3}\n(.*\n)*?-{3}\n+/
|
@@ -82,10 +109,11 @@ while true
|
|
82
109
|
content = source.sub(fm, "")
|
83
110
|
body = Kramdown::Document.new(content, :auto_ids => false).to_latex
|
84
111
|
|
85
|
-
|
86
|
-
|
112
|
+
render = ERB.new(File.read(template)).result(Info.new(title: title, author: author, date: date, body: body).get_binding)
|
113
|
+
|
114
|
+
open("#{output}.tex", "w").write(render)
|
87
115
|
|
88
|
-
puts `pdflatex -halt-on-error output.tex`
|
116
|
+
puts `pdflatex -halt-on-error #{output}.tex`
|
89
117
|
puts "\nLast Update: #{DateTime.now.strftime("%Y-%m-%d %H:%M:%S.%L")}"
|
90
118
|
|
91
119
|
time = File.mtime(path)
|
data/lib/krammer/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: krammer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kento Kaneko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-01-
|
11
|
+
date: 2015-01-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|