flying_table 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/flying_table/table_maker.rb +8 -3
- data/lib/flying_table/version.rb +1 -1
- data/test/flying_table_test.rb +8 -8
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7e97484463275a348c44a9b40ede2845072ddba0
|
4
|
+
data.tar.gz: 56758a6cda5c9f49f64847a5bfb6374ee6215ac4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed7ed4c08a2de5d6efdb26faf5cd169b1841ab1b4bf355c7ba8d5727f617f62a1b18df848e30dafc993d5d348370094d0bce064d35ca17cb7702cdf58e5cb52d
|
7
|
+
data.tar.gz: 99b62d601651783a23e027bfc0efaaff1921fb951cce272de702b07c367096b5bc1f06a10c582bb42113ce199a2a1fe5e4d1d10120679b4cc2f4873c4afb254b
|
@@ -2,15 +2,20 @@ class FlyingTable::TableMaker
|
|
2
2
|
def self.create(tables) new(tables).setup end
|
3
3
|
def self.destroy(tables) new(tables).teardown end
|
4
4
|
def initialize(tables)
|
5
|
-
@
|
5
|
+
@AR = ActiveRecord
|
6
|
+
@base = @AR::Base
|
7
|
+
@migration = @AR::Migration
|
6
8
|
@tables = tables
|
7
9
|
end
|
10
|
+
def setup() @base.transaction{@migration.suppress_messages{create_tables}} end
|
11
|
+
def teardown() @base.transaction{@migration.suppress_messages{drop_tables}} end
|
12
|
+
|
13
|
+
|
14
|
+
private
|
8
15
|
def create_columns(t,columns) columns.each{|name,type| t.send(type,name) } end
|
9
16
|
def create_tables() @tables.each{|table| seperate_table(table)} end
|
10
17
|
def drop_tables() @tables.each{|name| drop_table(name.to_s)} end
|
11
18
|
def seperate_table(table) table.each{|name,columns| create_table(name.to_s, columns)} end
|
12
|
-
def setup() @migration.suppress_messages{create_tables} end
|
13
|
-
def teardown() @migration.suppress_messages{drop_tables} end
|
14
19
|
|
15
20
|
def create_table(name,columns)
|
16
21
|
Object.const_set(name.classify, Class.new(ActiveRecord::Base))
|
data/lib/flying_table/version.rb
CHANGED
data/test/flying_table_test.rb
CHANGED
@@ -12,17 +12,17 @@ class FuzzyRecordTest < TestCase
|
|
12
12
|
assert_raises(NameError) {Example.new(name: 'John', created: Date.today)}
|
13
13
|
end
|
14
14
|
def test_creates_tables
|
15
|
-
FlyingTable.create(
|
16
|
-
example =
|
17
|
-
example2 =
|
15
|
+
FlyingTable.create(table: {name: :string}, fable: {created: :date})
|
16
|
+
example = Table.new(name: 'John')
|
17
|
+
example2 = Fable.new(created: Date.today)
|
18
18
|
assert_equal true, example.save!
|
19
19
|
assert_equal true, example2.save!
|
20
|
-
FlyingTable.destroy(:
|
20
|
+
FlyingTable.destroy(:table,:fable)
|
21
21
|
end
|
22
22
|
def test_destroys_tables
|
23
|
-
FlyingTable.create(
|
24
|
-
FlyingTable.destroy(:
|
25
|
-
assert_raises(NameError) {
|
26
|
-
assert_raises(NameError) {
|
23
|
+
FlyingTable.create(elbat: {name: :string}, elbaf: {created: :date})
|
24
|
+
FlyingTable.destroy(:elbat, :elbaf)
|
25
|
+
assert_raises(NameError) {Elbat.new()}
|
26
|
+
assert_raises(NameError) {Elbaf.new()}
|
27
27
|
end
|
28
28
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flying_table
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Moody
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-05-
|
12
|
+
date: 2015-05-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|