after_party 1.11.1 → 2.0.0

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: e57f0e1f1e66fd351666b2af8821091b35f73c9d34281e59816cc9094cbe590d
4
+ data.tar.gz: 37ec5d9c41df200d1f86e4395d9ca8dedfc4ac14bc70aaeb7abc114ae3b6b3da
5
5
  SHA512:
6
- metadata.gz: 2b47e978361290d43e0120c1d7dc4574e53e337840d80021895c7c83a0ad167da76f1572b1e2326ed45077a6900370a79f5c78b48c5cbc2b761b7b1b803efea4
7
- data.tar.gz: 0c85c7917e2c467020a6357662fea2526e4f85940c278476fdcdb990bc2b8b87d13b703e88fd4b2276f88adc6057455f4eb717a7c8789594da94e8ef7c5f2e77
6
+ metadata.gz: d23202ce6cb9edaa8b1312da9fd8a6ef64badc12990fc7df90dfded2c8634ef39be4bc59ac390638a750a9a771193f7039d8f09990235e2f1e48934fa14bda40
7
+ data.tar.gz: 708f8b4b14796914e777cda1ad5aa973a17998ea850e1e52017ea412a54fc9d08018c4a0d38a54e8c1a394a6bcc88a4f8741a7309664c69567d6878ccdc675a8
@@ -1 +1,3 @@
1
- require "after_party/models/active_record/task_record.rb"
1
+ # frozen_string_literal: true
2
+
3
+ require 'after_party/models/active_record/task_record'
@@ -1,11 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module AfterParty
4
+ # Task Record is a persisted object recorded when a taks is run.
2
5
  class TaskRecord < ActiveRecord::Base
3
- if ::Rails::VERSION::MAJOR.to_i == 3
4
- attr_accessible :version
5
- end
6
+ attr_accessible :version if ::Rails::VERSION::MAJOR.to_i == 3
6
7
 
7
8
  def self.completed_task?(version)
8
- all.any?{|t| t.version == version}
9
+ all.any? { |t| t.version == version }
9
10
  end
10
11
  end
11
12
  end
@@ -1,14 +1,15 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module AfterParty
4
+ # Task Record is a persisted object recorded when a taks is run.
2
5
  class TaskRecord
3
6
  include Mongoid::Document
4
7
  include Mongoid::Timestamps
5
8
 
6
9
  field :version, type: String
7
10
 
8
-
9
11
  def self.completed_task?(version)
10
- all.any?{|t| t.version == version}
12
+ all.any? { |t| t.version == version }
11
13
  end
12
14
  end
13
15
  end
14
-
@@ -1,15 +1,20 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module AfterParty
4
+ # Task Recorder is responsible for collecting pending tasks and recording their execution
2
5
  class TaskRecorder
3
6
  include ActiveModel::Naming
4
7
  attr_reader :filename, :timestamp, :task_name
5
8
 
6
- FILE_MASK = File.join(Rails.root, "lib/tasks/deployment/*.rake")
9
+ FILE_MASK = File.join(Rails.root, 'lib/tasks/deployment/*.rake')
7
10
 
8
11
  def self.pending_files
9
- Dir[FILE_MASK].collect{ |f| TaskRecorder.new(f) }.select{ |f| f.pending? }.sort{ |x,y| x.timestamp <=> y.timestamp }
12
+ Dir[FILE_MASK].collect { |f| TaskRecorder.new(f) }
13
+ .select(&:pending?)
14
+ .sort_by(&:timestamp)
10
15
  end
11
16
 
12
- def initialize(filename='')
17
+ def initialize(filename = '')
13
18
  @filename = filename
14
19
  parse_filename
15
20
  end
@@ -19,9 +24,10 @@ module AfterParty
19
24
  end
20
25
 
21
26
  def parse_filename
22
- /(\d+)_(.+)\.rake/.match(Pathname(@filename).basename.to_s)
23
- @timestamp = $1
24
- @task_name = $2
27
+ /(\d+)_(.+)\.rake/.match(Pathname(@filename).basename.to_s) do |m|
28
+ @timestamp = m[1]
29
+ @task_name = m[2]
30
+ end
25
31
  end
26
32
  end
27
33
  end
@@ -1 +1,3 @@
1
- require "after_party/models/mongoid/task_record.rb"
1
+ # frozen_string_literal: true
2
+
3
+ require 'after_party/models/mongoid/task_record'
@@ -1,21 +1,21 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'after_party'
2
4
  require 'rails'
3
5
  module AfterParty
6
+ # railtie is loaded from lib/after_party.rb. So all load paths need to be relative to /lib
4
7
  class Railtie < Rails::Railtie
5
- #railtie is loaded from lib/after_party.rb. So all load paths need to be relative to /lib
6
8
  rake_tasks do
7
- load "tasks/deploy_task_runner.rake"
9
+ load 'tasks/deploy_task_runner.rake'
8
10
  end
9
11
 
10
- initializer "load_task_record_models" do
11
- load "after_party/models/task_recorder.rb"
12
+ initializer 'load_task_record_models' do
13
+ load 'after_party/models/task_recorder.rb'
12
14
  end
