birt-core 0.1.1 → 0.1.2

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: 1dd88b8f71e985e806347414c5548bcd9ce5013f
4
- data.tar.gz: ce5bfa174ba56eba559f037b5245d7379754149c
3
+ metadata.gz: 299fc1930ccff07a320781bc0d9696ae7114b574
4
+ data.tar.gz: 9cdec5daf262906130b29362d38cd4ad226f17f0
5
5
  SHA512:
6
- metadata.gz: 403653f667629407dcdbd2ec7a3c5e517c6d40639cd5e64b920b94f50e3a425bd1885a124d02e63c009a2f556a7b219a4a18da51832842448b2d04b9b131e04b
7
- data.tar.gz: f13c91555c88b2c98ecc02ee3ee0bc0e7310b2a9c4e3d164f250df1e279fa994a3859188d42571c9a2f8c6413aa20e5221d981432ad72c544bde91625b0c7861
6
+ metadata.gz: 552bce0244578656a036a20b2a89bb9f4283b344b812784fb0e0318ccb9d5fb0589a64ec43c2ed46381048ba110bb96cc35d492af11740f4498f9976bdfd42fe
7
+ data.tar.gz: d976c468c55b9b79ffbd3bc82b6fa3aff68232cd788fe519401b067eb51f7081a992a7ac065ad4e749ad0e982a30f820457872cc55e7837041984fc82a91991a
@@ -1,7 +1,7 @@
1
1
  class Birt::Core::Mysql
2
2
 
3
3
  def self.client(data_source)
