views 0.0.1 → 4.0.0.0

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.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +1 -19
  3. data/lib/generators/view/templates/migration.rb +5 -0
  4. data/lib/generators/{views → view}/templates/view.sql +0 -0
  5. data/lib/generators/view/view_generator.rb +24 -0
  6. data/lib/views.rb +7 -50
  7. data/lib/views/extensions/active_record/abstract_adapter.rb +17 -0
  8. data/lib/views/extensions/active_record/command_recorder.rb +26 -0
  9. data/lib/views/extensions/active_record/postgresql_adapter.rb +39 -0
  10. data/lib/views/extensions/active_record/schema_dumper.rb +28 -0
  11. data/lib/views/railtie.rb +17 -0
  12. data/lib/views/version.rb +3 -1
  13. data/test/dummy/bin/bundle +1 -0
  14. data/test/dummy/bin/rails +1 -0
  15. data/test/dummy/bin/rake +1 -0
  16. data/test/dummy/bin/setup +2 -1
  17. data/test/dummy/config/database.yml +2 -5
  18. data/test/dummy/config/database.yml.travis +2 -11
  19. data/test/dummy/config/environments/development.rb +1 -1
  20. data/test/dummy/config/environments/production.rb +1 -1
  21. data/test/dummy/config/environments/test.rb +2 -2
  22. data/test/dummy/config/initializers/mime_types.rb +1 -1
  23. data/test/dummy/config/secrets.yml +2 -2
  24. data/test/dummy/db/migrate/20161125151623_create_guitars_view.rb +5 -0
  25. data/test/dummy/db/schema.rb +3 -1
  26. data/test/dummy/db/views/guitars.sql +2 -2
  27. data/test/dummy/log/development.log +2897 -24
  28. data/test/dummy/log/test.log +1545 -915
  29. data/test/dummy/public/404.html +57 -63
  30. data/test/dummy/public/422.html +57 -63
  31. data/test/dummy/public/500.html +56 -62
  32. data/test/{generators_test.rb → generator_test.rb} +4 -4
  33. data/test/migration_test.rb +20 -0
  34. data/test/task_test.rb +25 -0
  35. metadata +19 -10
  36. data/lib/generators/views/view_generator.rb +0 -15
  37. data/lib/tasks/views.rake +0 -7
  38. data/test/tasks_test.rb +0 -28
@@ -1,67 +1,61 @@
1
1
  <!DOCTYPE html>
2
2
  <html>
