databasion 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +24 -5
- data/Rakefile +1 -1
- data/bin/databasion +1 -1
- data/config/example.google.yml +6 -0
- data/databasion.gemspec +22 -22
- data/features/build_migration.feature +8 -0
- data/features/create_project.feature +8 -0
- data/features/cron_system.feature +7 -0
- data/features/env/helper_methods.rb +12 -0
- data/features/google_loader.feature +8 -0
- data/features/step_definitions/build_migration_steps.rb +22 -0
- data/features/step_definitions/create_project_steps.rb +13 -0
- data/features/step_definitions/cron_system_steps.rb +17 -0
- data/features/step_definitions/google_loader_steps.rb +14 -0
- data/features/step_definitions/yaml_builder_steps.rb +16 -0
- data/features/{databasion/migitize.feature → yaml_builder.feature} +1 -1
- data/lib/databasion.rb +37 -37
- data/lib/databasion/{applcize.rb → application.rb} +15 -10
- data/lib/databasion/{migitize.rb → build_migration.rb} +8 -7
- data/lib/databasion/cron_system.rb +53 -0
- data/lib/databasion/{gitilize.rb → git_committer.rb} +4 -3
- data/lib/databasion/{googlize.rb → google_loader.rb} +58 -18
- data/lib/databasion/{loadlize.rb → load_data.rb} +2 -2
- data/lib/databasion/{datacize.rb → migrate.rb} +3 -3
- data/lib/databasion/{svnilize.rb → svn_committer.rb} +3 -3
- data/lib/databasion/{yamalize.rb → yaml_builder.rb} +4 -4
- data/lib/tasks/databasion.rake +11 -6
- metadata +24 -24
- data/features/databasion.feature +0 -23
- data/features/databasion/googlize.feature +0 -13
- data/features/databasion/step_definitions/googlize_steps.rb +0 -32
- data/features/databasion/step_definitions/migitize_steps.rb +0 -26
- data/features/databasion/step_definitions/svnilize_steps.rb +0 -14
- data/features/databasion/step_definitions/yamalize_steps.rb +0 -29
- data/features/databasion/svnilize.feature +0 -8
- data/features/databasion/yamalize.feature +0 -9
- data/features/step_definitions/databasion_steps.rb +0 -35
- data/lib/databasion/csvilize.rb +0 -11
- data/lib/databasion/excelize.rb +0 -11
data/README.md
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
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
|
-
TODO: While this system uses Rails Migrations, it isn't taking full advantage of them (i.e. tracking changes, allowing for rollbacks, etc
|
7
|
+
TODO: While this system uses Rails Migrations, it isn't taking full advantage of them (i.e. tracking changes, allowing for rollbacks, etc).
|
8
8
|
|
9
9
|
## Requirements
|
10
10
|
|
@@ -100,17 +100,17 @@ Edit _config/google.yml_. Then run the scripts.
|
|
100
100
|
|
101
101
|
databasion --google
|
102
102
|
databasion --migrate
|
103
|
-
databasion --
|
103
|
+
databasion --load
|
104
104
|
databasion --svn
|
105
105
|
databasion --git
|
106
106
|
|
107
107
|
Or run them all in order.
|
108
108
|
|
109
|
-
databasion --google --migrate --
|
109
|
+
databasion --google --migrate --load --git
|
110
110
|
|
111
111
|
You can supply a different config path as well.
|
112
112
|
|
113
|
-
databasion -g -m -
|
113
|
+
databasion -g -m -l -i --config config/my.other.config.yml
|
114
114
|
|
115
115
|
Someone administrating a production database with this tool would definitely want to run each script sequentially by hand.
|
116
116
|
|
@@ -123,6 +123,7 @@ Someone administrating a production database with this tool would definitely wan
|
|
123
123
|
* _output_: Where to output the relevant data.
|
124
124
|
* _svn_: SVN configuration data.
|
125
125
|
* _git_: GIT configuration data.
|
126
|
+
* _cron_: Crontab parameters.
|
126
127
|
|
127
128
|
## SVN
|
128
129
|
|
@@ -132,13 +133,31 @@ If the currently created databasion project is committed to SVN, running the _--
|
|
132
133
|
|
133
134
|
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.
|
134
135
|
|
136
|
+
## Version Control
|
137
|
+
|
138
|
+
There is now a system in place to do crontab driven auto-updates. This allows the data to be updated without anyone having to access any systems.
|
139
|
+
|
140
|
+
First update _config/google.yml_'s cron section to reflect your project settings. The _options_ are your standard databasion switches. Make sure to supply a location for the version file so that it can be read at a later date.
|
141
|
+
|
142
|
+
Next, add a _Version_ spreadsheet to the master worksheet. In the A1 field use whichever number works best to start versioning with. When using this to manage the project, if the number is higher than before then the system will be updated. Currently version controlled rollbacks are not implemented.
|
143
|
+
|
144
|
+
Finally, add the databasion script to crontab.
|
145
|
+
|
146
|
+
Example crontab:
|
147
|
+
|
148
|
+
*/1 * * * * cd /home/my_user/project && databasion -r
|
149
|
+
|
150
|
+
This checks the Version spreadsheet once a minute, and if the version has changed runs databasion with the supplied options.
|
151
|
+
|
152
|
+
Note: This could easily be used from the commandline as well, and not just crontab.
|
153
|
+
|
135
154
|
## Roadmap
|
136
155
|
|
137
156
|
Long and winding.
|
138
157
|
|
139
158
|
## Testing
|
140
159
|
|
141
|
-
Currently Databasion uses the cucumber test suite.
|
160
|
+
Currently Databasion uses the cucumber test suite. A functional set of rudimentary tests are currently available, but it does not test everything 100%.
|
142
161
|
|
143
162
|
## Author
|
144
163
|
|
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.1.
|
11
|
+
gem.version = "0.1.1"
|
12
12
|
|
13
13
|
gem.add_dependency('activerecord', '>= 2.3.5')
|
14
14
|
gem.add_dependency('activesupport', '>= 2.3.5')
|
data/bin/databasion
CHANGED
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.1.
|
8
|
+
s.version = "0.1.1"
|
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-
|
12
|
+
s.date = %q{2010-11-04}
|
13
13
|
s.default_executable = %q{databasion}
|
14
14
|
s.email = %q{mojobojo@gmail.com}
|
15
15
|
s.executables = ["databasion"]
|
@@ -24,29 +24,29 @@ Gem::Specification.new do |s|
|
|
24
24
|
"bin/databasion",
|
25
25
|
"config/example.google.yml",
|
26
26
|
"databasion.gemspec",
|
27
|
-
"features/
|
28
|
-
"features/
|
29
|
-
"features/
|
30
|
-
"features/
|
31
|
-
"features/
|
32
|
-
"features/
|
33
|
-
"features/
|
34
|
-
"features/
|
35
|
-
"features/
|
36
|
-
"features/step_definitions/
|
27
|
+
"features/build_migration.feature",
|
28
|
+
"features/create_project.feature",
|
29
|
+
"features/cron_system.feature",
|
30
|
+
"features/env/helper_methods.rb",
|
31
|
+
"features/google_loader.feature",
|
32
|
+
"features/step_definitions/build_migration_steps.rb",
|
33
|
+
"features/step_definitions/create_project_steps.rb",
|
34
|
+
"features/step_definitions/cron_system_steps.rb",
|
35
|
+
"features/step_definitions/google_loader_steps.rb",
|
36
|
+
"features/step_definitions/yaml_builder_steps.rb",
|
37
|
+
"features/yaml_builder.feature",
|
37
38
|
"lib/databasion.rb",
|
38
|
-
"lib/databasion/
|
39
|
-
"lib/databasion/
|
40
|
-
"lib/databasion/
|
41
|
-
"lib/databasion/
|
42
|
-
"lib/databasion/
|
43
|
-
"lib/databasion/
|
44
|
-
"lib/databasion/
|
45
|
-
"lib/databasion/
|
46
|
-
"lib/databasion/svnilize.rb",
|
39
|
+
"lib/databasion/application.rb",
|
40
|
+
"lib/databasion/build_migration.rb",
|
41
|
+
"lib/databasion/cron_system.rb",
|
42
|
+
"lib/databasion/git_committer.rb",
|
43
|
+
"lib/databasion/google_loader.rb",
|
44
|
+
"lib/databasion/load_data.rb",
|
45
|
+
"lib/databasion/migrate.rb",
|
46
|
+
"lib/databasion/svn_committer.rb",
|
47
47
|
"lib/databasion/templates/migration.erb",
|
48
48
|
"lib/databasion/templates/model.erb",
|
49
|
-
"lib/databasion/
|
49
|
+
"lib/databasion/yaml_builder.rb",
|
50
50
|
"lib/migration_helpers/MIT-LICENSE",
|
51
51
|
"lib/migration_helpers/README.markdown",
|
52
52
|
"lib/migration_helpers/init.rb",
|
@@ -0,0 +1,8 @@
|
|
1
|
+
Feature: Create Project
|
2
|
+
In order to run databasion
|
3
|
+
A project directory should be built
|
4
|
+
|
5
|
+
Scenario: User runs databasion with the --create command
|
6
|
+
Given a project named test_project
|
7
|
+
When the databasion create command is ran
|
8
|
+
Then a project folder and config file should exist
|
@@ -0,0 +1,12 @@
|
|
1
|
+
def load_parse_data
|
2
|
+
{
|
3
|
+
'name' => 'mock',
|
4
|
+
'plural' => true,
|
5
|
+
'indexes' => ["id"],
|
6
|
+
'fields' => ["id", "name", "power"],
|
7
|
+
'types' => ["integer", "string, 20", "string, 40"],
|
8
|
+
'data' => [[1, "Brian Jones", "Super Intelligence"], [2, "Superman", "Invincible"], [3, "Batman", "Strength"]],
|
9
|
+
'ignore_cols' => [2],
|
10
|
+
'connection' => {'database' => 'moon', 'dbname' => 'db1'}
|
11
|
+
}
|
12
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'lib/databasion'
|
2
|
+
|
3
|
+
Given /a set of YAML data/ do
|
4
|
+
@config = YAML.load(File.open('config/google.yml'))
|
5
|
+
|
6
|
+
@parse_data = load_parse_data
|
7
|
+
Databasion::YamlBuilder.run(@parse_data, @config['output']['yaml_path'])
|
8
|
+
end
|
9
|
+
|
10
|
+
When /we run the BuildMigration system/ do
|
11
|
+
Databasion::BuildMigration.run(Dir['%s/**.yml' % @config['output']['yaml_path']], @config)
|
12
|
+
end
|
13
|
+
|
14
|
+
Then /it should build a migration, model, and database file/ do
|
15
|
+
File.exist?('%s/%s/100_%s_migration.rb' % [@config['output']['migrations']['path'], @parse_data['connection']['dbname'], @parse_data['name']]).should == true
|
16
|
+
File.exist?('%s/%s.rb' % [@config['output']['migrations']['models'], @parse_data['name']]).should == true
|
17
|
+
File.exist?('config/database.yml').should == true
|
18
|
+
FileUtils.rm_rf @config['output']['migrations']['path']
|
19
|
+
FileUtils.rm_rf @config['output']['migrations']['models']
|
20
|
+
FileUtils.rm_rf @config['output']['yaml_path']
|
21
|
+
FileUtils.rm 'config/database.yml'
|
22
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
Given /a project named (.*)/ do |project_name|
|
2
|
+
@project = project_name
|
3
|
+
end
|
4
|
+
|
5
|
+
When /the databasion create command is ran/ do
|
6
|
+
system 'bin/databasion -c %s' % @project
|
7
|
+
end
|
8
|
+
|
9
|
+
Then /a project folder and config file should exist/ do
|
10
|
+
File.exists?('%s' % @project).should == true
|
11
|
+
File.exists?('%s/config/google.yml' % @project).should == true
|
12
|
+
FileUtils.rm_rf '%s/' % @project
|
13
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'lib/databasion'
|
2
|
+
|
3
|
+
Given /a version spreadsheet in Google Docs/ do
|
4
|
+
@config = YAML.load(File.open('config/google.yml'))
|
5
|
+
end
|
6
|
+
|
7
|
+
When /the cron system is ran and the version changes/ do
|
8
|
+
Databasion::CronSystem.config = @config
|
9
|
+
Databasion::CronSystem.run
|
10
|
+
end
|
11
|
+
|
12
|
+
Then /databasion should have been ran/ do
|
13
|
+
Databasion::GoogleLoader.config = @config
|
14
|
+
version = Databasion::GoogleLoader.run_version
|
15
|
+
File.open(@config['cron']['version']['file']).readline.strip.should == version
|
16
|
+
FileUtils.rm_rf @config['cron']['version']['file']
|
17
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'lib/databasion'
|
2
|
+
|
3
|
+
Given /a google account from the yaml config/ do
|
4
|
+
@config = YAML.load(File.open('config/google.yml'))
|
5
|
+
end
|
6
|
+
|
7
|
+
When /GoogleLoader logs in/ do
|
8
|
+
Databasion::GoogleLoader.config = @config
|
9
|
+
Databasion::GoogleLoader.login
|
10
|
+
end
|
11
|
+
|
12
|
+
Then /we should have a GoogleSpreadsheet session/ do
|
13
|
+
Databasion::GoogleLoader.session.should be_kind_of(GoogleSpreadsheet::Session)
|
14
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'lib/databasion'
|
2
|
+
|
3
|
+
Given /a complete set of YAML definitions/ do
|
4
|
+
@config = YAML.load(File.open('config/google.yml'))
|
5
|
+
|
6
|
+
@parse_data = load_parse_data
|
7
|
+
end
|
8
|
+
|
9
|
+
When /the YAML files are parsed/ do
|
10
|
+
Databasion::YamlBuilder.run(@parse_data, @config['output']['yaml_path'])
|
11
|
+
end
|
12
|
+
|
13
|
+
Then /the result is Ruby migration files/ do
|
14
|
+
File.exist?("%s/%s.yml" % [@config['output']['yaml_path'], @parse_data['name']]).should == true
|
15
|
+
FileUtils.rm_rf @config['output']['yaml_path']
|
16
|
+
end
|
data/lib/databasion.rb
CHANGED
@@ -14,7 +14,7 @@ module Databasion
|
|
14
14
|
|
15
15
|
@@config = nil
|
16
16
|
|
17
|
-
def self.
|
17
|
+
def self.run(system, config=nil, opts=nil)
|
18
18
|
LOGGER.level = Logger::INFO
|
19
19
|
|
20
20
|
raise DatabasionError, 'Databasion requires a YAML config file path.' if config.nil?
|
@@ -22,63 +22,63 @@ module Databasion
|
|
22
22
|
|
23
23
|
case system
|
24
24
|
when "google"
|
25
|
-
|
26
|
-
when "excel"
|
27
|
-
excelize
|
25
|
+
run_google
|
28
26
|
when "migrate"
|
29
|
-
|
30
|
-
when "
|
31
|
-
|
27
|
+
run_migrate
|
28
|
+
when "load"
|
29
|
+
run_load(opts)
|
32
30
|
when "svn"
|
33
|
-
|
31
|
+
run_svn
|
34
32
|
when "git"
|
35
|
-
|
33
|
+
run_git
|
34
|
+
when "cron"
|
35
|
+
run_cron
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
39
|
private
|
40
|
-
def self.
|
41
|
-
Databasion::
|
42
|
-
Databasion::
|
40
|
+
def self.run_google
|
41
|
+
Databasion::GoogleLoader.config = @@config
|
42
|
+
Databasion::GoogleLoader.run
|
43
43
|
end
|
44
|
-
|
45
|
-
def self.
|
46
|
-
Databasion::
|
44
|
+
|
45
|
+
def self.run_migrate
|
46
|
+
Databasion::Migrate.config = @@config
|
47
|
+
Databasion::Migrate.run
|
47
48
|
end
|
48
49
|
|
49
|
-
def self.
|
50
|
-
Databasion::
|
51
|
-
Databasion::
|
50
|
+
def self.run_load(opts)
|
51
|
+
Databasion::LoadData.config = @@config
|
52
|
+
Databasion::LoadData.run(opts)
|
52
53
|
end
|
53
54
|
|
54
|
-
def self.
|
55
|
-
Databasion::
|
56
|
-
Databasion::
|
55
|
+
def self.run_svn
|
56
|
+
Databasion::SvnCommitter.config = @@config
|
57
|
+
Databasion::SvnCommitter.commit
|
57
58
|
end
|
58
59
|
|
59
|
-
def self.
|
60
|
-
Databasion::
|
61
|
-
Databasion::
|
60
|
+
def self.run_git
|
61
|
+
Databasion::GitCommitter.config = @@config
|
62
|
+
Databasion::GitCommitter.commit
|
62
63
|
end
|
63
64
|
|
64
|
-
def self.
|
65
|
-
Databasion::
|
66
|
-
Databasion::
|
65
|
+
def self.run_cron
|
66
|
+
Databasion::CronSystem.config = @@config
|
67
|
+
Databasion::CronSystem.run
|
67
68
|
end
|
68
69
|
|
69
70
|
def self.set_ar_logger
|
70
71
|
ActiveRecord::Base.logger = Databasion::LOGGER
|
71
72
|
end
|
72
73
|
|
73
|
-
autoload :
|
74
|
-
autoload :
|
75
|
-
autoload :
|
76
|
-
autoload :
|
77
|
-
autoload :
|
78
|
-
autoload :
|
79
|
-
autoload :
|
80
|
-
autoload :
|
81
|
-
autoload :
|
82
|
-
autoload :Gitilize, APP_PATH + '/databasion/gitilize.rb'
|
74
|
+
autoload :Application, APP_PATH + '/databasion/application.rb'
|
75
|
+
autoload :GoogleLoader, APP_PATH + '/databasion/google_loader.rb'
|
76
|
+
autoload :YamlBuilder, APP_PATH + '/databasion/yaml_builder.rb'
|
77
|
+
autoload :Migrate, APP_PATH + '/databasion/migrate.rb'
|
78
|
+
autoload :BuildMigration, APP_PATH + '/databasion/build_migration.rb'
|
79
|
+
autoload :LoadData, APP_PATH + '/databasion/load_data.rb'
|
80
|
+
autoload :SvnCommitter, APP_PATH + '/databasion/svn_committer.rb'
|
81
|
+
autoload :GitCommitter, APP_PATH + '/databasion/git_committer.rb'
|
82
|
+
autoload :CronSystem, APP_PATH + '/databasion/cron_system.rb'
|
83
83
|
|
84
84
|
end
|
@@ -3,7 +3,7 @@ require 'fileutils'
|
|
3
3
|
|
4
4
|
module Databasion
|
5
5
|
|
6
|
-
class
|
6
|
+
class Application
|
7
7
|
|
8
8
|
def self.run
|
9
9
|
opts = Trollop::options do
|
@@ -16,11 +16,13 @@ module Databasion
|
|
16
16
|
EOS
|
17
17
|
opt :create, "Create a base deploy directory", :type => String
|
18
18
|
opt :config, "Path to YAML config. Looks for config/google.yml by default", :type => String
|
19
|
-
opt :google, "
|
20
|
-
opt :migrate, "Migrate after
|
21
|
-
opt :
|
19
|
+
opt :google, "Load data from Google Spreadsheets"
|
20
|
+
opt :migrate, "Migrate after GoogleLoading"
|
21
|
+
opt :load, "Load parsed YAML data into migrated database"
|
22
|
+
opt :diff, "Manually check the diff of each database update from the load command"
|
22
23
|
opt :svn, "Auto commit the project files (assuming it has been committed to SVN)"
|
23
24
|
opt :git, "Auto commit the project files (assuming a working git repo)"
|
25
|
+
opt :cron, "Run the version control system via crontab and update on version changes"
|
24
26
|
end
|
25
27
|
if opts[:config].nil? and opts[:create].nil?
|
26
28
|
config = "config/google.yml"
|
@@ -40,20 +42,23 @@ module Databasion
|
|
40
42
|
end
|
41
43
|
|
42
44
|
def self.execute_databasion(opts)
|
45
|
+
if opts[:cron]
|
46
|
+
Databasion.run('cron', opts[:config], opts)
|
47
|
+
end
|
43
48
|
if opts[:google]
|
44
|
-
Databasion.
|
49
|
+
Databasion.run('google', opts[:config], opts)
|
45
50
|
end
|
46
51
|
if opts[:migrate]
|
47
|
-
Databasion.
|
52
|
+
Databasion.run('migrate', opts[:config], opts)
|
48
53
|
end
|
49
|
-
if opts[:
|
50
|
-
Databasion.
|
54
|
+
if opts[:load]
|
55
|
+
Databasion.run('load', opts[:config], opts)
|
51
56
|
end
|
52
57
|
if opts[:svn]
|
53
|
-
Databasion.
|
58
|
+
Databasion.run('svn', opts[:config], opts)
|
54
59
|
end
|
55
60
|
if opts[:git]
|
56
|
-
Databasion.
|
61
|
+
Databasion.run('git', opts[:config], opts)
|
57
62
|
end
|
58
63
|
end
|
59
64
|
|
@@ -4,20 +4,18 @@ require 'fileutils'
|
|
4
4
|
|
5
5
|
module Databasion
|
6
6
|
|
7
|
-
class
|
7
|
+
class BuildMigrationError < StandardError; end
|
8
8
|
|
9
|
-
class
|
9
|
+
class BuildMigration
|
10
10
|
|
11
11
|
@@migration_start = 100
|
12
12
|
|
13
|
-
def self.
|
14
|
-
raise
|
15
|
-
raise
|
13
|
+
def self.run(file_list=[], config=nil)
|
14
|
+
raise BuildMigrationError, 'Databasion::BuildMigration requires an array list of files. Try GoogleLoading first.' if file_list.empty?
|
15
|
+
raise BuildMigrationError, 'Databasion::BuildMigration requires a parsed YAML config.' if config.nil?
|
16
16
|
@@config = config
|
17
17
|
|
18
|
-
Databasion::LOGGER.info "Migrabating..."
|
19
18
|
parse(file_list)
|
20
|
-
Databasion::LOGGER.info "Migrabated!"
|
21
19
|
end
|
22
20
|
|
23
21
|
private
|
@@ -28,6 +26,7 @@ module Databasion
|
|
28
26
|
end
|
29
27
|
|
30
28
|
def self.parse(file_list)
|
29
|
+
Databasion::LOGGER.info "Migrabating..."
|
31
30
|
database_configs = []
|
32
31
|
file_list.each do |file|
|
33
32
|
meta = YAML.load(File.open(file))['meta']
|
@@ -35,6 +34,7 @@ module Databasion
|
|
35
34
|
process(meta)
|
36
35
|
end
|
37
36
|
write_database_yaml(database_configs)
|
37
|
+
Databasion::LOGGER.info "Migrabated!"
|
38
38
|
end
|
39
39
|
|
40
40
|
def self.process(meta)
|
@@ -116,6 +116,7 @@ module Databasion
|
|
116
116
|
f = File.open("config/database.yml", 'w')
|
117
117
|
f.write(YAML.dump(output))
|
118
118
|
f.close
|
119
|
+
Databasion::LOGGER.info "Wrote database config..."
|
119
120
|
end
|
120
121
|
|
121
122
|
def self.migration_exists?(file_name)
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module Databasion
|
2
|
+
|
3
|
+
class CronSystemError < StandardError; end
|
4
|
+
|
5
|
+
class CronSystem
|
6
|
+
|
7
|
+
@@config = nil
|
8
|
+
|
9
|
+
def self.config?
|
10
|
+
raise CronSystemError, 'CronSystem cannot load without a config.' unless defined?(@@config)
|
11
|
+
true
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.config=(data)
|
15
|
+
@@config = data
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.config
|
19
|
+
config?
|
20
|
+
@@config
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.run
|
24
|
+
Databasion::GoogleLoader.config = @@config
|
25
|
+
version = Databasion::GoogleLoader.run_version
|
26
|
+
|
27
|
+
if File.exist?(@@config['cron']['version']['file'])
|
28
|
+
old_version = File.open(@@config['cron']['version']['file']).readline.strip
|
29
|
+
if version > old_version
|
30
|
+
Databasion::LOGGER.info "Version changed, running databasion."
|
31
|
+
system "cd %s && databasion %s" % [@@config['cron']['project_base'], @@config['cron']['options']]
|
32
|
+
write_version(version)
|
33
|
+
elsif version < old_version
|
34
|
+
Databasion::LOGGER.info "Version rollback is currently not implemented."
|
35
|
+
else
|
36
|
+
Databasion::LOGGER.info "Version has not changed."
|
37
|
+
end
|
38
|
+
else
|
39
|
+
Databasion::LOGGER.info "CronSystem running for the first time."
|
40
|
+
system "cd %s && databasion %s" % [@@config['cron']['project_base'], @@config['cron']['options']]
|
41
|
+
write_version(version)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.write_version(version)
|
46
|
+
File.open(@@config['cron']['version']['file'], 'w') do |file|
|
47
|
+
file.write version
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
module Databasion
|
2
2
|
|
3
|
-
class
|
3
|
+
class GitCommitter
|
4
4
|
|
5
5
|
@@config = nil
|
6
6
|
|
7
|
-
class
|
7
|
+
class GitCommitterError < StandardError; end
|
8
8
|
|
9
9
|
def self.config=(config)
|
10
10
|
@@config = config
|
@@ -19,7 +19,7 @@ module Databasion
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def self.commit(path=Dir.pwd)
|
22
|
-
raise
|
22
|
+
raise GitCommitterError, "A file lock is in place. Cannot commit." if check_lock?
|
23
23
|
create unless check_repo?
|
24
24
|
create_lock
|
25
25
|
Databasion::LOGGER.info 'running: git commit -am "databasion auto commit"'
|
@@ -31,6 +31,7 @@ module Databasion
|
|
31
31
|
Databasion::LOGGER.info 'creating new git repository'
|
32
32
|
Databasion::LOGGER.info 'running: git init'
|
33
33
|
system git_path + ' init'
|
34
|
+
system git_path + ' add .'
|
34
35
|
end
|
35
36
|
|
36
37
|
def self.check_repo?
|
@@ -2,14 +2,21 @@ require "google_spreadsheet"
|
|
2
2
|
|
3
3
|
module Databasion
|
4
4
|
|
5
|
-
class
|
5
|
+
class GoogleLoaderError < StandardError; end
|
6
6
|
|
7
|
-
class
|
7
|
+
class GoogleLoader
|
8
8
|
|
9
|
-
@@master_sheet
|
9
|
+
@@master_sheet = 'Database'
|
10
|
+
@@version_sheet = 'Version'
|
11
|
+
|
12
|
+
@@table_def = 'table'
|
13
|
+
@@field_def = 'field'
|
14
|
+
@@type_def = 'type'
|
15
|
+
@@index_def = 'index'
|
16
|
+
@@ignore_def = 'ignore'
|
10
17
|
|
11
18
|
def self.config?
|
12
|
-
raise '
|
19
|
+
raise GoogleLoaderError, 'GoogleLoader cannot load without a config.' unless defined?(@@config)
|
13
20
|
true
|
14
21
|
end
|
15
22
|
|
@@ -34,25 +41,40 @@ module Databasion
|
|
34
41
|
@@master_sheet
|
35
42
|
end
|
36
43
|
|
44
|
+
def self.version_sheet=(version)
|
45
|
+
@@version_sheet = version
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.version_sheet
|
49
|
+
@@version_sheet
|
50
|
+
end
|
51
|
+
|
37
52
|
def self.login
|
38
53
|
begin
|
39
54
|
@@session = GoogleSpreadsheet.login(@@config['login']['username'], @@config['login']['password'])
|
40
55
|
rescue
|
41
|
-
raise
|
56
|
+
raise GoogleLoaderError, "Couldn't log into Google."
|
42
57
|
end
|
43
58
|
end
|
44
59
|
|
45
|
-
def self.
|
60
|
+
def self.run
|
46
61
|
config?
|
47
62
|
login
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
63
|
+
process.each do |data_hash|
|
64
|
+
Databasion::YamlBuilder.run(data_hash, @@config['output']['yaml_path'])
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def self.run_version
|
69
|
+
config?
|
70
|
+
login
|
71
|
+
fetch_version
|
52
72
|
end
|
53
73
|
|
54
74
|
private
|
55
75
|
def self.process
|
76
|
+
Databasion::LOGGER.info "Googlizing..."
|
77
|
+
data_list = []
|
56
78
|
@@config['sheets'].each do |token|
|
57
79
|
spreadsheet = @@session.spreadsheet_by_key(token['key'])
|
58
80
|
master_list = get_master(spreadsheet)
|
@@ -60,16 +82,18 @@ module Databasion
|
|
60
82
|
next unless master_list.collect { |row| row['spreadsheet'] }.include?(worksheet.title)
|
61
83
|
data_hash = parse(worksheet)
|
62
84
|
data_hash['connection'] = master_list.collect { |row| row if row['spreadsheet'] == worksheet.title }.reject { |d| d.nil? }[0]
|
63
|
-
|
85
|
+
data_list << data_hash
|
64
86
|
end
|
65
87
|
end
|
88
|
+
Databasion::LOGGER.info "Googlized!"
|
89
|
+
data_list
|
66
90
|
end
|
67
91
|
|
68
92
|
def self.get_master(spreadsheet)
|
69
93
|
master_list = []
|
70
94
|
header_info = nil
|
71
95
|
spreadsheet.worksheets.each do |worksheet|
|
72
|
-
if worksheet.title ==
|
96
|
+
if worksheet.title == master_sheet
|
73
97
|
worksheet.rows.each_with_index do |row, index|
|
74
98
|
if index == 0
|
75
99
|
header_info = row
|
@@ -84,7 +108,7 @@ module Databasion
|
|
84
108
|
break
|
85
109
|
end
|
86
110
|
end
|
87
|
-
raise
|
111
|
+
raise GoogleLoaderError, "There was no master sheet defined in the spreadsheet %s." % token['name'] if master_list.size == 0
|
88
112
|
master_list
|
89
113
|
end
|
90
114
|
|
@@ -102,7 +126,7 @@ module Databasion
|
|
102
126
|
next if (row.reject { |s| s.strip.empty? }).size == 0
|
103
127
|
|
104
128
|
case row[0]
|
105
|
-
when
|
129
|
+
when @@table_def
|
106
130
|
begin
|
107
131
|
d = row[1].split(",")
|
108
132
|
name = d[0].strip
|
@@ -111,19 +135,19 @@ module Databasion
|
|
111
135
|
name = row[1]
|
112
136
|
plural = true
|
113
137
|
end
|
114
|
-
when
|
138
|
+
when @@field_def
|
115
139
|
row.each do |field|
|
116
140
|
fields.push field unless field.empty?
|
117
141
|
end
|
118
|
-
when
|
142
|
+
when @@type_def
|
119
143
|
row.each do |type|
|
120
144
|
types.push type unless type.empty?
|
121
145
|
end
|
122
|
-
when
|
146
|
+
when @@index_def
|
123
147
|
row.each_with_index do |index, i|
|
124
148
|
indexes.push i-1 unless index.empty? or i == 0
|
125
149
|
end
|
126
|
-
when
|
150
|
+
when @@ignore_def
|
127
151
|
row.each_with_index do |ignore, i|
|
128
152
|
ignore_cols.push i-1 unless ignore.empty? or i == 0
|
129
153
|
end
|
@@ -145,6 +169,22 @@ module Databasion
|
|
145
169
|
}
|
146
170
|
end
|
147
171
|
|
172
|
+
def self.fetch_version
|
173
|
+
version = nil
|
174
|
+
@@config['sheets'].each do |token|
|
175
|
+
spreadsheet = @@session.spreadsheet_by_key(token['key'])
|
176
|
+
spreadsheet.worksheets.each do |worksheet|
|
177
|
+
if worksheet.title == version_sheet
|
178
|
+
worksheet.rows.each do |row|
|
179
|
+
version = row[0]
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|
183
|
+
end
|
184
|
+
raise GoogleLoaderError, "A Version spreadsheet was not found in any of the Google Spreadsheets supplied in google.yml" if version.nil?
|
185
|
+
version
|
186
|
+
end
|
187
|
+
|
148
188
|
end
|
149
189
|
|
150
190
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Databasion
|
2
2
|
|
3
|
-
class
|
3
|
+
class LoadData
|
4
4
|
|
5
5
|
@@config = nil
|
6
6
|
|
@@ -12,7 +12,7 @@ module Databasion
|
|
12
12
|
@@config
|
13
13
|
end
|
14
14
|
|
15
|
-
def self.
|
15
|
+
def self.run(opts)
|
16
16
|
Databasion.set_ar_logger
|
17
17
|
Databasion::LOGGER.info "Updating from YAML..."
|
18
18
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Databasion
|
2
2
|
|
3
|
-
class
|
3
|
+
class Migrate
|
4
4
|
|
5
5
|
@@config = nil
|
6
6
|
|
@@ -8,11 +8,11 @@ module Databasion
|
|
8
8
|
@@config = config
|
9
9
|
end
|
10
10
|
|
11
|
-
def self.
|
11
|
+
def self.run
|
12
12
|
require 'migration_helpers/init'
|
13
13
|
|
14
14
|
files = Dir["%s/*.yml" % @@config['output']['yaml_path']]
|
15
|
-
Databasion::
|
15
|
+
Databasion::BuildMigration.run(files, @@config)
|
16
16
|
|
17
17
|
Databasion.set_ar_logger
|
18
18
|
Databasion::LOGGER.info "Migrating..."
|
@@ -2,11 +2,11 @@ require 'fileutils'
|
|
2
2
|
|
3
3
|
module Databasion
|
4
4
|
|
5
|
-
class
|
5
|
+
class SvnCommitter
|
6
6
|
|
7
7
|
@@config = nil
|
8
8
|
|
9
|
-
class
|
9
|
+
class SvnCommitterError < StandardError; end
|
10
10
|
|
11
11
|
def self.config=(config)
|
12
12
|
@@config = config
|
@@ -21,7 +21,7 @@ module Databasion
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def self.commit(path=Dir.pwd)
|
24
|
-
raise
|
24
|
+
raise SvnCommitterError, "A file lock is in place. Cannot commit." if check_lock?
|
25
25
|
create_lock
|
26
26
|
svn_add_files(path)
|
27
27
|
Databasion::LOGGER.info 'running: svn commit -m "databasion auto commit"'
|
@@ -2,12 +2,12 @@ require 'fileutils'
|
|
2
2
|
|
3
3
|
module Databasion
|
4
4
|
|
5
|
-
class
|
5
|
+
class YamlBuilderError < StandardError; end
|
6
6
|
|
7
|
-
class
|
7
|
+
class YamlBuilder
|
8
8
|
|
9
|
-
def self.
|
10
|
-
raise YamalizeError, 'Databasion::
|
9
|
+
def self.run(data_hash, output_path=nil)
|
10
|
+
raise YamalizeError, 'Databasion::YamlBuilder requires an output path.' if output_path.nil?
|
11
11
|
@@output_path = output_path
|
12
12
|
|
13
13
|
Databasion::LOGGER.info "Yamlbating %s..." % data_hash['name']
|
data/lib/tasks/databasion.rake
CHANGED
@@ -3,21 +3,26 @@ require 'lib/databasion'
|
|
3
3
|
namespace :databasion do
|
4
4
|
desc "Run Databasion for Google Spreadsheets"
|
5
5
|
task :google do
|
6
|
-
Databasion.
|
6
|
+
Databasion.run('google', 'config/google.yml')
|
7
7
|
end
|
8
8
|
|
9
9
|
desc "Run Ruby Migration scripts"
|
10
10
|
task :migrate do
|
11
|
-
Databasion.
|
11
|
+
Databasion.run('migrate', 'config/google.yml')
|
12
12
|
end
|
13
13
|
|
14
|
-
desc "Run the
|
15
|
-
task :
|
16
|
-
Databasion.
|
14
|
+
desc "Run the load script to stuff YAML data into database"
|
15
|
+
task :load do
|
16
|
+
Databasion.run('load', 'config/google.yml')
|
17
17
|
end
|
18
18
|
|
19
19
|
desc "Run the SVN auto-commit system"
|
20
20
|
task :svn do
|
21
|
-
Databasion.
|
21
|
+
Databasion.run('svn', 'config/google.yml')
|
22
|
+
end
|
23
|
+
|
24
|
+
desc "Run the GIT auto-commit system"
|
25
|
+
task :git do
|
26
|
+
Databasion.run('git', 'config/google.yml')
|
22
27
|
end
|
23
28
|
end
|
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: 25
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 1
|
10
|
+
version: 0.1.1
|
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-
|
19
|
+
date: 2010-11-04 00:00:00 +09:00
|
20
20
|
default_executable: databasion
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
@@ -100,29 +100,29 @@ files:
|
|
100
100
|
- bin/databasion
|
101
101
|
- config/example.google.yml
|
102
102
|
- databasion.gemspec
|
103
|
-
- features/
|
104
|
-
- features/
|
105
|
-
- features/
|
106
|
-
- features/
|
107
|
-
- features/
|
108
|
-
- features/
|
109
|
-
- features/
|
110
|
-
- features/
|
111
|
-
- features/
|
112
|
-
- features/step_definitions/
|
103
|
+
- features/build_migration.feature
|
104
|
+
- features/create_project.feature
|
105
|
+
- features/cron_system.feature
|
106
|
+
- features/env/helper_methods.rb
|
107
|
+
- features/google_loader.feature
|
108
|
+
- features/step_definitions/build_migration_steps.rb
|
109
|
+
- features/step_definitions/create_project_steps.rb
|
110
|
+
- features/step_definitions/cron_system_steps.rb
|
111
|
+
- features/step_definitions/google_loader_steps.rb
|
112
|
+
- features/step_definitions/yaml_builder_steps.rb
|
113
|
+
- features/yaml_builder.feature
|
113
114
|
- lib/databasion.rb
|
114
|
-
- lib/databasion/
|
115
|
-
- lib/databasion/
|
116
|
-
- lib/databasion/
|
117
|
-
- lib/databasion/
|
118
|
-
- lib/databasion/
|
119
|
-
- lib/databasion/
|
120
|
-
- lib/databasion/
|
121
|
-
- lib/databasion/
|
122
|
-
- lib/databasion/svnilize.rb
|
115
|
+
- lib/databasion/application.rb
|
116
|
+
- lib/databasion/build_migration.rb
|
117
|
+
- lib/databasion/cron_system.rb
|
118
|
+
- lib/databasion/git_committer.rb
|
119
|
+
- lib/databasion/google_loader.rb
|
120
|
+
- lib/databasion/load_data.rb
|
121
|
+
- lib/databasion/migrate.rb
|
122
|
+
- lib/databasion/svn_committer.rb
|
123
123
|
- lib/databasion/templates/migration.erb
|
124
124
|
- lib/databasion/templates/model.erb
|
125
|
-
- lib/databasion/
|
125
|
+
- lib/databasion/yaml_builder.rb
|
126
126
|
- lib/migration_helpers/MIT-LICENSE
|
127
127
|
- lib/migration_helpers/README.markdown
|
128
128
|
- lib/migration_helpers/init.rb
|
data/features/databasion.feature
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
Feature: Run System
|
2
|
-
In order for the user to choose what they want to do
|
3
|
-
The user should be able to pass in configuration settings
|
4
|
-
|
5
|
-
Scenario: User calls google databate with config
|
6
|
-
Given there is an actual yaml config file for google
|
7
|
-
When the user runs databate for google
|
8
|
-
Then Databasion should not fail for google
|
9
|
-
|
10
|
-
Scenario: User calls google databate without config
|
11
|
-
Given there is no config file for google
|
12
|
-
When the user calls databate without config for google
|
13
|
-
Then Databasion should fail for google
|
14
|
-
|
15
|
-
Scenario: User calls excel databate with config
|
16
|
-
Given there is an actual yaml config file for excel
|
17
|
-
When the user runs databate for excel
|
18
|
-
Then Databasion should not fail for excel
|
19
|
-
|
20
|
-
Scenario: User calls excel databate without config
|
21
|
-
Given there is no config file for excel
|
22
|
-
When the user calls databate without config for excel
|
23
|
-
Then Databasion should fail for excel
|
@@ -1,13 +0,0 @@
|
|
1
|
-
Feature: Use Googlize
|
2
|
-
In order for a user to access google
|
3
|
-
They need to connect first
|
4
|
-
|
5
|
-
Scenario: Log into Google
|
6
|
-
Given a google account
|
7
|
-
When Googlize logs in
|
8
|
-
Then we should have a GoogleSpreadsheet session
|
9
|
-
|
10
|
-
Scenario: Run system with config
|
11
|
-
Given a google yaml config
|
12
|
-
When Googlize starts up
|
13
|
-
Then Googlize should not fail
|
@@ -1,32 +0,0 @@
|
|
1
|
-
require 'lib/databasion'
|
2
|
-
|
3
|
-
Given /a google account/ do
|
4
|
-
@config = YAML.load(File.open('config/google.yml'))
|
5
|
-
end
|
6
|
-
|
7
|
-
When /Googlize logs in/ do
|
8
|
-
Databasion::Googlize.config = @config
|
9
|
-
Databasion::Googlize.login
|
10
|
-
end
|
11
|
-
|
12
|
-
Then /we should have a GoogleSpreadsheet session/ do
|
13
|
-
Databasion::Googlize.session.should be_kind_of(GoogleSpreadsheet::Session)
|
14
|
-
end
|
15
|
-
|
16
|
-
Given /a google yaml config/ do
|
17
|
-
@config = YAML.load(File.open('config/google.yml'))
|
18
|
-
end
|
19
|
-
|
20
|
-
When /Googlize starts up/ do
|
21
|
-
Databasion::Googlize.config = @config
|
22
|
-
begin
|
23
|
-
Databasion::Googlize.googlebate
|
24
|
-
@error = false
|
25
|
-
rescue
|
26
|
-
@error = true
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
Then /Googlize should not fail/ do
|
31
|
-
@error.should == false
|
32
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
require 'lib/databasion'
|
2
|
-
|
3
|
-
Given /a complete set of YAML definitions/ do
|
4
|
-
@config = YAML.load(File.open('config/google.yml'))
|
5
|
-
|
6
|
-
@parse_data = {
|
7
|
-
'name' => 'mock',
|
8
|
-
'plural' => true,
|
9
|
-
'fields' => ["id", "name", "power"],
|
10
|
-
'types' => ["integer", "string, 20", "string, 40"],
|
11
|
-
'data' => [[1, "Brian Jones", "Super Intelligence"], [2, "Superman", "Invincible"], [3, "Batman", "Strength"]],
|
12
|
-
'ignore_cols' => [2],
|
13
|
-
'connection' => [{'database' => 'moon'}]
|
14
|
-
}
|
15
|
-
Databasion::Yamalize.yamlbate(@parse_data, @config['output']['yaml_path'])
|
16
|
-
|
17
|
-
@files = Dir["%s/%s.yml" % [@config['output']['yaml_path'], @parse_data['name']]]
|
18
|
-
end
|
19
|
-
|
20
|
-
When /the YAML files are parsed/ do
|
21
|
-
Databasion::Migitize.migrabate(@files, @config)
|
22
|
-
end
|
23
|
-
|
24
|
-
Then /the result is Ruby migration files/ do
|
25
|
-
File.exist?("%s/100_%s.rb" % [@config['output']['migrations']['path'], @parse_data['name']]).should == true
|
26
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
require 'lib/databasion'
|
2
|
-
|
3
|
-
Given /a databasion created file structure/ do
|
4
|
-
Databasion::Applcize.create_project({ :create => 'cucumber_test' })
|
5
|
-
end
|
6
|
-
|
7
|
-
When /the commit command is ran/ do
|
8
|
-
Databasion::Svnilize.commit('cucumber_test')
|
9
|
-
end
|
10
|
-
|
11
|
-
Then /the data should be stored in SVN/ do
|
12
|
-
|
13
|
-
FileUtils.rm_rf 'cucumber_test'
|
14
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
require 'lib/databasion'
|
2
|
-
|
3
|
-
Given /a chunk of (.*) data/ do |name|
|
4
|
-
@config = YAML.load(File.open('config/google.yml'))
|
5
|
-
@parse_data = {
|
6
|
-
'name' => 'mock',
|
7
|
-
'plural' => true,
|
8
|
-
'fields' => ["id", "name", "power"],
|
9
|
-
'types' => ["integer", "string, 20", "string, 40"],
|
10
|
-
'data' => [[1, "Brian Jones", "Super Intelligence"], [2, "Superman", "Invincible"], [3, "Batman", "Strength"]],
|
11
|
-
'ignore_cols' => [2],
|
12
|
-
'connection' => [{'database' => 'moon'}]
|
13
|
-
}
|
14
|
-
end
|
15
|
-
|
16
|
-
When /we parse it/ do
|
17
|
-
Databasion::Yamalize.yamlbate(@parse_data, @config['output']['yaml_path'])
|
18
|
-
end
|
19
|
-
|
20
|
-
Then /it should create a relevant YAML file/ do
|
21
|
-
File.exist?("%s/%s.yml" % [@config['output']['yaml_path'], @parse_data['name']]).should == true
|
22
|
-
end
|
23
|
-
|
24
|
-
And /should contain the correct data/ do
|
25
|
-
data = YAML.load(File.open("%s/%s.yml" % [@config['output']['yaml_path'], @parse_data['name']]))
|
26
|
-
data.should include('meta')
|
27
|
-
data.should include('data')
|
28
|
-
data['meta'].should include('connection')
|
29
|
-
end
|
@@ -1,9 +0,0 @@
|
|
1
|
-
Feature: Convert parsed hash into YAML
|
2
|
-
In order to convert the higher level into YAML
|
3
|
-
We need to process it and write it out to files
|
4
|
-
|
5
|
-
Scenario: Google passes data
|
6
|
-
Given a chunk of google data
|
7
|
-
When we parse it
|
8
|
-
Then it should create a relevant YAML file
|
9
|
-
And should contain the correct data
|
@@ -1,35 +0,0 @@
|
|
1
|
-
require 'lib/databasion'
|
2
|
-
|
3
|
-
Given /there is an actual yaml config file for (.*)/ do |name|
|
4
|
-
@config = 'config/google.yml'
|
5
|
-
end
|
6
|
-
|
7
|
-
When /the user runs databate for (.*)/ do |name|
|
8
|
-
begin
|
9
|
-
Databasion.databate(name, @config)
|
10
|
-
@error = false
|
11
|
-
rescue
|
12
|
-
@error = true
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
Then /Databasion should not fail for (.*)/ do |name|
|
17
|
-
@error.should == false
|
18
|
-
end
|
19
|
-
|
20
|
-
Given /there is no config file for (.*)/ do |name|
|
21
|
-
@config = nil
|
22
|
-
end
|
23
|
-
|
24
|
-
When /the user calls databate without config for (.*)/ do |name|
|
25
|
-
begin
|
26
|
-
Databasion.databate(name, @config)
|
27
|
-
@error = false
|
28
|
-
rescue
|
29
|
-
@error = true
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
Then /Databasion should fail for (.*)/ do |name|
|
34
|
-
@error.should == true
|
35
|
-
end
|
data/lib/databasion/csvilize.rb
DELETED