globalize 5.3.1 → 6.0.0.alpha.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
2
  SHA256:
3
- metadata.gz: 93f476f456eba6a50a3bda3d639ae4e4cc7d190d4b846a6534b26b1571dff968
4
- data.tar.gz: 10d20462ade18061edc4facf99f4e23c58b7855e4121e5f0f2d29ab5eb36eb24
3
+ metadata.gz: bb12d7f3b6c17018cefe1614dfba6b585ba169ef2ca412b58d230ccabf778033
4
+ data.tar.gz: ac44f2e8a75b53ad116b8674d1f5c3d47a122c9782133e3853359217fb944375
5
5
  SHA512:
6
- metadata.gz: 40ca71b7fefb3b4de28f8b6ae08c10fa6c8172cf69e86e18d3ab9166625f41a1ed15c4e4dd53977ff90a7dab4297577ab26a80de130fe58628fb67b0003be54b
7
- data.tar.gz: 7e5c4637c7f29d92d69ff704fec7d3c71d409c9f27c321df3807055471135877470b37dce6b0daceb68fad96c160e3dd031bf75e1df743acc76156d35f46ccfb
6
+ metadata.gz: 2f358f026bc47645ae8751cb3b2a3a7660cfbbb64c6c37e2ab2b46a9b548de357ba0e8a8880eb82326ce78c6e7605c31fbf27726d645b33baa62c594bace13b5
7
+ data.tar.gz: 185fbeea91d8fda53c23232897deba40ad149fbea99c329a32aa8d9bbd7c296c4b9a5a814ced76d39785969d8503011f9316bc600a07de7e82b1a03fe0c3a76a
data/Appraisals CHANGED
@@ -17,15 +17,15 @@ RAILS_VERSIONS.each do |version|
17
17
  end
18
18
 
19
19
  platforms :jruby do
20
- if !ENV['TRAVIS'] || ENV['DB'] == 'sqlite3'
20
+ if !ENV['CI'] || ENV['DB'] == 'sqlite3'
21
21
  gem 'activerecord-jdbcsqlite3-adapter', '~> 1'
22
22
  end
23
23
 
24
- if !ENV['TRAVIS'] || ENV['DB'] == 'mysql'
24
+ if !ENV['CI'] || ENV['DB'] == 'mysql'
25
25
  gem 'activerecord-jdbcmysql-adapter', '~> 1'
26
26
  end
27
27
 
28
- if !ENV['TRAVIS'] || %w(postgres postgresql).include?(ENV['DB'])
28
+ if !ENV['CI'] || %w(postgres postgresql).include?(ENV['DB'])
29
29
  gem 'activerecord-jdbcpostgresql-adapter', '~> 1'
30
30
  end
31
31
  end
data/CHANGELOG.md CHANGED
@@ -1,8 +1,9 @@
1
1
  # Globalize Changelog
2
2
 
3
- ## 5.3.1 (2021-01-11)
3
+ ## Unreleased
4
4
 
5
- * Fix foreign keys translation. [#773](https://github.com/globalize/globalize/pull/773) by [Sergey Tokarenko](https://github.com/stokarenko)
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
7
 
7
8
  ## 5.3.0 (2019-05-14)
8
9
 
data/CONTRIBUTING.md CHANGED
@@ -34,7 +34,7 @@ Have a bug fix, code improvement or proposed feature? Do the following:
34
34
 
35
35
  For pull requests to Rails/ActiveRecord 4 version of Globalize (v3.x), post to the `master` branch. For pull requests to the Rails/ActiveRecord 3.x version of Globalize (3.x), post to the `3-0-stable` branch.
36
36
 
37
- When you submit the pull request, Travis CI will run the [test suite](https://travis-ci.org/globalize/globalize) against your branch and will highlight any failures. Unless there is a good reason for it, we do not generally accept pull requests that take Globalize from green to red.
37
+ When you submit the pull request, GitHub Actions will run the [test suite](https://github.com/globalize/globalize/actions) against your branch and will highlight any failures. Unless there is a good reason for it, we do not generally accept pull requests that take Globalize from green to red.
38
38
 
39
39
  ## Testing
40
40
 
data/Gemfile CHANGED
@@ -1,3 +1,20 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
+
5
+ # Database Configuration
6
+ if !ENV['CI'] || ENV['DB'] == 'sqlite3'
7
+ gem 'sqlite3', platforms: [:ruby, :rbx]
8
+ end
9
+
10
+ if !ENV['CI'] || ENV['DB'] == 'mysql'
11
+ group :mysql do
12
+ gem 'mysql2', platforms: [:ruby, :rbx]
13
+ end
14
+ end
15
+
16
+ if !ENV['CI'] || %w(postgres postgresql).include?(ENV['DB'])
17
+ group :postgres, :postgresql do
18
+ gem 'pg', '< 1.0', platforms: [:ruby, :rbx]
19
+ end
20
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,80 @@
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
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  ![Globalize](http://globalize.github.io/globalize/images/globalize.png)
2
2
 
3
- [![Build Status](https://travis-ci.org/globalize/globalize.svg?branch=master)](https://travis-ci.org/globalize/globalize) [![Code Climate](https://codeclimate.com/github/globalize/globalize.svg)](https://codeclimate.com/github/globalize/globalize)
3
+ [![Build Status](https://github.com/globalize/globalize/workflows/CI/badge.svg)](https://github.com/globalize/globalize/actions) [![Code Climate](https://codeclimate.com/github/globalize/globalize.svg)](https://codeclimate.com/github/globalize/globalize)
4
4
  [![Open Source Helpers](https://www.codetriage.com/globalize/globalize/badges/users.svg)](https://www.codetriage.com/globalize/globalize)
5
5
 
6
6
  You can chat with us using Gitter:
@@ -28,7 +28,7 @@ gem install globalize
28
28
  When using bundler put this in your Gemfile:
29
29
 
30
30
  ```ruby
31
- gem 'globalize', '~> 5.1.0'
31
+ gem 'globalize', '~> 5.3.0'
32
32
  ```
33
33
 
34
34
  Please help us by letting us know what works, and what doesn't, when using pre-release code.
@@ -68,6 +68,7 @@ module Globalize
68
68
  def apply_globalize_options(options)
69
69
  options[:table_name] ||= "#{table_name.singularize}_translations"
70
70
  options[:foreign_key] ||= class_name.foreign_key
71
+ options[:autosave] ||= false
71
72
 
72
73
  class_attribute :translated_attribute_names, :translation_options, :fallbacks_for_empty_translations
73
74
  self.translated_attribute_names = []
@@ -99,7 +100,7 @@ module Globalize
99
100
  :foreign_key => options[:foreign_key],
100
101
  :dependent => :destroy,
101
102
  :extend => HasManyExtensions,
102
- :autosave => false,
103
+ :autosave => options[:autosave],
103
104
  :inverse_of => :globalized_model
104
105
 
105
106
  after_create :save_translations!
@@ -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)
69
+ translated_value = read_translated_attribute(attr_name, options, &block)
70
70
  translated_value.nil? ? super(attr_name, &block) : translated_value
71
71
  end
72
72
 
@@ -236,7 +236,10 @@ module Globalize
236
236
  return nil unless options[:translated]
237
237
  return nil unless translated?(name)
238
238
 
239
- globalize.fetch(options[:locale] || Globalize.locale, name)
239
+ value = globalize.fetch(options[:locale] || Globalize.locale, name)
240
+ return nil if value.nil?
241
+
242
+ block_given? ? yield(value) : value
240
243
  end
241
244
  end
242
245
  end
@@ -62,6 +62,7 @@ module Globalize
62
62
  end
63
63
 
64
64
  def drop_translation_table!(options = {})
65
+ add_missing_columns if options[:create_source_columns]
65
66
  move_data_to_model_table if options[:migrate_data]
66
67
  drop_translations_index
67
68
  drop_translation_table
@@ -148,8 +149,6 @@ module Globalize
148
149
  end
149
150
 
150
151
  def move_data_to_model_table
151
- add_missing_columns
152
-
153
152
  # Find all of the translated attributes for all records in the model.
154
153
  all_translated_attributes = model.all.collect{|m| m.attributes}
155
154
  all_translated_attributes.each do |translated_record|
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Globalize
4
- Version = '5.3.1'
4
+ Version = '6.0.0.alpha.1'
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: 5.3.1
4
+ version: 6.0.0.alpha.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sven Fuchs
@@ -11,10 +11,10 @@ authors:
11
11
  - Tomasz Stachewicz
12
12
  - Philip Arndt
13
13
  - Chris Salzberg
14
- autorequire:
14
+ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
- date: 2021-01-11 00:00:00.000000000 Z
17
+ date: 2020-04-19 00:00:00.000000000 Z
18
18
  dependencies:
19
19
  - !ruby/object:Gem::Dependency
20
20
  name: activerecord
@@ -25,7 +25,7 @@ dependencies:
25
25
  version: '4.2'
26
26
  - - "<"
27
27
  - !ruby/object:Gem::Version
28
- version: '6.1'
28
+ version: '7.0'
29
29
  type: :runtime
30
30
  prerelease: false
31
31
  version_requirements: !ruby/object:Gem::Requirement
@@ -35,7 +35,7 @@ dependencies:
35
35
  version: '4.2'
36
36
  - - "<"
37
37
  - !ruby/object:Gem::Version
38
- version: '6.1'
38
+ version: '7.0'
39
39
  - !ruby/object:Gem::Dependency
40
40
  name: activemodel
41
41
  requirement: !ruby/object:Gem::Requirement
@@ -45,7 +45,7 @@ dependencies:
45
45
  version: '4.2'
46
46
  - - "<"
47
47
  - !ruby/object:Gem::Version
48
- version: '6.1'
48
+ version: '7.0'
49
49
  type: :runtime
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
@@ -55,7 +55,7 @@ dependencies:
55
55
  version: '4.2'
56
56
  - - "<"
57
57
  - !ruby/object:Gem::Version
58
- version: '6.1'
58
+ version: '7.0'
59
59
  - !ruby/object:Gem::Dependency
60
60
  name: request_store
61
61
  requirement: !ruby/object:Gem::Requirement
@@ -182,20 +182,6 @@ dependencies:
182
182
  - - ">="
183
183
  - !ruby/object:Gem::Version
184
184
  version: '0'
185
- - !ruby/object:Gem::Dependency
186
- name: sqlite3
187
- requirement: !ruby/object:Gem::Requirement
188
- requirements:
189
- - - ">="
190
- - !ruby/object:Gem::Version
191
- version: '0'
192
- type: :development
193
- prerelease: false
194
- version_requirements: !ruby/object:Gem::Requirement
195
- requirements:
196
- - - ">="
197
- - !ruby/object:Gem::Version
198
- version: '0'
199
185
  description: Rails I18n de-facto standard library for ActiveRecord model/data translation.
200
186
  email: nobody@globalize-rails.org
201
187
  executables: []
@@ -206,12 +192,10 @@ files:
206
192
  - CHANGELOG.md
207
193
  - CONTRIBUTING.md
208
194
  - Gemfile
195
+ - Gemfile.lock
209
196
  - LICENSE
210
197
  - README.md
211
198
  - Rakefile
212
- - docker-compose.yml
213
- - globalize.gemspec
214
- - issue_template.rb
215
199
  - lib/globalize.rb
216
200
  - lib/globalize/active_record.rb
217
201
  - lib/globalize/active_record/act_macro.rb
@@ -244,7 +228,7 @@ homepage: http://github.com/globalize/globalize
244
228
  licenses:
245
229
  - MIT
246
230
  metadata: {}
247
- post_install_message:
231
+ post_install_message:
248
232
  rdoc_options: []
249
233
  require_paths:
250
234
  - lib
@@ -255,12 +239,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
255
239
  version: 2.4.6
256
240
  required_rubygems_version: !ruby/object:Gem::Requirement
257
241
  requirements:
258
- - - ">="
242
+ - - ">"
259
243
  - !ruby/object:Gem::Version
260
- version: '0'
244
+ version: 1.3.1
261
245
  requirements: []
262
- rubygems_version: 3.2.3
263
- signing_key:
246
+ rubygems_version: 3.0.3
247
+ signing_key:
264
248
  specification_version: 4
265
249
  summary: Rails I18n de-facto standard library for ActiveRecord model/data translation
266
250
  test_files: []
data/docker-compose.yml DELETED
@@ -1,22 +0,0 @@
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"
data/globalize.gemspec DELETED
@@ -1,32 +0,0 @@
1
- require File.expand_path('../lib/globalize/version', __FILE__)
2
-
3
- Gem::Specification.new do |s|
4
- s.name = 'globalize'
5
- s.version = Globalize::Version
6
- s.authors = ['Sven Fuchs', 'Joshua Harvey', 'Clemens Kofler', 'John-Paul Bader', 'Tomasz Stachewicz', 'Philip Arndt', 'Chris Salzberg']
7
- s.email = 'nobody@globalize-rails.org'
8
- s.homepage = 'http://github.com/globalize/globalize'
9
- s.summary = 'Rails I18n de-facto standard library for ActiveRecord model/data translation'
10
- s.description = "#{s.summary}."
11
- s.license = "MIT"
12
-
13
- s.files = Dir['{lib/**/*,[A-Z]*}']
14
- s.platform = Gem::Platform::RUBY
15
- s.require_path = 'lib'
16
- s.rubyforge_project = '[none]'
17
- s.required_ruby_version = '>= 2.4.6'
18
-
19
- s.add_dependency 'activerecord', '>= 4.2', '< 6.1'
20
- s.add_dependency 'activemodel', '>= 4.2', '< 6.1'
21
- s.add_dependency 'request_store', '~> 1.0'
22
-
23
- s.add_development_dependency 'appraisal'
24
- s.add_development_dependency 'database_cleaner'
25
- s.add_development_dependency 'm'
26
- s.add_development_dependency 'minitest'
27
- s.add_development_dependency 'minitest-reporters'
28
- s.add_development_dependency 'pry'
29
- s.add_development_dependency 'rake'
30
- s.add_development_dependency 'rdoc'
31
- s.add_development_dependency 'sqlite3'
32
- end
data/issue_template.rb DELETED
@@ -1,38 +0,0 @@
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