Skip to content

Commit

Permalink
Merge branch 'shioyama:master' into fix_active_record_table_backend
Browse files Browse the repository at this point in the history
  • Loading branch information
divanburger committed May 7, 2024
2 parents b4b5b64 + 31b8a9b commit 1bf068f
Show file tree
Hide file tree
Showing 24 changed files with 231 additions and 309 deletions.
146 changes: 4 additions & 142 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,27 +28,17 @@ jobs:
- '3.2'
- '3.1'
- '3.0'
- '2.7'
- '2.6'
database:
- 'sqlite3'
- 'mysql'
- 'postgres'
orm:
- name: 'active_record'
version: '4.2'
- name: 'active_record'
version: '5.0'
- name: 'active_record'
version: '5.1'
- name: 'active_record'
version: '5.2'
- name: 'active_record'
version: '6.0'
- name: 'active_record'
version: '6.1'
- name: 'active_record'
version: '7.0'
- name: 'active_record'
version: '7.1'
- name: 'sequel'
version: '5'
experimental: [false]
Expand All @@ -66,14 +56,6 @@ jobs:
feature: 'unit'
orm:
experimental: false
- ruby: '2.7'
feature: 'unit'
orm:
experimental: false
- ruby: '2.6'
feature: 'unit'
orm:
experimental: false
- ruby: '3.2'
feature: 'rails'
orm:
Expand Down Expand Up @@ -155,126 +137,6 @@ jobs:
- ruby: '3.0'
feature: 'i18n_fallbacks'
experimental: false
- ruby: '3.0'
database: 'sqlite3'
feature: 'unit'
orm:
name: 'active_record'
version: 'edge'
experimental: true
- ruby: '3.0'
database: 'mysql'
feature: 'unit'
orm:
name: 'active_record'
version: 'edge'
experimental: true
- ruby: '3.0'
database: 'postgres'
feature: 'unit'
orm:
name: 'active_record'
version: 'edge'
experimental: true
- ruby: '2.7'
feature: 'rails'
orm:
name: 'active_record'
version: '7.0'
database: 'sqlite3'
experimental: false
- ruby: '2.7'
feature: 'performance'
experimental: false
- ruby: '2.7'
feature: 'i18n_fallbacks'
experimental: false
- ruby: '2.7'
database: 'sqlite3'
feature: 'unit'
orm:
name: 'active_record'
version: 'edge'
experimental: true
- ruby: '2.7'
database: 'mysql'
feature: 'unit'
orm:
name: 'active_record'
version: 'edge'
experimental: true
- ruby: '2.7'
database: 'postgres'
feature: 'unit'
orm:
name: 'active_record'
version: 'edge'
experimental: true
exclude:
- ruby: '2.6'
orm:
name: 'active_record'
version: '7.0'
- ruby: '2.7'
orm:
name: 'active_record'
version: '4.2'
- ruby: '3.0'
orm:
name: 'active_record'
version: '4.2'
- ruby: '3.0'
orm:
name: 'active_record'
version: '5.0'
- ruby: '3.0'
orm:
name: 'active_record'
version: '5.1'
- ruby: '3.0'
orm:
name: 'active_record'
version: '5.2'
- ruby: '3.1'
orm:
name: 'active_record'
version: '4.2'
- ruby: '3.1'
orm:
name: 'active_record'
version: '5.0'
- ruby: '3.1'
orm:
name: 'active_record'
version: '5.1'
- ruby: '3.1'
orm:
name: 'active_record'
version: '5.2'
- ruby: '3.1'
orm:
name: 'active_record'
version: '6.0'
- ruby: '3.2'
orm:
name: 'active_record'
version: '4.2'
- ruby: '3.2'
orm:
name: 'active_record'
version: '5.0'
- ruby: '3.2'
orm:
name: 'active_record'
version: '5.1'
- ruby: '3.2'
orm:
name: 'active_record'
version: '5.2'
- ruby: '3.2'
orm:
name: 'active_record'
version: '6.0'

