activerecord-text-search-configuration 0.0.1 → 0.0.2

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: afbdb8cf9b7b89a5f0825b33393d58a5fb0478e6a031646a4dbbf4afbb89ba34
4
- data.tar.gz: 90574a92d626ba0861cc522dfe8dd6d9bb4d5e9f8397fe80e8efceaeb08926d2
3
+ metadata.gz: 570691dfaa883e86226e49e9c62be2ce9c5f1b6fa374db9ebb531bb39df5fcfa
4
+ data.tar.gz: 1dbb5918dbe51d9f04c219dd8b54e6bcce88057f590c948dd36043c1f5418bbb
5
5
  SHA512:
6
- metadata.gz: d13520cbe86371cf2df820aca696cd482ea69a9205e7a665fea3a4597fd8ae9503339b102cc9c41a428d79c699693498bedeaa21632a2f1f3afee2ca672e3bce
7
- data.tar.gz: e61a3191d201d6fdbebadb7c36248d1419daf75a474e62c956dc29ae8b8996b37be92fe3954f694ea41a72e610e3ddf745e3328955e6e04e4e5a2a248274b473
6
+ metadata.gz: 6fba43c0aa8ab8c4963b2f335d291bcf6d8f53ffa7f1564d8623f3901bd6a590601579468dde104bc29e608756229b45cbb1b3b9304ad70bf3c9b90c9bce57b6
7
+ data.tar.gz: fa2834e91e64f28368e79fb653520a4ec7e50df63caba16f93969542b117c8dadacb7f6c9011c8090634c4714c4590b05a1f0f96647d899be5a45227008fbd1f
@@ -4,25 +4,26 @@ module ActiveRecord
4
4
  module TextSearchConfiguration
5
5
  # Records text search configuration statements in migrations so they can be reverted.
6
6
  module CommandRecorder
7
- def create_text_search_configuration(*args, &)
8
- record(:create_text_search_configuration, args, &)
7
+ def create_text_search_configuration(*args, **kwargs, &)
8
+ command = text_search_configuration_command(__method__, args, kwargs)
9
+ record(*command, &)
9
10
  end
10
11
 
11
- def drop_text_search_configuration(*args, &)
12
- record(:drop_text_search_configuration, args, &)
12
+ def drop_text_search_configuration(*args, **kwargs, &)
13
+ command = text_search_configuration_command(__method__, args, kwargs)
14
+ record(*command, &)
13
15
  end
14
16
 
15
17
  private
16
18
 
17
- def invert_create_text_search_configuration(args)
18
- [:drop_text_search_configuration, [args.first]]
19
+ def invert_create_text_search_configuration(args, _kwargs = nil)
20
+ text_search_configuration_command(:drop_text_search_configuration, [args.first], {})
19
21
  end
20
22
 
21
23
  # Dropping can only be reverted when the migration passes everything needed to create the
22
24
  # configuration again.
23
- def invert_drop_text_search_configuration(args)
24
- options = args.extract_options!
25
- if options[:parser].nil? && options[:copy].nil?
25
+ def invert_drop_text_search_configuration(args, kwargs = args.extract_options!)
26
+ if kwargs[:parser].nil? && kwargs[:copy].nil?
26
27
  raise(
27
28
  ActiveRecord::IrreversibleMigration,
28
29
  'To make drop_text_search_configuration reversible, pass parser: or copy: and ' \
@@ -30,7 +31,18 @@ module ActiveRecord
30
31
  )
31
32
  end
32
33
 
33
- [:create_text_search_configuration, [args.first, options.except(:if_exists, :force)]]
34
+ text_search_configuration_command(
35
+ :create_text_search_configuration, [args.first], kwargs.except(:if_exists, :force)
36
+ )
37
+ end
38
+
39
+ # Rails 8.2 takes three instead of two arguments to the methods, this is an adapter so the
40
+ # code works on older and newer versions of Rails.
41
+ def text_search_configuration_command(command, args, kwargs)
42
+ return [command, args, kwargs] if method(:record).arity == 3
43
+ return [command, args] if kwargs.empty?
44
+
45
+ [command, [*args, Hash.ruby2_keywords_hash(kwargs)]]
34
46
  end
35
47
  end
36
48
  end
@@ -23,6 +23,7 @@ module ActiveRecord
23
23
 
24
24
  private
25
25
 
26
+ # rubocop:disable-next Metrics/AbcSize
26
27
  def text_search_configuration(stream, configuration)
27
28
  stream.puts(" create_text_search_configuration(\n")
28
29
  stream.puts(" #{configuration[:name].inspect},")
@@ -2,6 +2,6 @@
2
2
 
3
3
  module ActiveRecord
4
4
  module TextSearchConfiguration
5
- VERSION = '0.0.1'
5
+ VERSION = '0.0.2'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-text-search-configuration
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Manfred Stienstra