3
- <head>
4
- <title>The page you were looking for doesn't exist (404)</title>
5
- <meta name="viewport" content="width=device-width,initial-scale=1">
6
- <style>
7
- body {
8
- background-color: #EFEFEF;
9
- color: #2E2F30;
10
- text-align: center;
11
- font-family: arial, sans-serif;
12
- margin: 0;
13
- }
14
-
15
- div.dialog {
16
- width: 95%;
17
- max-width: 33em;
18
- margin: 4em auto 0;
19
- }
20
-
21
- div.dialog > div {
22
- border: 1px solid #CCC;
23
- border-right-color: #999;
24
- border-left-color: #999;
25
- border-bottom-color: #BBB;
26
- border-top: #B00100 solid 4px;
27
- border-top-left-radius: 9px;
28
- border-top-right-radius: 9px;
29
- background-color: white;
30
- padding: 7px 12% 0;
31
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
- }
33
-
34
- h1 {
35
- font-size: 100%;
36
- color: #730E15;
37
- line-height: 1.5em;
38
- }
39
-
40
- div.dialog > p {
41
- margin: 0 0 1em;
42
- padding: 1em;
43
- background-color: #F7F7F7;
44
- border: 1px solid #CCC;
45
- border-right-color: #999;
46
- border-left-color: #999;
47
- border-bottom-color: #999;
48
- border-bottom-left-radius: 4px;
49
- border-bottom-right-radius: 4px;
50
- border-top-color: #DADADA;
51
- color: #666;
52
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
- }
54
- </style>
55
- </head>
56
-
57
- <body>
58
- <!-- This file lives in public/404.html -->
59
- <div class="dialog">
60
- <div>
61
- <h1>The page you were looking for doesn't exist.</h1>
62
- <p>You may have mistyped the address or the page may have moved.</p>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ body {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+ div.dialog {
15
+ width: 95%;
16
+ max-width: 33em;
17
+ margin: 4em auto 0;
18
+ }
19
+ div.dialog > div {
20
+ border: 1px solid #CCC;
21
+ border-right-color: #999;
22
+ border-left-color: #999;
23
+ border-bottom-color: #BBB;
24
+ border-top: #B00100 solid 4px;
25
+ border-top-left-radius: 9px;
26
+ border-top-right-radius: 9px;
27
+ background-color: white;
28
+ padding: 7px 12% 0;
29
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
30
+ }
31
+ h1 {
32
+ font-size: 100%;
33
+ color: #730E15;
34
+ line-height: 1.5em;
35
+ }
36
+ div.dialog > p {
37
+ margin: 0 0 1em;
38
+ padding: 1em;
39
+ background-color: #F7F7F7;
40
+ border: 1px solid #CCC;
41
+ border-right-color: #999;
42
+ border-left-color: #999;
43
+ border-bottom-color: #999;
44
+ border-bottom-left-radius: 4px;
45
+ border-bottom-right-radius: 4px;
46
+ border-top-color: #DADADA;
47
+ color: #666;
48
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
49
+ }
50
+ </style>
51
+ </head>
52
+ <body>
53
+ <div class="dialog">
54
+ <div>
55
+ <h1>The page you were looking for doesn't exist.</h1>
56
+ <p>You may have mistyped the address or the page may have moved.</p>
57
+ </div>
58
+ <p>If you are the application owner check the logs for more information.</p>
63
59
  </div>
64
- <p>If you are the application owner check the logs for more information.</p>
65
- </div>
66
- </body>
60
+ </body>
67
61
  </html>
@@ -1,67 +1,61 @@
1
1
  <!DOCTYPE html>
2
2
  <html>
3
- <head>
4
- <title>The change you wanted was rejected (422)</title>
5
- <meta name="viewport" content="width=device-width,initial-scale=1">
6
- <style>
7
- body {
8
- background-color: #EFEFEF;
9
- color: #2E2F30;
10
- text-align: center;
11
- font-family: arial, sans-serif;
12
- margin: 0;
13
- }
14
-
15
- div.dialog {
16
- width: 95%;
17
- max-width: 33em;
18
- margin: 4em auto 0;
19
- }
20
-
21
- div.dialog > div {
22
- border: 1px solid #CCC;
23
- border-right-color: #999;
24
- border-left-color: #999;
25
- border-bottom-color: #BBB;
26
- border-top: #B00100 solid 4px;
27
- border-top-left-radius: 9px;
28
- border-top-right-radius: 9px;
29
- background-color: white;
30
- padding: 7px 12% 0;
31
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
- }
33
-
34
- h1 {
35
- font-size: 100%;
36
- color: #730E15;
37
- line-height: 1.5em;
38
- }
39
-
40
- div.dialog > p {
41
- margin: 0 0 1em;
42
- padding: 1em;
43
- background-color: #F7F7F7;
44
- border: 1px solid #CCC;
45
- border-right-color: #999;
46
- border-left-color: #999;
47
- border-bottom-color: #999;
48
- border-bottom-left-radius: 4px;
49
- border-bottom-right-radius: 4px;
50
- border-top-color: #DADADA;
51
- color: #666;
52
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
- }
54
- </style>
55
- </head>
56
-
57
- <body>
58
- <!-- This file lives in public/422.html -->
59
- <div class="dialog">
60
- <div>
61
- <h1>The change you wanted was rejected.</h1>
62
- <p>Maybe you tried to change something you didn't have access to.</p>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ body {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+ div.dialog {
15
+ width: 95%;
16
+ max-width: 33em;
17
+ margin: 4em auto 0;
18
+ }
19
+ div.dialog > div {
20
+ border: 1px solid #CCC;
21
+ border-right-color: #999;
22
+ border-left-color: #999;
23
+ border-bottom-color: #BBB;
24
+ border-top: #B00100 solid 4px;
25
+ border-top-left-radius: 9px;
26
+ border-top-right-radius: 9px;
27
+ background-color: white;
28
+ padding: 7px 12% 0;
29
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
30
+ }
31
+ h1 {
32
+ font-size: 100%;
33
+ color: #730E15;
34
+ line-height: 1.5em;
35
+ }
36
+ div.dialog > p {
37
+ margin: 0 0 1em;
38
+ padding: 1em;
39
+ background-color: #F7F7F7;
40
+ border: 1px solid #CCC;
41
+ border-right-color: #999;
42
+ border-left-color: #999;
43
+ border-bottom-color: #999;
44
+ border-bottom-left-radius: 4px;
45
+ border-bottom-right-radius: 4px;
46
+ border-top-color: #DADADA;
47
+ color: #666;
48
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
49
+ }
50
+ </style>
51
+ </head>
52
+ <body>
53
+ <div class="dialog">
54
+ <div>
55
+ <h1>The change you wanted was rejected.</h1>
56
+ <p>Maybe you tried to change something you didn't have access to.</p>
57
+ </div>
58
+ <p>If you are the application owner check the logs for more information.</p>
63
59
  </div>
