thinreports 0.10.0 → 0.10.1

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
  SHA1:
3
- metadata.gz: 40890b67b0013db37dcab5672e1b3166919adc9c
4
- data.tar.gz: 00d5a8a495b282c6f6c83864a2550774b09a9995
3
+ metadata.gz: 687d41cb0fe000892fa4cb8751fdc8fa70e20f0e
4
+ data.tar.gz: 0a40e144fe135538bb37e793117f7a56348a934b
5
5
  SHA512:
6
- metadata.gz: 7c84274da336894155c19db3ae9b6ce66f3c69bde20605c74efd841dd318c51d7317553a261cac391b8e5eb9d197d15fd05cfb18d0e87ffdafbf8b0a2ffbe315
7
- data.tar.gz: f2f4b9e4aa7edeca96bb40f7ceb187fa04dd9bdfcaf6d750af6602077f0d5c25cb19466ae50780cf87d1a433f82ea11f5837263d4f16b35922b0f525b475fd91
6
+ metadata.gz: 0d6da77661a179f657503f76f3e4c12b6664a73cac7f403aaf4506efb201ad336a18dd44612e4e456fdfb063e3c837692c02e877a3117897fb54b1dd4eefb3fe
7
+ data.tar.gz: 57443d5529f32831839676b6f9a8bb7a487153d0282e8c5fbee762ac52443f997071437b99d8543e81eeb8fbf785b5fb07b17825ff774f83b3e1508fe4239e37
@@ -34,7 +34,7 @@ Style/NumericPredicate:
34
34
  Style/PerlBackrefs:
35
35
  Enabled: false
36
36
 
37
- Style/PredicateName:
37
+ Naming/PredicateName:
38
38
  Enabled: false
39
39
 
40
40
  Style/SafeNavigation:
@@ -1,3 +1,9 @@
1
+ ## 0.10.1
2
+
3
+ Bug Fixes:
4
+
5
+ * Fixed a bug that an error occurred on page break in other list when there is a list with page-break disabled #87 [@meganemura]
6
+
1
7
  ## 0.10.0
2
8
 
3
9
  * Thinreports requires Prawn 2.2
@@ -3,11 +3,11 @@
3
3
  module Thinreports
4
4
  module Core
5
5
  module Shape
6
- def Interface(parent, format) # rubocop:disable Style/MethodName
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 Style/MethodName
10
+ def Format(type) # rubocop:disable Naming/MethodName
11
11
  find_by_type(type)::Format
12
12
  end
13
13
 
@@ -87,7 +87,7 @@ module Thinreports
87
87
  internal.rows.each do |row|
88
88
  new_list.internal.rows << row.copy(new_list)
89
89
  end
90
- new_list.finalized!
90
+ new_list.internal.finalized!
91
91
  end
92
92
 
93
93
  if internal.format.has_header?
@@ -32,8 +32,7 @@ module Thinreports
32
32
 
33
33
  def normalize(value)
34
34
  if value.is_a?(String)
35
- # rubocop:disable Style/RescueModifier
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({}) { |(k, v), h| h[k] = v.dup rescue v }
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 { |a| a.dup rescue a }
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
@@ -74,7 +74,7 @@ module Thinreports
74
74
  raise ArgumentError, 'Invalid argument for layout.'
75
75
  end
76
76
 
77
- @default_layout = layout unless @default_layout
77
+ @default_layout ||= layout
78
78
  layout
79
79
  end
80
80
 
@@ -86,7 +86,7 @@ module Thinreports
86
86
 
87
87
  # For list shapes.
88
88
  if at == :create
89
- manager.lists.values.each { |list| list.manager.finalize }
89
+ manager.lists.each_value { |list| list.manager.finalize }
90
90
  end
91
91
 
92
92
  @finalized = true
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Thinreports
4
- VERSION = '0.10.0'.freeze
4
+ VERSION = '0.10.1'.freeze
5
5
  end
@@ -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.0
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-05-09 00:00:00.000000000 Z
11
+ date: 2017-09-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: prawn