post_pusher 1.0.0 → 1.2.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
- SHA1:
3
- metadata.gz: ab7826c0117965f5dcc7227dee0cb9ce28c658d3
4
- data.tar.gz: c8c732f07cfd4f4a780a4bc235ae669e647b0aac
2
+ SHA256:
3
+ metadata.gz: c8c075270ea055b6c37e28f6bd4e5f4d04c2ea444d7e5fd778e7e383872a7af8
4
+ data.tar.gz: 17a834e02031b085ca403a82d9d1ae5266633460d450de239f64c09ae0dcdac0
5
5
  SHA512:
6
- metadata.gz: 16040dcfbb6e034126c2829ebe694bef31ad5ba511400508892beeb05babc0d96416fb2b049ddda37c84a6e6e975c5d32ea64024caa110123bf87df5a975248e
7
- data.tar.gz: 7b224d13fb05419433da875a532b9881220549dd0939330c56d8c5851f68be2238796bb30b79487e090d4f574343f35cd66aeac322c68931c33084734856e703
6
+ metadata.gz: 2dcfca7ce58d41fbc3275ad2363b0ca5fbd7228bf5625daa0b6aac51d49a8950a59a90e2404a7617ff731bdd2e4970b8f7bda3b96f47771df2b255107f871559
7
+ data.tar.gz: df616fa091701d274f76022233d35d0ba2aeaa8c025bdfd9671ee9763e5603e71564f2a316d1dc75d4f76277e922de95aa6141cb3899c7b9d357b1f1d325207b
data/README.md CHANGED
@@ -19,7 +19,7 @@ $ bundle
19
19
  Or install it yourself with:
20
20
 
21
21
  ```
22
- gem install post_pusher
22
+ $ gem install post_pusher
23
23
  ```
24
24
 
25
25
 
@@ -28,20 +28,24 @@ gem install post_pusher
28
28
  No way buddy; getting your post push task ready for a release using PostPusher is super easy.
29
29
 
30
30
  Steps:
31
- -rails g post_push_task task_name
32
- -add your code into the new task
33
- -commit
31
+
32
+ - `rails g post_push_task task_name`
33
+ - add your code into the new task
34
+ - commit
34
35
 
35
36
  Running the tasks:
36
- -bin/post_push work
37
37
 
38
- ## How do I add this to my rails app?
38
+ - `bin/post_push work`
39
+
40
+ ## How do I add this to my Rails app?
39
41
 
40
- -Add PostPusher to your gemfile
41
- -bundle
42
- -Run migrations (creates records table)
43
- -bundle binstub post_pusher (this enables you to be able to run bin/post_push by putting the post_push file in your bin directory)
44
- -Commit your changes
42
+ - Add PostPusher to your gemfile
43
+ - `bundle`
44
+ - `rails g post_pusher:install` (generate migration to create post_push_statuses table)
45
+ - Run migrations (creates records table)
46
+ - `bundle binstub post_pusher` (this enables you to be able to run `bin/post_push` by putting the post_push file in your bin directory)
47
+ - `bundle binstubs bundler --force` (this replaces `bin/bundle` so `bin/post_push` commands work properly)
48
+ - Commit your changes
45
49
 
46
50
  ## Running Tests
47
51
 
@@ -4,7 +4,7 @@ class PostPushTaskGenerator < Rails::Generators::Base
4
4
  desc "Create a post push task"
5
5
  argument :task_name, type: :string
6
6
  def create_post_push_task
7
- template "post_push_task.rake.erb", "lib/tasks/post_push/#{timestamp}_#{task_name}.rake"
7
+ template "post_push_task.rake.erb", "lib/tasks/post_push/#{timestamp}_#{task_name.underscore}.rake"
8
8
  end
9
9
 
10
10
  private
@@ -5,7 +5,7 @@ full_name = "post_push:#{timestamp}:#{task_name}"
5
5
  # When writing your task, be sure to:
6
6
  # * Print out useful information at startup and on completion
7
7
  # * Use a progress bar if the task will take a while
8
- # * Check Rails.env.development? or stage? and skip lengthy operations
8
+ # * Skip lengthy tasks unless we're in prod or the task is run with FORCE
9
9
 
10
10
  namespace :post_push do
11
11
  namespace "<%=timestamp%>" do
@@ -15,6 +15,13 @@ namespace :post_push do
15
15
  puts "---------------------------------------------------------"
16
16
  puts "Starting <%=full_name%> at #{DateTime.now}"
17
17
 
18
+ # If your task takes more than a minute or two to run, consider
19
+ # uncommenting this section so dev and stage environments can skip it
20
+ # unless Rails.env.production? || ENV['FORCE']
21
+ # puts "Skipping <%=task_name%> in #{Rails.env}; to run this specify FORCE=1"
22
+ # next
23
+ # end
24
+
18
25
  total_records = YourModel.count