64
- <p>If you are the application owner check the logs for more information.</p>
65
- </div>
66
- </body>
60
+ </body>
67
61
  </html>
@@ -1,66 +1,60 @@
1
1
  <!DOCTYPE html>
2
2
  <html>
3
- <head>
4
- <title>We're sorry, but something went wrong (500)</title>
5
- <meta name="viewport" content="width=device-width,initial-scale=1">
6
- <style>
7
- body {
8
- background-color: #EFEFEF;
9
- color: #2E2F30;
10
- text-align: center;
11
- font-family: arial, sans-serif;
12
- margin: 0;
13
- }
14
-
15
- div.dialog {
16
- width: 95%;
17
- max-width: 33em;
18
- margin: 4em auto 0;
19
- }
20
-
21
- div.dialog > div {
22
- border: 1px solid #CCC;
23
- border-right-color: #999;
24
- border-left-color: #999;
25
- border-bottom-color: #BBB;
26
- border-top: #B00100 solid 4px;
27
- border-top-left-radius: 9px;
28
- border-top-right-radius: 9px;
29
- background-color: white;
30
- padding: 7px 12% 0;
31
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
- }
33
-
34
- h1 {
35
- font-size: 100%;
36
- color: #730E15;
37
- line-height: 1.5em;
38
- }
39
-
40
- div.dialog > p {
41
- margin: 0 0 1em;
42
- padding: 1em;
43
- background-color: #F7F7F7;
44
- border: 1px solid #CCC;
45
- border-right-color: #999;
46
- border-left-color: #999;
47
- border-bottom-color: #999;
48
- border-bottom-left-radius: 4px;
49
- border-bottom-right-radius: 4px;
50
- border-top-color: #DADADA;
51
- color: #666;
52
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
- }
54
- </style>
55
- </head>
56
-
57
- <body>
58
- <!-- This file lives in public/500.html -->
59
- <div class="dialog">
60
- <div>
61
- <h1>We're sorry, but something went wrong.</h1>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ body {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+ div.dialog {
15
+ width: 95%;
16
+ max-width: 33em;
17
+ margin: 4em auto 0;
18
+ }
19
+ div.dialog > div {
20
+ border: 1px solid #CCC;
21
+ border-right-color: #999;
22
+ border-left-color: #999;
23
+ border-bottom-color: #BBB;
24
+ border-top: #B00100 solid 4px;
25
+ border-top-left-radius: 9px;
26
+ border-top-right-radius: 9px;
27
+ background-color: white;
28
+ padding: 7px 12% 0;
29
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
30
+ }
31
+ h1 {
32
+ font-size: 100%;
33
+ color: #730E15;
34
+ line-height: 1.5em;
35
+ }
36
+ div.dialog > p {
37
+ margin: 0 0 1em;
38
+ padding: 1em;
39
+ background-color: #F7F7F7;
40
+ border: 1px solid #CCC;
41
+ border-right-color: #999;
42
+ border-left-color: #999;
43
+ border-bottom-color: #999;
44
+ border-bottom-left-radius: 4px;
45
+ border-bottom-right-radius: 4px;
46
+ border-top-color: #DADADA;
47
+ color: #666;
48
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
49
+ }
50
+ </style>
51
+ </head>
52
+ <body>
53
+ <div class="dialog">
54
+ <div>
55
+ <h1>We're sorry, but something went wrong.</h1>
56
+ </div>
57
+ <p>If you are the application owner check the logs for more information.</p>
62
58
  </div>
63
- <p>If you are the application owner check the logs for more information.</p>
64
- </div>
65
- </body>
59
+ </body>
66
60
  </html>
@@ -1,10 +1,8 @@
1
1
  require 'test_helper'
2
2
  require 'rails/generators'
3
- require 'generators/views/view_generator'
3
+ require 'generators/view/view_generator'
4
4
 
5
- class GeneratorsTest < Rails::Generators::TestCase
6
-
7
- tests Views::Generators::ViewGenerator
5
+ class GeneratorTest < Rails::Generators::TestCase
8
6
  destination Rails.root.join('tmp')
9
7
 
10
8
  teardown do
@@ -12,8 +10,10 @@ class GeneratorsTest < Rails::Generators::TestCase
12
10
  end
13
11
 
14
12
  test 'file generation' do
13
+ self.class.tests Views::Generators::ViewGenerator
15
14
  run_generator %w(guitars)
16
15
  assert_file 'db/views/guitars.sql'
16
+ assert_migration 'db/migrate/create_guitars_view.rb'
17
17
  end
18
18
 
19
19
  end
