maid 0.10.0 → 0.11.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 (45) hide show
  1. checksums.yaml +4 -4
  2. data/.github/FUNDING.yml +14 -0
  3. data/.github/workflows/coverage.yml +3 -3
  4. data/.github/workflows/lint.yml +9 -1
  5. data/.github/workflows/merge-gatekeeper.yml +20 -0
  6. data/.github/workflows/release.yml +13 -20
  7. data/.github/workflows/stale.yml +25 -0
  8. data/.github/workflows/test.yml +8 -7
  9. data/.gitignore +1 -1
  10. data/.release-please-manifest.json +1 -1
  11. data/.rubocop.yml +3 -1
  12. data/.rubocop_todo.yml +105 -107
  13. data/.ruby-version +1 -1
  14. data/CHANGELOG.md +16 -0
  15. data/Dockerfile +13 -0
  16. data/Gemfile.lock +226 -0
  17. data/Guardfile +2 -0
  18. data/README.md +82 -49
  19. data/Rakefile +9 -0
  20. data/fixtures/files/test_rules.rb +3 -0
  21. data/lib/maid/logger/logger.rb +63 -0
  22. data/lib/maid/maid.rb +6 -22
  23. data/lib/maid/repeat.rb +2 -2
  24. data/lib/maid/rule.rb +2 -2
  25. data/lib/maid/rule_container.rb +2 -2
  26. data/lib/maid/tools.rb +3 -3
  27. data/lib/maid/trash_migration.rb +2 -0
  28. data/lib/maid/version.rb +1 -1
  29. data/lib/maid/watch.rb +2 -2
  30. data/lib/maid.rb +3 -2
  31. data/maid.gemspec +12 -9
  32. data/release-please-config.json +18 -0
  33. data/script/docker-test +7 -0
  34. data/spec/fakefs_helper.rb +13 -0
  35. data/spec/lib/maid/logger/logger_spec.rb +64 -0
  36. data/spec/lib/maid/maid_spec.rb +113 -103
  37. data/spec/lib/maid/rake/single_rule_spec.rb +1 -1
  38. data/spec/lib/maid/tools_spec.rb +383 -224
  39. data/spec/lib/maid/trash_migration_spec.rb +7 -5
  40. data/spec/spec_helper.rb +9 -1
  41. metadata +89 -42
  42. data/Vagrantfile +0 -14
  43. data/script/vagrant-provision +0 -43
  44. data/script/vagrant-test +0 -7
  45. data/script/vagrant-test-all +0 -34
@@ -3,7 +3,13 @@ require 'fileutils'
3
3
  require 'spec_helper'
4
4
 
5
5
  module Maid
6
- describe TrashMigration, fakefs: true do
6
+ describe TrashMigration, :fakefs do
7
+ before do
8
+ # Avoid FakeFS' File#flock NotImplementedError
9
+ FileUtils.mkdir_p(File.dirname(Maid::DEFAULTS[:log_device]))
10
+ FileUtils.touch(Maid::DEFAULTS[:log_device])
11
+ end
12
+
7
13
  context 'when running on Linux' do
8
14
  before do
9
15
  allow(Platform).to receive(:linux?).and_return(true)
@@ -47,10 +53,6 @@ module Maid
47
53
  end
48
54
 
49
55
  describe 'performing' do
50
- before do
51
- allow(Logger).to receive(:new).and_return(double('Logger').as_null_object)
52
- end
53
-
54
56
  context 'in Linux' do
55
57
  let(:filename) { 'foo.txt' }
56
58
  let(:trash_contents) do
data/spec/spec_helper.rb CHANGED
@@ -20,6 +20,14 @@ require 'vcr'
20
20
 
21
21
  require 'maid'
22
22
 
23
+ # Prevent running RSpec unless it's running in Vagrant or Docker, to avoid
24
+ # overwriting files on the live filesystem through the tests.
25
+ unless ENV['ISOLATED']
26
+ raise "It's safer to run the tests within a Docker container or a Vagrant box.
27
+ See https://github.com/maid/maid/wiki/Contributing. To run anyway, set the
28
+ environment variable `ISOLATED` to `true`"
29
+ end
30
+
23
31
  RSpec.configure do |config|