13
15
 
14
16
  generators do
15
- load "generators/task/task_generator.rb"
16
- load "generators/install/install_generator.rb"
17
+ load 'generators/task/task_generator.rb'
18
+ load 'generators/install/install_generator.rb'
17
19
  end
18
20
  end
19
-
20
-
21
21
  end
data/lib/after_party.rb CHANGED
@@ -1,7 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ # AfterParty is a moduke defined by gem after_party
1
4
  module AfterParty
2
- require "after_party/railtie.rb" if defined?(Rails)
5
+ require 'after_party/railtie' if defined?(Rails)
3
6
 
4
7
  def self.setup
5
8
  yield self
6
9
  end
7
- end
10
+ end
@@ -1,23 +1,25 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rails/generators'
2
4
 
3
5
  module AfterParty
4
6
  module Generators
5
-
7
+ # Generates the after_party.rb in config/initializers and a migration file
6
8
  class InstallGenerator < Rails::Generators::Base
7
- source_root File.expand_path('../templates', __FILE__)
8
- argument :orm_name, :type => :string, :default => "active_record"
9
+ source_root File.expand_path('templates', __dir__)
10
+ argument :orm_name, type: :string, default: 'active_record'
9
11
 
10
12
  def create_initializer_file
11
- template "after_party.rb", "config/initializers/after_party.rb"
13
+ template 'after_party.txt.erb', 'config/initializers/after_party.rb'
12
14
  end
13
15
 
14
16
  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
17
+ return unless requires_migration?
18
+
19
+ if requires_version_tag?
20
+ template 'migration.txt.erb', "db/migrate/#{timestamp}_create_#{table_name}.rb"
21
+ else
22
+ template 'migration-rails-3-4.txt.erb', "db/migrate/#{timestamp}_create_#{table_name}.rb"
21
23
  end
22
24
  end
23
25
 
@@ -26,13 +28,13 @@ module AfterParty
26
28
  end
27
29
 
28
30
  private
31
+
29
32
  def timestamp
30
- @timestamp ||= Time.now.utc.strftime("%Y%m%d%H%M%S")
33
+ @timestamp ||= Time.now.utc.strftime('%Y%m%d%H%M%S')
31
34
  end
32
35
 
33
36
  def migration_exists?
34
- absolute = File.expand_path("db/migrate/", destination_root)
35
- #dirname, file_name = File.dirname(absolute), File.basename(absolute).sub(/\.rb$/, '')
37
+ absolute = File.expand_path('db/migrate/', destination_root)
36
38
  Dir.glob("#{absolute}/[0-9]*_create_#{table_name}.rb").first
37
39
  end
38
40
 
@@ -41,14 +43,13 @@ module AfterParty
41
43
  end
42
44
 
43
45
  def requires_migration?
44
- orm_name == "active_record" && !migration_exists?
46
+ orm_name == 'active_record' && !migration_exists?
45
47
  end
46
48
 
47
49
  def table_name
48
- table = "task_record"
50
+ table = 'task_record'
49
51
  ActiveRecord::Base.pluralize_table_names ? table.pluralize : table
50
52
  end
51
-
52
53
  end
53
54
  end
54
55
  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
@@ -1,9 +1,13 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'date'
2
4
 
3
5
  module AfterParty
4
6
  module Generators
7
+ # creates after_party tasks
5
8
  class TaskGenerator < Rails::Generators::Base
6
- source_root(File.expand_path('../templates', __FILE__))
9
+ FILE_MASK = File.join(Rails.root, 'lib/tasks/deployment/*.rake')
10
+ source_root(File.expand_path('templates', __dir__))
7
11
  argument(:name, type: :string)
8
12
  class_option(
9
13
  :description,
@@ -12,10 +16,15 @@ module AfterParty
12
16
  )
13
17
 
14
18
  def copy_deploy_task
15
- template(
16
- 'deploy.txt.erb',
17
- "lib/tasks/deployment/#{timestamp}_#{file_name}.rake"
18
- )
19
+ file_names = Dir[FILE_MASK].collect { |f| AfterParty::TaskRecorder.new(f) }.map { |f| f.task_name.to_s }
20
+ if file_names.include?(file_name)
21
+ puts 'Error: Please Create a unique task name'
22
+ else
23
+ template(
24
+ 'deploy.txt.erb',
25
+ "lib/tasks/deployment/#{timestamp}_#{file_name}.rake"
26
+ )
27
+ end
19
28
  end
20
29
 
21
30
  private
@@ -27,12 +36,13 @@ module AfterParty
27
36
  def task_description
28
37
  line = 'Deployment task: '
29
38
  return line + file_name if options.description.blank?
39
+
30
40
  line + options.description
31
41
  end
32
42
 
33
43
  def timestamp
34
44
  @timestamp ||= Time.now.utc.strftime('%Y%m%d%H%M%S')
35
45
  end
