cvgen 0.0.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 +7 -0
- data/bin/cvgen +8 -0
- data/lib/cvgen/converter.rb +87 -0
- data/lib/cvgen/exec.rb +24 -0
- data/lib/cvgen/parser.rb +40 -0
- data/lib/cvgen.rb +14 -0
- metadata +90 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 995328ac1dfc6664b3b62d0c5d1beef9740b0853
|
4
|
+
data.tar.gz: 8be0281314e3f56ff61565b197fdadcfa7bb1048
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 61f110c5fb8f35c9a0f8c26d286594810607b1e21a410e9e833e1f59cf79ef3af9d2ac973c13c4ff0fd4a214741a1b2333e3d8babf21b6e7645b928f4395603f
|
7
|
+
data.tar.gz: 242f047e6f51701cdc1c0a410847fea35a2381769fdb82ebb1d4780074073edf39af1537272089898197f09b57401735281a29e74f37f51c7a2d92e17ca65f78
|
data/bin/cvgen
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
require 'kramdown'
|
2
|
+
require 'prawn'
|
3
|
+
|
4
|
+
module CVGen
|
5
|
+
|
6
|
+
class Converter < Kramdown::Converter::Pdf
|
7
|
+
|
8
|
+
HEADER_SIZES = [nil, 24, 16, 16, 12, 12, 12]
|
9
|
+
HEADER_TOP_PADDING = [nil, 0, 10, 10, 0, 0, 0]
|
10
|
+
HEADER_BOTTOM_PADDING = [nil, 4, 4, 6, 0, 0, 0]
|
11
|
+
|
12
|
+
def initialize(root, options)
|
13
|
+
@current_padding = 0
|
14
|
+
super
|
15
|
+
end
|
16
|
+
|
17
|
+
def root_options(root, opts)
|
18
|
+
super.update(:font => "Helvetica", :leading => 1, :kerning => true, :header_font => @options[:'header-font'])
|
19
|
+
end
|
20
|
+
|
21
|
+
def header_options(el, opts)
|
22
|
+
h = super
|
23
|
+
h[:font] = opts[:header_font] if opts[:header_font]
|
24
|
+
h.update({
|
25
|
+
:size => HEADER_SIZES[el.options[:level]],
|
26
|
+
:styles => [],
|
27
|
+
:bottom_padding => HEADER_BOTTOM_PADDING[el.options[:level]],
|
28
|
+
:top_padding => HEADER_TOP_PADDING[el.options[:level]]})
|
29
|
+
end
|
30
|
+
|
31
|
+
def render_header(el, opts)
|
32
|
+
if el.options['date']
|
33
|
+
@pdf.float do
|
34
|
+
with_block_padding(el, opts, true) do
|
35
|
+
@pdf.formatted_text [opts.merge(:text =>el.options['date'])], :align => :right
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
super
|
40
|
+
if el.options[:level] == 2
|
41
|
+
@pdf.stroke_horizontal_rule
|
42
|
+
@pdf.move_down 12
|
43
|
+
@current_padding += 12
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def ul_options(el, opts)
|
48
|
+
{}
|
49
|
+
end
|
50
|
+
|
51
|
+
def render_ul(el, opts)
|
52
|
+
@pdf.indent(15) { super }
|
53
|
+
end
|
54
|
+
|
55
|
+
def dt_options(el, opts)
|
56
|
+
super.update(:styles => [:italic])
|
57
|
+
end
|
58
|
+
|
59
|
+
def p_options(el, opts)
|
60
|
+
{:bottom_padding => 0}
|
61
|
+
end
|
62
|
+
|
63
|
+
def document_options(root)
|
64
|
+
h = super.update(:margin => 72)
|
65
|
+
h[:info].update(@options[:'document-info']) if @options[:'document-info']
|
66
|
+
h
|
67
|
+
end
|
68
|
+
|
69
|
+
def with_block_padding(el, opts, floated = false)
|
70
|
+
|
71
|
+
if opts.has_key?(:top_padding)
|
72
|
+
top = opts[:top_padding]
|
73
|
+
if top > @current_padding
|
74
|
+
@pdf.move_down(top - @current_padding)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
@current_padding = 0 unless floated
|
78
|
+
yield
|
79
|
+
if opts.has_key?(:bottom_padding)
|
80
|
+
@pdf.move_down(opts[:bottom_padding])
|
81
|
+
@current_padding = opts[:bottom_padding] unless floated
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
|
86
|
+
end
|
87
|
+
end
|
data/lib/cvgen/exec.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'cvgen'
|
2
|
+
require 'yaml'
|
3
|
+
|
4
|
+
module CVGen
|
5
|
+
module Exec
|
6
|
+
|
7
|
+
def self.call
|
8
|
+
input = ARGF.read
|
9
|
+
|
10
|
+
if input.start_with? "---\n"
|
11
|
+
config, input = input.split /(?<=\.{3}\n)/, 2
|
12
|
+
end
|
13
|
+
config = YAML.load config
|
14
|
+
raise "Config must be a hash" unless config.is_a? Hash
|
15
|
+
|
16
|
+
out = CVGen.generate input, config
|
17
|
+
|
18
|
+
$stdout.write out
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
data/lib/cvgen/parser.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'kramdown'
|
2
|
+
|
3
|
+
module CVGen
|
4
|
+
|
5
|
+
class Parser < Kramdown::Parser::Kramdown
|
6
|
+
Kramdown::Parser::Kramdown.send :remove_const, :ATX_HEADER_MATCH
|
7
|
+
Kramdown::Parser::Kramdown::ATX_HEADER_MATCH = /^(\#{1,6})(.+?(?:\\#)?)\s*?#*#{HEADER_ID}\s*?\n(?:(?:(\S.*)\s*?\n)(?:(\S.*)[ \t]*\n)?)?/
|
8
|
+
|
9
|
+
# def parse_atx_header
|
10
|
+
# return false if !after_block_boundary?
|
11
|
+
|
12
|
+
# start_line_number = @src.current_line_number
|
13
|
+
# @src.check(ATX_HEADER_MATCH)
|
14
|
+
# level, text, id = @src[1], @src[2].to_s.strip, @src[3]
|
15
|
+
# return false if text.empty?
|
16
|
+
|
17
|
+
# @src.pos += @src.matched_size
|
18
|
+
# el = new_block_el(:header, nil, nil, :level => level.length, :raw_text => text, :location => start_line_number)
|
19
|
+
# add_text(text, el)
|
20
|
+
# el.attr['id'] = id if id
|
21
|
+
# @tree.children << el
|
22
|
+
# true
|
23
|
+
# end
|
24
|
+
|
25
|
+
def parse_atx_header
|
26
|
+
rval = super
|
27
|
+
|
28
|
+
if rval
|
29
|
+
@tree.children.last.options['date'] = @src[4]
|
30
|
+
if @src[5]
|
31
|
+
@tree.children.last.children << Element.new(:br, nil, nil, :location => @src.current_line_number)
|
32
|
+
add_text(@src[5], @tree.children.last)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
rval
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
data/lib/cvgen.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'cvgen/parser'
|
2
|
+
require 'cvgen/converter'
|
3
|
+
|
4
|
+
module CVGen
|
5
|
+
|
6
|
+
def self.generate source, opts={}
|
7
|
+
root, warnings = Parser.parse(source, opts)
|
8
|
+
$stderr.puts warnings if warnings
|
9
|
+
output, c_warnings = Converter.convert(root, opts)
|
10
|
+
$stderr.puts c_warnings if c_warnings
|
11
|
+
output
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
metadata
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cvgen
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Matt Wildig
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-11-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: kramdown
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.5'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.5'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: prawn
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.3'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: prawn-table
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.2'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.2'
|
55
|
+
description: Because everybody hates word processors
|
56
|
+
email: matt@mattwildig.co.uk
|
57
|
+
executables:
|
58
|
+
- cvgen
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- bin/cvgen
|
63
|
+
- lib/cvgen.rb
|
64
|
+
- lib/cvgen/converter.rb
|
65
|
+
- lib/cvgen/exec.rb
|
66
|
+
- lib/cvgen/parser.rb
|
67
|
+
homepage: https://github.com/mattwildig/cvgen
|
68
|
+
licenses: []
|
69
|
+
metadata: {}
|
70
|
+
post_install_message:
|
71
|
+
rdoc_options: []
|
72
|
+
require_paths:
|
73
|
+
- lib
|
74
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
requirements: []
|
85
|
+
rubyforge_project:
|
86
|
+
rubygems_version: 2.4.2
|
87
|
+
signing_key:
|
88
|
+
specification_version: 4
|
89
|
+
summary: Generate CVs in PDF format from Markdown-like source
|
90
|
+
test_files: []
|