birt-core 0.1.2 → 0.1.3

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: 299fc1930ccff07a320781bc0d9696ae7114b574
4
- data.tar.gz: 9cdec5daf262906130b29362d38cd4ad226f17f0
3
+ metadata.gz: 50901c67b2049adcbed2c955c1d756cccb1b1867
4
+ data.tar.gz: bc6cda56190cbb2494236835826fbdff6d6ca1ac
5
5
  SHA512:
6
- metadata.gz: 552bce0244578656a036a20b2a89bb9f4283b344b812784fb0e0318ccb9d5fb0589a64ec43c2ed46381048ba110bb96cc35d492af11740f4498f9976bdfd42fe
7
- data.tar.gz: d976c468c55b9b79ffbd3bc82b6fa3aff68232cd788fe519401b067eb51f7081a992a7ac065ad4e749ad0e982a30f820457872cc55e7837041984fc82a91991a
6
+ metadata.gz: 6118e7d94219701603ca967e3ceda6d757fb6599bbb2af0812a98e08d20cab698abc22695c2234349bc9661d337a16d84be1a80ad9c5649226b36211608c495a
7
+ data.tar.gz: 5f5317d5ca3e3d5bb8ce6801742862b5cd849e43bd58b08c430f963770f6096b79154714c86965be504728bd99f402e4731a180dde148e599d3529be221a254c
@@ -3,15 +3,15 @@ class Birt::Core::DataSet
3
3
  attr_accessor :name
4
4
  attr_accessor :columns
5
5
  attr_accessor :query_text
6
- attr_accessor :query_result
6
+ attr_accessor :data_set_result
7
7
  attr_accessor :data_source
8
8
 
9
9
  def initialize(xml_element)
10
- self.columns = Array.new
10
+ @columns = []
11
11
  if xml_element
12
12
  self.name = xml_element.attribute(:name).value
13
13
  xml_element.get_elements("list-property[@name='resultSet']/structure/property[@name='name']").each do |column|
14
- self.columns.push column.text
14
+ self.columns << column.text
15
15
  end
16
16
  self.query_text = xml_element.get_elements("xml-property[@name='queryText']")[0].text.gsub("\n", ' ')
17
17
  end
@@ -20,8 +20,12 @@ class Birt::Core::DataSet
20
20
 
21
21
  #开始查询
22
22
  def query
23
- Birt::Core::Mysql.query(self.data_source, query_text).each do |row|
24
- p row
25
- end
23
+ Birt::Core::Mysql.query(self.data_source, query_text)
24
+ end
25
+
26
+ #查询结果
27
+ def data_set_result
28
+ @data_set_result ||= Birt::Core::DataSetResult.new(self.query)
26
29
  end
30
+
27
31
  end
@@ -0,0 +1,20 @@
1
+ class Birt::Core::DataSetResult
2
+
3
+ attr_accessor :rows
4
+ attr_accessor :row_headers
5
+ attr_accessor :columns
6
+ attr_accessor :column_headers
7
+
8
+ def initialize(data_result)
9
+ @rows, @row_headers, @columns, @column_headers= [], [], [], []
10
+
11
+ data_result.each do |row|
12
+ @column_headers = row.keys.inject([]) { |acc, (k,v)| acc<<k.to_s; acc } if column_headers.empty?
13
+ @row_headers << row.values[0]
14
+ @rows << row.values
15
+ row.values.each_with_index { |v, i| @columns[i]||=[]; @columns[i]<<v; }
16
+ end if data_result
17
+
18
+ end
19
+
20
+ end
@@ -31,13 +31,10 @@ class Birt::Core::RptDesign
31
31
 
32
32
  #报表
33
33
  _root.each_element(xpath='/report/body/table') do |item|
34
- self.reports[item.attribute(:id).value] = Birt::Core::TableReport.new(item) do |report|
34
+ self.reports["#{item.attribute(:id).value}_table"] = Birt::Core::TableReport.new(item) do |report|
35
35
  report.data_set = self.data_sets[item.get_elements("property[@name='dataSet']")[0].text]
36
36
  end
37
37
  end
38
-
39
- p self.reports
40
-
41
38
  end
42
39
 
43
40
  end
@@ -1,5 +1,5 @@
1
1
  module Birt
2
2
  module Core
3
- VERSION = "0.1.2"
3
+ VERSION = "0.1.3"
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.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stream
@@ -86,6 +86,7 @@ files:
86
86
  - birt-core.gemspec
87
87
  - lib/birt/core.rb
88
88
  - lib/birt/core/data_set.rb
89
+ - lib/birt/core/data_set_result.rb
89
90
  - lib/birt/core/data_source.rb
90
91
  - lib/birt/core/mysql.rb
91
92
  - lib/birt/core/report/base_report.rb