19
26
  next if total_records.zero?
20
27
  progress_bar = ProgressBar.new(total_records)
@@ -0,0 +1,27 @@
1
+ module PostPusher
2
+ module Generators
3
+ class InstallGenerator < ::Rails::Generators::Base
4
+ include Rails::Generators::Migration
5
+ source_root File.expand_path('../templates', __FILE__)
6
+ desc "add the post_pusher migrations"
7
+
8
+ def self.next_migration_number(path)
9
+ Time.now.utc.to_s(:number)
10
+ end
11
+
12
+ def copy_migrations
13
+ copy_migration "create_post_push_status"
14
+ end
15
+
16
+ protected
17
+
18
+ def copy_migration(filename)
19
+ if self.class.migration_exists?("db/migrate", "#{filename}")
20
+ say_status("skipped", "Migration #{filename}.rb already exists")
21
+ else
22
+ migration_template "#{filename}.rb", "db/migrate/#{filename}.rb"
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
data/lib/post_push_cli.rb CHANGED
@@ -2,6 +2,10 @@ require "thor"
2
2
  require_relative "../lib/post_pusher/rake_task_runner"
3
3
 
4
4
  class PostPushCli < Thor
5
+ def self.exit_on_failure?
6
+ true
7
+ end
8
+
5
9
  desc "work", "Run remaining post push tasks"
6
10
  def work
7
11
  load_rails_env!
@@ -28,6 +32,7 @@ class PostPushCli < Thor
28
32
 
29
33
  success_message "#{succeeded.size} tasks succeeded"
30
34
  error_message "Errors occured in #{failed.size} tasks:\n#{failed.join("\n")}" if failed.any?
35
+ raise "Some tasks failed" if failed.any?
31
36
  end
32
37
 
33
38
  desc "status", "List post push tasks and their status"
data/lib/post_pusher.rb CHANGED
@@ -1,16 +1 @@
1
- # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2
- # STEP 1
3
- # Load all dependent gems.
4
-
5
- # require 'a_dependent_gem'
6
- # require 'another_dependent_gem'
7
- # require 'a_dependent_local_gem'
8
- # ...
9
-
10
- # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
11
- # STEP 2
12
- # Load this gem's code.
13
1
  require "rails"
14
- require "rails/engine"
15
-
16
- require "post_pusher/engine"
@@ -34,7 +34,7 @@ class RakeTaskRunner
34
34
 
35
35
  def log_file_path
36
36
  logs = File.join(Rails.root, "log", "post_push")
37
- Dir.mkdir(logs) unless Dir.exist?(logs)
37
+ FileUtils.mkdir_p(logs) unless Dir.exist?(logs)
38
38
  File.join(logs, "#{log_file_name}.log")
39
39
  end
40
40
 
@@ -1,4 +1,4 @@
1
1
  module PostPusher
2
- VERSION = "1.0.0".freeze
2
+ VERSION = "1.2.1".freeze
3
3
  end
4
4
 
@@ -3,7 +3,6 @@ require File.expand_path("../boot", __FILE__)
3
3
  require "rails/all"
4
4
 
5
5
  Bundler.require(*Rails.groups)
6
- require "post_pusher"
7
6
 
8
7
  module Dummy
9
8
  class Application < Rails::Application
@@ -0,0 +1,7 @@
1
+ class CreatePostPushStatus < (Rails::VERSION::MAJOR >= 5 ? ActiveRecord::Migration[4.2] : ActiveRecord::Migration)
2
+ def change
3
+ create_table :post_push_statuses do |t|
4
+ t.string :task_name, null: false, index: true
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,27 @@
1
+ require 'test_helper'
2
+ require 'fileutils'
3
+ require 'rails/generators'
4
+ require 'generators/post_pusher/install/install_generator'
5
+
6
+ class PostPusher::Generators::InstallGeneratorTest < ::Rails::Generators::TestCase
7
+ TEMP_DIR = File.expand_path("../../../../tmp", __dir__)
8
+ tests PostPusher::Generators::InstallGenerator
9
+ destination TEMP_DIR
10
+
11
+ setup :prepare_destination
12
+
13
+ it 'creates the migration file' do
14
+ run_generator
15
+ assert_migration "db/migrate/create_post_push_status.rb"
16
+ end
17
+
18
+ it 'skips the migration file if it already exists' do
19
+ run_generator
20
+ run_generator
21
+
22
+ files = Dir.entries("#{TEMP_DIR}/db/migrate").reject { |f| f == '.' || f == '..' }
23
+
24
+ assert_equal 1, files.length
25
+ assert_migration "db/migrate/create_post_push_status.rb"
26
+ end
27
+ end
@@ -13,16 +13,16 @@ class PostPushExeTest < ActiveSupport::TestCase
13
13
  end
