sablon 0.0.22 → 0.1.0

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.
@@ -104,6 +104,27 @@ class NodePropertiesTest < Sablon::TestCase
104
104
  assert_equal props.to_docx, '<w:pPr><w:pStyle w:val="Paragraph" /></w:pPr>'
105
105
  end
106
106
 
107
+ def test_node_properties_table_factory
108
+ props = { 'tblStyle' => 'Classic' }
109
+ props = Sablon::HTMLConverter::NodeProperties.table(props)
110
+ assert_equal 'tblStyle=Classic', props.inspect
111
+ assert_equal props.to_docx, '<w:tblPr><w:tblStyle w:val="Classic" /></w:tblPr>'
112
+ end
113
+
114
+ def test_node_properties_table_row_factory
115
+ props = { 'jc' => 'left' }
116
+ props = Sablon::HTMLConverter::NodeProperties.table_row(props)
117
+ assert_equal 'jc=left', props.inspect
118
+ assert_equal props.to_docx, '<w:trPr><w:jc w:val="left" /></w:trPr>'
119
+ end
120
+
121
+ def test_node_properties_table_cell_factory
122
+ props = { 'tcFitText' => 'true' }
123
+ props = Sablon::HTMLConverter::NodeProperties.table_cell(props)
124
+ assert_equal 'tcFitText=true', props.inspect
125
+ assert_equal props.to_docx, '<w:tcPr><w:tcFitText w:val="true" /></w:tcPr>'
126
+ end
127
+
107
128
  def test_node_properties_run_factory
108
129
  props = { 'color' => 'FF00FF' }
109
130
  props = Sablon::HTMLConverter::NodeProperties.run(props)
data/test/html_test.rb CHANGED
@@ -14,12 +14,21 @@ class SablonHTMLTest < Sablon::TestCase
14
14
  end
15
15
 
16
16
  def test_generate_document_from_template_with_styles_and_html
17
+ uid_generator = UIDTestGenerator.new
17
18
  template_path = @base_path + "fixtures/insertion_template.docx"
18
19
  output_path = @base_path + "sandbox/html.docx"
19
20
  template = Sablon.template template_path
20
- context = { 'html:content' => content }
21
- template.render_to_file output_path, context
22
-
21
+ context = {
22
+ 'html:content' => content,
23
+ inline_content: {
24
+ 'html:should' => '<b><span style="color: #123456">should</span></b>',
25
+ 'html:github' => '<a href="http://www.github.com" style="color: #0000FF">GitHub</a>'
26
+ }
27
+ }
28
+ SecureRandom.stub(:uuid, uid_generator.method(:new_uid)) do
29
+ template.render_to_file output_path, context
30
+ end
31
+ #
23
32
  assert_docx_equal @sample_path, output_path
24
33
  end
25
34
 
data/test/test_helper.rb CHANGED
@@ -14,4 +14,20 @@ class Sablon::TestCase < MiniTest::Test
14
14
  def teardown
15
15
  super
16
16
  end
17
+
18
+ class UIDTestGenerator
19
+ def initialize
20
+ @current_id = 1234
21
+ @current_id_start = @current_id
22
+ end
23
+
24
+ def new_uid
25
+ @current_id += 1
26
+ @current_id.to_s
27
+ end
28
+
29
+ def reset
30
+ @current_id = @current_id_start
31
+ end
32
+ end
17
33
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sablon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.22
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yves Senn
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-12-12 00:00:00.000000000 Z
11
+ date: 2018-01-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -121,6 +121,7 @@ files:
121
121
  - lib/sablon/html/ast.rb
122
122
  - lib/sablon/html/ast_builder.rb
123
123
  - lib/sablon/html/converter.rb
124
+ - lib/sablon/html/node_properties.rb
124
125
  - lib/sablon/html/visitor.rb
125
126
  - lib/sablon/numbering.rb
126
127
  - lib/sablon/operations.rb
@@ -128,6 +129,7 @@ files:
128
129
  - lib/sablon/processor/document.rb
129
130
  - lib/sablon/processor/numbering.rb
130
131
  - lib/sablon/processor/section_properties.rb
132
+ - lib/sablon/relationship.rb
131
133
  - lib/sablon/template.rb
132
134
  - lib/sablon/test.rb
133
135
  - lib/sablon/test/assertions.rb
@@ -187,6 +189,7 @@ files:
187
189
  - test/fixtures/xml/test_ignore_complex_field_spanning_multiple_paragraphs.xml
188
190
  - test/html/ast_builder_test.rb
189
191
  - test/html/ast_test.rb
192
+ - test/html/converter_style_test.rb
190
193
  - test/html/converter_test.rb
191
194
  - test/html/node_properties_test.rb
192
195
  - test/html_test.rb
@@ -219,7 +222,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
219
222
  version: '0'
220
223
  requirements: []
221
224
  rubyforge_project:
222
- rubygems_version: 2.6.11
225
+ rubygems_version: 2.5.1
223
226
  signing_key:
224
227
  specification_version: 4
225
228
  summary: docx template processor
@@ -263,6 +266,7 @@ test_files:
263
266
  - test/fixtures/xml/test_ignore_complex_field_spanning_multiple_paragraphs.xml
264
267
  - test/html/ast_builder_test.rb
265
268
  - test/html/ast_test.rb
269
+ - test/html/converter_style_test.rb
266
270
  - test/html/converter_test.rb
267
271
  - test/html/node_properties_test.rb
268
272
  - test/html_test.rb