createDBTable 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/createDBTable.rb +66 -0
- metadata +43 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 044bada50b04d43aee65dbba1b1385ad350712ba
|
4
|
+
data.tar.gz: 1b3b11a2348d114194e97efb45ff12eaac0ae4e2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d2e6812195341f530ea5e0b741b764a58754bea4c5eb6a6b8863a39513614db336c44795ef1896d83aa71e8084c62972355e3520c441f2332ff77d6682b0b562
|
7
|
+
data.tar.gz: 672f05053545803e36dd5434988c8e874baaf90567e2b15b4ff3c213d24e3c6ed6788ee00593e701446f8d52c4061b242333eb2231dbd0bfec44088929387700
|
@@ -0,0 +1,66 @@
|
|
1
|
+
module CheckFields
|
2
|
+
|
3
|
+
def self.check(table)
|
4
|
+
if table.tablename == ''
|
5
|
+
result = false
|
6
|
+
elsif table.schema == ''
|
7
|
+
result = false
|
8
|
+
else
|
9
|
+
result = true
|
10
|
+
end
|
11
|
+
return result
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class RunRailsMigration
|
16
|
+
def initialize(tablename,schema)
|
17
|
+
@tablename=tablename
|
18
|
+
@schema=schema
|
19
|
+
end
|
20
|
+
protected
|
21
|
+
def runRailsMigration
|
22
|
+
begin
|
23
|
+
exit_status=system("rails generate model #{@tablename} #{@schema} >> log/NewVendorTable.log")
|
24
|
+
rescue Exception, NameError => nonerror
|
25
|
+
system('puts "Exception with Error" + nonerror >> log/NewVendorTable.log')
|
26
|
+
end
|
27
|
+
if exit_status.to_s == "true"
|
28
|
+
self.class.runDBMigrate
|
29
|
+
else
|
30
|
+
return false
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
private
|
37
|
+
def self.runDBMigrate
|
38
|
+
begin
|
39
|
+
exit_status=system('rake db:migrate >> log/NewVendorTable.log')
|
40
|
+
rescue Exception, NameError => nonerror
|
41
|
+
system('puts "Exception with Error" + nonerror >> log/NewVendorTable.log')
|
42
|
+
end
|
43
|
+
return exit_status.to_s
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
class CreateDBTable < RunRailsMigration
|
48
|
+
|
49
|
+
attr_reader :tablename, :schema
|
50
|
+
|
51
|
+
def initialize(tablename,schema)
|
52
|
+
super(tablename,schema)
|
53
|
+
@tablename=tablename
|
54
|
+
@schema=schema
|
55
|
+
end
|
56
|
+
|
57
|
+
def runMigrationProcess
|
58
|
+
if ((@tablename != '') && (@schema != ''))
|
59
|
+
self.runRailsMigration
|
60
|
+
else
|
61
|
+
return false
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
|
metadata
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: createDBTable
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Shiv
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-04-01 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Creates a table
|
14
|
+
email: shiv@gmail.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/createDBTable.rb
|
20
|
+
homepage: http://rubygems.org/gems/helloWorld
|
21
|
+
licenses: []
|
22
|
+
metadata: {}
|
23
|
+
post_install_message:
|
24
|
+
rdoc_options: []
|
25
|
+
require_paths:
|
26
|
+
- lib
|
27
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
28
|
+
requirements:
|
29
|
+
- - '>='
|
30
|
+
- !ruby/object:Gem::Version
|
31
|
+
version: '0'
|
32
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
33
|
+
requirements:
|
34
|
+
- - '>='
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '0'
|
37
|
+
requirements: []
|
38
|
+
rubyforge_project:
|
39
|
+
rubygems_version: 2.0.14
|
40
|
+
signing_key:
|
41
|
+
specification_version: 4
|
42
|
+
summary: create a database table with user defined fields
|
43
|
+
test_files: []
|