i18n-postgres_json 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +237 -0
- data/Rakefile +32 -0
- data/db/migrate/backend/20200409133306_create_i18n_postgres_json_backend_translations.rb +11 -0
- data/db/migrate/key_value/20200410160009_create_i18n_postgres_json_key_value_store_translations.rb +9 -0
- data/lib/i18n/postgres_json.rb +7 -0
- data/lib/i18n/postgres_json/backend.rb +25 -0
- data/lib/i18n/postgres_json/engine.rb +10 -0
- data/lib/i18n/postgres_json/key_value/store.rb +32 -0
- data/lib/i18n/postgres_json/key_value/translation.rb +23 -0
- data/lib/i18n/postgres_json/translation.rb +53 -0
- data/lib/i18n/postgres_json/version.rb +5 -0
- data/lib/tasks/i18n/postgres_json_tasks.rake +4 -0
- data/lib/tasks/i18n_postgres_jsonb_tasks.rake +27 -0
- metadata +113 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e059f727a22aee6aa72273561be945a2a1994b9b4026e16bf45112ce53c7def4
|
4
|
+
data.tar.gz: 6e605e2377bb4807f1636c64498f3af6895aa59142ad4b0abfa88874f1f84675
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b352b46ba2e40b2521ea58f8fe291b239d5b08a81b02192285311e5914a9c05497761503ec90484c495837bc465c28d81164a07caecf5b57a5c01e4dc159e9bc
|
7
|
+
data.tar.gz: 3d1f476c82482a1566fa858e6e58171c994d5e3960371e1c5ba35c2c0669120657677fdecfec8dea133abcbca8db2d44d2dac2b9e1d3f947305e97b1a95628e5
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2020 Sean Doyle
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,237 @@
|
|
1
|
+
# I18n::PostgresJson
|
2
|
+
|
3
|
+
Internationalization backed by Postgres JSON columns
|
4
|
+
|
5
|
+
## Usage
|
6
|
+
|
7
|
+
[PostgreSQL's][pg] support for storing objects as [JSON and JSONB
|
8
|
+
columns][pg-json], integrated with [`ActiveRecord` column-aware
|
9
|
+
models][activerecord-pg-json] makes it an ideal candidate to store dynamic,
|
10
|
+
editable application translation text.
|
11
|
+
|
12
|
+
This gem's inspiration comes from the [Rails Internationalization (<abbr
|
13
|
+
title="Internationalization">i18n</abbr>) Guides][i18n-guides] mention of
|
14
|
+
[`i18n-active_record`][i18n-ar].
|
15
|
+
|
16
|
+
[Cascading translations][i18n-chain] by combining a dynamic, database driven
|
17
|
+
translation source ahead of the default `I18n::Backend::Simple` enable dynamic
|
18
|
+
copy editing, with an in-code foundational source.
|
19
|
+
|
20
|
+
[pg]: https://www.postgresql.org/about/
|
21
|
+
[pg-json]: https://www.postgresql.org/docs/9.4/datatype-json.html#DATATYPE-JSON
|
22
|
+
[activerecord-pg-json]: https://guides.rubyonrails.org/active_record_postgresql.html#json-and-json
|
23
|
+
[i18n-ar]: https://github.com/svenfuchs/i18n-active_record
|
24
|
+
[i18n-guides]: https://guides.rubyonrails.org/i18n.html#using-different-backends
|
25
|
+
[i18n-chain]: https://www.rubydoc.info/github/ruby-i18n/i18n/master/I18n/Backend/Chain
|
26
|
+
|
27
|
+
## Installation
|
28
|
+
|
29
|
+
Add this line to your application's `Gemfile`:
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
gem 'i18n-postgres_json'
|
33
|
+
```
|
34
|
+
|
35
|
+
And then execute:
|
36
|
+
|
37
|
+
```bash
|
38
|
+
bundle
|
39
|
+
```
|
40
|
+
|
41
|
+
### I18n::PostgresJson::KeyValue::Store
|
42
|
+
|
43
|
+
The `I18n::PostgresJson::KeyValue::Store` class serves as a `store` for the
|
44
|
+
[`I18n::Backend::KeyValue` backend][i18n-key-value].
|
45
|
+
|
46
|
+
The `I18n::PostgresJson::KeyValue::Store` interacts with a Postgres table
|
47
|
+
consisting of:
|
48
|
+
|
49
|
+
```
|
50
|
+
Table "public.i18n_postgres_json_key_value_store_translations"
|
51
|
+
Column | Type | Collation | Nullable | Default
|
52
|
+
--------------+-----------------------------+-----------+----------+-----------------------------------------------------------------------------
|
53
|
+
id | integer | | not null | nextval('i18n_postgres_json_key_value_store_translations_id_seq'::regclass)
|
54
|
+
translations | json | | not null | '{}'::json
|
55
|
+
created_at | timestamp without time zone | | not null |
|
56
|
+
updated_at | timestamp without time zone | | not null |
|
57
|
+
Indexes:
|
58
|
+
"i18n_postgres_json_key_value_store_translations_pkey" PRIMARY KEY, btree (id)
|
59
|
+
```
|
60
|
+
|
61
|
+
This style of backend store _all_ translations, regardless of locale, within the
|
62
|
+
same `translations` column, backed by [JSON][pg-json].
|
63
|
+
|
64
|
+
**This table is only ever intended to store a single row.**
|
65
|
+
|
66
|
+
To generate this table, install the necessary migrations:
|
67
|
+
|
68
|
+
```bash
|
69
|
+
rails i18n_postgres_json:install:key_value
|
70
|
+
```
|
71
|
+
|
72
|
+
Then execute them:
|
73
|
+
|
74
|
+
```bash
|
75
|
+
rails db:migrate
|
76
|
+
```
|
77
|
+
|
78
|
+
Next, configure your `I18n.backend` (either in a Rails environment configuration
|
79
|
+
block, or an initializer of its own):
|
80
|
+
|
81
|
+
```ruby
|
82
|
+
# config/initializers/i18n.rb
|
83
|
+
I18n.backend = I18n::Backend::Chain.new(
|
84
|
+
I18n::Backend::KeyValue.new(I18n::PostgresJson::KeyValue::Store.new),
|
85
|
+
I18n.backend, # typically defaults to I18n::Backend::Simple
|
86
|
+
)
|
87
|
+
```
|
88
|
+
|
89
|
+
**Caveat:** It's worth noting that according to the [`I18n::Backend::KeyValue`
|
90
|
+
documentation][i18n-key-value], this backend cannot store serialized [Ruby
|
91
|
+
`Proc` instances][proc]:
|
92
|
+
|
93
|
+
> Since these stores only supports string, all values are converted to JSON
|
94
|
+
> before being stored, allowing it to also store booleans, hashes and arrays.
|
95
|
+
> **However, this store does not support Procs.**
|
96
|
+
|
97
|
+
[i18n-key-value]: https://www.rubydoc.info/github/ruby-i18n/i18n/master/I18n/Backend/KeyValue
|
98
|
+
[proc]: https://ruby-doc.org/core-2.7.1/Proc.html
|
99
|
+
|
100
|
+
### I18n::PostgresJson::Backend
|
101
|
+
|
102
|
+
The `I18n::PostgresJson::Backend` class serves as an `I18n::Backend`
|
103
|
+
implementation of its own.
|
104
|
+
|
105
|
+
The `I18n::PostgresJson::Backend` interacts with a Postgres table
|
106
|
+
consisting of:
|
107
|
+
|
108
|
+
```
|
109
|
+
Table "public.i18n_postgres_json_backend_translations"
|
110
|
+
Column | Type | Collation | Nullable | Default
|
111
|
+
--------------+-----------------------------+-----------+----------+---------------------------------------------------------------------
|
112
|
+
id | integer | | not null | nextval('i18n_postgres_json_backend_translations_id_seq'::regclass)
|
113
|
+
locale | character varying | | not null |
|
114
|
+
translations | json | | not null | '{}'::json
|
115
|
+
created_at | timestamp without time zone | | not null |
|
116
|
+
updated_at | timestamp without time zone | | not null |
|
117
|
+
Indexes:
|
118
|
+
"i18n_postgres_json_backend_translations_pkey" PRIMARY KEY, btree (id)
|
119
|
+
"index_i18n_postgres_json_backend_translations_on_locale" UNIQUE, btree (locale)
|
120
|
+
```
|
121
|
+
|
122
|
+
This style of backend splits each `locale` into its own row, separating out
|
123
|
+
translations into one lookup table per-locale. The `translations` column is
|
124
|
+
backed by [JSON][pg-json].
|
125
|
+
|
126
|
+
To generate this table, install the necessary migrations:
|
127
|
+
|
128
|
+
```bash
|
129
|
+
rails i18n_postgres_json:install:backend
|
130
|
+
```
|
131
|
+
|
132
|
+
Then execute them:
|
133
|
+
|
134
|
+
```bash
|
135
|
+
rails db:migrate
|
136
|
+
```
|
137
|
+
|
138
|
+
Next, configure your `I18n.backend` (either in a Rails environment configuration
|
139
|
+
block, or an initializer of its own):
|
140
|
+
|
141
|
+
```ruby
|
142
|
+
# config/initializers/i18n.rb
|
143
|
+
I18n.backend = I18n::Backend::Chain.new(
|
144
|
+
I18n::PostgresJson::Backend.new,
|
145
|
+
I18n.backend, # typically defaults to I18n::Backend::Simple
|
146
|
+
)
|
147
|
+
```
|
148
|
+
|
149
|
+
**Caveat**: It's worth noting that the `I18n::PostgresJson::Backend` does not
|
150
|
+
currently support translation linking.
|
151
|
+
|
152
|
+
### Writing to the tables
|
153
|
+
|
154
|
+
Regardless of whether your application integrates with
|
155
|
+
`I18n::PostgresJson::KeyValue::Store`, or `I18n::PostgresJson::Backend`, the
|
156
|
+
implementation for updating existing translations will be the same: use
|
157
|
+
[`I18n::Backend::Base.store_translations`][store_translations].
|
158
|
+
|
159
|
+
If you were to edit a translation through an HTML `<form>` element that
|
160
|
+
submitted to a Rails controller, it might look something like this:
|
161
|
+
|
162
|
+
```html
|
163
|
+
<!-- app/views/posts/index.html.erb -->
|
164
|
+
<form action="/translations" method="post">
|
165
|
+
<input type="hidden" name="translation[locale]" value="en">
|
166
|
+
<input type="hidden" name="translation[key]" value="posts.index.title">
|
167
|
+
|
168
|
+
<label for="translation_value">
|
169
|
+
Translation for posts.index.title
|
170
|
+
</label>
|
171
|
+
<input type="text" id="translation_value" name="translation[value]">
|
172
|
+
|
173
|
+
<button>
|
174
|
+
Save Translation
|
175
|
+
</button>
|
176
|
+
</form>
|
177
|
+
```
|
178
|
+
|
179
|
+
When that `<form>` element is submitted, the resulting controller action (in
|
180
|
+
this example, `translations#create`) would pass along the submitted translation
|
181
|
+
to `store_translations`:
|
182
|
+
|
183
|
+
```ruby
|
184
|
+
class TranslationsController < ApplicationController
|
185
|
+
def create
|
186
|
+
I18n.backend.store_translation(
|
187
|
+
translation_params.fetch(:locale),
|
188
|
+
translation_params.fetch(:key) => translation_params.fetch(:value),
|
189
|
+
)
|
190
|
+
|
191
|
+
redirect_to posts_url
|
192
|
+
end
|
193
|
+
|
194
|
+
private
|
195
|
+
|
196
|
+
def translation_params
|
197
|
+
params.require(:translation).permit(
|
198
|
+
:key,
|
199
|
+
:locale,
|
200
|
+
:value,
|
201
|
+
)
|
202
|
+
end
|
203
|
+
end
|
204
|
+
```
|
205
|
+
|
206
|
+
**Caveat:** This is a potentially disruptive (and destructive!) action, so the
|
207
|
+
application would want to limit control to authenticated content editors. This
|
208
|
+
example omits those details for the sake of brevity.
|
209
|
+
|
210
|
+
[store_translations]: https://www.rubydoc.info/github/ruby-i18n/i18n/I18n/Backend/Base#store_translations-instance_method
|
211
|
+
|
212
|
+
## Testing
|
213
|
+
|
214
|
+
In addition to being exercised by a test harness specific to this gem, each
|
215
|
+
backend is covered by the [`i18n-ruby`-provided API Tests][interface-tests].
|
216
|
+
|
217
|
+
These test cover a range of behavior, including:
|
218
|
+
|
219
|
+
* [The Basics of translating text](https://github.com/ruby-i18n/i18n/blob/v1.8.2/lib/i18n/tests/basics.rb)
|
220
|
+
* [Translation lookup](https://github.com/ruby-i18n/i18n/blob/v1.8.2/lib/i18n/tests/lookup.rb)
|
221
|
+
* [Falling back to provided defaults](https://github.com/ruby-i18n/i18n/blob/v1.8.2/lib/i18n/tests/defaults.rb)
|
222
|
+
* [Interpolation](https://github.com/ruby-i18n/i18n/blob/v1.8.2/lib/i18n/tests/interpolation.rb)
|
223
|
+
* [Translation key linking](https://github.com/ruby-i18n/i18n/blob/v1.8.2/lib/i18n/tests/link.rb)
|
224
|
+
* [Localizing Dates and Times](https://github.com/ruby-i18n/i18n/blob/v1.8.2/lib/i18n/tests/localization.rb)
|
225
|
+
* [Pluralizing text](https://github.com/ruby-i18n/i18n/blob/v1.8.2/lib/i18n/tests/pluralization.rb)
|
226
|
+
* [Storing Ruby Procs](https://github.com/ruby-i18n/i18n/blob/v1.8.2/lib/i18n/tests/procs.rb)
|
227
|
+
|
228
|
+
[interface-tests]: https://github.com/ruby-i18n/i18n/blob/v1.8.2/lib/i18n/tests/basics.rb
|
229
|
+
|
230
|
+
## Contributing
|
231
|
+
|
232
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md).
|
233
|
+
|
234
|
+
## License
|
235
|
+
|
236
|
+
The gem is available as open source under the terms of the [MIT
|
237
|
+
License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'I18n::PostgresJson'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.md')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
|
18
|
+
load 'rails/tasks/engine.rake'
|
19
|
+
|
20
|
+
load 'rails/tasks/statistics.rake'
|
21
|
+
|
22
|
+
require 'bundler/gem_tasks'
|
23
|
+
|
24
|
+
require 'rake/testtask'
|
25
|
+
|
26
|
+
Rake::TestTask.new(:test) do |t|
|
27
|
+
t.libs << 'test'
|
28
|
+
t.pattern = 'test/**/*_test.rb'
|
29
|
+
t.verbose = false
|
30
|
+
end
|
31
|
+
|
32
|
+
task default: :test
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class CreateI18nPostgresJsonBackendTranslations < ActiveRecord::Migration[4.2]
|
2
|
+
def change
|
3
|
+
create_table :i18n_postgres_json_backend_translations do |t|
|
4
|
+
t.string :locale, null: false
|
5
|
+
t.json :translations, null: false, default: {}
|
6
|
+
t.timestamps null: false
|
7
|
+
|
8
|
+
t.index :locale, unique: true
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
data/db/migrate/key_value/20200410160009_create_i18n_postgres_json_key_value_store_translations.rb
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
class CreateI18nPostgresJsonKeyValueStoreTranslations < ActiveRecord::Migration[4.2]
|
2
|
+
def change
|
3
|
+
create_table :i18n_postgres_json_key_value_store_translations do |t|
|
4
|
+
t.json :translations, null: false, default: {}
|
5
|
+
|
6
|
+
t.timestamps null: false
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module I18n
|
2
|
+
module PostgresJson
|
3
|
+
class Backend
|
4
|
+
include I18n::Backend::Base
|
5
|
+
|
6
|
+
def available_locales=(available_locales)
|
7
|
+
@available_locales = Array(available_locales).map(&:to_sym).presence
|
8
|
+
end
|
9
|
+
|
10
|
+
def available_locales
|
11
|
+
@available_locales || Translation.available_locales
|
12
|
+
end
|
13
|
+
|
14
|
+
def store_translations(locale, data, **options)
|
15
|
+
Translation.store_translations(locale, data)
|
16
|
+
end
|
17
|
+
|
18
|
+
protected
|
19
|
+
|
20
|
+
def lookup(locale, key, scope = [], separator: I18n.default_separator, **options)
|
21
|
+
Translation.locale(locale).lookup(key, scope, separator: separator)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module I18n
|
2
|
+
module PostgresJson
|
3
|
+
module KeyValue
|
4
|
+
class Store
|
5
|
+
def [](key)
|
6
|
+
record[escape(key)]
|
7
|
+
end
|
8
|
+
|
9
|
+
def []=(key, value)
|
10
|
+
record[escape(key)] = value
|
11
|
+
end
|
12
|
+
|
13
|
+
def keys
|
14
|
+
record.keys
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def escape(key)
|
20
|
+
key.gsub(
|
21
|
+
I18n::Backend::Flatten::SEPARATOR_ESCAPE_CHAR,
|
22
|
+
I18n.default_separator
|
23
|
+
)
|
24
|
+
end
|
25
|
+
|
26
|
+
def record
|
27
|
+
Translation.first_or_initialize
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module I18n
|
2
|
+
module PostgresJson
|
3
|
+
module KeyValue
|
4
|
+
class Translation < ActiveRecord::Base
|
5
|
+
self.table_name = "i18n_postgres_json_key_value_store_translations"
|
6
|
+
|
7
|
+
def [](key)
|
8
|
+
translations[key]
|
9
|
+
end
|
10
|
+
|
11
|
+
def []=(key, value)
|
12
|
+
translations[key] = value
|
13
|
+
|
14
|
+
save!
|
15
|
+
end
|
16
|
+
|
17
|
+
def keys
|
18
|
+
translations.keys
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module I18n
|
2
|
+
module PostgresJson
|
3
|
+
class Translation < ActiveRecord::Base
|
4
|
+
self.table_name = "i18n_postgres_json_backend_translations"
|
5
|
+
|
6
|
+
def self.available_locales
|
7
|
+
(
|
8
|
+
distinct.order(locale: :asc).pluck(:locale) + [I18n.default_locale]
|
9
|
+
).map(&:to_sym).uniq
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.store_translations(locale, data)
|
13
|
+
record = self.locale(locale)
|
14
|
+
|
15
|
+
record.translations.deep_merge!(data.deep_stringify_keys)
|
16
|
+
|
17
|
+
record.save!
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.locale(locale)
|
21
|
+
find_or_initialize_by(locale: locale)
|
22
|
+
end
|
23
|
+
|
24
|
+
def dig(*keys)
|
25
|
+
keys = Array(keys)
|
26
|
+
|
27
|
+
translations.with_indifferent_access.dig(*keys)
|
28
|
+
end
|
29
|
+
|
30
|
+
def lookup(key, scope = [], separator:)
|
31
|
+
_, *keys = I18n.normalize_keys(locale, key, scope, separator)
|
32
|
+
|
33
|
+
translated = keys.each_with_index.reduce(nil) { |translation, (_, index)|
|
34
|
+
if translation.present?
|
35
|
+
translation
|
36
|
+
else
|
37
|
+
leading = keys.take(index)
|
38
|
+
trailing = keys.drop(index)
|
39
|
+
|
40
|
+
dig(*([leading.join(separator)] + keys - leading)) ||
|
41
|
+
dig(*(keys - trailing + [trailing.join(separator)]))
|
42
|
+
end
|
43
|
+
}
|
44
|
+
|
45
|
+
if translated.respond_to?(:deep_symbolize_keys)
|
46
|
+
translated.deep_symbolize_keys
|
47
|
+
else
|
48
|
+
translated
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
namespace :i18n_postgres_json do
|
2
|
+
namespace :install do
|
3
|
+
Rake::Task["i18n_postgres_json_engine:install:migrations"].clear_comments
|
4
|
+
|
5
|
+
desc "Copy over the migrations needed for I18n::PostgresJson::Backend integration"
|
6
|
+
task backend: :environment do
|
7
|
+
ENV["MIGRATIONS_PATH"] = "db/migrate/backend"
|
8
|
+
|
9
|
+
if Rake::Task.task_defined?("i18n_postgres_json_engine:install:migrations")
|
10
|
+
Rake::Task["i18n_postgres_json_engine:install:migrations"].invoke
|
11
|
+
else
|
12
|
+
Rake::Task["app:i18n_postgres_json_engine:install:migrations"].invoke
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
desc "Copy over the migrations needed for I18n::PostgresJson::KeyValue::Store integration"
|
17
|
+
task key_value: :environment do
|
18
|
+
ENV["MIGRATIONS_PATH"] = "db/migrate/key_value"
|
19
|
+
|
20
|
+
if Rake::Task.task_defined?("i18n_postgres_json_engine:install:migrations")
|
21
|
+
Rake::Task["i18n_postgres_json_engine:install:migrations"].invoke
|
22
|
+
else
|
23
|
+
Rake::Task["app:i18n_postgres_json_engine:install:migrations"].invoke
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: i18n-postgres_json
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Sean Doyle
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-04-13 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activerecord
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 4.2.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 4.2.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: pg
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: mocha
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.7.0
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.7.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: minitest-around
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.5.0
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.5.0
|
69
|
+
description: Store I18n values in PostgreSQL JSON columns
|
70
|
+
email:
|
71
|
+
- sean.p.doyle24@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- MIT-LICENSE
|
77
|
+
- README.md
|
78
|
+
- Rakefile
|
79
|
+
- db/migrate/backend/20200409133306_create_i18n_postgres_json_backend_translations.rb
|
80
|
+
- db/migrate/key_value/20200410160009_create_i18n_postgres_json_key_value_store_translations.rb
|
81
|
+
- lib/i18n/postgres_json.rb
|
82
|
+
- lib/i18n/postgres_json/backend.rb
|
83
|
+
- lib/i18n/postgres_json/engine.rb
|
84
|
+
- lib/i18n/postgres_json/key_value/store.rb
|
85
|
+
- lib/i18n/postgres_json/key_value/translation.rb
|
86
|
+
- lib/i18n/postgres_json/translation.rb
|
87
|
+
- lib/i18n/postgres_json/version.rb
|
88
|
+
- lib/tasks/i18n/postgres_json_tasks.rake
|
89
|
+
- lib/tasks/i18n_postgres_jsonb_tasks.rake
|
90
|
+
homepage: https://github.com/seanpdoyle/i18n-postgres_json
|
91
|
+
licenses:
|
92
|
+
- MIT
|
93
|
+
metadata: {}
|
94
|
+
post_install_message:
|
95
|
+
rdoc_options: []
|
96
|
+
require_paths:
|
97
|
+
- lib
|
98
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - ">="
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '0'
|
108
|
+
requirements: []
|
109
|
+
rubygems_version: 3.0.3
|
110
|
+
signing_key:
|
111
|
+
specification_version: 4
|
112
|
+
summary: Internationalization backed by Postgres JSON columns
|
113
|
+
test_files: []
|