rails-i18nterface 0.1.4 → 0.1.5
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.
- data/lib/rails-i18nterface/sourcefiles.rb +5 -4
- data/lib/rails-i18nterface/version.rb +1 -1
- data/spec/internal/log/test.log +84 -0
- data/spec/lib/keys_spec.rb +21 -2
- data/spec/lib/sourcefiles_spec.rb +10 -10
- metadata +1 -1
@@ -3,10 +3,11 @@ module RailsI18nterface
|
|
3
3
|
|
4
4
|
def self.extract_files
|
5
5
|
i18n_lookup_pattern = /\b(?:I18n\.t|I18n\.translate|t)(?:\s|\():?(?:'|")(\.?[a-z0-9_\.]+)(?:'|")/
|
6
|
+
f = {}
|
6
7
|
self.files_to_scan.inject(HashWithIndifferentAccess.new) do |files, file|
|
7
|
-
files.merge! self.populate_keys(file, i18n_lookup_pattern)
|
8
|
+
f = files.merge! self.populate_keys(file, i18n_lookup_pattern)
|
8
9
|
end
|
9
|
-
|
10
|
+
f.merge self.extract_activerecords
|
10
11
|
end
|
11
12
|
|
12
13
|
def self.populate_keys(file, pattern)
|
@@ -41,7 +42,7 @@ module RailsI18nterface
|
|
41
42
|
matchdata = regex.match(File.read(schema))
|
42
43
|
while matchdata != nil
|
43
44
|
model = matchdata[1]
|
44
|
-
files["activerecord.models.#{model}"] = 'db/schema.rb'
|
45
|
+
files["activerecord.models.#{model}"] = ['db/schema.rb']
|
45
46
|
files.merge!(self.extract_attributes(model,matchdata[2]))
|
46
47
|
matchdata = regex.match(matchdata.post_match)
|
47
48
|
end
|
@@ -55,7 +56,7 @@ module RailsI18nterface
|
|
55
56
|
matchdata = regex.match(txt)
|
56
57
|
while matchdata != nil
|
57
58
|
attribute = matchdata[1]
|
58
|
-
files["activerecord.attributes.#{model}.#{attribute}"] = 'db/schema.rb'
|
59
|
+
files["activerecord.attributes.#{model}.#{attribute}"] = ['db/schema.rb']
|
59
60
|
matchdata = regex.match(matchdata.post_match)
|
60
61
|
end
|
61
62
|
files
|
data/spec/internal/log/test.log
CHANGED
@@ -736,3 +736,87 @@ Migrating to CreateTranslations (20110921112044)
|
|
736
736
|
[1m[35m (0.9ms)[0m CREATE TABLE "translations" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "locale" varchar(255), "key" varchar(255), "value" text, "interpolations" text, "is_proc" boolean DEFAULT 'f', "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
|
737
737
|
[1m[36m (0.3ms)[0m [1mINSERT INTO "schema_migrations" ("version") VALUES ('20110921112044')[0m
|
738
738
|
[1m[35m (108.7ms)[0m commit transaction
|
739
|
+
Connecting to database specified by database.yml
|
740
|
+
[1m[36m (2.0ms)[0m [1mselect sqlite_version(*)[0m
|
741
|
+
[1m[35m (125.2ms)[0m CREATE TABLE "article" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar(255) NOT NULL, "body" varchar(255), "created_at" datetime, "updated_at" datetime, "active" boolean DEFAULT 't')
|
742
|
+
[1m[36m (115.7ms)[0m [1mCREATE TABLE "topics" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar(255) NOT NULL, "created_at" datetime, "updated_at" datetime) [0m
|
743
|
+
[1m[35m (107.1ms)[0m CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
|
744
|
+
[1m[36m (108.5ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
745
|
+
[1m[35m (4.9ms)[0m SELECT "schema_migrations"."version" FROM "schema_migrations"
|
746
|
+
Migrating to CreateTranslations (20110921112044)
|
747
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
748
|
+
[1m[35m (0.3ms)[0m CREATE TABLE "translations" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "locale" varchar(255), "key" varchar(255), "value" text, "interpolations" text, "is_proc" boolean DEFAULT 'f', "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
|
749
|
+
[1m[36m (0.1ms)[0m [1mINSERT INTO "schema_migrations" ("version") VALUES ('20110921112044')[0m
|
750
|
+
[1m[35m (111.1ms)[0m commit transaction
|
751
|
+
Connecting to database specified by database.yml
|
752
|
+
[1m[36m (1.8ms)[0m [1mselect sqlite_version(*)[0m
|
753
|
+
[1m[35m (113.6ms)[0m CREATE TABLE "article" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar(255) NOT NULL, "body" varchar(255), "created_at" datetime, "updated_at" datetime, "active" boolean DEFAULT 't')
|
754
|
+
[1m[36m (97.4ms)[0m [1mCREATE TABLE "topics" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar(255) NOT NULL, "created_at" datetime, "updated_at" datetime) [0m
|
755
|
+
[1m[35m (107.3ms)[0m CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
|
756
|
+
[1m[36m (126.8ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
757
|
+
[1m[35m (5.0ms)[0m SELECT "schema_migrations"."version" FROM "schema_migrations"
|
758
|
+
Migrating to CreateTranslations (20110921112044)
|
759
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
760
|
+
[1m[35m (0.9ms)[0m CREATE TABLE "translations" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "locale" varchar(255), "key" varchar(255), "value" text, "interpolations" text, "is_proc" boolean DEFAULT 'f', "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
|
761
|
+
[1m[36m (0.3ms)[0m [1mINSERT INTO "schema_migrations" ("version") VALUES ('20110921112044')[0m
|
762
|
+
[1m[35m (123.5ms)[0m commit transaction
|
763
|
+
Connecting to database specified by database.yml
|
764
|
+
[1m[36m (1.9ms)[0m [1mselect sqlite_version(*)[0m
|
765
|
+
[1m[35m (128.4ms)[0m CREATE TABLE "article" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar(255) NOT NULL, "body" varchar(255), "created_at" datetime, "updated_at" datetime, "active" boolean DEFAULT 't')
|
766
|
+
[1m[36m (107.8ms)[0m [1mCREATE TABLE "topics" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar(255) NOT NULL, "created_at" datetime, "updated_at" datetime) [0m
|
767
|
+
[1m[35m (98.9ms)[0m CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
|
768
|
+
[1m[36m (99.5ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
769
|
+
[1m[35m (5.4ms)[0m SELECT "schema_migrations"."version" FROM "schema_migrations"
|
770
|
+
Migrating to CreateTranslations (20110921112044)
|
771
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
772
|
+
[1m[35m (0.7ms)[0m CREATE TABLE "translations" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "locale" varchar(255), "key" varchar(255), "value" text, "interpolations" text, "is_proc" boolean DEFAULT 'f', "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
|
773
|
+
[1m[36m (0.1ms)[0m [1mINSERT INTO "schema_migrations" ("version") VALUES ('20110921112044')[0m
|
774
|
+
[1m[35m (100.6ms)[0m commit transaction
|
775
|
+
Connecting to database specified by database.yml
|
776
|
+
[1m[36m (1.8ms)[0m [1mselect sqlite_version(*)[0m
|
777
|
+
[1m[35m (117.4ms)[0m CREATE TABLE "article" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar(255) NOT NULL, "body" varchar(255), "created_at" datetime, "updated_at" datetime, "active" boolean DEFAULT 't')
|
778
|
+
[1m[36m (91.1ms)[0m [1mCREATE TABLE "topics" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar(255) NOT NULL, "created_at" datetime, "updated_at" datetime) [0m
|
779
|
+
[1m[35m (90.7ms)[0m CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
|
780
|
+
[1m[36m (108.1ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
781
|
+
[1m[35m (5.0ms)[0m SELECT "schema_migrations"."version" FROM "schema_migrations"
|
782
|
+
Migrating to CreateTranslations (20110921112044)
|
783
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
784
|
+
[1m[35m (0.9ms)[0m CREATE TABLE "translations" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "locale" varchar(255), "key" varchar(255), "value" text, "interpolations" text, "is_proc" boolean DEFAULT 'f', "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
|
785
|
+
[1m[36m (0.3ms)[0m [1mINSERT INTO "schema_migrations" ("version") VALUES ('20110921112044')[0m
|
786
|
+
[1m[35m (116.3ms)[0m commit transaction
|
787
|
+
Connecting to database specified by database.yml
|
788
|
+
[1m[36m (1.8ms)[0m [1mselect sqlite_version(*)[0m
|
789
|
+
[1m[35m (139.9ms)[0m CREATE TABLE "article" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar(255) NOT NULL, "body" varchar(255), "created_at" datetime, "updated_at" datetime, "active" boolean DEFAULT 't')
|
790
|
+
[1m[36m (113.8ms)[0m [1mCREATE TABLE "topics" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar(255) NOT NULL, "created_at" datetime, "updated_at" datetime) [0m
|
791
|
+
[1m[35m (107.3ms)[0m CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
|
792
|
+
[1m[36m (116.1ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
793
|
+
[1m[35m (5.0ms)[0m SELECT "schema_migrations"."version" FROM "schema_migrations"
|
794
|
+
Migrating to CreateTranslations (20110921112044)
|
795
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
796
|
+
[1m[35m (0.9ms)[0m CREATE TABLE "translations" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "locale" varchar(255), "key" varchar(255), "value" text, "interpolations" text, "is_proc" boolean DEFAULT 'f', "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
|
797
|
+
[1m[36m (0.3ms)[0m [1mINSERT INTO "schema_migrations" ("version") VALUES ('20110921112044')[0m
|
798
|
+
[1m[35m (108.4ms)[0m commit transaction
|
799
|
+
Connecting to database specified by database.yml
|
800
|
+
[1m[36m (1.8ms)[0m [1mselect sqlite_version(*)[0m
|
801
|
+
[1m[35m (102.1ms)[0m CREATE TABLE "article" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar(255) NOT NULL, "body" varchar(255), "created_at" datetime, "updated_at" datetime, "active" boolean DEFAULT 't')
|
802
|
+
[1m[36m (97.4ms)[0m [1mCREATE TABLE "topics" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar(255) NOT NULL, "created_at" datetime, "updated_at" datetime) [0m
|
803
|
+
[1m[35m (98.9ms)[0m CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
|
804
|
+
[1m[36m (116.1ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
805
|
+
[1m[35m (5.1ms)[0m SELECT "schema_migrations"."version" FROM "schema_migrations"
|
806
|
+
Migrating to CreateTranslations (20110921112044)
|
807
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
808
|
+
[1m[35m (0.9ms)[0m CREATE TABLE "translations" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "locale" varchar(255), "key" varchar(255), "value" text, "interpolations" text, "is_proc" boolean DEFAULT 'f', "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
|
809
|
+
[1m[36m (0.3ms)[0m [1mINSERT INTO "schema_migrations" ("version") VALUES ('20110921112044')[0m
|
810
|
+
[1m[35m (125.0ms)[0m commit transaction
|
811
|
+
Connecting to database specified by database.yml
|
812
|
+
[1m[36m (1.9ms)[0m [1mselect sqlite_version(*)[0m
|
813
|
+
[1m[35m (131.5ms)[0m CREATE TABLE "article" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar(255) NOT NULL, "body" varchar(255), "created_at" datetime, "updated_at" datetime, "active" boolean DEFAULT 't')
|
814
|
+
[1m[36m (105.6ms)[0m [1mCREATE TABLE "topics" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar(255) NOT NULL, "created_at" datetime, "updated_at" datetime) [0m
|
815
|
+
[1m[35m (115.6ms)[0m CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
|
816
|
+
[1m[36m (116.2ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
817
|
+
[1m[35m (3.3ms)[0m SELECT "schema_migrations"."version" FROM "schema_migrations"
|
818
|
+
Migrating to CreateTranslations (20110921112044)
|
819
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
820
|
+
[1m[35m (0.3ms)[0m CREATE TABLE "translations" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "locale" varchar(255), "key" varchar(255), "value" text, "interpolations" text, "is_proc" boolean DEFAULT 'f', "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
|
821
|
+
[1m[36m (0.1ms)[0m [1mINSERT INTO "schema_migrations" ("version") VALUES ('20110921112044')[0m
|
822
|
+
[1m[35m (107.3ms)[0m commit transaction
|
data/spec/lib/keys_spec.rb
CHANGED
@@ -9,8 +9,27 @@ describe RailsI18nterface::Keys do
|
|
9
9
|
|
10
10
|
describe "to_a" do
|
11
11
|
it "extracts keys from I18n lookups in .rb, .html.erb, and .rhtml files" do
|
12
|
-
@keys.to_a.map(&:to_s).sort.should == [
|
13
|
-
|
12
|
+
@keys.to_a.map(&:to_s).sort.should == [
|
13
|
+
"activerecord.attributes.article.active",
|
14
|
+
"activerecord.attributes.article.body",
|
15
|
+
"activerecord.attributes.article.created_at",
|
16
|
+
"activerecord.attributes.article.title",
|
17
|
+
"activerecord.attributes.article.updated_at",
|
18
|
+
"activerecord.attributes.topics.created_at",
|
19
|
+
"activerecord.attributes.topics.title",
|
20
|
+
"activerecord.attributes.topics.updated_at",
|
21
|
+
"activerecord.models.article",
|
22
|
+
"activerecord.models.topics",
|
23
|
+
"article.key1",
|
24
|
+
"article.key2",
|
25
|
+
"article.key3",
|
26
|
+
"article.key4",
|
27
|
+
"article.key5",
|
28
|
+
"category_erb.key1",
|
29
|
+
"category_html_erb.key1",
|
30
|
+
"category_rhtml.key1",
|
31
|
+
"js.alert"
|
32
|
+
]
|
14
33
|
end
|
15
34
|
end
|
16
35
|
|
@@ -4,16 +4,16 @@ describe RailsI18nterface::Sourcefiles do
|
|
4
4
|
|
5
5
|
it "grabs field from schema.rb" do
|
6
6
|
expected = {
|
7
|
-
"activerecord.models.article"=>"db/schema.rb",
|
8
|
-
"activerecord.attributes.article.title"=>"db/schema.rb",
|
9
|
-
"activerecord.attributes.article.body"=>"db/schema.rb",
|
10
|
-
"activerecord.attributes.article.created_at"=>"db/schema.rb",
|
11
|
-
"activerecord.attributes.article.updated_at"=>"db/schema.rb",
|
12
|
-
"activerecord.attributes.article.active"=>"db/schema.rb",
|
13
|
-
"activerecord.models.topics"=>"db/schema.rb",
|
14
|
-
"activerecord.attributes.topics.title"=>"db/schema.rb",
|
15
|
-
"activerecord.attributes.topics.created_at"=>"db/schema.rb",
|
16
|
-
"activerecord.attributes.topics.updated_at"=>"db/schema.rb"
|
7
|
+
"activerecord.models.article"=>["db/schema.rb"],
|
8
|
+
"activerecord.attributes.article.title"=>["db/schema.rb"],
|
9
|
+
"activerecord.attributes.article.body"=>["db/schema.rb"],
|
10
|
+
"activerecord.attributes.article.created_at"=>["db/schema.rb"],
|
11
|
+
"activerecord.attributes.article.updated_at"=>["db/schema.rb"],
|
12
|
+
"activerecord.attributes.article.active"=>["db/schema.rb"],
|
13
|
+
"activerecord.models.topics"=>["db/schema.rb"],
|
14
|
+
"activerecord.attributes.topics.title"=>["db/schema.rb"],
|
15
|
+
"activerecord.attributes.topics.created_at"=>["db/schema.rb"],
|
16
|
+
"activerecord.attributes.topics.updated_at"=>["db/schema.rb"]
|
17
17
|
}
|
18
18
|
|
19
19
|
hash = RailsI18nterface::Sourcefiles.extract_activerecords
|