after_party 1.11.1 → 1.11.2

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
  SHA256:
3
- metadata.gz: 15481e7175b7a81ed83b04e640b760c90a5f507d2f2906839a41fe3913ad99fd
4
- data.tar.gz: b2424ec97d317a51ed166705a4451dbec5eba30024b5d2aa8d030ef4e6e69e59
3
+ metadata.gz: 7657bba3849b325107caef491606b9fdf9c1ed27eb457091dab2ccb04ef956c6
4
+ data.tar.gz: 78fcbb1352e173192a2dff5d5ffede332ee1587083b653fdda02c8dcd1becb30
5
5
  SHA512:
6
- metadata.gz: 2b47e978361290d43e0120c1d7dc4574e53e337840d80021895c7c83a0ad167da76f1572b1e2326ed45077a6900370a79f5c78b48c5cbc2b761b7b1b803efea4
7
- data.tar.gz: 0c85c7917e2c467020a6357662fea2526e4f85940c278476fdcdb990bc2b8b87d13b703e88fd4b2276f88adc6057455f4eb717a7c8789594da94e8ef7c5f2e77
6
+ metadata.gz: 768ce9b023b2512ebe5f548cf1f60f6c2d283702587a2fa32a1724311e452642e5b2ae45bde7359741bf878b7261123a375dbdfd2b434aff0afe6c493a2b9856
7
+ data.tar.gz: 5b6b8d921c951248f9839d4fdf2b9f96bb6392b440735e2b3a492357b99d351d938f6f16c49bcb9ef4126ab77b5f4fab4c9800bd72b31b8728fd3c058ddb7223
@@ -1,5 +1,6 @@
1
+ # AfterParty is a moduke defined by gem after_party
1
2
  module AfterParty
2
- require "after_party/railtie.rb" if defined?(Rails)
3
+ require 'after_party/railtie.rb' if defined?(Rails)
3
4
 
4
5
  def self.setup
5
6
  yield self
@@ -1 +1 @@
1
- require "after_party/models/active_record/task_record.rb"
1
+ require 'after_party/models/active_record/task_record.rb'
@@ -1,11 +1,10 @@
1
1
  module AfterParty
2
+ # Task Record is a persisted object recorded when a taks is run.
2
3
  class TaskRecord < ActiveRecord::Base
3
- if ::Rails::VERSION::MAJOR.to_i == 3
4
- attr_accessible :version
5
- end
4
+ attr_accessible :version if ::Rails::VERSION::MAJOR.to_i == 3
6
5
 
7
6
  def self.completed_task?(version)
8
- all.any?{|t| t.version == version}
7
+ all.any? { |t| t.version == version }
9
8
  end
10
9
  end
11
- end
10
+ end
@@ -1,14 +1,13 @@
1
1
  module AfterParty
2
+ # Task Record is a persisted object recorded when a taks is run.
2
3
  class TaskRecord
3
4
  include Mongoid::Document
4
5
  include Mongoid::Timestamps
5
6
 
6
7
  field :version, type: String
7
8
 
8
-
9
9
  def self.completed_task?(version)
10
- all.any?{|t| t.version == version}
10
+ all.any? { |t| t.version == version }
11
11
  end
12
12
  end
13
- end
14
-
13
+ end
@@ -1,15 +1,18 @@
1
1
  module AfterParty
2
+ # Task Recorder is responsible for collecting pending tasks and recording their execution
2
3
  class TaskRecorder
3
4
  include ActiveModel::Naming
4
5
  attr_reader :filename, :timestamp, :task_name
5
6
 
6
- FILE_MASK = File.join(Rails.root, "lib/tasks/deployment/*.rake")
7
+ FILE_MASK = File.join(Rails.root, 'lib/tasks/deployment/*.rake')
7
8
 
8
9
  def self.pending_files
9
- Dir[FILE_MASK].collect{ |f| TaskRecorder.new(f) }.select{ |f| f.pending? }.sort{ |x,y| x.timestamp <=> y.timestamp }
10
+ Dir[FILE_MASK].collect { |f| TaskRecorder.new(f) }
11
+ .select(&:pending?)
12
+ .sort_by(&:timestamp)
10
13
  end
11
14
 
12
- def initialize(filename='')
15
+ def initialize(filename = '')
13
16
  @filename = filename
14
17
  parse_filename
15
18
  end
@@ -19,9 +22,10 @@ module AfterParty
19
22
  end
20
23
 
21
24
  def parse_filename
