miguel 0.1.0.pre6 → 0.1.0.pre7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 46b9b8bd87e9bbcb4d68e8a4b0687709dd477b4a
4
- data.tar.gz: d5386b82cf60542e68e3bacfce52407d4242dd25
3
+ metadata.gz: c9d433cde1f5c11fbaa6f05447d646c48164a9ae
4
+ data.tar.gz: fc5cdeef2a2ddd96b23fdc815dbfd4e7befd91d8
5
5
  SHA512:
6
- metadata.gz: 9aae54cd7492a54b558931ccecb008d07559db82d3864b690bd27dde855864eaac4e3d72d9dfaff22a5d7de0f2fc732a65a63e5eed7b291e0e2a68296fa2e7b3
7
- data.tar.gz: 59015a5b44a5f50c107ddda26d7f5369f08b732c8f0c8baaa64406c5dd6d9feb834655d3fde72a72d1d9098813460c6d2e3956cd92d4e67b6d2dd105c324fb78
6
+ metadata.gz: e3f618e52170198078448a50a0fb7673958a5ed3ef7e01eb42226035008e7219d61e5851d7c4b7ceed82bb5e0c878ca95c6cc5b813fbf09684af94e28eaaacb7
7
+ data.tar.gz: dd7b64ea4f90f82af8112405a268690311f2ad6d82fce7beab3c7c042394dbf1d0d482c91c8e24b9c12a493e22c3d72f4cb70248158c31adb9d914295486b337
data/.gitignore CHANGED
@@ -1,2 +1,3 @@
1
1
  *~
2
2
  /miguel-*.gem
3
+ /coverage
@@ -165,7 +165,7 @@ module Miguel
165
165
  elsif File.exist?( name )
166
166
  config = load_db_config( name )
167
167
  Sequel.connect( config )
168
- elsif name =~ /:\/\//
168
+ elsif name =~ /:/
169
169
  Sequel.connect( name )
170
170
  else
171
171
  fail "Database config #{name} not found."
data/lib/miguel/schema.rb CHANGED
@@ -548,7 +548,7 @@ module Miguel
548
548
  # not the default :Integer, and :integer can't be specified for compound keys,
549
549
  # so we have to use the callback to set the type only at correct times.
550
550
  # Furthermore, Postgres's autoincrementing serials only work with Integer,
551
- # so we set the type only as long as the unsigned keys are not requested.
551
+ # so we set the type only as long as the unsigned keys are requested.
552
552
 
553
553
  unsigned_keys = !! opts[ :unsigned_keys ]
554
554
 
data/miguel.gemspec CHANGED
@@ -4,7 +4,7 @@ require File.expand_path( '../lib/miguel/version', __FILE__ )
4
4
 
5
5
  Gem::Specification.new do |s|
6
6
  s.name = 'miguel'
7
- s.version = Miguel::VERSION + '.pre6'
7
+ s.version = Miguel::VERSION + '.pre7'
8
8
  s.summary = 'Database migrator and migration generator for Sequel.'
9
9
  s.description = <<EOT
10
10
  This gem makes it easy to create and maintain an up-to-date database schema
@@ -13,7 +13,7 @@ EOT
13
13
 
14
14
  s.author = 'Patrik Rak'
15
15
  s.email = 'patrik@raxoft.cz'
16
- s.homepage = 'http://rubygems.org/gems/miguel'
16
+ s.homepage = 'https://github.com/raxoft/miguel'
17
17
  s.license = 'MIT'
18
18
 
19
19
  s.files = `git ls-files`.split( "\n" )
