traco 5.0.0 → 5.1.0

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
- SHA1:
3
- metadata.gz: 995b6c0b60252d02350da1d58e7ea0268a80a80b
4
- data.tar.gz: 65c1db0ac8b1036daf10595d5c8745ccf2412aac
2
+ SHA256:
3
+ metadata.gz: '0558c0d88be16881d21c8d132f91237f872f8d6ed718ac9c5f96542fa2a2da29'
4
+ data.tar.gz: ef022bdbd5381ed2a5df36e125fd1dbc98423bdb0788a682105b997d9ecca720
5
5
  SHA512:
6
- metadata.gz: 7f8fe7b9b21d2ea1ac651bf85d0eaa642e276533973347e8feb7248616632c764a1368a5670f8ee64d2afb519160cdbdec68a53ccb2c730e23c81330db3f657f
7
- data.tar.gz: 448dff9dd08c1e8fb9c3d4dcfa57bf3fd4e66311ec84c66410fbaea44fac667fe7c8c1add591bb11b6a665648582dd6de59ce35aef604fe14d2a7e3d0444690b
6
+ metadata.gz: 7eb1119b6ed4de3f33df0c85b6c82faaedcc48f5982066e037bd2bd0ecd9c666eb4ce52f19845f01ca522b4e5f5ff5bad60ad93f09ac536de56976d67a70e300
7
+ data.tar.gz: 64e59646deb593318e26e0363c5b90f76e0f62a85c7702d987a0f8e599abd095ea4cb0fe966b7c2b67ce3102d40390c76c76bf71fc88060a3f4585ecc505fc13
data/.gitignore CHANGED
@@ -3,3 +3,5 @@ Gemfile.lock
3
3
  pkg/
4
4
  tmp
5
5
  *.gem
6
+ # Appraisal generated lockfiles
7
+ *.gemfile.lock
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ -r spec_helper
@@ -1,10 +1,24 @@
1
1
  language: ruby
2
- rvm:
3
- - 2.5.1
4
- - 2.4.4
5
- - 2.3.0
6
2
 
7
- # Avoid some errors, and speed things up:
8
- # https://github.com/bundler/bundler/issues/3558#issuecomment-171347979
9
- # https://docs.travis-ci.com/user/workers/container-based-infrastructure/
10
- sudo: false
3
+ rvm:
4
+ - 2.6.3
5
+ - 2.5.5
6
+ - 2.4.6
7
+ - 2.3.8
8
+ gemfile:
9
+ - gemfiles/rails_4.2.gemfile
10
+ - gemfiles/rails_5.0.gemfile
11
+ - gemfiles/rails_5.1.gemfile
12
+ - gemfiles/rails_5.2.gemfile
13
+ - gemfiles/rails_6.0.gemfile
14
+ - gemfiles/rails_6.1.gemfile
15
+ matrix:
16
+ exclude:
17
+ - rvm: 2.3.8
18
+ gemfile: gemfiles/rails_6.0.gemfile
19
+ - rvm: 2.3.8
20
+ gemfile: gemfiles/rails_6.1.gemfile
21
+ - rvm: 2.4.6
22
+ gemfile: gemfiles/rails_6.0.gemfile
23
+ - rvm: 2.4.6
24
+ gemfile: gemfiles/rails_6.1.gemfile
@@ -0,0 +1,26 @@
1
+ appraise "rails-4.2" do
2
+ gem "activerecord", "~> 4.2.0"
3
+ gem "sqlite3", "~> 1.3.13"
4
+ end
5
+
6
+ appraise "rails-5.0" do
7
+ gem "activerecord", "~> 5.0.0"
8
+ gem "sqlite3", "~> 1.3.13"
9
+ end
10
+
11
+ appraise "rails-5.1" do
12
+ gem "activerecord", "~> 5.1.0"
13
+ gem "sqlite3", "~> 1.3.13"
14
+ end
15
+
16
+ appraise "rails-5.2" do
17
+ gem "activerecord", "~> 5.2.0"
18
+ end
19
+
20
+ appraise "rails-6.0" do
21
+ gem "activerecord", "~> 6.0.3.1"
22
+ end
23
+
24
+ appraise "rails-6.1" do
25
+ gem "activerecord", "~> 6.1.0"
26
+ end
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 5.1.0
4
+
5
+ * Feature: Add `fallback: :i18n` to use the fallbacks from `I18n.fallbacks`. Thanks to [sunny](https://github.com/sunny)!
6
+
3
7
  ## 5.0.0
4
8
 
5
9
  * Change `locale_columns` and `locales_for_attribute` to sort current locale first, then default locale (previously, it was default locale first). This makes more sense for our own apps, and hopefully other apps as well.
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # Traco
2
2
 
3
- [![Build Status](https://secure.travis-ci.org/barsoom/traco.png)](http://travis-ci.org/barsoom/traco)
3
+ [![Build Status](https://secure.travis-ci.org/barsoom/traco.svg)](http://travis-ci.org/barsoom/traco)
4
4
 
5
- Translatable attributes for Ruby on Rails, stored in the model table itself.
5
+ Translatable attributes for Ruby on Rails 4.2+, stored in the model table itself.
6
6
 
7
7
  Inspired by Iain Hecker's [translatable_columns](https://github.com/iain/translatable_columns/).
8
8
 
@@ -98,6 +98,8 @@ You can specify e.g. `translates :title, fallback: :any` to fall back first to t
98
98
 
99
99
  You can specify e.g. `translates :title, fallback: [:sv]` to explicitly declare fallbacks as an array of any length.
100
100
 
101
+ You can specify e.g. `translates :title, fallback: :i18n` to use the fallbacks from `I18n.fallbacks`.
102
+
101
103
  You can override the default fallback strategy with a parameter passed to the reader: `post.title(fallback: :any)`.
102
104
 
103
105
  If you need to declare the default locale fallback, do `post.title(fallback: :default)`.
@@ -0,0 +1,12 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activerecord", "~> 4.2.0"
6
+ gem "sqlite3", "~> 1.3.13"
7
+
8
+ group :benchmark do
9
+ gem "benchmark-ips"
10
+ end
11
+
12
+ gemspec path: "../"
@@ -0,0 +1,12 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activerecord", "~> 5.0.0"
6
+ gem "sqlite3", "~> 1.3.13"
7
+
8
+ group :benchmark do
9
+ gem "benchmark-ips"
10
+ end
11
+
12
+ gemspec path: "../"
@@ -0,0 +1,12 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activerecord", "~> 5.1.0"
6
+ gem "sqlite3", "~> 1.3.13"
7
+
8
+ group :benchmark do
9
+ gem "benchmark-ips"
10
+ end
11
+
12
+ gemspec path: "../"
@@ -0,0 +1,11 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activerecord", "~> 5.2.0"
6
+
7
+ group :benchmark do
8
+ gem "benchmark-ips"
9
+ end
10
+
11
+ gemspec path: "../"
@@ -0,0 +1,11 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activerecord", "~> 6.0.3.1"
6
+
7
+ group :benchmark do
8
+ gem "benchmark-ips"
9
+ end
10
+
11
+ gemspec path: "../"
@@ -0,0 +1,11 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activerecord", "~> 6.1.0"
6
+
7
+ group :benchmark do
8
+ gem "benchmark-ips"
9
+ end
10
+
11
+ gemspec path: "../"
@@ -7,6 +7,7 @@ module Traco
7
7
  ANY_FALLBACK = :any,
8
8
  NO_FALLBACK = false,
9
9
  DEFAULT_FIRST_FALLBACK = :default_first,
10
+ I18N_FALLBACK = :i18n,
10
11
  ]
11
12
 
12
13
  attr_reader :fallback_option
@@ -26,6 +27,7 @@ module Traco
26
27
  when ANY_FALLBACK then [ current_locale, @default_locale, *@available_locales ].uniq
27
28
  when NO_FALLBACK then [ current_locale ]
28
29
  when DEFAULT_FIRST_FALLBACK then [ @default_locale, *@available_locales ].uniq
30
+ when I18N_FALLBACK then I18n.fallbacks[current_locale]
29
31
  when Array then [ current_locale, *fallback_option ]
30
32
  else raise "Unknown fallback." # Should never get here.
31
33
  end
@@ -1,3 +1,3 @@
1
1
  module Traco
2
- VERSION = "5.0.0"
2
+ VERSION = "5.1.0"
3
3
  end
@@ -1,7 +1,6 @@
1
- require "spec_helper"
2
1
  require "traco/locale_fallbacks"
3
2
 
4
- describe Traco::LocaleFallbacks do
3
+ RSpec.describe Traco::LocaleFallbacks do
5
4
  describe ".new" do
6
5
  it "raises ArgumentError if an unknown argument passed in" do
7
6
  expect { Traco::LocaleFallbacks.new(:foo) }.to raise_error(ArgumentError)
@@ -51,5 +50,20 @@ describe Traco::LocaleFallbacks do
51
50
  expect(subject[:sv]).to eq [ :uk, :de, :en, :sv ]
52
51
  end
53
52
  end
53
+
54
+ context "with the ':i18n' option" do
55
+ it "returns what is configured as a I18n fallback" do
56
+ I18n.fallbacks = I18n::Locale::Fallbacks.new(
57
+ en: [ :en, :uk, :de, :sv ],
58
+ uk: [ :uk, :en, :de, :sv ],
59
+ de: [ :de, :uk, :en, :sv ],
60
+ sv: [ :sv, :en, :uk, :de ],
61
+ )
62
+
63
+ subject = Traco::LocaleFallbacks.new(:i18n)
64
+ expect(subject[:sv]).to eq [ :sv, :en, :uk, :de ]
65
+ expect(subject[:de]).to eq [ :de, :uk, :en, :sv ]
66
+ end
67
+ end
54
68
  end
55
69
  end
@@ -3,6 +3,9 @@ require "i18n"
3
3
  RSpec.configure do |config|
4
4
  config.filter_run focus: true
5
5
  config.run_all_when_everything_filtered = true
6
+ config.disable_monkey_patching!
6
7
  end
7
8
 
8
9
  I18n.enforce_available_locales = false
10
+
11
+ I18n::Backend::Simple.include(I18n::Backend::Fallbacks)
@@ -1,5 +1,5 @@
1
1
  RSpec.configure do |config|
2
- config.before(:each) do
2
+ config.before do
3
3
  # Clear class state before each spec.
4
4
  Object.send(:remove_const, "Post")
5
5
  Object.send(:remove_const, "SubPost")
@@ -1,10 +1,9 @@
1
1
  # encoding: utf-8
2
2
 
3
- require "spec_helper"
4
3
  require "spec_helper_models"
5
4
  require "traco"
6
5
 
7
- describe Traco, ".split_localized_column" do
6
+ RSpec.describe Traco, ".split_localized_column" do
8
7
  subject { described_class }
9
8
 
10
9
  it "returns attribute and locale" do
@@ -24,7 +23,7 @@ describe Traco, ".split_localized_column" do
24
23
  end
25
24
  end
26
25
 
27
- describe ActiveRecord::Base, ".translates" do
26
+ RSpec.describe ActiveRecord::Base, ".translates" do
28
27
  it "is available" do
29
28
  expect(Post).to respond_to :translates
30
29
  end
@@ -57,7 +56,7 @@ describe ActiveRecord::Base, ".translates" do
57
56
  end
58
57
  end
59
58
 
60
- describe Post, ".translatable_attributes" do
59
+ RSpec.describe Post, ".translatable_attributes" do
61
60
  before do
62
61
  Post.translates :title
63
62
  end
@@ -77,7 +76,7 @@ describe Post, ".translatable_attributes" do
77
76
  end
78
77
  end
79
78
 
80
- describe Post, ".locales_for_attribute" do
79
+ RSpec.describe Post, ".locales_for_attribute" do
81
80
  before do
82
81
  Post.translates :title
83
82
  I18n.default_locale = :"pt-BR"
@@ -95,7 +94,7 @@ describe Post, ".locales_for_attribute" do
95
94
  end
96
95
  end
97
96
 
98
- describe Post, ".locale_columns" do
97
+ RSpec.describe Post, ".locale_columns" do
99
98
  before do
100
99
  Post.translates :title
101
100
  I18n.default_locale = :"pt-BR"
@@ -124,7 +123,7 @@ it "supports multiple attributes" do
124
123
  end
125
124
  end
126
125
 
127
- describe Post, ".current_locale_column" do
126
+ RSpec.describe Post, ".current_locale_column" do
128
127
  before do
129
128
  Post.translates :title
130
129
  end
@@ -140,7 +139,7 @@ describe Post, ".current_locale_column" do
140
139
  end
141
140
  end
142
141
 
143
- describe Post, "#title" do
142
+ RSpec.describe Post, "#title" do
144
143
  let(:post) {
145
144
  Post.new(title_sv: "Hej", title_en: "Halloa", title_pt_br: "Olá")
146
145
  }
@@ -271,7 +270,7 @@ describe Post, "#title" do
271
270
  end
272
271
  end
273
272
 
274
- describe Post, "#title=" do
273
+ RSpec.describe Post, "#title=" do
275
274
  before do
276
275
  Post.translates :title
277
276
  end
@@ -298,7 +297,7 @@ describe Post, "#title=" do
298
297
  end
299
298
  end
300
299
 
301
- describe Post, "#title?" do
300
+ RSpec.describe Post, "#title?" do
302
301
  before do
303
302
  Post.translates :title
304
303
  I18n.locale = :sv
@@ -315,7 +314,7 @@ describe Post, "#title?" do
315
314
  end
316
315
  end
317
316
 
318
- describe Post, ".human_attribute_name" do
317
+ RSpec.describe Post, ".human_attribute_name" do
319
318
  before do
320
319
  Post.translates :title
321
320
  I18n.locale = :sv
@@ -8,7 +8,7 @@ Gem::Specification.new do |s|
8
8
  s.authors = ["Henrik Nyh"]
9
9
  s.email = ["henrik@barsoom.se"]
10
10
  s.homepage = ""
11
- s.summary = "Translatable columns for Rails 3 or better, stored in the model table itself."
11
+ s.summary = "Translatable columns for Rails 4.2 or better, stored in the model table itself."
12
12
  s.license = "MIT"
13
13
 
14
14
  s.files = `git ls-files`.split("\n")
@@ -18,10 +18,11 @@ Gem::Specification.new do |s|
18
18
 
19
19
  s.required_ruby_version = ">= 2.3.0"
20
20
 
21
- s.add_dependency "activerecord", ">= 3.0"
21
+ s.add_dependency "activerecord", ">= 4.2"
22
22
 
23
23
  s.add_development_dependency "sqlite3"
24
24
 
25
25
  s.add_development_dependency "rake"
26
26
  s.add_development_dependency "rspec"
27
+ s.add_development_dependency "appraisal"
27
28
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: traco
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.0
4
+ version: 5.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henrik Nyh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-10 00:00:00.000000000 Z
11
+ date: 2020-12-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '3.0'
19
+ version: '4.2'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '3.0'
26
+ version: '4.2'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: sqlite3
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: appraisal
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
69
83
  description:
70
84
  email:
71
85
  - henrik@barsoom.se
@@ -74,13 +88,21 @@ extensions: []
74
88
  extra_rdoc_files: []
75
89
  files:
76
90
  - ".gitignore"
91
+ - ".rspec"
77
92
  - ".travis.yml"
93
+ - Appraisals
78
94
  - CHANGELOG.md
79
95
  - Gemfile
80
96
  - LICENSE.txt
81
97
  - README.md
82
98
  - Rakefile
83
99
  - benchmarks/overhead.rb
100
+ - gemfiles/rails_4.2.gemfile
101
+ - gemfiles/rails_5.0.gemfile
102
+ - gemfiles/rails_5.1.gemfile
103
+ - gemfiles/rails_5.2.gemfile
104
+ - gemfiles/rails_6.0.gemfile
105
+ - gemfiles/rails_6.1.gemfile
84
106
  - lib/traco.rb
85
107
  - lib/traco/attributes.rb
86
108
  - lib/traco/class_methods.rb
@@ -113,11 +135,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
113
135
  - !ruby/object:Gem::Version
114
136
  version: '0'
115
137
  requirements: []
116
- rubyforge_project:
117
- rubygems_version: 2.6.11
138
+ rubygems_version: 3.1.4
118
139
  signing_key:
119
140
  specification_version: 4
120
- summary: Translatable columns for Rails 3 or better, stored in the model table itself.
141
+ summary: Translatable columns for Rails 4.2 or better, stored in the model table itself.
121
142
  test_files:
122
143
  - spec/app/post.rb
123
144
  - spec/app/sv.yml