prun-ops 0.3.9 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +3 -0
  3. data/.rubocop.yml +11 -0
  4. data/.rubocop_todo.yml +59 -0
  5. data/.ruby-version +1 -1
  6. data/CHANGELOG.md +76 -0
  7. data/CODE_OF_CONDUCT.md +132 -0
  8. data/LICENSE.txt +17 -18
  9. data/README.md +4 -77
  10. data/Rakefile +10 -0
  11. data/lib/capistrano/all.rake +13 -13
  12. data/lib/capistrano/backup.rake +17 -15
  13. data/lib/capistrano/config/app.rake +11 -11
  14. data/lib/capistrano/config/config.rake +12 -10
  15. data/lib/capistrano/config/monitis.rake +3 -1
  16. data/lib/capistrano/config/mysql.rake +9 -11
  17. data/lib/capistrano/config/nginx.rake +8 -6
  18. data/lib/capistrano/config/nodejs.rake +12 -6
  19. data/lib/capistrano/config/postgres.rake +37 -22
  20. data/lib/capistrano/config/rails.rake +3 -2
  21. data/lib/capistrano/config/redis.rake +2 -0
  22. data/lib/capistrano/config/ruby.rake +7 -5
  23. data/lib/capistrano/config/ubuntu.rake +5 -3
  24. data/lib/capistrano/config/yarn.rake +3 -1
  25. data/lib/capistrano/diagnosis.rake +24 -24
  26. data/lib/capistrano/git.rake +14 -11
  27. data/lib/capistrano/{prun-ops.rb → prun_ops.rb} +8 -6
  28. data/lib/{cred.rb → prun/cred.rb} +5 -2
  29. data/lib/{prun-ops → prun/ops}/railitie.rb +5 -3
  30. data/lib/prun/ops/version.rb +7 -0
  31. data/lib/prun/ops.rb +14 -0
  32. data/lib/tasks/backup.rake +18 -13
  33. data/lib/tasks/db.rake +29 -17
  34. data/lib/tasks/git.rake +3 -3
  35. data/lib/tasks/http.rake +4 -2
  36. data/lib/tasks/version.rake +6 -5
  37. data/sig/prun/ops.rbs +6 -0
  38. metadata +27 -51
  39. data/.gitignore +0 -16
  40. data/Gemfile +0 -4
  41. data/Gemfile.lock +0 -60
  42. data/lib/prun-ops/version.rb +0 -3
  43. data/lib/prun-ops.rb +0 -10
  44. data/prun-ops.gemspec +0 -28
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  namespace :backup do
2
- desc 'Restore and database and :backup_dirs from the git :backup_repo, with the TAG given'
4
+ desc "Restore and database and :backup_dirs from the git :backup_repo, with the TAG given"
3
5
  task restore: :get_config do
4
6
  pull_repo(tag)
5
7
  sh "rake db:restore #{@backup_path}/db.sql"
@@ -11,7 +13,7 @@ namespace :backup do
11
13
  end
12
14
  end
13
15
 
14
- desc 'Commits and tag the database dump and :backup_dirs into a git :backup_repo'
16
+ desc "Commits and tag the database dump and :backup_dirs into a git :backup_repo"
15
17
  task backup: ["db:backup", :get_config] do
16
18
  pull_repo
17
19
 
@@ -26,17 +28,17 @@ task backup: ["db:backup", :get_config] do
26
28
 
27
29
  # Pushing data
28
30
  comment = "#{@app_name} backup at #{Time.now.strftime "%F %R"}"
29
- sh "git add --all && git commit -m '#{comment}'" do |ok, res|
30
- if ! ok
31
- puts "Nothing change since last backup"
32
- else
31
+ sh "git add --all && git commit -m '#{comment}'" do |ok, _res|
32
+ if ok
33
33
  sh "git push origin master"
34
+ else
35
+ puts "Nothing change since last backup"
34
36
  end
35
37
  end
36
38
 
37
39
  # Tagging
38
40
  tagname = if tag.blank?
39
- "#{@app_name}-#{Date.today.strftime "%Y%m%d" }"
41
+ "#{@app_name}-#{Date.today.strftime "%Y%m%d"}"
40
42
  else
41
43
  tag
42
44
  end
@@ -58,17 +60,20 @@ end
58
60
 
59
61
  def tag
60
62
  name = ARGV[1]
61
- task name.to_sym do ; end unless name.nil?
62
- return name
63
+ unless name.nil?
64
+ task name.to_sym do
65
+ end
66
+ end
67
+ name
63
68
  end
64
69
 
65
- def pull_repo(tag="")
70
+ def pull_repo(tag = "")
66
71
  if File.directory?(@repo_path)
67
- cd "#{@repo_path}"
72
+ cd @repo_path.to_s
68
73
  sh "git pull origin master"
