json_resume 1.0.0 → 1.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 +4 -4
- data/bin/json_resume +25 -10
- data/lib/json_resume/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: d947985b77239ae5e683bda7bf79ceb94d0939a6
|
4
|
+
data.tar.gz: 0ba72d5177a5b0865053614131bb4b71ee91d3b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65c7a82bffcb5a6b669e32972bd0c5fb4a9bced35e6b202e133c25184ae8a4ef7bbc74c7655113b120ee9efe4bf39ef103403bb78417cef614e9487b5254b95e
|
7
|
+
data.tar.gz: b322404fa58413748947ab42813181b4a1f35140316f55a0be360e2d9925f6245604e81e40aedc2a3ad13124cfb7fe123a03b2bd538452ef2f98375cc9f33658
|
data/bin/json_resume
CHANGED
@@ -9,6 +9,12 @@ require 'pdfkit'
|
|
9
9
|
require 'rest-client'
|
10
10
|
|
11
11
|
WL_URL = "https://www.writelatex.com/docs"
|
12
|
+
|
13
|
+
class String
|
14
|
+
def red; "\033[31m#{self}\033[0m" end
|
15
|
+
def green; "\033[32m#{self}\033[0m" end
|
16
|
+
end
|
17
|
+
|
12
18
|
class JsonResumeCLI < Thor
|
13
19
|
|
14
20
|
desc "convert /path/to/json/file", "converts the json to pretty resume format"
|
@@ -19,7 +25,11 @@ class JsonResumeCLI < Thor
|
|
19
25
|
def convert(json_input)
|
20
26
|
set_i18n(options[:locale])
|
21
27
|
puts "Generating the #{options[:out]} type..."
|
22
|
-
|
28
|
+
begin
|
29
|
+
puts send('convert_to_'+options[:out], json_input, get_template(options))
|
30
|
+
rescue Encoding::InvalidByteSequenceError
|
31
|
+
puts "ERROR: You need to 'export LC_CTYPE=en_US.UTF-8' ...".green
|
32
|
+
end
|
23
33
|
end
|
24
34
|
|
25
35
|
desc "sample", "Generates a sample json file in cwd"
|
@@ -28,7 +38,7 @@ class JsonResumeCLI < Thor
|
|
28
38
|
json_file_paths = Dir["#{@@orig_locn}/../examples/*.json"]
|
29
39
|
json_file_names = json_file_paths.map{|x| File.basename(x)}
|
30
40
|
FileUtils.cp json_file_paths, Dir.pwd
|
31
|
-
msg = "Generated #{json_file_names.join(" ")} in #{cwd}/"
|
41
|
+
msg = "Generated #{json_file_names.join(" ")} in #{cwd}/".green
|
32
42
|
msg += "\nYou can now modify it and call: json_resume convert <file.json>"
|
33
43
|
puts msg
|
34
44
|
end
|
@@ -42,7 +52,7 @@ class JsonResumeCLI < Thor
|
|
42
52
|
theme = options[:theme]
|
43
53
|
template_path = "#{@@orig_locn}/../templates/#{theme}_#{out_type}.mustache"
|
44
54
|
if !(File.exists? template_path) and theme != 'default'
|
45
|
-
puts "Theme #{theme} doesn't exist for #{options[:out]} type yet! Using default..."
|
55
|
+
puts "Theme #{theme} doesn't exist for #{options[:out]} type yet! Using default...".red
|
46
56
|
template_path = "#{@@orig_locn}/../templates/default_#{out_type}.mustache"
|
47
57
|
end
|
48
58
|
return template_path
|
@@ -81,9 +91,14 @@ class JsonResumeCLI < Thor
|
|
81
91
|
}
|
82
92
|
kit = PDFKit.new(html_file, pdf_options)
|
83
93
|
|
84
|
-
|
94
|
+
begin
|
95
|
+
kit.to_file(dest+"/resume.pdf")
|
96
|
+
rescue Errno::ENOENT => e
|
97
|
+
puts "\nTry: sudo apt-get update; sudo apt-get install libxtst6 libfontconfig1".green
|
98
|
+
raise e
|
99
|
+
end
|
85
100
|
FileUtils.rm_rf "#{dest}/#{tmp_dir}"
|
86
|
-
msg = "\nGenerated resume.pdf at #{dest}."
|
101
|
+
msg = "\nGenerated resume.pdf at #{dest}.".green
|
87
102
|
end
|
88
103
|
|
89
104
|
def convert_to_tex(json_input, template, dest=Dir.pwd, filename="resume.tex")
|
@@ -94,13 +109,13 @@ class JsonResumeCLI < Thor
|
|
94
109
|
file1 = "resume"; filename = "#{file1}.tex"
|
95
110
|
convert_to_tex(json_input, template, dest, filename)
|
96
111
|
if `which pdflatex` == ""
|
97
|
-
puts "It looks like pdflatex is not installed..."
|
112
|
+
puts "It looks like pdflatex is not installed...".red
|
98
113
|
puts "Either install it with instructions at..."
|
99
114
|
puts "http://dods.ipsl.jussieu.fr/fast/pdflatex_install.html"
|
100
115
|
return use_write_latex(dest, filename)
|
101
116
|
end
|
102
117
|
if `kpsewhich moderncv.cls` == ""
|
103
|
-
puts "It looks liks moderncv package for tex is not installed"
|
118
|
+
puts "It looks liks moderncv package for tex is not installed".red
|
104
119
|
puts "Read about it here: http://ctan.org/pkg/moderncv"
|
105
120
|
return use_write_latex(dest, filename)
|
106
121
|
end
|
@@ -116,14 +131,14 @@ class JsonResumeCLI < Thor
|
|
116
131
|
if reply == "" || reply == "y"
|
117
132
|
return convert_using_writeLatex(dest, filename)
|
118
133
|
end
|
119
|
-
msg = "Latex file created at #{dest}/#{filename}"
|
134
|
+
msg = "Latex file created at #{dest}/#{filename}".green
|
120
135
|
end
|
121
136
|
|
122
137
|
def convert_using_writeLatex(dest, filename)
|
123
138
|
tex_file = File.read("#{dest}/#{filename}")
|
124
139
|
RestClient.post(WL_URL, :snip => tex_file, :splash => "none") do |response, req, res, &bb|
|
125
140
|
FileUtils.rm "#{dest}/#{filename}"
|
126
|
-
msg = "\nPDF is ready at #{response.headers[:location]}"
|
141
|
+
msg = "\nPDF is ready at #{response.headers[:location]}".green
|
127
142
|
end
|
128
143
|
end
|
129
144
|
|
@@ -145,7 +160,7 @@ class JsonResumeCLI < Thor
|
|
145
160
|
resume_obj = JsonResume.new(json_input, "output_type" => output_type)
|
146
161
|
mustache_obj = Mustache.render(i18n(File.read(template)), resume_obj.reader.hash)
|
147
162
|
File.open(dest,'w') {|f| f.write(mustache_obj) }
|
148
|
-
return "\nGenerated files present at #{dest}"
|
163
|
+
return "\nGenerated files present at #{dest}".green
|
149
164
|
end
|
150
165
|
|
151
166
|
end
|
data/lib/json_resume/version.rb
CHANGED