skiima 0.1.000 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +15 -0
  2. data/.gitignore +9 -0
  3. data/.travis.yml +11 -3
  4. data/Gemfile +12 -6
  5. data/Guardfile +13 -11
  6. data/LICENSE +20 -0
  7. data/Procfile.example +2 -0
  8. data/README.md +170 -23
  9. data/Rakefile +26 -22
  10. data/lib/skiima.rb +61 -240
  11. data/lib/skiima/config.rb +60 -0
  12. data/lib/skiima/config/struct.rb +87 -0
  13. data/lib/skiima/db/connector.rb +195 -0
  14. data/lib/skiima/db/connector/active_record.rb +11 -0
  15. data/lib/skiima/db/connector/active_record/base_connector.rb +34 -0
  16. data/lib/skiima/db/connector/active_record/mysql2_connector.rb +147 -0
  17. data/lib/skiima/db/connector/active_record/mysql_connector.rb +177 -0
  18. data/lib/skiima/db/connector/active_record/postgresql_connector.rb +39 -0
  19. data/lib/skiima/db/helpers/mysql.rb +230 -0
  20. data/lib/skiima/db/helpers/postgresql.rb +221 -0
  21. data/lib/skiima/db/resolver.rb +62 -0
  22. data/lib/skiima/dependency/reader.rb +55 -0
  23. data/lib/skiima/dependency/script.rb +63 -0
  24. data/lib/skiima/i18n.rb +24 -0
  25. data/lib/skiima/loader.rb +108 -0
  26. data/lib/skiima/locales/en.yml +2 -2
  27. data/lib/skiima/logger.rb +54 -0
  28. data/lib/skiima/railtie.rb +10 -0
  29. data/lib/skiima/railties/skiima.rake +31 -0
  30. data/lib/skiima/version.rb +2 -2
  31. data/skiima.gemspec +5 -5
  32. data/spec/config/{database.yml → database.yml.example} +16 -0
  33. data/spec/config/database.yml.travis +69 -0
  34. data/spec/db/skiima/{depends.yml → dependencies.yml} +7 -2
  35. data/spec/db/skiima/{empty_depends.yml → empty_dependencies.yml} +0 -0
  36. data/spec/db/skiima/init_test_db/database.skiima_test.mysql.current.sql +7 -0
  37. data/spec/db/skiima/init_test_db/database.skiima_test.postgresql.current.sql +7 -0
  38. data/spec/mysql2_spec.rb +61 -12
  39. data/spec/mysql_spec.rb +66 -27
  40. data/spec/postgresql_spec.rb +55 -34
  41. data/spec/shared_examples/config_shared_example.rb +40 -0
  42. data/spec/skiima/config/struct_spec.rb +78 -0
  43. data/spec/skiima/config_spec.rb +6 -0
  44. data/spec/skiima/db/connector/active_record/base_connector_spec.rb +0 -0
  45. data/spec/skiima/db/connector/active_record/mysql2_connector_spec.rb +3 -0
  46. data/spec/skiima/db/connector/active_record/mysql_connector_spec.rb +3 -0
  47. data/spec/skiima/db/connector/active_record/postgresql_connector_spec.rb +7 -0
  48. data/spec/skiima/db/connector_spec.rb +6 -0
  49. data/spec/skiima/db/resolver_spec.rb +54 -0
  50. data/spec/skiima/dependency/reader_spec.rb +52 -0
  51. data/spec/skiima/{dependency_spec.rb → dependency/script_spec.rb} +3 -41
  52. data/spec/skiima/i18n_spec.rb +29 -0
  53. data/spec/skiima/loader_spec.rb +102 -0
  54. data/spec/skiima/logger_spec.rb +0 -0
  55. data/spec/skiima_spec.rb +43 -64
  56. data/spec/spec_helper.rb +38 -4
  57. metadata +144 -100
  58. data/lib/skiima/db_adapters.rb +0 -187
  59. data/lib/skiima/db_adapters/base_mysql_adapter.rb +0 -308
  60. data/lib/skiima/db_adapters/mysql2_adapter.rb +0 -114
  61. data/lib/skiima/db_adapters/mysql_adapter.rb +0 -287
  62. data/lib/skiima/db_adapters/postgresql_adapter.rb +0 -509
  63. data/lib/skiima/dependency.rb +0 -84
  64. data/lib/skiima_helpers.rb +0 -49
  65. data/spec/skiima/db_adapters/mysql_adapter_spec.rb +0 -38
  66. data/spec/skiima/db_adapters/postgresql_adapter_spec.rb +0 -20
  67. data/spec/skiima/db_adapters_spec.rb +0 -31
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ Yjc2YmJlOTIwMzY2YWM2MjQ0OGU2OTFhNTllNzMxMDA2Y2I4YmM5OA==
5
+ data.tar.gz: !binary |-
6
+ NGQ3M2RhMWM5YTUxYjRmNGI0NjFhNDY4NDUyNWNjYjQzZjVjYzQzNg==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ YzY1NTIyNzcwZTczZTQwMjZiYzkxYTcyMjQ1M2E1Mzk4MGU3OTcyOTk4MzZi
10
+ YTZhNWM4NzRiOGQzZmNjMWJmZjI5MzQ4YjZiZGM1MWY1Y2RjM2Q1NTlmMzY5
11
+ MjdmOTE5Yzc1NzkyMGU5MDZkNTU5ZGRlYTM5MzdlMDJlZjY5NGY=
12
+ data.tar.gz: !binary |-
13
+ NDMzZjgzMmIxMjk1NTExODE5Y2E0MzhmZDYyNDU2ZGFlOWU4ZWRkNGE2Yjcy
14
+ OThhNzMyMDdhZDI2MWVhNWVkODc2Mzk2NWZhZGQ1YzkxNjIwNGM4ZjJhMzBm
15
+ YjljNmMyNjNhMDQwODU0YjM0NWRhNGI0M2IzNjNjMzMzMDJlZjQ=
data/.gitignore CHANGED
@@ -1,8 +1,11 @@
1
+ ## Ruby
1
2
  *.gem
2
3
  .rvmrc
3
4
  .bundle
4
5
  Gemfile.lock
5
6
  pkg/*
7
+ .guard_history
8
+ Procfile
6
9
 
7
10
  ## Rubymine
8
11
  .idea/*
@@ -18,3 +21,9 @@ Desktop DF
18
21
 
19
22
  ## Spec Logging
20
23
  spec/test.log
24
+
25
+ ## Config
26
+ spec/config/database.yml
27
+
28
+ ## Notes
29
+ NOTES.md
@@ -2,7 +2,15 @@ language: ruby
2
2
  rvm:
3
3
  - 1.9.2
4
4
  - 1.9.3
5
- - jruby
5
+ - 2.0.0
6
6
  - rbx-19mode
7
- # uncomment this line if your project needs to run something other than `rake`:
8
- # script: bundle exec rspec spec
7
+ # - jruby
8
+ services:
9
+ - mysql
10
+ - postgresql
11
+ before_script:
12
+ - cp spec/config/database.yml.travis spec/config/database.yml
13
+ - mysql -e "create user 'skiima'@'localhost'"
14
+ - rake skiima:setup:db:postgresql
15
+ - rake skiima:setup:db:mysql
16
+ #script: rake
data/Gemfile CHANGED
@@ -5,14 +5,20 @@ source "http://rubygems.org"
5
5
  gemspec
6
6
 
7
7
  group :development do
8
- gem 'guard'
9
- gem 'guard-minitest'
8
+ gem 'guard', '~> 1.6.2'
9
+ gem 'guard-minitest', '~> 0.5.0'
10
10
  gem 'pry'
11
11
  gem 'rake'
12
12
 
13
- gem 'pg'
14
- gem 'mysql'
15
- gem 'mysql2'
13
+ gem 'foreman', '~> 0.62.0'
14
+ gem 'pg', '~> 0.14.1'
15
+ gem 'mysql', '~> 2.9.1'
16
+ gem 'mysql2', '~> 0.3.11'
17
+ end
18
+
19
+ group :active_record do
20
+ gem 'activerecord', '>= 3.2', '< 4.1'
21
+ gem 'activesupport', '>= 3.2', '< 4.1'
16
22
  end
17
23
 
18
24
  if Config::CONFIG['target_os'] =~ /darwin/i
@@ -23,7 +29,7 @@ if Config::CONFIG['target_os'] =~ /linux/i
23
29
  gem 'rb-inotify', '>= 0.5.1'
24
30
  gem 'libnotify', '~> 0.1.3'
25
31
  end
26
- if RbConfig::CONFIG['target_os'] =~ /mswin|mingw/i
32
+ if Config::CONFIG['target_os'] =~ /mswin|mingw/i
27
33
  gem 'win32console', :require => false
28
34
  gem 'rb-fchange', '~> 0.0.2', :require => false
29
35
  gem 'rb-notifu', '~> 0.0.4', :require => false
data/Guardfile CHANGED
@@ -1,14 +1,16 @@
1
- # A sample Guardfile
2
- # More info at https://github.com/guard/guard#readme
1
+ interactor guard_rc: '~/.my_guard-rc', history_file: '.guard_history'
2
+ scope groups: [:minitest]
3
3
 
4
- guard 'minitest', :notify => true do
5
- # with Minitest::Unit
6
- # watch(%r|^test/test_(.*)\.rb|)
7
- # watch(%r|^lib/(.*)([^/]+)\.rb|) { |m| "test/#{m[1]}test_#{m[2]}.rb" }
8
- # watch(%r|^test/test_helper\.rb|) { "test" }
4
+ group :minitest do
5
+ guard :minitest, :notify => true do
6
+ # with Minitest::Unit
7
+ # watch(%r|^test/test_(.*)\.rb|)
8
+ # watch(%r|^lib/(.*)([^/]+)\.rb|) { |m| "test/#{m[1]}test_#{m[2]}.rb" }
9
+ # watch(%r|^test/test_helper\.rb|) { "test" }
9
10
 
10
- # with Minitest::Spec
11
- watch(%r|^spec/(.*)_spec\.rb|)
12
- watch(%r|^lib/(.*)\.rb|) { |m| "spec/#{m[1]}_spec.rb" }
13
- watch(%r|^spec/spec_helper\.rb|) { "spec" }
11
+ # with Minitest::Spec
12
+ watch(%r|^spec/(.*)_spec\.rb|)
13
+ watch(%r|^lib/(.*)\.rb|) { |m| "spec/#{m[1]}_spec.rb" }
14
+ watch(%r|^spec/spec_helper\.rb|) { "spec" }
15
+ end
14
16
  end
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 David Conner
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,2 @@
1
+ postgres: postgres -D /usr/local/var/postgres
2
+ mysql: /usr/local/bin/mysqld
data/README.md CHANGED
@@ -1,21 +1,133 @@
1
1
  Skiima: an ORM-Agnostic, Rails-Independent alternative to migrations.
2
- ------------------------
3
2
 
4
- #### Goals:
5
- Skiima is a work in progress with the following goals:
3
+ [![Build Status](https://travis-ci.org/dcunited001/skiima.png?branch=master)](https://travis-ci.org/dcunited001/skiima)
4
+
5
+ ------------------------
6
6
 
7
+ ## Using Skiima with ActiveRecord:
8
+
9
+ > Adding generators soon
10
+
11
+ #### Installing
12
+ 1. Add skiima to your Gemfile
13
+ 1. Bundle Install
14
+ 1. Configure your database.yml
15
+ - Ensure that users have the appropriate DDL permissions
16
+ 1. `mkdir db/skiima`
17
+ 1. `touch db/skiima/dependencies.yml`
18
+ - Refer to the example below or $SKIIMA_GEM/spec/db/skiima/dependencies
19
+ 1. Set up a :test dependency group
20
+ - include the groups of scripts you want to run after a fresh db clone
21
+ - add `bundle exec rake skiima:test:up` to your CI setup script, after calling db:test:prepare
22
+ - or add a rake task to your project that calls both db:test:prepare and skima:test:up
23
+ - specify environment/groups with `bundle exec rake skiima:test:up[development,group_name]
24
+ 1. Set up a :default dependency group
25
+ - include the groups of scripts you want to run during every deploy
26
+ - because the scripts are run on each deploy, this rake task should only be used in certain instances
27
+ - you should usually call Skiima.up & Skiima.down from a migration
28
+
29
+ #### Adding a new Skiima Script Group to your project
30
+
31
+ > Again, generators coming soon to help automate this.
32
+
33
+ 1. Add a new migration to your Rails project. Refer to the sample below.
34
+ 1. `mkdir db/skiima/$group_name`
35
+ 1. `touch db/skiima/$group_name/$type.$object_name.$db_type.$db_version.sql`
36
+ - $type => view/proc/function/etc
37
+ - $object_name => identifies the script across multiple db providers & versions
38
+ - $db_type => provider name (mysql/postgres)
39
+ - $db_version => usually just 'current'
40
+ - using $db_version, you can write scripts to support multiple versions of mysql, for example
41
+ - Skiima compares the connected database's version to pull the correct script
42
+ - or you can just configure skiima to prefer to load specific version of sql scripts
43
+ - pass :version => 'version_name' to Skiima.up & Skiima.down
44
+ 1. Also add a corresponding drop script to run if:
45
+ - either the up script is not reversible with a single drop statement
46
+ - or if Skiima can not automatically drop that type object
47
+ - see below for supported objects
48
+ 1. Now update db/skiima/dependencies.yml
49
+ - Refer to the example below or $SKIIMA_GEM/spec/db/skiima/dependencies
50
+ 1. The script should be ready to use with Skiima.up & Skiima.down
51
+
52
+ Sample Skiima Migration:
53
+
54
+ ```ruby
55
+
56
+ class AddViewBackedModel < ActiveRecord::Migration
57
+ def up
58
+ Skiima.up(Rails.env, :group_name)
59
+ end
60
+
61
+ def down
62
+ Skiima.down(Rails.env, :group_name)
63
+ end
64
+ end
65
+
66
+ ```
67
+
68
+ Sample Dependencies.yml:
69
+
70
+ ```yml
71
+
72
+ script_group_name:
73
+ postgresql:
74
+ current:
75
+ - view.script_name
76
+ mysql:
77
+ current:
78
+ - view.script_name
79
+ default:
80
+ test:
81
+ - script_group_name
82
+ dependency_group_name:
83
+ - script_group_name
84
+
85
+ ```
86
+
87
+ #### Running tests with your new Skiima Script Group
88
+
89
+ 1. `bundle exec rake db:migrate`
90
+ 1. `bundle exec rake db:test:prepare`
91
+ 1. `bundle exec rake skiima:test:up`
92
+ 1. `bundle exec rake`
93
+
94
+ #### Adding a view-backed model
95
+
96
+ ```ruby
97
+ # add a view named 'view_foo_report_on_bar'
98
+ class FooReportOnBar < ActiveRecord::Base
99
+ set_table_name :view_foo_report_on_bar
100
+
101
+ belongs_to :baz
102
+ end
103
+ ```
104
+
105
+ ## Using Skiima with another ORM:
106
+
107
+ > Support for Datamapper, Sequal, & JRuby providers coming soon.
108
+
109
+ ## Running Tests
110
+
111
+ 1. Setup Mysql & Postgres. Copy database.yml.example & set up users/passwords for your system
112
+ 1. Bundle Install
113
+ 1. Run test setup tasks
114
+ - bundle exec rake skiima:setup:db:postgresql
115
+ - bundle exec rake skiima:setup:db:mysql
116
+ 1. `rake`
117
+
118
+ ## Skiima Goals:
7
119
  * Provide a better way to integrate views and functions into Ruby applications.
8
120
  * Embeddable in gems to create DB independent extensions.
9
121
  * Avoid any unnecessary dependencies or complexity.
10
122
 
11
- I was working on another project and added some cool features that relied on postgres views, rules, etc. And basically, I needed a place to put these scripts and a way to execute them in a specified order.
123
+ I was working on another project and added some cool features that relied on postgres views, rules, etc. And basically, I needed a place to put these scripts and a way to execute them in a specified order.
12
124
 
13
125
  There are alot of cool tricks to use in ActiveRecord with sql objects other than tables. Not to mention there are performance benefits with the right schema. Not everything needs to happen at the application layer.
14
126
 
15
127
  If you have any questions about how things work, look at the tests. If you have any suggestions, don't hesitate to contact me.
16
128
 
17
- #### Supported Databases:
18
- ##### Postgres
129
+ ## Supported Databases:
130
+ #### Postgres
19
131
 
20
132
  - Schemas
21
133
  - Tables
@@ -25,7 +137,7 @@ If you have any questions about how things work, look at the tests. If you have
25
137
  - Triggers(soon)
26
138
  - Functions(soon)
27
139
 
28
- ##### Mysql/Mysql2
140
+ #### Mysql/Mysql2
29
141
 
30
142
  - Tables
31
143
  - Views
@@ -34,36 +146,36 @@ If you have any questions about how things work, look at the tests. If you have
34
146
  - Functions(soon)
35
147
  - Procs(soon)
36
148
 
37
- #### Interface:
38
- ##### Config Files
39
- Skiima reads two yaml files: database.yml and depends.yml.
149
+ ## Interface:
150
+ #### Config Files
151
+ Skiima reads two yaml files: database.yml and dependencies.yml.
40
152
 
41
153
  - By default, `database.yml` goes in your `APP_ROOT/config directory`.
42
- - And similarly, `depends.yml` goes in `APP_ROOT/db/skiima`.
154
+ - And similarly, `dependencies.yml` goes in `APP_ROOT/db/skiima`.
43
155
 
44
- ##### Groups
156
+ #### Groups
45
157
  Skiima allows you to create groups of sql scripts to be executed during migrations. Each group of sql scripts requires its own folder inside `db/skiima`.
46
158
 
47
- ##### Adapter and Version
159
+ #### Adapter and Version
48
160
  Since different databases have different capabilities and object types, you can trigger different scripts to run per adapter. Furthermore, you can execute different scripts for different versions of a database. You can also use this version tag if you want to package different sets of functionality.
49
161
 
50
- ##### Depends.yml Format
51
- In the `depends.yml` configuration, add lines for each script in the format.
162
+ #### Dependencies.yml Format
163
+ In the `dependencies.yml` configuration, add lines for each script in the format.
52
164
 
53
165
  * `type.name.attr1.attr2`
54
166
 
55
167
  `attr1` and `attr2` allow you to define the target SQL object and other attributes that need to be passed on a per type basis. This is only used when Skiima drops your objects without a matching 'drop' script.
56
168
 
57
- ##### Filename Format
58
- Inside each group folder, create sql files with the following format. These need to match the `depends.yml` configuration.
169
+ #### Filename Format
170
+ Inside each group folder, create sql files with the following format. These need to match the `dependencies.yml` configuration.
59
171
 
60
172
  * `type.name.adapter.version.sql`
61
173
  * `type.name.adapter.version.drop.sql` to override the default drop behavior.
62
174
 
63
- ##### Interpolation in Scripts
175
+ #### Interpolation in Scripts
64
176
  You can interpolate variables in your SQL Scripts and then pass in values at runtime with the `:vars` hash. The default character to use for interpolation is `&`, but this can be changed in the Module initialization. There are default vars that are substituted, such as `&database`.
65
177
 
66
- ##### Module Initialization
178
+ #### Module Initialization
67
179
  If you're using Rails, you can add a Skiima.setup block in an intializer file to set defaults. There are other ways to integrate Skiima into your project as well.
68
180
 
69
181
  Skiima.setup do |config|
@@ -73,15 +185,50 @@ If you're using Rails, you can add a Skiima.setup block in an intializer file to
73
185
  config.locale = :en
74
186
  end
75
187
 
76
- ##### Finally, in your Migrations
77
- Skiima reads the specified groups from depends.yml and compiles a list of scripts to run. If you're using Rails, substitute `:development` with `Rails.env`
188
+ #### Finally, in your Migrations
189
+ Skiima reads the specified groups from dependencies.yml and compiles a list of scripts to run. If you're using Rails, substitute `:development` with `Rails.env`
78
190
 
79
191
  def up
80
192
  Skiima.up(:development, :group_one, :group_n, :vars => {:var_one => 'db_name'})
81
193
  end
82
-
194
+
83
195
  def down
84
196
  Skiima.down(:development, :group_one, :group_n, :vars => {:var_one => 'db_name'})
85
197
  end
86
198
 
87
- #### yes, i know i am shamelessly biting activerecord code.
199
+ ## 0.2.000 Updates:
200
+
201
+ - Added a modified OpenStruct to manage configuration
202
+ - Moved most classes to separate files
203
+
204
+ ## 0.2.010 Updates:
205
+
206
+ - Add Skiima::Db::Connector
207
+ - Update Skiima::Db::Resolver
208
+ - Add ActiveRecord::BaseConnector
209
+ - Add PosgresqlConnector
210
+ - Add Postresql Helpers
211
+ - Add MysqlConnector
212
+ - Add Mysql2Connector
213
+ - Add Mysql Helpers
214
+
215
+ ## 0.2.011 Updates:
216
+
217
+ - Add Travis CI Config
218
+ - Add Railties tasks
219
+ - Updated dependencies.yml to allow for dependency groups
220
+ - Updated Readme with examples
221
+
222
+ ## 0.2.100 Planned:
223
+
224
+ - Add JRuby Support
225
+ - Add Appraisal to test Skiima with separate bundles
226
+ - Add Coveralls?
227
+ - Add Gemnasium?
228
+
229
+ ## 0.3 Planned:
230
+
231
+ - DataMapper Support
232
+ - Sequel Support
233
+ - Mongo Support?
234
+ - Manage config's for other data providers? (Redis/etc)
data/Rakefile CHANGED
@@ -6,7 +6,6 @@ require 'skiima'
6
6
 
7
7
  SPEC_ROOT = File.join(File.dirname(__FILE__), 'spec')
8
8
 
9
-
10
9
  Rake::TestTask.new do |t|
11
10
  t.libs << "spec"
12
11
  t.test_files = FileList['spec/**/*_spec.rb']
@@ -15,34 +14,39 @@ end
15
14
 
16
15
  task :default => :test
17
16
 
18
- namespace :test do
19
- namespace :prepare do
17
+ namespace :skiima do
18
+
19
+ task :setup do
20
+ Skiima.setup do |config|
21
+ config.root_path = SPEC_ROOT
22
+ config.config_path = 'config'
23
+ config.scripts_path = 'db/skiima'
24
+ config.locale = :en
25
+ end
26
+ end
27
+
28
+ namespace :setup do
29
+ namespace :db do
30
+
31
+ task :postgresql => :'skiima:setup' do
32
+ env = :postgresql_root
33
+ test_env = :postgresql_test
34
+ db = Skiima.read_db_yml(Skiima.full_database_path)
35
+ vars = { database: db[test_env]['database'], testuser: 'skiima', testpass: 'test'}
20
36
 
21
- task :postgresql do
22
- Skiima.setup do |config|
23
- config.root_path = SPEC_ROOT
24
- config.config_path = 'config'
25
- config.scripts_path = 'db/skiima'
26
- config.locale = :en
37
+ Skiima.up(env, :init_test_db, vars: vars)
27
38
  end
28
39
 
29
- db_config = Skiima.read_db_yaml(Skiima.full_database_path)[:development]
30
- Skiima.new(:development)
31
- Skiima.read_sql_file('init_test_db', 'database.skiima_test.postgresql.current.sql')
32
- end
40
+ task :mysql => :'skiima:setup' do
41
+ env = :mysql_root
42
+ test_env = :mysql_test
43
+ db = Skiima.read_db_yml(Skiima.full_database_path)
44
+ vars = { database: db[test_env]['database'], testuser: 'skiima', testpass: 'test'}
33
45
 
34
- task :mysql do
35
- Skiima.setup do |config|
36
- config.root_path = SPEC_ROOT
37
- config.config_path = 'config'
38
- config.scripts_path = 'db/skiima'
39
- config.locale = :en
46
+ Skiima.up(env, :init_test_db, vars: vars)
40
47
  end
41
48
 
42
- db_config = Skiima.read_db_yaml(Skiima.full_database_path)
43
- Skiima.read_sql_file('init_test_db', 'database.skiima_test.mysql.current.sql')
44
49
  end
45
-
46
50
  end
47
51
  end
48
52