caracal 1.3.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 52dc6e582d7e47010ca9fc90d1e02f20944d55faa485548c881bec1091c45e96
4
- data.tar.gz: b6f22eebb075a7852b0ea30ea595ca6ca89f7b98e40564ff3ab2b68c9f004039
3
+ metadata.gz: f7539fa972b10d2c7af3de21bb8f9787eecb0e0c3867326afd4cdedd2ec3dd5a
4
+ data.tar.gz: 8356897d9cb7e54c9816497f0297cc635afb2267f42cba57fac009b3819791f0
5
5
  SHA512:
6
- metadata.gz: 9651b63df3aa217d25c8ed1f9c3676a57071f3c4e7532053c76f0d07ead18e399c0dcc79c40427959bd275966c60e8be5b72ac0620f0bfd8853aff0ff1a1ddc4
7
- data.tar.gz: 9b9bd2396372f9fe4334eccbeddee4bff14aa7f3b14acc595fe6dbdeba858f37017c3b64d38b28b9efd60f26b11351590122bff05d73f7fb3cffefa36c9dee3a
6
+ metadata.gz: b8542dfdc09c07f78f7bf63714d681b1f8a0d93c6718f14f3d1e53ef6b055e6549df94b95fddb93390f89e6d300063566b9d71d7584b104c453caa4dadf0e023
7
+ data.tar.gz: '009ca4e19a83ec60c60bc3dc9e009da724a0768f50ebfba2b2e4045bf98e658689386495e3f59fd639eb2da1bb1fcfd059ada4f517353707647799c3d9c12be6'
@@ -1,9 +1,18 @@
1
+ #### v1.4.0
2
+
3
+ * Enhancements
4
+ * Changed `file_name` method to accept absolute and relative paths. (@jdugan)
5
+ * Added instance save method so documents can be created via commands instead of blocks, if desired. (@jdugan)
6
+ * Removed extra paragraph tag inserted after tables; added logic to ensure final tag of table cells is always a paragraph. (@jdugan)
7
+
8
+
1
9
  #### v1.3.0
2
10
 
3
11
  * Enhancements
4
12
  * Added proper text highlighting. Colors are limited so we left :bgcolor option. (@rmarone)
5
13
  * Added bookmarks and internal links. (@rmarone)
6
14
 
15
+
7
16
  #### v1.2.0
8
17
 
9
18
  * Enhancements
@@ -1,39 +1,43 @@
1
1
  module Caracal
2
2
  module Core
3
-
4
- # This module encapsulates all the functionality related to setting the
3
+
4
+ # This module encapsulates all the functionality related to setting the
5
5
  # document's name.
6
6
  #
7
7
  module FileName
8
8
  def self.included(base)
9
9
  base.class_eval do
10
-
10
+
11
11
  #-------------------------------------------------------------
12
12
  # Configuration
13
13
  #-------------------------------------------------------------
14
-
14
+
15
15
  # constants
16
16
  const_set(:DEFAULT_FILE_NAME, 'caracal.docx')
17
-
17
+
18
18
  # accessors
19
19
  attr_reader :name
20
-
21
-
20
+ attr_reader :path
21
+
22
+
22
23
  #-------------------------------------------------------------
23
24
  # Public Methods
24
25
  #-------------------------------------------------------------
25
-
26
+
26
27
  # This method sets the name of the output file. Defaults
27
28
  # to the name of the library.
28
29
  #
29
30
  def file_name(value=nil)
30
31
  v = value.to_s.strip
31
- @name = (v == '') ? self.class::DEFAULT_FILE_NAME : v
32
+ a = v.split('/')
33
+
34
+ @name = (v == '') ? self.class::DEFAULT_FILE_NAME : a.last
35
+ @path = (a.size > 1) ? v : "./#{ v }"
32
36
  end
33
-
37
+
34
38
  end
35
39
  end
36
40
  end
37
-
41
+
38
42
  end
39
- end
43
+ end
@@ -1,5 +1,6 @@
1
1
  require 'caracal/core/models/base_model'
2
2
  require 'caracal/core/models/margin_model'
3
+ require 'caracal/core/models/paragraph_model'
3
4
 
4
5
 
5
6
  module Caracal