36
- end # class TaskGenerator
37
- end # module Generators
38
- end # module AfterParty
46
+ end
47
+ end
48
+ 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,19 +1,18 @@
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."
3
- task :run => :environment do
4
- tasks = AfterParty::TaskRecorder.pending_files.map {|f| "after_party:#{f.task_name}"}
1
+ # frozen_string_literal: true
5
2
 
6
- tasks.each {|t| Rake::Task[t].invoke}
3
+ namespace :after_party do
4
+ desc 'runs (in order) all pending after_party deployment tasks, if they have not run yet against the current db.'
5
+ task run: :environment do
6
+ tasks = AfterParty::TaskRecorder.pending_files.map { |f| "after_party:#{f.task_name}" }
7
7
 
8
- if tasks.empty?
9
- puts "no pending tasks to run"
10
- end
8
+ tasks.each { |t| Rake::Task[t].invoke }
11
9
 
10
+ puts 'no pending tasks to run' if tasks.empty?
12
11
  end
13
12
 
14
- desc "Check the status of after_party deployment tasks"
15
- task :status => :environment do
16
- tasks = Dir[AfterParty::TaskRecorder::FILE_MASK].sort.collect do |filename|
13
+ desc 'Check the status of after_party deployment tasks'
14
+ task status: :environment do
15
+ tasks = Dir[AfterParty::TaskRecorder::FILE_MASK].collect do |filename|
17
16
  recorder = AfterParty::TaskRecorder.new(filename)
18
17
  {
19
18
  version: recorder.timestamp,
@@ -22,10 +21,10 @@ namespace :after_party do
22
21
  }
23
22
  end
24
23
 
25
- puts <<-EOF
26
- Status Task ID Task Name
27
- --------------------------------------------------
28
- EOF
24
+ puts <<~TABLE
25
+ Status Task ID Task Name
26
+ --------------------------------------------------
27
+ TABLE
29
28
  tasks.each do |task|
30
29
  puts " #{task[:status]} #{task[:version]} #{task[:task_name].capitalize}"
31
30
  end
data/lib/version.rb ADDED
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Version
4
+ VERSION = '2.0.0'
5
+ end
metadata CHANGED
@@ -1,113 +1,127 @@
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: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve Mitchell
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-11 00:00:00.000000000 Z
11
+ date: 2024-12-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '7'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: '7'
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
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: '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: '6'
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
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '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
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: '7'
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: '7'
69
69
  - !ruby/object:Gem::Dependency
70
- name: generator_spec
70
+ name: pg
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ">="
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '0'
75
+ version: '1'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ">="
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '0'
82
+ version: '1'
83
83
  - !ruby/object:Gem::Dependency
84
- name: factory_bot
84
+ name: rspec
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ">="
87
+ - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '0'
89
+ version: '3'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ">="
94
+ - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '0'
96
+ version: '3'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec-rails
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '5'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '5'
97
111
  - !ruby/object:Gem::Dependency
98
- name: sqlite3
112
+ name: rubocop
99
113
  requirement: !ruby/object:Gem::Requirement
100
114
  requirements:
101
115
  - - "~>"
102
116
  - !ruby/object:Gem::Version
103
- version: 1.3.6
117
+ version: '1'
104
118
  type: :development
105
119
  prerelease: false
106
120
  version_requirements: !ruby/object:Gem::Requirement
107
121
  requirements:
108
122
  - - "~>"
109
123
  - !ruby/object:Gem::Version
110
- version: 1.3.6
124
+ version: '1'
111
125
  description: Automated post-deploy tasks for Ruby/Rails. Your deployment is the party.
112
126
  This is the after party
113
127
  email: thestevemitchell@gmail.com
@@ -124,35 +138,36 @@ 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
131
145
  - lib/generators/task/task_generator.rb
132
146
  - lib/generators/task/templates/deploy.txt.erb
133
147
  - lib/tasks/deploy_task_runner.rake
148
+ - lib/version.rb
134
149
  homepage: http://github.com/theSteveMitchell/after_party
135
150
  licenses:
136
151
  - MIT
137
- metadata: {}
138
- post_install_message:
152
+ metadata:
153
+ rubygems_mfa_required: 'true'
154
+ post_install_message:
139
155
  rdoc_options: []
140
156
  require_paths:
141
157
  - lib
142
158
  required_ruby_version: !ruby/object:Gem::Requirement
143
159
  requirements:
144
- - - ">="
160
+ - - "~>"
145
161
  - !ruby/object:Gem::Version
146
- version: '0'
162
+ version: '3.0'
147
163
  required_rubygems_version: !ruby/object:Gem::Requirement
148
164
  requirements:
149
165
  - - ">="
150
166
  - !ruby/object:Gem::Version
151
167
  version: '0'
152
168
  requirements: []
153
- rubyforge_project:
154
- rubygems_version: 2.7.8
155
- signing_key:
169
+ rubygems_version: 3.2.3
170
+ signing_key:
156
171
  specification_version: 4
157
172
  summary: A rails engine that manages deploy tasks and versions using activeRecord
158
173
  or mongoid