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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: f4569d0c19e94ae2656d0b6bf1b83023c28a96d1
4
- data.tar.gz: 696ab1dfa89bdffdfb4af49e2d6d7ac02f7a56ea
2
+ SHA256:
3
+ metadata.gz: 365e44dc02e354cb81a8d5e8962c51ec0873e208e35be402d24ce5826aee5a54
4
+ data.tar.gz: 262ca4346fcb9a9800cc5d8016860f64d9e88f0318cdde986626a09310a9a783
5
5
  SHA512:
6
- metadata.gz: ed54801e4b6ed8992884635bcf5f638cd0c1b7140fc852e062b54290ab0af49b32d5a7c3ef6ea5fdc4706e7a20ccd7e08cea63a9906ba39c3486e0e20edc7357
7
- data.tar.gz: a496c9ecbf793d6ee89b79df65b89d50a4ca8b818f79fad7eff152c60397347dec5df38561ae15cee7efe5c6a6751616682fb2f2410bfacce0d9c36926d609cd
6
+ metadata.gz: aa190b450724f9aa7d2c0fbe21618eb2fe8acb4169886129a018a1d20bf2e888884f33d604cff01c9d60c0599f6c33453a900eb2e81067a3d7788ea904183819
7
+ data.tar.gz: dde00c42005d41c515d0519719c7287d7bdd74fdbe66244167d772096928193a2d3cef51b057ba2af8695e00de8f98e6754784a1397ebb9448e0044c1e958738
data/.travis.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  language: ruby
2
- rvm: 2.4.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.0.rc1
17
- - RAILS_VERSION=5.1.4
18
- - RAILS_VERSION=5.0.6
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
@@ -1,3 +1,9 @@
1
+ ## 0.2.1
2
+
3
+ - Added support for `config.paths["db"]`
4
+ - Fixed migration generation when DB specified for Rails < 5.0.2
5
+ - Fixed Rails API
6
+
1
7
  ## 0.2.0
2
8
 
3
9
  - Added support for Rails 4.2
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 rake db:create
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 rake db:migrate
48
+ DB=catalog rails db:migrate
49
49
  ```
50
50
 
51
51
  Rollback
52
52
 
53
53
  ```sh
54
- DB=catalog rake db:rollback
54
+ DB=catalog rails db:rollback
55
55
  ```
56
56
 
57
57
  ## Models
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 ? "db/#{db}" : "db"
15
- abort "Unknown DB: #{db}" if db && !Dir.exist?(db_dir)
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
- if db
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
- super(source, destination.sub("db/migrate", Multiverse.migrate_path), config)
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
@@ -3,23 +3,21 @@ require "rails/railtie"
3
3
  module Multiverse
4
4
  class Railtie < Rails::Railtie
5
5
  generators do
6
- if ActiveRecord::VERSION::MAJOR >= 5
7
- require "rails/generators/active_record/migration"
8
- ActiveRecord::Generators::Migration.prepend(Multiverse::Generators::Migration)
9
- else
10
- require "rails/generators/migration"
11
- Rails::Generators::Migration.prepend(Multiverse::Generators::MigrationTemplate)
12
- end
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
- # for Rails < 5.0.3, need to patch db_migrate_path in model and migration generator
18
- if ActiveRecord::VERSION::MAJOR == 5 && ActiveRecord.version < Gem::Version.new("5.0.3")
19
- ActiveRecord::Generators::ModelGenerator.prepend(Multiverse::Generators::Migration)
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::Migration)
20
+ ActiveRecord::Generators::MigrationGenerator.prepend(Multiverse::Generators::MigrationTemplate)
23
21
  end
24
22
  end
25
23
 
@@ -1,3 +1,3 @@
1
1
  module Multiverse
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
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.0
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-02-19 00:00:00.000000000 Z
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.6.13
151
+ rubygems_version: 2.7.7
152
152
  signing_key:
153
153
  specification_version: 4
154
154
  summary: Multiple databases for Rails