look_up_table 0.1.0.rc8 → 0.1.0.rc9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (105) hide show
  1. data/lib/look_up_table/base.rb +155 -0
  2. data/lib/look_up_table/cache.rb +170 -0
  3. data/lib/look_up_table/method_missing.rb +22 -0
  4. data/lib/look_up_table/no_cache.rb +45 -0
  5. data/lib/look_up_table/version.rb +2 -1
  6. data/lib/look_up_table.rb +7 -268
  7. data/test/dummy/app/models/bar.rb +4 -0
  8. data/test/dummy/app/models/foo.rb +4 -0
  9. data/test/dummy/app/models/foobar.rb +9 -0
  10. data/test/dummy/config/database.yml +9 -14
  11. data/test/dummy/config/environments/test.rb +3 -0
  12. data/test/dummy/db/development.sqlite3 +0 -0
  13. data/test/dummy/db/migrate/20111024130333_create_foobars.rb +2 -1
  14. data/test/dummy/db/migrate/20111024130334_create_foos.rb +11 -0
  15. data/test/dummy/db/migrate/20111024130335_create_bars.rb +11 -0
  16. data/test/dummy/db/schema.rb +13 -1
  17. data/test/dummy/log/development.log +14 -0
  18. data/test/dummy/log/test.log +59 -0
  19. data/test/dummy/tmp/cache/3F4/570/Foobarid%2F0 +0 -0
  20. data/test/dummy/tmp/cache/3F5/580/Foobarid%2F1 +0 -0
  21. data/test/dummy/tmp/cache/45C/750/Foobarbar%2F0 +0 -0
  22. data/test/dummy/tmp/cache/45D/760/Foobarbar%2F1 +0 -0
  23. data/test/dummy/tmp/cache/45E/770/Foobarbar%2F2 +0 -0
  24. data/test/dummy/tmp/cache/45F/780/Foobarbar%2F3 +0 -0
  25. data/test/dummy/tmp/cache/460/790/Foobarbar%2F4 +0 -0
  26. data/test/dummy/tmp/cache/461/7A0/Foobarbar%2F5 +0 -0
  27. data/test/dummy/tmp/cache/462/7B0/Foobarbar%2F6 +0 -0
  28. data/test/dummy/tmp/cache/463/7C0/Foobarbar%2F7 +0 -0
  29. data/test/dummy/tmp/cache/464/7D0/Foobarbar%2F8 +0 -0
  30. data/test/dummy/tmp/cache/465/7E0/Foobarbar%2F9 +0 -0
  31. data/test/dummy/tmp/cache/46B/D60/Foobarfoo%2F0 +0 -0
  32. data/test/dummy/tmp/cache/46C/D70/Foobarfoo%2F1 +0 -0
  33. data/test/dummy/tmp/cache/46D/D80/Foobarfoo%2F2 +0 -0
  34. data/test/dummy/tmp/cache/46E/D90/Foobarfoo%2F3 +0 -0
  35. data/test/dummy/tmp/cache/46F/DA0/Foobarfoo%2F4 +0 -0
  36. data/test/dummy/tmp/cache/470/DB0/Foobarfoo%2F5 +0 -0
  37. data/test/dummy/tmp/cache/471/DC0/Foobarfoo%2F6 +0 -0
  38. data/test/dummy/tmp/cache/472/DD0/Foobarfoo%2F7 +0 -0
  39. data/test/dummy/tmp/cache/473/DE0/Foobarfoo%2F8 +0 -0
  40. data/test/dummy/tmp/cache/474/DF0/Foobarfoo%2F9 +0 -0
  41. data/test/dummy/tmp/cache/48D/030/Foobarbar%2F10 +0 -0
  42. data/test/dummy/tmp/cache/48E/040/Foobarbar%2F11 +0 -0
  43. data/test/dummy/tmp/cache/48E/050/Foobarbar%2F20 +0 -0
  44. data/test/dummy/tmp/cache/48F/050/Foobarbar%2F12 +0 -0
  45. data/test/dummy/tmp/cache/48F/060/Foobarbar%2F21 +0 -0
  46. data/test/dummy/tmp/cache/48F/070/Foobarbar%2F30 +0 -0
  47. data/test/dummy/tmp/cache/490/060/Foobarbar%2F13 +0 -0
  48. data/test/dummy/tmp/cache/490/070/Foobarbar%2F22 +0 -0
  49. data/test/dummy/tmp/cache/490/080/Foobarbar%2F31 +0 -0
  50. data/test/dummy/tmp/cache/490/090/Foobarbar%2F40 +0 -0
  51. data/test/dummy/tmp/cache/491/070/Foobarbar%2F14 +0 -0
  52. data/test/dummy/tmp/cache/491/080/Foobarbar%2F23 +0 -0
  53. data/test/dummy/tmp/cache/491/090/Foobarbar%2F32 +0 -0
  54. data/test/dummy/tmp/cache/491/0A0/Foobarbar%2F41 +0 -0
  55. data/test/dummy/tmp/cache/492/080/Foobarbar%2F15 +0 -0
  56. data/test/dummy/tmp/cache/492/090/Foobarbar%2F24 +0 -0
  57. data/test/dummy/tmp/cache/492/0A0/Foobarbar%2F33 +0 -0
  58. data/test/dummy/tmp/cache/493/090/Foobarbar%2F16 +0 -0
  59. data/test/dummy/tmp/cache/493/0A0/Foobarbar%2F25 +0 -0
  60. data/test/dummy/tmp/cache/493/0B0/Foobarbar%2F34 +0 -0
  61. data/test/dummy/tmp/cache/494/0A0/Foobarbar%2F17 +0 -0
  62. data/test/dummy/tmp/cache/494/0B0/Foobarbar%2F26 +0 -0
  63. data/test/dummy/tmp/cache/494/0C0/Foobarbar%2F35 +0 -0
  64. data/test/dummy/tmp/cache/495/0B0/Foobarbar%2F18 +0 -0
  65. data/test/dummy/tmp/cache/495/0C0/Foobarbar%2F27 +0 -0
  66. data/test/dummy/tmp/cache/495/0D0/Foobarbar%2F36 +0 -0
  67. data/test/dummy/tmp/cache/496/0C0/Foobarbar%2F19 +0 -0
  68. data/test/dummy/tmp/cache/496/0D0/Foobarbar%2F28 +0 -0
  69. data/test/dummy/tmp/cache/496/0E0/Foobarbar%2F37 +0 -0
  70. data/test/dummy/tmp/cache/497/0E0/Foobarbar%2F29 +0 -0
  71. data/test/dummy/tmp/cache/497/0F0/Foobarbar%2F38 +0 -0
  72. data/test/dummy/tmp/cache/498/100/Foobarbar%2F39 +0 -0
  73. data/test/dummy/tmp/cache/49C/730/Foobarfoo%2F10 +0 -0
  74. data/test/dummy/tmp/cache/49D/740/Foobarfoo%2F11 +0 -0
  75. data/test/dummy/tmp/cache/49D/750/Foobarfoo%2F20 +0 -0
  76. data/test/dummy/tmp/cache/49E/750/Foobarfoo%2F12 +0 -0
  77. data/test/dummy/tmp/cache/49E/760/Foobarfoo%2F21 +0 -0
  78. data/test/dummy/tmp/cache/49E/770/Foobarfoo%2F30 +0 -0
  79. data/test/dummy/tmp/cache/49F/760/Foobarfoo%2F13 +0 -0
  80. data/test/dummy/tmp/cache/49F/770/Foobarfoo%2F22 +0 -0
  81. data/test/dummy/tmp/cache/49F/780/Foobarfoo%2F31 +0 -0
  82. data/test/dummy/tmp/cache/49F/790/Foobarfoo%2F40 +0 -0
  83. data/test/dummy/tmp/cache/4A0/770/Foobarfoo%2F14 +0 -0
  84. data/test/dummy/tmp/cache/4A0/780/Foobarfoo%2F23 +0 -0
  85. data/test/dummy/tmp/cache/4A0/790/Foobarfoo%2F32 +0 -0
  86. data/test/dummy/tmp/cache/4A0/7A0/Foobarfoo%2F41 +0 -0
  87. data/test/dummy/tmp/cache/4A1/780/Foobarfoo%2F15 +0 -0
  88. data/test/dummy/tmp/cache/4A1/790/Foobarfoo%2F24 +0 -0
  89. data/test/dummy/tmp/cache/4A1/7A0/Foobarfoo%2F33 +0 -0
  90. data/test/dummy/tmp/cache/4A2/790/Foobarfoo%2F16 +0 -0
  91. data/test/dummy/tmp/cache/4A2/7A0/Foobarfoo%2F25 +0 -0
  92. data/test/dummy/tmp/cache/4A2/7B0/Foobarfoo%2F34 +0 -0
  93. data/test/dummy/tmp/cache/4A3/7A0/Foobarfoo%2F17 +0 -0
  94. data/test/dummy/tmp/cache/4A3/7B0/Foobarfoo%2F26 +0 -0
  95. data/test/dummy/tmp/cache/4A3/7C0/Foobarfoo%2F35 +0 -0
  96. data/test/dummy/tmp/cache/4A4/7B0/Foobarfoo%2F18 +0 -0
  97. data/test/dummy/tmp/cache/4A4/7C0/Foobarfoo%2F27 +0 -0
  98. data/test/dummy/tmp/cache/4A4/7D0/Foobarfoo%2F36 +0 -0
  99. data/test/dummy/tmp/cache/4A5/7C0/Foobarfoo%2F19 +0 -0
  100. data/test/dummy/tmp/cache/4A5/7D0/Foobarfoo%2F28 +0 -0
  101. data/test/dummy/tmp/cache/4A5/7E0/Foobarfoo%2F37 +0 -0
  102. data/test/dummy/tmp/cache/4A6/7E0/Foobarfoo%2F29 +0 -0
  103. data/test/dummy/tmp/cache/4A6/7F0/Foobarfoo%2F38 +0 -0
  104. data/test/dummy/tmp/cache/4A7/800/Foobarfoo%2F39 +0 -0
  105. metadata +191 -7
