active_table 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,8 @@
1
1
  module ActiveTable
2
2
  class Base < ActiveRecord::Base
3
3
  @@insert_statements = []
4
+ @@table_list = []
5
+
4
6
  def self.active_table(&block)
5
7
  @table = {}
6
8
  block.call
@@ -20,6 +22,10 @@ module ActiveTable
20
22
  @table[:rows] << params
21
23
  end
22
24
 
25
+ def self.table_list
26
+ @@table_list
27
+ end
28
+
23
29
  def self.create_table!
24
30
  connection = ActiveRecord::Base.connection
25
31
  connection.execute "DROP TABLE IF EXISTS #{connection.quote_table_name(@table[:name])}"
@@ -29,6 +35,8 @@ module ActiveTable
29
35
  end
30
36
 
31
37
  @@insert_statements.reject!{|statement| statement[:table_name] == @table[:name]}
38
+ @@table_list << @table[:name] unless @@table_list.include?(@table[:name])
39
+
32
40
  @table[:rows].each do |row|
33
41
  insert_sql = generate_insert_sql_for_hash(connection, @table[:name], row)
34
42
  connection.execute insert_sql
@@ -1,3 +1,3 @@
1
1
  module ActiveTable
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -47,6 +47,29 @@ describe "a model created with active_table" do
47
47
  end
48
48
  end
49
49
 
50
+ context "#table_list" do
51
+ it "should return a list of tables under ActiveTable control" do
52
+ class AwesomeModel < ActiveTable::Base
53
+ active_table do
54
+ create_table :awesome_models do |t|
55
+ t.string :name
56
+ end
57
+ end
58
+ end
59
+
60
+ class MoreAwesomeModel < ActiveTable::Base
61
+ active_table do
62
+ create_table :more_awesome_models do |t|
63
+ t.string :title
64
+ end
65
+ end
66
+ end
67
+
68
+ ActiveTable::Base.table_list.should include(:awesome_models, :more_awesome_models)
69
+ ActiveTable::Base.table_list.count.should == 2
70
+ end
71
+ end
72
+
50
73
  context "#seed!" do
51
74
  it "should attempt to re-insert all rows" do
52
75
  class AwesomeModel < ActiveTable::Base
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_table
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -14,7 +14,7 @@ default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activerecord
17
- requirement: &2152706580 !ruby/object:Gem::Requirement
17
+ requirement: &2164666700 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -25,7 +25,7 @@ dependencies:
25
25
  version: 4.0.0
26
26
  type: :runtime
27
27
  prerelease: false
28
- version_requirements: *2152706580
28
+ version_requirements: *2164666700
29
29
  description: Dynamically-populated ActiveRecord models based on static data
30
30
  email:
31
31
  - casecommons-dev@googlegroups.com