tidy_reset 0.1.20 → 0.1.21
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/tidy_reset/tasks/tidy.rake +15 -3
- data/lib/tidy_reset.rb +19 -24
- data/tidy_reset.gemspec +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 73885e339b07c70af26560c7b256e6fd17b4e937
|
4
|
+
data.tar.gz: d61e6423158502650ca76258cd6539a15be2b5c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f35fc0fe77197dc0c4e3c0e0dadcfc96e70b4cda7cb03e5703ac5f50d5e996ab6ca29d404a6119d1d2fb359df14067b6800388bf41adcaefeb06bb52fad9d453
|
7
|
+
data.tar.gz: ebb8c94763b5bde67a9e83387e2c75ecc27bcd322729c0df3251990302d7ed1df16c004766cd00c611749ebee8abb7859a19e6d496598c3255f92b93d3738cb7
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.21
|
@@ -4,10 +4,11 @@ namespace :tidy do
|
|
4
4
|
# Executes all tasks
|
5
5
|
end
|
6
6
|
|
7
|
+
ACCEPTED_ENVIRONMENTS = ['test', 'sandbox', 'integration']
|
7
8
|
# Prevents mistakes. Raises an error for stages not test or sandbox.
|
8
9
|
# All tidy tasks should :validate as a task dependency.
|
9
10
|
task :validate, [:stage] => [:environment] do |t, args|
|
10
|
-
if (args.stage && !
|
11
|
+
if (args.stage && !ACCEPTED_ENVIRONMENTS.include?(args.stage)) || !ACCEPTED_ENVIRONMENTS.include?(STAGE)
|
11
12
|
raise "ERROR: tasks are meant for 'test' and 'sandbox' ONLY."
|
12
13
|
end
|
13
14
|
end
|
@@ -49,8 +50,8 @@ namespace :tidy do
|
|
49
50
|
task :db, [:stage] => [:validate] do |t, args|
|
50
51
|
app = TidyReset.app_name(args.stage)
|
51
52
|
TidyReset.execute("heroku run rake tidy:db:purge --app #{app}")
|
52
|
-
TidyReset.execute("heroku run rake db:migrate --app #{app}")
|
53
|
-
TidyReset.execute("heroku run rake db:seed --app #{app}")
|
53
|
+
TidyReset.execute("heroku run rake tidy:db:migrate --app #{app}")
|
54
|
+
TidyReset.execute("heroku run rake tidy:db:seed --app #{app}")
|
54
55
|
end
|
55
56
|
|
56
57
|
namespace :db do
|
@@ -58,8 +59,19 @@ namespace :tidy do
|
|
58
59
|
task :purge => [:validate, :environment] do |t, args|
|
59
60
|
TidyReset.configuration.databases.each do |database|
|
60
61
|
TidyReset.database_purge(database)
|
62
|
+
puts "Tidy task done."
|
61
63
|
end
|
62
64
|
end
|
65
|
+
|
66
|
+
task :migrate => [:validate, :environment] do |t, args|
|
67
|
+
Rake::Task['db:migrate'].invoke
|
68
|
+
puts "Tidy task done."
|
69
|
+
end
|
70
|
+
|
71
|
+
task :seed => [:validate, :environment] do |t, args|
|
72
|
+
Rake::Task['db:seed'].invoke
|
73
|
+
puts "Tidy task done."
|
74
|
+
end
|
63
75
|
end
|
64
76
|
|
65
77
|
desc "Clears the Rails.cache on a remote application."
|
data/lib/tidy_reset.rb
CHANGED
@@ -3,6 +3,10 @@ require 'tidy_reset/version'
|
|
3
3
|
require 'open3'
|
4
4
|
|
5
5
|
module TidyReset
|
6
|
+
class RakeExecuteException < StandardError; end
|
7
|
+
class RakeStatusException < StandardError; end
|
8
|
+
class RakeCompletedException < StandardError; end
|
9
|
+
|
6
10
|
class << self
|
7
11
|
attr_accessor :configuration
|
8
12
|
|
@@ -14,38 +18,29 @@ module TidyReset
|
|
14
18
|
yield(configuration)
|
15
19
|
end
|
16
20
|
|
21
|
+
def process(line)
|
22
|
+
puts line
|
23
|
+
@execute_error = RakeExecuteException if line =~ /rake aborted/
|
24
|
+
@rake_completed = true if line =~ /Tidy task done./
|
25
|
+
end
|
26
|
+
|
17
27
|
def execute(command)
|
18
28
|
Bundler.with_clean_env do
|
19
29
|
begin
|
20
30
|
tries ||= 3
|
21
|
-
|
22
|
-
|
31
|
+
@execute_error = false
|
32
|
+
@rake_completed = false
|
23
33
|
puts "running: #{command}"
|
34
|
+
|
24
35
|
Open3.popen3(command) do |stdin, stdout, stderr, wait_thr|
|
25
|
-
while line = stdout.gets
|
26
|
-
|
27
|
-
rake_error = true if line =~ /rake aborted/
|
28
|
-
db_seed_completed = true if line =~ /The rake task db:seed finished successfully./
|
29
|
-
end
|
30
|
-
|
31
|
-
while line = stderr.gets
|
32
|
-
puts line
|
33
|
-
rake_error = true if line =~ /rake aborted/
|
34
|
-
end
|
35
|
-
|
36
|
-
if db_seed_completed == false && command =~ /db:seed/
|
37
|
-
raise RuntimeError, "ERROR: rake db:seed failed!"
|
38
|
-
end
|
39
|
-
|
40
|
-
unless wait_thr.value.success?
|
41
|
-
raise RuntimeError, wait_thr.value
|
42
|
-
end
|
36
|
+
process(line) while line = stdout.gets
|
37
|
+
process(line) while line = stderr.gets
|
43
38
|
|
44
|
-
|
45
|
-
|
46
|
-
|
39
|
+
raise RakeStatusException, "Non-zero Exit Code: #{wait_thr.value}" unless wait_thr.value.success?
|
40
|
+
raise RakeCompletedException if (@rake_completed == false && command =~ /heroku run rake tidy:db:/ )
|
41
|
+
raise @execute_error if @execute_error
|
47
42
|
end
|
48
|
-
rescue
|
43
|
+
rescue => e
|
49
44
|
if (tries -= 1) > 0
|
50
45
|
puts "Failed running command. Waiting 10s before next retry. Error: #{e}"
|
51
46
|
sleep(10)
|
data/tidy_reset.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: tidy_reset 0.1.
|
5
|
+
# stub: tidy_reset 0.1.21 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "tidy_reset"
|
9
|
-
s.version = "0.1.
|
9
|
+
s.version = "0.1.21"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["Thinknear"]
|
14
|
-
s.date = "2014-
|
14
|
+
s.date = "2014-11-06"
|
15
15
|
s.description = "Reset dynos, environment variables, deploys master git branch, and purges the database."
|
16
16
|
s.email = "software@thinknear.com"
|
17
17
|
s.extra_rdoc_files = [
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tidy_reset
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.21
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thinknear
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-11-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|