globalize 6.0.0.alpha.1 → 6.0.0

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
2
  SHA256:
3
- metadata.gz: bb12d7f3b6c17018cefe1614dfba6b585ba169ef2ca412b58d230ccabf778033
4
- data.tar.gz: ac44f2e8a75b53ad116b8674d1f5c3d47a122c9782133e3853359217fb944375
3
+ metadata.gz: 7501e626a9b5bfd187c9db3d0b5a809351308d7783c606a486cb9dab2a7d1649
4
+ data.tar.gz: f3661b320279e118f396356680dceaa12d322495d823978a1b89d9628ec712de
5
5
  SHA512:
6
- metadata.gz: 2f358f026bc47645ae8751cb3b2a3a7660cfbbb64c6c37e2ab2b46a9b548de357ba0e8a8880eb82326ce78c6e7605c31fbf27726d645b33baa62c594bace13b5
7
- data.tar.gz: 185fbeea91d8fda53c23232897deba40ad149fbea99c329a32aa8d9bbd7c296c4b9a5a814ced76d39785969d8503011f9316bc600a07de7e82b1a03fe0c3a76a
6
+ metadata.gz: 525c265c86c7ed85a78dea1c721c20f98db1b74cf23bb49453e5677c3ee4605e18fe708d1e1f77723b784f5d98f717181f154c7cd664fe54236756711149881a
7
+ data.tar.gz: 25e5300ccf2279af73d7e8df8c2ffd5f23a616a3d1fbb3c6289dff82182277b4e045a7ca1443643b44f78f9d0ac2cb5a188ebe9a7e455dd2cbb700d0dc857939
Binary file
@@ -0,0 +1 @@
1
+ ?$��ʀ�th1�7J����a/[��4a��jZ�X==�k����At��P�luU@'�~�=����+����ef>m�O�~)�����-)�z�,��q�nM��6iŨ��7_�G�5"2ɳx�A��
data/Appraisals CHANGED
@@ -1,15 +1,35 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  RAILS_VERSIONS = %w[
4
- 4.2.10
5
- 5.1.6
6
- 5.2.1
4
+ 4.2.11.3
5
+ 5.1.7
6
+ 5.2.4.4
7
+ 6.0.3.4
8
+ 6.1.0
7
9
  ]
8
10
 
9
11
  RAILS_VERSIONS.each do |version|
10
12
  appraise "rails_#{version}" do
11
13
  gem 'activemodel', version
12
14
  gem 'activerecord', version
15
+
16
+ if version =~ /^6/
17
+ gem 'sqlite3', '~> 1.4', platforms: [:ruby, :rbx]
18
+ elsif version =~ /^5/
19
+ gem 'sqlite3', '~> 1.3', '>= 1.3.6', platforms: [:ruby, :rbx]
20
+ else version =~ /^4/
21
+ gem 'sqlite3', '~> 1.3.6', platforms: [:ruby, :rbx]
22
+ end
23
+
24
+ if !ENV['CI'] || %w(postgres postgresql).include?(ENV['DB'])
25
+ group :postgres, :postgresql do
26
+ if version =~ /^4/
27
+ gem 'pg', '< 1.0', platforms: [:ruby, :rbx]
28
+ else
29
+ gem 'pg', '~> 1.1', platforms: [:ruby, :rbx]
30
+ end
31
+ end
32
+ end
13
33
 
14
34
  platforms :rbx do
15
35
  gem "rubysl", "~> 2.0"
@@ -3,7 +3,8 @@
3
3
  ## Unreleased
4
4
 
5
5
  * Add `create_source_columns` option for migrations. [#715](https://github.com/globalize/globalize/pull/715) by [IlyasValiullov](https://github.com/IlyasValiullov)
6
- * Autosave is now configurable, but defaults to false. [#736](https://github.com/globalize/globalize/pull/736) by [James Hart](https://github.com/hjhart)
6
+ * Autosave is now configurable, but defaults to false. [#736](https://github.com/globalize/globalize/pull/736) by [James Hart](https://github.com/hjhart)
7
+ * Fix foreign keys translation. [#769](https://github.com/globalize/globalize/pull/769) by [Sergey Tokarenko](https://github.com/stokarenko)
7
8
 
8
9
  ## 5.3.0 (2019-05-14)
9
10
 
data/README.md CHANGED
@@ -12,6 +12,11 @@ to add model translations to ActiveRecord models.
12
12
 
13
13
  In other words, a way to translate actual user-generated content, for example; a single blog post with multiple translations.
14
14
 
15
+ ## Current state of the gem
16
+
17
+ Globalize is not very actively maintained. Pull Requests are welcome, especially for compatibility with new versions of Rails, but none of the maintainers actively use Globalize anymore. If you need a more actively maintained model translation gem, we recommend checking out [Mobility](https://github.com/shioyama/mobility), a natural successor of Globalize created by Chris Salzberg (one of Globalize maintainers) and inspired by the ideas discussed around Globalize. For a more up-to-date discussion of the current situation, see [issue #753](https://github.com/globalize/globalize/issues/753).
18
+
19
+
15
20
  ## Requirements
16
21
 
17
22
  * ActiveRecord >= 4.2.0 (see below for installation with ActiveRecord 3.x)
@@ -0,0 +1,22 @@
1
+ version: '3.7'
2
+ services:
3
+ postgres:
4
+ image: postgres:11
5
+ volumes:
6
+ - ./tmp/postgres:/var/lib/postgresql/data
7
+ ports:
8
+ - "5432:5432"
9
+ environment:
10
+ POSTGRES_USER: "postgres"
11
+ POSTGRES_PASSWORD: ""
12
+ mysql:
13
+ image: mysql:8.0
14
+ volumes:
15
+ - ./tmp/mysql:/var/lib/mysql
16
+ ports:
17
+ - "3306:3306"
18
+ environment:
19
+ MYSQL_USER: "root"
20
+ MYSQL_PASSWORD: ""
21
+ MYSQL_ROOT_PASSWORD: ""
22
+ MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/globalize/version'
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = 'globalize'
7
+ s.version = Globalize::Version
8
+ s.authors = ['Sven Fuchs', 'Joshua Harvey', 'Clemens Kofler', 'John-Paul Bader', 'Tomasz Stachewicz', 'Philip Arndt', 'Chris Salzberg']
9
+ s.email = 'nobody@globalize-rails.org'
10
+ s.homepage = 'http://github.com/globalize/globalize'
11
+ s.summary = 'Rails I18n de-facto standard library for ActiveRecord model/data translation'
12
+ s.description = "#{s.summary}."
13
+ s.license = "MIT"
14
+
15
+ s.files = Dir['{lib/**/*,[A-Z]*}']
16
+ s.platform = Gem::Platform::RUBY
17
+ s.require_path = 'lib'
18
+ s.required_ruby_version = '>= 2.4.6'
19
+
20
+ s.add_dependency 'activerecord', '>= 4.2', '< 7.0'
21
+ s.add_dependency 'activemodel', '>= 4.2', '< 7.0'
22
+ s.add_dependency 'request_store', '~> 1.0'
23
+
24
+ s.add_development_dependency 'appraisal'
25
+ s.add_development_dependency 'database_cleaner'
26
+ s.add_development_dependency 'm'
27
+ s.add_development_dependency 'minitest'
28
+ s.add_development_dependency 'minitest-reporters'
29
+ s.add_development_dependency 'pry'
30
+ s.add_development_dependency 'rake'
31
+ s.add_development_dependency 'rdoc'
32
+
33
+ s.cert_chain = [File.expand_path('certs/parndt.pem', __dir__)]
34
+ if $PROGRAM_NAME =~ /gem\z/ && ARGV.include?('build') && ARGV.include?(__FILE__)
35
+ s.signing_key = File.expand_path('~/.ssh/gem-private_key.pem')
36
+ end
37
+ end
@@ -0,0 +1,38 @@
1
+ # Activate the gem you are reporting the issue against.
2
+ gem 'activerecord', '4.2.0'
3
+ gem 'globalize', '5.0.1'
4
+ require 'active_record'
5
+ require 'globalize'
6
+ require 'minitest/autorun'
7
+ require 'logger'
8
+
9
+ # Ensure backward compatibility with Minitest 4
10
+ Minitest::Test = MiniTest::Unit::TestCase unless defined?(Minitest::Test)
11
+
12
+ # This connection will do for database-independent bug reports.
13
+ ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
14
+ ActiveRecord::Base.logger = Logger.new(STDOUT)
15
+
16
+ ActiveRecord::Schema.define do
17
+ create_table :posts, force: true do |t|
18
+ end
19
+
20
+ create_table :post_translations, force: true do |t|
21
+ t.references :post
22
+ t.string :title
23
+ t.text :content
24
+ t.string :locale
25
+ end
26
+ end
27
+
28
+ class Post < ActiveRecord::Base
29
+ translates :content, :title
30
+ end
31
+
32
+ class BugTest < Minitest::Test
33
+ def test_association_stuff
34
+ post = Post.create!(title: 'HI')
35
+
36
+ assert_equal 'HI', post.title
37
+ end
38
+ end
@@ -66,6 +66,14 @@ module Globalize
66
66
  ::ActiveRecord.version >= Gem::Version.new('5.2.0')
67
67
  end
68
68
 
69
+ def rails_6?
70
+ ::ActiveRecord.version >= Gem::Version.new('6.0.0')
71
+ end
72
+
73
+ def rails_61?
74
+ ::ActiveRecord.version >= Gem::Version.new('6.1.0')
75
+ end
76
+
69
77
  protected
70
78
 
71
79
  def read_locale
@@ -41,11 +41,17 @@ module Globalize
41
41
  self.dirty = {}
42
42
  end
43
43
 
44
- def _reset_attribute name
45
- original_value = record.changed_attributes[name]
46
- record.send(:clear_attribute_changes, [name])
47
- record.send("#{name}=", original_value)
48
- record.send(:clear_attribute_changes, [name])
44
+ if Globalize.rails_6?
45
+ def _reset_attribute name
46
+ record.send(:clear_attribute_changes, [name])
47
+ end
48
+ else
49
+ def _reset_attribute name
50
+ original_value = record.changed_attributes[name]
51
+ record.send(:clear_attribute_changes, [name])
52
+ record.send("#{name}=", original_value)
53
+ record.send(:clear_attribute_changes, [name])
54
+ end
49
55
  end
50
56
 
51
57
  def reset
@@ -53,6 +59,30 @@ module Globalize
53
59
  super
54
60
  end
55
61
 
62
+ def changed_attributes(locale)
63
+ Hash[changes(locale).map { |name, change| [name, change.first] }]
64
+ end
65
+
66
+ def changed
67
+ stash.keys.flat_map { |locale| changes(locale).keys }.uniq
68
+ end
69
+
70
+ def changes(locale)
71
+ stash[locale].keys.inject({}) do |hash, name|
72
+ next hash unless dirty[name].is_a?(Hash)
73
+ next hash unless dirty[name].key?(locale)
74
+
75
+ new_value = stash[locale][name]
76
+ old_value = dirty[name][locale]
77
+
78
+ unless new_value == old_value
79
+ hash[name] = [old_value, new_value]
80
+ end
81
+
82
+ hash
83
+ end
84
+ end
85
+
56
86
  end
57
87
  end
58
88
  end
@@ -66,7 +66,7 @@ module Globalize
66
66
  end
67
67
 
68
68
  def _read_attribute(attr_name, options = {}, &block)
69
- translated_value = read_translated_attribute(attr_name, options, &block)
69
+ translated_value = read_translated_attribute(attr_name, options)
70
70
  translated_value.nil? ? super(attr_name, &block) : translated_value
71
71
  end
72
72
 
@@ -185,6 +185,20 @@ module Globalize
185
185
  changed_attributes.present? || translations.any?(&:changed?)
186
186
  end
187
187
 
188
+ if Globalize.rails_6?
189
+ def changed_attributes
190
+ super.merge(globalize.changed_attributes(::Globalize.locale))
191
+ end
192
+
193
+ def changes
194
+ super.merge(globalize.changes(::Globalize.locale))
195
+ end
196
+
197
+ def changed
198
+ super.concat(globalize.changed).uniq
199
+ end
200
+ end
201
+
188
202
  # need to access instance variable directly since changed_attributes
189
203
  # is frozen as of Rails 4.2
190
204
  def original_changed_attributes
@@ -236,10 +250,7 @@ module Globalize
236
250
  return nil unless options[:translated]
237
251
  return nil unless translated?(name)
238
252
 
239
- value = globalize.fetch(options[:locale] || Globalize.locale, name)
240
- return nil if value.nil?
241
-
242
- block_given? ? yield(value) : value
253
+ globalize.fetch(options[:locale] || Globalize.locale, name)
243
254
  end
244
255
  end
245
256
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Globalize
4
- Version = '6.0.0.alpha.1'
4
+ Version = '6.0.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: globalize
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.0.alpha.1
4
+ version: 6.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sven Fuchs
@@ -11,10 +11,36 @@ authors:
11
11
  - Tomasz Stachewicz
12
12
  - Philip Arndt
13
13
  - Chris Salzberg
14
- autorequire:
14
+ autorequire:
15
15
  bindir: bin
16
- cert_chain: []
17
- date: 2020-04-19 00:00:00.000000000 Z
16
+ cert_chain:
17
+ - |
18
+ -----BEGIN CERTIFICATE-----
19
+ MIIEMjCCApqgAwIBAgIBATANBgkqhkiG9w0BAQsFADAjMSEwHwYDVQQDDBhnZW1z
20
+ L0RDPXAvREM9YXJuZHQvREM9aW8wHhcNMjAwNTEwMjIxOTQ2WhcNMjEwNTEwMjIx
21
+ OTQ2WjAjMSEwHwYDVQQDDBhnZW1zL0RDPXAvREM9YXJuZHQvREM9aW8wggGiMA0G
22
+ CSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQDT+JzHYPGMYJt9ct2DCsbIymn1uJJp
23
+ HnDkQESfsGe40jTC90oF2iVbVOkaacNc1N3CSWUZvZjuygUuS86P6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75Sct6h2220lO5ySqYtqAXuOMBDGv5L0zLalx1g8LACA7uILTKVWh8B8
40
+ Hsej0MQ3drCB1eA4c9OXdCUQJnY2aLTq3uNvTbZvoTgWK55eq3KLBJ4zzoKZ4tBX
41
+ /HIFI/fEwYlI1Ji3oikUrHkc4rWgaQ==
42
+ -----END CERTIFICATE-----
43
+ date: 2021-01-11 00:00:00.000000000 Z
18
44
  dependencies:
19
45
  - !ruby/object:Gem::Dependency
20
46
  name: activerecord
@@ -192,10 +218,12 @@ files:
192
218
  - CHANGELOG.md
193
219
  - CONTRIBUTING.md
194
220
  - Gemfile
195
- - Gemfile.lock
196
221
  - LICENSE
197
222
  - README.md
198
223
  - Rakefile
224
+ - docker-compose.yml
225
+ - globalize.gemspec
226
+ - issue_template.rb
199
227
  - lib/globalize.rb
200
228
  - lib/globalize/active_record.rb
201
229
  - lib/globalize/active_record/act_macro.rb
@@ -228,7 +256,7 @@ homepage: http://github.com/globalize/globalize
228
256
  licenses:
229
257
  - MIT
230
258
  metadata: {}
231
- post_install_message:
259
+ post_install_message:
232
260
  rdoc_options: []
233
261
  require_paths:
234
262
  - lib
@@ -239,12 +267,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
239
267
  version: 2.4.6
240
268
  required_rubygems_version: !ruby/object:Gem::Requirement
241
269
  requirements:
242
- - - ">"
270
+ - - ">="
243
271
  - !ruby/object:Gem::Version
244
- version: 1.3.1
272
+ version: '0'
245
273
  requirements: []
246
- rubygems_version: 3.0.3
247
- signing_key:
274
+ rubygems_version: 3.2.3
275
+ signing_key:
248
276
  specification_version: 4
249
277
  summary: Rails I18n de-facto standard library for ActiveRecord model/data translation
250
278
  test_files: []
Binary file
@@ -1,80 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- globalize (5.3.0)
5
- activemodel (>= 4.2, < 6.1)
6
- activerecord (>= 4.2, < 6.1)
7
- request_store (~> 1.0)
8
-
9
- GEM
10
- remote: https://rubygems.org/
11
- specs:
12
- activemodel (6.0.2.1)
13
- activesupport (= 6.0.2.1)
14
- activerecord (6.0.2.1)
15
- activemodel (= 6.0.2.1)
16
- activesupport (= 6.0.2.1)
17
- activesupport (6.0.2.1)
18
- concurrent-ruby (~> 1.0, >= 1.0.2)
19
- i18n (>= 0.7, < 2)
20
- minitest (~> 5.1)
21
- tzinfo (~> 1.1)
22
- zeitwerk (~> 2.2)
23
- ansi (1.5.0)
24
- appraisal (2.2.0)
25
- bundler
26
- rake
27
- thor (>= 0.14.0)
28
- builder (3.2.4)
29
- coderay (1.1.2)
30
- concurrent-ruby (1.1.6)
31
- database_cleaner (1.8.2)
32
- i18n (1.8.2)
33
- concurrent-ruby (~> 1.0)
34
- m (1.5.1)
35
- method_source (>= 0.6.7)
36
- rake (>= 0.9.2.2)
37
- method_source (0.9.2)
38
- minitest (5.14.0)
39
- minitest-reporters (1.4.2)
40
- ansi
41
- builder
42
- minitest (>= 5.0)
43
- ruby-progressbar
44
- mysql2 (0.5.3)
45
- pg (0.21.0)
46
- pry (0.12.2)
47
- coderay (~> 1.1.0)
48
- method_source (~> 0.9.0)
49
- rack (2.2.2)
50
- rake (13.0.1)
51
- rdoc (6.2.1)
52
- request_store (1.5.0)
53
- rack (>= 1.4)
54
- ruby-progressbar (1.10.1)
55
- sqlite3 (1.4.2)
56
- thor (1.0.1)
57
- thread_safe (0.3.6)
58
- tzinfo (1.2.6)
59
- thread_safe (~> 0.1)
60
- zeitwerk (2.2.2)
61
-
62
- PLATFORMS
63
- ruby
64
-
65
- DEPENDENCIES
66
- appraisal
67
- database_cleaner
68
- globalize!
69
- m
70
- minitest
71
- minitest-reporters
72
- mysql2
73
- pg (< 1.0)
74
- pry
75
- rake
76
- rdoc
77
- sqlite3
78
-
79
- BUNDLED WITH
80
- 2.1.4