env:
DB: ${{ matrix.database }}
Expand Down Expand Up @@ -304,7 +166,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Update packages
run: sudo apt-get update
- name: Install Sqlite
Expand All @@ -314,7 +176,7 @@ jobs:
run: sudo apt-get install libpq-dev postgresql-client -y
if: matrix.database == 'postgres'
- id: cache-bundler
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: vendor/bundle
key: ${{ matrix.ruby }}-${{ matrix.orm.name }}-${{ matrix.orm.version }}-${{ matrix.feature }}-${{ hashFiles('mobility.gemspec') }}-${{ hashFiles('Gemfile') }}
Expand Down
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,29 @@

## 1.3

### (unreleased)

- Allow `I18n.available_locales` to contain Strings
([#612](https://github.com/shioyama/mobility/pull/612))

### 1.3.0.rc3

- Don't try to load generators if Rails is loaded but AR is not
([#627](https://github.com/shioyama/mobility/pull/627)), thanks
[flop](https://github.com/flop)!
- Allow compound foreign keys
([#632](https://github.com/shioyama/mobility/pull/632)), thanks
[mival](https://github.com/mival)!
- Fix active model `*_previously_changed?` and active record
`will_save_change_to_*?` and `saved_change_to_*?` dirty methods to accept
kwargs ([#639](https://github.com/shioyama/mobility/pull/639)) thanks
[doits](https://github.com/doits)!

### 1.3.0.rc2

- Pass `coder` as keyword argument to `serialize` (ActiveRecord version > 7.1)
([#617](https://github.com/shioyama/mobility/pull/617))

### 1.3.0.rc1

This version includes potentially breaking chnages for jsonb and hstore
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ group :development, :test do
when 'active_record'
orm_version ||= '7.0'
case orm_version
when '4.2', '5.0', '5.1', '5.2', '6.0', '6.1', '7.0'
when '6.1', '7.0', '7.1'
gem 'activerecord', "~> #{orm_version}.0"
when 'edge'
git 'https://github.com/rails/rails.git', branch: 'main' do
Expand Down
10 changes: 3 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ Mobility
[![Gem Version](https://badge.fury.io/rb/mobility.svg)][gem]
[![Build Status](https://github.com/shioyama/mobility/workflows/CI/badge.svg)][actions]
[![Code Climate](https://api.codeclimate.com/v1/badges/72200f2b00c339ec4537/maintainability.svg)][codeclimate]
[![Gitter Chat](https://badges.gitter.im/mobility-ruby/mobility.svg)](https://gitter.im/mobility-ruby/mobility)

[gem]: https://rubygems.org/gems/mobility
[actions]: https://github.com/shioyama/mobility/actions
Expand Down Expand Up @@ -55,17 +54,13 @@ Installation
Add this line to your application's Gemfile:

```ruby
gem 'mobility', '~> 1.3.0.rc1'
gem 'mobility', '~> 1.3.0.rc3'
```

### ActiveRecord (Rails)

Requirements:
- ActiveRecord >= 5.0 (including 6.x)

(Support for most backends and features is also supported with
ActiveRecord/Rails 4.2, but there are some tests still failing. To see exactly
what might not work, check pending specs in Rails 4.2 builds.)
- ActiveRecord >= 6.1

To translate attributes on a model, extend `Mobility`, then call `translates`
passing in one or more attributes as well as a hash of options (see below).
Expand Down Expand Up @@ -1027,6 +1022,7 @@ Integrations
* [mobility-actiontext](https://github.com/sedubois/mobility-actiontext): Translate
Rails [Action Text](https://guides.rubyonrails.org/action_text_overview.html) rich text
with Mobility.
* [mobility_typed](https://github.com/GeorgeGorbanev/mobility_typed): Add type checking to Rails models accessors.

Tutorials
---------
Expand Down
42 changes: 21 additions & 21 deletions certs/shioyama.pem
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
-----BEGIN CERTIFICATE-----
MIIEcDCCAtigAwIBAgIBATANBgkqhkiG9w0BAQsFADA/MQ4wDAYDVQQDDAVjaHJp
czEYMBYGCgmSJomT8ixkARkWCGRlamltYXRhMRMwEQYKCZImiZPyLGQBGRYDY29t
MB4XDTIzMDMyODA3MTQzNVoXDTI0MDMyNzA3MTQzNVowPzEOMAwGA1UEAwwFY2hy
MB4XDTI0MDMzMTA4NTQyOFoXDTI1MDMzMTA4NTQyOFowPzEOMAwGA1UEAwwFY2hy
aXMxGDAWBgoJkiaJk/IsZAEZFghkZWppbWF0YTETMBEGCgmSJomT8ixkARkWA2Nv
bTCCAaIwDQYJKoZIhvcNAQEBBQADggGPADCCAYoCggGBAJI6uJ3SQZs7gaYR4nFb
yKG+ZHDMoAvrYHPp5hb3ssueoniFtfV1SOh2QOm3AfdA4XIiUco1NAepYkp+zEIT
sCUKWkYe8uOwvpdTBrO6JbEfFw0/2ewkCWreN/hfFjOXqZIieJXEHeScrzbU0w/6
/oa3rsiN91ED1qaQqRU7K9pPuhuOnKrZSzdTDpbwbBn4jK2j2BQ2/yRlX6FObOWa
4gpyFpr0jU0rpk38UOiHS9uDN7Zi+uagAulgHHkzfYaNPjCswIdobpzLiT9C0stQ
EYI4cc51dAhoVR4FYP+J0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n3mS2OJl3tRCGuPvwAA9MV10hmwbQTXMrNK
tD9kfT9eseUE4mfPnIaHOs4FiIoHniA7zdtjB7GIQ4cEpB6o
-----END CERTIFICATE-----
6 changes: 3 additions & 3 deletions lib/mobility.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class Error < StandardError
CALL_COMPILABLE_REGEXP = /\A[a-zA-Z_]\w*[!?]?\z/
private_constant :CALL_COMPILABLE_REGEXP

require "rails/generators/mobility/generators" if defined?(Rails)
require "rails/generators/mobility/generators" if defined?(Rails) && defined?(ActiveRecord)

class << self
def extended(model_class)
Expand Down Expand Up @@ -228,9 +228,9 @@ def enforce_available_locales!(locale)
# methods (in LocaleAccessors) than is really necessary.
def available_locales
if defined?(Rails) && Rails.respond_to?(:application) && Rails.application
Rails.application.config.i18n.available_locales&.map(&:to_sym) || I18n.available_locales
Rails.application.config.i18n.available_locales&.map(&:to_sym) || I18n.available_locales.map(&:to_sym)
else
I18n.available_locales
I18n.available_locales.map(&:to_sym)
end
end

Expand Down
8 changes: 7 additions & 1 deletion lib/mobility/backends/active_record/serialized.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,13 @@ def self.build_node(attr, _locale)

setup do |attributes, options|
coder = { yaml: YAMLCoder, json: JSONCoder }[options[:format]]
attributes.each { |attribute| serialize (options[:column_affix] % attribute), coder }
attributes.each do |attribute|
if (::ActiveRecord::VERSION::STRING >= "7.1")
serialize (options[:column_affix] % attribute), coder: coder
else
serialize (options[:column_affix] % attribute), coder
end
end
end

# @!group Cache Methods
Expand Down
8 changes: 7 additions & 1 deletion lib/mobility/backends/active_record/table.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,13 @@ def configure(options)
options[:association_name] = :translations
options[:subclass_name] ||= :Translation
end
%i[foreign_key association_name subclass_name table_name].each { |key| options[key] = options[key].to_sym }
%i[foreign_key association_name subclass_name table_name].each { |key|
if options[key].is_a?(Enumerable)
options[key] = options[key].map!(&:to_sym)
else
options[key] = options[key].to_sym
end
}
end
# @!endgroup

Expand Down
Loading

0 comments on commit 1bf068f

Please sign in to comment.