data/test/coverage.rb ADDED
@@ -0,0 +1,9 @@
1
+ # Enable coverage testing in external command.
2
+
3
+ require 'simplecov'
4
+ SimpleCov.start do
5
+ command_name ENV[ 'COVERAGE_COMMAND_NAME' ] || "#{$PROGRAM_NAME} #{ARGV.join( ' ' )}"
6
+ formatter SimpleCov::Formatter::SimpleFormatter
7
+ end
8
+
9
+ # EOF #
@@ -0,0 +1,15 @@
1
+ # Database configuration for JRuby.
2
+
3
+ development:
4
+ adapter: jdbc
5
+ url: 'jdbc:sqlite::memory:'
6
+
7
+ mysql:
8
+ adapter: jdbc
9
+ url: 'jdbc:mysql://localhost/miguel_test?user=travis&password='
10
+
11
+ postgres:
12
+ adapter: jdbc
13
+ url: 'jdbc:postgresql://localhost/miguel_test?user=postgres'
14
+
15
+ # EOF #
data/test/helper.rb CHANGED
@@ -2,11 +2,21 @@
2
2
 
3
3
  # Test coverage if enabled.
4
4
 
5
+ def jruby?
6
+ defined?( RUBY_ENGINE ) and RUBY_ENGINE == 'jruby'
7
+ end
8
+
9
+ if ENV[ 'COVERAGE' ]
10
+ require 'simplecov'
11
+ SimpleCov.start
12
+ end
13
+
5
14
  begin
6
- require "codeclimate-test-reporter"
15
+ require 'codeclimate-test-reporter'
7
16
  CodeClimate::TestReporter.start
17
+ ENV[ 'COVERAGE' ] = 'on'
8
18
  rescue LoadError
9
- end
19
+ end unless jruby?
10
20
 
11
21
  # Setup helpers.
12
22
 
@@ -16,6 +26,10 @@ SEQ_COUNT = Dir[ "#{DATA_DIR}/seq_*.rb" ].count
16
26
 
17
27
  class Bacon::Context
18
28
 
29
+ def database_config
30
+ jruby? ? 'jruby.yml' : 'db.yml'
31
+ end
32
+
19
33
  def data( name )
20
34
  "#{DATA_DIR}/#{name}"
21
35
  end
data/test/test_command.rb CHANGED
@@ -19,7 +19,7 @@ describe Miguel::Command do
19
19
  end
20
20
 
21
21
  def with_tempfile( content = nil, extension = 'rb' )
22
- f = Tempfile.new( [ 'miguel', ".#{extension}" ] )
22
+ f = Tempfile.new( [ 'miguel', "-#{content ? content.hash : 'new'}.#{extension}" ] )
23
23
  if content
24
24
  f.write( content )
25
25
  f.flush
@@ -31,9 +31,17 @@ describe Miguel::Command do
31
31
  f.unlink
32
32
  end
33
33
 
34
+ def sequence_number
35
+ @sequence_number = @sequence_number.to_i + 1
36
+ end
37
+
34
38
  def run( *args )
39
+ if ENV[ 'COVERAGE' ]
40
+ coverage = %w[ -r ./test/coverage ]
41
+ ENV[ 'COVERAGE_COMMAND_NAME' ] = "Command Test ##{sequence_number}"
42
+ end
35
43
  out = err = nil
36
- Open3.popen3( 'ruby', 'bin/miguel', *args ) do |i, o, e, t|
44
+ Open3.popen3( 'ruby', *coverage, 'bin/miguel', *args ) do |i, o, e, t|
37
45
  yield i if block_given?
38
46
  i.close
39
47
  out = o.read
@@ -79,57 +87,59 @@ describe Miguel::Command do
79
87
  end
80
88
 
81
89
  should 'show changes needed to migrate from one schema to another' do
82
- schema = 'sqlite://'
83
- SEQ_COUNT.times do |i|
84
- new_schema = data( "seq_#{i}.rb" )
85
- out = test( 'diff', '-m', 'full', schema, new_schema )
86
- match_file( out, "seq_#{i}.txt" )
87
- schema = new_schema
90
+ with_tempfile( nil, 'db' ) do |path|
91
+ schema = jruby? ? "jdbc:sqlite:#{path}" : "sqlite://#{path}"
92
+ SEQ_COUNT.times do |i|
93
+ new_schema = data( "seq_#{i}.rb" )
94
+ out = test( 'diff', '-m', 'full', schema, new_schema )
95
+ match_file( out, "seq_#{i}.txt" )
96
+ schema = new_schema
97
+ end
88
98
  end
