thinreports 0.10.0 → 0.10.1
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/.rubocop.yml +1 -1
- data/CHANGELOG.md +6 -0
- data/lib/thinreports/core/shape.rb +2 -2
- data/lib/thinreports/core/shape/list/page.rb +1 -1
- data/lib/thinreports/core/shape/text_block/formatter/number.rb +13 -2
- data/lib/thinreports/core/utils.rb +6 -3
- data/lib/thinreports/report/internal.rb +1 -1
- data/lib/thinreports/report/page.rb +1 -1
- data/lib/thinreports/version.rb +1 -1
- data/test/unit/core/shape/list/test_page.rb +76 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 687d41cb0fe000892fa4cb8751fdc8fa70e20f0e
|
4
|
+
data.tar.gz: 0a40e144fe135538bb37e793117f7a56348a934b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0d6da77661a179f657503f76f3e4c12b6664a73cac7f403aaf4506efb201ad336a18dd44612e4e456fdfb063e3c837692c02e877a3117897fb54b1dd4eefb3fe
|
7
|
+
data.tar.gz: 57443d5529f32831839676b6f9a8bb7a487153d0282e8c5fbee762ac52443f997071437b99d8543e81eeb8fbf785b5fb07b17825ff774f83b3e1508fe4239e37
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -3,11 +3,11 @@
|
|
3
3
|
module Thinreports
|
4
4
|
module Core
|
5
5
|
module Shape
|
6
|
-
def Interface(parent, format) # rubocop:disable
|
6
|
+
def Interface(parent, format) # rubocop:disable Naming/MethodName
|
7
7
|
find_by_type(format.type)::Interface.new(parent, format)
|
8
8
|
end
|
9
9
|
|
10
|
-
def Format(type) # rubocop:disable
|
10
|
+
def Format(type) # rubocop:disable Naming/MethodName
|
11
11
|
find_by_type(type)::Format
|
12
12
|
end
|
13
13
|
|
@@ -32,8 +32,7 @@ module Thinreports
|
|
32
32
|
|
33
33
|
def normalize(value)
|
34
34
|
if value.is_a?(String)
|
35
|
-
|
36
|
-
(Integer(value) rescue nil) || (Float(value) rescue nil)
|
35
|
+
convert_to_integer(value) || convert_to_float(value)
|
37
36
|
else
|
38
37
|
value
|
39
38
|
end
|
@@ -47,6 +46,18 @@ module Thinreports
|
|
47
46
|
value = BigDecimal(value.to_s).round(precision)
|
48
47
|
sprintf("%.#{precision}f", value)
|
49
48
|
end
|
49
|
+
|
50
|
+
def convert_to_integer(value)
|
51
|
+
Integer(value)
|
52
|
+
rescue ArgumentError
|
53
|
+
nil
|
54
|
+
end
|
55
|
+
|
56
|
+
def convert_to_float(value)
|
57
|
+
Float(value)
|
58
|
+
rescue ArgumentError
|
59
|
+
nil
|
60
|
+
end
|
50
61
|
end
|
51
62
|
end
|
52
63
|
end
|
@@ -6,13 +6,16 @@ module Thinreports
|
|
6
6
|
klass.extend self
|
7
7
|
end
|
8
8
|
|
9
|
-
# rubocop:disable Style/RescueModifier
|
10
9
|
def deep_copy(src)
|
11
10
|
case src
|
12
11
|
when Hash
|
13
|
-
src.each_with_object({})
|
12
|
+
src.each_with_object({}) do |(k, v), h|
|
13
|
+
h[k] = v.dup rescue v # rubocop:disable Lint/RescueWithoutErrorClass,Lint/RescueModifier
|
14
|
+
end
|
14
15
|
when Array
|
15
|
-
src.map
|
16
|
+
src.map do |a|
|
17
|
+
a.dup rescue a # rubocop:disable Lint/RescueWithoutErrorClass,Lint/RescueModifier
|
18
|
+
end
|
16
19
|
else
|
17
20
|
raise ArgumentError
|
18
21
|
end
|
data/lib/thinreports/version.rb
CHANGED
@@ -8,6 +8,41 @@ class Thinreports::Core::Shape::List::TestPage < Minitest::Test
|
|
8
8
|
# Alias
|
9
9
|
List = Thinreports::Core::Shape::List
|
10
10
|
|
11
|
+
LIST_SCHEMA = {
|
12
|
+
'type' => 'list',
|
13
|
+
'id' => 'list',
|
14
|
+
'display' => true,
|
15
|
+
'x' => 10.0,
|
16
|
+
'y' => 20.0,
|
17
|
+
'width' => 30.0,
|
18
|
+
'height' => 40.0,
|
19
|
+
'content-height' => 255,
|
20
|
+
'auto-page-break' => true,
|
21
|
+
'header' => {
|
22
|
+
'enabled' => true,
|
23
|
+
'height' => 10.0,
|
24
|
+
'translate' => { 'x' => 210.0, 'y' => 310.0 },
|
25
|
+
'items' => []
|
26
|
+
},
|
27
|
+
'detail' => {
|
28
|
+
'height' => 20.0,
|
29
|
+
'translate' => { 'x' => 220.0, 'y' => 320.0 },
|
30
|
+
'items' => []
|
31
|
+
},
|
32
|
+
'page-footer' => {
|
33
|
+
'enabled' => false,
|
34
|
+
'height' => 30.0,
|
35
|
+
'translate' => { 'x' => 230.0, 'y' => 330.0 },
|
36
|
+
'items' => []
|
37
|
+
},
|
38
|
+
'footer' => {
|
39
|
+
'enabled' => false,
|
40
|
+
'height' => 40.0,
|
41
|
+
'translate' => { 'x' => 240.0, 'y' => 340.0 },
|
42
|
+
'items' => []
|
43
|
+
}
|
44
|
+
}
|
45
|
+
|
11
46
|
def create_report(&block)
|
12
47
|
report = Thinreports::Report.new layout: layout_file.path
|
13
48
|
block.call(report) if block_given?
|
@@ -79,4 +114,45 @@ class Thinreports::Core::Shape::List::TestPage < Minitest::Test
|
|
79
114
|
rescue => e
|
80
115
|
flunk exception_details(e, 'Not worked when list has not header')
|
81
116
|
end
|
117
|
+
|
118
|
+
def test_copy_when_auto_page_break_disabled
|
119
|
+
list_schema = LIST_SCHEMA.merge('auto-page-break' => false)
|
120
|
+
|
121
|
+
report = Thinreports::Report::Base.new
|
122
|
+
layout = Thinreports::Layout::Base.new(layout_file.path)
|
123
|
+
report_page = Thinreports::Report::Page.new(report, layout)
|
124
|
+
|
125
|
+
list_format = Thinreports::Core::Shape::List::Format.new(list_schema)
|
126
|
+
|
127
|
+
list_page = List::Page.new(report.page, list_format)
|
128
|
+
|
129
|
+
2.times { list_page.add_row }
|
130
|
+
|
131
|
+
copied_list_page = list_page.copy(Thinreports::Report::Page.new(report, layout))
|
132
|
+
|
133
|
+
assert list_page.manager.finalized?
|
134
|
+
assert copied_list_page.manager.finalized?
|
135
|
+
assert_equal 2, copied_list_page.internal.rows.count
|
136
|
+
end
|
137
|
+
|
138
|
+
def test_copy_when_auto_page_break_enabled
|
139
|
+
list_schema = LIST_SCHEMA.merge('auto-page-break' => true)
|
140
|
+
|
141
|
+
report = Thinreports::Report::Base.new
|
142
|
+
layout = Thinreports::Layout::Base.new(layout_file.path)
|
143
|
+
report_page = Thinreports::Report::Page.new(report, layout)
|
144
|
+
|
145
|
+
list_format = Thinreports::Core::Shape::List::Format.new(list_schema)
|
146
|
+
|
147
|
+
list_page = List::Page.new(report.page, list_format)
|
148
|
+
|
149
|
+
2.times { list_page.add_row }
|
150
|
+
list_page.manager.finalize_page
|
151
|
+
|
152
|
+
copied_list_page = list_page.copy(Thinreports::Report::Page.new(report, layout))
|
153
|
+
|
154
|
+
refute list_page.manager.finalized?
|
155
|
+
refute copied_list_page.manager.finalized?
|
156
|
+
assert_empty copied_list_page.internal.rows
|
157
|
+
end
|
82
158
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: thinreports
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
4
|
+
version: 0.10.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matsukei Co.,Ltd.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-09-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: prawn
|