22
- /(\d+)_(.+)\.rake/.match(Pathname(@filename).basename.to_s)
23
- @timestamp = $1
24
- @task_name = $2
25
+ /(\d+)_(.+)\.rake/.match(Pathname(@filename).basename.to_s) do |m|
26
+ @timestamp = m[1]
27
+ @task_name = m[2]
28
+ end
25
29
  end
26
30
  end
27
- end
31
+ end
@@ -1 +1 @@
1
- require "after_party/models/mongoid/task_record.rb"
1
+ require 'after_party/models/mongoid/task_record.rb'
@@ -1,21 +1,19 @@
1
1
  require 'after_party'
2
2
  require 'rails'
3
3
  module AfterParty
4
+ # railtie is loaded from lib/after_party.rb. So all load paths need to be relative to /lib
4
5
  class Railtie < Rails::Railtie
5
- #railtie is loaded from lib/after_party.rb. So all load paths need to be relative to /lib
6
6
  rake_tasks do
7
- load "tasks/deploy_task_runner.rake"
7
+ load 'tasks/deploy_task_runner.rake'
8
8
  end
9
9
 
10
- initializer "load_task_record_models" do
11
- load "after_party/models/task_recorder.rb"
10
+ initializer 'load_task_record_models' do
11
+ load 'after_party/models/task_recorder.rb'
12
12
  end
13
13
 
14
14
  generators do
15
- load "generators/task/task_generator.rb"
16
- load "generators/install/install_generator.rb"
15
+ load 'generators/task/task_generator.rb'
16
+ load 'generators/install/install_generator.rb'
17
17
  end
18
18
  end
19
-
20
-
21
- end
19
+ end
@@ -2,22 +2,22 @@ require 'rails/generators'
2
2
 
3
3
  module AfterParty
4
4
  module Generators
5
-
5
+ # Generates the after_party.rb in config/initializers and a migration file
6
6
  class InstallGenerator < Rails::Generators::Base
7
7
  source_root File.expand_path('../templates', __FILE__)
8
- argument :orm_name, :type => :string, :default => "active_record"
8
+ argument :orm_name, :type => :string, :default => 'active_record'
9
9
 
10
10
  def create_initializer_file
11
- template "after_party.rb", "config/initializers/after_party.rb"
11
+ template 'after_party.txt.erb', 'config/initializers/after_party.rb'
12
12
  end
13
13
 
14
14
  def copy_migration
15
- if requires_migration?
16
- if requires_version_tag?
17
- template "migration.txt.erb", "db/migrate/#{timestamp}_create_#{table_name}.rb"
18
- else
19
- template "migration-rails-3-4.txt.erb", "db/migrate/#{timestamp}_create_#{table_name}.rb"
20
- end
15
+ return unless requires_migration?
16
+
17
+ if requires_version_tag?
18
+ template 'migration.txt.erb', "db/migrate/#{timestamp}_create_#{table_name}.rb"
19
+ else
20
+ template 'migration-rails-3-4.txt.erb', "db/migrate/#{timestamp}_create_#{table_name}.rb"
21
21
  end
22
22
  end
23
23
 
@@ -26,13 +26,13 @@ module AfterParty
26
26
  end
27
27
 
28
28
  private
29
+
29
30
  def timestamp
30
- @timestamp ||= Time.now.utc.strftime("%Y%m%d%H%M%S")
31
+ @timestamp ||= Time.now.utc.strftime('%Y%m%d%H%M%S')
31
32
  end
32
33
 
33
34
  def migration_exists?
34
- absolute = File.expand_path("db/migrate/", destination_root)
35
- #dirname, file_name = File.dirname(absolute), File.basename(absolute).sub(/\.rb$/, '')
35
+ absolute = File.expand_path('db/migrate/', destination_root)
36
36
  Dir.glob("#{absolute}/[0-9]*_create_#{table_name}.rb").first
37
37
  end
38
38
 
@@ -41,14 +41,13 @@ module AfterParty
41
41
  end
42
42
 
43
43
  def requires_migration?
44
- orm_name == "active_record" && !migration_exists?
44
+ orm_name == 'active_record' && !migration_exists?
45
45
  end
46
46
 
47
47
  def table_name
48
- table = "task_record"
48
+ table = 'task_record'
49
49
  ActiveRecord::Base.pluralize_table_names ? table.pluralize : table
50
50
  end
51
-
52
51
  end
53
52
  end
54
- end
53
+ end
@@ -3,7 +3,5 @@ AfterParty.setup do |config|
3
3
  # Load and configure the ORM. Supports :active_record (default) and
4
4
  # :mongoid (bson_ext recommended) by default. Other ORMs may be
5
5
  # available as additional gems.
6
- require "after_party/<%= orm_name %>.rb"
7
-
8
-
6
+ require 'after_party/<%= orm_name %>.rb'
9
7
  end