89
99
  end
90
100
 
91
101
  should 'apply schema to the database' do
92
- test( 'apply', '--env', 'mysql', data( 'db.yml' ), data( 'schema.rb' ), '--force' ).should.not.be.empty
93
- test( 'apply', '--env', 'mysql', data( 'db.yml' ), data( 'schema.rb' ), '--force' ).should.match /\ANo changes are necessary\.\Z/
102
+ test( 'apply', '--env', 'mysql', data( database_config ), data( 'schema.rb' ), '--force' ).should.not.be.empty
103
+ test( 'apply', '--env', 'mysql', data( database_config ), data( 'schema.rb' ), '--force' ).should.match /\ANo changes are necessary\.\Z/
94
104
  end
95
105
 
96
106
  should 'be able to clear the entire database' do
97
- test( 'apply', '--env', 'mysql', data( 'db.yml' ), data( 'schema.rb' ), '--force' )
98
- test( 'clear', '--env', 'mysql', data( 'db.yml' ), '--force' ).should.not.be.empty
99
- test( 'clear', '--env', 'mysql', data( 'db.yml' ), '--force' ).should.match /\ANo changes are necessary\.\Z/
107
+ test( 'apply', '--env', 'mysql', data( database_config ), data( 'schema.rb' ), '--force' )
108
+ test( 'clear', '--env', 'mysql', data( database_config ), '--force' ).should.not.be.empty
109
+ test( 'clear', '--env', 'mysql', data( database_config ), '--force' ).should.match /\ANo changes are necessary\.\Z/
100
110
  end
101
111
 
102
112
  should 'require confirmation before changing the database' do
103
- out, err = run( 'apply', '--env', 'mysql', data( 'db.yml' ), data( 'schema.rb' ) )
113
+ out, err = run( 'apply', '--env', 'mysql', data( database_config ), data( 'schema.rb' ) )
104
114
  out.should.match /^Confirm \(yes or no\)\?/
105
115
  err.should.match /\AOK, aborting\.\Z/
106
116
 
107
- out, err = run( 'apply', '--env', 'mysql', data( 'db.yml' ), data( 'schema.rb' ) ) do |input|
117
+ out, err = run( 'apply', '--env', 'mysql', data( database_config ), data( 'schema.rb' ) ) do |input|
108
118
  input.write 'blah'
109
119
  end
110
120
  out.should.match /^Confirm \(yes or no\)\?/
111
121
  out.should.match /Please answer 'yes' or 'no'\.$/
112
122
  err.should.match /\AOK, aborting\.\Z/
113
123
 
114
- out, err = run( 'apply', '--env', 'mysql', data( 'db.yml' ), data( 'schema.rb' ) ) do |input|
124
+ out, err = run( 'apply', '--env', 'mysql', data( database_config ), data( 'schema.rb' ) ) do |input|
115
125
  input.write 'no'
116
126
  end
117
127
  out.should.match /^Confirm \(yes or no\)\?/
118
128
  out.should.not.match /Please answer 'yes' or 'no'\.$/
119
129
  err.should.match /\AOK, aborting\.\Z/
120
130
 
121
- out, err = run( 'apply', '--env', 'mysql', data( 'db.yml' ), data( 'schema.rb' ) ) do |input|
131
+ out, err = run( 'apply', '--env', 'mysql', data( database_config ), data( 'schema.rb' ) ) do |input|
122
132
  input.write 'yes'
123
133
  end
124
134
  out.should.match /^Confirm \(yes or no\)\?/
125
135
  out.should.match /OK, those changes were applied\./
126
136
  err.should.be.empty
127
137
 
128
- out, err = run( 'clear', '--env', 'mysql', data( 'db.yml' ) )
138
+ out, err = run( 'clear', '--env', 'mysql', data( database_config ) )
129
139
  out.should.match /^Confirm \(yes or no\)\?/
130
140
  err.should.match /\AOK, aborting\.\Z/
