capistrano-ops 1.0.11 → 1.2.0

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 (60) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +18 -0
  3. data/.github/workflows/ci.yml +44 -0
  4. data/.github/workflows/release.yml +1 -1
  5. data/.gitignore +1 -0
  6. data/.rspec +3 -0
  7. data/.rubocop.yml +4 -5
  8. data/.rubocop_todo.yml +55 -0
  9. data/.ruby-version +1 -1
  10. data/CHANGELOG.md +48 -1
  11. data/README.md +101 -5
  12. data/Rakefile +5 -1
  13. data/bin/console +1 -1
  14. data/capistrano-ops.gemspec +10 -8
  15. data/lib/capistrano/ops/backup/helper.rb +4 -4
  16. data/lib/capistrano/ops/backup/tasks/database/create.rake +1 -0
  17. data/lib/capistrano/ops/backup/tasks/database/pull.rake +1 -0
  18. data/lib/capistrano/ops/backup/tasks/storage/create.rake +1 -0
  19. data/lib/capistrano/ops/backup/tasks/storage/pull.rake +1 -0
  20. data/lib/capistrano/ops/capistrano.rb +1 -0
  21. data/lib/capistrano/ops/figaro_yml/helpers.rb +3 -6
  22. data/lib/capistrano/ops/figaro_yml/tasks/check.rake +1 -0
  23. data/lib/capistrano/ops/figaro_yml/tasks/check_config_present.rake +1 -0
  24. data/lib/capistrano/ops/figaro_yml/tasks/check_figaro_file_exists.rake +1 -0
  25. data/lib/capistrano/ops/figaro_yml/tasks/check_git_tracking.rake +1 -0
  26. data/lib/capistrano/ops/figaro_yml/tasks/create_local.rake +1 -0
  27. data/lib/capistrano/ops/figaro_yml/tasks/figaro_yml_symlink.rake +1 -0
  28. data/lib/capistrano/ops/figaro_yml/tasks/get.rake +4 -3
  29. data/lib/capistrano/ops/figaro_yml/tasks/get_stage.rake +1 -0
  30. data/lib/capistrano/ops/figaro_yml/tasks/sort_local.rake +1 -0
  31. data/lib/capistrano/ops/figaro_yml.rb +2 -1
  32. data/lib/capistrano/ops/invoke/tasks/invoke.rake +1 -1
  33. data/lib/capistrano/ops/local/helpers.rb +71 -0
  34. data/lib/capistrano/ops/local/tasks/console.rake +59 -0
  35. data/lib/capistrano/ops/local/tasks/run.rake +40 -0
  36. data/lib/capistrano/ops/local.rb +9 -0
  37. data/lib/capistrano/ops/logrotate/paths.rb +2 -0
  38. data/lib/capistrano/ops/logrotate/tasks/disable.rake +1 -0
  39. data/lib/capistrano/ops/logrotate.rb +2 -1
  40. data/lib/capistrano/ops/rails/lib/backup/api.rb +1 -1
  41. data/lib/capistrano/ops/rails/lib/backup/s3.rb +9 -8
  42. data/lib/capistrano/ops/rails/lib/backup.rb +2 -0
  43. data/lib/capistrano/ops/rails/lib/notification/api.rb +1 -1
  44. data/lib/capistrano/ops/rails/lib/notification/slack.rb +4 -4
  45. data/lib/capistrano/ops/rails/lib/notification/webhook.rb +4 -4
  46. data/lib/capistrano/ops/rails/lib/tasks/pg/dump.rake +3 -3
  47. data/lib/capistrano/ops/rails/lib/tasks/pg/postgres_helper.rb +3 -3
  48. data/lib/capistrano/ops/rails/lib/tasks/pg/remove_old_dumps.rake +1 -1
  49. data/lib/capistrano/ops/rails/lib/tasks/storage/backup.rake +1 -1
  50. data/lib/capistrano/ops/rails/lib/tasks/storage/remove_old_backups.rake +2 -2
  51. data/lib/capistrano/ops/rails/lib/tasks/storage/storage_helper.rb +5 -5
  52. data/lib/capistrano/ops/version.rb +1 -1
  53. data/lib/capistrano/ops/whenever.rb +2 -1
  54. data/lib/capistrano/ops/wkhtmltopdf/tasks/setup.rake +1 -0
  55. data/spec/capistrano/ops/local/helpers_spec.rb +121 -0
  56. data/spec/capistrano/ops/version_spec.rb +9 -0
  57. data/spec/spec_helper.rb +20 -0
  58. metadata +63 -27
  59. data/.travis.yml +0 -13
  60. data/lib/capistrano/ops/capistrano/v3/tasks/backup.rake +0 -25
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b8c94fd6b958f219478ce26ed0631cd216f3b145701d55cd4192819ab9afecc5
4
- data.tar.gz: fc29a70471fdd88d40ab72f17a3b5f0fd4aac4e71d93215143bc971778d4c070
3
+ metadata.gz: fe9dc820d50c226c74d26afad1f5031651bdf9758c220268cfe1d8721416b011
4
+ data.tar.gz: 5ac2da6ebbd2a6d7ba4bebf031b2bd3b690f30367ce48437a8c2656a2b65ec44
5
5
  SHA512:
