serial_translator 2.0.3 → 2.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/lint.yml +29 -0
- data/.github/workflows/tests.yml +22 -0
- data/.rubocop.yml +61 -0
- data/.tool-versions +1 -1
- data/README.md +1 -9
- data/lib/serial_translator/serial_translator_length_validator.rb +3 -2
- data/lib/serial_translator/version.rb +1 -1
- data/lib/serial_translator.rb +3 -0
- data/serial_translator.gemspec +1 -0
- data/spec/lib/serial_translator_spec.rb +10 -0
- metadata +20 -4
- data/.travis.yml +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 16540a0794dd2e5b30066bd6db4a42a7db4976d91f9cd82753bd5b210aa6a565
|
4
|
+
data.tar.gz: 1299a9f6bfbc957cf8795cbe2d5d0ce4130b1822005c60a41d5933d2d1941eca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d18b78243cf079e150907d76fa004b92992fd1e9dc99a7cfda20f3946176a8a119b128562ba09334af0088a4ae8e66d1f7091c745705671fdf618d25608c923
|
7
|
+
data.tar.gz: e85688152b1ca0a2b980684e845f41953ac4551c9a97558bfdad95dd166dea6931259586ea0162fa0b87b02bdfa89ab382d00ea577e305099b7fbee1ce3ebeef
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# based on https://github.com/rails/rails/blob/4a78dcb/.github/workflows/rubocop.yml
|
2
|
+
|
3
|
+
name: rubocop linting
|
4
|
+
|
5
|
+
on: [push, pull_request]
|
6
|
+
|
7
|
+
jobs:
|
8
|
+
build:
|
9
|
+
runs-on: ubuntu-latest
|
10
|
+
|
11
|
+
steps:
|
12
|
+
- uses: actions/checkout@v2
|
13
|
+
- name: Set up Ruby
|
14
|
+
uses: ruby/setup-ruby@v1
|
15
|
+
with:
|
16
|
+
ruby-version: 2.7
|
17
|
+
- name: Cache gems
|
18
|
+
uses: actions/cache@v1
|
19
|
+
with:
|
20
|
+
path: vendor/bundle
|
21
|
+
key: ${{ runner.os }}-rubocop-${{ hashFiles('**/Gemfile.lock') }}
|
22
|
+
restore-keys: |
|
23
|
+
${{ runner.os }}-rubocop-
|
24
|
+
- name: Install gems
|
25
|
+
run: |
|
26
|
+
bundle config path vendor/bundle
|
27
|
+
bundle install --jobs 4 --retry 3
|
28
|
+
- name: Run rubocop
|
29
|
+
run: bundle exec rubocop --lint
|
@@ -0,0 +1,22 @@
|
|
1
|
+
name: tests
|
2
|
+
|
3
|
+
on: [push, pull_request]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
build:
|
7
|
+
runs-on: ubuntu-latest
|
8
|
+
|
9
|
+
strategy:
|
10
|
+
matrix:
|
11
|
+
ruby: [ '2.7', 'ruby-head' ]
|
12
|
+
|
13
|
+
steps:
|
14
|
+
- uses: actions/checkout@v2
|
15
|
+
- name: Set up Ruby ${{ matrix.ruby }}
|
16
|
+
uses: ruby/setup-ruby@v1
|
17
|
+
with:
|
18
|
+
ruby-version: ${{ matrix.ruby }}
|
19
|
+
- name: Install dependencies
|
20
|
+
run: bundle install --jobs 4
|
21
|
+
- name: Test with Rake
|
22
|
+
run: bundle exec rake
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
# usage: `rubocop --lint`
|
2
|
+
|
3
|
+
AllCops:
|
4
|
+
NewCops: enable
|
5
|
+
|
6
|
+
# disable some linters that are not so likely to indicate bugs
|
7
|
+
|
8
|
+
Lint/AmbiguousAssignment:
|
9
|
+
Enabled: false
|
10
|
+
Lint/AmbiguousBlockAssociation:
|
11
|
+
Enabled: false
|
12
|
+
Lint/AmbiguousOperator:
|
13
|
+
Enabled: false
|
14
|
+
Lint/AmbiguousRegexpLiteral:
|
15
|
+
Enabled: false
|
16
|
+
Lint/AssignmentInCondition:
|
17
|
+
Enabled: false
|
18
|
+
Lint/ConstantDefinitionInBlock:
|
19
|
+
Enabled: false
|
20
|
+
Lint/ConstantResolution:
|
21
|
+
Enabled: false
|
22
|
+
Lint/DuplicateBranch:
|
23
|
+
Enabled: false
|
24
|
+
Lint/EmptyBlock:
|
25
|
+
Enabled: false
|
26
|
+
Lint/EmptyClass:
|
27
|
+
Enabled: false
|
28
|
+
Lint/EmptyConditionalBody:
|
29
|
+
Enabled: false
|
30
|
+
Lint/EmptyExpression:
|
31
|
+
Enabled: false
|
32
|
+
Lint/EmptyFile:
|
33
|
+
Enabled: false
|
34
|
+
Lint/EmptyWhen:
|
35
|
+
Enabled: false
|
36
|
+
Lint/EnsureReturn:
|
37
|
+
Enabled: false
|
38
|
+
Lint/Loop:
|
39
|
+
Enabled: false
|
40
|
+
Lint/MissingSuper:
|
41
|
+
Enabled: false
|
42
|
+
Lint/MixedRegexpCaptureTypes:
|
43
|
+
Enabled: false
|
44
|
+
Lint/NumberConversion:
|
45
|
+
Enabled: false
|
46
|
+
Lint/ParenthesesAsGroupedExpression:
|
47
|
+
Enabled: false
|
48
|
+
Lint/RedundantStringCoercion:
|
49
|
+
Enabled: false
|
50
|
+
Lint/ShadowedArgument:
|
51
|
+
Enabled: false
|
52
|
+
Lint/ShadowedException:
|
53
|
+
Enabled: false
|
54
|
+
Lint/ShadowingOuterLocalVariable:
|
55
|
+
Enabled: false
|
56
|
+
Lint/SuppressedException:
|
57
|
+
Enabled: false
|
58
|
+
Lint/UnusedBlockArgument:
|
59
|
+
Enabled: false
|
60
|
+
Lint/UnusedMethodArgument:
|
61
|
+
Enabled: false
|
data/.tool-versions
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby 3.0.
|
1
|
+
ruby 3.0.2
|
data/README.md
CHANGED
@@ -1,15 +1,10 @@
|
|
1
1
|
# SerialTranslator
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/serial_translator.svg)](http://badge.fury.io/rb/serial_translator)
|
4
|
-
[![Build Status](https://
|
5
|
-
[![Dependency Status](https://gemnasium.com/betterplace/serial_translator.svg)](https://gemnasium.com/betterplace/serial_translator)
|
4
|
+
[![Build Status](https://github.com/betterplace/serial_translator/workflows/tests/badge.svg)](https://github.com/betterplace/serial_translator/actions)
|
6
5
|
|
7
6
|
Translate ActiveRecord object attributes without the use of additional models.
|
8
7
|
|
9
|
-
## Changes from 1.* to 2.*
|
10
|
-
|
11
|
-
`serial_translator` will now store all translations in JSON format per default rather than in YAML. However, it is still able to read YAML serialized translations and will convert them in the background.
|
12
|
-
|
13
8
|
## Installation
|
14
9
|
|
15
10
|
Add it to your Gemfile:
|
@@ -67,9 +62,6 @@ class BlogPost < ActiveRecord::Base
|
|
67
62
|
end
|
68
63
|
```
|
69
64
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
65
|
## Contributing
|
74
66
|
|
75
67
|
1. Fork it
|
@@ -4,8 +4,9 @@ module SerialTranslator
|
|
4
4
|
translations = record.__send__("#{attribute}_translations")&.values || []
|
5
5
|
translations = [nil] if translations.empty?
|
6
6
|
translations.each do |value|
|
7
|
-
next if options[:allow_blank] && value.to_s == '' ||
|
8
|
-
options[:allow_nil] && value.nil?
|
7
|
+
next if (options[:allow_blank] && value.to_s == '') ||
|
8
|
+
(options[:allow_nil] && value.nil?)
|
9
|
+
|
9
10
|
validate_translation(record, attribute, value)
|
10
11
|
end
|
11
12
|
end
|
data/lib/serial_translator.rb
CHANGED
data/serial_translator.gemspec
CHANGED
@@ -25,6 +25,7 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.add_development_dependency 'rspec'
|
26
26
|
spec.add_development_dependency 'rspec-collection_matchers'
|
27
27
|
spec.add_development_dependency 'json', '~>2'
|
28
|
+
spec.add_development_dependency 'rubocop'
|
28
29
|
spec.add_development_dependency 'simplecov'
|
29
30
|
spec.add_development_dependency 'sqlite3'
|
30
31
|
end
|
@@ -42,6 +42,16 @@ describe SerialTranslator do
|
|
42
42
|
end
|
43
43
|
|
44
44
|
describe 'writing an attribute' do
|
45
|
+
it 'sets the value for the current text locale even with weird utf8 contents' do
|
46
|
+
badly_encoded_string = "Ügnore ünvalîd \xFF UTF-8"
|
47
|
+
expect(badly_encoded_string.valid_encoding?).to eq false
|
48
|
+
|
49
|
+
object.current_translation_locale = :de
|
50
|
+
object.title = badly_encoded_string
|
51
|
+
|
52
|
+
expect(object.title_translations).to eq({ de: 'Ügnore ünvalîd UTF-8' })
|
53
|
+
end
|
54
|
+
|
45
55
|
it 'sets the value for the current text locale' do
|
46
56
|
object.current_translation_locale = :de
|
47
57
|
object.title = 'Deutsch'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: serial_translator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- betterplace development team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-10-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -108,6 +108,20 @@ dependencies:
|
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '2'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rubocop
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
111
125
|
- !ruby/object:Gem::Dependency
|
112
126
|
name: simplecov
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -143,10 +157,12 @@ executables: []
|
|
143
157
|
extensions: []
|
144
158
|
extra_rdoc_files: []
|
145
159
|
files:
|
160
|
+
- ".github/workflows/lint.yml"
|
161
|
+
- ".github/workflows/tests.yml"
|
146
162
|
- ".gitignore"
|
147
163
|
- ".rspec"
|
164
|
+
- ".rubocop.yml"
|
148
165
|
- ".tool-versions"
|
149
|
-
- ".travis.yml"
|
150
166
|
- ".utilsrc"
|
151
167
|
- Gemfile
|
152
168
|
- LICENSE.txt
|
@@ -183,7 +199,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
183
199
|
- !ruby/object:Gem::Version
|
184
200
|
version: '0'
|
185
201
|
requirements: []
|
186
|
-
rubygems_version: 3.2.
|
202
|
+
rubygems_version: 3.2.29
|
187
203
|
signing_key:
|
188
204
|
specification_version: 4
|
189
205
|
summary: Translate attribute values without additional models
|