24
32
  config.mock_with(:rspec) do |mocks|
25
33
  mocks.allow_message_expectations_on_nil = false
@@ -33,7 +41,7 @@ RSpec.configure do |config|
33
41
  # NOTE: If a test fails because ENOENT /usr/share/zoneinfo/Africa/Abidjan,
34
42
  # add `fake_zoneinfo: true` to the describe:
35
43
  # `describe(MyClass, fake_zoneinfo: true do`
36
- config.before(:context, fake_zoneinfo: true) do
44
+ config.before(:context, :fake_zoneinfo) do
37
45
  # Rufus needs zoneinfo data to run, but when using FakeFS,
38
46
  # /usr/share/zoneinfo doesn't exist on the FakeFS.
39
47
  # On Linux, we just have to FakeFS::FileSystem.clone the directory and it
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: maid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Benjamin Oakes
8
8
  - Coaxial
9
- autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2023-05-01 00:00:00.000000000 Z
11
+ date: 2025-03-30 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: deprecated
@@ -201,16 +200,16 @@ dependencies:
201
200
  name: fuubar
202
201
  requirement: !ruby/object:Gem::Requirement
203
202
  requirements:
204
- - - ">="
203
+ - - "~>"
205
204
  - !ruby/object:Gem::Version
206
- version: '0'
205
+ version: 2.5.1
207
206
  type: :development
208
207
  prerelease: false
209
208
  version_requirements: !ruby/object:Gem::Requirement
210
209
  requirements:
211
- - - ">="
210
+ - - "~>"
212
211
  - !ruby/object:Gem::Version
213
- version: '0'
212
+ version: 2.5.1
214
213
  - !ruby/object:Gem::Dependency
215
214
  name: guard
216
215
  requirement: !ruby/object:Gem::Requirement
@@ -257,30 +256,58 @@ dependencies:
257
256
  name: guard-rubocop
258
257
  requirement: !ruby/object:Gem::Requirement
259
258
  requirements:
260
- - - ">="
259
+ - - "~>"
261
260
  - !ruby/object:Gem::Version
262
- version: '0'
261
+ version: 1.5.0
263
262
  type: :development
264
263
  prerelease: false
265
264
  version_requirements: !ruby/object:Gem::Requirement
266
265
  requirements:
267
- - - ">="
266
+ - - "~>"
268
267
  - !ruby/object:Gem::Version
269
- version: '0'
268
+ version: 1.5.0
269
+ - !ruby/object:Gem::Dependency
270
+ name: irb
271
+ requirement: !ruby/object:Gem::Requirement
272
+ requirements:
273
+ - - "~>"
274
+ - !ruby/object:Gem::Version
275
+ version: 1.15.1
276
+ type: :development
277
+ prerelease: false
278
+ version_requirements: !ruby/object:Gem::Requirement
279
+ requirements:
280
+ - - "~>"
281
+ - !ruby/object:Gem::Version
282
+ version: 1.15.1
283
+ - !ruby/object:Gem::Dependency
284
+ name: ostruct
285
+ requirement: !ruby/object:Gem::Requirement
286
+ requirements:
287
+ - - "~>"
288
+ - !ruby/object:Gem::Version
289
+ version: 0.6.1
290
+ type: :development
291
+ prerelease: false
292
+ version_requirements: !ruby/object:Gem::Requirement
293
+ requirements:
294
+ - - "~>"
295
+ - !ruby/object:Gem::Version
296
+ version: 0.6.1
270
297
  - !ruby/object:Gem::Dependency
271
298
  name: pry-byebug
272
299
  requirement: !ruby/object:Gem::Requirement
273
300
  requirements:
274
- - - ">="
301
+ - - "~>"
275
302
  - !ruby/object:Gem::Version
276
- version: '0'
303
+ version: 3.10.1
277
304
  type: :development
278
305
  prerelease: false
279
306
  version_requirements: !ruby/object:Gem::Requirement
280
307
  requirements:
281
- - - ">="
308
+ - - "~>"
282
309
  - !ruby/object:Gem::Version
283
- version: '0'
310
+ version: 3.10.1
284
311
  - !ruby/object:Gem::Dependency
285
312
  name: rake
286
313
  requirement: !ruby/object:Gem::Requirement
