rodolfo 1.0.0 → 1.0.1.pre.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/bin/rodolfo +7 -2
  3. data/lib/meta.rb +1 -1
  4. data/lib/rodolfo.rb +8 -11
  5. metadata +4 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9807ffde2d7aaa7b10b0ba04956038283f717310
4
- data.tar.gz: 1de971165b46313cb8ff017a501a4e0cc97745a8
3
+ metadata.gz: 68773cd4b01068d325a4be05c192b943fdbf6c5a
4
+ data.tar.gz: 7927974f44f4e4cd7065efa3e3984f9163310a7d
5
5
  SHA512:
6
- metadata.gz: 82ae84c0b2c89e6e2bff19e41c2aa7631e3c72e8b80c72626d48fe5dca63ba31daad31d84fd0ecf506b4e9508634678ce6c5c6fcbc88435c8b3278197a871a0b
7
- data.tar.gz: febda8ebf97c78c78ad69203de37f05780485c9eb4e3e014282327544cac06d6be332b2b0ee8d5708493ccaec1dab62d1b11006f2bf0ada403a95217096f7e45
6
+ metadata.gz: 1054b5eebdb65342242d126f24e73493bb0818b407e2aa98cdb465a2fba07d9b288263cb4e5d0d978152ac89472d5ced1501454b45eb01e293a252a68cfe92e5
7
+ data.tar.gz: acd180749aba6c8d747d422aa690c9fbbbffbe6ecb6fb17c30bb875cdbdc7c16b3f5175cc54cced180be982a65c3199f094d15fde97adb87fcb6fcba9a97632c
data/bin/rodolfo CHANGED
@@ -35,5 +35,10 @@ unless opts.skip_validation? || package.valid?
35
35
  exit 2
36
36
  end
37
37
 
38
- STDOUT.write package.make
39
- exit 0
38
+ begin
39
+ STDOUT.write package.make
40
+ exit 0
41
+ rescue NoMethodError
42
+ STDOUT.write 'Missing or incorrect data, template can\'t be rendered'
43
+ exit 2
44
+ end
data/lib/meta.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  ##
2
2
  # Create PDFs from the CLI using Prawn
3
3
  module Rodolfo
4
- VERSION = '1.0.0'.freeze
4
+ VERSION = '1.0.1-pre'.freeze
5
5
  end
data/lib/rodolfo.rb CHANGED
@@ -17,30 +17,27 @@ module Rodolfo
17
17
  #
18
18
  # It handles methods for manipulate those files and the pdf generation
19
19
  class Package
20
+ attr_reader :data, :validation_errors
21
+
20
22
  def initialize(path, data)
21
23
  @path = Pathname.new(path).absolute? ? path : File.join(Dir.pwd, path)
24
+ opts = { errors_as_objects: true, insert_defaults: true }
25
+ @validation_errors = JSON::Validator.fully_validate(schema, data, opts)
22
26
  @data = data
23
- @json_file_path = File.join @path, 'schema.json'
24
- @template_file_path = File.join @path, 'template'
25
27
  end
26
28
 
27
29
  def schema
28
- @json_schema ||= File.read @json_file_path
30
+ json_file_path = File.join @path, 'schema.json'
31
+ File.read json_file_path
29
32
  end
30
33
 
31
34
  def valid?
32
- args = schema, @data, { errors_as_objects: true }
33
- @validation_errors = JSON::Validator.fully_validate(*args)
34
35
  @validation_errors.empty?
35
36
  end
36
37
 
37
- def validation_errors
38
- valid? unless @validation_errors
39
- @validation_errors
40
- end
41
-
42
38
  def make
43
- require @template_file_path
39
+ template_file_path = File.join @path, 'template'
40
+ require template_file_path
44
41
  Rodolfo::Template.new(@data).render
45
42
  end
46
43
  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: 1.0.0
4
+ version: 1.0.1.pre.pre
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-31 00:00:00.000000000 Z
11
+ date: 2016-11-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json-schema
@@ -263,9 +263,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
263
263
  version: '2.0'
264
264
  required_rubygems_version: !ruby/object:Gem::Requirement
265
265
  requirements:
266
- - - ">="
266
+ - - ">"
267
267
  - !ruby/object:Gem::Version
268
- version: '0'
268
+ version: 1.3.1
269
269
  requirements: []
270
270
  rubyforge_project:
271
271
  rubygems_version: 2.5.1