@@ -0,0 +1,20 @@
1
+ require 'test_helper'
2
+
3
+ class MigrationTest < ActiveSupport::TestCase
4
+
5
+ test 'create and drop' do
6
+ ActiveRecord::Migration.verbose = false
7
+ paths = Rails.application.paths['db/migrate'].to_a
8
+ assert_nothing_raised do
9
+ ActiveRecord::Migrator.migrate paths, 0
10
+ ActiveRecord::Migrator.migrate paths, nil
11
+ end
12
+ end
13
+
14
+ test 'change' do
15
+ assert_nothing_raised do
16
+ ActiveRecord::Migration.change_view :guitars
17
+ end
18
+ end
19
+
20
+ end
data/test/task_test.rb ADDED
@@ -0,0 +1,25 @@
1
+ require 'test_helper'
2
+
3
+ class TaskTest < ActiveSupport::TestCase
4
+
5
+ setup do
6
+ Dummy::Application.load_tasks
7
+ end
8
+
9
+ test 'load' do
10
+ silence_stream(STDOUT) do
11
+ Rake::Task['db:reset'].invoke
12
+ end
13
+ assert_equal 'guitars', ActiveRecord::Base.connection.views.first['name']
14
+ end
15
+
16
+ test 'dump' do
17
+ path = Rails.root.join('db/schema.rb')
18
+ FileUtils.rm_rf path
19
+ silence_stream(STDOUT) do
20
+ Rake::Task['db:schema:dump'].invoke
21
+ end
22
+ assert_includes File.read(path), 'create_view "guitars", force: true'
23
+ end
24
+
25
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: views
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 4.0.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mathías Montossi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-18 00:00:00.000000000 Z
11
+ date: 2016-12-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -60,17 +60,22 @@ dependencies:
60
60
  version: '1.1'
61
61
  description: Simple way to manage database views in rails.
62
62
  email:
63
- - mmontossi@buyin.io
63
+ - mmontossi@gmail.com
64
64
  executables: []
65
65
  extensions: []
66
66
  extra_rdoc_files: []
67
67
  files:
68
68
  - MIT-LICENSE
69
69
  - Rakefile
70
- - lib/generators/views/templates/view.sql
71
- - lib/generators/views/view_generator.rb
72
- - lib/tasks/views.rake
70
+ - lib/generators/view/templates/migration.rb
71
+ - lib/generators/view/templates/view.sql
72
+ - lib/generators/view/view_generator.rb
73
73
  - lib/views.rb
74
+ - lib/views/extensions/active_record/abstract_adapter.rb
75
+ - lib/views/extensions/active_record/command_recorder.rb
76
+ - lib/views/extensions/active_record/postgresql_adapter.rb
77
+ - lib/views/extensions/active_record/schema_dumper.rb
78
+ - lib/views/railtie.rb
74
79
  - lib/views/version.rb
75
80
  - test/dummy/Rakefile
76
81
  - test/dummy/app/assets/javascripts/application.js
@@ -104,6 +109,7 @@ files:
104
109
  - test/dummy/config/routes.rb
105
110
  - test/dummy/config/secrets.yml
106
111
  - test/dummy/db/migrate/20161017172847_create_products.rb
112
+ - test/dummy/db/migrate/20161125151623_create_guitars_view.rb
107
113
  - test/dummy/db/schema.rb
108
114
  - test/dummy/db/views/guitars.sql
109
115
  - test/dummy/log/development.log
@@ -112,8 +118,9 @@ files:
112
118
  - test/dummy/public/422.html
113
119
  - test/dummy/public/500.html
114
120
  - test/dummy/public/favicon.ico
115
- - test/generators_test.rb
116
- - test/tasks_test.rb
121
+ - test/generator_test.rb
122
+ - test/migration_test.rb
123
+ - test/task_test.rb
117
124
  - test/test_helper.rb
118
125
  homepage: https://github.com/mmontossi/views
119
126
  licenses:
@@ -171,6 +178,7 @@ test_files:
171
178
  - test/dummy/config/secrets.yml
172
179
  - test/dummy/config.ru
173
180
  - test/dummy/db/migrate/20161017172847_create_products.rb
181
+ - test/dummy/db/migrate/20161125151623_create_guitars_view.rb
174
182
  - test/dummy/db/schema.rb
175
183
  - test/dummy/db/views/guitars.sql
176
184
  - test/dummy/log/development.log
@@ -180,6 +188,7 @@ test_files:
180
188
  - test/dummy/public/500.html
181
189
  - test/dummy/public/favicon.ico
182
190
  - test/dummy/Rakefile
183
- - test/generators_test.rb
184
- - test/tasks_test.rb
191
+ - test/generator_test.rb
192
+ - test/migration_test.rb
193
+ - test/task_test.rb
185
194
  - test/test_helper.rb