131
141
 
132
- out, err = run( 'clear', '--env', 'mysql', data( 'db.yml' ) ) do |input|
142
+ out, err = run( 'clear', '--env', 'mysql', data( database_config ) ) do |input|
133
143
  input.write 'yes'
134
144
  end
135
145
  out.should.match /^Confirm \(yes or no\)\?/
@@ -138,19 +148,19 @@ describe Miguel::Command do
138
148
  end
139
149
 
140
150
  should 'show no changes when told so' do
141
- test( 'apply', '--env', 'mysql', data( 'db.yml' ), data( 'schema.rb' ), '--force', '--quiet' ).should.be.empty
142
- test( 'apply', '--env', 'mysql', data( 'db.yml' ), data( 'schema.rb' ), '--force', '--quiet' ).should.be.empty
143
- test( 'clear', '--env', 'mysql', data( 'db.yml' ), '--force', '--quiet' ).should.be.empty
144
- test( 'clear', '--env', 'mysql', data( 'db.yml' ), '--force', '--quiet' ).should.be.empty
151
+ test( 'apply', '--env', 'mysql', data( database_config ), data( 'schema.rb' ), '--force', '--quiet' ).should.be.empty
152
+ test( 'apply', '--env', 'mysql', data( database_config ), data( 'schema.rb' ), '--force', '--quiet' ).should.be.empty
153
+ test( 'clear', '--env', 'mysql', data( database_config ), '--force', '--quiet' ).should.be.empty
154
+ test( 'clear', '--env', 'mysql', data( database_config ), '--force', '--quiet' ).should.be.empty
145
155
  end
146
156
 
147
157
  should 'log SQL commands to stdout when requested' do
148
- test( 'show', '--env', 'mysql', data( 'db.yml' ), '--echo' ).should.match /SHOW FULL TABLES/
158
+ test( 'show', '--env', 'mysql', data( database_config ), '--echo' ).should.match /SHOW FULL TABLES/
149
159
  end
150
160
 
151
161
  should 'log SQL commands to given file when requested' do
152
162
  with_tempfile do |path|
153
- test( 'show', '--env', 'mysql', data( 'db.yml' ), '--log', path )
163
+ test( 'show', '--env', 'mysql', data( database_config ), '--log', path )
154
164
  File.read( path ).should.match /SHOW FULL TABLES/
155
165
  end
156
166
  end
@@ -38,7 +38,7 @@ describe Miguel::Importer do
38
38
  end
39
39
 
40
40
  def databases
41
- YAML.load_file( data( 'db.yml' ) ).map do |env, config|
41
+ YAML.load_file( data( database_config ) ).map do |env, config|
42
42
  Sequel.connect( config )
43
43
  end
44
44
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: miguel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.pre6
4
+ version: 0.1.0.pre7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patrik Rak
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-05 00:00:00.000000000 Z
11
+ date: 2015-10-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sequel
@@ -94,7 +94,6 @@ files:
94
94
  - ".travis.yml"
95
95
  - README.md
96
96
  - Rakefile
97
- - TODO
98
97
  - bin/miguel
99
98
  - examples/db.yml
100
99
  - examples/schema.rb
@@ -106,7 +105,9 @@ files:
106
105
  - lib/miguel/schema.rb
107
106
  - lib/miguel/version.rb
108
107
  - miguel.gemspec
108
+ - test/coverage.rb
109
109
  - test/data/db.yml
110
+ - test/data/jruby.yml
110
111
  - test/data/schema.rb
111
112
  - test/data/schema.txt
112
113
  - test/data/schema_bare.txt
@@ -128,7 +129,7 @@ files:
128
129
  - test/test_importer.rb
129
130
  - test/test_migrator.rb
130
131
  - test/test_schema.rb
131
- homepage: http://rubygems.org/gems/miguel
132
+ homepage: https://github.com/raxoft/miguel
132
133
  licenses:
133
134
  - MIT
134
135
  metadata: {}
data/TODO DELETED
@@ -1 +0,0 @@
1
- add tests