flying_table 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9fdcb6771bc79a70905fe0d41d65f23017df6387
4
+ data.tar.gz: dc45fafe7f604d3d137b5c6964b85851bf750af6
5
+ SHA512:
6
+ metadata.gz: 97f0444b7a9a0d5eacbe3ae6fe44222491a0b4387bce8ca8b178782622f45534febf970615464ef035705e48430af2578aefc6a8e39de013ec5d3ba69e9cedea
7
+ data.tar.gz: 5b64963f19b9f4c48405fed0ed3632d4479a2fb9e789da340d53f22d2e167d088d83816843f939ab81ed763a7234f4a2e291220d7268cdd4e2245b9b9c31e10e
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in flying_table.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Chris Moody
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,61 @@
1
+ # FlyingTable
2
+
3
+ Create and destroy tables on the fly.
4
+ Quickly build up and teardown tables with class.
5
+ Primarily for testing purposes.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'flying_table'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install flying_table
22
+
23
+ ## Usage
24
+
25
+ In your tests to create a table with class name Example fields name: :string and created: :date
26
+
27
+ ```ruby
28
+ $ FlyingTable.create(example: {name: :string, created: :date})
29
+ ```
30
+
31
+ To create multiple tables:
32
+
33
+ ```ruby
34
+ $ FlyingTable.create(example: {name: :string}, example2: {created: :date})
35
+ ```
36
+
37
+ To destroy tables
38
+
39
+ ```ruby
40
+ $ FlyingTable.destroy(:example,:example2)
41
+ ```
42
+
43
+
44
+ ## Contributing
45
+
46
+ 1. Fork it ( https://github.com/[my-github-username]/flying_table/fork )
47
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
48
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
49
+ 4. Push to the branch (`git push origin my-new-feature`)
50
+ 5. Create a new Pull Request
51
+
52
+ Author
53
+ -------
54
+
55
+ * Chris Moody
56
+ * Ian Snyder
57
+
58
+ License
59
+ -------
60
+
61
+ This is free software released into the public domain.
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new do |t|
5
+ t.libs << 'test'
6
+ t.pattern = "test/*_test.rb"
7
+ end
8
+
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'flying_table/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "flying_table"
8
+ spec.version = FlyingTable::VERSION
9
+ spec.authors = ["Chris Moody", "Ian Snyder"]
10
+ spec.email = ["cmoody@transcon.com"]
11
+ spec.summary = %q{Table and class maker primarily for testing}
12
+ spec.homepage = "https://github.com/transcon/flying_table"
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_dependency "rails"
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.7"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_development_dependency 'minitest'
25
+ spec.add_development_dependency 'awesome_print'
26
+ spec.add_development_dependency 'minitest-reporters', '>= 1.0.1'
27
+ spec.add_development_dependency 'sqlite3'
28
+ end
@@ -0,0 +1,23 @@
1
+ class FlyingTable::TableMaker
2
+ def self.create(tables) new(tables).setup end
3
+ def self.destroy(tables) new(tables).teardown end
4
+ def initialize(tables)
5
+ @migration = ActiveRecord::Migration
6
+ @tables = tables
7
+ end
8
+ def create_columns(t,columns) columns.each{|name,type| t.send(type,name) } end
9
+ def create_tables() @tables.each{|table| seperate_table(table)} end
10
+ def drop_tables() @tables.each{|name| drop_table(name.to_s)} end
11
+ 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
+
15
+ def create_table(name,columns)
16
+ Object.const_set(name.classify, Class.new(ActiveRecord::Base))
17
+ @migration.create_table(name.pluralize){ |t| create_columns(t,columns)}
18
+ end
19
+ def drop_table(name)
20
+ Object.send(:remove_const, name.classify)
21
+ @migration.drop_table(name.pluralize)
22
+ end
23
+ end
@@ -0,0 +1,3 @@
1
+ module FlyingTable
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,8 @@
1
+ require "flying_table/version"
2
+ require "flying_table/table_maker"
3
+ require "active_record"
4
+
5
+ module FlyingTable
6
+ def self.create(*args) TableMaker.create(args) end
7
+ def self.destroy(*args) TableMaker.destroy(args) end
8
+ end
@@ -0,0 +1,28 @@
1
+ require "test_helper"
2
+ class FuzzyRecordTest < TestCase
3
+ def test_creates_table
4
+ FlyingTable.create(example: {name: :string, created: :date})
5
+ example = Example.new(name: 'John', created: Date.today)
6
+ assert_equal true, example.save!
7
+ FlyingTable.destroy(:example)
8
+ end
9
+ def test_destroys_table
10
+ FlyingTable.create(example: {name: :string, created: :date})
11
+ FlyingTable.destroy(:example)
12
+ assert_raises(NameError) {Example.new(name: 'John', created: Date.today)}
13
+ end
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)
18
+ assert_equal true, example.save!
19
+ assert_equal true, example2.save!
20
+ FlyingTable.destroy(:example,:example2)
21
+ end
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()}
27
+ end
28
+ end
@@ -0,0 +1,10 @@
1
+ require 'minitest/autorun'
2
+ require 'flying_table'
3
+ require 'minitest/reporters'
4
+
5
+ ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => ":memory:")
6
+
7
+ Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new
8
+
9
+ class TestCase < MiniTest::Test
10
+ end
metadata ADDED
@@ -0,0 +1,156 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: flying_table
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Chris Moody
8
+ - Ian Snyder
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2015-05-14 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rails
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ">="
19
+ - !ruby/object:Gem::Version
20
+ version: '0'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ version: '0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: bundler
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '1.7'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '1.7'
42
+ - !ruby/object:Gem::Dependency
43
+ name: rake
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: '10.0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '10.0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: minitest
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ - !ruby/object:Gem::Dependency
71
+ name: awesome_print
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ - !ruby/object:Gem::Dependency
85
+ name: minitest-reporters
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: 1.0.1
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: 1.0.1
98
+ - !ruby/object:Gem::Dependency
99
+ name: sqlite3
100
+ requirement: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ type: :development
106
+ prerelease: false
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ description:
113
+ email:
114
+ - cmoody@transcon.com
115
+ executables: []
116
+ extensions: []
117
+ extra_rdoc_files: []
118
+ files:
119
+ - ".gitignore"
120
+ - Gemfile
121
+ - LICENSE.txt
122
+ - README.md
123
+ - Rakefile
124
+ - flying_table.gemspec
125
+ - lib/flying_table.rb
126
+ - lib/flying_table/table_maker.rb
127
+ - lib/flying_table/version.rb
128
+ - test/flying_table_test.rb
129
+ - test/test_helper.rb
130
+ homepage: https://github.com/transcon/flying_table
131
+ licenses:
132
+ - MIT
133
+ metadata: {}
134
+ post_install_message:
135
+ rdoc_options: []
136
+ require_paths:
137
+ - lib
138
+ required_ruby_version: !ruby/object:Gem::Requirement
139
+ requirements:
140
+ - - ">="
141
+ - !ruby/object:Gem::Version
142
+ version: '0'
143
+ required_rubygems_version: !ruby/object:Gem::Requirement
144
+ requirements:
145
+ - - ">="
146
+ - !ruby/object:Gem::Version
147
+ version: '0'
148
+ requirements: []
149
+ rubyforge_project:
150
+ rubygems_version: 2.4.3
151
+ signing_key:
152
+ specification_version: 4
153
+ summary: Table and class maker primarily for testing
154
+ test_files:
155
+ - test/flying_table_test.rb
156
+ - test/test_helper.rb