6
- metadata.gz: c0d8bbebfdbe41493e8844f6dbca9561fa76e321d1c9024d76880d43aa1a001d941f556631df188c29958f28467f4deafd09bd999fb5c420be328e324adc1265
7
- data.tar.gz: a8dbc8d0b748e510fa29ca51f56a6764b5daa0313503e011fd8e451e813105c83a2e844825b976521857f6378f7208d7102c4f263a2d5672030c73a554118e13
6
+ metadata.gz: de3334c09fe3b2f7cb113d13d8a309d5466464c438499e684531e015d888f73cdc8e2f7d033bbe96cf9bebab64c89ba8c18d1b74cae48ed6df5172ea47741302
7
+ data.tar.gz: 3d177c55f3fcf475f030f67222a0a14b715f712f4627ae6c96db27e8f75a2af162015080410d7bbd0f822b854cbfd88e5e16df668cca21132ddd4cbccd462177
@@ -0,0 +1,18 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: bundler
4
+ directory: "/"
5
+ schedule:
6
+ interval: weekly
7
+ open-pull-requests-limit: 5
8
+ labels:
9
+ - dependencies
10
+ - ruby
11
+
12
+ - package-ecosystem: github-actions
13
+ directory: "/"
14
+ schedule:
15
+ interval: weekly
16
+ labels:
17
+ - dependencies
18
+ - ci
@@ -0,0 +1,44 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+
8
+ jobs:
9
+ lint:
10
+ name: RuboCop
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - uses: actions/checkout@v4
14
+ - uses: ruby/setup-ruby@v1
15
+ with:
16
+ ruby-version-file: .ruby-version
17
+ bundler-cache: true
18
+ - run: bundle exec rubocop --parallel
19
+
20
+ audit:
21
+ name: bundler-audit
22
+ runs-on: ubuntu-latest
23
+ steps:
24
+ - uses: actions/checkout@v4
25
+ - uses: ruby/setup-ruby@v1
26
+ with:
27
+ ruby-version-file: .ruby-version
28
+ bundler-cache: true
29
+ - run: bundle exec bundle-audit check --update
30
+
31
+ test:
32
+ name: RSpec (Ruby ${{ matrix.ruby }})
33
+ runs-on: ubuntu-latest
34
+ strategy:
35
+ fail-fast: false
36
+ matrix:
37
+ ruby: ['3.2', '3.3', '3.4']
38
+ steps:
39
+ - uses: actions/checkout@v4
40
+ - uses: ruby/setup-ruby@v1
41
+ with:
42
+ ruby-version: ${{ matrix.ruby }}
43
+ bundler-cache: true
44
+ - run: bundle exec rspec
@@ -19,7 +19,7 @@ jobs:
19
19
  - name: Set up Ruby
20
20
  uses: ruby/setup-ruby@v1
21
21
  with:
22
- ruby-version: '3.3'
22
+ ruby-version-file: .ruby-version
23
23
  bundler-cache: true
24
24
 
25
25
  - uses: rubygems/release-gem@v1
data/.gitignore CHANGED
@@ -1,4 +1,5 @@
1
1
  /.bundle/
2
+ /.ruby-lsp/
2
3
  /.yardoc
3
4
  /Gemfile.lock
4
5
  /_yardoc/
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --require spec_helper
2
+ --format documentation
3
+ --color
data/.rubocop.yml CHANGED
@@ -1,8 +1,10 @@
1
- # RuboCop configuration for ms-graph-mailer gem
1
+ inherit_from: .rubocop_todo.yml
2
+
3
+ # RuboCop configuration for capistrano-ops gem
2
4
 
