thinreports 0.6.0.pre3 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +37 -32
- data/doc/yardoc_templates/default/layout/html/footer.erb +1 -1
- data/lib/thinreports.rb +2 -1
- data/lib/thinreports/config.rb +21 -0
- data/lib/thinreports/core/errors.rb +14 -1
- data/lib/thinreports/core/format/builder.rb +6 -1
- data/lib/thinreports/core/page.rb +6 -6
- data/lib/thinreports/core/shape.rb +8 -9
- data/lib/thinreports/core/shape/base/internal.rb +6 -12
- data/lib/thinreports/core/shape/basic.rb +3 -0
- data/lib/thinreports/core/shape/basic/block_format.rb +12 -0
- data/lib/thinreports/core/shape/basic/block_interface.rb +25 -0
- data/lib/thinreports/core/shape/basic/block_internal.rb +33 -0
- data/lib/thinreports/core/shape/basic/interface.rb +37 -11
- data/lib/thinreports/core/shape/basic/internal.rb +3 -12
- data/lib/thinreports/core/shape/image_block.rb +15 -0
- data/lib/thinreports/core/shape/image_block/format.rb +13 -0
- data/lib/thinreports/core/shape/image_block/interface.rb +19 -0
- data/lib/thinreports/core/shape/image_block/internal.rb +16 -0
- data/lib/thinreports/core/shape/list/events.rb +19 -2
- data/lib/thinreports/core/shape/list/manager.rb +17 -4
- data/lib/thinreports/core/shape/list/page.rb +2 -2
- data/lib/thinreports/core/shape/list/page_state.rb +4 -0
- data/lib/thinreports/core/shape/list/section_internal.rb +4 -0
- data/lib/thinreports/core/shape/manager/format.rb +1 -1
- data/lib/thinreports/core/shape/manager/internal.rb +24 -11
- data/lib/thinreports/core/shape/manager/target.rb +2 -2
- data/lib/thinreports/core/shape/style.rb +15 -0
- data/lib/thinreports/core/shape/style/base.rb +149 -0
- data/lib/thinreports/core/shape/style/basic.rb +17 -0
- data/lib/thinreports/core/shape/style/graphic.rb +60 -0
- data/lib/thinreports/core/shape/style/text.rb +138 -0
- data/lib/thinreports/core/shape/text/internal.rb +4 -0
- data/lib/thinreports/core/shape/text_block.rb +16 -0
- data/lib/thinreports/core/shape/{tblock → text_block}/format.rb +3 -3
- data/lib/thinreports/core/shape/{tblock → text_block}/formatter.rb +7 -7
- data/lib/thinreports/core/shape/{tblock → text_block}/formatter/basic.rb +1 -1
- data/lib/thinreports/core/shape/{tblock → text_block}/formatter/datetime.rb +1 -1
- data/lib/thinreports/core/shape/{tblock → text_block}/formatter/number.rb +1 -1
- data/lib/thinreports/core/shape/{tblock → text_block}/formatter/padding.rb +10 -8
- data/lib/thinreports/core/shape/{tblock → text_block}/interface.rb +2 -21
- data/lib/thinreports/core/shape/{tblock → text_block}/internal.rb +16 -10
- data/lib/thinreports/core/utils.rb +0 -8
- data/lib/thinreports/generator.rb +2 -2
- data/lib/thinreports/generator/configuration.rb +30 -0
- data/lib/thinreports/generator/pdf.rb +13 -10
- data/lib/thinreports/generator/pdf/configuration.rb +28 -0
- data/lib/thinreports/generator/pdf/document.rb +16 -56
- data/lib/thinreports/generator/pdf/document/draw_shape.rb +35 -17
- data/lib/thinreports/generator/pdf/document/font.rb +25 -9
- data/lib/thinreports/generator/pdf/document/graphics.rb +1 -1
- data/lib/thinreports/generator/pdf/document/graphics/attributes.rb +18 -4
- data/lib/thinreports/generator/pdf/document/graphics/basic.rb +1 -1
- data/lib/thinreports/generator/pdf/document/graphics/image.rb +18 -1
- data/lib/thinreports/generator/pdf/document/graphics/text.rb +29 -6
- data/lib/thinreports/generator/pdf/document/page.rb +70 -0
- data/lib/thinreports/generator/pdf/document/parse_color.rb +1 -1
- data/lib/thinreports/generator/pdf/document/parse_svg.rb +1 -1
- data/lib/thinreports/generator/pdf/drawer.rb +1 -1
- data/lib/thinreports/generator/pdf/drawer/base.rb +5 -7
- data/lib/thinreports/generator/pdf/drawer/list.rb +4 -4
- data/lib/thinreports/generator/pdf/drawer/list_section.rb +8 -3
- data/lib/thinreports/generator/pdf/drawer/page.rb +10 -3
- data/lib/thinreports/generator/pdf/prawn_ext.rb +16 -21
- data/lib/thinreports/layout/format.rb +2 -2
- data/lib/thinreports/layout/version.rb +2 -2
- data/lib/thinreports/report/base.rb +68 -31
- data/tasks/test.rake +48 -4
- data/test/benchmark/basic_estimate.tlf +1 -0
- data/test/benchmark/bench_basic_estimate.rb +95 -0
- data/test/case/character_spacing/character_spacing.rb +7 -0
- data/test/case/character_spacing/character_spacing.tlf +1 -0
- data/test/case/dynamic_image/dynamic_image.rb +41 -0
- data/test/case/dynamic_image/dynamic_image.tlf +1 -0
- data/test/case/dynamic_image/img200x100.png +0 -0
- data/test/case/dynamic_image/img50x50.png +0 -0
- data/test/case/dynamic_style/dynamic_style.rb +154 -0
- data/test/case/dynamic_style/dynamic_style.tlf +1 -0
- data/test/case/dynamic_style/dynamic_style_in_list.tlf +1 -0
- data/test/case/dynamic_style/image.png +0 -0
- data/test/case/eudc/eudc.rb +20 -0
- data/test/case/eudc/eudc.tlf +1 -0
- data/test/case/eudc/eudc.ttf +0 -0
- data/test/case/helper.rb +27 -0
- data/test/case/hidden_shapes/hidden_shapes.rb +13 -0
- data/test/case/hidden_shapes/hidden_shapes.tlf +1 -0
- data/test/case/list_events/list_events.rb +32 -0
- data/test/case/list_events/list_events.tlf +1 -0
- data/test/case/list_header_inheriting/list_header_inheriting.rb +19 -0
- data/test/case/list_header_inheriting/list_header_inheriting.tlf +1 -0
- data/test/case/list_manual_generation/list_manual_generation.rb +24 -0
- data/test/case/list_manual_generation/list_manual_generation.tlf +1 -0
- data/test/case/single_line_tblock/single_line_tblock.rb +15 -0
- data/test/case/single_line_tblock/single_line_tblock.tlf +1 -0
- data/test/case/tblock_styles/tblock_styles.rb +27 -0
- data/test/case/tblock_styles/tblock_styles.tlf +1 -0
- data/test/case/text_align/text_align.rb +9 -0
- data/test/case/text_align/text_align.tlf +1 -0
- data/test/unit/core/shape/base/test_internal.rb +65 -85
- data/test/unit/core/shape/basic/test_basic_format.rb +30 -0
- data/test/unit/core/shape/basic/test_basic_interface.rb +27 -0
- data/test/unit/core/shape/basic/test_basic_internal.rb +55 -0
- data/test/unit/core/shape/basic/test_interface.rb +84 -36
- data/test/unit/core/shape/basic/test_internal.rb +32 -24
- data/test/unit/core/shape/image_block/test_format.rb +58 -0
- data/test/unit/core/shape/image_block/test_interface.rb +23 -0
- data/test/unit/core/shape/image_block/test_internal.rb +28 -0
- data/test/unit/core/shape/list/test_events.rb +19 -11
- data/test/unit/core/shape/list/test_manager.rb +112 -0
- data/test/unit/core/shape/list/test_page.rb +57 -0
- data/test/unit/core/shape/list/test_section_format.rb +1 -1
- data/test/unit/core/shape/list/test_section_interface.rb +37 -30
- data/test/unit/core/shape/list/test_section_internal.rb +39 -14
- data/test/unit/core/shape/manager/test_format.rb +12 -18
- data/test/unit/core/shape/manager/test_internal.rb +127 -93
- data/test/unit/core/shape/manager/test_target.rb +63 -56
- data/test/unit/core/shape/styles/test_base.rb +219 -0
- data/test/unit/core/shape/styles/test_basic.rb +24 -0
- data/test/unit/core/shape/styles/test_graphic.rb +69 -0
- data/test/unit/core/shape/styles/test_text.rb +318 -0
- data/test/unit/core/shape/{tblock → text_block}/formatter/test_basic.rb +2 -2
- data/test/unit/core/shape/{tblock → text_block}/formatter/test_datetime.rb +2 -2
- data/test/unit/core/shape/{tblock → text_block}/formatter/test_number.rb +2 -2
- data/test/unit/core/shape/{tblock → text_block}/formatter/test_padding.rb +11 -6
- data/test/unit/core/shape/text_block/test_format.rb +160 -0
- data/test/unit/core/shape/{tblock → text_block}/test_formatter.rb +2 -2
- data/test/unit/core/shape/text_block/test_interface.rb +46 -0
- data/test/unit/core/shape/text_block/test_internal.rb +128 -0
- data/test/unit/core/test_shape.rb +31 -6
- data/test/unit/data/basic_layout1.tlf +1 -0
- data/test/unit/data/basic_layout2.tlf +1 -0
- data/test/unit/data/basic_list_layout.tlf +1 -0
- data/test/unit/generator/pdf/document/graphics/test_attributes.rb +81 -52
- data/test/unit/generator/pdf/document/graphics/test_text.rb +159 -0
- data/test/unit/generator/pdf/document/test_font.rb +21 -6
- data/test/unit/generator/pdf/document/test_graphics.rb +2 -2
- data/test/unit/generator/pdf/document/test_page.rb +95 -0
- data/test/unit/generator/pdf/document/test_parse_color.rb +2 -2
- data/test/unit/generator/pdf/test_configuration.rb +24 -0
- data/test/unit/generator/pdf/test_document.rb +28 -0
- data/test/unit/generator/test_configuration.rb +25 -0
- data/test/unit/generator/test_pdf.rb +19 -0
- data/test/unit/helper.rb +18 -0
- data/test/unit/layout/test_format.rb +24 -7
- data/test/unit/layout/test_version.rb +61 -27
- data/test/unit/report/test_base.rb +185 -89
- data/test/unit/test_config.rb +22 -0
- data/test/unit/test_report.rb +4 -4
- metadata +94 -43
- data/lib/thinreports/core/shape/tblock.rb +0 -16
- data/lib/thinreports/generator/pxd.rb +0 -75
- data/lib/thinreports/generator/pxd/helper.rb +0 -33
- data/lib/thinreports/generator/pxd/list_renderer.rb +0 -58
- data/lib/thinreports/generator/pxd/page_renderer.rb +0 -75
- data/tasks/clean.rake +0 -6
- data/test/unit/core/shape/tblock/test_format.rb +0 -125
- data/test/unit/core/shape/tblock/test_interface.rb +0 -40
- data/test/unit/core/shape/tblock/test_internal.rb +0 -139
data/README.rdoc
CHANGED
@@ -1,69 +1,74 @@
|
|
1
1
|
= ThinReports Generator
|
2
2
|
|
3
3
|
ThinReports is Open Source Reporting Solution for Ruby.
|
4
|
-
And it
|
4
|
+
And it provides you these tools:
|
5
5
|
|
6
|
-
* ThinReports Editor (GUI
|
7
|
-
* ThinReports Generator (Report
|
6
|
+
* ThinReports Editor (GUI Designer)
|
7
|
+
* ThinReports Generator (Report Generator for Ruby)
|
8
8
|
|
9
|
-
|
10
|
-
|
9
|
+
You can see more details:
|
10
|
+
|
11
|
+
* {Official Site}[http://www.thinreports.org/]
|
12
|
+
* {Project Site}[http://osc.matsukei.net/projects/thinreports/wiki]
|
11
13
|
|
12
14
|
== Quick Start
|
13
15
|
|
14
16
|
Getting started with ThinReports Generator can be as simple as:
|
15
17
|
|
16
|
-
|
18
|
+
require 'thinreports'
|
17
19
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
20
|
+
report = ThinReports::Report.new :layout => 'report.tlf'
|
21
|
+
report.start_new_page do
|
22
|
+
page.item(:title).value('ThinReports')
|
23
|
+
end
|
22
24
|
|
23
|
-
|
25
|
+
# :pdf is used as default when the type argument of a #generate_file is omitted.
|
26
|
+
report.generate_file('report.pdf')
|
24
27
|
|
25
28
|
Or can be as:
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
+
|
30
|
+
ThinReports::Report.generate_file(:pdf, 'report.pdf', :layout => 'report.tlf') do
|
31
|
+
start_new_page
|
29
32
|
|
30
|
-
|
33
|
+
page.item(:title).value('ThinReports')
|
31
34
|
|
32
|
-
|
35
|
+
start_new_page
|
33
36
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
+
page.item(:title).value('ThinReports').style(:color, '#ff0000')
|
38
|
+
end
|
39
|
+
|
37
40
|
{Learn more}[http://osc.matsukei.net/projects/thinreports/wiki/Getting_Started].
|
38
41
|
|
39
|
-
==
|
42
|
+
== Release Note
|
43
|
+
|
44
|
+
* {Changelog}[http://osc.matsukei.net/projects/thinreports/wiki/Changelog]
|
40
45
|
|
41
|
-
|
46
|
+
== Documentation
|
42
47
|
|
43
48
|
* {Getting Started}[http://osc.matsukei.net/projects/thinreports/wiki/Getting_Started]
|
44
49
|
* {Guide}[http://osc.matsukei.net/projects/thinreports/wiki/Guide]
|
45
|
-
* {
|
46
|
-
* {
|
50
|
+
* {Examples}[http://osc.matsukei.net/projects/thinreports/wiki/Examples]
|
51
|
+
* {HowTos}[http://osc.matsukei.net/projects/thinreports/wiki/HowTos]
|
47
52
|
|
48
|
-
==
|
53
|
+
== Project
|
49
54
|
|
50
|
-
|
55
|
+
* {Roadmap}[http://osc.matsukei.net/projects/thinreports/roadmap]
|
56
|
+
* {Issue Tracker (Read-Only)}[http://osc.matsukei.net/projects/thinreports/issues]
|
57
|
+
* {Source Code}[http://osc.matsukei.net/projects/thinreports/wiki/Source_Code]
|
51
58
|
|
52
|
-
==
|
59
|
+
== Help
|
53
60
|
|
54
61
|
* {Open Forum}[http://osc.matsukei.net/projects/thinreports/boards]
|
55
|
-
* {Issue Tracker (Read-Only)}[http://osc.matsukei.net/projects/thinreports/issues]
|
56
62
|
|
57
63
|
== Dependencies
|
58
64
|
|
59
|
-
* <code>prawn</code> <code>= 0.
|
60
|
-
* <code>json</code> <code>>= 1.4.6</code>
|
61
|
-
(Only for less than Ruby 1.9)
|
65
|
+
* <code>prawn</code> <code>= 0.12.0</code>
|
66
|
+
* <code>json</code> <code>>= 1.4.6</code> (Only for less than Ruby 1.9)
|
62
67
|
|
63
68
|
=== Note
|
64
69
|
|
65
70
|
We tested on <code>Ruby 1.8.7</code> and <code>1.9.2</code>.
|
66
|
-
|
71
|
+
But we recommend <code>1.9.2+</code>.
|
67
72
|
|
68
73
|
== Resources
|
69
74
|
|
@@ -71,7 +76,7 @@ We recommend <code>1.9.2+</code>.
|
|
71
76
|
|
72
77
|
ThinReports includes the following fonts.
|
73
78
|
|
74
|
-
* IPAFonts: Copyright(c) 2003-2011 Information-technology Promotion Agency, Japan.
|
79
|
+
* IPAFonts: Copyright(c) 2003-2011 Information-technology Promotion Agency, Japan.
|
75
80
|
Please see the lincense file {IPA_Font_License_Agreement_v1.0.txt}[http://ipafont.ipa.go.jp/ipa_font_license_v1.html].
|
76
81
|
|
77
82
|
== License
|
data/lib/thinreports.rb
CHANGED
@@ -0,0 +1,21 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
module ThinReports
|
4
|
+
# @yield [config]
|
5
|
+
# @yieldparam [ThinReports::Configuration] config
|
6
|
+
def self.configure(&block)
|
7
|
+
block_exec_on(self.config, &block)
|
8
|
+
end
|
9
|
+
|
10
|
+
# @return [ThinReports::Configuration]
|
11
|
+
def self.config
|
12
|
+
@config ||= ThinReports::Configuration.new
|
13
|
+
end
|
14
|
+
|
15
|
+
class Configuration
|
16
|
+
# @return [ThinReports::Generator::Configuration]
|
17
|
+
def generator
|
18
|
+
@generator ||= ThinReports::Generator::Configuration.new
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -7,6 +7,10 @@ module ThinReports
|
|
7
7
|
end
|
8
8
|
|
9
9
|
class UnknownShapeStyleName < Basic
|
10
|
+
def initialize(style, availables)
|
11
|
+
super("The specified style name, '#{style}', cannot be used. " +
|
12
|
+
"The available styles are #{availables.map{|s| ":#{s}"}.join(', ')}.")
|
13
|
+
end
|
10
14
|
end
|
11
15
|
|
12
16
|
class UnknownShapeType < Basic
|
@@ -22,9 +26,15 @@ module ThinReports
|
|
22
26
|
end
|
23
27
|
|
24
28
|
class UnknownItemId < Basic
|
29
|
+
def initialize(id, item_type = 'Basic')
|
30
|
+
super("The layout does not have a #{item_type} Item with id '#{id}'.")
|
31
|
+
end
|
25
32
|
end
|
26
33
|
|
27
34
|
class DisabledListSection < Basic
|
35
|
+
def initialize(section)
|
36
|
+
super("The #{section} section is disabled.")
|
37
|
+
end
|
28
38
|
end
|
29
39
|
|
30
40
|
class UnknownEventType < Basic
|
@@ -34,6 +44,9 @@ module ThinReports
|
|
34
44
|
end
|
35
45
|
|
36
46
|
class UnknownGeneratorType < Basic
|
47
|
+
def initialize(type)
|
48
|
+
super("The specified generator type, '#{type}', was not found.")
|
49
|
+
end
|
37
50
|
end
|
38
51
|
|
39
52
|
class NoConfigurationFound < Basic
|
@@ -49,7 +62,7 @@ module ThinReports
|
|
49
62
|
def initialize(filename, fileversion, required_rules)
|
50
63
|
super("Generator #{ThinReports::VERSION} can not be built this file, " +
|
51
64
|
"'#{File.basename(filename)}'." +
|
52
|
-
"This file is
|
65
|
+
"This file is updated in the Editor of version '#{fileversion}', " +
|
53
66
|
"but Generator requires version #{required_rules}.")
|
54
67
|
end
|
55
68
|
end
|
@@ -5,8 +5,8 @@ module ThinReports
|
|
5
5
|
|
6
6
|
class BlankPage
|
7
7
|
# @return [Integer]
|
8
|
-
|
9
|
-
|
8
|
+
attr_accessor :no
|
9
|
+
|
10
10
|
# @param [Boolean] count (nil)
|
11
11
|
def initialize(count = nil)
|
12
12
|
@count = count.nil? ? true : count
|
@@ -61,7 +61,7 @@ module ThinReports
|
|
61
61
|
new_page.manager.shapes[id] = new_shape
|
62
62
|
|
63
63
|
if new_shape.internal.type_of?(:list)
|
64
|
-
|
64
|
+
new_page.manager.lists[id] = new_shape
|
65
65
|
end
|
66
66
|
end
|
67
67
|
new_page
|
@@ -71,11 +71,11 @@ module ThinReports
|
|
71
71
|
# @option options [:create, :copy] :at (:create)
|
72
72
|
# @private
|
73
73
|
def finalize(options = {})
|
74
|
-
|
75
|
-
|
74
|
+
at = options[:at] || :create
|
75
|
+
|
76
76
|
# For list shapes.
|
77
77
|
if at == :create
|
78
|
-
|
78
|
+
manager.lists.values.each {|list| list.manager.finalize }
|
79
79
|
end
|
80
80
|
|
81
81
|
@finalized = true
|
@@ -28,14 +28,11 @@ module ThinReports
|
|
28
28
|
# @private
|
29
29
|
def self.find_by_type(type)
|
30
30
|
case type
|
31
|
-
when
|
32
|
-
|
33
|
-
when List::TYPE_NAME
|
34
|
-
|
35
|
-
when
|
36
|
-
Text
|
37
|
-
when *Basic::TYPE_NAMES
|
38
|
-
Basic
|
31
|
+
when TextBlock::TYPE_NAME then TextBlock
|
32
|
+
when ImageBlock::TYPE_NAME then ImageBlock
|
33
|
+
when List::TYPE_NAME then List
|
34
|
+
when Text::TYPE_NAME then Text
|
35
|
+
when *Basic::TYPE_NAMES then Basic
|
39
36
|
else
|
40
37
|
raise ThinReports::Errors::UnknownShapeType
|
41
38
|
end
|
@@ -45,9 +42,11 @@ module ThinReports
|
|
45
42
|
end
|
46
43
|
end
|
47
44
|
|
45
|
+
require 'thinreports/core/shape/style'
|
48
46
|
require 'thinreports/core/shape/manager'
|
49
47
|
require 'thinreports/core/shape/base'
|
50
48
|
require 'thinreports/core/shape/basic'
|
51
49
|
require 'thinreports/core/shape/text'
|
52
|
-
require 'thinreports/core/shape/
|
50
|
+
require 'thinreports/core/shape/text_block'
|
51
|
+
require 'thinreports/core/shape/image_block'
|
53
52
|
require 'thinreports/core/shape/list'
|
@@ -13,29 +13,27 @@ module ThinReports
|
|
13
13
|
end
|
14
14
|
private_class_method :format_delegators
|
15
15
|
|
16
|
-
AVAILABLE_STYLES = [:fill, :stroke]
|
17
|
-
|
18
16
|
attr_reader :parent
|
19
17
|
attr_reader :format
|
20
|
-
|
18
|
+
attr_writer :style
|
19
|
+
attr_accessor :states
|
21
20
|
|
22
21
|
def initialize(parent, format)
|
23
22
|
@parent = parent
|
24
23
|
@format = format
|
25
|
-
|
26
24
|
@states = {}
|
27
|
-
@
|
25
|
+
@style = nil
|
28
26
|
|
29
27
|
@finalized_attributes = nil
|
30
28
|
end
|
31
29
|
|
32
|
-
def
|
33
|
-
|
30
|
+
def style
|
31
|
+
raise NotImplementedError
|
34
32
|
end
|
35
33
|
|
36
34
|
def copy(new_parent, &block)
|
37
35
|
new_internal = self.class.new(new_parent, format)
|
38
|
-
new_internal.
|
36
|
+
new_internal.style = style.copy
|
39
37
|
new_internal.states = states.simple_deep_copy
|
40
38
|
|
41
39
|
block.call(new_internal) if block_given?
|
@@ -47,10 +45,6 @@ module ThinReports
|
|
47
45
|
self
|
48
46
|
end
|
49
47
|
|
50
|
-
def available_style?(style_name)
|
51
|
-
AVAILABLE_STYLES.include?(style_name)
|
52
|
-
end
|
53
|
-
|
54
48
|
def type_of?(type_name)
|
55
49
|
raise NotImplementedError
|
56
50
|
end
|
@@ -13,3 +13,6 @@ end
|
|
13
13
|
require 'thinreports/core/shape/basic/format'
|
14
14
|
require 'thinreports/core/shape/basic/internal'
|
15
15
|
require 'thinreports/core/shape/basic/interface'
|
16
|
+
require 'thinreports/core/shape/basic/block_format'
|
17
|
+
require 'thinreports/core/shape/basic/block_internal'
|
18
|
+
require 'thinreports/core/shape/basic/block_interface'
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
module ThinReports
|
4
|
+
module Core::Shape
|
5
|
+
|
6
|
+
class Basic::BlockInterface < Basic::Interface
|
7
|
+
# @overload value(val)
|
8
|
+
# Set a val
|
9
|
+
# @param [Object] val
|
10
|
+
# @return [self]
|
11
|
+
# @overload value
|
12
|
+
# Return the value
|
13
|
+
# @return [Object]
|
14
|
+
def value(*args)
|
15
|
+
if args.empty?
|
16
|
+
internal.read_value
|
17
|
+
else
|
18
|
+
internal.write_value(args.first)
|
19
|
+
self
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
module ThinReports
|
4
|
+
module Core::Shape
|
5
|
+
|
6
|
+
# @private
|
7
|
+
class Basic::BlockInternal < Basic::Internal
|
8
|
+
format_delegators :box
|
9
|
+
|
10
|
+
def style
|
11
|
+
@style ||= Style::Basic.new(format)
|
12
|
+
end
|
13
|
+
|
14
|
+
def read_value
|
15
|
+
states.key?(:value) ? states[:value] : format.value.dup
|
16
|
+
end
|
17
|
+
alias_method :value, :read_value
|
18
|
+
|
19
|
+
def write_value(val)
|
20
|
+
states[:value] = val
|
21
|
+
end
|
22
|
+
|
23
|
+
def real_value
|
24
|
+
read_value
|
25
|
+
end
|
26
|
+
|
27
|
+
def type_of?(type_name)
|
28
|
+
type_name == :block
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
@@ -4,27 +4,53 @@ module ThinReports
|
|
4
4
|
module Core::Shape
|
5
5
|
|
6
6
|
class Basic::Interface < Base::Interface
|
7
|
-
internal_delegators :
|
7
|
+
internal_delegators :type
|
8
|
+
|
9
|
+
# @return [String]
|
10
|
+
def id
|
11
|
+
internal.id.dup
|
12
|
+
end
|
8
13
|
|
9
14
|
# @param [Boolean] visibility
|
10
15
|
# @return [self]
|
11
16
|
def visible(visibility)
|
12
|
-
internal.visible
|
17
|
+
internal.style.visible = visibility
|
13
18
|
self
|
14
19
|
end
|
15
20
|
|
16
|
-
# @
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
21
|
+
# @return [Boolean]
|
22
|
+
def visible?
|
23
|
+
internal.style.visible
|
24
|
+
end
|
25
|
+
|
26
|
+
# @overload style(style_name)
|
27
|
+
# @param [Symbol] style_name
|
28
|
+
# @return [Object]
|
29
|
+
# @overload style(style_name, value)
|
30
|
+
# @param [Symbol] style_name
|
31
|
+
# @param [String, Symbol, Number, Array] value
|
32
|
+
# @return [self]
|
33
|
+
# @overload style(style_name, value1, value2)
|
34
|
+
# @param [Symbol] style_name
|
35
|
+
# @param [String, Number] value1
|
36
|
+
# @param [String, Number] value2
|
37
|
+
# @return [self]
|
38
|
+
def style(*args)
|
39
|
+
case args.length
|
40
|
+
when 1
|
41
|
+
internal.style[args.first]
|
42
|
+
when 2
|
43
|
+
internal.style[args.first] = args.last
|
44
|
+
self
|
45
|
+
when 3
|
46
|
+
internal.style[args.shift] = args
|
47
|
+
self
|
48
|
+
else
|
49
|
+
raise ArgumentError, '#style requires 1 or 2, 3 arguments'
|
22
50
|
end
|
23
|
-
internal.svg_attr(style_name, value)
|
24
|
-
self
|
25
51
|
end
|
26
52
|
|
27
|
-
# @param [Hash] settings
|
53
|
+
# @param [Hash] settings :style_name => value
|
28
54
|
# @return [self]
|
29
55
|
def styles(settings)
|
30
56
|
settings.each{ |args| style(*args) }
|