14
14
 
15
15
  describe "#work" do
16
- setup { subject.work }
17
-
18
16
  # TODO: re-enable this. Solano isn't finding all the tasks (I think),
19
17
  # so this one isn't available. Make it work in a debug console with
20
18
  # bin/solano_run_gem_tests. --sagotsky
21
19
  # it "should mark finished tasks so they dont rerun" do
20
+ # subject.work
22
21
  # completed_tasks.must_include 'post_push:3:runnable_task'
23
22
  # end
24
23
 
25
24
  it "should not mark failed tasks as finished" do
25
+ subject.work rescue nil
26
26
  completed_tasks.wont_include "post_push:1:broken_task"
27
27
  end
28
28
  end
data/test/test_helper.rb CHANGED
@@ -2,7 +2,9 @@ $LOAD_PATH.unshift File.expand_path("../lib", __dir__)
2
2
 
3
3
  require "active_support"
4
4
  require File.expand_path("dummy/config/environment.rb", __dir__)
5
+
5
6
  ActiveSupport::TestCase.test_order = :random # if we don't set this, active_support gives a warning
7
+
6
8
  require "minitest/autorun"
7
9
  require 'minitest/reporters'
8
10
  require "post_pusher"
@@ -27,5 +29,8 @@ class ActiveSupport::TestCase
27
29
  extend MiniTest::Spec::DSL
28
30
  end
29
31
 
30
- ActiveRecord::Migrator.migrate File.expand_path("dummy/db/migrate", __dir__)
31
- ActiveRecord::Migrator.migrate File.expand_path("../db/migrate", __dir__)
32
+ if defined?(ActiveRecord::MigrationContext)
33
+ ActiveRecord::MigrationContext.new(File.expand_path("dummy/db/migrate", __dir__)).up
34
+ else
35
+ ActiveRecord::Migrator.migrate File.expand_path("dummy/db/migrate", __dir__)
36
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: post_pusher
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - PatientsLikeMe
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-04-23 00:00:00.000000000 Z
11
+ date: 2021-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -28,44 +28,44 @@ dependencies:
28
28
  name: sqlite3
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: 1.3.6
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: 1.3.6
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: minitest
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: 5.11.0
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: 5.11.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: minitest-reporters
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: 1.1.11
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '0'
68
+ version: 1.1.11
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: minitest-spec-rails
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -94,6 +94,34 @@ dependencies:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rails
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 5.2.4.3
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 5.2.4.3
111
+ - !ruby/object:Gem::Dependency
112
+ name: sprockets
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: 3.7.2
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: 3.7.2
97
125
  description: A tool to run a set of tasks after deploys
98
126
  email:
99
127
  - engineers@patientslikeme.com
@@ -104,15 +132,15 @@ extra_rdoc_files: []
104
132
  files:
105
133
  - README.md
106
134
  - Rakefile
107
- - db/migrate/20160620190743_create_post_push_status.rb
108
135
  - exe/post_push
109
136
  - lib/generators/post_push_invoke/post_push_invoke_generator.rb
110
137
  - lib/generators/post_push_invoke/templates/post_push_invoke.rake.erb
111
138
  - lib/generators/post_push_task/post_push_task_generator.rb
112
139
  - lib/generators/post_push_task/templates/post_push_task.rake.erb
140
+ - lib/generators/post_pusher/install/install_generator.rb
141
+ - lib/generators/post_pusher/install/templates/create_post_push_status.rb
113
142
  - lib/post_push_cli.rb
114
143
  - lib/post_pusher.rb
115
- - lib/post_pusher/engine.rb
116
144
  - lib/post_pusher/rake_task_runner.rb
117
145
  - lib/post_pusher/version.rb
118
146
  - test/dummy/README.rdoc
@@ -147,12 +175,14 @@ files:
147
175
  - test/dummy/config/secrets.yml
148
176
  - test/dummy/db/migrate/20150618161222_create_user.rb
149
177
  - test/dummy/db/migrate/20151229195418_create_soft_deletables.rb
178
+ - test/dummy/db/migrate/20160620190743_create_post_push_status.rb
150
179
  - test/dummy/db/schema.rb
151
180
  - test/dummy/lib/tasks/dummy_tasks.rake
152
181
  - test/dummy/public/404.html
153
182
  - test/dummy/public/422.html
154
183
  - test/dummy/public/500.html
155
184
  - test/dummy/public/favicon.ico
185
+ - test/generators/post_pusher/install/install_generator_test.rb
156
186
  - test/post_push_exe_test.rb
157
187
  - test/rake_task_runner_test.rb
158
188
  - test/test_helper.rb
