mince_migrator 1.0.0 → 1.0.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: 41b113ade7cbebb55bd8640f1f1a49739a1ba0c0
4
- data.tar.gz: cb22a342cd4f20d89ecf0d0bd99a1b577566bde2
3
+ metadata.gz: 2645b8a38ac118c432757c8a5efccb6b691bb16d
4
+ data.tar.gz: 5ee1e303a5cf09400e183957babea7c507752b70
5
5
  SHA512:
6
- metadata.gz: a02d661a150eb49a28aea7e37ab96f9d69e979e9531bb0072aac2de525e1bb56eda2c31675f16e6285e95f7e46bfad678b13be914cfcb0579b1302feb7458a2f
7
- data.tar.gz: 2d58ae4f149108c101ac01e939ddba2f5afc37e224d2fb6133054bdb4588cc559d3b1625563da847447e21fe3c46ca62b20882c87f9be2a835cad077d09bed2a
6
+ metadata.gz: 7b26ef928f0c524bb485ee7dc05d46261d5431cdfd81109004bc4f7a72a924bffeb5ada874e528663f032ae0f4eefef84e136d3493a5cae1927920ea36d97067
7
+ data.tar.gz: 3d76da888ba05bf3a03ed2c92b78b77369271d2a5ca0933e6ef9a92d46c4b323863c3bf772623ce76a63709748638acadb017d8de7c43391b9e22a2acfc478ea
data/bin/mince_migrator CHANGED
@@ -4,39 +4,46 @@ require 'mince_migrator/version'
4
4
  require 'mince_migrator/list'
5
5
  require 'mince_migrator/cli_helper'
6
6
 
7
- include GLI::App
8
7
  include MinceMigrator::CliHelper
9
8
 
10
- program_desc 'Manages database migrations for ruby applications'
11
- version MinceMigrator.version
9
+ module MinceMigrator
10
+ class CliApp
11
+ include GLI::App
12
+ end
13
+ end
14
+
15
+ mince_migrator_cli_app = MinceMigrator::CliApp.new
12
16
 
13
- desc 'Creates a migration'
14
- arg_name 'Name of migration'
15
- command :create do |c|
17
+ mince_migrator_cli_app.program_desc 'Manages database migrations for ruby applications'
18
+ mince_migrator_cli_app.version MinceMigrator.version
19
+
20
+ mince_migrator_cli_app.desc 'Creates a migration'
21
+ mince_migrator_cli_app.arg_name 'Name of migration'
22
+ mince_migrator_cli_app.command :create do |c|
16
23
  c.action do |global_options,options,args|
17
24
  name = args.join(" ")
18
25
  create_migration(name)
19
26
  end
20
27
  end
21
28
 
22
- desc 'Lists all migrations and their statuses'
23
- command :list do |c|
29
+ mince_migrator_cli_app.desc 'Lists all migrations and their statuses'
30
+ mince_migrator_cli_app.command :list do |c|
24
31
  c.action do |global_options,options,args|
25
32
  list_migrations(MinceMigrator::List.new)
26
33
  end
27
34
  end
28
35
 
29
- desc 'Reverts a migration'
30
- arg_name 'Name of migration'
31
- command :revert do |c|
36
+ mince_migrator_cli_app.desc 'Reverts a migration'
37
+ mince_migrator_cli_app.arg_name 'Name of migration'
38
+ mince_migrator_cli_app.command :revert do |c|
32
39
  c.action do |global_options,options,args|
33
40
  name = args.join(" ")
34
41
  revert_migration(name: name)
35
42
  end
36
43
  end
37
44
 
38
- desc 'Deletes all migrations that have already ran'
39
- command :delete_ran do |c|
45
+ mince_migrator_cli_app.desc 'Deletes all migrations that have already ran'
46
+ mince_migrator_cli_app.command :delete_ran do |c|
40
47
  c.action do |global_options,options,args|
41
48
  list = MinceMigrator::List.new('ran')
42
49
  if list.all.any?
@@ -49,9 +56,9 @@ command :delete_ran do |c|
49
56
  end
50
57
  end
51
58
 
52
- desc 'Deletes a migration'
53
- arg_name 'Name of migration'
54
- command :delete do |c|
59
+ mince_migrator_cli_app.desc 'Deletes a migration'
60
+ mince_migrator_cli_app.arg_name 'Name of migration'
61
+ mince_migrator_cli_app.command :delete do |c|
55
62
  c.action do |global_options,options,args|
56
63
  name = args.join(" ")
57
64
 
