scenic-jets 1.5.4

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 (77) hide show
  1. checksums.yaml +7 -0
  2. data/.github/workflows/ci.yml +78 -0
  3. data/.gitignore +19 -0
  4. data/.hound.yml +2 -0
  5. data/.rubocop.yml +129 -0
  6. data/.yardopts +4 -0
  7. data/CHANGELOG.md +223 -0
  8. data/CODE_OF_CONDUCT.md +76 -0
  9. data/CONTRIBUTING.md +24 -0
  10. data/Gemfile +16 -0
  11. data/LICENSE.txt +22 -0
  12. data/README.md +5 -0
  13. data/Rakefile +29 -0
  14. data/SECURITY.md +14 -0
  15. data/bin/rake +17 -0
  16. data/bin/rspec +17 -0
  17. data/bin/setup +18 -0
  18. data/bin/yard +16 -0
  19. data/lib/generators/scenic/generators.rb +12 -0
  20. data/lib/generators/scenic/materializable.rb +31 -0
  21. data/lib/generators/scenic/model/USAGE +12 -0
  22. data/lib/generators/scenic/model/model_generator.rb +52 -0
  23. data/lib/generators/scenic/model/templates/model.erb +3 -0
  24. data/lib/generators/scenic/view/USAGE +20 -0
  25. data/lib/generators/scenic/view/templates/db/migrate/create_view.erb +5 -0
  26. data/lib/generators/scenic/view/templates/db/migrate/update_view.erb +12 -0
  27. data/lib/generators/scenic/view/view_generator.rb +127 -0
  28. data/lib/scenic.rb +31 -0
  29. data/lib/scenic/adapters/postgres.rb +256 -0
  30. data/lib/scenic/adapters/postgres/connection.rb +57 -0
  31. data/lib/scenic/adapters/postgres/errors.rb +26 -0
  32. data/lib/scenic/adapters/postgres/index_reapplication.rb +71 -0
  33. data/lib/scenic/adapters/postgres/indexes.rb +53 -0
  34. data/lib/scenic/adapters/postgres/refresh_dependencies.rb +116 -0
  35. data/lib/scenic/adapters/postgres/views.rb +74 -0
  36. data/lib/scenic/command_recorder.rb +52 -0
  37. data/lib/scenic/command_recorder/statement_arguments.rb +51 -0
  38. data/lib/scenic/configuration.rb +37 -0
  39. data/lib/scenic/definition.rb +35 -0
  40. data/lib/scenic/index.rb +36 -0
  41. data/lib/scenic/schema_dumper.rb +44 -0
  42. data/lib/scenic/statements.rb +163 -0
  43. data/lib/scenic/version.rb +3 -0
  44. data/lib/scenic/view.rb +54 -0
  45. data/scenic.gemspec +36 -0
  46. data/spec/acceptance/user_manages_views_spec.rb +88 -0
  47. data/spec/acceptance_helper.rb +33 -0
  48. data/spec/dummy/.gitignore +16 -0
  49. data/spec/dummy/Rakefile +13 -0
  50. data/spec/dummy/app/models/application_record.rb +5 -0
  51. data/spec/dummy/bin/bundle +3 -0
  52. data/spec/dummy/bin/rails +4 -0
  53. data/spec/dummy/bin/rake +4 -0
  54. data/spec/dummy/config.ru +4 -0
  55. data/spec/dummy/config/application.rb +15 -0
  56. data/spec/dummy/config/boot.rb +5 -0
  57. data/spec/dummy/config/database.yml +14 -0
  58. data/spec/dummy/config/environment.rb +5 -0
  59. data/spec/dummy/db/migrate/.keep +0 -0
  60. data/spec/dummy/db/views/.keep +0 -0
  61. data/spec/generators/scenic/model/model_generator_spec.rb +36 -0
  62. data/spec/generators/scenic/view/view_generator_spec.rb +57 -0
  63. data/spec/integration/revert_spec.rb +74 -0
  64. data/spec/scenic/adapters/postgres/connection_spec.rb +79 -0
  65. data/spec/scenic/adapters/postgres/refresh_dependencies_spec.rb +82 -0
  66. data/spec/scenic/adapters/postgres/views_spec.rb +37 -0
  67. data/spec/scenic/adapters/postgres_spec.rb +209 -0
  68. data/spec/scenic/command_recorder/statement_arguments_spec.rb +41 -0
  69. data/spec/scenic/command_recorder_spec.rb +111 -0
  70. data/spec/scenic/configuration_spec.rb +27 -0
  71. data/spec/scenic/definition_spec.rb +62 -0
  72. data/spec/scenic/schema_dumper_spec.rb +115 -0
  73. data/spec/scenic/statements_spec.rb +199 -0
  74. data/spec/spec_helper.rb +22 -0
  75. data/spec/support/generator_spec_setup.rb +14 -0
  76. data/spec/support/view_definition_helpers.rb +10 -0
  77. metadata +307 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 845cf1edcbb3f329b692e28a8d5ab93695e6f7376d58ed3a171659f005f81cb5
4
+ data.tar.gz: 79057f90ea5e2d2528dcc7e7920d63a38fcda97b26149d2b4b15240eade05974
5
+ SHA512:
6
+ metadata.gz: c9ec1207ebcad3307627d08cf411e93648c794429fd039bfa724cf1fcee34dc011abb7cb6448155d0249d4cbf570aef716d248f8a3d1537de4dbed50e599dbe2
7
+ data.tar.gz: '084644c84686e8b53e283bbafc8c5ec96bc75991fe0238217a2811d179d51f4a94cf26b4abb17e69d401f5cbcf413a6711635bf272c1cbaf5f86e237396bab29'
@@ -0,0 +1,78 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: master
6
+ pull_request:
7
+ branches: "*"
8
+
9
+ jobs:
10
+ build:
11
+ name: Ruby ${{ matrix.ruby }}, Rails ${{ matrix.rails }}
12
+
13
+ strategy:
14
+ fail-fast: false
15
+ matrix:
16
+ ruby: ["2.7","2.4"]
17
+ rails: ["5.2", "6.0", "master"]
18
+ exclude:
19
+ - ruby: "2.4"
20
+ rails: "6.0"
21
+ - ruby: "2.4"
22
+ rails: "master"
23
+ include:
24
+ - rails: "master"
25
+ continue-on-error: true
26
+
27
+ runs-on: ubuntu-latest
28
+
29
+ services:
30
+ postgres:
31
+ image: postgres
32
+ env:
33
+ POSTGRES_USER: "postgres"
34
+ POSTGRES_PASSWORD: "postgres"
35
+ ports:
36
+ - 5432:5432
37
+ options: >-
38
+ --health-cmd pg_isready
39
+ --health-interval 10s
40
+ --health-timeout 5s
41
+ --health-retries 5
42
+
43
+ env:
44
+ RAILS_VERSION: ${{ matrix.rails }}
45
+ POSTGRES_USER: "postgres"
46
+ POSTGRES_PASSWORD: "postgres"
47
+
48
+ steps:
49
+ - name: Checkout
50
+ uses: actions/checkout@v2
51
+
52
+ - name: Install Ruby ${{ matrix.ruby }}
53
+ uses: ruby/setup-ruby@v1.61.1
54
+ with:
55
+ ruby-version: ${{ matrix.ruby }}
56
+
57
+ - name: Install dependent libraries
58
+ run: sudo apt-get install libpq-dev
59
+
60
+ - name: Generate lockfile
61
+ run: bundle lock
62
+
63
+ - name: Cache dependencies
64
+ uses: actions/cache@v1
65
+ with:
66
+ path: vendor/bundle
67
+ key: bundle-${{ hashFiles('Gemfile.lock') }}
68
+
69
+ - name: Set up Scenic
70
+ run: bin/setup
71
+
72
+ - name: Run fast tests
73
+ run: bundle exec rake spec
74
+ continue-on-error: ${{ matrix.continue-on-error }}
75
+
76
+ - name: Run acceptance tests
77
+ run: bundle exec rake spec:acceptance
78
+ continue-on-error: ${{ matrix.continue-on-error }}
data/.gitignore ADDED
@@ -0,0 +1,19 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ gemfiles/*.lock
19
+ .DS_Store
data/.hound.yml ADDED
@@ -0,0 +1,2 @@
1
+ rubocop:
2
+ config_file: .rubocop.yml
data/.rubocop.yml ADDED
@@ -0,0 +1,129 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.3.0
3
+ Exclude:
4
+ - "tmp/**/*"
5
+ - "bin/*"
6
+ - "spec/dummy/**/*"
7
+
8
+ Bundler/OrderedGems:
9
+ Enabled: false
10
+
11
+ Gemspec/OrderedDependencies:
12
+ Enabled: false
13
+
14
+ Layout/AlignParameters:
15
+ Enabled: true
16
+ EnforcedStyle: with_fixed_indentation
17
+ Layout/ConditionPosition:
18
+ Enabled: false
19
+ Layout/DotPosition:
20
+ EnforcedStyle: leading
21
+ Layout/ExtraSpacing:
22
+ Enabled: true
23
+ Layout/IndentAssignment:
24
+ Enabled: False
25
+ Layout/MultilineOperationIndentation:
26
+ Enabled: true
27
+ EnforcedStyle: indented
28
+ Layout/MultilineMethodCallIndentation:
29
+ Enabled: true
30
+ EnforcedStyle: indented
31
+
32
+ Lint/AmbiguousOperator:
33
+ Enabled: true
34
+ Lint/AmbiguousRegexpLiteral:
35
+ Enabled: true
36
+ Lint/DuplicatedKey:
37
+ Enabled: true
38
+
39
+ Metrics/ClassLength:
40
+ Enabled: false
41
+ Metrics/ModuleLength:
42
+ Enabled: false
43
+ Metrics/AbcSize:
44
+ Enabled: false
45
+ Metrics/BlockLength:
46
+ CountComments: true # count full line comments?
47
+ Max: 25
48
+ ExcludedMethods: []
49
+ Exclude:
50
+ - "spec/**/*"
51
+ - "*.gemspec"
52
+ Metrics/CyclomaticComplexity:
53
+ Enabled: false
54
+ Metrics/LineLength:
55
+ Max: 80
56
+ Metrics/MethodLength:
57
+ Enabled: false
58
+
59
+ Security/Eval:
60
+ Enabled: true
61
+ Exclude:
62
+ - "spec/scenic/schema_dumper_spec.rb"
63
+ Style/BlockDelimiters:
64
+ Enabled: false
65
+ Style/CollectionMethods:
66
+ Enabled: true
67
+ PreferredMethods:
68
+ find: find
69
+ inject: reduce
70
+ collect: map
71
+ find_all: select
72
+ Style/ConditionalAssignment:
73
+ Enabled: false
74
+ Style/ClassAndModuleChildren:
75
+ Enabled: true
76
+ Exclude:
77
+ - "spec/**/*"
78
+ Style/Documentation:
79
+ Enabled: false
80
+ Style/FrozenStringLiteralComment:
81
+ Description: >-
82
+ Add the frozen_string_literal comment to the top of files
83
+ to help transition from Ruby 2.3.0 to Ruby 3.0.
84
+ Enabled: false
85
+ Style/GuardClause:
86
+ Enabled: false
87
+ Style/IfUnlessModifier:
88
+ Enabled: false
89
+ Style/Lambda:
90
+ Enabled: false
91
+ Style/NumericLiterals:
92
+ Enabled: false
93
+ Style/OneLineConditional:
94
+ Enabled: false
95
+ Style/PercentLiteralDelimiters:
96
+ Enabled: false
97
+ Style/StringLiterals:
98
+ EnforcedStyle: double_quotes
99
+ Enabled: true
100
+ Style/TrailingCommaInArguments:
101
+ Description: 'Checks for trailing comma in argument lists.'
102
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
103
+ EnforcedStyleForMultiline: comma
104
+ SupportedStylesForMultiline:
105
+ - comma
106
+ - consistent_comma
107
+ - no_comma
108
+ Enabled: true
109
+ Style/TrailingCommaInArrayLiteral:
110
+ Description: 'Checks for trailing comma in array literals.'
111
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
112
+ EnforcedStyleForMultiline: comma
113
+ SupportedStylesForMultiline:
114
+ - comma
115
+ - consistent_comma
116
+ - no_comma
117
+ Enabled: true
118
+ Style/TrailingCommaInHashLiteral:
119
+ Description: 'Checks for trailing comma in hash literals.'
120
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
121
+ EnforcedStyleForMultiline: comma
122
+ SupportedStylesForMultiline:
123
+ - comma
124
+ - consistent_comma
125
+ - no_comma
126
+ Enabled: true
127
+ Style/WordArray:
128
+ Enabled: false
129
+
data/.yardopts ADDED
@@ -0,0 +1,4 @@
1
+ --hide-api private
2
+ --exclude templates
3
+ --markup markdown
4
+ --markup-provider redcarpet
data/CHANGELOG.md ADDED
@@ -0,0 +1,223 @@
1
+ # Changelog
2
+
3
+ The noteworthy changes for each Scenic version are included here. For a complete
4
+ changelog, see the [commits] for each version via the version links.
5
+
6
+ [commits]: https://github.com/scenic-views/scenic/commits/master
7
+
8
+ ## [1.5.4] - September 16, 2020
9
+
10
+ [1.5.4]: https://github.com/scenic-views/scenic/compare/v1.5.3...v1.5.4
11
+
12
+ ### Fixed
13
+
14
+ - Added missing changelog for v1.5.3.
15
+
16
+ ## [1.5.3] - September 15, 2020
17
+
18
+ [1.5.3]: https://github.com/scenic-views/scenic/compare/v1.5.2...v1.5.3
19
+
20
+ ### Fixed
21
+
22
+ - `scenic-oracle_enhanced_adapter` has been pulled from rubygems.
23
+ `scenic-oracle_adapter` is a current, maintained alternative.
24
+ - Updated code snippets - since Rails 5.0, all models inherit from
25
+ ApplicationRecord (#302)
26
+ - Update Caleb's last name
27
+
28
+ ### Added
29
+
30
+ - Add Security Policy
31
+
32
+ ## [1.5.2] - February 6, 2020
33
+
34
+ ### Fixed
35
+
36
+ - The schema statement `create_view` is now reversible when passed a `version`
37
+ argument.
38
+ - Calling `refresh_materialized_view` with both `concurrently` and `cascade` set
39
+ to `true` now correctly cascades the concurrent refresh to dependent views.
40
+ - File generation and lookup now operates correctly for schema-qualified names
41
+ like `warehouse.archived_posts`.
42
+
43
+ [1.5.2]: https://github.com/scenic-views/scenic/compare/v1.5.1...v1.5.2
44
+
45
+ ## [1.5.1] - February 10, 2019
46
+
47
+ ### Fixed
48
+
49
+ - Passing `no_data: true` when creating a materialized view would error if the
50
+ corresponding SQL file had statement-terminating semicolon.
51
+
52
+ [1.5.1]: https://github.com/scenic-views/scenic/compare/v1.5.0...v1.5.1
53
+
54
+ ## [1.5.0] - February 8, 2019
55
+
56
+ ### Added
57
+
58
+ - `create_view` can now be passed `materialized: { no_data: true }` to create
59
+ the materialized view without populating it. Generators have been updated to
60
+ accept a `--no-data` option.
61
+
62
+ ### Fixed
63
+
64
+ - Passing `cascade: true` when refreshing a materialized view will no longer
65
+ error when the view in question has no dependencies.
66
+ - Fixed runtime deprecation warnings when using `pg` 0.21 and newer.
67
+ - Fixed a cascading refresh issue when the name of the view to trigger the
68
+ refresh is a substring of one of its dependencies.
69
+
70
+
71
+ [1.5.0]: https://github.com/scenic-views/scenic/compare/v1.4.1...v1.5.0
72
+
73
+ ## [1.4.1] - December 15, 2017
74
+
75
+ ### Fixed
76
+
77
+ - View migrations created under Rails 5 and newer will use the current migration
78
+ version in the generated migration class rather than always using `5.0`.
79
+
80
+ [1.4.1]: https://github.com/scenic-views/scenic/compare/v1.4.0...v1.4.1
81
+
82
+ ## [1.4.0] - May 11, 2017
83
+
84
+ ### Added
85
+
86
+ - `refresh_materialized_view` now accepts a `cascade` option, which defaults to
87
+ `false`. Setting this option to `true` will refresh any materialized views the
88
+ current view depends on first, ensuring the view being refreshed has the most
89
+ up-to-date information.
90
+ - `sql_definition` argument is now supported when using `update_view`.
91
+
92
+ ### Fixed
93
+
94
+ - View migrations created under Rails 5 and newer will no longer result in
95
+ warnings.
96
+ - `ar_internal_metadata` is no longer included in the schema dump for Rails 5
97
+ and newer apps.
98
+ - Using the `scenic:model` generator will no longer create a fixture or factory.
99
+
100
+ [1.4.0]: https://github.com/scenic-views/scenic/compare/v1.3.0...v1.4.0
101
+
102
+ ## [1.3.0] - May 27, 2016
103
+
104
+ ### Added
105
+ - Add `replace_view` migration statement, which issues `CREATE OR REPLACE
106
+ VIEW` rather than `CREATE VIEW` or `DROP VIEW` and `CREATE VIEW`.
107
+ - Schema-qualify views outside the 'public' namespace, such as
108
+ `scenic.searches`
109
+
110
+ ### Fixed
111
+ * Singularize generated model name when injecting into class.
112
+ Previously, pluralized names would issue a warning and Scenic would
113
+ attempt to insert model code into the pluralized model file.
114
+ * Convert shell-based smoke tests to RSpec syntax.
115
+
116
+ [1.3.0]: https://github.com/scenic-views/scenic/compare/v1.2.0...v1.3.0
117
+
118
+ ## [1.2.0] - February 5, 2016
119
+
120
+ ### Added
121
+ - The generators now accept namespaced view definitions. For example: `rails
122
+ generate scenic:view my_app.users`.
123
+
124
+ ### Fixed
125
+ - Materialized view indexes are now properly dumped to `db/schema.rb`. This was
126
+ an oversight in previous releases, meaning `rake db:schema:load` was missing
127
+ indexes.
128
+ - Calling `update_view` for a materialized view now properly finds associated
129
+ indexes for automatic reapplication. An issue in the previous index query was
130
+ returning no indexes.
131
+
132
+ **Note**: Dumping materialized view indexes will produce an invalid
133
+ `db/schema.rb` file under Rails 5 beta 1 and beta 2. This is fixed on Rails
134
+ master.
135
+
136
+ [1.2.0]: https://github.com/scenic-views/scenic/compare/v1.1.1...v1.2.0
137
+
138
+ ## [1.1.1] - January 29, 2016
139
+
140
+ ### Fixed
141
+ - Some schema operations were failing with a `PG::ConnectionBad: connection is
142
+ closed` error. This has been fixed by ensuring we grab a fresh connection for
143
+ all operations.
144
+
145
+ [1.1.1]: https://github.com/scenic-views/scenic/compare/v1.1.0...v1.1.1
146
+
147
+ ## [1.1.0] - January 8, 2016
148
+
149
+ ### Added
150
+ - Added support for updating materialized view definitions while maintaining
151
+ existing indexes that are still applicable after the update.
152
+ - Added support for refreshing materialized views concurrently (requires
153
+ Postgres 9.4 or newer).
154
+
155
+ ### Fixed
156
+ - The schema dumper will now dump views and materialized views together in the
157
+ order they are returned by Postgres. This fixes issues when loading views that
158
+ depend on other views via `rake db:schema:load`.
159
+ - Scenic now works on [supported versions of Postgres] older than 9.3.0.
160
+ Attempts to use database features not supported by your specific version of
161
+ Postgres will raise descriptive errors.
162
+ - Fixed inability to dump materialized views in Rails 5.0.0.beta1.
163
+
164
+ [supported versions of Postgres]: http://www.postgresql.org/support/versioning/
165
+ [1.1.0]: https://github.com/scenic-views/scenic/compare/v1.0.0...v1.1.0
166
+
167
+ ## [1.0.0] - November 23, 2015
168
+
169
+ ### Added
170
+ - Added support for [materialized views].
171
+ - Allow changing the database adapter via `Scenic::Configuration`.
172
+
173
+ ### Fixed
174
+ - Improved formatting of the view when dumped to `schema.rb`.
175
+ - Fixed generation of namespaced models by using ActiveRecord's own model
176
+ generator.
177
+ - Eliminated `alias_method_chain` deprecation when running with Rails master
178
+ (5.0).
179
+
180
+ [materialized views]:https://github.com/scenic-views/scenic/blob/v1.0.0/README.md
181
+ [1.0.0]: https://github.com/scenic-views/scenic/compare/v0.3.0...v1.0.0
182
+
183
+ ## [0.3.0] - January 23, 2015
184
+
185
+ ### Added
186
+ - Previous view definition is copied into new view definition file when updating
187
+ an existing view.
188
+
189
+ ### Fixed
190
+ - We avoid dumping views that belong to Postgres extensions.
191
+ - `db/schema.rb` is prettier thanks to a blank line after each view definition.
192
+
193
+ [0.3.0]: https://github.com/scenic-views/scenic/compare/v0.2.1...v0.3.0
194
+
195
+ ## [0.2.1] - January 5, 2015
196
+
197
+ ### Fixed
198
+ - View generator will now create `db/views` directory if necessary.
199
+
200
+ [0.2.1]: https://github.com/scenic-views/scenic/compare/v0.2.0...v0.2.1
201
+
202
+ ## [0.2.0] - August 11, 2014
203
+
204
+ ### Added
205
+ - Teach view generator to update existing views.
206
+
207
+ ### Fixed
208
+ - Raise an error if view definition is empty.
209
+
210
+ [0.2.0]: https://github.com/scenic-views/scenic/compare/v0.1.0...v0.2.0
211
+
212
+ ## [0.1.0] - August 4, 2014
213
+
214
+ Scenic makes it easier to work with Postgres views in Rails.
215
+
216
+ It introduces view methods to ActiveRecord::Migration and allows views to be
217
+ dumped to db/schema.rb. It provides generators for models, view definitions,
218
+ and migrations. It is built around a basic versioning system for view
219
+ definition files.
220
+
221
+ In short, go add a view to your app.
222
+
223
+ [0.1.0]: https://github.com/scenic-views/scenic/compare/8599daa132880cd6c07efb0395c0fb023b171f47...v0.1.0