mobility 1.0.0.rc1 → 1.0.4

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: 8658079d8c9fad02763385921421140d2410cde1d505c286627de5a8c1819612
4
- data.tar.gz: 9bb012a9f564971e0c24fd3015e20e17384d7cbd77f2f0a5f1f1505e5262277a
3
+ metadata.gz: 4e614b2354ec6cfbc7d4b3d946beabc5214904c21432cceb0b78530ca389184e
4
+ data.tar.gz: fa9e5cf7097b92a203e38e07617254e42d3bc11f58254b4b13b359639b70902a
5
5
  SHA512:
6
- metadata.gz: 0a4a8a38a27d6f727091062010087466c85bfe48ce369395adb5501bd9875cfba21a56bce6a13b92b5cf83746883934f4161835f1336adedd9539bbf1138c51b
7
- data.tar.gz: ca65fdaf7af558d235fdb5ba45347b9ca2319d9e6d69ddf7611afa2a50a477a30998316ce8661ca640ced1d09cd05f6ff282b1edfebd79abf4830c142bdf95df
6
+ metadata.gz: ef1653434cb1e303f0496c9fecd810ea2d2772009dca94358949e293157e6f2a58341867ad6c117a5dc91469002acdd80b969d442126a7df95ea49f667360cc8
7
+ data.tar.gz: dceae9f7039d21bcd5d68a0a2f54515b39c0b8ab871c7386fe0834a88f973e91af5c27f48a85cdfe0d6479a8291a976abfee2208e16a116c4d75b03db54a8f87
@@ -1,3 +1,2 @@
1
- 8��>
2
- i!�]>T*Ho�m꿻��󒁹h�^B���"@�y ��1�$�{{UqK��Cu1+7)�&y��/z���b�-�ޮ�]vR��^�.'$~��btam��b�}F@\?
3
- �Օ�F?#�D�-��*�^�M�ɼ�̨��{�~��la�eY�f7 }o�<������Mye,H^��o@�^~ۦE�V0���aD��u���
1
+ z�UE-F��h9d8����CF�`3���F���rXp4�S;)���ߴ>]�B��o����Wn Y��"�!\�snE��NھH�zp��!C4ɦ�2�Ջ�s��n����=g�CV��i��b6��E�S��F���t+*��r|�-gd[��pغaCq���]�iZy��L�<u%�smШT��*~sk�}:�S T���Լ��i )�y,�V�Vc���‡O;��.򏸼g��؁��֮tvc�w�"V��]
2
+ m~k��?��,�{����G@�������]m�Ň?F&���VN�� �PdSޒ�dG�ah����y�*\���|p�ɒ�+� WP���:�;�G��䎄)jv3�]5yER��<<|��l��A
data.tar.gz.sig CHANGED
Binary file
@@ -1,22 +1,67 @@
1
1
  # Mobility Changelog
2
2
 
3
+ ### Unreleased
4
+ - Remove `Mobility::Plugins::Attributes#each`
5
+ ([#475](https://github.com/shioyama/mobility/pull/475))
6
+ - Add public method `Mobility::Plugins::ActiveRecord::Query.build_query`
7
+ ([#471](https://github.com/shioyama/mobility/pull/471))
8
+ - Allow setting locale per node in query block
9
+ ([#479](https://github.com/shioyama/mobility/pull/479))
10
+ - Add `Mobility.validate_locale!`
11
+ ([#479](https://github.com/shioyama/mobility/pull/479))
12
+ - Call after_destroy in setup block to delete associated translations
13
+ ([#487](https://github.com/shioyama/mobility/pull/487))
14
+ - Add key, value and belongs_to options to key-value backend
15
+ ([#488](https://github.com/shioyama/mobility/pull/488)) thanks
16
+ [sedubois](https://github.com/sedubois)!
17
+
3
18
  ## 1.0
4
19
 
5
- 1.0 is a rewrite of many internals of the gem. Please see the [wiki page on v1.0](https://github.com/shioyama/mobility/wiki/Introduction-to-Mobility-v1.0) for more details on how to upgrade.
20
+ 1.0 is a rewrite of many internals of the gem. Please see the [wiki page on
21
+ v1.0](https://github.com/shioyama/mobility/wiki/Introduction-to-Mobility-v1.0)
22
+ for more details on how to upgrade.
23
+
24
+ ### 1.0.4
25
+ - Correctly override default backend options, fixes
26
+ [#492](https://github.com/shioyama/mobility/issues/492)
27
+ ([#495](https://github.com/shioyama/mobility/pull/495))
28
+
29
+ ### 1.0.3
30
+ - Fix `Mobility.default_backend`
31
+ ([#497](https://github.com/shioyama/mobility/pull/497))
32
+
33
+ ### 1.0.2
34
+
35
+ ### 1.0.1
36
+
37
+ - Make `Mobility::Plugins::ActiveRecord::Query::VirtualRow` and
38
+ `Mobility::Plugins::ActiveRecord::Query::QueryExtension`
39
+ ([#471](https://github.com/shioyama/mobility/pull/471)) public
40
+ - Fix typo in initializer template
41
+ ([#474](https://github.com/shioyama/mobility/pull/474))
42
+
43
+ ### 1.0.0
44
+
45
+ - Fix setting a locale from Rails config
46
+ ([#468](https://github.com/shioyama/mobility/pull/468)) thanks
47
+ [sergey-alekseev](https://github.com/sergey-alekseev)!
48
+ - Fixes validations with validates_uniqueness_of
49
+ ([#470](https://github.com/shioyama/mobility/pull/470)) thanks
50
+ [artplan1](https://github.com/artplan1)!
6
51
 
7
- ## 1.0.0.rc1 (pre-release)
52
+ ### 1.0.0.rc1 (pre-release)
8
53
 
9
54
  - Remove `Mobility::ActiveRecord`, `Mobility::Sequel` and `Mobility::Arel`, and
10
55
  general cleanup ([#464](https://github.com/shioyama/mobility/pull/464))
11
56
 
12
- ## 1.0.0.beta2 (pre-release)
57
+ ### 1.0.0.beta2 (pre-release)
13
58
 
14
59
  - Refactor attributes & backend plugins and make `mobility_attributes` public
15
60
  ([#462](https://github.com/shioyama/mobility/pull/462))
16
61
  - Make attribute_methods plugin depend on attributes
17
62
  ([#461](https://github.com/shioyama/mobility/pull/461))
18
63
 
19
- ## 1.0.0.beta1 (pre-release)
64
+ ### 1.0.0.beta1 (pre-release)
20
65
 
21
66
  - Remove `Mobility::Backend#apply_plugin`
22
67
  ([#454](https://github.com/shioyama/mobility/pull/454))
@@ -27,7 +72,7 @@
27
72
  - Fix Ruby 2.7 deprecation warnings
28
73
  ([#460](https://github.com/shioyama/mobility/pull/460))
29
74
 
30
- ## 1.0.0.alpha (pre-release)
75
+ ### 1.0.0.alpha (pre-release)
31
76
 
32
77
  - Default fallbacks plugin to `true` when enabled
33
78
  ([#447](https://github.com/shioyama/mobility/pull/447))
data/Gemfile CHANGED
@@ -8,20 +8,11 @@ orm, orm_version = ENV['ORM'], ENV['ORM_VERSION']
8
8
  group :development, :test do
9
9
  case orm
10
10
  when 'active_record'
11
- orm_version ||= '6.0'
11
+ orm_version ||= '6.1'
12
12
  case orm_version
13
- when '4.2'
14
- gem 'activerecord', '>= 4.2.6', '< 5.0'
15
- when '5.0'
16
- gem 'activerecord', '>= 5.0', '< 5.1'
17
- when '5.1'
18
- gem 'activerecord', '>= 5.1', '< 5.2'
19
- when '5.2'
20
- gem 'activerecord', '>= 5.2.0', '< 5.3'
21
- gem 'railties', '>= 5.2.0.rc2', '< 5.3'
22
- when '6.0'
23
- gem 'activerecord', '>= 6.0.0', '< 6.1'
24
- when '6.1'
13
+ when '4.2', '5.0', '5.1', '5.2', '6.0', '6.1'
14
+ gem 'activerecord', "~> #{orm_version}.0"
15
+ when '6.2'
25
16
  git 'https://github.com/rails/rails.git' do
26
17
  gem 'activerecord'
27
18
  gem 'activesupport'
@@ -32,10 +23,8 @@ group :development, :test do
32
23
  when 'sequel'
33
24
  orm_version ||= '5'
34
25
  case orm_version
35
- when '4'
36
- gem 'sequel', '>= 4.46.0', '< 5.0'
37
26
  when '5'
38
- gem 'sequel', '>= 5.0.0', '< 6.0.0'
27
+ gem 'sequel', "~> #{orm_version}.0"
39
28
  else
40
29
  raise ArgumentError, 'Invalid Sequel version'
41
30
  end
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mobility (1.0.0.beta2)
4
+ mobility (1.0.1)
5
5
  i18n (>= 0.6.10, < 2)
6
6
  request_store (~> 1.0)
7
7
 
@@ -48,7 +48,7 @@ GEM
48
48
  rb-inotify (~> 0.9, >= 0.9.10)
49
49
  lumberjack (1.2.8)
50
50
  method_source (1.0.0)
51
- minitest (5.14.2)
51
+ minitest (5.14.3)
52
52
  nenv (0.3.0)
53
53
  notiffany (0.1.3)
54
54
  nenv (~> 0.1)
@@ -83,16 +83,16 @@ GEM
83
83
  shellany (0.0.1)
84
84
  thor (1.0.1)
85
85
  thread_safe (0.3.6)
86
- tzinfo (1.2.8)
86
+ tzinfo (1.2.9)
87
87
  thread_safe (~> 0.1)
88
88
  yard (0.9.25)
89
- zeitwerk (2.4.1)
89
+ zeitwerk (2.4.2)
90
90
 
91
91
  PLATFORMS
92
92
  ruby
93
93
 
94
94
  DEPENDENCIES
95
- activerecord (>= 6.0.0, < 6.1)
95
+ activerecord (~> 6.0.0)
96
96
  benchmark-ips
97
97
  database_cleaner (~> 1.5, >= 1.5.3)
98
98
  guard-rspec
data/README.md CHANGED
@@ -12,11 +12,9 @@ Mobility
12
12
  [docs]: http://www.rubydoc.info/gems/mobility
13
13
  [wiki]: https://github.com/shioyama/mobility/wiki
14
14
 
15
- **This is the readme for the [`master`](https://github.com/shioyama/mobility)
16
- branch, which corresponds to v1.0.0.rc1, a pre-release version of Mobility.
17
- If you are using an earlier version (0.8.x or earlier), you probably want the
18
- readme on the [0-8-stable
19
- branch](https://github.com/shioyama/mobility/tree/0-8-stable).**
15
+ **This is the readme for version 1.0 of Mobility. If you are using an earlier
16
+ version (0.8.x or earlier), you probably want the readme on the [0-8
17
+ branch](https://github.com/shioyama/mobility/tree/0-8).**
20
18
 
21
19
  Mobility is a gem for storing and retrieving translations as attributes on a
22
20
  class. These translations could be the content of blog posts, captions on
@@ -58,12 +56,9 @@ To use the latest pre-version of Mobility 1.0, add this line to your
58
56
  application's Gemfile:
59
57
 
60
58
  ```ruby
61
- gem 'mobility', '~> 1.0.0.rc1'
59
+ gem 'mobility', '~> 1.0.4'
62
60
  ```
63
61
 
64
- For the latest stable version of Mobility, see the readme on the
65
- [0-8-stable](https://github.com/shioyama/mobility/tree/0-8-stable) branch.
66
-
67
62
  ### ActiveRecord (Rails)
68
63
 
69
64
  Requirements:
@@ -92,8 +87,8 @@ which looks something like this:
92
87
 
93
88
  ```ruby
94
89
  Mobility.configure do
95
- # PLUGINS
96
90
 
91
+ # PLUGINS
97
92
  plugins do
98
93
  backend :key_value
99
94
 
@@ -107,15 +102,15 @@ Mobility.configure do
107
102
  end
108
103
  ```
109
104
 
110
- Each method call inside the block passed to `config.plugins` declares a plugin,
111
- along with an optional default. To use a different default backend, you can
105
+ Each method call inside the block passed to `plugins` declares a plugin, along
106
+ with an optional default. To use a different default backend, you can
112
107
  change the default passed to the `backend` plugin, like this:
113
108
 
114
109
  ```diff
115
- Mobility.configure do |config|
116
- # PLUGINS
110
+ Mobility.configure do
117
111
 
118
- config.plugins do
112
+ # PLUGINS
113
+ plugins do
119
114
  - backend :key_value
120
115
  + backend :table
121
116
  ```
@@ -126,10 +121,10 @@ You can also set defaults for backend-specific options. Below, we set the
126
121
  default `type` option for the KeyValue backend to `:string`.
127
122
 
128
123
  ```diff
129
- Mobility.configure do |config|
130
- # PLUGINS
124
+ Mobility.configure do
131
125
 
132
- config.plugins do
126
+ # PLUGINS
127
+ plugins do
133
128
  - backend :key_value
134
129
  + backend :key_value, type: :string
135
130
  end
@@ -150,7 +145,7 @@ Requirements:
150
145
  When configuring Mobility, ensure that you include the `sequel` plugin:
151
146
 
152
147
  ```diff
153
- config.plugins do
148
+ plugins do
154
149
  backend :key_value
155
150
 
156
151
  - active_record
@@ -297,7 +292,7 @@ accessors" in Mobility, and can be enabled by including the `locale_accessors`
297
292
  plugin, with a default set of accessors:
298
293
 
299
294
  ```diff
300
- config.plugins do
295
+ plugins do
301
296
  # ...
302
297
  + locale_accessors [:en, :ja]
303
298
  ```
@@ -345,7 +340,7 @@ defined for a given locale.)
345
340
  Ensure the plugin is enabled:
346
341
 
347
342
  ```diff
348
- config.plugins do
343
+ plugins do
349
344
  # ...
350
345
  + fallthrough_accessors
351
346
  ```
@@ -470,7 +465,7 @@ Mobility offers basic support for translation fallbacks. First, enable the
470
465
  `fallbacks` plugin:
471
466
 
472
467
  ```diff
473
- config.plugins do
468
+ plugins do
474
469
  # ...
475
470
  + fallbacks
476
471
  + locale_accessors
@@ -579,7 +574,7 @@ fallbacks](https://github.com/svenfuchs/i18n/wiki/Fallbacks).
579
574
  Another option is to assign a default value, using the `default` plugin:
580
575
 
581
576
  ```diff
582
- config.plugins do
577
+ plugins do
583
578
  # ...
584
579
  + default 'foo'
585
580
  ```
@@ -632,7 +627,7 @@ have enabled an ORM plugin (either `active_record` or `sequel`), since the
632
627
  dirty plugin will depend on one of these being enabled.
633
628
 
634
629
  ```diff
635
- config.plugins do
630
+ plugins do
636
631
  # ...
637
632
  active_record
638
633
  + dirty
@@ -722,7 +717,7 @@ can be quickly retrieved again. The cache plugin is included in the default
722
717
  configuration created by the install generator:
723
718
 
724
719
  ```diff
725
- config.plugins do
720
+ plugins do
726
721
  # ...
727
722
  + cache
728
723
  ```
@@ -752,7 +747,7 @@ this feature, include the `query` plugin, and ensure you also have an ORM
752
747
  plugin enabled (`active_record` or `sequel`):
753
748
 
754
749
  ```diff
755
- config.plugins do
750
+ plugins do
756
751
  # ...
757
752
  active_record
758
753
  + query
@@ -107,7 +107,7 @@ module Mobility
107
107
  # Alias to default backend defined on *translations_class+.
108
108
  # @return [Symbol,Class]
109
109
  def default_backend
110
- translations_class.defaults[:backend]
110
+ translations_class.defaults[:backend]&.first
111
111
  end
112
112
 
113
113
  # Configure Mobility
@@ -218,7 +218,7 @@ module Mobility
218
218
  # methods (in LocaleAccessors) than is really necessary.
219
219
  def available_locales
220
220
  if defined?(Rails) && Rails.application
221
- Rails.application.config.i18n.available_locales || I18n.available_locales
221
+ Rails.application.config.i18n.available_locales&.map(&:to_sym) || I18n.available_locales
222
222
  else
223
223
  I18n.available_locales
224
224
  end
@@ -121,8 +121,8 @@ Also includes a +configure+ class method to apply plugins to a pluggable
121
121
  # Does this class include all plugins this plugin depends (directly) on?
122
122
  # @param [Class] klass Pluggable class
123
123
  def dependencies_satisfied?(klass)
124
- required_plugins = dependencies.keys.map { |name| Plugins.load_plugin(name) }
125
- (required_plugins - klass.included_modules).none?
124
+ plugin_keys = klass.included_plugins.map { |plugin| Plugins.lookup_name(plugin) }
125
+ (dependencies.keys - plugin_keys).none?
126
126
  end
127
127
 
128
128
  # Specifies a dependency of this plugin.
@@ -67,9 +67,9 @@ enabled for any one attribute on the model.
67
67
  end
68
68
  end
69
69
 
70
- # Internal class to create a "clean room" for manipulating translated
71
- # attribute nodes in an instance-eval'ed block. Inspired by Sequel's
72
- # (much more sophisticated) virtual rows.
70
+ # Creates a "clean room" for manipulating translated attribute nodes in
71
+ # an instance-eval'ed block. Inspired by Sequel's (much more
72
+ # sophisticated) virtual rows.
73
73
  class VirtualRow < BasicObject
74
74
  attr_reader :__backends
75
75
 
@@ -108,7 +108,7 @@ enabled for any one attribute on the model.
108
108
  end
109
109
  end
110
110
  end
111
- private_constant :QueryMethod, :VirtualRow
111
+ private_constant :QueryMethod
112
112
 
113
113
  module QueryExtension
114
114
  def where!(opts, *rest)
@@ -273,7 +273,7 @@ enabled for any one attribute on the model.
273
273
  end
274
274
  end
275
275
 
276
- private_constant :QueryExtension, :FindByMethods
276
+ private_constant :FindByMethods
277
277
  end
278
278
 
279
279
  class MissingBackend < Mobility::Error; end
@@ -10,6 +10,10 @@ module Mobility
10
10
  klass.class_eval do
11
11
  unless const_defined?(:UniquenessValidator, false)
12
12
  self.const_set(:UniquenessValidator, Class.new(UniquenessValidator))
13
+
14
+ def self.validates_uniqueness_of(*attr_names)
15
+ validates_with(UniquenessValidator, _merge_attributes(attr_names))
16
+ end
13
17
  end
14
18
  end
15
19
  end
@@ -33,13 +33,6 @@ Defines:
33
33
  def initialize(*args, **original_options)
34
34
  super
35
35
 
36
- # Validate that the default backend from config has valid keys
37
- if (default = self.class.defaults[:backend])
38
- name, backend_options = default
39
- extra_keys = backend_options.keys - backend.valid_keys
40
- raise InvalidOptionKey, "These are not valid #{name} backend keys: #{extra_keys.join(', ')}." unless extra_keys.empty?
41
- end
42
-
43
36
  include InstanceMethods
44
37
  end
45
38
 
@@ -87,7 +80,7 @@ Defines:
87
80
 
88
81
  case options[:backend]
89
82
  when String, Symbol, Class
90
- @backend, @backend_options = options[:backend], options
83
+ @backend, @backend_options = options[:backend], options.dup
91
84
  when Array
92
85
  @backend, @backend_options = options[:backend]
93
86
  @backend_options = @backend_options.merge(original_options)
@@ -105,6 +98,14 @@ Defines:
105
98
  def validate_options(options)
106
99
  return super unless backend
107
100
  super(options.slice(*(options.keys - backend.valid_keys)))
101
+
102
+ # Validate that the default backend from config has valid keys, or if
103
+ # it is overridden by an array input that the array has valid keys.
104
+ if options[:backend].is_a?(Array)
105
+ name, backend_options = options[:backend]
106
+ extra_keys = backend_options.keys - backend.valid_keys
107
+ raise InvalidOptionKey, "These are not valid #{name} backend keys: #{extra_keys.join(', ')}." unless extra_keys.empty?
108
+ end
108
109
  end
109
110
 
110
111
  # Override default argument-handling in DSL to store kwargs passed along
@@ -8,8 +8,8 @@ module Mobility
8
8
  module VERSION
9
9
  MAJOR = 1
10
10
  MINOR = 0
11
- TINY = 0
12
- PRE = "rc1"
11
+ TINY = 4
12
+ PRE = nil
13
13
 
14
14
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
15
15
  end
@@ -1,5 +1,4 @@
1
1
  class CreateStringTranslations < <%= activerecord_migration_class %>
2
-
3
2
  def change
4
3
  create_table :mobility_string_translations do |t|
5
4
  t.string :locale, null: false
@@ -1,5 +1,4 @@
1
1
  class CreateTextTranslations < <%= activerecord_migration_class %>
2
-
3
2
  def change
4
3
  create_table :mobility_text_translations do |t|
5
4
  t.string :locale, null: false
@@ -1,5 +1,4 @@
1
1
  Mobility.configure do
2
-
3
2
  # PLUGINS
4
3
  plugins do
5
4
  # Backend
@@ -104,5 +103,14 @@ Mobility.configure do
104
103
  #
105
104
  # Or define specific defaults by uncommenting line below
106
105
  # locale_accessors [:en, :ja]
106
+
107
+ # Attribute Methods
108
+ #
109
+ # Adds translated attributes to +attributes+ hash, and defines methods
110
+ # +translated_attributes+ and +untranslated_attributes+ which return hashes
111
+ # with translated and untranslated attributes, respectively. Be aware that
112
+ # this plugin can create conflicts with other gems.
113
+ #
114
+ # attribute_methods
107
115
  end
108
116
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mobility
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.rc1
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Salzberg
@@ -34,7 +34,7 @@ cert_chain:
34
34
  gSQml7TqcC6dZRsZRwYqzD9kUwdAJoCqno2CBUKs2l0yQAjFT36lRrVJznb7uWwa
35
35
  xpPFnsrtyaZW6Dty8TSG3qzmeGpmpIotA8x1VA==
36
36
  -----END CERTIFICATE-----
37
- date: 2020-11-23 00:00:00.000000000 Z
37
+ date: 2021-01-31 00:00:00.000000000 Z
38
38
  dependencies:
39
39
  - !ruby/object:Gem::Dependency
40
40
  name: request_store
@@ -247,7 +247,13 @@ metadata:
247
247
  homepage_uri: https://github.com/shioyama/mobility
248
248
  source_code_uri: https://github.com/shioyama/mobility
249
249
  changelog_uri: https://github.com/shioyama/mobility/blob/master/CHANGELOG.md
250
- post_install_message:
250
+ post_install_message: |2
251
+
252
+ Warning: Mobility v1.0 includes backwards-incompatible changes (mostly around configuration).
253
+
254
+ If you are upgrading from an earlier version, please see:
255
+ - https://github.com/shioyama/mobility/releases/tag/v1.0.0
256
+ - https://github.com/shioyama/mobility/wiki/Introduction-to-Mobility-v1.0
251
257
  rdoc_options: []
252
258
  require_paths:
253
259
  - lib
@@ -258,9 +264,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
258
264
  version: '2.5'
259
265
  required_rubygems_version: !ruby/object:Gem::Requirement
260
266
  requirements:
261
- - - ">"
267
+ - - ">="
262
268
  - !ruby/object:Gem::Version
263
- version: 1.3.1
269
+ version: '0'
264
270
  requirements: []
265
271
  rubygems_version: 3.1.2
266
272
  signing_key:
metadata.gz.sig CHANGED
Binary file