kaal-rails 0.3.0 → 0.5.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: 800bd823b767eafa640969d895f5c1b408f6cfdbce1ea386ca98950eadd2ccc1
4
- data.tar.gz: 8f611cf0bd2b4f9002184cbf5f5743444aeb8ebcd0b2faa8482f761a5c48ddfb
3
+ metadata.gz: f6c3d26fefed62ee5114436e1a5695133e88770be0f64d0aff9cc3358e1367a8
4
+ data.tar.gz: 84f117442db3c9c21569d2a55460bf575167aeefb190cd4ae90dae443c425073
5
5
  SHA512:
6
- metadata.gz: ea626952cb9cf77da562331ebb7ba727fdae05ff434d99a652e5c9d19c1549a12754d546d63ea69188962dab96391802ce04052f9e2014f46119a20437e9c913
7
- data.tar.gz: 6cbb6b3d94a29f3b3217fd19052c74feaad8f009ec2b69e6ebfaae41687f51f73ddf17e7a1c4e07d9d32541b115f33563d9d4a3926b841cb5706f9bf0e7e4959
6
+ metadata.gz: 45c1e82dafa72cb398fcc4a58ecd5616dabe69c89e9cd2501a645e6a097f5665571c1849178ac230278c438d539efa7b6a622e65537d2fbdc001f333fcd1de11
7
+ data.tar.gz: 527d9da69cc8cc495a9c2bb8a139188dfbcc895362aab1a307e46e3f3699a8f837d59a54481825b1fd0f69bc3fc20356aa422ec27a62830dd3e0579da52f2b69
data/README.md CHANGED
@@ -5,7 +5,6 @@ Rails plugin gem for Kaal.
5
5
  `kaal-rails` depends on:
6
6
 
7
7
  - `kaal`
8
- - `kaal-activerecord`
9
8
 
10
9
  It owns the Rails integration surface:
11
10
 
@@ -42,12 +41,15 @@ bundle exec rails generate kaal:install --backend=mysql
42
41
  bundle exec rails db:migrate
43
42
  ```
44
43
 
44
+ These migrations install the Kaal persistence tables required by the selected backend.
45
+
45
46
  ## What It Provides
46
47
 
47
48
  - Rails-native setup on top of the Kaal engine
48
- - Active Record-backed persistence through `kaal-activerecord`
49
+ - Active Record-backed persistence through the core `kaal` gem
49
50
  - migration templates for the Kaal tables required by the selected backend
50
51
  - automatic backend selection from the Rails database adapter unless the app sets `Kaal.configuration.backend` itself
52
+ - the normal Kaal runtime API in a Rails install surface
51
53
 
52
54
  ## Usage
53
55
 
@@ -61,9 +63,9 @@ end
61
63
 
62
64
  If you do nothing, `kaal-rails` will auto-wire:
63
65
 
64
- - SQLite to `Kaal::ActiveRecord::DatabaseAdapter`
65
- - PostgreSQL to `Kaal::ActiveRecord::PostgresAdapter`
66
- - MySQL to `Kaal::ActiveRecord::MySQLAdapter`
66
+ - SQLite to `Kaal::Backend::SQLite`
67
+ - PostgreSQL to `Kaal::Backend::Postgres`
68
+ - MySQL to `Kaal::Backend::MySQL`
67
69
 
68
70
  Available Rails surfaces:
69
71
 
@@ -6,6 +6,7 @@
6
6
  # LICENSE file in the root directory of this source tree.
7
7
  require 'fileutils'
8
8
  require 'pathname'
9
+ require 'kaal/internal/active_record/migration_templates'
9
10
 
10
11
  module Kaal
11
12
  module Rails
@@ -40,15 +41,14 @@ module Kaal
40
41
 
41
42
  def install_migrations
42
43
  migrations_dir = root.join('db', 'migrate')
43
- base_time = time_source.call
44
44
  FileUtils.mkdir_p(migrations_dir)
45
45
 
46
- Kaal::ActiveRecord::MigrationTemplates.for_backend(backend).map.with_index do |(name, contents), index|
46
+ Kaal::Internal::ActiveRecord::MigrationTemplates.for_backend(backend).map.with_index do |(name, contents), index|
47
47
  slug = name.sub(/^\d+_/, '')
48
48
  existing = Dir[migrations_dir.join("*_#{slug}").to_s].first
49
49
  next({ status: :exists, path: existing.to_s }) if existing
50
50
 
51
- timestamp = (base_time + index).strftime('%Y%m%d%H%M%S')
51
+ timestamp = (time_source.call + index).strftime('%Y%m%d%H%M%S')
52
52
  target = migrations_dir.join("#{timestamp}_#{slug}")
53
53
  File.write(target, contents)
54
54
  { status: :create, path: target.to_s }
@@ -6,6 +6,6 @@
6
6
  # LICENSE file in the root directory of this source tree.
7
7
  module Kaal
8
8
  module Rails
9
- VERSION = '0.3.0'
9
+ VERSION = '0.5.0'
10
10
  end
11
11
  end
data/lib/kaal/rails.rb CHANGED
@@ -6,7 +6,6 @@
6
6
  # LICENSE file in the root directory of this source tree.
7
7
  require 'pathname'
8
8
  require 'kaal'
9
- require 'kaal/active_record'
10
9
  require 'kaal/rails/version'
11
10
  require 'kaal/rails/installer'
12
11
  require 'kaal/rails/railtie'
@@ -33,20 +32,23 @@ module Kaal
33
32
  def build_backend(backend_name = detect_backend_name)
34
33
  case backend_name.to_s
35
34
  when 'sqlite'
36
- Kaal::ActiveRecord::DatabaseAdapter.new
35
+ Kaal::Backend::SQLite.new
37
36
  when 'postgres'
38
- Kaal::ActiveRecord::PostgresAdapter.new
37
+ Kaal::Backend::Postgres.new
39
38
  when 'mysql'
40
- Kaal::ActiveRecord::MySQLAdapter.new
39
+ Kaal::Backend::MySQL.new
41
40
  end
42
41
  end
43
42
 
44
43
  def configure_backend!(configuration: Kaal.configuration, backend: build_backend)
44
+ logger = configuration.logger
45
45
  current_backend = configuration.backend
46
- return current_backend if current_backend
47
- return nil unless backend
46
+ selected_backend = current_backend || backend
47
+ return nil unless selected_backend
48
48
 
49
- configuration.backend = backend
49
+ configuration.backend = selected_backend unless current_backend
50
+ Kaal.warn_on_risky_configuration!(configuration:, logger:)
51
+ selected_backend
50
52
  end
51
53
 
52
54
  def install!(root: ::Rails.root, backend: detect_backend_name)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kaal-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nitesh Purohit
@@ -16,28 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 0.3.0
19
+ version: 0.5.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 0.3.0
27
- - !ruby/object:Gem::Dependency
28
- name: kaal-activerecord
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - '='
32
- - !ruby/object:Gem::Version
33
- version: 0.3.0
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - '='
39
- - !ruby/object:Gem::Version
40
- version: 0.3.0
26
+ version: 0.5.0
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: rails
43
29
  requirement: !ruby/object:Gem::Requirement