sequelize-rails 0.4.1 → 0.6.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f1b95356822be96711195c7cb2756d2c84d3f1e8d1db2d9bdc1e4e7defee16d5
4
- data.tar.gz: e1261347c5eb6b75c3e5fcd7407cea9d17cc3deb451c7c0847cbf0316863c6ec
3
+ metadata.gz: f4f3572fa044301c579e0760ae4ba8247d043093ab3c8756dfd380829806ac16
4
+ data.tar.gz: f523555fe11cb97ff974e6f7f4949208b2071a272d5e28ab9fe70decce299839
5
5
  SHA512:
6
- metadata.gz: 5152e52462ee0e45700ab0650a3ea61cff498c8bd8022769db5f712785e4d123db5910b6c19b9cd0ffd8a489af6dcd9f8b5ae8f50bfe3030e47e6cfe928576dd
7
- data.tar.gz: 9ffb4fe02077f5b269ed43124da05e9e48db8fae102e4ea7f00b624d4dcc1566d7efa7f0d1d2f7e0e5f73e2d8a1a4b517375d01ec7a6740365f061ff60461bd3
6
+ metadata.gz: 06bbac5d130b2fb85940230f313a8fe8907efc08084a851986f89868f7ee9e2a395c20d7ed52014d92b904fb5a6e79e068b3cdf47562d8f91890dd294f788a39
7
+ data.tar.gz: 7cbfc94ec5c533cf05f3a4c81e625cec6dd3c7cab7aba972a62d7e68175749cb4abcf7a7e37b225dc99ea556d6319a912e39986e2b15f031a5b82089d19731f5
data/.rubocop.yml ADDED
@@ -0,0 +1,2 @@
1
+ Exclude:
2
+ - '**/*'
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.6.0] - 2023-09-04
4
+
5
+ - Adds migration generator
6
+
7
+ ## [0.5.0] - 2023-09-04
8
+
9
+ - Adds the `db:seed` rake task for running seed files
10
+ - Stubs the `db:schema:load` rake task and adds it as a step in `db:setup`
11
+ - Stubs the `db:schema:dump` rake task
12
+
3
13
  ## [0.4.1] - 2023-08-16
4
14
 
5
15
  - Adds a `Rails.application.config.sequel.after_connect` hook that is called after each connection is established. This hook can be used to add plugins and extensions to the database connection once established.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sequelize-rails (0.4.1)
4
+ sequelize-rails (0.6.0)
5
5
  activerecord (>= 6.0.0)
6
6
  rails (>= 6.0.0)
7
7
  sequel (>= 5.0.0)
@@ -9,67 +9,67 @@ PATH
9
9
  GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
- actioncable (7.0.7)
13
- actionpack (= 7.0.7)
14
- activesupport (= 7.0.7)
12
+ actioncable (7.0.7.2)
13
+ actionpack (= 7.0.7.2)
14
+ activesupport (= 7.0.7.2)
15
15
  nio4r (~> 2.0)
16
16
  websocket-driver (>= 0.6.1)
17
- actionmailbox (7.0.7)
18
- actionpack (= 7.0.7)
19
- activejob (= 7.0.7)
20
- activerecord (= 7.0.7)
21
- activestorage (= 7.0.7)
22
- activesupport (= 7.0.7)
17
+ actionmailbox (7.0.7.2)
18
+ actionpack (= 7.0.7.2)
19
+ activejob (= 7.0.7.2)
20
+ activerecord (= 7.0.7.2)
21
+ activestorage (= 7.0.7.2)
22
+ activesupport (= 7.0.7.2)
23
23
  mail (>= 2.7.1)
24
24
  net-imap
25
25
  net-pop
26
26
  net-smtp
27
- actionmailer (7.0.7)
28
- actionpack (= 7.0.7)
29
- actionview (= 7.0.7)
30
- activejob (= 7.0.7)
31
- activesupport (= 7.0.7)
27
+ actionmailer (7.0.7.2)
28
+ actionpack (= 7.0.7.2)
29
+ actionview (= 7.0.7.2)
30
+ activejob (= 7.0.7.2)
31
+ activesupport (= 7.0.7.2)
32
32
  mail (~> 2.5, >= 2.5.4)
33
33
  net-imap
34
34
  net-pop
35
35
  net-smtp
36
36
  rails-dom-testing (~> 2.0)
37
- actionpack (7.0.7)
38
- actionview (= 7.0.7)
39
- activesupport (= 7.0.7)
37
+ actionpack (7.0.7.2)
38
+ actionview (= 7.0.7.2)
39
+ activesupport (= 7.0.7.2)
40
40
  rack (~> 2.0, >= 2.2.4)
41
41
  rack-test (>= 0.6.3)
42
42
  rails-dom-testing (~> 2.0)
43
43
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
44
- actiontext (7.0.7)
45
- actionpack (= 7.0.7)
46
- activerecord (= 7.0.7)
47
- activestorage (= 7.0.7)
48
- activesupport (= 7.0.7)
44
+ actiontext (7.0.7.2)
45
+ actionpack (= 7.0.7.2)
46
+ activerecord (= 7.0.7.2)
47
+ activestorage (= 7.0.7.2)
48
+ activesupport (= 7.0.7.2)
49
49
  globalid (>= 0.6.0)
50
50
  nokogiri (>= 1.8.5)
51
- actionview (7.0.7)
52
- activesupport (= 7.0.7)
51
+ actionview (7.0.7.2)
52
+ activesupport (= 7.0.7.2)
53
53
  builder (~> 3.1)
54
54
  erubi (~> 1.4)
55
55
  rails-dom-testing (~> 2.0)
56
56
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
57
- activejob (7.0.7)
58
- activesupport (= 7.0.7)
57
+ activejob (7.0.7.2)
58
+ activesupport (= 7.0.7.2)
59
59
  globalid (>= 0.3.6)
60
- activemodel (7.0.7)
61
- activesupport (= 7.0.7)
62
- activerecord (7.0.7)
63
- activemodel (= 7.0.7)
64
- activesupport (= 7.0.7)
65
- activestorage (7.0.7)
66
- actionpack (= 7.0.7)
67
- activejob (= 7.0.7)
68
- activerecord (= 7.0.7)
69
- activesupport (= 7.0.7)
60
+ activemodel (7.0.7.2)
61
+ activesupport (= 7.0.7.2)
62
+ activerecord (7.0.7.2)
63
+ activemodel (= 7.0.7.2)
64
+ activesupport (= 7.0.7.2)
65
+ activestorage (7.0.7.2)
66
+ actionpack (= 7.0.7.2)
67
+ activejob (= 7.0.7.2)
68
+ activerecord (= 7.0.7.2)
69
+ activesupport (= 7.0.7.2)
70
70
  marcel (~> 1.0)
71
71
  mini_mime (>= 1.1.0)
72
- activesupport (7.0.7)
72
+ activesupport (7.0.7.2)
73
73
  concurrent-ruby (~> 1.0, >= 1.0.2)
74
74
  i18n (>= 1.6, < 2)
75
75
  minitest (>= 5.1)
@@ -80,14 +80,15 @@ GEM
80
80
  rake
81
81
  thor (>= 0.14.0)
82
82
  ast (2.4.2)
83
+ bigdecimal (3.1.4)
83
84
  builder (3.2.4)
84
85
  coderay (1.1.3)
85
86
  concurrent-ruby (1.2.2)
86
87
  crass (1.0.6)
87
88
  date (3.3.3)
88
89
  erubi (1.12.0)
89
- globalid (1.1.0)
90
- activesupport (>= 5.0)
90
+ globalid (1.2.0)
91
+ activesupport (>= 6.1)
91
92
  i18n (1.14.1)
92
93
  concurrent-ruby (~> 1.0)
93
94
  json (2.6.3)
@@ -133,20 +134,20 @@ GEM
133
134
  rack (2.2.8)
134
135
  rack-test (2.1.0)
135
136
  rack (>= 1.3)
