birt 0.1.8 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/config/birt.yml +9 -0
- data/config/database.yml +13 -0
- data/lib/birt/core/data_source.rb +5 -2
- data/lib/birt/core/mysql.rb +39 -9
- data/lib/birt/core/rpt_design.rb +2 -2
- data/lib/birt/version.rb +1 -1
- data/lib/birt.rb +2 -1
- metadata +32 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 73de487306437a5f2436c45ea2eb0b09a14663a1
|
4
|
+
data.tar.gz: c68d43bb533f6f104b0280abfd76d108f2ecfdc9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a015056d3bbd6e78903784641929dd5bce22b214b20895214b6886478ab09e957192e54378eb5b80ac936b617a28c6ad9ae1830a4fc1336073a51962542729b
|
7
|
+
data.tar.gz: 87beae04b1ac18f60bb8f6febf4b9faefb6b751f03403632bbb0c97a429e1b8e838945fcaf164b0ef3648376331653437a2091bb3f4553cd62e09f6e5490717f
|
data/config/birt.yml
ADDED
data/config/database.yml
ADDED
@@ -7,7 +7,7 @@ class Birt::Core::DataSource
|
|
7
7
|
attr_accessor :password
|
8
8
|
attr_accessor :database
|
9
9
|
|
10
|
-
def initialize(xml_element)
|
10
|
+
def initialize(xml_element = nil)
|
11
11
|
if xml_element
|
12
12
|
self.name = xml_element.attribute(:name).value
|
13
13
|
self.host = xml_element.get_elements("property[@name='odaURL']")[0].text
|
@@ -24,4 +24,7 @@ class Birt::Core::DataSource
|
|
24
24
|
@port = port_database[0]
|
25
25
|
@database = port_database[1]
|
26
26
|
end
|
27
|
-
|
27
|
+
def set_host(host)
|
28
|
+
@host = host
|
29
|
+
end
|
30
|
+
end
|
data/lib/birt/core/mysql.rb
CHANGED
@@ -1,13 +1,7 @@
|
|
1
1
|
class Birt::Core::Mysql
|
2
2
|
|
3
|
-
def self.client(data_source)
|
4
|
-
|
5
|
-
host: data_source.host,
|
6
|
-
port: data_source.port,
|
7
|
-
username: data_source.username,
|
8
|
-
password: data_source.password,
|
9
|
-
database: data_source.database
|
10
|
-
)
|
3
|
+
def self.client(data_source = nil)
|
4
|
+
create_client(choose_data_source(data_source))
|
11
5
|
end
|
12
6
|
|
13
7
|
def self.query(data_source, query_text)
|
@@ -16,4 +10,40 @@ class Birt::Core::Mysql
|
|
16
10
|
yield(results) if block_given?
|
17
11
|
results
|
18
12
|
end
|
19
|
-
|
13
|
+
def self.create_client(data_source)
|
14
|
+
Mysql2::Client.new(
|
15
|
+
host: data_source.host,
|
16
|
+
port: data_source.port,
|
17
|
+
username: data_source.username,
|
18
|
+
password: data_source.password,
|
19
|
+
database: data_source.database
|
20
|
+
)
|
21
|
+
end
|
22
|
+
def self.rails_data_source
|
23
|
+
config_path = Rails.root ? File.join(Rails.root, "config", "database.yml") : './config/database.yml'
|
24
|
+
database_yml = File.open(config_path)
|
25
|
+
dbconfig = YAML::load(database_yml)
|
26
|
+
dbconfig = dbconfig[Rails.env] if defined? Rails
|
27
|
+
data_source = Birt::Core::DataSource.new do |item|
|
28
|
+
item.set_host dbconfig['host']
|
29
|
+
item.port = dbconfig['port'] ||= 3306
|
30
|
+
item.username = dbconfig['username']
|
31
|
+
item.password = dbconfig['password']
|
32
|
+
item.database = dbconfig['database']
|
33
|
+
end
|
34
|
+
data_source
|
35
|
+
end
|
36
|
+
def self.choose_data_source(data_source = nil)
|
37
|
+
return rails_data_source if data_source.nil?
|
38
|
+
config_path = Rails.root ? File.join(Rails.root, "config", "birt.yml") : './config/birt.yml'
|
39
|
+
if (File.exist?(config_path))
|
40
|
+
config = YAML.load(ERB.new(File.new(config_path).read).result)
|
41
|
+
config = config[Rails.env] if defined? Rails
|
42
|
+
end
|
43
|
+
if "rptdesign" == config["datasource"]
|
44
|
+
data_source
|
45
|
+
else
|
46
|
+
rails_data_source
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
data/lib/birt/core/rpt_design.rb
CHANGED
@@ -40,7 +40,7 @@ class Birt::Core::RptDesign
|
|
40
40
|
|
41
41
|
#数据源
|
42
42
|
_root.each_element(xpath = '/report/data-sources/oda-data-source') do |item|
|
43
|
-
|
43
|
+
@data_sources[item.attribute(:name).value] = Birt::Core::DataSource.new(item)
|
44
44
|
end
|
45
45
|
|
46
46
|
#数据集
|
@@ -72,4 +72,4 @@ class Birt::Core::RptDesign
|
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
75
|
-
end
|
75
|
+
end
|
data/lib/birt/version.rb
CHANGED
data/lib/birt.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: birt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- saxer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-08-
|
11
|
+
date: 2015-08-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 4.2.3
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.2'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3.2'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: bundler
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,6 +108,20 @@ dependencies:
|
|
94
108
|
- - "~>"
|
95
109
|
- !ruby/object:Gem::Version
|
96
110
|
version: 0.3.18
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: pry
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
97
125
|
description: birt report
|
98
126
|
email:
|
99
127
|
- 15201280641@qq.com
|
@@ -114,6 +142,8 @@ files:
|
|
114
142
|
- app/assets/stylesheets/birt/components/loading.scss
|
115
143
|
- app/assets/stylesheets/birt/components/table.scss
|
116
144
|
- app/views/birt/api/index.json.jbuilder
|
145
|
+
- config/birt.yml
|
146
|
+
- config/database.yml
|
117
147
|
- config/routes.rb
|
118
148
|
- lib/app/controllers/birt/api_controller.rb
|
119
149
|
- lib/app/helpers/application_helper.rb
|