@@ -2,6 +2,7 @@ require 'date'
2
2
 
3
3
  module AfterParty
4
4
  module Generators
5
+ # creates after_party tasks
5
6
  class TaskGenerator < Rails::Generators::Base
6
7
  source_root(File.expand_path('../templates', __FILE__))
7
8
  argument(:name, type: :string)
@@ -27,12 +28,13 @@ module AfterParty
27
28
  def task_description
28
29
  line = 'Deployment task: '
29
30
  return line + file_name if options.description.blank?
31
+
30
32
  line + options.description
31
33
  end
32
34
 
33
35
  def timestamp
34
36
  @timestamp ||= Time.now.utc.strftime('%Y%m%d%H%M%S')
35
37
  end
36
- end # class TaskGenerator
37
- end # module Generators
38
- end # module AfterParty
38
+ end
39
+ end
40
+ end
@@ -9,5 +9,5 @@ namespace :after_party do
9
9
  # run with every deploy (or every time you call after_party:run).
10
10
  AfterParty::TaskRecord
11
11
  .create version: AfterParty::TaskRecorder.new(__FILE__).timestamp
12
- end # task :<%= file_name %>
13
- end # namespace :after_party
12
+ end
13
+ end
@@ -1,17 +1,14 @@
1
1
  namespace :after_party do
2
- desc "runs (in order) all pending after_party deployment tasks, if they have not run yet against the current db."
2
+ desc 'runs (in order) all pending after_party deployment tasks, if they have not run yet against the current db.'
3
3
  task :run => :environment do
4
- tasks = AfterParty::TaskRecorder.pending_files.map {|f| "after_party:#{f.task_name}"}
4
+ tasks = AfterParty::TaskRecorder.pending_files.map { |f| "after_party:#{f.task_name}" }
5
5
 
6
- tasks.each {|t| Rake::Task[t].invoke}
7
-
8
- if tasks.empty?
9
- puts "no pending tasks to run"
10
- end
6
+ tasks.each { |t| Rake::Task[t].invoke }
11
7
 
8
+ puts 'no pending tasks to run' if tasks.empty?
12
9
  end
13
10
 
14
- desc "Check the status of after_party deployment tasks"
11
+ desc 'Check the status of after_party deployment tasks'
15
12
  task :status => :environment do
16
13
  tasks = Dir[AfterParty::TaskRecorder::FILE_MASK].sort.collect do |filename|
17
14
  recorder = AfterParty::TaskRecorder.new(filename)
@@ -22,10 +19,10 @@ namespace :after_party do
22
19
  }
23
20
  end
24
21
 
25
- puts <<-EOF
22
+ puts <<-TABLE
26
23
  Status Task ID Task Name
27
24
  --------------------------------------------------
28
- EOF
25
+ TABLE
29
26
  tasks.each do |task|
30
27
  puts " #{task[:status]} #{task[:version]} #{task[:task_name].capitalize}"
31
28
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: after_party
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.11.1
4
+ version: 1.11.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve Mitchell
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-11 00:00:00.000000000 Z
11
+ date: 2019-03-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -25,7 +25,7 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: mongoid
28
+ name: factory_bot
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
@@ -39,7 +39,7 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: rspec
42
+ name: generator_spec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
@@ -53,21 +53,21 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: rspec-rails
56
+ name: mongoid
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: '3.4'
61
+ version: '0'
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: '3.4'
68
+ version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: generator_spec
70
+ name: rspec
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - ">="
@@ -81,7 +81,21 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
- name: factory_bot
84
+ name: rspec-rails
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '3.4'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '3.4'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop
85
99
  requirement: !ruby/object:Gem::Requirement
86
100
  requirements:
87
101
  - - ">="
@@ -124,7 +138,7 @@ files:
124
138
  - lib/after_party/railtie.rb
125
139
  - lib/generators/install/USAGE
126
140
  - lib/generators/install/install_generator.rb
127
- - lib/generators/install/templates/after_party.rb
141
+ - lib/generators/install/templates/after_party.txt.erb
128
142
  - lib/generators/install/templates/migration-rails-3-4.txt.erb
129
143
  - lib/generators/install/templates/migration.txt.erb
130
144
  - lib/generators/task/USAGE
@@ -150,8 +164,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
150
164
  - !ruby/object:Gem::Version
151
165
  version: '0'
152
166
  requirements: []
153
- rubyforge_project:
154
- rubygems_version: 2.7.8
167
+ rubygems_version: 3.0.1
155
168
  signing_key:
156
169
  specification_version: 4
157
170
  summary: A rails engine that manages deploy tasks and versions using activeRecord