69
74
  else
70
75
  sh "git clone #{@git_repo} #{@repo_path}"
71
- cd "#{@repo_path}"
76
+ cd @repo_path.to_s
72
77
  end
73
78
  sh "git checkout tags/#{tag}" unless tag.blank?
74
- end
79
+ end
data/lib/tasks/db.rake CHANGED
@@ -1,40 +1,52 @@
1
+ # frozen_string_literal: true
2
+
1
3
  namespace :db do
2
4
  desc "Reset DataBase for environment and test"
3
5
  task :reset do
4
- Rake::Task['db:drop'].invoke
5
- Rake::Task['db:create'].invoke
6
- Rake::Task['db:migrate'].invoke
7
- Rake::Task['db:seed'].invoke
6
+ Rake::Task["db:drop"].invoke
7
+ Rake::Task["db:create"].invoke
8
+ Rake::Task["db:migrate"].invoke
9
+ Rake::Task["db:seed"].invoke
8
10
  sh "rake db:test:prepare"
9
11
  end
10
12
 
11
13
  desc "Backup the database tp tmp/db.sql file"
12
14
  task backup: :get_db_config do
13
- sh "export PGPASSWORD=#{@password} && pg_dump #{@database} --host #{@host} --port #{@port} -U #{@username} -f #{@default_filename}"
15
+ if @url
16
+ sh "pg_dump -d #{@url} -f #{filename}"
17
+ else
18
+ sh "export PGPASSWORD=#{@password} && pg_dump #{@database} --host #{@host} --port #{@port} -U #{@username} -f #{@default_filename}"
19
+ end
14
20
  end
15
21
 
16
22
  desc "Restore the database from tmp/db.sql file if no one is passed"
17
- task restore: [:drop, :create, :get_db_config] do
23
+ task restore: %i[drop create get_db_config] do
18
24
  sh "export PGPASSWORD=#{@password} && psql -d #{@database} -U #{@username} -h #{@host} --port #{@port} < #{filename}"
19
25
  end
20
26
  end
21
27
 
22
28
  task :get_db_config do
23
- config = Rails.configuration.database_configuration
24
- @host = config[Rails.env]["host"]
25
- @port = config[Rails.env]["port"]
26
- @database = config[Rails.env]["database"]
27
- @username = config[Rails.env]["username"]
28
- @password = config[Rails.env]["password"]
29
+ config = if Rails.env.production?
30
+ Rails.configuration.database_configuration[Rails.env]["primary"]
31
+ else
32
+ Rails.configuration.database_configuration[Rails.env]
33
+ end
34
+
35
+ @host = config["host"]
36
+ @port = config["port"]
37
+ @database = config["database"]
38
+ @username = config["username"]
39
+ @password = config["password"]
40
+ @url = config["url"]
29
41
 
30
42
  @default_filename = "tmp/db.sql"
31
43
  end
32
44
 
33
45
  def filename
34
46
  name = ARGV[1]
35
- task name.to_sym do ; end unless name.nil?
36
- return name ? name : @default_filename
47
+ unless name.nil?
48
+ task name.to_sym do
49
+ end
50
+ end
51
+ name || @default_filename
37
52
  end
38
-
39
-
40
-
data/lib/tasks/git.rake CHANGED
@@ -1,8 +1,8 @@
1
- namespace :git do
1
+ # frozen_string_literal: true
2
2
 
3
+ namespace :git do
3
4
  desc "Merge dev forward master branch"
4
5
  task :ff do
5
6
  sh "git checkout master && git merge dev && git push && git checkout dev"
6
7
  end
7
-
8
- end
8
+ end
data/lib/tasks/http.rake CHANGED
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  namespace :http do
2
4
  desc "Starts a simple HTTP server in port 8000: rake http:s [folder]"
3
5
  task :s do
4
- folder = ARGV[1] ? ARGV[1] : '.'
6
+ folder = ARGV[1] || "."
5
7
  sh "ruby -run -e httpd #{folder} -p 8000"
6
8
  end
7
- end
9
+ end
@@ -1,10 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  desc "Version control"
2
4
  namespace :version do
3
5
  desc "Release a version: rake version:release version_tag"
4
- task :release, :number do |t, args|
6
+ task :release, :number do |_t, _args|
5
7
  version_tag = get_version_tag
6
8
  # Merge dev/master and push
7
- sh "git show-branch dev" do |ok, res|
9
+ sh "git show-branch dev" do |ok, _res|
8
10
  if ok
9
11
  sh "git checkout master && git merge dev && git push && git checkout dev"
10
12
  else
@@ -18,7 +20,7 @@ namespace :version do
18
20
  end
19
21
 
20
22
  desc "Delete a version: rake version:remove version_tag "