@@ -3,23 +3,18 @@
3
3
  #
4
4
  # Ensure the SQLite 3 gem is defined in your Gemfile
5
5
  # gem 'sqlite3'
6
- development:
7
- adapter: sqlite3
8
- database: db/development.sqlite3
9
- pool: 5
10
- timeout: 5000
6
+ database:
7
+ database: lookup_table_dev
8
+ adapter: postgresql
9
+ username: werbeboten
10
+ password: werbeboten
11
11
 
12
12
  # Warning: The database defined as "test" will be erased and
13
13
  # re-generated from your development database when you run "rake".
14
14
  # Do not set this db to the same as development or production.
15
15
  test:
16
- adapter: sqlite3
17
- database: db/test.sqlite3
18
- pool: 5
19
- timeout: 5000
16
+ database: lookup_table_test
17
+ adapter: postgresql
18
+ username: werbeboten
19
+ password: werbeboten
20
20
 
21
- production:
22
- adapter: sqlite3
23
- database: db/production.sqlite3
24
- pool: 5
25
- timeout: 5000
@@ -36,4 +36,7 @@ Dummy::Application.configure do
36
36
 
37
37
  # Print deprecation notices to the stderr
38
38
  config.active_support.deprecation = :stderr
39
+
40
+ config.cache_store = :mem_cache_store
39
41
  end