@@ -59,9 +66,9 @@ command :delete do |c|
59
66
  end
60
67
  end
61
68
 
62
- desc 'Runs a migration'
63
- arg_name 'Name of migration'
64
- command :run do |c|
69
+ mince_migrator_cli_app.desc 'Runs a migration'
70
+ mince_migrator_cli_app.arg_name 'Name of migration'
71
+ mince_migrator_cli_app.command :run do |c|
65
72
  c.action do |global_options,options,args|
66
73
  name = args.join(" ")
67
74
 
@@ -69,8 +76,8 @@ command :run do |c|
69
76
  end
70
77
  end
71
78
 
72
- desc 'Runs all migrations that have not yet been ran'
73
- command :run_all do |c|
79
+ mince_migrator_cli_app.desc 'Runs all migrations that have not yet been ran'
80
+ mince_migrator_cli_app.command :run_all do |c|
74
81
  c.action do
75
82
  list = MinceMigrator::List.new('not ran')
76
83
  if list.all.any?
@@ -83,9 +90,9 @@ command :run_all do |c|
83
90
  end
84
91
  end
85
92
 
86
- desc 'Shows the details of a migration'
87
- arg_name 'Name of migration'
88
- command :show do |c|
93
+ mince_migrator_cli_app.desc 'Shows the details of a migration'
94
+ mince_migrator_cli_app.arg_name 'Name of migration'
95
+ mince_migrator_cli_app.command :show do |c|
89
96
  c.action do |global_options,options,args|
90
97
  name = args.join(" ")
91
98
 
@@ -97,7 +104,7 @@ command :show do |c|
97
104
  end
98
105
  end
99
106
 
100
- pre do |global,command,options,args|
107
+ mince_migrator_cli_app.pre do |global,command,options,args|
101
108
  # Pre logic here
102
109
  # Return true to proceed; false to abort and not call the
103
110
  # chosen command
@@ -110,16 +117,18 @@ pre do |global,command,options,args|
110
117
  true
111
118
  end
112
119
 
113
- post do |global,command,options,args|
120
+ mince_migrator_cli_app.post do |global,command,options,args|
114
121
  # Post logic here
115
122
  # Use skips_post before a command to skip this
116
123
  # block on that command only
117
124
  end
118
125
 
119
- on_error do |exception|
126
+ mince_migrator_cli_app.on_error do |exception|
120
127
  # Error logic here
121
128
  # return false to skip default error handling
122
- true
129
+ puts exception
130
+ puts exception.backtrace.join("\n")
131
+ false
123
132
  end
124
133
 
125
- exit run(ARGV)
134
+ exit mince_migrator_cli_app.run(ARGV)
@@ -5,6 +5,7 @@ module MinceMigrator
5
5
  require_relative 'list'
6
6
  require_relative 'migrations/runner'
7
7
  require_relative 'list_report'
8
+ require_relative 'status_report'
8
9
 
9
10
  module CliHelper
10
11
  def delete_migration(options)
@@ -25,7 +25,11 @@ module MinceMigrator
25
25
  end
26
26
  @list.all.each do |migration|
27
27
  row do
28
- column migration.name
28
+ if migration.name.size > 40
29
+ column "#{migration.name[0..36]}..."
30
+ else
31
+ column migration.name
32
+ end
29
33
  status_column(migration)
30
34
  column migration.age
31
35
  column migration.time_created.strftime("%m/%d/%Y")
@@ -17,7 +17,7 @@ module MinceMigrator
17
17
  table border: false do
18
18
  row do
19
19
  column 'Name', width: 15
20
- column migration.name, width: 30
20
+ column migration.name, width: 100
21
21
  end
22
22
  row do
23
23
  column 'Status'
@@ -9,7 +9,7 @@ module MinceMigrator
9
9
  end
10
10
 
11
11
  def self.patch
12
- 0
12
+ 1
13
13
  end
14
14
  end
15
15
 
@@ -14,7 +14,13 @@ describe MinceMigrator::Migration do
14
14
  its(:time_created) { should == klass.time_created }
15
15
  its(:relative_path) { should == relative_path }
16
16
  its(:path) { should == path }
17
- its(:age) { should == '6d' }
17
+ its(:age) do
18
+ expected = if Time.now.utc.hour < 12
19
+ should include '7d'
20
+ else
21
+ should include '6d'
22
+ end
23
+ end
18
24
 
19
25
  it 'can run the migration' do
20
26
  return_value = mock
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mince_migrator
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Simpson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-05-10 00:00:00.000000000 Z
11
+ date: 2013-05-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mince