multiverse 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +5 -4
- data/CHANGELOG.md +6 -0
- data/README.md +3 -3
- data/lib/generators/multiverse/templates/{record.rb → record.rb.tt} +0 -0
- data/lib/multiverse.rb +3 -9
- data/lib/multiverse/generators.rb +7 -3
- data/lib/multiverse/railtie.rb +12 -14
- data/lib/multiverse/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 365e44dc02e354cb81a8d5e8962c51ec0873e208e35be402d24ce5826aee5a54
|
4
|
+
data.tar.gz: 262ca4346fcb9a9800cc5d8016860f64d9e88f0318cdde986626a09310a9a783
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa190b450724f9aa7d2c0fbe21618eb2fe8acb4169886129a018a1d20bf2e888884f33d604cff01c9d60c0599f6c33453a900eb2e81067a3d7788ea904183819
|
7
|
+
data.tar.gz: dde00c42005d41c515d0519719c7287d7bdd74fdbe66244167d772096928193a2d3cef51b057ba2af8695e00de8f98e6754784a1397ebb9448e0044c1e958738
|
data/.travis.yml
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
language: ruby
|
2
|
-
rvm: 2.
|
2
|
+
rvm: 2.5.1
|
3
3
|
gemfile:
|
4
4
|
- Gemfile
|
5
5
|
sudo: false
|
@@ -13,7 +13,8 @@ notifications:
|
|
13
13
|
on_success: never
|
14
14
|
on_failure: change
|
15
15
|
env:
|
16
|
-
- RAILS_VERSION=5.2.
|
17
|
-
- RAILS_VERSION=5.1
|
18
|
-
- RAILS_VERSION=5.
|
16
|
+
- RAILS_VERSION=5.2.1
|
17
|
+
- RAILS_VERSION=5.2.1 API=t
|
18
|
+
- RAILS_VERSION=5.1.6
|
19
|
+
- RAILS_VERSION=5.0.7
|
19
20
|
- RAILS_VERSION=4.2.10
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -33,7 +33,7 @@ This creates a `CatalogRecord` class for models to inherit from and adds configu
|
|
33
33
|
Create the database
|
34
34
|
|
35
35
|
```sh
|
36
|
-
DB=catalog
|
36
|
+
DB=catalog rails db:create
|
37
37
|
```
|
38
38
|
|
39
39
|
Create a migration
|
@@ -45,13 +45,13 @@ DB=catalog rails generate migration add_name_to_products
|
|
45
45
|
Run migrations
|
46
46
|
|
47
47
|
```sh
|
48
|
-
DB=catalog
|
48
|
+
DB=catalog rails db:migrate
|
49
49
|
```
|
50
50
|
|
51
51
|
Rollback
|
52
52
|
|
53
53
|
```sh
|
54
|
-
DB=catalog
|
54
|
+
DB=catalog rails db:rollback
|
55
55
|
```
|
56
56
|
|
57
57
|
## Models
|
File without changes
|
data/lib/multiverse.rb
CHANGED
@@ -11,19 +11,13 @@ module Multiverse
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def db_dir
|
14
|
-
db_dir = db
|
15
|
-
abort "Unknown DB: #{db}"
|
14
|
+
db_dir = "#{Rails.application.config.paths["db"].first}/#{db}"
|
15
|
+
abort "Unknown DB: #{db}" unless Dir.exist?(db_dir)
|
16
16
|
db_dir
|
17
17
|
end
|
18
18
|
|
19
19
|
def parent_class_name
|
20
|
-
|
21
|
-
"#{db.camelize}Record"
|
22
|
-
elsif ActiveRecord::VERSION::MAJOR >= 5
|
23
|
-
"ApplicationRecord"
|
24
|
-
else
|
25
|
-
"ActiveRecord::Base"
|
26
|
-
end
|
20
|
+
"#{db.camelize}Record"
|
27
21
|
end
|
28
22
|
|
29
23
|
def migrate_path
|
@@ -2,19 +2,23 @@ module Multiverse
|
|
2
2
|
module Generators
|
3
3
|
module ModelGenerator
|
4
4
|
def parent_class_name
|
5
|
-
Multiverse.parent_class_name
|
5
|
+
Multiverse.db ? Multiverse.parent_class_name : super
|
6
6
|
end
|
7
7
|
end
|
8
8
|
|
9
9
|
module Migration
|
10
10
|
def db_migrate_path
|
11
|
-
Multiverse.migrate_path
|
11
|
+
Multiverse.db ? Multiverse.migrate_path : super
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
15
|
module MigrationTemplate
|
16
16
|
def migration_template(source, destination, config = {})
|
17
|
-
|
17
|
+
if Multiverse.db
|
18
|
+
super(source, destination.sub("db/migrate", Multiverse.migrate_path), config)
|
19
|
+
else
|
20
|
+
super
|
21
|
+
end
|
18
22
|
end
|
19
23
|
end
|
20
24
|
end
|
data/lib/multiverse/railtie.rb
CHANGED
@@ -3,23 +3,21 @@ require "rails/railtie"
|
|
3
3
|
module Multiverse
|
4
4
|
class Railtie < Rails::Railtie
|
5
5
|
generators do
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
require "rails/generators/active_record/model/model_generator"
|
15
|
-
ActiveRecord::Generators::ModelGenerator.prepend(Multiverse::Generators::ModelGenerator)
|
6
|
+
ActiveSupport.on_load(:active_record) do
|
7
|
+
if ActiveRecord::VERSION::MAJOR >= 5
|
8
|
+
require "rails/generators/active_record/migration"
|
9
|
+
ActiveRecord::Generators::Migration.prepend(Multiverse::Generators::Migration)
|
10
|
+
else
|
11
|
+
require "rails/generators/migration"
|
12
|
+
Rails::Generators::Migration.prepend(Multiverse::Generators::MigrationTemplate)
|
13
|
+
end
|
16
14
|
|
17
|
-
|
18
|
-
|
19
|
-
ActiveRecord::Generators::ModelGenerator.prepend(Multiverse::Generators::
|
15
|
+
require "rails/generators/active_record/model/model_generator"
|
16
|
+
ActiveRecord::Generators::ModelGenerator.prepend(Multiverse::Generators::ModelGenerator)
|
17
|
+
ActiveRecord::Generators::ModelGenerator.prepend(Multiverse::Generators::MigrationTemplate)
|
20
18
|
|
21
19
|
require "rails/generators/active_record/migration/migration_generator"
|
22
|
-
ActiveRecord::Generators::MigrationGenerator.prepend(Multiverse::Generators::
|
20
|
+
ActiveRecord::Generators::MigrationGenerator.prepend(Multiverse::Generators::MigrationTemplate)
|
23
21
|
end
|
24
22
|
end
|
25
23
|
|
data/lib/multiverse/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: multiverse
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-08-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -123,7 +123,7 @@ files:
|
|
123
123
|
- README.md
|
124
124
|
- Rakefile
|
125
125
|
- lib/generators/multiverse/db_generator.rb
|
126
|
-
- lib/generators/multiverse/templates/record.rb
|
126
|
+
- lib/generators/multiverse/templates/record.rb.tt
|
127
127
|
- lib/multiverse.rb
|
128
128
|
- lib/multiverse/generators.rb
|
129
129
|
- lib/multiverse/railtie.rb
|
@@ -148,7 +148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
148
148
|
version: '0'
|
149
149
|
requirements: []
|
150
150
|
rubyforge_project:
|
151
|
-
rubygems_version: 2.
|
151
|
+
rubygems_version: 2.7.7
|
152
152
|
signing_key:
|
153
153
|
specification_version: 4
|
154
154
|
summary: Multiple databases for Rails
|