136
- rails (7.0.7)
137
- actioncable (= 7.0.7)
138
- actionmailbox (= 7.0.7)
139
- actionmailer (= 7.0.7)
140
- actionpack (= 7.0.7)
141
- actiontext (= 7.0.7)
142
- actionview (= 7.0.7)
143
- activejob (= 7.0.7)
144
- activemodel (= 7.0.7)
145
- activerecord (= 7.0.7)
146
- activestorage (= 7.0.7)
147
- activesupport (= 7.0.7)
137
+ rails (7.0.7.2)
138
+ actioncable (= 7.0.7.2)
139
+ actionmailbox (= 7.0.7.2)
140
+ actionmailer (= 7.0.7.2)
141
+ actionpack (= 7.0.7.2)
142
+ actiontext (= 7.0.7.2)
143
+ actionview (= 7.0.7.2)
144
+ activejob (= 7.0.7.2)
145
+ activemodel (= 7.0.7.2)
146
+ activerecord (= 7.0.7.2)
147
+ activestorage (= 7.0.7.2)
148
+ activesupport (= 7.0.7.2)
148
149
  bundler (>= 1.15.0)
149
- railties (= 7.0.7)
150
+ railties (= 7.0.7.2)
150
151
  rails-dom-testing (2.2.0)
151
152
  activesupport (>= 5.0.0)
152
153
  minitest
@@ -154,9 +155,9 @@ GEM
154
155
  rails-html-sanitizer (1.6.0)
155
156
  loofah (~> 2.21)
156
157
  nokogiri (~> 1.14)
157
- railties (7.0.7)
158
- actionpack (= 7.0.7)
159
- activesupport (= 7.0.7)
158
+ railties (7.0.7.2)
159
+ actionpack (= 7.0.7.2)
160
+ activesupport (= 7.0.7.2)
160
161
  method_source
161
162
  rake (>= 12.2)
162
163
  thor (~> 1.0)
@@ -181,7 +182,8 @@ GEM
181
182
  rubocop (>= 1.7.0, < 2.0)
182
183
  rubocop-ast (>= 0.4.0)
183
184
  ruby-progressbar (1.13.0)
184
- sequel (5.71.0)
185
+ sequel (5.72.0)
186
+ bigdecimal
185
187
  sqlite3 (1.6.1)
186
188
  mini_portile2 (~> 2.8.0)
187
189
  standard (1.25.3)
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Sequel
4
+ module Generators
5
+ class ApplicationRecordGenerator < ::Rails::Generators::Base
6
+ source_root File.expand_path("templates", __dir__)
7
+
8
+ def create_application_record
9
+ template "application_record.rb", application_record_file_name
10
+ end
11
+
12
+ private
13
+
14
+ def application_record_file_name
15
+ @application_record_file_name ||=
16
+ if namespaced?
17
+ "app/models/#{namespaced_path}/application_record.rb"
18
+ else
19
+ "app/models/application_record.rb"
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Sequel
4
+ module Generators
5
+ class MigrationGenerator < ::Rails::Generators::NamedBase
6
+ include ::Rails::Generators::Migration
7
+
8
+ source_root File.expand_path("templates", __dir__)
9
+
10
+ argument :attributes, type: :array, default: [], banner: "field[:type][:index] field[:type][:index]"
11
+
12
+ def self.next_migration_number _dirname
13
+ Time.now.strftime "%Y%m%d%H%M%S"
14
+ end
15
+
16
+ def create_migration_file
17
+ migration_template "migration.rb.erb", "db/migrate/#{file_name}.rb"
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Sequel
4
+ module Generators
5
+ class ModelGenerator < ::Rails::Generators::NamedBase
6
+ source_root File.expand_path("templates", __dir__)
7
+ end
8
+ end
9
+ end
@@ -4,7 +4,7 @@ class ApplicationRecord < Sequel::Model
4
4
  dataset = nil
5
5
  end
6
6
 
7
- # Allows subclassed models to be initialzed with a customized dataset
7
+ # Allows subclassed models to be initialized with a customized dataset
8
8
  def ApplicationRecord *args
9
9
  ApplicationRecord.Model *args
10
10
  end
@@ -24,7 +24,7 @@ module Sequel
24
24
  ::Sequel::Rails::Railties::LogSubscriber.backtrace_cleaner.add_filter { |line| line.gsub(::Rails.root.to_s + File::SEPARATOR, "") }
25
25
 
26
26
  # Config initialization
27
- config.app_generators.orm :sequelize_rails, migration: :sequel_migration
27
+ config.app_generators.orm :sequel
28
28
  config.sequel = ActiveSupport::OrderedOptions.new
29
29
 
30
30
  initializer "sequel.plugins" do
@@ -64,6 +64,12 @@ module Sequel
64
64
  rake_tasks do
65
65
  load File.expand_path("../tasks.rake", __dir__)
66
66
  end
67
+
68
+ generators do
69
+ require "sequel/generators/application_record_generator"
70
+ require "sequel/generators/migration_generator"
71
+ require "sequel/generators/model_generator"
72
+ end
67
73
  end
68
74
  end
69
75
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Sequel
4
4
  module Rails
5
- VERSION = "0.4.1"
5
+ VERSION = "0.6.0"
6
6
  end
7
7
  end
data/lib/sequel/rails.rb CHANGED
@@ -7,12 +7,6 @@ require "sequel/rails/translation_support"
7
7
  # Plugins
8
8
  require "sequel/plugins/pretty_print"
9
9
 
10
- # Generators
11
- require "rails/generators"
12
- require "sequel/rails/generators/migration/migration_generator"
13
- require "sequel/rails/generators/model/model_generator"
14
- require "sequel/rails/generators/application_record/application_record_generator"
15
-
16
10
  # Minitest support
17
11
  begin
18
12
  gem "minitest"
@@ -125,13 +125,13 @@ db_namespace = namespace ns do
125
125
  end
126
126
 
127
127
  namespace :migrate do
128
- # desc "Runs the \"down\" method for the last applied migration"
128
+ desc "Runs the \"down\" method for the last applied migration"
129
129
  task down: [:connection] do
130
130
  target = (migrator.applied_migrations[-2] || "0_").split("_", 2).first.to_i
131
131
  migrator(target: target).run
132
132
  end
133
133
 
134
- # desc "Runs the \"up\" method for the next pending migration"
134
+ desc "Runs the \"up\" method for the next pending migration"
135
135
  task up: [:connection] do
136
136
  pending = migrator.migration_tuples.first
137
137
  if pending
@@ -172,30 +172,33 @@ db_namespace = namespace ns do
172
172
  desc "Rolls back the last migration"
173
173
  task rollback: [:"migrate:down"]
174
174
 
175
- # namespace :schema do
176
- # namespace :cache do
177
- # desc "Clears the database schema and indicies caches"
178
- # task clear: [] do
179
- # end
175
+ namespace :schema do
176
+ # namespace :cache do
177
+ # desc "Clears the database schema and indicies caches"
178
+ # task clear: [] do
179
+ # end
180
180
 
181
- # desc "Creates the database schema and indicies caches"
182
- # task dump: [] do
183
- # end
184
- # end
181
+ # desc "Creates the database schema and indicies caches"
182
+ # task dump: [] do
183
+ # end
184
+ # end
185
185
 
186
- # desc "Creates a backup of just the database's schema"
187
- # task dump: [] do
188
- # end
186
+ desc "Creates a backup of the database's schema"
187
+ task dump: [] do
188
+ puts "Please implement the #{ns}:schema:dump task within your Rakefile"
189
+ end
189
190
 
190
- # desc "Restores the database's schema from backup"
191
- # task load: [] do
192
- # end
193
- # end
191
+ desc "Restores the database's schema from backup"
192
+ task load: [] do
193
+ puts "Please implement the #{ns}:schema:load task within your Rakefile"
194
+ end
195
+ end
194
196
 
195
- # desc "Loads the seed data from db/seeds.rb"
196
- # task seed: [] do
197
- # end
197
+ desc "Loads seed data by running db/seeds.rb"
198
+ task seed: [:connection] do
199
+ require Rails.root.join("db", "seeds.rb")
200
+ end
198
201
 
199
- desc "Runs the #{ns}:create, #{ns}:migrate, #{ns}:seed tasks"
200
- task setup: [:"#{ns}:create", :"#{ns}:migrate", :"#{ns}:seed"]
202
+ desc "Runs the #{ns}:create, #{ns}:schema:load, #{ns}:migrate, #{ns}:seed tasks"
203
+ task setup: [:"#{ns}:create", :"#{ns}:schema:load", :"#{ns}:migrate", :"#{ns}:seed"]
201
204
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sequelize-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kenaniah Cerny
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-08-16 00:00:00.000000000 Z
11
+ date: 2023-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -145,6 +145,7 @@ extensions: []
145
145
  extra_rdoc_files: []
146
146
  files:
147
147
  - ".DS_Store"
148
+ - ".rubocop.yml"
148
149
  - ".standard.yml"
149
150
  - Appraisals
150
151
  - CHANGELOG.md
@@ -160,14 +161,14 @@ files:
160
161
  - gemfiles/rails_6.gemfile
161
162
  - gemfiles/rails_7.gemfile
162
163
  - lib/sequel/extensions/sequel_instrumentation.rb
164
+ - lib/sequel/generators/application_record_generator.rb
165
+ - lib/sequel/generators/migration_generator.rb
166
+ - lib/sequel/generators/model_generator.rb
167
+ - lib/sequel/generators/templates/application_record.rb.tt
168
+ - lib/sequel/generators/templates/migration.rb.erb
163
169
  - lib/sequel/plugins/pretty_print.rb
164
170
  - lib/sequel/rails.rb
165
171
  - lib/sequel/rails/db_console.rb
166
- - lib/sequel/rails/generators/application_record/application_record_generator.rb
167
- - lib/sequel/rails/generators/application_record/templates/application_record.rb.tt
168
- - lib/sequel/rails/generators/migration/migration_generator.rb
169
- - lib/sequel/rails/generators/migration/templates/migration.rb.erb
170
- - lib/sequel/rails/generators/model/model_generator.rb
171
172
  - lib/sequel/rails/minitest.rb
172
173
  - lib/sequel/rails/railtie.rb
173
174
  - lib/sequel/rails/railties/controller_runtime.rb
@@ -1,26 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Sequel
4
- module Rails
5
- module Generators
6
- class ApplicationRecordGenerator < ::Rails::Generators::Base
7
- source_root File.expand_path("templates", __dir__)
8
-
9
- def create_application_record
10
- template "application_record.rb", application_record_file_name
11
- end
12
-
13
- private
14
-
15
- def application_record_file_name
16
- @application_record_file_name ||=
17
- if namespaced?
18
- "app/models/#{namespaced_path}/application_record.rb"
19
- else
20
- "app/models/application_record.rb"
21
- end
22
- end
23
- end
24
- end
25
- end
26
- end
@@ -1,23 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Sequel
4
- module Rails
5
- module Generators
6
- class MigrationGenerator < ::Rails::Generators::NamedBase
7
- include ::Rails::Generators::Migration
8
-
9
- source_root File.expand_path("templates", __dir__)
10
-
11
- argument :attributes, type: :array, default: [], banner: "field[:type][:index] field[:type][:index]"
12
-
13
- def self.next_migration_number _dirname
14
- Time.now.strftime "%Y%m%d%H%M%S"
15
- end
16
-
17
- def create_migration_file
18
- migration_template "migration.rb.erb", "db/migrate/#{file_name}.rb"
19
- end
20
- end
21
- end
22
- end
23
- end
@@ -1,11 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Sequel
4
- module Rails
5
- module Generators
6
- class ModelGenerator < ::Rails::Generators::NamedBase
7
- source_root File.expand_path("templates", __dir__)
8
- end
9
- end
10
- end
11
- end