@@ -175,50 +205,51 @@ required_rubygems_version: !ruby/object:Gem::Requirement
175
205
  - !ruby/object:Gem::Version
176
206
  version: '0'
177
207
  requirements: []
178
- rubyforge_project:
179
- rubygems_version: 2.5.2
208
+ rubygems_version: 3.2.0
180
209
  signing_key:
181
210
  specification_version: 4
182
211
  summary: A tool to run a set of tasks after deploys
183
212
  test_files:
184
- - test/rake_task_runner_test.rb
185
- - test/test_helper.rb
186
- - test/dummy/README.rdoc
187
- - test/dummy/app/assets/stylesheets/application.css
188
- - test/dummy/app/assets/javascripts/application.js
189
213
  - test/dummy/app/controllers/application_controller.rb
190
- - test/dummy/app/helpers/application_helper.rb
191
214
  - test/dummy/app/views/layouts/application.html.erb
192
- - test/dummy/config.ru
193
- - test/dummy/lib/tasks/dummy_tasks.rake
194
- - test/dummy/db/schema.rb
195
- - test/dummy/db/migrate/20151229195418_create_soft_deletables.rb
196
- - test/dummy/db/migrate/20150618161222_create_user.rb
215
+ - test/dummy/app/assets/javascripts/application.js
216
+ - test/dummy/app/assets/stylesheets/application.css
217
+ - test/dummy/app/helpers/application_helper.rb
197
218
  - test/dummy/bin/rake
198
219
  - test/dummy/bin/setup
199
- - test/dummy/bin/rails
200
220
  - test/dummy/bin/bundle
201
- - test/dummy/config/environment.rb
202
- - test/dummy/config/initializers/inflections.rb
203
- - test/dummy/config/initializers/session_store.rb
204
- - test/dummy/config/initializers/cookies_serializer.rb
205
- - test/dummy/config/initializers/assets.rb
206
- - test/dummy/config/initializers/backtrace_silencers.rb
207
- - test/dummy/config/initializers/wrap_parameters.rb
208
- - test/dummy/config/initializers/mime_types.rb
209
- - test/dummy/config/initializers/filter_parameter_logging.rb
221
+ - test/dummy/bin/rails
222
+ - test/dummy/config/secrets.yml
223
+ - test/dummy/config/routes.rb
210
224
  - test/dummy/config/locales/en.yml
211
- - test/dummy/config/application.rb
212
225
  - test/dummy/config/environments/production.rb
213
226
  - test/dummy/config/environments/development.rb
214
227
  - test/dummy/config/environments/test.rb
228
+ - test/dummy/config/environment.rb
229
+ - test/dummy/config/application.rb
215
230
  - test/dummy/config/database.yml
216
231
  - test/dummy/config/boot.rb
217
- - test/dummy/config/secrets.yml
218
- - test/dummy/config/routes.rb
232
+ - test/dummy/config/initializers/backtrace_silencers.rb
233
+ - test/dummy/config/initializers/mime_types.rb
234
+ - test/dummy/config/initializers/filter_parameter_logging.rb
235
+ - test/dummy/config/initializers/session_store.rb
236
+ - test/dummy/config/initializers/wrap_parameters.rb
237
+ - test/dummy/config/initializers/assets.rb
238
+ - test/dummy/config/initializers/cookies_serializer.rb
239
+ - test/dummy/config/initializers/inflections.rb
240
+ - test/dummy/config.ru
219
241
  - test/dummy/Rakefile
220
- - test/dummy/public/404.html
221
- - test/dummy/public/500.html
222
242
  - test/dummy/public/favicon.ico
223
243
  - test/dummy/public/422.html
244
+ - test/dummy/public/500.html
245
+ - test/dummy/public/404.html
246
+ - test/dummy/lib/tasks/dummy_tasks.rake
247
+ - test/dummy/db/schema.rb
248
+ - test/dummy/db/migrate/20151229195418_create_soft_deletables.rb
249
+ - test/dummy/db/migrate/20160620190743_create_post_push_status.rb
250
+ - test/dummy/db/migrate/20150618161222_create_user.rb
251
+ - test/dummy/README.rdoc
252
+ - test/test_helper.rb
224
253
  - test/post_push_exe_test.rb
254
+ - test/generators/post_pusher/install/install_generator_test.rb
255
+ - test/rake_task_runner_test.rb
@@ -1,13 +0,0 @@
1
- module PostPusher
2
- class Engine < ::Rails::Engine
3
- engine_name "post_pusher"
4
-
5
- initializer :append_migrations do |app|
6
- unless app.root.to_s.match root.to_s
7
- config.paths["db/migrate"].expanded.each do |expanded_path|
8
- app.config.paths["db/migrate"] << expanded_path
9
- end
10
- end
11
- end
12
- end
13
- end