dbview_cti 0.0.1
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.
- data/.gitignore +9 -0
- data/Gemfile +31 -0
- data/MIT-LICENSE +20 -0
- data/README.md +219 -0
- data/Rakefile +27 -0
- data/dbview_cti.gemspec +24 -0
- data/lib/db_view_cti/connection_adapters/schema_statements.rb +44 -0
- data/lib/db_view_cti/loader.rb +19 -0
- data/lib/db_view_cti/migration/command_recorder.rb +19 -0
- data/lib/db_view_cti/model/cti.rb +129 -0
- data/lib/db_view_cti/model/extensions.rb +25 -0
- data/lib/db_view_cti/names.rb +33 -0
- data/lib/db_view_cti/railtie.rb +11 -0
- data/lib/db_view_cti/sql_generation/migration/base.rb +92 -0
- data/lib/db_view_cti/sql_generation/migration/factory.rb +19 -0
- data/lib/db_view_cti/sql_generation/migration/postgresql.rb +107 -0
- data/lib/db_view_cti/sql_generation/model.rb +60 -0
- data/lib/db_view_cti/version.rb +3 -0
- data/lib/dbview_cti.rb +35 -0
- data/lib/tasks/view-based-cti_tasks.rake +4 -0
- data/spec/dummy-rails-3/.rspec +1 -0
- data/spec/dummy-rails-3/Rakefile +7 -0
- data/spec/dummy-rails-3/app/assets/javascripts/application.js +15 -0
- data/spec/dummy-rails-3/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy-rails-3/app/controllers/application_controller.rb +3 -0
- data/spec/dummy-rails-3/app/helpers/application_helper.rb +2 -0
- data/spec/dummy-rails-3/app/mailers/.gitkeep +0 -0
- data/spec/dummy-rails-3/app/models/.gitkeep +0 -0
- data/spec/dummy-rails-3/app/models/car.rb +4 -0
- data/spec/dummy-rails-3/app/models/motor_cycle.rb +4 -0
- data/spec/dummy-rails-3/app/models/motor_vehicle.rb +4 -0
- data/spec/dummy-rails-3/app/models/rocket_engine.rb +4 -0
- data/spec/dummy-rails-3/app/models/space_ship.rb +4 -0
- data/spec/dummy-rails-3/app/models/space_shuttle.rb +4 -0
- data/spec/dummy-rails-3/app/models/vehicle.rb +4 -0
- data/spec/dummy-rails-3/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy-rails-3/config/application.rb +68 -0
- data/spec/dummy-rails-3/config/boot.rb +10 -0
- data/spec/dummy-rails-3/config/database.yml +37 -0
- data/spec/dummy-rails-3/config/environment.rb +5 -0
- data/spec/dummy-rails-3/config/environments/development.rb +37 -0
- data/spec/dummy-rails-3/config/environments/production.rb +67 -0
- data/spec/dummy-rails-3/config/environments/test.rb +37 -0
- data/spec/dummy-rails-3/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy-rails-3/config/initializers/dbview_cti.rb +8 -0
- data/spec/dummy-rails-3/config/initializers/inflections.rb +15 -0
- data/spec/dummy-rails-3/config/initializers/mime_types.rb +5 -0
- data/spec/dummy-rails-3/config/initializers/secret_token.rb +7 -0
- data/spec/dummy-rails-3/config/initializers/session_store.rb +8 -0
- data/spec/dummy-rails-3/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy-rails-3/config/locales/en.yml +5 -0
- data/spec/dummy-rails-3/config/routes.rb +58 -0
- data/spec/dummy-rails-3/config.ru +4 -0
- data/spec/dummy-rails-3/db/migrate/20130711214909_create_vehicles.rb +10 -0
- data/spec/dummy-rails-3/db/migrate/20130713133605_create_motor_vehicles.rb +13 -0
- data/spec/dummy-rails-3/db/migrate/20130713133705_create_cars.rb +13 -0
- data/spec/dummy-rails-3/db/migrate/20130713153631_create_motor_cycles.rb +12 -0
- data/spec/dummy-rails-3/db/migrate/20130816022212_create_space_ships.rb +13 -0
- data/spec/dummy-rails-3/db/migrate/20130817014120_create_space_shuttles.rb +14 -0
- data/spec/dummy-rails-3/db/migrate/20130817024220_create_rocket_engines.rb +12 -0
- data/spec/dummy-rails-3/db/migrate/20130819040414_add_reliability_to_space_ships.rb +13 -0
- data/spec/dummy-rails-3/db/schema.rb +74 -0
- data/spec/dummy-rails-3/lib/assets/.gitkeep +0 -0
- data/spec/dummy-rails-3/log/.gitkeep +0 -0
- data/spec/dummy-rails-3/public/404.html +26 -0
- data/spec/dummy-rails-3/public/422.html +26 -0
- data/spec/dummy-rails-3/public/500.html +25 -0
- data/spec/dummy-rails-3/public/favicon.ico +0 -0
- data/spec/dummy-rails-3/script/rails +6 -0
- data/spec/dummy-rails-4/.rspec +1 -0
- data/spec/dummy-rails-4/Rakefile +6 -0
- data/spec/dummy-rails-4/app/assets/images/.keep +0 -0
- data/spec/dummy-rails-4/app/assets/javascripts/application.js +13 -0
- data/spec/dummy-rails-4/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy-rails-4/app/controllers/application_controller.rb +5 -0
- data/spec/dummy-rails-4/app/controllers/concerns/.keep +0 -0
- data/spec/dummy-rails-4/app/helpers/application_helper.rb +2 -0
- data/spec/dummy-rails-4/app/mailers/.keep +0 -0
- data/spec/dummy-rails-4/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy-rails-4/bin/bundle +3 -0
- data/spec/dummy-rails-4/bin/rails +4 -0
- data/spec/dummy-rails-4/bin/rake +4 -0
- data/spec/dummy-rails-4/config/application.rb +28 -0
- data/spec/dummy-rails-4/config/boot.rb +5 -0
- data/spec/dummy-rails-4/config/database.yml +37 -0
- data/spec/dummy-rails-4/config/environment.rb +5 -0
- data/spec/dummy-rails-4/config/environments/development.rb +29 -0
- data/spec/dummy-rails-4/config/environments/production.rb +80 -0
- data/spec/dummy-rails-4/config/environments/test.rb +36 -0
- data/spec/dummy-rails-4/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy-rails-4/config/initializers/dbview_cti.rb +8 -0
- data/spec/dummy-rails-4/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy-rails-4/config/initializers/inflections.rb +16 -0
- data/spec/dummy-rails-4/config/initializers/mime_types.rb +5 -0
- data/spec/dummy-rails-4/config/initializers/secret_token.rb +12 -0
- data/spec/dummy-rails-4/config/initializers/session_store.rb +3 -0
- data/spec/dummy-rails-4/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy-rails-4/config/locales/en.yml +23 -0
- data/spec/dummy-rails-4/config/routes.rb +56 -0
- data/spec/dummy-rails-4/config.ru +4 -0
- data/spec/dummy-rails-4/db/schema.rb +74 -0
- data/spec/dummy-rails-4/lib/assets/.keep +0 -0
- data/spec/dummy-rails-4/log/.keep +0 -0
- data/spec/dummy-rails-4/public/404.html +58 -0
- data/spec/dummy-rails-4/public/422.html +58 -0
- data/spec/dummy-rails-4/public/500.html +57 -0
- data/spec/dummy-rails-4/public/favicon.ico +0 -0
- data/spec/models/car_spec.rb +58 -0
- data/spec/models/motor_vehicle_spec.rb +44 -0
- data/spec/models/space_shuttle_spec.rb +22 -0
- data/spec/models/vehicle_spec.rb +90 -0
- data/spec/spec_helper.rb +40 -0
- metadata +228 -0
@@ -0,0 +1,92 @@
|
|
1
|
+
module DBViewCTI
|
2
|
+
module SQLGeneration
|
3
|
+
module Migration
|
4
|
+
class Base
|
5
|
+
|
6
|
+
def initialize(class_name, options = {})
|
7
|
+
@options = options
|
8
|
+
@derived_class = class_name.constantize
|
9
|
+
@base_class = @derived_class.superclass
|
10
|
+
@base_class_table = @base_class.table_name
|
11
|
+
@derived_class_table = DBViewCTI::Names.table_name(@derived_class)
|
12
|
+
# we assume the foreign key is in the derived class
|
13
|
+
@base_class_key = 'id'
|
14
|
+
@derived_class_key = DBViewCTI::Names.foreign_key(@base_class)
|
15
|
+
# columns in base class
|
16
|
+
@base_class_columns = @base_class.column_names
|
17
|
+
if @base_class.cti_derived_class?
|
18
|
+
# base class is itself derived, so we remove the foreign key it holds to the higher
|
19
|
+
# level class
|
20
|
+
foreign_key = DBViewCTI::Names.foreign_key(@base_class.superclass)
|
21
|
+
@base_class_columns = @base_class_columns - [ foreign_key ]
|
22
|
+
end
|
23
|
+
# columns in derived class
|
24
|
+
# first, reset table name (it might have been changed to the view name by cti_derived_class)
|
25
|
+
temp = @derived_class.table_name
|
26
|
+
@derived_class.table_name = @derived_class_table
|
27
|
+
@derived_class.reset_column_information
|
28
|
+
@derived_class_columns = @derived_class.column_names
|
29
|
+
# put back old table name (needed since the class might be used again in a next migration)
|
30
|
+
@derived_class.table_name = temp
|
31
|
+
@derived_class.reset_column_information
|
32
|
+
# names
|
33
|
+
@view_name = DBViewCTI::Names.view_name(@derived_class)
|
34
|
+
@trigger_name = DBViewCTI::Names.trigger_name(@derived_class)
|
35
|
+
# column arrays for triggers
|
36
|
+
@insert_base_class_columns = @base_class_columns - ['id']
|
37
|
+
@insert_derived_class_columns = @derived_class_columns - ['id', @derived_class_key]
|
38
|
+
@update_base_class_columns = explicit_columns(@base_class_columns) + ['updated_at']
|
39
|
+
@update_derived_class_columns = @derived_class_columns - [ @derived_class_key ]
|
40
|
+
end
|
41
|
+
|
42
|
+
def create_view_sql
|
43
|
+
base_columns = add_table_name( explicit_columns(@base_class_columns), @base_class_table).
|
44
|
+
join(', ')
|
45
|
+
derived_columns = add_table_name( @derived_class_columns - ['id', @derived_class_key], @derived_class_table).
|
46
|
+
join(', ')
|
47
|
+
query = <<-eos
|
48
|
+
CREATE VIEW #{@view_name} AS
|
49
|
+
SELECT #{@derived_class_table}.id, #{base_columns}, #{derived_columns}
|
50
|
+
FROM #{@base_class_table}
|
51
|
+
INNER JOIN #{@derived_class_table}
|
52
|
+
ON #{ add_table_name(@base_class_key, @base_class_table) } = #{ add_table_name(@derived_class_key, @derived_class_table) };
|
53
|
+
eos
|
54
|
+
end
|
55
|
+
|
56
|
+
def drop_view_sql
|
57
|
+
"DROP VIEW #{@view_name};"
|
58
|
+
end
|
59
|
+
|
60
|
+
def create_trigger_sql
|
61
|
+
# to be implemented by derived classes
|
62
|
+
raise NotImplementedError, "DBViewCTI: create_trigger_sql not implemented for this adapter."
|
63
|
+
end
|
64
|
+
|
65
|
+
def drop_trigger_sql
|
66
|
+
# to be implemented by derived classes
|
67
|
+
raise NotImplementedError, "DBViewCTI: drop_trigger_sql not implemented for this adapter."
|
68
|
+
end
|
69
|
+
|
70
|
+
private
|
71
|
+
|
72
|
+
def explicit_columns(columns)
|
73
|
+
columns - ['id', 'created_at', 'updated_at']
|
74
|
+
end
|
75
|
+
|
76
|
+
def add_table_name(columns, table_name)
|
77
|
+
return table_name + '.' + columns if columns.is_a?(String)
|
78
|
+
columns.map do |column|
|
79
|
+
table_name + '.' + column
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def update_notation(columns, source_table)
|
84
|
+
columns.map do |column|
|
85
|
+
"#{column}=#{source_table}.#{column}"
|
86
|
+
end.join(', ')
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module DBViewCTI
|
2
|
+
module SQLGeneration
|
3
|
+
module Migration
|
4
|
+
class Factory
|
5
|
+
|
6
|
+
def self.generator(class_name, options = {})
|
7
|
+
adapter_type = ActiveRecord::Base.configurations[Rails.env]['adapter']
|
8
|
+
case adapter_type
|
9
|
+
when /postgresql/
|
10
|
+
PostgreSQL.new(class_name, options)
|
11
|
+
else
|
12
|
+
raise NotImplementedError, "DBViewCTI: Unknown adapter type '#{adapter_type}'"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
module DBViewCTI
|
2
|
+
module SQLGeneration
|
3
|
+
module Migration
|
4
|
+
|
5
|
+
class PostgreSQL < Base
|
6
|
+
|
7
|
+
def create_trigger_sql
|
8
|
+
# trigger function
|
9
|
+
@trigger_func_name = DBViewCTI::Names.trigger_function_name(@derived_class)
|
10
|
+
|
11
|
+
insert_trigger_func = <<-eos
|
12
|
+
CREATE OR REPLACE FUNCTION #{trigger_func_name}()
|
13
|
+
RETURNS TRIGGER
|
14
|
+
LANGUAGE plpgsql
|
15
|
+
AS $function$
|
16
|
+
DECLARE
|
17
|
+
base_id integer;
|
18
|
+
derived_id integer;
|
19
|
+
return_row RECORD;
|
20
|
+
BEGIN
|
21
|
+
IF TG_OP = 'INSERT' THEN
|
22
|
+
-- insert into base class and return id
|
23
|
+
INSERT INTO #{@base_class_table} (#{ @insert_base_class_columns.join(', ') })
|
24
|
+
VALUES (#{ add_table_name(@insert_base_class_columns, 'NEW').join(', ') })
|
25
|
+
RETURNING #{@base_class_key}
|
26
|
+
INTO base_id;
|
27
|
+
-- insert into derived class, including foreign key
|
28
|
+
INSERT INTO #{@derived_class_table} (#{ (@insert_derived_class_columns + [@derived_class_key]).join(', ') })
|
29
|
+
VALUES (#{ add_table_name(@insert_derived_class_columns, 'NEW').join(', ') },
|
30
|
+
base_id)
|
31
|
+
RETURNING id
|
32
|
+
INTO derived_id;
|
33
|
+
-- return correct record from view
|
34
|
+
SELECT *
|
35
|
+
INTO return_row
|
36
|
+
FROM #{@view_name}
|
37
|
+
WHERE id = derived_id
|
38
|
+
LIMIT 1;
|
39
|
+
RETURN return_row;
|
40
|
+
|
41
|
+
ELSIF TG_OP = 'UPDATE' THEN
|
42
|
+
-- update base class
|
43
|
+
UPDATE #{@base_class_table}
|
44
|
+
SET #{ update_notation(@update_base_class_columns, 'NEW') }
|
45
|
+
WHERE #{@base_class_table}.#{@base_class_key} =
|
46
|
+
(SELECT #{@derived_class_key} FROM #{@derived_class_table}
|
47
|
+
WHERE #{@derived_class_table}.id = OLD.id);
|
48
|
+
-- update derived class
|
49
|
+
UPDATE #{@derived_class_table}
|
50
|
+
SET #{ update_notation(@update_derived_class_columns, 'NEW') }
|
51
|
+
WHERE #{@derived_class_table}.id = OLD.id;
|
52
|
+
-- return correct record from view
|
53
|
+
SELECT *
|
54
|
+
INTO return_row
|
55
|
+
FROM #{@view_name}
|
56
|
+
WHERE id = OLD.id
|
57
|
+
LIMIT 1;
|
58
|
+
RETURN return_row;
|
59
|
+
|
60
|
+
ELSIF TG_OP = 'DELETE' THEN
|
61
|
+
-- find foreign key (not present in view!) in derived class
|
62
|
+
SELECT #{@derived_class_key}
|
63
|
+
INTO base_id
|
64
|
+
FROM #{@derived_class_table}
|
65
|
+
WHERE id = OLD.id;
|
66
|
+
-- due to possible key constraints we first delete the derived class
|
67
|
+
DELETE FROM #{@derived_class_table}
|
68
|
+
WHERE #{@derived_class_table}.id = OLD.id;
|
69
|
+
-- delete base class
|
70
|
+
DELETE FROM #{@base_class_table}
|
71
|
+
WHERE #{@base_class_table}.#{@base_class_key} = base_id;
|
72
|
+
RETURN NULL;
|
73
|
+
|
74
|
+
END IF;
|
75
|
+
RETURN NEW;
|
76
|
+
END;
|
77
|
+
$function$;
|
78
|
+
eos
|
79
|
+
|
80
|
+
# trigger:
|
81
|
+
insert_trigger = <<-eos
|
82
|
+
CREATE TRIGGER #{@trigger_name}
|
83
|
+
INSTEAD OF INSERT OR UPDATE OR DELETE ON #{@view_name}
|
84
|
+
FOR EACH ROW
|
85
|
+
EXECUTE PROCEDURE #{trigger_func_name}();
|
86
|
+
eos
|
87
|
+
insert_trigger_func + insert_trigger
|
88
|
+
end
|
89
|
+
|
90
|
+
def drop_trigger_sql
|
91
|
+
query = <<-eos
|
92
|
+
DROP TRIGGER IF EXISTS #{@trigger_name} ON #{@view_name};
|
93
|
+
DROP FUNCTION IF EXISTS #{trigger_func_name}();
|
94
|
+
eos
|
95
|
+
end
|
96
|
+
|
97
|
+
private
|
98
|
+
|
99
|
+
def trigger_func_name
|
100
|
+
DBViewCTI::Names.trigger_function_name(@derived_class)
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module DBViewCTI
|
2
|
+
module SQLGeneration
|
3
|
+
module Model
|
4
|
+
|
5
|
+
# generates left-outer-join query used in specialize and type
|
6
|
+
def cti_outer_join_sql(id)
|
7
|
+
if !@cti_outer_join_query.nil?
|
8
|
+
return [@cti_outer_join_query + "#{id if id}", @cti_outer_join_levels]
|
9
|
+
end
|
10
|
+
start = "SELECT #{DBViewCTI::Names.table_name(self)}.id AS #{DBViewCTI::Names.foreign_key(self)}"
|
11
|
+
end_ = "\nFROM #{DBViewCTI::Names.table_name(self)}"
|
12
|
+
levels = { DBViewCTI::Names.foreign_key(self) => 0 }
|
13
|
+
level = 1
|
14
|
+
base_class = self
|
15
|
+
block = Proc.new do |klass, descendants|
|
16
|
+
start += ", #{DBViewCTI::Names.table_name(klass)}.id AS #{DBViewCTI::Names.foreign_key(klass)}"
|
17
|
+
end_ += "\nLEFT OUTER JOIN #{DBViewCTI::Names.table_name(klass)} " +
|
18
|
+
"ON #{DBViewCTI::Names.table_name(klass)}.#{DBViewCTI::Names.foreign_key(base_class)} = " +
|
19
|
+
"#{DBViewCTI::Names.table_name(base_class)}.id"
|
20
|
+
prev_base_class = base_class
|
21
|
+
base_class = klass
|
22
|
+
levels[DBViewCTI::Names.foreign_key(klass)] = level
|
23
|
+
level += 1
|
24
|
+
descendants.each(&block)
|
25
|
+
level -= 1
|
26
|
+
base_class = prev_base_class
|
27
|
+
end
|
28
|
+
@cti_descendants ||= {}
|
29
|
+
@cti_descendants.each(&block)
|
30
|
+
@cti_outer_join_query = start + end_ + "\nWHERE #{DBViewCTI::Names.table_name(self)}.id = "
|
31
|
+
@cti_outer_join_levels = levels
|
32
|
+
[@cti_outer_join_query + "#{id if id}", @cti_outer_join_levels]
|
33
|
+
end
|
34
|
+
|
35
|
+
# generates inner-join query used in convert_to(target_class)
|
36
|
+
def cti_inner_join_sql(id, target_class)
|
37
|
+
if @cti_inner_join_query && @cti_inner_join_query[target_class]
|
38
|
+
return @cti_inner_join_query[target_class] + "#{id if id}"
|
39
|
+
end
|
40
|
+
return nil if !@cti_ascendants.include?(target_class)
|
41
|
+
query = "SELECT #{DBViewCTI::Names.table_name(target_class)}.id AS #{DBViewCTI::Names.foreign_key(target_class)}" +
|
42
|
+
"\nFROM #{DBViewCTI::Names.table_name(self)}"
|
43
|
+
base_class = self
|
44
|
+
@cti_ascendants ||= []
|
45
|
+
@cti_ascendants.reverse.each do |ascendant|
|
46
|
+
query += "\nINNER JOIN #{DBViewCTI::Names.table_name(ascendant)} " +
|
47
|
+
"ON #{DBViewCTI::Names.table_name(base_class)}.#{DBViewCTI::Names.foreign_key(ascendant)} = " +
|
48
|
+
"#{DBViewCTI::Names.table_name(ascendant)}.id"
|
49
|
+
break if ascendant == target_class
|
50
|
+
base_class = ascendant
|
51
|
+
end
|
52
|
+
query += "\nWHERE #{DBViewCTI::Names.table_name(self)}.id = "
|
53
|
+
@cti_inner_join_query ||= {}
|
54
|
+
@cti_inner_join_query[target_class] = query
|
55
|
+
query + "#{id if id}"
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
data/lib/dbview_cti.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
module DBViewCTI
|
2
|
+
extend ActiveSupport::Autoload
|
3
|
+
autoload :Names
|
4
|
+
|
5
|
+
module ConnectionAdapters
|
6
|
+
extend ActiveSupport::Autoload
|
7
|
+
autoload :SchemaStatements
|
8
|
+
end
|
9
|
+
|
10
|
+
module Migration
|
11
|
+
extend ActiveSupport::Autoload
|
12
|
+
autoload :CommandRecorder
|
13
|
+
end
|
14
|
+
|
15
|
+
module SQLGeneration
|
16
|
+
module Migration
|
17
|
+
extend ActiveSupport::Autoload
|
18
|
+
autoload :Factory
|
19
|
+
autoload :Base
|
20
|
+
autoload :PostgreSQL, 'db_view_cti/sql_generation/migration/postgresql'
|
21
|
+
end
|
22
|
+
extend ActiveSupport::Autoload
|
23
|
+
autoload :Model
|
24
|
+
end
|
25
|
+
|
26
|
+
module Model
|
27
|
+
extend ActiveSupport::Autoload
|
28
|
+
autoload :CTI
|
29
|
+
autoload :Extensions
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
require 'db_view_cti/loader'
|
34
|
+
require 'db_view_cti/railtie' if defined?(Rails)
|
35
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
@@ -0,0 +1,7 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
3
|
+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
4
|
+
|
5
|
+
require File.expand_path('../config/application', __FILE__)
|
6
|
+
|
7
|
+
Dummy::Application.load_tasks
|
@@ -0,0 +1,15 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// the compiled file.
|
9
|
+
//
|
10
|
+
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
|
11
|
+
// GO AFTER THE REQUIRES BELOW.
|
12
|
+
//
|
13
|
+
//= require jquery
|
14
|
+
//= require jquery_ujs
|
15
|
+
//= require_tree .
|
@@ -0,0 +1,13 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the top of the
|
9
|
+
* compiled file, but it's generally better to create a new file per style scope.
|
10
|
+
*
|
11
|
+
*= require_self
|
12
|
+
*= require_tree .
|
13
|
+
*/
|
File without changes
|
File without changes
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
# Pick the frameworks you want:
|
4
|
+
require "active_record/railtie"
|
5
|
+
require "action_controller/railtie"
|
6
|
+
require "action_mailer/railtie"
|
7
|
+
require "active_resource/railtie"
|
8
|
+
require "sprockets/railtie"
|
9
|
+
# require "rails/test_unit/railtie"
|
10
|
+
|
11
|
+
Bundler.require(*Rails.groups)
|
12
|
+
require "dbview_cti"
|
13
|
+
|
14
|
+
# for some strange reason, we have to manually require foreigner, it doesn't work through the gemspec file
|
15
|
+
require 'foreigner'
|
16
|
+
|
17
|
+
module Dummy
|
18
|
+
class Application < Rails::Application
|
19
|
+
# Settings in config/environments/* take precedence over those specified here.
|
20
|
+
# Application configuration should go into files in config/initializers
|
21
|
+
# -- all .rb files in that directory are automatically loaded.
|
22
|
+
|
23
|
+
# Custom directories with classes and modules you want to be autoloadable.
|
24
|
+
# config.autoload_paths += %W(#{config.root}/extras)
|
25
|
+
|
26
|
+
# Only load the plugins named here, in the order given (default is alphabetical).
|
27
|
+
# :all can be used as a placeholder for all plugins not explicitly named.
|
28
|
+
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
29
|
+
|
30
|
+
# Activate observers that should always be running.
|
31
|
+
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
|
32
|
+
|
33
|
+
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
34
|
+
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
35
|
+
# config.time_zone = 'Central Time (US & Canada)'
|
36
|
+
|
37
|
+
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
38
|
+
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
39
|
+
# config.i18n.default_locale = :de
|
40
|
+
|
41
|
+
# Configure the default encoding used in templates for Ruby 1.9.
|
42
|
+
config.encoding = "utf-8"
|
43
|
+
|
44
|
+
# Configure sensitive parameters which will be filtered from the log file.
|
45
|
+
config.filter_parameters += [:password]
|
46
|
+
|
47
|
+
# Enable escaping HTML in JSON.
|
48
|
+
config.active_support.escape_html_entities_in_json = true
|
49
|
+
|
50
|
+
# Use SQL instead of Active Record's schema dumper when creating the database.
|
51
|
+
# This is necessary if your schema can't be completely dumped by the schema dumper,
|
52
|
+
# like if you have constraints or database-specific column types
|
53
|
+
# config.active_record.schema_format = :sql
|
54
|
+
|
55
|
+
# Enforce whitelist mode for mass assignment.
|
56
|
+
# This will create an empty whitelist of attributes available for mass-assignment for all models
|
57
|
+
# in your app. As such, your models will need to explicitly whitelist or blacklist accessible
|
58
|
+
# parameters by using an attr_accessible or attr_protected declaration.
|
59
|
+
config.active_record.whitelist_attributes = true
|
60
|
+
|
61
|
+
# Enable the asset pipeline
|
62
|
+
config.assets.enabled = true
|
63
|
+
|
64
|
+
# Version of your assets, change this if you want to expire all your assets
|
65
|
+
config.assets.version = '1.0'
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# SQLite version 3.x
|
2
|
+
# gem install sqlite3
|
3
|
+
#
|
4
|
+
# Ensure the SQLite 3 gem is defined in your Gemfile
|
5
|
+
# gem 'sqlite3'
|
6
|
+
#development:
|
7
|
+
# adapter: sqlite3
|
8
|
+
# database: db/development.sqlite3
|
9
|
+
# pool: 5
|
10
|
+
# timeout: 5000
|
11
|
+
|
12
|
+
development:
|
13
|
+
adapter: postgresql
|
14
|
+
encoding: utf8
|
15
|
+
pool: 5
|
16
|
+
database: dbview_cti
|
17
|
+
timeout: 5000
|
18
|
+
username: cti
|
19
|
+
password: cti
|
20
|
+
|
21
|
+
# Warning: The database defined as "test" will be erased and
|
22
|
+
# re-generated from your development database when you run "rake".
|
23
|
+
# Do not set this db to the same as development or production.
|
24
|
+
test:
|
25
|
+
adapter: postgresql
|
26
|
+
encoding: utf8
|
27
|
+
pool: 5
|
28
|
+
database: dbview_cti_test
|
29
|
+
timeout: 5000
|
30
|
+
username: cti
|
31
|
+
password: cti
|
32
|
+
|
33
|
+
production:
|
34
|
+
adapter: sqlite3
|
35
|
+
database: db/production.sqlite3
|
36
|
+
pool: 5
|
37
|
+
timeout: 5000
|
@@ -0,0 +1,37 @@
|
|
1
|
+
Dummy::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb
|
3
|
+
|
4
|
+
# In the development environment your application's code is reloaded on
|
5
|
+
# every request. This slows down response time but is perfect for development
|
6
|
+
# since you don't have to restart the web server when you make code changes.
|
7
|
+
config.cache_classes = false
|
8
|
+
|
9
|
+
# Log error messages when you accidentally call methods on nil.
|
10
|
+
config.whiny_nils = true
|
11
|
+
|
12
|
+
# Show full error reports and disable caching
|
13
|
+
config.consider_all_requests_local = true
|
14
|
+
config.action_controller.perform_caching = false
|
15
|
+
|
16
|
+
# Don't care if the mailer can't send
|
17
|
+
config.action_mailer.raise_delivery_errors = false
|
18
|
+
|
19
|
+
# Print deprecation notices to the Rails logger
|
20
|
+
config.active_support.deprecation = :log
|
21
|
+
|
22
|
+
# Only use best-standards-support built into browsers
|
23
|
+
config.action_dispatch.best_standards_support = :builtin
|
24
|
+
|
25
|
+
# Raise exception on mass assignment protection for Active Record models
|
26
|
+
config.active_record.mass_assignment_sanitizer = :strict
|
27
|
+
|
28
|
+
# Log the query plan for queries taking more than this (works
|
29
|
+
# with SQLite, MySQL, and PostgreSQL)
|
30
|
+
config.active_record.auto_explain_threshold_in_seconds = 0.5
|
31
|
+
|
32
|
+
# Do not compress assets
|
33
|
+
config.assets.compress = false
|
34
|
+
|
35
|
+
# Expands the lines which load the assets
|
36
|
+
config.assets.debug = true
|
37
|
+
end
|