4
- @client ||=Mysql2::Core::Client.new(
4
+ @client ||=Mysql2::Client.new(
5
5
  host: data_source.host,
6
6
  port: data_source.port,
7
7
  username: data_source.username,
@@ -0,0 +1,12 @@
1
+ class Birt::Core::BaseReport
2
+ attr_accessor :id
3
+
4
+ def initialize(xml_element)
5
+ if xml_element
6
+ self.id = xml_element.attribute(:id).value if xml_element.attribute(:id)
7
+ end
8
+
9
+ yield(self) if block_given?
10
+ end
11
+
12
+ end
@@ -0,0 +1,15 @@
1
+ class Birt::Core::Property < Birt::Core::BaseReport
2
+ attr_accessor :name
3
+ attr_accessor :text
4
+
5
+ def initialize(x_ele)
6
+
7
+ super(x_ele) do
8
+ self.name = x_ele.attribute(:name).value
9
+ self.text = x_ele.text
10
+ end
11
+
12
+ yield(self) if block_given?
13
+ end
14
+
15
+ end
@@ -0,0 +1,16 @@
1
+ class Birt::Core::TableCellData < Birt::Core::BaseReport
2
+
3
+
4
+ attr_accessor :properties
5
+
6
+ def initialize(x_ele)
7
+ self.properties = Array.new
8
+
9
+ super(x_ele) do
10
+ x_ele.get_elements(xpath="property").each { |tp| self.properties.push Birt::Core::Property.new(tp) }
11
+ end
12
+
13
+ yield(self) if block_given?
14
+ end
15
+
16
+ end
@@ -0,0 +1,15 @@
1
+ class Birt::Core::TableCellLabel < Birt::Core::BaseReport
2
+
3
+ attr_accessor :text_properties
4
+
5
+ def initialize(x_ele)
6
+ self.text_properties = Array.new
7
+
8
+ super(x_ele) do
9
+ x_ele.get_elements(xpath="text-property").each { |tp| self.text_properties.push Birt::Core::TextProperty.new(tp) }
10
+ end
11
+
12
+ yield(self) if block_given?
13
+ end
14
+
15
+ end
@@ -0,0 +1,13 @@
1
+ class Birt::Core::TableDetail < Birt::Core::BaseReport
2
+ attr_accessor :rows
3
+
4
+ def initialize(x_ele)
5
+ self.rows = Array.new
6
+
7
+ super(x_ele) do
8
+ x_ele.get_elements(xpath="row").each { |row| self.rows.push Birt::Core::TableRow.new(row) }
9
+ end
10
+
11
+ yield(self) if block_given?
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ class Birt::Core::TableFooter< Birt::Core::BaseReport
2
+ attr_accessor :rows
3
+
4
+ def initialize(x_ele)
5
+ self.rows = Array.new
6
+
7
+ super(x_ele) do
8
+ x_ele.get_elements(xpath="row").each { |row| self.rows.push Birt::Core::TableRow.new(row)}
9
+ end
10
+
11
+ yield(self) if block_given?
12
+ end
13
+ end
@@ -0,0 +1,15 @@
1
+ class Birt::Core::TableHeader < Birt::Core::BaseReport
2
+
3
+ attr_accessor :rows
4
+
5
+ def initialize(x_ele)
6
+ self.rows = Array.new
7
+
8
+ super(x_ele) do
9
+ x_ele.get_elements(xpath="row").each { |row| self.rows.push Birt::Core::TableRow.new(row)}
10
+ end
11
+
12
+ yield(self) if block_given?
13
+ end
14
+
15
+ end
@@ -1,2 +1,17 @@
1
- class Birt::Core::TableReport
1
+ class Birt::Core::TableReport < Birt::Core::BaseReport
2
+ attr_accessor :header
3
+ attr_accessor :detail
4
+ attr_accessor :footer
5
+ attr_accessor :data_set
6
+
7
+ def initialize(xml_element)
8
+
9
+ super(xml_element) do
10
+ self.header = Birt::Core::TableHeader.new(xml_element.get_elements(xpath="header")[0])
11
+ self.detail = Birt::Core::TableDetail.new(xml_element.get_elements(xpath="detail")[0])
12
+ self.footer = Birt::Core::TableDetail.new(xml_element.get_elements(xpath="footer")[0])
13
+ end
14
+
15
+ yield(self) if block_given?
16
+ end
2
17
  end
@@ -0,0 +1,15 @@
1
+ class Birt::Core::TableRow < Birt::Core::BaseReport
2
+
3
+ attr_accessor :row_cells
4
+
5
+ def initialize(x_ele)
6
+ self.row_cells = Array.new
7
+
8
+ super(x_ele) do
9
+ x_ele.get_elements(xpath="cell").each { |cell| self.row_cells.push Birt::Core::TableRowCell.new(cell) }
10
+ end
11
+
12
+ yield(self) if block_given?
13
+ end
14
+
15
+ end
@@ -0,0 +1,16 @@
1
+ class Birt::Core::TableRowCell < Birt::Core::BaseReport
2
+ attr_accessor :cell_labels
3
+ attr_accessor :cell_datas
4
+
5
+ def initialize(x_ele)
6
+ self.cell_labels = Array.new
7
+ self.cell_datas = Array.new
8
+
9
+ super(x_ele) do
10
+ x_ele.get_elements(xpath="label").each { |label| self.cell_labels.push Birt::Core::TableCellLabel.new(label) }
11
+ x_ele.get_elements(xpath="data").each { |data| self.cell_datas.push Birt::Core::TableCellData.new(data) }
12
+ end
13
+
14
+ yield(self) if block_given?
15
+ end
16
+ end
@@ -0,0 +1,15 @@
1
+ class Birt::Core::TextProperty < Birt::Core::BaseReport
2
+ attr_accessor :name
3
+ attr_accessor :text
4
+
5
+ def initialize(x_ele)
6
+
7
+ super(x_ele) do
8
+ self.name = x_ele.attribute(:name).value
9
+ self.text = x_ele.text
10
+ end
11
+
12
+ yield(self) if block_given?
13
+ end
14
+
15
+ end
@@ -4,11 +4,13 @@ class Birt::Core::RptDesign
4
4
  attr_accessor :rpt_design_path
5
5
  attr_accessor :data_sources
6
6
  attr_accessor :data_sets
7
+ attr_accessor :reports
7
8
 
8
9
  def initialize(rpt_design_path)
9
10
  self.rpt_design_path = rpt_design_path
10
11
  self.data_sources = Hash.new
11
12
  self.data_sets = Hash.new
13
+ self.reports = Hash.new
12
14
  end
13
15
 
14
16
  #解析文件
@@ -17,19 +19,24 @@ class Birt::Core::RptDesign
17
19
 
18
20
  #数据源
19
21
  _root.each_element(xpath = '/report/data-sources/oda-data-source') do |item|
20
- self.data_sources[item.attribute(:name).value] = Birt::Core::DataSource.new(item)
22
+ p self.data_sources[item.attribute(:name).value] = Birt::Core::DataSource.new(item)
21
23
  end
22
24
 
23
25
  #数据集
24
26
  _root.each_element(xpath='/report/data-sets/oda-data-set') do |item|
25
27
  self.data_sets[item.attribute(:name).value] = Birt::Core::DataSet.new(item) do |data_set|
26
28
  data_set.data_source = self.data_sources[item.get_elements("property[@name='dataSource']")[0].text]
27
- data_set.query
28
29
  end
29
30
  end
30
31
 
31
- p self.data_sources
32
- p self.data_sets
32
+ #报表
33
+ _root.each_element(xpath='/report/body/table') do |item|
34
+ self.reports[item.attribute(:id).value] = Birt::Core::TableReport.new(item) do |report|
35
+ report.data_set = self.data_sets[item.get_elements("property[@name='dataSet']")[0].text]
36
+ end
37
+ end
38
+
39
+ p self.reports
33
40
 
34
41
  end
35
42
 
@@ -1,5 +1,5 @@
1
1
  module Birt
2
2
  module Core
3
- VERSION = "0.1.1"
3
+ VERSION = "0.1.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: birt-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stream
@@ -88,7 +88,17 @@ files:
88
88
  - lib/birt/core/data_set.rb
89
89
  - lib/birt/core/data_source.rb
90
90
  - lib/birt/core/mysql.rb
91
+ - lib/birt/core/report/base_report.rb
92
+ - lib/birt/core/report/property.rb
93
+ - lib/birt/core/report/table_cell_data.rb
94
+ - lib/birt/core/report/table_cell_label.rb
95
+ - lib/birt/core/report/table_detail.rb
96
+ - lib/birt/core/report/table_footer.rb
97
+ - lib/birt/core/report/table_header.rb
91
98
  - lib/birt/core/report/table_report.rb
99
+ - lib/birt/core/report/table_row.rb
100
+ - lib/birt/core/report/table_row_cell.rb
101
+ - lib/birt/core/report/text_property.rb
92
102
  - lib/birt/core/rpt_design.rb
93
103
  - lib/birt/core/version.rb
94
104
  homepage: https://github.com/mumaoxi/birt-core