42
+
Binary file
@@ -1,10 +1,11 @@
1
1
  class CreateFoobars < ActiveRecord::Migration
2
2
  def change
3
3
  create_table :foobars do |t|
4
- t.string :foo
4
+ t.string :foo
5
5
  t.integer :bar
6
6
 
7
7
  t.timestamps
8
8
  end
9
9
  end
10
10
  end
11
+
@@ -0,0 +1,11 @@
1
+ class CreateFoos < ActiveRecord::Migration
2
+ def change
3
+ create_table :foos do |t|
4
+ t.string :foo
5
+ #t.integer :bar
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+ end
11
+
@@ -0,0 +1,11 @@
1
+ class CreateBars < ActiveRecord::Migration
2
+ def change
3
+ create_table :bars do |t|
4
+ #t.string :foo
5
+ t.integer :bar
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+ end
11
+
@@ -11,7 +11,13 @@
11
11
  #
12
12
  # It's strongly recommended to check this file into your version control system.
13
13
 
14
- ActiveRecord::Schema.define(:version => 20111024130333) do
14
+ ActiveRecord::Schema.define(:version => 20111024130335) do
15
+
16
+ create_table "bars", :force => true do |t|
17
+ t.integer "bar"
18
+ t.datetime "created_at"
19
+ t.datetime "updated_at"
20
+ end
15
21
 
16
22
  create_table "foobars", :force => true do |t|
17
23
  t.string "foo"
@@ -20,4 +26,10 @@ ActiveRecord::Schema.define(:version => 20111024130333) do
20
26
  t.datetime "updated_at"
21
27
  end
22
28
 
29
+ create_table "foos", :force => true do |t|
30
+ t.string "foo"
31
+ t.datetime "created_at"
32
+ t.datetime "updated_at"
33
+ end
34
+
23
35
  end
@@ -9,3 +9,17 @@ Migrating to CreateFoobars (20111024130333)
9
9
   (0.5ms) select sqlite_version(*)
10
10
   (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
11
11
   (0.0ms) PRAGMA index_list("foobars")
12
+  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
13
+ Migrating to CreateFoobars (20111024130333)
14
+ Migrating to CreateFoos (20111024130334)
15
+  (0.0ms) select sqlite_version(*)
16
+  (0.7ms) CREATE TABLE "foos" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "foo" varchar(255), "created_at" datetime, "updated_at" datetime) 
17
+  (0.3ms) INSERT INTO "schema_migrations" ("version") VALUES ('20111024130334')
18
+ Migrating to CreateBars (20111024130335)
19
+  (1.1ms) CREATE TABLE "bars" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "bar" integer, "created_at" datetime, "updated_at" datetime) 
20
+  (0.6ms) INSERT INTO "schema_migrations" ("version") VALUES ('20111024130335')
21
+  (0.3ms) select sqlite_version(*)
22
+  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations"
23
+  (0.0ms) PRAGMA index_list("bars")
24
+  (0.0ms) PRAGMA index_list("foobars")
25
+  (0.0ms) PRAGMA index_list("foos")
@@ -9,3 +9,62 @@ Migrating to CreateFoobars (20111024130333)
9
9
   (0.3ms) select sqlite_version(*)
10
10
   (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
11
11
   (0.1ms) PRAGMA index_list("foobars")
12
+  (28.7ms) CREATE TABLE "schema_migrations" ("version" character varying(255) NOT NULL) 
13
+  (0.3ms) SHOW search_path
14
+  (2.9ms)  SELECT distinct i.relname, d.indisunique, d.indkey, t.oid
15
+ FROM pg_class t
16
+ INNER JOIN pg_index d ON t.oid = d.indrelid
17
+ INNER JOIN pg_class i ON d.indexrelid = i.oid
18
+ WHERE i.relkind = 'i'
19
+ AND d.indisprimary = 'f'
20
+ AND t.relname = 'schema_migrations'
21
+ AND i.relnamespace IN (SELECT oid FROM pg_namespace WHERE nspname IN ('"$user"','public') )
22
+ ORDER BY i.relname
23
+ 
24
+  (73.5ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
25
+  (0.4ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
26
+ Migrating to CreateFoobars (20111024130333)
27
+  (0.1ms) BEGIN
28
+  (34.4ms) CREATE TABLE "foobars" ("id" serial primary key, "foo" character varying(255), "bar" integer, "created_at" timestamp, "updated_at" timestamp) 
29
+  (0.5ms) INSERT INTO "schema_migrations" ("version") VALUES ('20111024130333')
30
+  (15.0ms) COMMIT
31
+ Migrating to CreateFoos (20111024130334)
32
+  (0.8ms) BEGIN
33
+  (66.9ms) CREATE TABLE "foos" ("id" serial primary key, "foo" character varying(255), "created_at" timestamp, "updated_at" timestamp) 
34
+  (0.4ms) INSERT INTO "schema_migrations" ("version") VALUES ('20111024130334')
35
+  (15.0ms) COMMIT
36
+ Migrating to CreateBars (20111024130335)
37
+  (0.4ms) BEGIN
38
+  (86.8ms) CREATE TABLE "bars" ("id" serial primary key, "bar" integer, "created_at" timestamp, "updated_at" timestamp) 
39
+  (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES ('20111024130335')
40
+  (9.6ms) COMMIT
41
+  (0.3ms) SELECT "schema_migrations"."version" FROM "schema_migrations"
42
+  (0.4ms) SHOW search_path
43
+  (2.2ms) SELECT distinct i.relname, d.indisunique, d.indkey, t.oid
44
+ FROM pg_class t
45
+ INNER JOIN pg_index d ON t.oid = d.indrelid
46
+ INNER JOIN pg_class i ON d.indexrelid = i.oid
47
+ WHERE i.relkind = 'i'
48
+ AND d.indisprimary = 'f'
49
+ AND t.relname = 'bars'
50
+ AND i.relnamespace IN (SELECT oid FROM pg_namespace WHERE nspname IN ('"$user"','public') )
51
+ ORDER BY i.relname
52
+  (1.0ms)  SELECT distinct i.relname, d.indisunique, d.indkey, t.oid
53
+ FROM pg_class t
54
+ INNER JOIN pg_index d ON t.oid = d.indrelid
55
+ INNER JOIN pg_class i ON d.indexrelid = i.oid
56
+ WHERE i.relkind = 'i'
57
+ AND d.indisprimary = 'f'
58
+ AND t.relname = 'foobars'
59
+ AND i.relnamespace IN (SELECT oid FROM pg_namespace WHERE nspname IN ('"$user"','public') )
60
+ ORDER BY i.relname
61
+ 
62
+  (0.9ms) SELECT distinct i.relname, d.indisunique, d.indkey, t.oid
63
+ FROM pg_class t
64
+ INNER JOIN pg_index d ON t.oid = d.indrelid
65
+ INNER JOIN pg_class i ON d.indexrelid = i.oid
66
+ WHERE i.relkind = 'i'
67
+ AND d.indisprimary = 'f'
68
+ AND t.relname = 'foos'
69
+ AND i.relnamespace IN (SELECT oid FROM pg_namespace WHERE nspname IN ('"$user"','public') )
70
+ ORDER BY i.relname