easy_reports 0.0.11 → 0.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9a302a193c8ff80d4a4ea8642339fb0040731ad4
4
- data.tar.gz: 6b18432abc312199315d3e7c88036763e4af93a4
3
+ metadata.gz: 2a06454a1c40dda15773fbff6ccaded3fb50bda7
4
+ data.tar.gz: a65e2e88df4ac14a947d4699087cbab9152a21fc
5
5
  SHA512:
6
- metadata.gz: 169245d4b47377e168ffca34548e6139ecb47698678cd433f147980108fb266c062fe25c3f94cd6237f6cc21d4600b7f2bea685e9c4d813ff4f131a3edb2b531
7
- data.tar.gz: e3d3e5efe13017087bf2fc2d32bd34a425bdf8bcabb655cf12928ebe1c49b4e16372b6fc4aead8ac56fbaba3341194d712cc1ddf2e4ff04ff28eb549203cc7e7
6
+ metadata.gz: 67e0bdb44d5036c23b1dc0853a6d1ad5102b9c4f6ce8ba4b3c6fd0dc624245e164db3abf8391e47574fca8c4395dcb906501eed58edf9a6467374e2bea0df734
7
+ data.tar.gz: 48ffd8a838edc8cfef7317cb63e183f19fce2a1b75ada83df7a2de06db676e35ca9265e35d223686967aabf300f7ed5d09e3962fa56eb85da63e9a3e15d96409
@@ -8,21 +8,8 @@ module EasyReports
8
8
  @reports = Report.all
9
9
 
10
10
  # TODO: remove into service
11
- @old_connection = ActiveRecord::Base.connection
12
- db_config = EasyReports::DatabaseConfig.last
13
-
14
- ActiveRecord::Base.establish_connection(
15
- adapter: db_config.adapter,
16
- encoding: db_config.encoding,
17
- pool: db_config.pool,
18
- username: db_config.username,
19
- password: db_config.password,
20
- host: db_config.host,
21
- database: db_config.database
22
- )
23
- @table_list = ActiveRecord::Base.connection.tables
24
- ActiveRecord::Base.establish_connection("#{Rails.env}")
25
-
11
+ database_mediator = EasyReports::DatabaseMediator.new
12
+ @table_list = database_mediator.tables
26
13
  end
27
14
 
28
15
  def show
@@ -0,0 +1,18 @@
1
+ module EasyReports
2
+ class DatabaseMediator
3
+
4
+ attr_reader :db
5
+
6
+ def initialize
7
+ db_config = EasyReports::DatabaseConfig.last
8
+
9
+ @db = ::Sequel.connect(
10
+ "#{db_config.adapter}://#{db_config.username}:#{db_config.password}@#{db_config.host}:#{db_config.port}/#{db_config.database}",
11
+ :max_connections => db_config.pool, :logger => Logger.new('log/db.log'))
12
+ end
13
+
14
+ def tables
15
+ db.tables
16
+ end
17
+ end
18
+ end
@@ -25,6 +25,9 @@
25
25
  = f.label :host
26
26
  = f.text_field :host
27
27
  .field
28
- = f.label :database
29
- = f.text_field :database
28
+ = f.label :port
29
+ = f.text_field :port
30
+ .field
31
+ = f.label :database_name
32
+ = f.text_field :database_name
30
33
  .actions = f.submit 'Save'
@@ -3,11 +3,12 @@ class CreateEasyReportsDatabaseConfigs < ActiveRecord::Migration
3
3
  create_table :easy_reports_database_configs do |t|
4
4
  t.string :adapter
5
5
  t.string :encoding
6
- t.string :pool
6
+ t.integer :pool
7
7
  t.string :username
8
8
  t.string :password
9
9
  t.string :host
10
- t.string :database
10
+ t.integer :port
11
+ t.string :database_name
11
12
 
12
13
  t.timestamps
13
14
  end
@@ -1,3 +1,3 @@
1
1
  module EasyReports
2
- VERSION = "0.0.11"
2
+ VERSION = "0.0.13"
3
3
  end
data/lib/easy_reports.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  require "easy_reports/engine"
2
2
  require "easy_reports/version"
3
+ require "sequel"
4
+ DB = Sequel.postgres
3
5
 
4
6
  module EasyReports
5
7
  end
data/test/dummy/Gemfile CHANGED
@@ -7,5 +7,6 @@ gem 'slim'
7
7
 
8
8
  gem 'thin'
9
9
  gem 'pg'
10
+ gem 'sequel'
10
11
 
11
12
  # gem "rails"
@@ -1,10 +1,11 @@
1
1
  PATH
2
2
  remote: ../..
3
3
  specs:
4
- easy_reports (0.0.10)
4
+ easy_reports (0.0.11)
5
+ pg
5
6
  rails (~> 4.1.8)
7
+ sequel
6
8
  slim
7
- slim-rails
8
9
 
9
10
  GEM
10
11
  remote: https://rubygems.org/
@@ -68,14 +69,10 @@ GEM
68
69
  rake (>= 0.8.7)
69
70
  thor (>= 0.18.1, < 2.0)
70
71
  rake (10.4.2)
72
+ sequel (4.17.0)
71
73
  slim (2.1.0)
72
74
  temple (~> 0.6.9)
73
75
  tilt (>= 1.3.3, < 2.1)
74
- slim-rails (2.1.5)
75
- actionpack (>= 3.0, < 4.2)
76
- activesupport (>= 3.0, < 4.2)
77
- railties (>= 3.0, < 4.2)
78
- slim (~> 2.0)
79
76
  sprockets (2.12.3)
80
77
  hike (~> 1.2)
81
78
  multi_json (~> 1.0)
@@ -103,6 +100,7 @@ PLATFORMS
103
100
  DEPENDENCIES
104
101
  easy_reports!
105
102
  pg
103
+ sequel
106
104
  slim
107
105
  sqlite3
108
106
  thin
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: easy_reports
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Davydenkov Mihail
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-13 00:00:00.000000000 Z
11
+ date: 2014-12-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -123,6 +123,7 @@ files:
123
123
  - app/helpers/easy_reports/reports_helper.rb
124
124
  - app/models/easy_reports/database_config.rb
125
125
  - app/models/easy_reports/report.rb
126
+ - app/services/easy_reports/database_mediator.rb
126
127
  - app/views/easy_reports/database_configs/_form.html.slim
127
128
  - app/views/easy_reports/database_configs/edit.html.slim
128
129
  - app/views/easy_reports/database_configs/index.html.slim
@@ -180,8 +181,6 @@ files:
180
181
  - test/dummy/config/locales/en.yml
181
182
  - test/dummy/config/routes.rb
182
183
  - test/dummy/config/secrets.yml
183
- - test/dummy/db/migrate/20141207144158_create_easy_reports_reports.easy_reports.rb
184
- - test/dummy/db/migrate/20141213190452_create_easy_reports_database_configs.easy_reports.rb
185
184
  - test/dummy/db/schema.rb
186
185
  - test/dummy/lib/assets/.keep
187
186
  - test/dummy/log/.keep
@@ -257,8 +256,6 @@ test_files:
257
256
  - test/dummy/config/locales/en.yml
258
257
  - test/dummy/config/routes.rb
259
258
  - test/dummy/config/secrets.yml
260
- - test/dummy/db/migrate/20141207144158_create_easy_reports_reports.easy_reports.rb
261
- - test/dummy/db/migrate/20141213190452_create_easy_reports_database_configs.easy_reports.rb
262
259
  - test/dummy/db/schema.rb
263
260
  - test/dummy/lib/assets/.keep
264
261
  - test/dummy/log/.keep
@@ -1,11 +0,0 @@
1
- # This migration comes from easy_reports (originally 20141207141745)
2
- class CreateEasyReportsReports < ActiveRecord::Migration
3
- def change
4
- create_table :easy_reports_reports do |t|
5
- t.string :title
6
- t.text :description
7
-
8
- t.timestamps
9
- end
10
- end
11
- end
@@ -1,16 +0,0 @@
1
- # This migration comes from easy_reports (originally 20141213173509)
2
- class CreateEasyReportsDatabaseConfigs < ActiveRecord::Migration
3
- def change
4
- create_table :easy_reports_database_configs do |t|
5
- t.string :adapter
6
- t.string :encoding
7
- t.string :pool
8
- t.string :username
9
- t.string :password
10
- t.string :host
11
- t.string :database
12
-
13
- t.timestamps
14
- end
15
- end
16
- end