docx-builder 0.2.1 → 0.2.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4a834e7eb99b4459de40d6942008c8487626ff25ccf75d19a2c4d5af4978402b
4
- data.tar.gz: 1fa0be4e4a3c0d9c7e15804d90b1dbcedc9ca3b42f059593daeef50f08ca5b47
3
+ metadata.gz: 1a12d4646ce0b78cc0977eb4c1fa6a6d4082911dc1546c567b299a58f9b84e56
4
+ data.tar.gz: 13197d06bd647197e7fb0857ce7f10c3d4f9c119c3e0a28503d2ad20c73a44fa
5
5
  SHA512:
6
- metadata.gz: b80c298d29268dc7b5aae2ddc90533be3668fc8fa34c2f0da64451c47a58a44e9eee63b269092cb4af1e86b7ecdcba0ee63d23498f7c24935fcfc524019c5abd
7
- data.tar.gz: 8f85311bcfd8a02207a2f673d0b81be605b49ede108508b9a3da514ce3a725c0085f9dbbbefdcf567a8abb46ee614e974e5d5ac0eda7f4456315684c0c60edd9
6
+ metadata.gz: 36580ca2af1ab880193203d304f8030125a53e6139e66c750d33f6f7846e33ccd0efe581d37eed5948708f8a933beef76d527922d3eadc018501028ca9521c51
7
+ data.tar.gz: cd3a2fd33771dcfc717f0e2ecf5340125ec80e9be792ed073425c2126c5684c2a66fc7ecbf269b795c5593fa08bab8f256af608861de0d62624b57ca60836bbf
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- docx-builder (0.2.1)
4
+ docx-builder (0.2.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -0,0 +1,11 @@
1
+ module Docx
2
+ module Builder
3
+ class Configuration
4
+ attr_accessor :null_placeholder
5
+
6
+ def initialize
7
+ @null_placeholder = ''
8
+ end
9
+ end
10
+ end
11
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Docx
4
4
  module Builder
5
- VERSION = "0.2.1"
5
+ VERSION = "0.2.2"
6
6
  end
7
7
  end
@@ -5,6 +5,7 @@ module Docx
5
5
  document.gsub(/\{\{.*?\}\}/m) do |match|
6
6
  ret = match.include?('>') ? join_variable_tags(match) : match
7
7
  ret = clean_spaces_inside_variables(ret)
8
+ ret = insert_null_placeholder(ret)
8
9
  ret
9
10
  end
10
11
  end
@@ -25,6 +26,13 @@ module Docx
25
26
  puts "Returning cleaned variable: #{ret}"
26
27
  ret
27
28
  end
29
+
30
+ def self.insert_null_placeholder(expression)
31
+ placeholder = Docx::Builder.configuration.null_placeholder
32
+ expression.gsub(/\{\{%\s(.+)\s%\}\}/) do |m|
33
+ "{{% (#{$1} || '#{placeholder}') %}}"
34
+ end
35
+ end
28
36
  end
29
37
 
30
38
  # {{% devedor[:pessoa_fisica][:cedula_identidade] %}},
data/lib/docx/builder.rb CHANGED
@@ -9,4 +9,19 @@ require_relative "builder/decoder"
9
9
  require_relative "builder/encoder"
10
10
  require_relative 'builder/cleaners'
11
11
  require_relative "builder/xml_processor"
12
- require_relative "builder/template"
12
+ require_relative "builder/template"
13
+ require_relative "builder/configuration"
14
+
15
+ module Docx
16
+ module Builder
17
+ class << self
18
+ def configuration
19
+ @configuration ||= Configuration.new
20
+ end
21
+
22
+ def configure
23
+ yield(configuration)
24
+ end
25
+ end
26
+ end
27
+ end
data/publish.sh CHANGED
@@ -1,4 +1 @@
1
- gem bump
2
- gem build
3
- gem push $(ls docx-builder-*.gem)
4
- rm docx-builder-*.gem
1
+ bundle exec rake release
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: docx-builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tecnologia Cashme
@@ -32,6 +32,7 @@ files:
32
32
  - docx-builder.gemspec
33
33
  - lib/docx/builder.rb
34
34
  - lib/docx/builder/cleaners.rb
35
+ - lib/docx/builder/configuration.rb
35
36
  - lib/docx/builder/decoder.rb
36
37
  - lib/docx/builder/encoder.rb
37
38
  - lib/docx/builder/template.rb