squasher 0.5.0 → 0.5.1

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: 60335f7e6ad04a4db267dd1ad99152aa02d79242
4
- data.tar.gz: 4c17e356d84255ae3177094facf40904845e8223
3
+ metadata.gz: 3d724bebcea027694c4fd7ae07faefc4e640cd9d
4
+ data.tar.gz: d7b96e31bb8f2c6bf26ffbad436502e1763a27cc
5
5
  SHA512:
6
- metadata.gz: 74cd4d6ba164431b5ab92d2a57af1ac197a3cf66b790332386d29c0e305c448b4063e9119f7d22b9623a7d4145d387de7ac77ef38dfeaa216baafe86b716c20f
7
- data.tar.gz: f6b728c61110d26e8fa647b58b8e37a02ceac6ac32f74fb6111eec377f475d983faa59d74be91ce633447e82c40fd2a2625b19fba1fd48c1d229c355c4baa735
6
+ metadata.gz: 576496807d697dfaf1498c6fc63f4b743a5c663efb1559ed477bae63f1b5ad7b9ee9722244fdc2cd2e7b07ee014ec6eba2f7021b56b4f5c9da1b9bff4876861d
7
+ data.tar.gz: 462a6477e481b454d5eac1f723a46a37cabb4893dd63b774c34582c2f8293d89aa48c24fef88c696831d0ed6f5e34f454e3ddfc15cb82ac5df6b28fbf476e7f2
data/README.md CHANGED
@@ -59,19 +59,19 @@ You can tell `squasher` a more detailed date, for example:
59
59
 
60
60
  ### Options
61
61
 
62
- `-d` - execute in **dry** mode - test a squashing process without deleting old migrations. The final output will be
62
+ `-d/--dry` - execute in **dry** mode - test a squashing process without deleting old migrations. The final output will be
63
63
  printed in the console.
64
64
 
65
- `-r` - reuse a database from previous squashing process. The option can be used in the next cases:
65
+ `-r/--reuse` - reuse a database from previous squashing process. The option can be used in the next cases:
66
66
  - you've run squasher in **dry** mode before and there were no errors
67
67
  - you're squashing migrations gradually. For example, you want to squash migrations from 2013 till 2015, but the
68
68
  process breaks in a migration from 2014. In this situation you squash till 2014, save the squasher's
69
69
  database at the end, make a patch in the broken migration and run again the suite with `-r` option. As the result
70
70
  squasher will not need to create the db schema and all data from the previous migrations will be there.
71
71
 
72
- `-e` - tell squasher that you are squashing a Rails engine. To squash migrations you need to configure a dummy app. If your dummy app located outside the engine's folder provide path to it as the next argument `squasher -e ../my-engine-app 2016`
72
+ `-e/--engine` - tell squasher that you are squashing a Rails engine. To squash migrations you need to configure a dummy app. If your dummy app located outside the engine's folder provide path to it as the next argument `squasher --engine ../my-engine-app 2016`
73
73
 
74
- `-m` - for correct work with Rails 5 specify a migration version like `squasher -m 5.0 ...`
74
+ `-m/--migration` - for correct work with Rails 5 specify a migration version like `squasher -m 5.0 ...`
75
75
 
76
76
  ## Requirements
77
77
 
@@ -79,6 +79,10 @@ It works and was tested on Ruby 2.0+ and Rails 3.1+. It also requires a valid de
79
79
  If an old migration inserted data (created ActiveRecord model records) you will lose this code in the squashed migration, **BUT** `squasher` will ask you to leave a tmp database which will have all data that was inserted while migrating. Using this database you could add that data as another migration, or into `config/seed.rb` (the expected place for this stuff).
80
80
 
81
81
  ## Changelog
