rails-i18nterface 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
- files.merge! self.extract_activerecords
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
@@ -1,3 +1,3 @@
1
1
  module RailsI18nterface
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
@@ -736,3 +736,87 @@ Migrating to CreateTranslations (20110921112044)
736
736
   (0.9ms) 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
   (0.3ms) INSERT INTO "schema_migrations" ("version") VALUES ('20110921112044')
738
738
   (108.7ms) commit transaction
739
+ Connecting to database specified by database.yml
740
+  (2.0ms) select sqlite_version(*)
741
+  (125.2ms) 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
+  (115.7ms) CREATE TABLE "topics" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar(255) NOT NULL, "created_at" datetime, "updated_at" datetime) 
743
+  (107.1ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
744
+  (108.5ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
745
+  (4.9ms) SELECT "schema_migrations"."version" FROM "schema_migrations"
746
+ Migrating to CreateTranslations (20110921112044)
747
+  (0.1ms) begin transaction
748
+  (0.3ms) 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
+  (0.1ms) INSERT INTO "schema_migrations" ("version") VALUES ('20110921112044')
750
+  (111.1ms) commit transaction
751
+ Connecting to database specified by database.yml
752
+  (1.8ms) select sqlite_version(*)
753
+  (113.6ms) 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
+  (97.4ms) CREATE TABLE "topics" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar(255) NOT NULL, "created_at" datetime, "updated_at" datetime) 
755
+  (107.3ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
756
+  (126.8ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
757
+  (5.0ms) SELECT "schema_migrations"."version" FROM "schema_migrations"
758
+ Migrating to CreateTranslations (20110921112044)
759
+  (0.1ms) begin transaction
760
+  (0.9ms) 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
+  (0.3ms) INSERT INTO "schema_migrations" ("version") VALUES ('20110921112044')
762
+  (123.5ms) commit transaction
763
+ Connecting to database specified by database.yml
764
+  (1.9ms) select sqlite_version(*)
765
+  (128.4ms) 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
+  (107.8ms) CREATE TABLE "topics" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar(255) NOT NULL, "created_at" datetime, "updated_at" datetime) 
767
+  (98.9ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
768
+  (99.5ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
769
+  (5.4ms) SELECT "schema_migrations"."version" FROM "schema_migrations"
770
+ Migrating to CreateTranslations (20110921112044)
771
+  (0.1ms) begin transaction
772
+  (0.7ms) 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
+  (0.1ms) INSERT INTO "schema_migrations" ("version") VALUES ('20110921112044')
774
+  (100.6ms) commit transaction
775
+ Connecting to database specified by database.yml
776
+  (1.8ms) select sqlite_version(*)
777
+  (117.4ms) 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
+  (91.1ms) CREATE TABLE "topics" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar(255) NOT NULL, "created_at" datetime, "updated_at" datetime) 
779
+  (90.7ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
780
+  (108.1ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
781
+  (5.0ms) SELECT "schema_migrations"."version" FROM "schema_migrations"
782
+ Migrating to CreateTranslations (20110921112044)
783
+  (0.1ms) begin transaction
784
+  (0.9ms) 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
+  (0.3ms) INSERT INTO "schema_migrations" ("version") VALUES ('20110921112044')
786
+  (116.3ms) commit transaction
787
+ Connecting to database specified by database.yml
788
+  (1.8ms) select sqlite_version(*)
789
+  (139.9ms) 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
+  (113.8ms) CREATE TABLE "topics" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar(255) NOT NULL, "created_at" datetime, "updated_at" datetime) 
791
+  (107.3ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
792
+  (116.1ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
793
+  (5.0ms) SELECT "schema_migrations"."version" FROM "schema_migrations"
794
+ Migrating to CreateTranslations (20110921112044)
795
+  (0.1ms) begin transaction
796
+  (0.9ms) 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
+  (0.3ms) INSERT INTO "schema_migrations" ("version") VALUES ('20110921112044')
798
+  (108.4ms) commit transaction
799
+ Connecting to database specified by database.yml
800
+  (1.8ms) select sqlite_version(*)
801
+  (102.1ms) 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
+  (97.4ms) CREATE TABLE "topics" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar(255) NOT NULL, "created_at" datetime, "updated_at" datetime) 
803
+  (98.9ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
804
+  (116.1ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
805
+  (5.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations"
806
+ Migrating to CreateTranslations (20110921112044)
807
+  (0.1ms) begin transaction
808
+  (0.9ms) 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
+  (0.3ms) INSERT INTO "schema_migrations" ("version") VALUES ('20110921112044')
810
+  (125.0ms) commit transaction
811
+ Connecting to database specified by database.yml
812
+  (1.9ms) select sqlite_version(*)
813
+  (131.5ms) 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
+  (105.6ms) CREATE TABLE "topics" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar(255) NOT NULL, "created_at" datetime, "updated_at" datetime) 
815
+  (115.6ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
816
+  (116.2ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
817
+  (3.3ms) SELECT "schema_migrations"."version" FROM "schema_migrations"
818
+ Migrating to CreateTranslations (20110921112044)
819
+  (0.0ms) begin transaction
820
+  (0.3ms) 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
+  (0.1ms) INSERT INTO "schema_migrations" ("version") VALUES ('20110921112044')
822
+  (107.3ms) commit transaction
@@ -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 == ['article.key1', 'article.key2', 'article.key3', 'article.key4', 'article.key5',
13
- 'category_erb.key1', 'category_html_erb.key1', 'category_rhtml.key1', 'js.alert']
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-i18nterface
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: