translatable_records 4.0.0.0 → 4.0.0.1

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
2
  SHA1:
3
- metadata.gz: 0aa7a3637f4a3e85e9a73392989ab14fb3b3256f
4
- data.tar.gz: bee2ea776f4f3075ec6b14f65969485d29eeac94
3
+ metadata.gz: a26760086d362fabbcb7a67d41bbb2de0f664f1b
4
+ data.tar.gz: 1f69f8d5d5e078d01f76c9e3a5e1f8900d4bccc6
5
5
  SHA512:
6
- metadata.gz: 9dd0bd41b405a1cd70f046903ab7229682c0b31bf5beb30d63f456cbf0fef69405e10b326fef5b897f678ac713d91ef6560b6b6640f2490d1645ff0432f209f2
7
- data.tar.gz: 192a617012a83f7fe36357ce3bcf60953d6624255b1b290256ed1b70e49b4810cbad79cca3ad982b9da13fc49495567acbe9ace667caf3eaf79ba4adc573650a
6
+ metadata.gz: c30b54476adfeef31bbcac47b7ec2f710cb1ab0001542ab6f0531584f85dfe1edc0c102741f99717bf415e0030511b3030c79e0190658f94f9a1a4ff50a3a520
7
+ data.tar.gz: 7020b8f57c7caa99d661eb18b1f93689b3d91110453b4da87b21f35752f0f5e803de2c29c6a620fcbf9f0c00563dcee5198e58852cb93feec972c91718dbe5da
data/README.md CHANGED
@@ -71,6 +71,12 @@ If you want to save multiple translations:
71
71
  <% end %>