21
- task :remove, :number do |t, args|
23
+ task :remove, :number do |_t, _args|
22
24
  version_tag = get_version_tag
23
25
  sh "git tag -d #{version_tag}"
24
26
  sh "git push origin :refs/tags/#{version_tag}"
@@ -32,5 +34,4 @@ namespace :version do
32
34
  ARGV[1]
33
35
  end
34
36
  end
35
-
36
- end
37
+ end
data/sig/prun/ops.rbs ADDED
@@ -0,0 +1,6 @@
1
+ module Prun
2
+ module Ops
3
+ VERSION: String
4
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
5
+ end
6
+ end
metadata CHANGED
@@ -1,43 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prun-ops
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.9
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
- - Juan Lebrijo
8
- autorequire:
9
- bindir: bin
7
+ - jlebrijo
8
+ bindir: exe
10
9
  cert_chain: []
11
- date: 2025-04-10 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: bundler
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '0'
27
- - !ruby/object:Gem::Dependency
28
- name: rake
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
12
  - !ruby/object:Gem::Dependency
42
13
  name: capistrano
43
14
  requirement: !ruby/object:Gem::Requirement
@@ -53,7 +24,7 @@ dependencies:
53
24
  - !ruby/object:Gem::Version
54
25
  version: '0'
55
26
  - !ruby/object:Gem::Dependency
56
- name: capistrano-rails
27
+ name: capistrano3-puma
57
28
  requirement: !ruby/object:Gem::Requirement
58
29
  requirements:
59
30
  - - ">="
@@ -67,7 +38,7 @@ dependencies:
67
38
  - !ruby/object:Gem::Version
68
39
  version: '0'
69
40
  - !ruby/object:Gem::Dependency
70
- name: capistrano-rvm
41
+ name: capistrano-rails
71
42
  requirement: !ruby/object:Gem::Requirement
72
43
  requirements:
73
44
  - - ">="
@@ -81,7 +52,7 @@ dependencies:
81
52
  - !ruby/object:Gem::Version
82
53
  version: '0'
83
54
  - !ruby/object:Gem::Dependency
84
- name: capistrano3-puma
55
+ name: capistrano-rvm
85
56
  requirement: !ruby/object:Gem::Requirement
86
57
  requirements:
87
58
  - - ">="
@@ -111,15 +82,17 @@ dependencies:
111
82
  description: 'Encapsulates Operations commands for Rails Applications: Deploy, Diagnose,
112
83
  Monitoring, Version Releasing and Backup.'
113
84
  email:
114
- - juan@lebrijo.com
85
+ - jlebrijo@gmail.com
115
86
  executables: []
116
87
  extensions: []
117
88
  extra_rdoc_files: []
118
89
  files:
119
- - ".gitignore"
90
+ - ".rspec"
91
+ - ".rubocop.yml"
92
+ - ".rubocop_todo.yml"
120
93
  - ".ruby-version"
121
- - Gemfile
122
- - Gemfile.lock
94
+ - CHANGELOG.md
95
+ - CODE_OF_CONDUCT.md
123
96
  - LICENSE.txt
124
97
  - README.md
125
98
  - Rakefile
@@ -142,22 +115,26 @@ files:
142
115
  - lib/capistrano/config/yarn.rake
143
116
  - lib/capistrano/diagnosis.rake
144
117
  - lib/capistrano/git.rake
145
- - lib/capistrano/prun-ops.rb
146
- - lib/cred.rb
147
- - lib/prun-ops.rb
148
- - lib/prun-ops/railitie.rb
149
- - lib/prun-ops/version.rb
118
+ - lib/capistrano/prun_ops.rb
119
+ - lib/prun/cred.rb
120
+ - lib/prun/ops.rb
121
+ - lib/prun/ops/railitie.rb
122
+ - lib/prun/ops/version.rb
150
123
  - lib/tasks/backup.rake
151
124
  - lib/tasks/db.rake
152
125
  - lib/tasks/git.rake
153
126
  - lib/tasks/http.rake
154
127
  - lib/tasks/version.rake
155
- - prun-ops.gemspec
128
+ - sig/prun/ops.rbs
156
129
  homepage: http://github.com/jlebrijo/prun-ops
157
130
  licenses:
158
131
  - MIT
159
- metadata: {}
160
- post_install_message:
132
+ metadata:
133
+ allowed_push_host: https://rubygems.org
134
+ homepage_uri: http://github.com/jlebrijo/prun-ops
135
+ source_code_uri: http://github.com/jlebrijo/prun-ops
136
+ changelog_uri: http://github.com/jlebrijo/prun-ops/blob/master/CHANGELOG.md
137
+ rubygems_mfa_required: 'true'
161
138
  rdoc_options: []
162
139
  require_paths:
163
140
  - lib
@@ -165,15 +142,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
165
142
  requirements:
166
143
  - - ">="
167
144
  - !ruby/object:Gem::Version
168
- version: '0'
145
+ version: 3.1.0
169
146
  required_rubygems_version: !ruby/object:Gem::Requirement
170
147
  requirements:
171
148
  - - ">="
172
149
  - !ruby/object:Gem::Version
173
150
  version: '0'
174
151
  requirements: []
175
- rubygems_version: 3.0.9
176
- signing_key:
152
+ rubygems_version: 3.6.7
177
153
  specification_version: 4
178
154
  summary: Encapsulates Deployment and Manteinance Operations commands needed for a
179
155
  Rails Application.
data/.gitignore DELETED
@@ -1,16 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- #/Gemfile.lock
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
- /pkg/
8
- /spec/reports/
9
- /tmp/
10
- *.bundle
11
- *.so
12
- *.o
13
- *.a
14
- mkmf.log
15
- .idea
16
- *.gem
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in prun_ops.gemspec
4
- gemspec
data/Gemfile.lock DELETED
@@ -1,60 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- prun-ops (0.3.9)
5
- capistrano
6
- capistrano-rails
7
- capistrano-rvm
8
- capistrano3-puma
9
- newrelic_rpm
10
-
11
- GEM
12
- remote: https://rubygems.org/
13
- specs:
14
- airbrussh (1.5.3)
15
- sshkit (>= 1.6.1, != 1.7.0)
16
- capistrano (3.19.2)
17
- airbrussh (>= 1.0.0)
18
- i18n
19
- rake (>= 10.0.0)
20
- sshkit (>= 1.9.0)
21
- capistrano-bundler (2.1.1)
22
- capistrano (~> 3.1)
23
- capistrano-rails (1.7.0)
24
- capistrano (~> 3.1)
25
- capistrano-bundler (>= 1.1, < 3)
26
- capistrano-rvm (0.1.2)
27
- capistrano (~> 3.0)
28
- sshkit (~> 1.2)
29
- capistrano3-puma (3.1.1)
30
- capistrano (~> 3.7)
31
- capistrano-bundler
32
- puma (~> 3.4)
33
- concurrent-ruby (1.1.9)
34
- i18n (1.5.1)
35
- concurrent-ruby (~> 1.0)
36
- mutex_m (0.1.2)
37
- net-scp (4.1.0)
38
- net-ssh (>= 2.6.5, < 8.0.0)
39
- net-sftp (2.1.2)
40
- net-ssh (>= 2.6.5)
41
- net-ssh (4.2.0)
42
- newrelic_rpm (8.2.0)
43
- puma (3.11.4)
44
- rake (10.3.2)
45
- sshkit (1.22.0)
46
- mutex_m
47
- net-scp (>= 1.1.2)
48
- net-sftp (>= 2.1.2)
49
- net-ssh (>= 2.8.0)
50
-
51
- PLATFORMS
52
- ruby
53
-
54
- DEPENDENCIES
55
- bundler
56
- prun-ops!
57
- rake
58
-
59
- BUNDLED WITH
60
- 1.17.3
@@ -1,3 +0,0 @@
1
- module PrunOps
2
- VERSION = "0.3.9"
3
- end
data/lib/prun-ops.rb DELETED
@@ -1,10 +0,0 @@
1
- require "prun-ops/version"
2
- require "cred"
3
-
4
- module PrunOps
5
- require 'prun-ops/railitie' if defined?(Rails)
6
-
7
- if defined?(Rails) && (Rails.env == 'development')
8
- Rails.logger = Logger.new(STDOUT)
9
- end
10
- end
data/prun-ops.gemspec DELETED
@@ -1,28 +0,0 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'prun-ops/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "prun-ops"
8
- spec.version = PrunOps::VERSION
9
- spec.authors = ["Juan Lebrijo"]
10
- spec.email = ["juan@lebrijo.com"]
11
- spec.summary = %q{Encapsulates Deployment and Manteinance Operations commands needed for a Rails Application.}
12
- spec.description = %q{Encapsulates Operations commands for Rails Applications: Deploy, Diagnose, Monitoring, Version Releasing and Backup.}
13
- spec.homepage = "http://github.com/jlebrijo/prun-ops"
14
- spec.license = "MIT"
15
-
16
- spec.files = `git ls-files -z`.split("\x0")
17
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
- spec.require_paths = ["lib"]
19
-
20
- spec.add_development_dependency "bundler"
21
- spec.add_development_dependency "rake"
22
-
23
- spec.add_runtime_dependency 'capistrano'
24
- spec.add_runtime_dependency 'capistrano-rails'
25
- spec.add_runtime_dependency 'capistrano-rvm'
26
- spec.add_runtime_dependency 'capistrano3-puma'
27
- spec.add_runtime_dependency 'newrelic_rpm'
28
- end