rodolfo 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/rodolfo +14 -8
- data/lib/rodolfo.rb +13 -24
- 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: 721c332031a996a570c5084587a12caa636cec6b
|
4
|
+
data.tar.gz: 5f1857ff5e61f6cdc3af3493706b8834de5a7faa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf72f7910018f6a6b41b369bbe8c59fbf0cfc14745dac772407558b86762f577a21dc8e6a62a92b7e44254beb2fab79897d2e48ef2e1273d06f805505d2cd870
|
7
|
+
data.tar.gz: c1cd4c02b2d7eddfb204fe59de0c4015d6c4e4f4ba687c4708e432b5499e43699d919f7af0d31201b8986d18dc467411c192078c879debdc3e8f5ec2fae32565
|
data/bin/rodolfo
CHANGED
@@ -9,22 +9,28 @@ require File.join(root_path, 'lib', 'rodolfo.rb')
|
|
9
9
|
opts = Slop.parse do |o|
|
10
10
|
o.string '-t', '--template', 'template name'
|
11
11
|
o.string '-o', '--output', 'output pdf (optional, you can use stdout instead)'
|
12
|
+
o.on '--schema', 'print the json schema'
|
12
13
|
o.on '--version', 'print the version' do
|
13
|
-
|
14
|
-
exit
|
14
|
+
STDOUT.write Rodolfo::VERSION
|
15
|
+
exit 0
|
15
16
|
end
|
16
17
|
end
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
unless json_data && opts[:template]
|
21
|
-
puts 'Missing json data throught stdin' unless json_data
|
19
|
+
unless opts[:template]
|
22
20
|
puts opts
|
23
|
-
exit
|
21
|
+
exit 1
|
22
|
+
end
|
23
|
+
|
24
|
+
package = Rodolfo::Package.new(opts[:template])
|
25
|
+
|
26
|
+
if opts[:schema]
|
27
|
+
STDOUT.write package.schema
|
28
|
+
exit 0
|
24
29
|
end
|
25
30
|
|
31
|
+
json_data = $stdin.tty? ? nil : $stdin.read
|
26
32
|
data = JSON.parse(json_data, symbolize_names: true)
|
27
|
-
bytes =
|
33
|
+
bytes = package.make data
|
28
34
|
|
29
35
|
if opts[:output]
|
30
36
|
open(opts[:output], 'wb') { |f| f.puts bytes }
|
data/lib/rodolfo.rb
CHANGED
@@ -1,38 +1,27 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
def schema
|
8
|
-
@package.schema
|
9
|
-
end
|
10
|
-
|
11
|
-
def make(data)
|
12
|
-
require 'prawn'
|
13
|
-
require 'prawn/measurements'
|
14
|
-
require 'prawn/measurement_extensions'
|
15
|
-
require 'prawn/table'
|
1
|
+
require 'pathname'
|
2
|
+
require 'prawn'
|
3
|
+
require 'prawn/measurements'
|
4
|
+
require 'prawn/measurement_extensions'
|
5
|
+
require 'prawn/table'
|
16
6
|
|
17
|
-
|
18
|
-
|
19
|
-
end
|
20
|
-
end
|
7
|
+
module Rodolfo
|
8
|
+
VERSION = '0.0.3'.freeze
|
21
9
|
|
22
|
-
class
|
10
|
+
class Package
|
23
11
|
def initialize(path)
|
24
|
-
@path = path
|
12
|
+
@path = Pathname.new(path).absolute? ? path : File.join(Dir.pwd, path)
|
25
13
|
@json_file_path = File.join @path, 'schema.json'
|
26
|
-
@template_file_path = File.join @path, 'template
|
14
|
+
@template_file_path = File.join @path, 'template'
|
27
15
|
end
|
28
16
|
|
29
17
|
def schema
|
30
18
|
@json_schema ||= File.read @json_file_path
|
31
19
|
end
|
32
20
|
|
33
|
-
def
|
21
|
+
def make(data)
|
34
22
|
require @template_file_path
|
35
|
-
Rodolfo.
|
23
|
+
p = Rodolfo::Template.new data
|
24
|
+
Prawn::Document.new(&p).render
|
36
25
|
end
|
37
26
|
end
|
38
27
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rodolfo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Initios
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-10-
|
11
|
+
date: 2016-10-15 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Create pdfs with Prawn
|
14
14
|
email: dev@initios.com
|