72
72
  ```
73
73
 
74
+ ## Contributing
75
+
76
+ Any issue, pull request, comment of any kind is more than welcome!
77
+
78
+ I will mainly ensure compatibility to PostgreSQL, AWS, Redis, Elasticsearch, FreeBSD and Memcached. 
79
+
74
80
  ## Credits
75
81
 
76
82
  This gem is maintained and funded by [mmontossi](https://github.com/mmontossi).
@@ -2,7 +2,7 @@ require 'rails/generators'
2
2
 
3
3
  module TranslatableRecords
4
4
  module Generators
5
- class TranslationGenerator < ::Rails::Generators::NamedBase
5
+ class TranslationGenerator < Rails::Generators::NamedBase
6
6
  include Rails::Generators::Migration
7
7
 
8
8
  source_root File.expand_path('../templates', __FILE__)
@@ -5,11 +5,13 @@ module TranslatableRecords
5
5
 
6
6
  def initialize(model)
7
7
  @model = model
8
- @concern = Module.new
8
+ @concern = Module.new do
9
+ extend ActiveSupport::Concern
10
+ include Concern
11
+ end
9
12
  end
10
13
 
11
14
  def define(attributes)
12
- model.include Concern
13
15
  ensure_association
14
16
  attributes.each do |attribute|
15
17
  define_writer attribute
@@ -1,10 +1,12 @@
1
1
  module TranslatableRecords
2
2
  class Railtie < Rails::Railtie
3
3
 
4
- initializer 'translatable_records.extensions' do
5
- ::ActiveRecord::Base.include(
6
- TranslatableRecords::Extensions::ActiveRecord::Base
7
- )
4
+ initializer 'translatable_records.active_record' do
5
+ ActiveSupport.on_load :active_record do
6
+ ::ActiveRecord::Base.include(
7
+ TranslatableRecords::Extensions::ActiveRecord::Base
8
+ )
9
+ end
8
10
  end
9
11
 
10
12
  end
@@ -1,5 +1,5 @@
1
1
  module TranslatableRecords
2
2
 
3
- VERSION = '4.0.0.0'
3
+ VERSION = '4.0.0.1'
4
4
 
5
5
  end
@@ -1,7 +1,10 @@
1
- development:
1
+ default: &default
2
2
  adapter: postgresql
3
+
4
+ development:
5
+ <<: *default
3
6
  database: translatable_records_development
4
7
 
5
8
  test:
6
- adapter: postgresql
9
+ <<: *default
7
10
  database: translatable_records_test
@@ -36,4 +36,43 @@ WHERE c.contype = 'f'
36
36
  AND t1.relname = 'products'
37
37
  AND t3.nspname = ANY (current_schemas(false))
38
38
  ORDER BY c.conname
39
+ 
40
+  (2.5ms) CREATE TABLE "schema_migrations" ("version" character varying NOT NULL) 
41
+  (18.6ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
42
+ ActiveRecord::SchemaMigration Load (0.3ms) SELECT "schema_migrations".* FROM "schema_migrations"
43
+ Migrating to CreateProducts (20130819155126)
44
+  (0.1ms) BEGIN
45
+  (1.8ms) CREATE TABLE "products" ("id" serial primary key, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL) 
46
+ SQL (0.3ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) [["version", "20130819155126"]]
47
+  (0.4ms) COMMIT
48
+ Migrating to CreateProductTranslations (20161205171056)
49
+  (0.2ms) BEGIN
50
+  (2.0ms) CREATE TABLE "product_translations" ("id" serial primary key, "product_id" integer, "locale" character varying, "name" character varying, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL) 
51
+  (0.7ms) CREATE UNIQUE INDEX "index_product_translations_on_product_id_and_locale" ON "product_translations" ("product_id", "locale")
52
+ SQL (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) [["version", "20161205171056"]]
53
+  (0.5ms) COMMIT
54
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
55
+  (1.7ms) SELECT t2.oid::regclass::text AS to_table, a1.attname AS column, a2.attname AS primary_key, c.conname AS name, c.confupdtype AS on_update, c.confdeltype AS on_delete
56
+ FROM pg_constraint c
57
+ JOIN pg_class t1 ON c.conrelid = t1.oid
58
+ JOIN pg_class t2 ON c.confrelid = t2.oid
59
+ JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
60
+ JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
61
+ JOIN pg_namespace t3 ON c.connamespace = t3.oid
62
+ WHERE c.contype = 'f'
63
+ AND t1.relname = 'product_translations'
64
+ AND t3.nspname = ANY (current_schemas(false))
65
+ ORDER BY c.conname
66
+
67
+  (1.4ms) SELECT t2.oid::regclass::text AS to_table, a1.attname AS column, a2.attname AS primary_key, c.conname AS name, c.confupdtype AS on_update, c.confdeltype AS on_delete
68
+ FROM pg_constraint c
69
+ JOIN pg_class t1 ON c.conrelid = t1.oid
70
+ JOIN pg_class t2 ON c.confrelid = t2.oid
71
+ JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
72
+ JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
73
+ JOIN pg_namespace t3 ON c.connamespace = t3.oid
74
+ WHERE c.contype = 'f'
75
+ AND t1.relname = 'products'
76
+ AND t3.nspname = ANY (current_schemas(false))
77
+ ORDER BY c.conname
39
78
  
@@ -1456,3 +1456,94 @@ ProductTest: test_persistent
1456
1456
  GeneratorsTest: test_install
1457
1457
  ----------------------------
1458
1458
   (0.2ms) ROLLBACK
1459
+ ActiveRecord::SchemaMigration Load (26.9ms) SELECT "schema_migrations".* FROM "schema_migrations"
1460
+  (0.2ms) BEGIN
1461
+ ----------------------------
1462
+ GeneratorsTest: test_install
1463
+ ----------------------------
1464
+  (0.1ms) ROLLBACK
1465
+  (0.1ms) BEGIN
1466
+ ----------------------------
1467
+ ProductTest: test_persistent
1468
+ ----------------------------
1469
+  (0.2ms) SAVEPOINT active_record_1
1470
+ ProductTranslation Exists (24.8ms) SELECT 1 AS one FROM "product_translations" WHERE ("product_translations"."product_id" IS NULL AND "product_translations"."locale" = 'en') LIMIT 1
1471
+ ProductTranslation Exists (0.3ms) SELECT 1 AS one FROM "product_translations" WHERE ("product_translations"."product_id" IS NULL AND "product_translations"."locale" = 'es') LIMIT 1
1472
+ SQL (2.0ms) INSERT INTO "products" ("created_at", "updated_at") VALUES ($1, $2) RETURNING "id" [["created_at", "2016-12-13 20:29:31.078254"], ["updated_at", "2016-12-13 20:29:31.078254"]]
1473
+ SQL (1.9ms) INSERT INTO "product_translations" ("locale", "name", "product_id", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5) RETURNING "id" [["locale", "en"], ["name", "phone"], ["product_id", 52], ["created_at", "2016-12-13 20:29:31.081643"], ["updated_at", "2016-12-13 20:29:31.081643"]]
1474
+ SQL (0.2ms) INSERT INTO "product_translations" ("locale", "name", "product_id", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5) RETURNING "id" [["locale", "es"], ["name", "teléfono"], ["product_id", 52], ["created_at", "2016-12-13 20:29:31.084802"], ["updated_at", "2016-12-13 20:29:31.084802"]]
1475
+  (0.1ms) RELEASE SAVEPOINT active_record_1
1476
+ Product Load (0.3ms) SELECT "products".* FROM "products" WHERE "products"."id" = $1 LIMIT 1 [["id", 52]]
1477
+ ProductTranslation Load (0.2ms) SELECT "product_translations".* FROM "product_translations" WHERE "product_translations"."product_id" = $1 [["product_id", 52]]
1478
+  (0.1ms) SAVEPOINT active_record_1
1479
+ SQL (0.2ms) DELETE FROM "product_translations" WHERE "product_translations"."id" = $1 [["id", 97]]
1480
+ SQL (0.2ms) DELETE FROM "product_translations" WHERE "product_translations"."id" = $1 [["id", 98]]
1481
+ SQL (0.1ms) DELETE FROM "products" WHERE "products"."id" = $1 [["id", 52]]
1482
+  (0.1ms) RELEASE SAVEPOINT active_record_1
1483
+  (0.2ms) SELECT COUNT(*) FROM "product_translations"
1484
+  (0.1ms) ROLLBACK
1485
+ ActiveRecord::SchemaMigration Load (0.3ms) SELECT "schema_migrations".* FROM "schema_migrations"
1486
+  (0.2ms) BEGIN
1487
+ ----------------------------
1488
+ GeneratorsTest: test_install
1489
+ ----------------------------
1490
+  (0.2ms) ROLLBACK
1491
+  (0.1ms) BEGIN
1492
+ ----------------------------
1493
+ ProductTest: test_persistent
1494
+ ----------------------------
1495
+  (0.3ms) SAVEPOINT active_record_1
1496
+ ProductTranslation Exists (0.7ms) SELECT 1 AS one FROM "product_translations" WHERE ("product_translations"."product_id" IS NULL AND "product_translations"."locale" = 'en') LIMIT 1
1497
+ ProductTranslation Exists (0.2ms) SELECT 1 AS one FROM "product_translations" WHERE ("product_translations"."product_id" IS NULL AND "product_translations"."locale" = 'es') LIMIT 1
1498
+ SQL (0.3ms) INSERT INTO "products" ("created_at", "updated_at") VALUES ($1, $2) RETURNING "id" [["created_at", "2016-12-13 20:30:16.263393"], ["updated_at", "2016-12-13 20:30:16.263393"]]
1499
+ SQL (0.2ms) INSERT INTO "product_translations" ("locale", "name", "product_id", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5) RETURNING "id" [["locale", "en"], ["name", "phone"], ["product_id", 53], ["created_at", "2016-12-13 20:30:16.264872"], ["updated_at", "2016-12-13 20:30:16.264872"]]
1500
+ SQL (0.2ms) INSERT INTO "product_translations" ("locale", "name", "product_id", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5) RETURNING "id" [["locale", "es"], ["name", "teléfono"], ["product_id", 53], ["created_at", "2016-12-13 20:30:16.265837"], ["updated_at", "2016-12-13 20:30:16.265837"]]
1501
+  (0.1ms) RELEASE SAVEPOINT active_record_1
1502
+ Product Load (0.3ms) SELECT "products".* FROM "products" WHERE "products"."id" = $1 LIMIT 1 [["id", 53]]
1503
+ ProductTranslation Load (0.2ms) SELECT "product_translations".* FROM "product_translations" WHERE "product_translations"."product_id" = $1 [["product_id", 53]]
1504
+  (0.1ms) SAVEPOINT active_record_1
1505
+ SQL (0.2ms) DELETE FROM "product_translations" WHERE "product_translations"."id" = $1 [["id", 99]]
1506
+ SQL (0.2ms) DELETE FROM "product_translations" WHERE "product_translations"."id" = $1 [["id", 100]]
1507
+ SQL (0.2ms) DELETE FROM "products" WHERE "products"."id" = $1 [["id", 53]]
1508
+  (0.1ms) RELEASE SAVEPOINT active_record_1
1509
+  (0.2ms) SELECT COUNT(*) FROM "product_translations"
1510
+  (0.2ms) ROLLBACK
1511
+  (19.3ms) CREATE TABLE "schema_migrations" ("version" character varying NOT NULL) 
1512
+  (16.8ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
1513
+ ActiveRecord::SchemaMigration Load (0.3ms) SELECT "schema_migrations".* FROM "schema_migrations"
1514
+ Migrating to CreateProducts (20130819155126)
1515
+  (0.1ms) BEGIN
1516
+  (7.9ms) CREATE TABLE "products" ("id" serial primary key, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL) 
1517
+ SQL (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) [["version", "20130819155126"]]
1518
+  (6.4ms) COMMIT
1519
+ Migrating to CreateProductTranslations (20161205171056)
1520
+  (11.7ms) BEGIN
1521
+  (12.9ms) CREATE TABLE "product_translations" ("id" serial primary key, "product_id" integer, "locale" character varying, "name" character varying, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL) 
1522
+  (0.8ms) CREATE UNIQUE INDEX "index_product_translations_on_product_id_and_locale" ON "product_translations" ("product_id", "locale")
1523
+ SQL (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) [["version", "20161205171056"]]
1524
+  (0.6ms) COMMIT
1525
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
1526
+  (1.7ms) SELECT t2.oid::regclass::text AS to_table, a1.attname AS column, a2.attname AS primary_key, c.conname AS name, c.confupdtype AS on_update, c.confdeltype AS on_delete
1527
+ FROM pg_constraint c
1528
+ JOIN pg_class t1 ON c.conrelid = t1.oid
1529
+ JOIN pg_class t2 ON c.confrelid = t2.oid
1530
+ JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
1531
+ JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
1532
+ JOIN pg_namespace t3 ON c.connamespace = t3.oid
1533
+ WHERE c.contype = 'f'
1534
+ AND t1.relname = 'product_translations'
1535
+ AND t3.nspname = ANY (current_schemas(false))
1536
+ ORDER BY c.conname
1537
+
1538
+  (1.9ms) SELECT t2.oid::regclass::text AS to_table, a1.attname AS column, a2.attname AS primary_key, c.conname AS name, c.confupdtype AS on_update, c.confdeltype AS on_delete
1539
+ FROM pg_constraint c
1540
+ JOIN pg_class t1 ON c.conrelid = t1.oid
1541
+ JOIN pg_class t2 ON c.confrelid = t2.oid
1542
+ JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
1543
+ JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
1544
+ JOIN pg_namespace t3 ON c.connamespace = t3.oid
1545
+ WHERE c.contype = 'f'
1546
+ AND t1.relname = 'products'
1547
+ AND t3.nspname = ANY (current_schemas(false))
1548
+ ORDER BY c.conname
1549
+ 
@@ -10,7 +10,7 @@ class GeneratorsTest < ::Rails::Generators::TestCase
10
10
  end
11
11
 
12
12
  test 'install' do
13
- self.class.tests TranslationGenerator
13
+ self.class.tests TranslatableRecords::Generators::TranslationGenerator
14
14
  run_generator %w(product)
15
15
  assert_file 'app/models/product_translation.rb'
16
16
  assert_migration 'db/migrate/create_product_translations.rb'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: translatable_records
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0.0
4
+ version: 4.0.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - mmontossi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-06 00:00:00.000000000 Z
11
+ date: 2016-12-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails