databasion 0.0.9 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +10 -6
- data/Rakefile +1 -1
- data/config/example.google.yml +4 -1
- data/databasion.gemspec +2 -2
- data/lib/databasion/applcize.rb +4 -0
- data/lib/databasion/gitilize.rb +47 -0
- data/lib/databasion/googlize.rb +0 -1
- data/lib/databasion/svnilize.rb +3 -4
- data/lib/databasion/templates/migration.erb +4 -1
- data/lib/databasion.rb +7 -0
- metadata +4 -4
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
## Google Spreadsheet/Excel -> YAML -> Ruby Migration -> Database Management Tool
|
4
4
|
|
5
|
-
A database management tool. The theory is that a designer/planner can edit application data
|
5
|
+
A database management tool. The theory is that a designer/planner can edit application data and a programmer can setup the database and it's fields, all in one happy little place. As tables are added and data is changed, if the script is run once again it will update the target database.
|
6
6
|
|
7
7
|
TODO: While this system uses Rails Migrations, it isn't taking full advantage of them (i.e. tracking changes, allowing for rollbacks, etc.). This was also created under a high pressure timeline, so it was unfortunate that I could not create a fully working test suite.
|
8
8
|
|
@@ -102,14 +102,15 @@ Edit _config/google.yml_. Then run the scripts.
|
|
102
102
|
databasion --migrate
|
103
103
|
databasion --update
|
104
104
|
databasion --svn
|
105
|
+
databasion --git
|
105
106
|
|
106
107
|
Or run them all in order.
|
107
108
|
|
108
|
-
databasion --google --migrate --update --
|
109
|
+
databasion --google --migrate --update --git
|
109
110
|
|
110
111
|
You can supply a different config path as well.
|
111
112
|
|
112
|
-
databasion -g -m -u -
|
113
|
+
databasion -g -m -u -i --config config/my.other.config.yml
|
113
114
|
|
114
115
|
Someone administrating a production database with this tool would definitely want to run each script sequentially by hand.
|
115
116
|
|
@@ -121,16 +122,19 @@ Someone administrating a production database with this tool would definitely wan
|
|
121
122
|
* _sheets_: A list of the keys gleaned from the Google Docs URL, and a human readable name.
|
122
123
|
* _output_: Where to output the relevant data.
|
123
124
|
* _svn_: SVN configuration data.
|
125
|
+
* _git_: GIT configuration data.
|
124
126
|
|
125
127
|
## SVN
|
126
128
|
|
127
129
|
If the currently created databasion project is committed to SVN, running the _--svn_ switch will auto-add and commit all the project files. This is useful for maintaining version control of the system, especially if something goes wrong and you need to do a rollback.
|
128
130
|
|
129
|
-
##
|
131
|
+
## GIT
|
132
|
+
|
133
|
+
Much like SVN, if the project is commited to a GIT repo, the _--git_ switch will auto-add and commit all the project files. If there isn't a repository, it will also initialize a new one for you.
|
130
134
|
|
131
|
-
|
135
|
+
## Roadmap
|
132
136
|
|
133
|
-
|
137
|
+
Long and winding.
|
134
138
|
|
135
139
|
## Testing
|
136
140
|
|
data/Rakefile
CHANGED
@@ -8,7 +8,7 @@ Jeweler::Tasks.new do |gem|
|
|
8
8
|
gem.email = "mojobojo@gmail.com"
|
9
9
|
gem.homepage = "http://github.com/boj/databasion"
|
10
10
|
gem.authors = ["Brian Jones", "Istpika"]
|
11
|
-
gem.version = "0.0
|
11
|
+
gem.version = "0.1.0"
|
12
12
|
|
13
13
|
gem.add_dependency('activerecord', '>= 2.3.5')
|
14
14
|
gem.add_dependency('activesupport', '>= 2.3.5')
|
data/config/example.google.yml
CHANGED
data/databasion.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{databasion}
|
8
|
-
s.version = "0.0
|
8
|
+
s.version = "0.1.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Brian Jones", "Istpika"]
|
12
|
-
s.date = %q{2010-10-
|
12
|
+
s.date = %q{2010-10-28}
|
13
13
|
s.default_executable = %q{databasion}
|
14
14
|
s.email = %q{mojobojo@gmail.com}
|
15
15
|
s.executables = ["databasion"]
|
data/lib/databasion/applcize.rb
CHANGED
@@ -20,6 +20,7 @@ module Databasion
|
|
20
20
|
opt :migrate, "Migrate after Googlizing or Excelizing"
|
21
21
|
opt :update, "Load parsed YAML into migrated database"
|
22
22
|
opt :svn, "Auto commit the project files (assuming it has been committed to SVN)"
|
23
|
+
opt :git, "Auto commit the project files (assuming a working git repo)"
|
23
24
|
end
|
24
25
|
if opts[:config].nil? and opts[:create].nil?
|
25
26
|
config = "config/google.yml"
|
@@ -51,6 +52,9 @@ module Databasion
|
|
51
52
|
if opts[:svn]
|
52
53
|
Databasion.databate('svn', opts[:config])
|
53
54
|
end
|
55
|
+
if opts[:git]
|
56
|
+
Databasion.databate('git', opts[:config])
|
57
|
+
end
|
54
58
|
end
|
55
59
|
|
56
60
|
def self.create_project(opts)
|
data/lib/databasion/gitilize.rb
CHANGED
@@ -2,6 +2,53 @@ module Databasion
|
|
2
2
|
|
3
3
|
class Gitilize
|
4
4
|
|
5
|
+
@@config = nil
|
6
|
+
|
7
|
+
class GitilizeError < StandardError; end
|
8
|
+
|
9
|
+
def self.config=(config)
|
10
|
+
@@config = config
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.config
|
14
|
+
@@config
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.git_path
|
18
|
+
@@config['git']['bin']
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.commit(path=Dir.pwd)
|
22
|
+
raise GitilizeError, "A file lock is in place. Cannot commit." if check_lock?
|
23
|
+
create unless check_repo?
|
24
|
+
create_lock
|
25
|
+
Databasion::LOGGER.info 'running: git commit -am "databasion auto commit"'
|
26
|
+
system git_path + ' commit -am "databasion auto commit"'
|
27
|
+
remove_lock
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.create
|
31
|
+
Databasion::LOGGER.info 'creating new git repository'
|
32
|
+
Databasion::LOGGER.info 'running: git init'
|
33
|
+
system git_path + ' init'
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.check_repo?
|
37
|
+
File.exist?('.git') ? true : false
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.check_lock?
|
41
|
+
File.exist?('git.lock') ? true : false
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.create_lock
|
45
|
+
File.new('git.lock', 'w') unless check_lock?
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.remove_lock
|
49
|
+
FileUtils.rm 'git.lock'
|
50
|
+
end
|
51
|
+
|
5
52
|
end
|
6
53
|
|
7
54
|
end
|
data/lib/databasion/googlize.rb
CHANGED
@@ -60,7 +60,6 @@ module Databasion
|
|
60
60
|
next unless master_list.collect { |row| row['spreadsheet'] }.include?(worksheet.title)
|
61
61
|
data_hash = parse(worksheet)
|
62
62
|
data_hash['connection'] = master_list.collect { |row| row if row['spreadsheet'] == worksheet.title }.reject { |d| d.nil? }[0]
|
63
|
-
puts data_hash.inspect
|
64
63
|
Databasion::Yamalize.yamlbate(data_hash, @@config['output']['yaml_path'])
|
65
64
|
end
|
66
65
|
end
|
data/lib/databasion/svnilize.rb
CHANGED
@@ -24,8 +24,8 @@ module Databasion
|
|
24
24
|
raise SvnilizeError, "A file lock is in place. Cannot commit." if check_lock?
|
25
25
|
create_lock
|
26
26
|
svn_add_files(path)
|
27
|
-
Databasion::LOGGER.info 'running: svn commit -m "
|
28
|
-
system svn_path + ' commit -m "
|
27
|
+
Databasion::LOGGER.info 'running: svn commit -m "databasion auto commit"'
|
28
|
+
system svn_path + ' commit -m "databasion auto commit"'
|
29
29
|
Databasion::LOGGER.info 'running: svn update'
|
30
30
|
system svn_path + ' update'
|
31
31
|
remove_lock
|
@@ -40,8 +40,7 @@ module Databasion
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def self.check_lock?
|
43
|
-
|
44
|
-
false
|
43
|
+
File.exist?('svn.lock') ? true : false
|
45
44
|
end
|
46
45
|
|
47
46
|
def self.create_lock
|
@@ -2,9 +2,12 @@ class <%= class_name %>Migration < ActiveRecord::Migration
|
|
2
2
|
def self.up
|
3
3
|
create_table :<%= table_name %><%= ', :id => false' if fields.collect {|f| f['field']}.include?('id') %> do |t|
|
4
4
|
<% for field in fields %>
|
5
|
-
t.<%= field['type'] %> :<%= field['field'] %><%= ', :limit => %s' % field['size'] if field['size'] %><%=
|
5
|
+
t.<%= field['type'] %> :<%= field['field'] %><%= ', :limit => %s' % field['size'] if field['size'] %><%= "\n" %>
|
6
6
|
<% end %>
|
7
7
|
end
|
8
|
+
<% if fields.collect {|f| f['field']}.include?('id') %>
|
9
|
+
execute "ALTER TABLE <%= table_name %> ADD PRIMARY KEY (id)"
|
10
|
+
<% end %>
|
8
11
|
<% if indexes.size > 1 %>
|
9
12
|
add_index :<%= table_name %>, [<%= indexes.collect {|i| ":%s" % i }.join(",") %>]
|
10
13
|
<% elsif indexes.size == 1 %>
|
data/lib/databasion.rb
CHANGED
@@ -31,6 +31,8 @@ module Databasion
|
|
31
31
|
loadalize
|
32
32
|
when "svn"
|
33
33
|
svnilize
|
34
|
+
when "git"
|
35
|
+
gitilize
|
34
36
|
end
|
35
37
|
end
|
36
38
|
|
@@ -58,6 +60,11 @@ module Databasion
|
|
58
60
|
Databasion::Svnilize.config = @@config
|
59
61
|
Databasion::Svnilize.commit
|
60
62
|
end
|
63
|
+
|
64
|
+
def self.gitilize
|
65
|
+
Databasion::Gitilize.config = @@config
|
66
|
+
Databasion::Gitilize.commit
|
67
|
+
end
|
61
68
|
|
62
69
|
def self.set_ar_logger
|
63
70
|
ActiveRecord::Base.logger = Databasion::LOGGER
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: databasion
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
+
- 1
|
8
9
|
- 0
|
9
|
-
|
10
|
-
version: 0.0.9
|
10
|
+
version: 0.1.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Brian Jones
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2010-10-
|
19
|
+
date: 2010-10-28 00:00:00 +09:00
|
20
20
|
default_executable: databasion
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|