caracal_the_curve 1.4.4 → 1.4.5
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 +4 -4
- data/lib/caracal/core/models/page_flip_model.rb +23 -0
- data/lib/caracal/core/page_flips.rb +9 -0
- data/lib/caracal/version.rb +1 -1
- data/spec/lib/caracal/core/tables_spec.rb +16 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 45e42709e5e6dd37c33347d099b56c90db0dfff8309539fe75da327279f34065
|
4
|
+
data.tar.gz: 9c6d77453283e2a10e66f9224606bf2f445307143cf20395fa815b5ab1da71a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 006140646a3c87366f118d25b3e62fc72386d849c57a9a5858253b4543b5a75e6978dda390d2ae547d1f3bfc4472c4e4fbf3f6364333ac96967bd628e1ff7c7a
|
7
|
+
data.tar.gz: cb58b0fecf147183b867ebae009e972a95583a76094a30716751833383d3c9e0388f300b8b97ecbffcb0c27afb35cf1f448718c6a9f5c0c91170bfb94a9fb5f4
|
@@ -13,6 +13,11 @@ module Caracal
|
|
13
13
|
# Configuration
|
14
14
|
#-------------------------------------------------------------
|
15
15
|
|
16
|
+
# accessors
|
17
|
+
attr_reader :page_width
|
18
|
+
attr_reader :page_margin_left
|
19
|
+
attr_reader :page_margin_right
|
20
|
+
|
16
21
|
# initialization
|
17
22
|
def initialize(options={}, &block)
|
18
23
|
super options, &block
|
@@ -21,6 +26,15 @@ module Caracal
|
|
21
26
|
#-------------------------------------------------------------
|
22
27
|
# Public Methods
|
23
28
|
#-------------------------------------------------------------
|
29
|
+
|
30
|
+
#========== SETTERS ===============================
|
31
|
+
|
32
|
+
# integers
|
33
|
+
[:width, :margin_left, :margin_right].each do |m|
|
34
|
+
define_method "#{ m }" do |value|
|
35
|
+
instance_variable_set("@page_#{ m }", value.to_i)
|
36
|
+
end
|
37
|
+
end
|
24
38
|
|
25
39
|
#=============== DATA ACCESSORS =======================
|
26
40
|
|
@@ -35,6 +49,15 @@ module Caracal
|
|
35
49
|
def valid?
|
36
50
|
contents.size > 0
|
37
51
|
end
|
52
|
+
|
53
|
+
#--------------------------------------------------
|
54
|
+
# Private Instance Methods
|
55
|
+
#--------------------------------------------------
|
56
|
+
private
|
57
|
+
|
58
|
+
def option_keys
|
59
|
+
[:width, :margin_left, :margin_right]
|
60
|
+
end
|
38
61
|
end
|
39
62
|
end
|
40
63
|
end
|
@@ -19,6 +19,15 @@ module Caracal
|
|
19
19
|
def page_flip(*args, &block)
|
20
20
|
options = Caracal::Utilities.extract_options!(args)
|
21
21
|
|
22
|
+
# Pass through the page dimensions from the parent document,
|
23
|
+
# using the page height as the page width, due to it using
|
24
|
+
# the inverse dimensions.
|
25
|
+
options.merge!({
|
26
|
+
width: page_height,
|
27
|
+
margin_left: page_margin_left,
|
28
|
+
margin_right: page_margin_right
|
29
|
+
})
|
30
|
+
|
22
31
|
model = Caracal::Core::Models::PageFlipModel.new(options, &block)
|
23
32
|
|
24
33
|
if model.valid?
|
data/lib/caracal/version.rb
CHANGED
@@ -18,8 +18,21 @@ describe Caracal::Core::Tables do
|
|
18
18
|
|
19
19
|
it { expect(subject.contents.size).to eq size + 1 }
|
20
20
|
it { expect(subject.contents.last).to be_a(Caracal::Core::Models::TableModel) }
|
21
|
+
it { expect(subject.contents.last.table_width).to be(9360) }
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '.table within a page-flip' do
|
25
|
+
let!(:size) { subject.contents.size }
|
26
|
+
|
27
|
+
before do
|
28
|
+
subject.page_flip do |x|
|
29
|
+
x.table [['Sample Text']]
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
it { expect(subject.contents.size).to eq size + 1 }
|
34
|
+
it { expect(subject.contents.last.contents.first).to be_a(Caracal::Core::Models::TableModel) }
|
35
|
+
it { expect(subject.contents.last.contents.first.table_width).to be(12960) }
|
21
36
|
end
|
22
|
-
|
23
37
|
end
|
24
|
-
|
25
|
-
end
|
38
|
+
end
|