3
5
  AllCops:
4
6
  NewCops: enable
5
- TargetRubyVersion: 3.1
7
+ TargetRubyVersion: 3.2
6
8
  SuggestExtensions: false
7
9
  Exclude:
8
10
  - 'vendor/**/*'
@@ -78,9 +80,6 @@ Layout/SpaceAroundMethodCallOperator:
78
80
  Gemspec/DevelopmentDependencies:
79
81
  Enabled: false
80
82
 
81
- Gemspec/RequireMFA:
82
- Enabled: false
83
-
84
83
  Lint/RaiseException:
85
84
  Enabled: true
86
85
 
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,55 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config --auto-gen-only-exclude --no-auto-gen-timestamp`
3
+ # using RuboCop version 1.91.0.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 3
10
+ # This cop supports safe autocorrection (--autocorrect).
11
+ # Configuration parameters: Max, AllowHeredoc, AllowURI, AllowQualifiedName, URISchemes, AllowRBSInlineAnnotation, AllowCopDirectives, AllowedPatterns, SplitStrings.
12
+ # URISchemes: http, https
13
+ Layout/LineLength:
14
+ Exclude:
15
+ - 'lib/capistrano/ops/rails/lib/tasks/pg/dump.rake'
16
+ - 'lib/capistrano/ops/rails/lib/tasks/storage/storage_helper.rb'
17
+
18
+ # Offense count: 1
19
+ # Configuration parameters: CountComments, Max, CountAsOne.
20
+ Metrics/ClassLength:
21
+ Exclude:
22
+ - 'lib/capistrano/ops/rails/lib/backup/s3.rb'
23
+
24
+ # Offense count: 1
25
+ # Configuration parameters: AllowedMethods, AllowedPatterns, Max.
26
+ Metrics/CyclomaticComplexity:
27
+ Exclude:
28
+ - 'lib/capistrano/ops/rails/lib/backup/s3.rb'
29
+
30
+ # Offense count: 1
31
+ # Configuration parameters: AllowedMethods, AllowedPatterns, Max.
32
+ Metrics/PerceivedComplexity:
33
+ Exclude:
34
+ - 'lib/capistrano/ops/rails/lib/backup/s3.rb'
35
+
36
+ # Offense count: 2
37
+ # Configuration parameters: Mode, AllowedMethods, AllowedPatterns, AllowBangMethods, WaywardPredicates.
38
+ # AllowedMethods: call
39
+ # WaywardPredicates: infinite?, nonzero?
40
+ Naming/PredicateMethod:
41
+ Exclude:
42
+ - 'lib/capistrano/ops/figaro_yml/helpers.rb'
43
+ - 'lib/capistrano/ops/logrotate/helpers.rb'
44
+
45
+ # Offense count: 1
46
+ Style/MultilineBlockChain:
47
+ Exclude:
48
+ - 'lib/capistrano/ops/figaro_yml/helpers.rb'
49
+
50
+ # Offense count: 1
51
+ # Configuration parameters: AllowedMethods.
52
+ # AllowedMethods: respond_to_missing?
53
+ Style/OptionalBooleanParameter:
54
+ Exclude:
55
+ - 'lib/capistrano/ops/rails/lib/tasks/storage/storage_helper.rb'
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.1.4
1
+ 3.4.10
data/CHANGELOG.md CHANGED
@@ -7,6 +7,51 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [1.2.0] - 2026-09-18
11
+
12
+ ### Added
13
+
14
+ - Add `local:run` and `local:console` tasks (module `capistrano/ops/local`) to upload a local Ruby script from `scripts/local/` to the server and execute it — once via `rails runner`, or interactively with a Rails console
15
+ - Helpers module `Capistrano::Ops::Local::Helpers` with script resolution (auto `.rb`), listing, TTY-aware coloring, and dangerous-stage confirmation
16
+ - Configurable settings: `:local_scripts_dir`, `:local_dangerous_stages`; existing `:console_role`, `:console_env`, `:console_user`, `:console_shell` respected
17
+ - Specs for helpers (script resolution, TTY coloring, tmp-path generation)
18
+ - README section documenting the new tasks, including `capistrano-rails` prerequisite for `local:console`
19
+
20
+ ## [1.1.0] - 2026-09-18
21
+
22
+ ### Added
23
+
24
+ - Add CI workflow (`.github/workflows/ci.yml`) with a Ruby matrix (3.2, 3.3, 3.4) running RSpec, plus separate RuboCop and bundler-audit jobs
25
+ - Add Dependabot config for weekly `bundler` and `github-actions` updates
26
+ - Add `bundler-audit` dev-dependency and Rake task
27
+ - Add minimal spec harness (`spec/spec_helper.rb`, `.rspec`, version smoke spec)
28
+ - Add `.rubocop_todo.yml` baseline for new cops that would require API-shape changes (metrics, predicate naming, keyword args)
29
+
30
+ ### Changed
31
+
32
+ - Widen `required_ruby_version` to `>= 3.2` (previously `>= 3.1.4, < 3.4.0` — blocked Ruby 3.4/3.5)
33
+ - Add version bounds for `rails` (`>= 7.2, < 9`), `faraday` (`>= 2.0, < 3.0`) and `nokogiri` (`>= 1.15`)
34
+ - Bump `.ruby-version` to `3.4.10`; release workflow now reads it via `ruby-version-file`
35
+ - Bump `.rubocop.yml` `TargetRubyVersion` to `3.2` and enable `Gemspec/RequireMFA`
36
+ - Bump dev-dependencies: `bundler >= 2.4, < 5`, `rubocop ~> 1.80`, `rubocop-rake ~> 0.7`, `rubocop-rspec ~> 3.0`
37
+ - `rake` default now runs `spec` + `rubocop`
38
+
39
+ ### Removed
40
+
41
+ - Remove obsolete `.travis.yml` (Travis CI is end-of-life)
42
+ - Remove stray `release.gem` build artifact from repo root
43
+ - Remove dead `lib/capistrano/ops/capistrano/v3/tasks/backup.rake`: never wired into `TaskLoader`, required a non-existent `backup_helper` file, and its deprecated tasks (`backup:create` / `backup:pull`) had been superseded by `backup:database:*`
44
+
45
+ ### Fixed
46
+
47
+ - Fix `NameError` in `Notification::Webhook#backup_notification` when notification level was `error` on a successful backup (`_notification_level` param was referenced without the underscore)
48
+ - Fix `bin/console`: required non-existent `capistrano/rake`; now requires `capistrano/ops`
49
+ - Correct copy-paste header in `.rubocop.yml` (was labeled for `ms-graph-mailer`)
50
+
51
+ ### Docs
52
+
53
+ - Clarify optional runtime dependencies (`whenever`, `figaro`, `wicked_pdf`) in README; state Ruby and Rails floors explicitly
54
+
10
55
  ## [1.0.11] - 2025-12-22
11
56
 
12
57
  ### Added
@@ -276,7 +321,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
276
321
  - Figaro YAML management
277
322
  - Basic Capistrano integration
278
323
 
279
- [Unreleased]: https://github.com/zauberware/capistrano-ops/compare/v1.0.11...HEAD
324
+ [Unreleased]: https://github.com/zauberware/capistrano-ops/compare/v1.2.0...HEAD
325
+ [1.2.0]: https://github.com/zauberware/capistrano-ops/releases/tag/v1.2.0
326
+ [1.1.0]: https://github.com/zauberware/capistrano-ops/releases/tag/v1.1.0
280
327
  [1.0.11]: https://github.com/zauberware/capistrano-ops/releases/tag/v1.0.11
281
328
  [v1.0.10]: https://github.com/zauberware/capistrano-ops/compare/v1.0.9...v1.0.10
282
329
  [v1.0.9]: https://github.com/zauberware/capistrano-ops/compare/v1.0.8...v1.0.9
data/README.md CHANGED
@@ -24,6 +24,7 @@ The capistrano-ops gem is a valuable library, tailor-made for Rails DevOps profe
24
24
  - [Configuration](#configuration-1)
25
25
  - [Usage](#usage-1)
26
26
  - [Wkhtmltopdf Setup](#wkhtmltopdf-setup)
27
+ - [Local scripts (run / console)](#local-scripts-run--console)
27
28
  - [Contributing](#contributing)
28
29
  - [License](#license)
29
30
 
@@ -78,14 +79,23 @@ The capistrano-ops gem is a valuable library, tailor-made for Rails DevOps profe
78
79
 
79
80
  ## Requirements
80
81
 
81
- ```ruby
82
- 'capistrano', '~> 3.0'
83
- 'whenever' # for scheduling tasks
84
- 'figaro' # for environment variables if you use figaro_yml tasks
82
+ Runtime requirements pulled in by the gem itself:
83
+
84
+ - Ruby `>= 3.2`
85
+ - Rails `>= 7.2, < 9`
86
+ - `capistrano ~> 3.0` (in your app)
87
+
88
+ Optional runtime dependencies — the corresponding task groups are only
89
+ loaded when the gem is present in your `Gemfile`:
85
90
 
86
- # hint: if you use other aws-sdk gems, its possible that you have to update them too
91
+ ```ruby
92
+ gem 'whenever' # enables whenever:show_crontab
93
+ gem 'figaro' # enables figaro_yml:* tasks
94
+ gem 'wicked_pdf' # enables wkhtmltopdf:setup (with wkhtmltopdf-binary)
87
95
  ```
88
96
 
97
+ > hint: if you use other aws-sdk gems, it's possible that you have to update them too
98
+
89
99
  [↑](#)
90
100
 
91
101
  ## Installation
@@ -161,6 +171,8 @@ require 'capistrano/ops'
161
171
  | `cap <environment> logrotate:enable` | enable logrotate for logfiles on server |
162
172
  | `cap <environment> logrotate:disable` | disable logrotate for logfiles on server |
163
173
  | `cap <environment> logrotate:check` | show logrotate status for logfiles on server |
174
+ | `cap <environment> local:run SCRIPT=<file>` | upload local script and execute it once via `rails runner` on the server |
175
+ | `cap <environment> local:console SCRIPT=<file>` | open a remote Rails console with a local script preloaded |
164
176
  | `rake pg:dump` | creates postgres database backup |
165
177
  | `rake pg:remove_old_dumps` | remove old postgres backups |
166
178
  | `rake storage:backup` | creates backup of storage |
@@ -381,6 +393,90 @@ require 'capistrano/ops/wkhtmltopdf'
381
393
 
382
394
  [↑](#)
383
395
 
396
+ ## Local scripts (run / console)
397
+
398
+ Ship a Ruby script from your workstation onto the server and execute it there —
399
+ either once via `rails runner`, or with a Rails console attached and the
400
+ script's methods preloaded. Useful for one-off data patches, ad-hoc audits, or
401
+ debugging sessions where you want your local scratch code to have full access
402
+ to the production Rails environment.
403
+
404
+ ### Requirements
405
+
406
+ `local:console` uses the interactive console runner shipped in `capistrano-rails`.
407
+ Make sure both are loaded in your `Capfile`:
408
+
409
+ ```ruby
410
+ # Capfile
411
+ require 'capistrano/rails/console' # provides run_interactively (needed by local:console)
412
+ require 'capistrano/ops' # auto-loads capistrano/ops/local
413
+ ```
414
+
415
+ If `capistrano-rails` is not in your Gemfile, the `local:*` tasks will emit a
416
+ warning at load time and skip registering. `local:run` alone technically only
417
+ needs core Capistrano, but for simplicity both tasks share the same gate.
418
+
419
+ ### Setup
420
+
421
+ Create the scripts directory in your app root (default `scripts/local/`) and
422
+ drop `.rb` files in it:
423
+
424
+ ```
425
+ scripts/local/
426
+ ├── check_stuck_jobs.rb
427
+ └── set_welcome_email_template.rb
428
+ ```
429
+
430
+ The directory is configurable:
431
+
432
+ ```ruby
433
+ # config/deploy.rb
434
+ set :local_scripts_dir, 'ops/scripts' # default: 'scripts/local'
435
+ ```
436
+
437
+ ### Tasks
438
+
439
+ ```bash
440
+ cap staging local:run SCRIPT=check_stuck_jobs # execute once via rails runner
441
+ cap staging local:console SCRIPT=check_stuck_jobs # open remote console with script preloaded
442
+ ```
443
+
444
+ - `.rb` extension is optional (`SCRIPT=foo` and `SCRIPT=foo.rb` both work)
445
+ - Omitting `SCRIPT=` prints the list of available scripts
446
+ - Interactive `[y/N]` confirmation on "dangerous" stages (default: `production`)
447
+ - Uploaded temp files are cleaned up automatically after execution
448
+
449
+ ### Writing scripts
450
+
451
+ Define methods rather than top-level code — this way the same script works for
452
+ both `local:run` (direct execution) and `local:console` (interactive access):
453
+
454
+ ```ruby
455
+ # scripts/local/check_stuck_jobs.rb
456
+ def show_stuck_jobs(hours_ago: 24)
457
+ cutoff = hours_ago.hours.ago
458
+ Sidekiq::Workers.new.select { |_, _, w| Time.at(w['run_at']) < cutoff }.each do |process, _, work|
459
+ puts "#{work['payload']['class']} on #{process}"
460
+ end
461
+ end
462
+
463
+ # auto-run when executed via local:run, dormant in the console
464
+ show_stuck_jobs unless defined?(IRB)
465
+ ```
466
+
467
+ ### Configuration options
468
+
469
+ | Setting | Default | Purpose |
470
+ | -------------------------- | ------------------------------- | ---------------------------------------------- |
471
+ | `:local_scripts_dir` | `'scripts/local'` | Where local scripts are read from |
472
+ | `:local_dangerous_stages` | `%w[production]` | Stages that trigger the `[y/N]` confirmation |
473
+ | `:console_role` | `:app` | Capistrano role used to pick the target host |
474
+ | `:console_env` | `fetch(:rails_env) \|\| :stage` | Rails env passed to `rails runner` / `console` |
475
+ | `:console_user` | (unset) | `sudo -u` target user for the remote command |
476
+ | `:console_shell` | (unset) | Shell override for the interactive session |
477
+
478
+ [↑](#)
479
+
384
480
  ## Contributing
385
481
 
386
482
  1. Fork it ( https://github.com/zauberware/capistrano-ops/fork )
data/Rakefile CHANGED
@@ -2,10 +2,14 @@
2
2
 
3
3
  require 'bundler/gem_tasks'
4
4
  require 'rspec/core/rake_task'
5
+ require 'rubocop/rake_task'
6
+ require 'bundler/audit/task'
5
7
 
6
8
  RSpec::Core::RakeTask.new(:spec)
9
+ RuboCop::RakeTask.new
10
+ Bundler::Audit::Task.new
7
11
 
8
- task default: :spec
12
+ task default: %i[spec rubocop]
9
13
 
10
14
  namespace :version do
11
15
  desc 'Bump patch version (0.1.0 -> 0.1.1)'
data/bin/console CHANGED
@@ -2,7 +2,7 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require 'bundler/setup'
5
- require 'capistrano/rake'
5
+ require 'capistrano/ops'
6
6
 
7
7
  # You can add fixtures and/or initialization code here to make experimenting
8
8
  # with your gem easier. You can also use a different console, if you like.
@@ -18,15 +18,17 @@ Gem::Specification.new do |s|
18
18
  s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
19
19
  s.require_paths = ['lib']
20
20
 
21
- s.required_ruby_version = '>= 3.1.4', '< 3.4.0'
21
+ s.required_ruby_version = '>= 3.2'
22
22
  s.add_dependency 'aws-sdk-s3', '~> 1.208'
23
- s.add_dependency 'faraday'
24
- s.add_dependency 'nokogiri'
25
- s.add_dependency 'rails'
26
- s.add_development_dependency 'bundler', '~> 2.0'
23
+ s.add_dependency 'faraday', '>= 2.0', '< 3.0'
24
+ s.add_dependency 'nokogiri', '>= 1.15'
25
+ s.add_dependency 'rails', '>= 7.2', '< 9'
26
+ s.add_development_dependency 'bundler', '>= 2.4', '< 5'
27
+ s.add_development_dependency 'bundler-audit', '~> 0.9'
27
28
  s.add_development_dependency 'rake', '~> 13.0'
28
29
  s.add_development_dependency 'rspec', '~> 3.0'
29
- s.add_development_dependency 'rubocop', '~> 1.0'
30
- s.add_development_dependency 'rubocop-rake', '~> 0.6'
31
- s.add_development_dependency 'rubocop-rspec', '~> 2.0'
30
+ s.add_development_dependency 'rubocop', '~> 1.80'
31
+ s.add_development_dependency 'rubocop-rake', '~> 0.7'
32
+ s.add_development_dependency 'rubocop-rspec', '~> 3.0'
33
+ s.metadata['rubygems_mfa_required'] = 'true'
32
34
  end
@@ -5,7 +5,7 @@ module Capistrano
5
5
  module Backup
6
6
  module Helper
7
7
  def backup_file_name(type)
8
- regex = type == 'storage' ? "'.{0,}\.tar.gz'" : "'.{0,}\.dump'"
8
+ regex = type == 'storage' ? "'.{0,}.tar.gz'" : "'.{0,}.dump'"
9
9
  @backup_file_name ||= capture "cd #{shared_path}/backups && ls -lt | grep -E -i #{regex} | head -n 1 | awk '{print $9}'"
10
10
  end
11
11
 
@@ -26,7 +26,7 @@ module Capistrano
26
26
  puts 'Temporary backup deleted'
27
27
  end
28
28
 
29
- def question(question, default = 'n', &block)
29
+ def question(question, default = 'n', &)
30
30
  print "#{question} #{default.downcase == 'n' ? '(y/N)' : '(Y/n)'}: "
31
31
  input = $stdin.gets.strip.downcase
32
32
  answer = (input.empty? ? default : input).downcase.to_s
@@ -34,7 +34,7 @@ module Capistrano
34
34
  if %w[y n].include?(answer)
35
35
  yield(answer == 'y')
36
36
  else
37
- question(question, default, &block)
37
+ question(question, default, &)
38
38
  end
39
39
  end
40
40
 
@@ -47,7 +47,7 @@ module Capistrano
47
47
  def size_str(size)
48
48
  units = %w[B KB MB GB TB]
49
49
  e = (Math.log(size) / Math.log(1024)).floor
50
- s = format('%.2f', size.to_f / 1024**e)
50
+ s = format('%.2f', size.to_f / (1024**e))
51
51
  s.sub(/\.?0*$/, units[e])
52
52
  end
53
53
  end
@@ -3,6 +3,7 @@
3
3
  namespace :backup do
4
4
  namespace :database do
5
5
  include Capistrano::Ops::Backup::Helper
6
+
6
7
  # Default to :app role
7
8
  rake_roles = fetch(:rake_roles, :app)
8
9
 
@@ -3,6 +3,7 @@
3
3
  namespace :backup do
4
4
  namespace :database do
5
5
  include Capistrano::Ops::Backup::Helper
6
+
6
7
  # Default to :app role
7
8
  rake_roles = fetch(:rake_roles, :app)
8
9
 
@@ -3,6 +3,7 @@
3
3
  namespace :backup do
4
4
  namespace :storage do
5
5
  include Capistrano::Ops::Backup::Helper
6
+
6
7
  # Default to :app role
7
8
  rake_roles = fetch(:rake_roles, :app)
8
9
 
@@ -3,6 +3,7 @@
3
3
  namespace :backup do
4
4
  namespace :storage do
5
5
  include Capistrano::Ops::Backup::Helper
6
+
6
7
  # Default to :app role
7
8
  rake_roles = fetch(:rake_roles, :app)
8
9
  desc 'pull latest storage dump from server to local'
@@ -7,6 +7,7 @@ require 'capistrano/ops/logrotate'
7
7
  require 'capistrano/ops/logs'
8
8
  require 'capistrano/ops/invoke'
9
9
  require 'capistrano/ops/backup'
10
+ require 'capistrano/ops/local'
10
11
 
11
12
  unless defined?(Capistrano::VERSION) && Gem::Version.new(Capistrano::VERSION).release >= Gem::Version.new('3.0.0')
12
13
  puts 'Capistrano 3 is required to use this gem'
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'yaml'
4
4
 
5
- # rubocop:disable Metrics/ModuleLength
5
+ # rubocop:disable-next Metrics/ModuleLength
6
6
  module Capistrano
7
7
  module Ops
8
8
  module FigaroYml
@@ -63,7 +63,7 @@ module Capistrano
63
63
  end
64
64
 
65
65
  def local_yaml
66
- YAML.safe_load(File.read(figaro_yml_local_path)) || {}
66
+ YAML.safe_load_file(figaro_yml_local_path) || {}
67
67
  end
68
68
 
69
69
  def figaro_yml_env
@@ -162,9 +162,7 @@ module Capistrano
162
162
 
163
163
  # file helpers
164
164
  def write_to_file(file, content)
165
- File.open(file, 'w') do |f|
166
- f.write(content)
167
- end
165
+ File.write(file, content)
168
166
  end
169
167
 
170
168
  def write_combined_yaml(yamls_combined)
@@ -180,4 +178,3 @@ module Capistrano
180
178
  end
181
179
  end
182
180
  end
183
- # rubocop:enable Metrics/ModuleLength
@@ -3,6 +3,7 @@
3
3
  namespace :figaro_yml do
4
4
  include Capistrano::Ops::FigaroYml::Paths
5
5
  include Capistrano::Ops::FigaroYml::Helpers
6
+
6
7
  desc 'figaro `application.yml` file checks'
7
8
  task :check do
8
9
  invoke 'figaro_yml:check_figaro_file_exists'
@@ -3,6 +3,7 @@
3
3
  namespace :figaro_yml do
4
4
  include Capistrano::Ops::FigaroYml::Paths
5
5
  include Capistrano::Ops::FigaroYml::Helpers
6
+
6
7
  task :check_config_present do
7
8
  next unless local_figaro_yml(figaro_yml_env).nil?
8
9
 
@@ -3,6 +3,7 @@
3
3
  namespace :figaro_yml do
4
4
  include Capistrano::Ops::FigaroYml::Paths
5
5
  include Capistrano::Ops::FigaroYml::Helpers
6
+
6
7
  task :check_figaro_file_exists do
7
8
  next if File.exist?(figaro_yml_local_path)
8
9
 
@@ -3,6 +3,7 @@
3
3
  namespace :figaro_yml do
4
4
  include Capistrano::Ops::FigaroYml::Paths
5
5
  include Capistrano::Ops::FigaroYml::Helpers
6
+
6
7
  task :check_git_tracking do
7
8
  next unless system("git ls-files #{fetch(:figaro_yml_local_path)} --error-unmatch >/dev/null 2>&1")
8
9
 
@@ -3,6 +3,7 @@
3
3
  namespace :figaro_yml do
4
4
  include Capistrano::Ops::FigaroYml::Paths
5
5
  include Capistrano::Ops::FigaroYml::Helpers
6
+
6
7
  task :create_local do
7
8
  run_locally do
8
9
  puts "found #{stages.count} stages"
@@ -3,6 +3,7 @@
3
3
  namespace :figaro_yml do
4
4
  include Capistrano::Ops::FigaroYml::Paths
5
5
  include Capistrano::Ops::FigaroYml::Helpers
6
+
6
7
  task :figaro_yml_symlink do
7
8
  set :linked_files, fetch(:linked_files, []).push(fetch(:figaro_yml_remote_path))
8
9
  end
@@ -3,10 +3,9 @@
3
3
  namespace :figaro_yml do
4
4
  include Capistrano::Ops::FigaroYml::Paths
5
5
  include Capistrano::Ops::FigaroYml::Helpers
6
+
6
7
  task :get do
7
- if !File.exist?(figaro_yml_local_path)
8
- invoke 'figaro_yml:create_local'
9
- else
8
+ if File.exist?(figaro_yml_local_path)
10
9
  local_yml = local_figaro_yml(figaro_yml_env)
11
10
  local_global, local_stage, local_rest = configs(local_yml, figaro_yml_env)
12
11
  on release_roles :all do
@@ -40,6 +39,8 @@ namespace :figaro_yml do
40
39
  # write to new file
41
40
  write_combined_yaml(composed_yml.sort.to_h)
42
41
  end
42
+ else
43
+ invoke 'figaro_yml:create_local'
43
44
  end
44
45
  end
45
46
  end
@@ -3,6 +3,7 @@
3
3
  namespace :figaro_yml do
4
4
  include Capistrano::Ops::FigaroYml::Paths
5
5
  include Capistrano::Ops::FigaroYml::Helpers
6
+
6
7
  rake_roles = fetch(:rake_roles, :app)
7
8
 
8
9
  task :get_stage do
@@ -3,6 +3,7 @@
3
3
  namespace :figaro_yml do
4
4
  include Capistrano::Ops::FigaroYml::Paths
5
5
  include Capistrano::Ops::FigaroYml::Helpers
6
+
6
7
  task :sort_local do
7
8
  run_locally do
8
9
  info 'Sorting local application.yml...'
@@ -4,4 +4,5 @@ require 'capistrano/ops/task_loader'
4
4
  require 'capistrano/ops/figaro_yml/paths'
5
5
  require 'capistrano/ops/figaro_yml/helpers'
6
6
 
7
- TaskLoader.load_tasks_if_gem_present('figaro', 'figaro_yml/tasks', 'WARNING: Gemfile does not include figaro gem which is required for figaro_yml tasks')
7
+ TaskLoader.load_tasks_if_gem_present('figaro', 'figaro_yml/tasks',
8
+ 'WARNING: Gemfile does not include figaro gem which is required for figaro_yml tasks')