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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9fdcb6771bc79a70905fe0d41d65f23017df6387
4
- data.tar.gz: dc45fafe7f604d3d137b5c6964b85851bf750af6
3
+ metadata.gz: 7e97484463275a348c44a9b40ede2845072ddba0
4
+ data.tar.gz: 56758a6cda5c9f49f64847a5bfb6374ee6215ac4
5
5
  SHA512:
6
- metadata.gz: 97f0444b7a9a0d5eacbe3ae6fe44222491a0b4387bce8ca8b178782622f45534febf970615464ef035705e48430af2578aefc6a8e39de013ec5d3ba69e9cedea
7
- data.tar.gz: 5b64963f19b9f4c48405fed0ed3632d4479a2fb9e789da340d53f22d2e167d088d83816843f939ab81ed763a7234f4a2e291220d7268cdd4e2245b9b9c31e10e
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
- @migration = ActiveRecord::Migration
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))
@@ -1,3 +1,3 @@
1
1
  module FlyingTable
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -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(example: {name: :string}, example2: {created: :date})
16
- example = Example.new(name: 'John')
17
- example2 = Example2.new(created: Date.today)
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(:example,:example2)
20
+ FlyingTable.destroy(:table,:fable)
21
21
  end
22
22
  def test_destroys_tables
23
- FlyingTable.create(example: {name: :string}, example2: {created: :date})
24
- FlyingTable.destroy(:example, :example2)
25
- assert_raises(NameError) {Example.new()}
26
- assert_raises(NameError) {Example2.new()}
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.1
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-14 00:00:00.000000000 Z
12
+ date: 2015-05-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails