expire 0.2.2 → 0.2.4

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: 95ad9d50ba3a040c262e441236fd4c0edbe0391581583e4fa5386e995a5127c7
4
- data.tar.gz: 0b3c1fdf36581f4dec6e3e70b96fca8daefd3851b8549c07249d95c96748f0ba
3
+ metadata.gz: 57e88d0a5839162fefb355cc820dd6430916414e6d4ee5d9ee5ae330fa1cc7b8
4
+ data.tar.gz: aa49b1799dd8a22240ef021f7d5851396b1274cd09ef9d33e403c2a69728f2e5
5
5
  SHA512:
6
- metadata.gz: cb1c79e5290fe70589afd40e95cdad51ea74b957ca9f5c83191258072e06e20d7f293ac5f9fe7a72192aa990fa19ec534b5bb4e368fb2b22a570c1acc459c64c
7
- data.tar.gz: c3c2555dc1378409001f7ef40d42e04e65a0678181053d5ccf6dfd0b8234e4b3540996c32fc2e9e264b1715baa5a3d0ab7f48edc7e03f9005425f30a6fcd5829
6
+ metadata.gz: 1cf762f329fab2daa59ace79cecdec71acef846aa5f36c88e22bd015f60b36923ea6a757ca65e9a0a4182754193a2dde9d3048e35a1956abe99899b1509caf5f
7
+ data.tar.gz: ac24d2ac7a8626bca4265dda6253f5ba2690297343f3ac3390abc7e659c8f9f59adb4f3fa4fc9df697ef41b9aa8a1ce5cdfe19e4fc1125baf3c6cdf6e0fc224b
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
3
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
4
4
 
5
5
  # Specify your gem's dependencies in expire.gemspec
6
6
  gemspec
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- expire (0.2.2)
4
+ expire (0.2.4)
5
5
  activesupport (~> 7.0)
6
6
  pastel (~> 0.8)
7
7
  thor (~> 1.2)
@@ -10,23 +10,29 @@ PATH
10
10
  GEM
11
11
  remote: https://rubygems.org/
12
12
  specs:
13
- activesupport (7.0.4.3)
13
+ activesupport (7.1.3.4)
14
+ base64
15
+ bigdecimal
14
16
  concurrent-ruby (~> 1.0, >= 1.0.2)
17
+ connection_pool (>= 2.2.5)
18
+ drb
15
19
  i18n (>= 1.6, < 2)
16
20
  minitest (>= 5.1)
21
+ mutex_m
17
22
  tzinfo (~> 2.0)
18
- aruba (2.1.0)
23
+ aruba (2.2.0)
19
24
  bundler (>= 1.17, < 3.0)
20
- childprocess (>= 2.0, < 5.0)
21
25
  contracts (>= 0.16.0, < 0.18.0)
22
- cucumber (>= 4.0, < 9.0)
26
+ cucumber (>= 8.0, < 10.0)
23
27
  rspec-expectations (~> 3.4)
24
28
  thor (~> 1.0)
25
29
  ast (2.4.2)
26
- builder (3.2.4)
30
+ base64 (0.2.0)
31
+ bigdecimal (3.1.8)
32
+ builder (3.3.0)
27
33
  byebug (11.1.3)
28
- childprocess (4.1.0)
29
- concurrent-ruby (1.2.2)
34
+ concurrent-ruby (1.3.3)
35
+ connection_pool (2.4.1)
30
36
  contracts (0.17)
31
37
  cucumber (8.0.0)
32
38
  builder (~> 3.2, >= 3.2.4)
@@ -40,7 +46,7 @@ GEM
40
46
  mime-types (~> 3.4, >= 3.4.1)
41
47
  multi_test (~> 1.1, >= 1.1.0)
42
48
  sys-uname (~> 1.2, >= 1.2.2)
43
- cucumber-ci-environment (9.1.0)
49
+ cucumber-ci-environment (9.2.0)
44
50
  cucumber-core (11.0.0)
45
51
  cucumber-gherkin (~> 23.0, >= 23.0.1)
46
52
  cucumber-messages (~> 18.0, >= 18.0.0)
@@ -52,73 +58,133 @@ GEM
52
58
  cucumber-messages (~> 18.0, >= 18.0.0)
53
59
  cucumber-messages (18.0.0)
54
60
  cucumber-tag-expressions (4.1.0)
55
- diff-lcs (1.5.0)
61
+ diff-lcs (1.5.1)
56
62
  docile (1.4.0)
57
- ffi (1.15.5)
58
- i18n (1.12.0)
63
+ drb (2.2.1)
64
+ dry-configurable (1.1.0)
65
+ dry-core (~> 1.0, < 2)
66
+ zeitwerk (~> 2.6)
67
+ dry-core (1.0.1)
59
68
  concurrent-ruby (~> 1.0)
60
- json (2.6.3)
61
- kwalify (0.7.2)
62
- mime-types (3.4.1)
69
+ zeitwerk (~> 2.6)
70
+ dry-inflector (1.0.0)
71
+ dry-initializer (3.1.1)
72
+ dry-logic (1.5.0)
73
+ concurrent-ruby (~> 1.0)
74
+ dry-core (~> 1.0, < 2)
75
+ zeitwerk (~> 2.6)
76
+ dry-schema (1.13.4)
77
+ concurrent-ruby (~> 1.0)
78
+ dry-configurable (~> 1.0, >= 1.0.1)
79
+ dry-core (~> 1.0, < 2)
80
+ dry-initializer (~> 3.0)
81
+ dry-logic (>= 1.4, < 2)
82
+ dry-types (>= 1.7, < 2)
83
+ zeitwerk (~> 2.6)
84
+ dry-types (1.7.2)
85
+ bigdecimal (~> 3.0)
86
+ concurrent-ruby (~> 1.0)
87
+ dry-core (~> 1.0)
88
+ dry-inflector (~> 1.0)
89
+ dry-logic (~> 1.4)
90
+ zeitwerk (~> 2.6)
91
+ ffi (1.17.0)
92
+ i18n (1.14.5)
93
+ concurrent-ruby (~> 1.0)
94
+ json (2.7.2)
95
+ language_server-protocol (3.17.0.3)
96
+ lint_roller (1.1.0)
97
+ mime-types (3.5.2)
63
98
  mime-types-data (~> 3.2015)
64
- mime-types-data (3.2022.0105)
65
- minitest (5.18.0)
99
+ mime-types-data (3.2024.0604)
100
+ minitest (5.23.1)
66
101
  multi_test (1.1.0)
67
- parallel (1.22.1)
68
- parser (3.1.3.0)
102
+ mutex_m (0.2.0)
103
+ parallel (1.25.1)
104
+ parser (3.3.3.0)
69
105
  ast (~> 2.4.1)
106
+ racc
70
107
  pastel (0.8.0)
71
108
  tty-color (~> 0.5)
109
+ racc (1.8.0)
72
110
  rainbow (3.1.1)
73
- rake (13.0.6)
74
- reek (6.1.2)
75
- kwalify (~> 0.7.0)
76
- parser (~> 3.1.0)
111
+ rake (13.2.1)
112
+ reek (6.3.0)
113
+ dry-schema (~> 1.13.0)
114
+ parser (~> 3.3.0)
77
115
  rainbow (>= 2.0, < 4.0)
78
- regexp_parser (2.6.1)
79
- rexml (3.2.5)
80
- rspec (3.12.0)
81
- rspec-core (~> 3.12.0)
82
- rspec-expectations (~> 3.12.0)
83
- rspec-mocks (~> 3.12.0)
84
- rspec-core (3.12.0)
85
- rspec-support (~> 3.12.0)
86
- rspec-expectations (3.12.0)
116
+ rexml (~> 3.1)
117
+ regexp_parser (2.9.2)
118
+ rexml (3.3.0)
119
+ strscan
120
+ rspec (3.13.0)
121
+ rspec-core (~> 3.13.0)
122
+ rspec-expectations (~> 3.13.0)
123
+ rspec-mocks (~> 3.13.0)
124
+ rspec-core (3.13.0)
125
+ rspec-support (~> 3.13.0)
126
+ rspec-expectations (3.13.1)
87
127
  diff-lcs (>= 1.2.0, < 2.0)
88
- rspec-support (~> 3.12.0)
89
- rspec-mocks (3.12.1)
128
+ rspec-support (~> 3.13.0)
129
+ rspec-mocks (3.13.1)
90
130
  diff-lcs (>= 1.2.0, < 2.0)
91
- rspec-support (~> 3.12.0)
92
- rspec-support (3.12.0)
93
- rubocop (1.40.0)
131
+ rspec-support (~> 3.13.0)
132
+ rspec-support (3.13.1)
133
+ rubocop (1.64.1)
94
134
  json (~> 2.3)
135
+ language_server-protocol (>= 3.17.0)
95
136
  parallel (~> 1.10)
96
- parser (>= 3.1.2.1)
137
+ parser (>= 3.3.0.2)
97
138
  rainbow (>= 2.2.2, < 4.0)
98
139
  regexp_parser (>= 1.8, < 3.0)
99
140
  rexml (>= 3.2.5, < 4.0)
100
- rubocop-ast (>= 1.23.0, < 2.0)
141
+ rubocop-ast (>= 1.31.1, < 2.0)
101
142
  ruby-progressbar (~> 1.7)
102
- unicode-display_width (>= 1.4.0, < 3.0)
103
- rubocop-ast (1.24.0)
104
- parser (>= 3.1.1.0)
105
- rubocop-rspec (2.16.0)
106
- rubocop (~> 1.33)
107
- ruby-progressbar (1.11.0)
108
- simplecov (0.21.2)
143
+ unicode-display_width (>= 2.4.0, < 3.0)
144
+ rubocop-ast (1.31.3)
145
+ parser (>= 3.3.1.0)
146
+ rubocop-capybara (2.21.0)
147
+ rubocop (~> 1.41)
148
+ rubocop-factory_bot (2.26.1)
149
+ rubocop (~> 1.61)
150
+ rubocop-performance (1.21.1)
151
+ rubocop (>= 1.48.1, < 2.0)
152
+ rubocop-ast (>= 1.31.1, < 2.0)
153
+ rubocop-rspec (2.31.0)
154
+ rubocop (~> 1.40)
155
+ rubocop-capybara (~> 2.17)
156
+ rubocop-factory_bot (~> 2.22)
157
+ rubocop-rspec_rails (~> 2.28)
158
+ rubocop-rspec_rails (2.29.1)
159
+ rubocop (~> 1.61)
160
+ ruby-progressbar (1.13.0)
161
+ simplecov (0.22.0)
109
162
  docile (~> 1.1)
110
163
  simplecov-html (~> 0.11)
111
164
  simplecov_json_formatter (~> 0.1)
112
165
  simplecov-html (0.12.3)
113
166
  simplecov_json_formatter (0.1.4)
114
- sys-uname (1.2.2)
167
+ standard (1.37.0)
168
+ language_server-protocol (~> 3.17.0.2)
169
+ lint_roller (~> 1.0)
170
+ rubocop (~> 1.64.0)
171
+ standard-custom (~> 1.0.0)
172
+ standard-performance (~> 1.4)
173
+ standard-custom (1.0.2)
174
+ lint_roller (~> 1.0)
175
+ rubocop (~> 1.50)
176
+ standard-performance (1.4.0)
177
+ lint_roller (~> 1.1)
178
+ rubocop-performance (~> 1.21.0)
179
+ strscan (3.1.0)
180
+ sys-uname (1.3.0)
115
181
  ffi (~> 1.1)
116
- thor (1.2.1)
182
+ thor (1.3.1)
117
183
  tty-color (0.6.0)
118
184
  tzinfo (2.0.6)
119
185
  concurrent-ruby (~> 1.0)
120
- unicode-display_width (2.3.0)
121
- zeitwerk (2.6.6)
186
+ unicode-display_width (2.5.0)
187
+ zeitwerk (2.6.16)
122
188
 
123
189
  PLATFORMS
124
190
  ruby
@@ -135,6 +201,7 @@ DEPENDENCIES
135
201
  rubocop (~> 1.9)
136
202
  rubocop-rspec (~> 2.2)
137
203
  simplecov (~> 0.21)
204
+ standard (~> 1.31)
138
205
 
139
206
  BUNDLED WITH
140
207
  2.3.26
data/Rakefile CHANGED
@@ -1,11 +1,11 @@
1
- require 'bundler/gem_tasks'
2
- require 'cucumber/rake/task'
3
- require 'rspec/core/rake_task'
1
+ require "bundler/gem_tasks"
2
+ require "cucumber/rake/task"
3
+ require "rspec/core/rake_task"
4
4
 
5
5
  Cucumber::Rake::Task.new(:cucumber) do |task|
6
- task.cucumber_opts = '--format pretty'
6
+ task.cucumber_opts = "--format pretty"
7
7
  end
8
8
 
9
9
  RSpec::Core::RakeTask.new(:spec)
10
10
 
11
- task :default => [:spec, :cucumber]
11
+ task default: [:spec, :cucumber]
data/exe/expire CHANGED
@@ -3,5 +3,5 @@
3
3
 
4
4
  # -*- mode: ruby
5
5
 
6
- require 'expire/cli'
6
+ require "expire/cli"
7
7
  Expire::CLI.start
data/expire.gemspec CHANGED
@@ -1,17 +1,16 @@
1
-
2
1
  lib = File.expand_path("../lib", __FILE__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
3
  require "expire/version"
5
4
 
6
5
  Gem::Specification.new do |spec|
7
- spec.name = "expire"
8
- spec.version = Expire::VERSION
9
- spec.authors = ["Thomas Regnet"]
6
+ spec.name = "expire"
7
+ spec.version = Expire::VERSION
8
+ spec.authors = ["Thomas Regnet"]
10
9
  # spec.email = ["TODO: Write your email address"]
11
10
 
12
- spec.summary = %q{Calculate expired backups.}
13
- spec.homepage = 'https://github.com/thomasregnet/expire'
14
- spec.license = "MIT"
11
+ spec.summary = "Calculate expired backups."
12
+ spec.homepage = "https://github.com/thomasregnet/expire"
13
+ spec.license = "MIT"
15
14
 
16
15
  # Prevent pushing this gem to RubyGems.org.
17
16
  # To allow pushes either set the 'allowed_push_host'
@@ -20,8 +19,8 @@ Gem::Specification.new do |spec|
20
19
  if spec.respond_to?(:metadata)
21
20
  # spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
22
21
 
23
- spec.metadata['homepage_uri'] = spec.homepage
24
- spec.metadata['source_code_uri'] = spec.homepage
22
+ spec.metadata["homepage_uri"] = spec.homepage
23
+ spec.metadata["source_code_uri"] = spec.homepage
25
24
  else
26
25
  raise "RubyGems 2.0 or newer is required to protect against " \
27
26
  "public gem pushes."
@@ -29,26 +28,28 @@ Gem::Specification.new do |spec|
29
28
 
30
29
  # Specify which files should be added to the gem when it is released.
31
30
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
32
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
31
+ spec.files = Dir.chdir(File.expand_path("..", __FILE__)) do
33
32
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
34
33
  end
35
- spec.bindir = "exe"
36
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
34
+ spec.bindir = "exe"
35
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
37
36
  spec.require_paths = ["lib"]
38
-
39
- spec.add_dependency 'activesupport', '~> 7.0'
40
- spec.add_dependency 'pastel', '~> 0.8'
41
- spec.add_dependency 'thor', '~> 1.2'
42
- spec.add_dependency 'zeitwerk', "~> 2.4"
43
-
44
- spec.add_development_dependency 'aruba', '~> 2.1'
45
- spec.add_development_dependency 'bundler', '~> 2.3'
46
- spec.add_development_dependency 'byebug', '~> 11.1'
47
- spec.add_development_dependency 'cucumber', '~> 8.0'
48
- spec.add_development_dependency 'rake', '~> 13.0'
49
- spec.add_development_dependency 'reek', '~> 6.0'
50
- spec.add_development_dependency 'rspec', '~> 3.0'
51
- spec.add_development_dependency 'rubocop', '~> 1.9'
52
- spec.add_development_dependency 'rubocop-rspec', '~> 2.2'
53
- spec.add_development_dependency 'simplecov', '~> 0.21'
37
+ spec.required_ruby_version = ">= 3.2"
38
+
39
+ spec.add_dependency "activesupport", "~> 7.0"
40
+ spec.add_dependency "pastel", "~> 0.8"
41
+ spec.add_dependency "thor", "~> 1.2"
42
+ spec.add_dependency "zeitwerk", "~> 2.4"
43
+
44
+ spec.add_development_dependency "aruba", "~> 2.1"
45
+ spec.add_development_dependency "bundler", "~> 2.3"
46
+ spec.add_development_dependency "byebug", "~> 11.1"
47
+ spec.add_development_dependency "cucumber", "~> 8.0"
48
+ spec.add_development_dependency "rake", "~> 13.0"
49
+ spec.add_development_dependency "reek", "~> 6.0"
50
+ spec.add_development_dependency "rspec", "~> 3.0"
51
+ spec.add_development_dependency "rubocop", "~> 1.9"
52
+ spec.add_development_dependency "rubocop-rspec", "~> 2.2"
53
+ spec.add_development_dependency "simplecov", "~> 0.21"
54
+ spec.add_development_dependency "standard", "~> 1.31"
54
55
  end
data/lib/expire/backup.rb CHANGED
@@ -6,7 +6,7 @@ module Expire
6
6
  include Comparable
7
7
 
8
8
  def initialize(time:, pathname:)
9
- @time = time
9
+ @time = time
10
10
  @pathname = pathname
11
11
 
12
12
  # @reasons_to_keep is a Set so a reason can added multiple times
@@ -15,7 +15,7 @@ module Expire
15
15
  end
16
16
 
17
17
  attr_reader :time, :pathname, :reasons_to_keep
18
- alias __getobj__ time
18
+ alias_method :__getobj__, :time
19
19
 
20
20
  def same_hour?(other)
21
21
  return false unless same_day?(other)
@@ -64,7 +64,7 @@ module Expire
64
64
  # end
65
65
 
66
66
  def cweek
67
- time&.strftime('%V').to_i
67
+ time&.strftime("%V").to_i
68
68
  end
69
69
 
70
70
  def expired?
@@ -76,7 +76,7 @@ module Expire
76
76
  end
77
77
 
78
78
  def to_s
79
- time.strftime('%Y-%m-%dT%H:%M')
79
+ time.strftime("%Y-%m-%dT%H:%M")
80
80
  end
81
81
  end
82
82
  end
@@ -22,10 +22,10 @@ module Expire
22
22
  def time
23
23
  digits = extract_digits
24
24
 
25
- year = digits[0..3].to_i
26
- month = digits[4..5].to_i
27
- day = digits[6..7].to_i
28
- hour = digits[8..9].to_i
25
+ year = digits[0..3].to_i
26
+ month = digits[4..5].to_i
27
+ day = digits[6..7].to_i
28
+ hour = digits[8..9].to_i
29
29
  minute = digits[10..11].to_i
30
30
 
31
31
  time_for(year, month, day, hour, minute)
@@ -43,7 +43,7 @@ module Expire
43
43
  def extract_digits
44
44
  basename = pathname.basename.to_s
45
45
 
46
- digits = basename.gsub(/[^0-9]/, '')
46
+ digits = basename.gsub(/[^0-9]/, "")
47
47
 
48
48
  digits_length = digits.length
49
49
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'forwardable'
3
+ require "forwardable"
4
4
 
5
5
  module Expire
6
6
  # All Backups go here
data/lib/expire/cli.rb CHANGED
@@ -1,218 +1,218 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'expire'
4
- require 'thor'
3
+ require "expire"
4
+ require "thor"
5
5
 
6
6
  module Expire
7
7
  # Command line interface
8
8
  # rubocop:disable Metrics/ClassLength
9
9
  class CLI < Thor
10
- desc 'rule_option_names', 'List rule option names ordered by their rank'
10
+ desc "rule_option_names", "List rule option names ordered by their rank"
11
11
  method_option(
12
12
  :help,
13
- aliases: '-h',
14
- type: :boolean,
15
- desc: 'Display usage information'
13
+ aliases: "-h",
14
+ type: :boolean,
15
+ desc: "Display usage information"
16
16
  )
17
17
  def rule_option_names(*)
18
18
  if options[:help]
19
- invoke :help, ['rule_option_names']
19
+ invoke :help, ["rule_option_names"]
20
20
  else
21
- require_relative 'commands/rule_option_names'
21
+ require_relative "commands/rule_option_names"
22
22
  Expire::Commands::RuleOptionNames.new(options).execute
23
23
  end
24
24
  end
25
25
 
26
- desc 'rule_names', 'List rule names ordered by their rank'
26
+ desc "rule_names", "List rule names ordered by their rank"
27
27
  method_option(
28
28
  :help,
29
- aliases: '-h',
30
- type: :boolean,
31
- desc: 'Display usage information'
29
+ aliases: "-h",
30
+ type: :boolean,
31
+ desc: "Display usage information"
32
32
  )
33
33
  def rule_names(*)
34
34
  if options[:help]
35
- invoke :help, ['rule_names']
35
+ invoke :help, ["rule_names"]
36
36
  else
37
- require_relative 'commands/rule_names'
37
+ require_relative "commands/rule_names"
38
38
  Expire::Commands::RuleNames.new(options).execute
39
39
  end
40
40
  end
41
41
 
42
- desc 'rule_classes', 'List rule classes ordered by their rank'
42
+ desc "rule_classes", "List rule classes ordered by their rank"
43
43
  method_option(
44
44
  :help,
45
- aliases: '-h',
46
- type: :boolean,
47
- desc: 'Display usage information'
45
+ aliases: "-h",
46
+ type: :boolean,
47
+ desc: "Display usage information"
48
48
  )
49
49
  def rule_classes(*)
50
50
  if options[:help]
51
- invoke :help, ['rule_classes']
51
+ invoke :help, ["rule_classes"]
52
52
  else
53
- require_relative 'commands/rule_classes'
53
+ require_relative "commands/rule_classes"
54
54
  Expire::Commands::RuleClasses.new(options).execute
55
55
  end
56
56
  end
57
57
 
58
- desc 'remove PATH', 'Remove PATH from the filesystem'
59
- method_option :help, aliases: '-h', type: :boolean,
60
- desc: 'Display usage information'
58
+ desc "remove PATH", "Remove PATH from the filesystem"
59
+ method_option :help, aliases: "-h", type: :boolean,
60
+ desc: "Display usage information"
61
61
  def remove(path)
62
62
  if options[:help]
63
- invoke :help, ['remove']
63
+ invoke :help, ["remove"]
64
64
  else
65
- require_relative 'commands/remove'
65
+ require_relative "commands/remove"
66
66
  Expire::Commands::Remove.new(path: path).execute
67
67
  end
68
68
  end
69
69
 
70
- desc 'oldest PATH', 'Show the oldest backup'
71
- method_option :help, aliases: '-h', type: :boolean,
72
- desc: 'Display usage information'
70
+ desc "oldest PATH", "Show the oldest backup"
71
+ method_option :help, aliases: "-h", type: :boolean,
72
+ desc: "Display usage information"
73
73
  def oldest(path)
74
74
  if options[:help]
75
- invoke :help, ['oldest']
75
+ invoke :help, ["oldest"]
76
76
  else
77
- require_relative 'commands/oldest'
77
+ require_relative "commands/oldest"
78
78
  Expire::Commands::Oldest.new(path, options).execute
79
79
  end
80
80
  end
81
81
 
82
- desc 'newest PATH', 'Show the newest backup'
83
- method_option :help, aliases: '-h', type: :boolean,
84
- desc: 'Display usage information'
82
+ desc "newest PATH", "Show the newest backup"
83
+ method_option :help, aliases: "-h", type: :boolean,
84
+ desc: "Display usage information"
85
85
  def newest(path)
86
86
  if options[:help]
87
- invoke :help, ['newest']
87
+ invoke :help, ["newest"]
88
88
  else
89
- require_relative 'commands/newest'
89
+ require_relative "commands/newest"
90
90
  Expire::Commands::Newest.new(path, options).execute
91
91
  end
92
92
  end
93
93
 
94
94
  # Play with test-data
95
95
  class Playground < Thor
96
- desc 'create PATH', 'play with test-data'
96
+ desc "create PATH", "play with test-data"
97
97
  def create(path)
98
98
  Expire.create_playground(path)
99
99
  end
100
100
  end
101
101
 
102
- desc 'purge PATH', 'Remove expired backups from PATH'
103
- method_option :help, aliases: '-h', type: :boolean,
104
- desc: 'Display usage information'
105
- method_option :format, aliases: '-f', type: :string,
102
+ desc "purge PATH", "Remove expired backups from PATH"
103
+ method_option :help, aliases: "-h", type: :boolean,
104
+ desc: "Display usage information"
105
+ method_option :format, aliases: "-f", type: :string,
106
106
  enum: %w[expired kept none simple enhanced],
107
- default: 'none',
108
- desc: 'output format'
109
- method_option :purge_command, aliases: '--cmd', type: :string,
110
- desc: 'run command to purge the backup'
111
- method_option :rules_file, aliases: '-r', type: :string,
112
- desc: 'read expire-rules from file'
113
- method_option :simulate, aliases: '-s', type: :boolean,
114
- desc: 'Simulate purge, do not delete anything'
107
+ default: "none",
108
+ desc: "output format"
109
+ method_option :purge_command, aliases: "--cmd", type: :string,
110
+ desc: "run command to purge the backup"
111
+ method_option :rules_file, aliases: "-r", type: :string,
112
+ desc: "read expire-rules from file"
113
+ method_option :simulate, aliases: "-s", type: :boolean,
114
+ desc: "Simulate purge, do not delete anything"
115
115
  method_option(
116
116
  :keep_most_recent,
117
117
  type: :string,
118
- desc: 'keep the <integer> most recent backups'
118
+ desc: "keep the <integer> most recent backups"
119
119
  )
120
120
  method_option(
121
121
  :keep_most_recent_for,
122
122
  type: :string,
123
- desc: 'keep the most recent backups for <integer> <unit>'
123
+ desc: "keep the most recent backups for <integer> <unit>"
124
124
  )
125
125
  method_option(
126
126
  :from_now_keep_most_recent_for,
127
127
  type: :string,
128
- desc: 'keep the most recent backups for <integer> <unit> calculated from now'
128
+ desc: "keep the most recent backups for <integer> <unit> calculated from now"
129
129
  )
130
130
  method_option(
131
131
  :keep_hourly,
132
132
  type: :string,
133
- desc: 'keep the <integer> most recent backups from different hours'
133
+ desc: "keep the <integer> most recent backups from different hours"
134
134
  )
135
135
  method_option(
136
136
  :keep_daily,
137
137
  type: :string,
138
- desc: 'keep the <integer> most recent backups from different days'
138
+ desc: "keep the <integer> most recent backups from different days"
139
139
  )
140
140
  method_option(
141
141
  :keep_weekly,
142
142
  type: :string,
143
- desc: 'keep the <integer> most recent backups from different weeks'
143
+ desc: "keep the <integer> most recent backups from different weeks"
144
144
  )
145
145
  method_option(
146
146
  :keep_monthly,
147
147
  type: :string,
148
- desc: 'keep the <integer> most recent backups from different months'
148
+ desc: "keep the <integer> most recent backups from different months"
149
149
  )
150
150
  method_option(
151
151
  :keep_yearly,
152
152
  type: :string,
153
- desc: 'keep the <integer> most recent backups from different years'
153
+ desc: "keep the <integer> most recent backups from different years"
154
154
  )
155
155
  method_option(
156
156
  :keep_hourly_for,
157
157
  type: :string,
158
- desc: 'keep one backup per hour for <integer> <unit>'
158
+ desc: "keep one backup per hour for <integer> <unit>"
159
159
  )
160
160
  method_option(
161
161
  :keep_daily_for,
162
162
  type: :string,
163
- desc: 'keep one backup per day for <integer> <unit>'
163
+ desc: "keep one backup per day for <integer> <unit>"
164
164
  )
165
165
  method_option(
166
166
  :keep_weekly_for,
167
167
  type: :string,
168
- desc: 'keep one backup per week for <integer> <unit>'
168
+ desc: "keep one backup per week for <integer> <unit>"
169
169
  )
170
170
  method_option(
171
171
  :keep_monthly_for,
172
172
  type: :string,
173
- desc: 'keep one backup per month for <integer> <unit>'
173
+ desc: "keep one backup per month for <integer> <unit>"
174
174
  )
175
175
  method_option(
176
176
  :keep_yearly_for,
177
177
  type: :string,
178
- desc: 'keep one backup per year for <integer> <unit>'
178
+ desc: "keep one backup per year for <integer> <unit>"
179
179
  )
180
180
  method_option(
181
181
  :from_now_keep_hourly_for,
182
182
  type: :string,
183
- desc: 'keep one backup per hour for <integer> <unit> calculated from now'
183
+ desc: "keep one backup per hour for <integer> <unit> calculated from now"
184
184
  )
185
185
  method_option(
186
186
  :from_now_keep_daily_for,
187
187
  type: :string,
188
- desc: 'keep one backup per hour for <integer> <unit> calculated from now'
188
+ desc: "keep one backup per hour for <integer> <unit> calculated from now"
189
189
  )
190
190
  method_option(
191
191
  :from_now_keep_weekly_for,
192
192
  type: :string,
193
- desc: 'keep one backup per hour for <integer> <unit> calculated from now'
193
+ desc: "keep one backup per hour for <integer> <unit> calculated from now"
194
194
  )
195
195
  method_option(
196
196
  :from_now_keep_monthly_for,
197
197
  type: :string,
198
- desc: 'keep one backup per hour for <integer> <unit> calculated from now'
198
+ desc: "keep one backup per hour for <integer> <unit> calculated from now"
199
199
  )
200
200
  method_option(
201
201
  :from_now_keep_yearly_for,
202
202
  type: :string,
203
- desc: 'keep one backup per hour for <integer> <unit> calculated from now'
203
+ desc: "keep one backup per hour for <integer> <unit> calculated from now"
204
204
  )
205
205
  def purge(path)
206
206
  if options[:help]
207
- invoke :help, ['purge']
207
+ invoke :help, ["purge"]
208
208
  else
209
- require_relative 'commands/purge'
209
+ require_relative "commands/purge"
210
210
  Expire::Commands::Purge.new(path, options).execute
211
211
  end
212
212
  end
213
213
 
214
- desc 'playground', 'play with test-data'
215
- subcommand 'playground', Playground
214
+ desc "playground", "play with test-data"
215
+ subcommand "playground", Playground
216
216
 
217
217
  def self.exit_on_failure?
218
218
  true
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'forwardable'
3
+ require "forwardable"
4
4
 
5
5
  module Expire
6
6
  # Helpers for TTY
@@ -25,7 +25,7 @@ module Expire
25
25
  #
26
26
  # @api public
27
27
  def command(**options)
28
- require 'tty-command'
28
+ require "tty-command"
29
29
  TTY::Command.new(options)
30
30
  end
31
31
 
@@ -35,7 +35,7 @@ module Expire
35
35
  #
36
36
  # @api public
37
37
  def cursor
38
- require 'tty-cursor'
38
+ require "tty-cursor"
39
39
  TTY::Cursor
40
40
  end
41
41
 
@@ -45,7 +45,7 @@ module Expire
45
45
  #
46
46
  # @api public
47
47
  def editor
48
- require 'tty-editor'
48
+ require "tty-editor"
49
49
  TTY::Editor
50
50
  end
51
51
 
@@ -55,7 +55,7 @@ module Expire
55
55
  #
56
56
  # @api public
57
57
  def generator
58
- require 'tty-file'
58
+ require "tty-file"
59
59
  TTY::File
60
60
  end
61
61
 
@@ -65,7 +65,7 @@ module Expire
65
65
  #
66
66
  # @api public
67
67
  def pager(**options)
68
- require 'tty-pager'
68
+ require "tty-pager"
69
69
  TTY::Pager.new(options)
70
70
  end
71
71
 
@@ -75,7 +75,7 @@ module Expire
75
75
  #
76
76
  # @api public
77
77
  def platform
78
- require 'tty-platform'
78
+ require "tty-platform"
79
79
  TTY::Platform.new
80
80
  end
81
81
 
@@ -85,7 +85,7 @@ module Expire
85
85
  #
86
86
  # @api public
87
87
  def prompt(**options)
88
- require 'tty-prompt'
88
+ require "tty-prompt"
89
89
  TTY::Prompt.new(options)
90
90
  end
91
91
 
@@ -95,7 +95,7 @@ module Expire
95
95
  #
96
96
  # @api public
97
97
  def screen
98
- require 'tty-screen'
98
+ require "tty-screen"
99
99
  TTY::Screen
100
100
  end
101
101
 
@@ -104,9 +104,9 @@ module Expire
104
104
  # @see http://www.rubydoc.info/gems/tty-which
105
105
  #
106
106
  # @api public
107
- def which(*args)
108
- require 'tty-which'
109
- TTY::Which.which(*args)
107
+ def which(*)
108
+ require "tty-which"
109
+ TTY::Which.which(*)
110
110
  end
111
111
 
112
112
  # Check if executable exists
@@ -114,9 +114,9 @@ module Expire
114
114
  # @see http://www.rubydoc.info/gems/tty-which
115
115
  #
116
116
  # @api public
117
- def exec_exist?(*args)
118
- require 'tty-which'
119
- TTY::Which.exist?(*args)
117
+ def exec_exist?(*)
118
+ require "tty-which"
119
+ TTY::Which.exist?(*)
120
120
  end
121
121
  end
122
122
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative '../command'
3
+ require_relative "../command"
4
4
 
5
5
  module Expire
6
6
  module Commands
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative '../command'
3
+ require_relative "../command"
4
4
 
5
5
  module Expire
6
6
  module Commands
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative '../command'
3
+ require_relative "../command"
4
4
 
5
5
  module Expire
6
6
  module Commands
@@ -15,7 +15,7 @@ module Expire
15
15
 
16
16
  def execute(input: $stdin, output: $stdout)
17
17
  Expire.purge(path, options)
18
- rescue StandardError => _e
18
+ rescue => _e
19
19
  exit 1
20
20
  end
21
21
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative '../command'
3
+ require_relative "../command"
4
4
 
5
5
  module Expire
6
6
  module Commands
@@ -1,12 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative '../command'
3
+ require_relative "../command"
4
4
 
5
5
  module Expire
6
6
  module Commands
7
7
  # Print all rule-classes
8
8
  class RuleClasses < Expire::Command
9
- def initialize(_); end
9
+ # standard:disable Style/RedundantInitialize
10
+ def initialize(_)
11
+ end
12
+ # standard:enable Style/RedundantInitialize
10
13
 
11
14
  def execute(output: $stdout)
12
15
  Expire.rule_classes.each do |rule_class|
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative '../command'
3
+ require_relative "../command"
4
4
 
5
5
  module Expire
6
6
  module Commands
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative '../command'
3
+ require_relative "../command"
4
4
 
5
5
  module Expire
6
6
  module Commands
@@ -14,7 +14,7 @@ module Expire
14
14
  attr_reader :path
15
15
 
16
16
  def call
17
- if path == '-'
17
+ if path == "-"
18
18
  generate_backup_list_from($stdin)
19
19
  else
20
20
  pathname = Pathname.new(path)
@@ -4,9 +4,9 @@ module Expire
4
4
  # Hold backups for a period
5
5
  class KeepAdjectiveForRuleBase < FromNowKeepAdjectiveForRuleBase
6
6
  ADJECTIVE_FOR = {
7
- 'week' => 'weekly',
8
- 'month' => 'monthly',
9
- 'year' => 'yearly'
7
+ "week" => "weekly",
8
+ "month" => "monthly",
9
+ "year" => "yearly"
10
10
  }.freeze
11
11
 
12
12
  PRIMARY_RANK = 30
@@ -6,20 +6,20 @@ module Expire
6
6
  using RefineAllAndNone
7
7
 
8
8
  NOUN_FOR = {
9
- 'hourly' => 'hour',
10
- 'daily' => 'day',
11
- 'weekly' => 'week',
12
- 'monthly' => 'month',
13
- 'yearly' => 'year'
9
+ "hourly" => "hour",
10
+ "daily" => "day",
11
+ "weekly" => "week",
12
+ "monthly" => "month",
13
+ "yearly" => "year"
14
14
  }.freeze
15
15
 
16
16
  PRIMARY_RANK = 20
17
17
  SECONDARY_RANK_FOR = {
18
- 'hourly' => 1,
19
- 'daily' => 2,
20
- 'weekly' => 3,
21
- 'monthly' => 4,
22
- 'yearly' => 5
18
+ "hourly" => 1,
19
+ "daily" => 2,
20
+ "weekly" => 3,
21
+ "monthly" => 4,
22
+ "yearly" => 5
23
23
  }.freeze
24
24
 
25
25
  def self.from_value(value)
@@ -27,7 +27,7 @@ module Expire
27
27
  value = 0 if value.none?
28
28
 
29
29
  integer_value = Integer(value)
30
- raise ArgumentError, 'must be at least -1' if integer_value < -1
30
+ raise ArgumentError, "must be at least -1" if integer_value < -1
31
31
 
32
32
  new(amount: integer_value)
33
33
  end
@@ -53,7 +53,7 @@ module Expire
53
53
 
54
54
  def apply(backups, _)
55
55
  per_spacing = backups.one_per(spacing)
56
- kept = amount == -1 ? per_spacing : per_spacing.most_recent(amount)
56
+ kept = (amount == -1) ? per_spacing : per_spacing.most_recent(amount)
57
57
  kept.each { |backup| backup.add_reason_to_keep(reason_to_keep) }
58
58
  end
59
59
 
@@ -91,7 +91,7 @@ module Expire
91
91
  end
92
92
 
93
93
  def pretty_amount
94
- amount == -1 ? 'all' : amount.to_s
94
+ (amount == -1) ? "all" : amount.to_s
95
95
  end
96
96
  end
97
97
  end
@@ -30,7 +30,7 @@ module Expire
30
30
  private
31
31
 
32
32
  def reason_to_keep
33
- return 'keep the most recent backup' if amount == 1
33
+ return "keep the most recent backup" if amount == 1
34
34
 
35
35
  "keep the #{amount} most recent backups"
36
36
  end
@@ -4,11 +4,11 @@ module Expire
4
4
  # Create playground with example data
5
5
  class Playground
6
6
  STEP_WIDTHS = {
7
- 'hourly' => 'hour',
8
- 'daily' => 'day',
9
- 'weekly' => 'week',
10
- 'monthly' => 'month',
11
- 'yearly' => 'year'
7
+ "hourly" => "hour",
8
+ "daily" => "day",
9
+ "weekly" => "week",
10
+ "monthly" => "month",
11
+ "yearly" => "year"
12
12
  }.freeze
13
13
 
14
14
  def self.create(base)
@@ -16,15 +16,15 @@ module Expire
16
16
  end
17
17
 
18
18
  def initialize(base)
19
- @base = base
19
+ @base = base
20
20
  @backups_dir = Pathname.new("#{base}/backups")
21
21
 
22
22
  @options = {
23
- hourly: 42,
24
- daily: 15,
25
- weekly: 15,
23
+ hourly: 42,
24
+ daily: 15,
25
+ weekly: 15,
26
26
  monthly: 25,
27
- yearly: 5
27
+ yearly: 5
28
28
  }
29
29
  end
30
30
 
@@ -46,7 +46,7 @@ module Expire
46
46
  private
47
47
 
48
48
  def mkbackup(time)
49
- backup_name = time.strftime('%Y-%m-%dT%H:%M')
49
+ backup_name = time.strftime("%Y-%m-%dT%H:%M")
50
50
  FileUtils.mkdir_p("#{backups_dir}/#{backup_name}")
51
51
  end
52
52
 
@@ -9,7 +9,7 @@ module Expire
9
9
 
10
10
  def initialize(path, options)
11
11
  @options = options
12
- @path = path
12
+ @path = path
13
13
  end
14
14
 
15
15
  attr_reader :options, :path
@@ -17,7 +17,7 @@ module Expire
17
17
  def call
18
18
  check_preconditions
19
19
  purge_expired_backups
20
- rescue StandardError => e
20
+ rescue => e
21
21
  report.error(e.message)
22
22
  raise
23
23
  end
@@ -34,8 +34,8 @@ module Expire
34
34
 
35
35
  def check_preconditions
36
36
  raise NoBackupsError, "Can't find any backups" unless backup_list.any?
37
- raise NoRulesError, 'Will not purge without rules' unless rules.any?
38
- raise AllBackupsExpiredError, 'Will not delete all backups' if annotated_backup_list.keep_count < 1
37
+ raise NoRulesError, "Will not purge without rules" unless rules.any?
38
+ raise AllBackupsExpiredError, "Will not delete all backups" if annotated_backup_list.keep_count < 1
39
39
  end
40
40
 
41
41
  def report
@@ -46,7 +46,7 @@ module Expire
46
46
  wanted_format = options[:format]
47
47
 
48
48
  return ReportNull unless wanted_format
49
- return ReportNull if wanted_format == 'none'
49
+ return ReportNull if wanted_format == "none"
50
50
 
51
51
  class_name = "::Expire::Report#{wanted_format.titleize}"
52
52
  class_name.safe_constantize or raise ArgumentError, "unknown format \"#{wanted_format}\""
@@ -5,24 +5,24 @@ module Expire
5
5
  module RefineAllAndNone
6
6
  refine String do
7
7
  def all?
8
- return true if ['-1', 'all'].include?(strip.downcase)
8
+ ["-1", "all"].include?(strip.downcase)
9
9
  end
10
10
 
11
11
  # %w does not work here, I assume there is a problem with "0"
12
12
  # rubocop:disable Style/RedundantPercentQ
13
13
  def none?
14
- return true if %q(0 none).include?(strip.downcase)
14
+ %q(0 none).include?(strip.downcase)
15
15
  end
16
16
  # rubocop:enable Style/RedundantPercentQ
17
17
  end
18
18
 
19
19
  refine Integer do
20
20
  def all?
21
- return true if self == -1
21
+ self == -1
22
22
  end
23
23
 
24
24
  def none?
25
- return true if zero?
25
+ zero?
26
26
  end
27
27
  end
28
28
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # For some unknown reason Pastel is not autoloaded by Zeitwerk
4
- require 'pastel'
4
+ require "pastel"
5
5
 
6
6
  module Expire
7
7
  # Base class for Reporters
@@ -5,7 +5,7 @@ module Expire
5
5
  class ReportEnhanced < ReportSimple
6
6
  def on_keep(backup)
7
7
  receiver.puts(pastel.green("keeping #{backup.pathname}"))
8
- receiver.puts ' reasons:'
8
+ receiver.puts " reasons:"
9
9
  backup.reasons_to_keep.each do |reason|
10
10
  receiver.puts " - #{reason}"
11
11
  end
@@ -8,14 +8,19 @@ module Expire
8
8
  puts message
9
9
  end
10
10
 
11
- def before_all(_); end
11
+ def before_all(_)
12
+ end
12
13
 
13
- def after_all(_); end
14
+ def after_all(_)
15
+ end
14
16
 
15
- def on_keep(_); end
17
+ def on_keep(_)
18
+ end
16
19
 
17
- def before_purge(_); end
20
+ def before_purge(_)
21
+ end
18
22
 
19
- def after_purge(_); end
23
+ def after_purge(_)
24
+ end
20
25
  end
21
26
  end
@@ -34,7 +34,7 @@ module Expire
34
34
  end
35
35
 
36
36
  def numerus_backup
37
- 'backup'.pluralize(amount)
37
+ "backup".pluralize(amount)
38
38
  end
39
39
 
40
40
  def option_name
@@ -44,7 +44,7 @@ module Expire
44
44
  end
45
45
 
46
46
  def rule_class_names
47
- class_symbols = Expire.constants.select { |klass| Expire.const_get(klass).to_s =~ /Rule\z/ }
47
+ class_symbols = Expire.constants.select { |klass| Expire.const_get(klass).to_s.end_with?("Rule") }
48
48
 
49
49
  class_symbols.map { |c_sym| "Expire::#{c_sym}" }
50
50
  end
@@ -3,7 +3,7 @@
3
3
  module Expire
4
4
  MAJOR = 0
5
5
  MINOR = 2
6
- TINY = 2
6
+ TINY = 4
7
7
 
8
- VERSION = [MAJOR, MINOR, TINY].compact * '.'
8
+ VERSION = [MAJOR, MINOR, TINY].compact * "."
9
9
  end
data/lib/expire.rb CHANGED
@@ -1,14 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'active_support'
4
- require 'active_support/core_ext'
5
- require 'active_support/core_ext/date_and_time/calculations'
6
- require 'date'
7
- require 'yaml'
8
- require 'zeitwerk'
3
+ require "active_support"
4
+ require "active_support/core_ext"
5
+ require "active_support/core_ext/date_and_time/calculations"
6
+ require "date"
7
+ require "yaml"
8
+ require "zeitwerk"
9
9
 
10
10
  loader = Zeitwerk::Loader.for_gem
11
- loader.inflector.inflect('cli' => 'CLI')
11
+ loader.inflector.inflect("cli" => "CLI")
12
12
  loader.setup
13
13
 
14
14
  # Expire backup directories
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: expire
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas Regnet
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-03-16 00:00:00.000000000 Z
11
+ date: 2024-06-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -206,6 +206,20 @@ dependencies:
206
206
  - - "~>"
207
207
  - !ruby/object:Gem::Version
208
208
  version: '0.21'
209
+ - !ruby/object:Gem::Dependency
210
+ name: standard
211
+ requirement: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - "~>"
214
+ - !ruby/object:Gem::Version
215
+ version: '1.31'
216
+ type: :development
217
+ prerelease: false
218
+ version_requirements: !ruby/object:Gem::Requirement
219
+ requirements:
220
+ - - "~>"
221
+ - !ruby/object:Gem::Version
222
+ version: '1.31'
209
223
  description:
210
224
  email:
211
225
  executables:
@@ -307,7 +321,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
307
321
  requirements:
308
322
  - - ">="
309
323
  - !ruby/object:Gem::Version
310
- version: '0'
324
+ version: '3.2'
311
325
  required_rubygems_version: !ruby/object:Gem::Requirement
312
326
  requirements:
313
327
  - - ">="