@@ -299,16 +326,16 @@ dependencies:
299
326
  name: rake-notes
300
327
  requirement: !ruby/object:Gem::Requirement
301
328
  requirements:
302
- - - ">="
329
+ - - "~>"
303
330
  - !ruby/object:Gem::Version
304
- version: '0'
331
+ version: 0.2.2
305
332
  type: :development
306
333
  prerelease: false
307
334
  version_requirements: !ruby/object:Gem::Requirement
308
335
  requirements:
309
- - - ">="
336
+ - - "~>"
310
337
  - !ruby/object:Gem::Version
311
- version: '0'
338
+ version: 0.2.2
312
339
  - !ruby/object:Gem::Dependency
313
340
  name: redcarpet
314
341
  requirement: !ruby/object:Gem::Requirement
@@ -323,6 +350,20 @@ dependencies:
323
350
  - - "~>"
324
351
  - !ruby/object:Gem::Version
325
352
  version: 3.6.0
353
+ - !ruby/object:Gem::Dependency
354
+ name: reline
355
+ requirement: !ruby/object:Gem::Requirement
356
+ requirements:
357
+ - - "~>"
358
+ - !ruby/object:Gem::Version
359
+ version: 0.6.0
360
+ type: :development
361
+ prerelease: false
362
+ version_requirements: !ruby/object:Gem::Requirement
363
+ requirements:
364
+ - - "~>"
365
+ - !ruby/object:Gem::Version
366
+ version: 0.6.0
326
367
  - !ruby/object:Gem::Dependency
327
368
  name: rspec
328
369
  requirement: !ruby/object:Gem::Requirement
@@ -341,58 +382,58 @@ dependencies:
341
382
  name: rubocop
342
383
  requirement: !ruby/object:Gem::Requirement
343
384
  requirements:
344
- - - ">="
385
+ - - "~>"
345
386
  - !ruby/object:Gem::Version
346
- version: '0'
387
+ version: '1.50'
347
388
  type: :development
348
389
  prerelease: false
349
390
  version_requirements: !ruby/object:Gem::Requirement
350
391
  requirements:
351
- - - ">="
392
+ - - "~>"
352
393
  - !ruby/object:Gem::Version
353
- version: '0'
394
+ version: '1.50'
354
395
  - !ruby/object:Gem::Dependency
355
396
  name: rubocop-rake
356
397
  requirement: !ruby/object:Gem::Requirement
357
398
  requirements:
358
- - - ">="
399
+ - - "~>"
359
400
  - !ruby/object:Gem::Version
360
- version: '0'
401
+ version: 0.6.0
361
402
  type: :development
362
403
  prerelease: false
363
404
  version_requirements: !ruby/object:Gem::Requirement
364
405
  requirements:
365
- - - ">="
406
+ - - "~>"
366
407
  - !ruby/object:Gem::Version
367
- version: '0'
408
+ version: 0.6.0
368
409
  - !ruby/object:Gem::Dependency
369
410
  name: rubocop-rspec
370
411
  requirement: !ruby/object:Gem::Requirement
371
412
  requirements:
372
- - - ">="
413
+ - - "~>"
373
414
  - !ruby/object:Gem::Version
374
- version: '0'
415
+ version: 3.5.0
375
416
  type: :development
376
417
  prerelease: false
377
418
  version_requirements: !ruby/object:Gem::Requirement
378
419
  requirements:
379
- - - ">="
420
+ - - "~>"
380
421
  - !ruby/object:Gem::Version
381
- version: '0'
422
+ version: 3.5.0
382
423
  - !ruby/object:Gem::Dependency
383
424
  name: simplecov
384
425
  requirement: !ruby/object:Gem::Requirement
385
426
  requirements:
386
- - - ">="
427
+ - - "~>"
387
428
  - !ruby/object:Gem::Version
388
- version: '0'
429
+ version: 0.22.0
389
430
  type: :development
390
431
  prerelease: false
391
432
  version_requirements: !ruby/object:Gem::Requirement
392
433
  requirements:
393
- - - ">="
434
+ - - "~>"
394
435
  - !ruby/object:Gem::Version
395
- version: '0'
436
+ version: 0.22.0
396
437
  - !ruby/object:Gem::Dependency
397
438
  name: timecop
398
439
  requirement: !ruby/object:Gem::Requirement
@@ -489,11 +530,14 @@ extra_rdoc_files: []
489
530
  files:
490
531
  - ".act-env"
491
532
  - ".act-secrets.example"
533
+ - ".github/FUNDING.yml"
492
534
  - ".github/ISSUE_TEMPLATE/bug_report.md"
493
535
  - ".github/ISSUE_TEMPLATE/feature_request.md"
494
536
  - ".github/workflows/coverage.yml"
495
537
  - ".github/workflows/lint.yml"
538
+ - ".github/workflows/merge-gatekeeper.yml"
496
539
  - ".github/workflows/release.yml"
540
+ - ".github/workflows/stale.yml"
497
541
  - ".github/workflows/test.yml"
498
542
  - ".gitignore"
499
543
  - ".release-please-manifest.json"
@@ -507,19 +551,22 @@ files:
507
551
  - CHANGELOG.md
508
552
  - CONTRIBUTING.md
509
553
  - ChangeLog
554
+ - Dockerfile
510
555
  - Gemfile
556
+ - Gemfile.lock
511
557
  - Guardfile
512
558
  - LICENSE
513
559
  - README.md
514
560
  - Rakefile
515
561
  - SECURITY.md
516
- - Vagrantfile
517
562
  - bin/maid
563
+ - fixtures/files/test_rules.rb
518
564
  - fixtures/vcr_cassettes/Dependency_expectations/Geocoder/translates_latitude_and_longitude_into_street_addresses.yml
519
565
  - fixtures/vcr_cassettes/Maid_Tools/_location_city/given_a_JPEG_image/reports_the_known_location.yml
520
566
  - lib/maid.rb
521
567
  - lib/maid/app.rb
522
568
  - lib/maid/downloading.rb
569
+ - lib/maid/logger/logger.rb
523
570
  - lib/maid/maid.rb
524
571
  - lib/maid/numeric_extensions.rb
525
572
  - lib/maid/platform.rb
@@ -535,15 +582,15 @@ files:
535
582
  - lib/maid/version.rb
536
583
  - lib/maid/watch.rb
537
584
  - maid.gemspec
585
+ - release-please-config.json
538
586
  - resources/OneThingWell.png
539
587
  - resources/download-for-ubuntu.png
540
588
  - resources/hacker-news.png
541
589
  - resources/ruby5.gif
590
+ - script/docker-test
542
591
  - script/smoke-test
543
- - script/vagrant-provision
544
- - script/vagrant-test
545
- - script/vagrant-test-all
546
592
  - spec/dependency_spec.rb
593
+ - spec/fakefs_helper.rb
547
594
  - spec/fixtures/files/1.zip
548
595
  - spec/fixtures/files/bar.zip
549
596
  - spec/fixtures/files/foo.zip
@@ -552,6 +599,7 @@ files:
552
599
  - spec/fixtures/files/unknown.foo
553
600
  - spec/fixtures/files/さ.zip
554
601
  - spec/lib/maid/app_spec.rb
602
+ - spec/lib/maid/logger/logger_spec.rb
555
603
  - spec/lib/maid/maid_spec.rb
556
604
  - spec/lib/maid/numeric_extensions_spec.rb
557
605
  - spec/lib/maid/platform_spec.rb
@@ -582,15 +630,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
582
630
  requirements:
583
631
  - - ">="
584
632
  - !ruby/object:Gem::Version
585
- version: 2.7.0
633
+ version: 3.2.0
586
634
  required_rubygems_version: !ruby/object:Gem::Requirement
587
635
  requirements:
588
636
  - - ">="
589
637
  - !ruby/object:Gem::Version
590
638
  version: '0'
591
639
  requirements: []
592
- rubygems_version: 3.4.6
593
- signing_key:
640
+ rubygems_version: 3.6.2
594
641
  specification_version: 4
595
642
  summary: Be lazy. Let Maid clean up after you, based on rules you define. Think of
596
643
  it as "Hazel for hackers".
data/Vagrantfile DELETED
@@ -1,14 +0,0 @@
1
- # -*- mode: ruby -*-
2
- # vi: set ft=ruby :
3
-
4
- Vagrant.configure('2') do |config|
5
- # See also: `script/vagrant-test`, `script/vagrant-test-all`
6
- config.vm.box = ENV['MAID_TARGET_BOX'] || 'hashicorp/precise64'
7
-
8
- config.vm.provider :virtualbox do |vb|
9
- # Maid has very low system requirements
10
- vb.customize ['modifyvm', :id, '--cpus', 1, '--memory', 192]
11
- end
12
-
13
- config.vm.provision(:shell, path: 'script/vagrant-provision', args: ENV['MAID_TARGET_RUBY'] || '1.9.3')
14
- end
@@ -1,43 +0,0 @@
1
- #!/usr/bin/env bash
2
- # A simple shell-based provisioner for Vagrant.
3
- #
4
- # Documentation: [Shell Provisioner](http://vagrantup.com/v1/docs/provisioners/shell.html)
5
- set -o errexit
6
-
7
- # Set to '1.9.3', 'jruby'
8
- target_ruby_version="${1:-1.9.3}"
9
-
10
- # Install the given package, no questions asked.
11
- function install-pkg {
12
- sudo apt-get install -y "$1"
13
- }
14
-
15
- # Only install the given package if targeting the given Ruby version.
16
- function install-pkg-if-ruby {
17
- local ruby_version="$1"
18
- local package="$2"
19
-
20
- if [ "$target_ruby_version" == "$ruby_version" ]; then
21
- install-pkg "$package"
22
- fi
23
- }
24
-
25
- sudo apt-get update
26
-
27
- # ## Dependencies
28
- # Installs `ruby 1.9.3p0`
29
- install-pkg-if-ruby '1.9.3' 'ruby1.9.1'
30
- install-pkg-if-ruby 'jruby' 'jruby'
31
-
32
- # ## Development dependencies
33
- #
34
- # For building `maid-x.y.z.gem`
35
- install-pkg 'git-core'
36
- # For building `ffi` for `guard`'s soft dependency on `rb-inotify`
37
- install-pkg 'make'
38
- install-pkg 'libffi-dev'
39
- install-pkg-if-ruby '1.9.3' 'ruby1.9.1-dev'
40
-
41
- sudo gem install bundler
42
- cd /vagrant
43
- bundle install
data/script/vagrant-test DELETED
@@ -1,7 +0,0 @@
1
- #!/usr/bin/env bash
2
- # Run tests on a newly created Vagrant box.
3
- set -o errexit
4
-
5
- vagrant destroy --force
6
- vagrant up
7
- vagrant ssh --command 'cd /vagrant && rake && sudo rake install && script/smoke-test'
@@ -1,34 +0,0 @@
1
- #!/usr/bin/env bash
2
- # Test all officially supported Ubuntu versions.
3
- #
4
- # See also: `Vagrantfile`
5
-
6
- # ## Base Boxes
7
- #
8
- # To add a [box](http://vagrantup.com/v1/docs/boxes.html):
9
- #
10
- # vagrant box add $box_name $box_url
11
- #
12
- # Base boxes for supported releases are listed below. The idea is to come close to the [official Canonical support timeline](http://en.wikipedia.org/wiki/Ubuntu_releases#Table_of_versions), when possible.
13
- #
14
- # ### Releases preferred with Ruby 1.9.3
15
- #
16
- # Supported until 2017-04:
17
- #
18
- # * `precise32`: http://files.vagrantup.com/precise32.box
19
- # * `precise64`: http://files.vagrantup.com/precise64.box
20
- #
21
- # Supported until 2014-07:
22
- #
23
- # * `saucy32`
24
- # * `saucy64`
25
- #
26
- # ## See Also
27
- #
28
- # * [Vagrant Boxes List](http://www.vagrantbox.es/)
29
- # * [Contributing Guide](https://github.com/benjaminoakes/maid/wiki/Contributing)
30
-
31
- MAID_TARGET_BOX='hashicorp/precise32' MAID_TARGET_RUBY='1.9.3' script/vagrant-test
32
- MAID_TARGET_BOX='hashicorp/precise64' MAID_TARGET_RUBY='1.9.3' script/vagrant-test
33
- # TODO: Locate and add box for `saucy32`
34
- # TODO: Locate and add box for `saucy64`