@@ -39,6 +40,11 @@ module Caracal
39
40
  end
40
41
 
41
42
  super options, &block
43
+
44
+ p_klass = Caracal::Core::Models::ParagraphModel # the final tag in a table cell
45
+ unless contents.last.is_a? p_klass # *must* be a paragraph for OOXML
46
+ contents << p_klass.new(content: '') # to not throw an error.
47
+ end
42
48
  end
43
49
 
44
50
 
@@ -37,9 +37,9 @@ require 'caracal/renderers/styles_renderer'
37
37
  module Caracal
38
38
  class Document
39
39
 
40
- #-------------------------------------------------------------
40
+ #------------------------------------------------------
41
41
  # Configuration
42
- #-------------------------------------------------------------
42
+ #------------------------------------------------------
43
43
 
44
44
  # mixins (order is important)
45
45
  include Caracal::Core::CustomProperties
@@ -64,11 +64,11 @@ module Caracal
64
64
  include Caracal::Core::Text
65
65
 
66
66
 
67
- #-------------------------------------------------------------
67
+ #------------------------------------------------------
68
68
  # Public Class Methods
69
- #-------------------------------------------------------------
69
+ #------------------------------------------------------
70
70
 
71
- #============ OUTPUT ====================================
71
+ #============ OUTPUT ==================================
72
72
 
73
73
  # This method renders a new Word document and returns it as a
74
74
  # a string.
@@ -86,16 +86,17 @@ module Caracal
86
86
  #
87
87
  def self.save(f_name = nil, &block)
88
88
  docx = new(f_name, &block)
89
- buffer = docx.render
90
-
91
- File.open("./#{ docx.name }", 'wb') { |f| f.write(buffer.string) }
89
+ docx.save
90
+ # buffer = docx.render
91
+ #
92
+ # File.open(docx.path, 'wb') { |f| f.write(buffer.string) }
92
93
  end
93
94
 
94
95
 
95
96
 
96
- #-------------------------------------------------------------
97
+ #------------------------------------------------------
97
98
  # Public Instance Methods
98
- #-------------------------------------------------------------
99
+ #------------------------------------------------------
99
100
 
100
101
  # This method instantiates a new word document.
101
102
  #
@@ -119,7 +120,7 @@ module Caracal
119
120
  end
120
121
 
121
122
 
122
- #============ GETTERS ===================================
123
+ #============ GETTERS =================================
123
124
 
124
125
  # This method returns an array of models which constitute the
125
126
  # set of instructions for producing the document content.
@@ -129,7 +130,7 @@ module Caracal
129
130
  end
130
131
 
131
132
 
132
- #============ RENDERING =================================
133
+ #============ RENDERING ===============================
133
134
 
134
135
  # This method renders the word document instance into
135
136
  # a string buffer. Order is important!
@@ -153,13 +154,21 @@ module Caracal
153
154
  end
154
155
 
155
156
 
157
+ #============ SAVING ==================================
158
+
159
+ def save
160
+ buffer = render
161
+
162
+ File.open(path, 'wb') { |f| f.write(buffer.string) }
163
+ end
164
+
156
165
 
157
- #-------------------------------------------------------------
166
+ #------------------------------------------------------
158
167
  # Private Instance Methods
159
- #-------------------------------------------------------------
168
+ #------------------------------------------------------
160
169
  private
161
170
 
162
- #============ RENDERERS =====================================
171
+ #============ RENDERERS ===============================
163
172
 
164
173
  def render_app(zip)
165
174
  content = ::Caracal::Renderers::AppRenderer.render(self)
@@ -403,7 +403,7 @@ module Caracal
403
403
 
404
404
  # don't know why this is needed, but it prevents a
405
405
  # rendering error.
406
- render_paragraph(xml, Caracal::Core::Models::ParagraphModel.new)
406
+ # render_paragraph(xml, Caracal::Core::Models::ParagraphModel.new)
407
407
  end
408
408
 
409
409
 
@@ -1,3 +1,3 @@
1
1
  module Caracal
2
- VERSION = '1.3.0'
2
+ VERSION = '1.4.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: caracal
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Trade Infomatics
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-08-28 00:00:00.000000000 Z
12
+ date: 2018-08-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri