easy_reports 0.0.10 → 0.0.11

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: 8025e7cfe8e938dfc483d1eae4d22d8c61a65274
4
- data.tar.gz: fb88b02443d7c147a7ec58e3e20f4455342f9c58
3
+ metadata.gz: 9a302a193c8ff80d4a4ea8642339fb0040731ad4
4
+ data.tar.gz: 6b18432abc312199315d3e7c88036763e4af93a4
5
5
  SHA512:
6
- metadata.gz: 7ea634e086940d697ca2849e43c619b38e07563a1ea6b443e153c3049125419319ee98d661954cd7feae5963afff029a9258d541259a4c3d8d7f81c020016444
7
- data.tar.gz: 1162f6f60b3d72a6e5b85c25f71ce6651216b395cda0a0749cb8739ee65b0d2bddf0494f14efb78fadfc7b1b9de4b2108b2e7abd6fb1ad8c32d8b0f28ff40acb
6
+ metadata.gz: 169245d4b47377e168ffca34548e6139ecb47698678cd433f147980108fb266c062fe25c3f94cd6237f6cc21d4600b7f2bea685e9c4d813ff4f131a3edb2b531
7
+ data.tar.gz: e3d3e5efe13017087bf2fc2d32bd34a425bdf8bcabb655cf12928ebe1c49b4e16372b6fc4aead8ac56fbaba3341194d712cc1ddf2e4ff04ff28eb549203cc7e7
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,53 @@
1
+ require_dependency "easy_reports/application_controller"
2
+
3
+ module EasyReports
4
+ class DatabaseConfigsController < ApplicationController
5
+ before_action :set_database_config, only: [:show, :edit, :update, :destroy]
6
+
7
+ def index
8
+ @database_configs = DatabaseConfig.all
9
+ end
10
+
11
+ def show
12
+ end
13
+
14
+ def new
15
+ @database_config = DatabaseConfig.new
16
+ end
17
+
18
+ def edit
19
+ end
20
+
21
+ def create
22
+ @database_config = DatabaseConfig.new(database_config_params)
23
+
24
+ if @database_config.save
25
+ redirect_to @database_config, notice: 'Database config was successfully created.'
26
+ else
27
+ render :new
28
+ end
29
+ end
30
+
31
+ def update
32
+ if @database_config.update(database_config_params)
33
+ redirect_to @database_config, notice: 'Database config was successfully updated.'
34
+ else
35
+ render :edit
36
+ end
37
+ end
38
+
39
+ def destroy
40
+ @database_config.destroy
41
+ redirect_to database_configs_url, notice: 'Database config was successfully destroyed.'
42
+ end
43
+
44
+ private
45
+ def set_database_config
46
+ @database_config = DatabaseConfig.find(params[:id])
47
+ end
48
+
49
+ def database_config_params
50
+ params.require(:database_config).permit(:adapter, :encoding, :pool, :username, :password, :host, :database)
51
+ end
52
+ end
53
+ end
@@ -4,25 +4,37 @@ module EasyReports
4
4
  class ReportsController < ApplicationController
5
5
  before_action :set_report, only: [:show, :edit, :update, :destroy]
6
6
 
7
- # GET /reports
8
7
  def index
9
8
  @reports = Report.all
9
+
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
+
10
26
  end
11
27
 
12
- # GET /reports/1
13
28
  def show
14
29
  end
15
30
 
16
- # GET /reports/new
17
31
  def new
18
32
  @report = Report.new
19
33
  end
20
34
 
21
- # GET /reports/1/edit
22
35
  def edit
23
36
  end
24
37
 
25
- # POST /reports
26
38
  def create
27
39
  @report = Report.new(report_params)
28
40
 
@@ -33,7 +45,6 @@ module EasyReports
33
45
  end
34
46
  end
35
47
 
36
- # PATCH/PUT /reports/1
37
48
  def update
38
49
  if @report.update(report_params)
39
50
  redirect_to @report, notice: 'Report was successfully updated.'
@@ -42,19 +53,16 @@ module EasyReports
42
53
  end
43
54
  end
44
55
 
45
- # DELETE /reports/1
46
56
  def destroy
47
57
  @report.destroy
48
58
  redirect_to reports_url, notice: 'Report was successfully destroyed.'
49
59
  end
50
60
 
51
61
  private
52
- # Use callbacks to share common setup or constraints between actions.
53
62
  def set_report
54
63
  @report = Report.find(params[:id])
55
64
  end
56
65
 
57
- # Only allow a trusted parameter "white list" through.
58
66
  def report_params
59
67
  params.require(:report).permit(:title, :description)
60
68
  end
@@ -0,0 +1,4 @@
1
+ module EasyReports
2
+ module DatabaseConfigsHelper
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module EasyReports
2
+ class DatabaseConfig < ActiveRecord::Base
3
+ end
4
+ end
@@ -0,0 +1,30 @@
1
+ = form_for @database_config do |f|
2
+ - if @database_config.errors.any?
3
+ #error_explanation
4
+ h2 = "#{pluralize(@database_config.errors.count, "error")} prohibited this database_config from being saved:"
5
+ ul
6
+ - @database_config.errors.full_messages.each do |message|
7
+ li = message
8
+
9
+ .field
10
+ = f.label :adapter
11
+ = f.text_field :adapter
12
+ .field
13
+ = f.label :encoding
14
+ = f.text_field :encoding
15
+ .field
16
+ = f.label :pool
17
+ = f.text_field :pool
18
+ .field
19
+ = f.label :username
20
+ = f.text_field :username
21
+ .field
22
+ = f.label :password
23
+ = f.text_field :password
24
+ .field
25
+ = f.label :host
26
+ = f.text_field :host
27
+ .field
28
+ = f.label :database
29
+ = f.text_field :database
30
+ .actions = f.submit 'Save'
@@ -0,0 +1,8 @@
1
+ h1 Editing database_config
2
+
3
+ == render 'form'
4
+
5
+ = link_to 'Show', @database_config
6
+ '|
7
+ = link_to 'Back', database_configs_path
8
+
@@ -0,0 +1,33 @@
1
+ h1 Listing database_configs
2
+
3
+ table
4
+ thead
5
+ tr
6
+ th Adapter
7
+ th Encoding
8
+ th Pool
9
+ th Username
10
+ th Password
11
+ th Host
12
+ th Database
13
+ th
14
+ th
15
+ th
16
+
17
+ tbody
18
+ - @database_configs.each do |database_config|
19
+ tr
20
+ td = database_config.adapter
21
+ td = database_config.encoding
22
+ td = database_config.pool
23
+ td = database_config.username
24
+ td = database_config.password
25
+ td = database_config.host
26
+ td = database_config.database
27
+ td = link_to 'Show', database_config
28
+ td = link_to 'Edit', edit_database_config_path(database_config)
29
+ td = link_to 'Destroy', database_config, data: {:confirm => 'Are you sure?'}, :method => :delete
30
+
31
+ br
32
+
33
+ = link_to 'New Database config', new_database_config_path
@@ -0,0 +1,5 @@
1
+ h1 New database_config
2
+
3
+ == render 'form'
4
+
5
+ = link_to 'Back', database_configs_path
@@ -0,0 +1,27 @@
1
+ p#notice = notice
2
+
3
+ p
4
+ strong Adapter:
5
+ = @database_config.adapter
6
+ p
7
+ strong Encoding:
8
+ = @database_config.encoding
9
+ p
10
+ strong Pool:
11
+ = @database_config.pool
12
+ p
13
+ strong Username:
14
+ = @database_config.username
15
+ p
16
+ strong Password:
17
+ = @database_config.password
18
+ p
19
+ strong Host:
20
+ = @database_config.host
21
+ p
22
+ strong Database:
23
+ = @database_config.database
24
+
25
+ = link_to 'Edit', edit_database_config_path(@database_config)
26
+ '|
27
+ = link_to 'Back', database_configs_path
@@ -21,3 +21,6 @@ table
21
21
  br
22
22
 
23
23
  = link_to 'New Report', new_report_path
24
+
25
+ - @table_list.each do |table|
26
+ p = table
data/config/routes.rb CHANGED
@@ -1,4 +1,8 @@
1
1
  EasyReports::Engine.routes.draw do
2
+
3
+ root to: 'reports#index'
2
4
  get 'dashboard', to: 'reports#index', as: 'reports'
3
5
  resource :report
6
+
7
+ resources :database_configs
4
8
  end
@@ -0,0 +1,15 @@
1
+ class CreateEasyReportsDatabaseConfigs < ActiveRecord::Migration
2
+ def change
3
+ create_table :easy_reports_database_configs do |t|
4
+ t.string :adapter
5
+ t.string :encoding
6
+ t.string :pool
7
+ t.string :username
8
+ t.string :password
9
+ t.string :host
10
+ t.string :database
11
+
12
+ t.timestamps
13
+ end
14
+ end
15
+ end
data/easy_reports.gemspec CHANGED
@@ -26,5 +26,6 @@ Gem::Specification.new do |spec|
26
26
  spec.add_development_dependency "bundler", "~> 1.7"
27
27
  spec.add_development_dependency "rake", "~> 10.0"
28
28
  spec.add_dependency "slim"
29
- spec.add_dependency "slim-rails"
29
+ spec.add_dependency "pg"
30
+ spec.add_dependency "sequel"
30
31
  end
@@ -1,3 +1,3 @@
1
1
  module EasyReports
2
- VERSION = "0.0.10"
2
+ VERSION = "0.0.11"
3
3
  end
@@ -0,0 +1,51 @@
1
+ require 'test_helper'
2
+
3
+ module EasyReports
4
+ class DatabaseConfigsControllerTest < ActionController::TestCase
5
+ setup do
6
+ @database_config = database_configs(:one)
7
+ end
8
+
9
+ test "should get index" do
10
+ get :index
11
+ assert_response :success
12
+ assert_not_nil assigns(:database_configs)
13
+ end
14
+
15
+ test "should get new" do
16
+ get :new
17
+ assert_response :success
18
+ end
19
+
20
+ test "should create database_config" do
21
+ assert_difference('DatabaseConfig.count') do
22
+ post :create, database_config: { adapter: @database_config.adapter, database: @database_config.database, encoding: @database_config.encoding, host: @database_config.host, password: @database_config.password, pool: @database_config.pool, username: @database_config.username }
23
+ end
24
+
25
+ assert_redirected_to database_config_path(assigns(:database_config))
26
+ end
27
+
28
+ test "should show database_config" do
29
+ get :show, id: @database_config
30
+ assert_response :success
31
+ end
32
+
33
+ test "should get edit" do
34
+ get :edit, id: @database_config
35
+ assert_response :success
36
+ end
37
+
38
+ test "should update database_config" do
39
+ patch :update, id: @database_config, database_config: { adapter: @database_config.adapter, database: @database_config.database, encoding: @database_config.encoding, host: @database_config.host, password: @database_config.password, pool: @database_config.pool, username: @database_config.username }
40
+ assert_redirected_to database_config_path(assigns(:database_config))
41
+ end
42
+
43
+ test "should destroy database_config" do
44
+ assert_difference('DatabaseConfig.count', -1) do
45
+ delete :destroy, id: @database_config
46
+ end
47
+
48
+ assert_redirected_to database_configs_path
49
+ end
50
+ end
51
+ end
data/test/dummy/Gemfile CHANGED
@@ -5,4 +5,7 @@ gem 'sqlite3'
5
5
  gem 'easy_reports', path: '../..'
6
6
  gem 'slim'
7
7
 
8
+ gem 'thin'
9
+ gem 'pg'
10
+
8
11
  # gem "rails"
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../..
3
3
  specs:
4
- easy_reports (0.0.9)
4
+ easy_reports (0.0.10)
5
5
  rails (~> 4.1.8)
6
6
  slim
7
7
  slim-rails
@@ -37,7 +37,9 @@ GEM
37
37
  tzinfo (~> 1.1)
38
38
  arel (5.0.1.20140414130214)
39
39
  builder (3.2.2)
40
+ daemons (1.1.9)
40
41
  erubis (2.7.0)
42
+ eventmachine (1.0.3)
41
43
  hike (1.2.3)
42
44
  i18n (0.6.11)
43
45
  json (1.8.1)
@@ -46,6 +48,7 @@ GEM
46
48
  mime-types (2.4.3)
47
49
  minitest (5.4.3)
48
50
  multi_json (1.10.1)
51
+ pg (0.17.1)
49
52
  rack (1.5.2)
50
53
  rack-test (0.6.2)
51
54
  rack (>= 1.0)
@@ -84,6 +87,10 @@ GEM
84
87
  sprockets (>= 2.8, < 4.0)
85
88
  sqlite3 (1.3.10)
86
89
  temple (0.6.10)
90
+ thin (1.6.2)
91
+ daemons (>= 1.0.9)
92
+ eventmachine (>= 1.0.0)
93
+ rack (>= 1.0.0)
87
94
  thor (0.19.1)
88
95
  thread_safe (0.3.4)
89
96
  tilt (1.4.1)
@@ -95,5 +102,7 @@ PLATFORMS
95
102
 
96
103
  DEPENDENCIES
97
104
  easy_reports!
105
+ pg
98
106
  slim
99
107
  sqlite3
108
+ thin
@@ -0,0 +1,16 @@
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
@@ -11,7 +11,19 @@
11
11
  #
12
12
  # It's strongly recommended that you check this file into your version control system.
13
13
 
14
- ActiveRecord::Schema.define(version: 20141207144158) do
14
+ ActiveRecord::Schema.define(version: 20141213190452) do
15
+
16
+ create_table "easy_reports_database_configs", force: true do |t|
17
+ t.string "adapter"
18
+ t.string "encoding"
19
+ t.string "pool"
20
+ t.string "username"
21
+ t.string "password"
22
+ t.string "host"
23
+ t.string "database"
24
+ t.datetime "created_at"
25
+ t.datetime "updated_at"
26
+ end
15
27
 
16
28
  create_table "easy_reports_reports", force: true do |t|
17
29
  t.string "title"
@@ -0,0 +1,19 @@
1
+ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
2
+
3
+ one:
4
+ adapter: MyString
5
+ encoding: MyString
6
+ pool: MyString
7
+ username: MyString
8
+ password: MyString
9
+ host: MyString
10
+ database: MyString
11
+
12
+ two:
13
+ adapter: MyString
14
+ encoding: MyString
15
+ pool: MyString
16
+ username: MyString
17
+ password: MyString
18
+ host: MyString
19
+ database: MyString
@@ -0,0 +1,6 @@
1
+ require 'test_helper'
2
+
3
+ module EasyReports
4
+ class DatabaseConfigsHelperTest < ActionView::TestCase
5
+ end
6
+ end
@@ -0,0 +1,9 @@
1
+ require 'test_helper'
2
+
3
+ module EasyReports
4
+ class DatabaseConfigTest < ActiveSupport::TestCase
5
+ # test "the truth" do
6
+ # assert true
7
+ # end
8
+ end
9
+ end
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.10
4
+ version: 0.0.11
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-07 00:00:00.000000000 Z
11
+ date: 2014-12-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -67,7 +67,21 @@ dependencies:
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: slim-rails
70
+ name: pg
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: sequel
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
73
87
  - - ">="
@@ -95,15 +109,25 @@ files:
95
109
  - Rakefile
96
110
  - app/assets/images/easy_reports/.keep
97
111
  - app/assets/javascripts/easy_reports/application.js
112
+ - app/assets/javascripts/easy_reports/database_configs.js
98
113
  - app/assets/javascripts/easy_reports/reports.js
99
114
  - app/assets/stylesheets/easy_reports/application.css
115
+ - app/assets/stylesheets/easy_reports/database_configs.css
100
116
  - app/assets/stylesheets/easy_reports/reports.css
101
117
  - app/assets/stylesheets/scaffold.css
102
118
  - app/controllers/easy_reports/application_controller.rb
119
+ - app/controllers/easy_reports/database_configs_controller.rb
103
120
  - app/controllers/easy_reports/reports_controller.rb
104
121
  - app/helpers/easy_reports/application_helper.rb
122
+ - app/helpers/easy_reports/database_configs_helper.rb
105
123
  - app/helpers/easy_reports/reports_helper.rb
124
+ - app/models/easy_reports/database_config.rb
106
125
  - app/models/easy_reports/report.rb
126
+ - app/views/easy_reports/database_configs/_form.html.slim
127
+ - app/views/easy_reports/database_configs/edit.html.slim
128
+ - app/views/easy_reports/database_configs/index.html.slim
129
+ - app/views/easy_reports/database_configs/new.html.slim
130
+ - app/views/easy_reports/database_configs/show.html.slim
107
131
  - app/views/easy_reports/reports/_form.html.slim
108
132
  - app/views/easy_reports/reports/edit.html.slim
109
133
  - app/views/easy_reports/reports/index.html.slim
@@ -113,11 +137,13 @@ files:
113
137
  - bin/rails
114
138
  - config/routes.rb
115
139
  - db/migrate/20141207141745_create_easy_reports_reports.rb
140
+ - db/migrate/20141213173509_create_easy_reports_database_configs.rb
116
141
  - easy_reports.gemspec
117
142
  - lib/easy_reports.rb
118
143
  - lib/easy_reports/engine.rb
119
144
  - lib/easy_reports/version.rb
120
145
  - lib/tasks/easy_reports_tasks.rake
146
+ - test/controllers/easy_reports/database_configs_controller_test.rb
121
147
  - test/controllers/easy_reports/reports_controller_test.rb
122
148
  - test/dummy/Gemfile
123
149
  - test/dummy/Gemfile.lock
@@ -155,6 +181,7 @@ files:
155
181
  - test/dummy/config/routes.rb
156
182
  - test/dummy/config/secrets.yml
157
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
158
185
  - test/dummy/db/schema.rb
159
186
  - test/dummy/lib/assets/.keep
160
187
  - test/dummy/log/.keep
@@ -162,8 +189,11 @@ files:
162
189
  - test/dummy/public/422.html
163
190
  - test/dummy/public/500.html
164
191
  - test/dummy/public/favicon.ico
192
+ - test/fixtures/easy_reports/database_configs.yml
165
193
  - test/fixtures/easy_reports/reports.yml
194
+ - test/helpers/easy_reports/database_configs_helper_test.rb
166
195
  - test/helpers/easy_reports/reports_helper_test.rb
196
+ - test/models/easy_reports/database_config_test.rb
167
197
  - test/models/easy_reports/report_test.rb
168
198
  homepage: http://github.com/DavydenkovM/easy_reports.git
169
199
  licenses:
@@ -190,6 +220,7 @@ signing_key:
190
220
  specification_version: 4
191
221
  summary: Add reports dashboard in your rails app
192
222
  test_files:
223
+ - test/controllers/easy_reports/database_configs_controller_test.rb
193
224
  - test/controllers/easy_reports/reports_controller_test.rb
194
225
  - test/dummy/Gemfile
195
226
  - test/dummy/Gemfile.lock
@@ -227,6 +258,7 @@ test_files:
227
258
  - test/dummy/config/routes.rb
228
259
  - test/dummy/config/secrets.yml
229
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
230
262
  - test/dummy/db/schema.rb
231
263
  - test/dummy/lib/assets/.keep
232
264
  - test/dummy/log/.keep
@@ -234,6 +266,9 @@ test_files:
234
266
  - test/dummy/public/422.html
235
267
  - test/dummy/public/500.html
236
268
  - test/dummy/public/favicon.ico
269
+ - test/fixtures/easy_reports/database_configs.yml
237
270
  - test/fixtures/easy_reports/reports.yml
271
+ - test/helpers/easy_reports/database_configs_helper_test.rb
238
272
  - test/helpers/easy_reports/reports_helper_test.rb
273
+ - test/models/easy_reports/database_config_test.rb
239
274
  - test/models/easy_reports/report_test.rb