82
+ - 0.5.1
83
+ - Fix work on Windows machines ([@tobmatth](https://github.com/tobmatth))
84
+ - 0.5.0
85
+ - Rework command line integration. Fix clean process with Rails 5
82
86
  - 0.4.0
83
87
  - Support rails versioned migrations which were introduced in Rails 5
84
88
  - 0.3.1
data/lib/squasher.rb CHANGED
@@ -26,7 +26,8 @@ module Squasher
26
26
  def rake(command, description = nil)
27
27
  tell(description) if description
28
28
  config.in_app_root do
29
- system("RAILS_ENV=development DISABLE_DATABASE_ENVIRONMENT_CHECK=1 bundle exec rake #{ command }")
29
+ env = { 'RAILS_ENV' => 'development', 'DISABLE_DATABASE_ENVIRONMENT_CHECK' => '1' }
30
+ system(env, "bundle exec rake #{ command }")
30
31
  end
31
32
  end
32
33
 
@@ -39,6 +40,10 @@ module Squasher
39
40
  message = messages.fetch(key.to_s)
40
41
  message = message.join("\n") if message.is_a?(Array)
41
42
  message = colorize(message)
43
+ print(message, options)
44
+ end
45
+
46
+ def print(message, options = {})
42
47
  puts message % options
43
48
  end
44
49
 
@@ -1,3 +1,3 @@
1
1
  module Squasher
2
- VERSION = "0.5.0"
2
+ VERSION = "0.5.1"
3
3
  end
@@ -18,7 +18,7 @@ module Squasher
18
18
  result = under_squash_env do
19
19
  if Squasher.config.set?(:dry)
20
20
  Squasher.tell(:dry_mode_finished)
21
- puts Render.render(:init_schema, config)
21
+ Squasher.print(Render.render(:init_schema, config))
22
22
  else
23
23
  path = config.migration_file(finish_timestamp, :init_schema)
24
24
  File.open(path, 'wb') { |io| io << Render.render(:init_schema, config) }
@@ -10,4 +10,40 @@ describe Squasher do
10
10
  Squasher.squash(input, [])
11
11
  end
12
12
  end
13
+
14
+ context '.rake' do
15
+ before do
16
+ allow_any_instance_of(Object).to receive(:system)
17
+ end
18
+
19
+ context 'when given a description' do
20
+ it 'outputs it' do
21
+ expect(Squasher).to receive(:tell).with('description')
22
+ Squasher.rake('db:migrate', 'description')
23
+ end
24
+ end
25
+
26
+ it 'switches to the app root before running a given command' do
27
+ allow(Dir).to receive(:pwd) { fake_root }
28
+ expect(Dir).to receive(:chdir).with(fake_root)
29
+ Squasher.rake('db:migrate')
30
+ end
31
+
32
+ it 'runs a given command' do
33
+ expect_any_instance_of(Object).to receive(:system).with(anything, /db:migrate/)
34
+ Squasher.rake('db:migrate')
35
+ end
36
+
37
+ it 'sets the Rails environment to development' do
38
+ expect_any_instance_of(Object).to receive(:system)
39
+ .with(hash_including('RAILS_ENV' => 'development'), /db:migrate/)
40
+ Squasher.rake('db:migrate')
41
+ end
42
+
43
+ it 'disables database environment check' do
44
+ expect_any_instance_of(Object).to receive(:system)
45
+ .with(hash_including('DISABLE_DATABASE_ENVIRONMENT_CHECK' => '1'), /db:migrate/)
46
+ Squasher.rake('db:migrate')
47
+ end
48
+ end
13
49
  end
data/spec/spec_helper.rb CHANGED
@@ -10,6 +10,9 @@ module Squasher
10
10
  File.join(File.dirname(__FILE__), 'fake_app')
11
11
  end
12
12
  end
13
+
14
+ def puts(*)
15
+ end
13
16
  end
14
17
 
15
18
  require 'bundler/setup'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: squasher
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergey Pchelintsev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-03 00:00:00.000000000 Z
11
+ date: 2017-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler