maid 0.10.0.pre.alpha.3 → 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 (51) hide show
  1. checksums.yaml +4 -4
  2. data/.github/FUNDING.yml +14 -0
  3. data/.github/ISSUE_TEMPLATE/bug_report.md +37 -0
  4. data/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
  5. data/.github/workflows/coverage.yml +3 -3
  6. data/.github/workflows/lint.yml +9 -1
  7. data/.github/workflows/merge-gatekeeper.yml +20 -0
  8. data/.github/workflows/release.yml +13 -20
  9. data/.github/workflows/stale.yml +25 -0
  10. data/.github/workflows/test.yml +8 -7
  11. data/.gitignore +1 -1
  12. data/.release-please-manifest.json +1 -1
  13. data/.rubocop.yml +3 -1
  14. data/.rubocop_todo.yml +105 -107
  15. data/.ruby-version +1 -1
  16. data/CHANGELOG.md +23 -0
  17. data/Dockerfile +13 -0
  18. data/Gemfile.lock +226 -0
  19. data/Guardfile +2 -0
  20. data/README.md +82 -49
  21. data/Rakefile +9 -0
  22. data/SECURITY.md +29 -0
  23. data/fixtures/files/test_rules.rb +3 -0
  24. data/fixtures/vcr_cassettes/Dependency_expectations/Geocoder/translates_latitude_and_longitude_into_street_addresses.yml +42 -0
  25. data/fixtures/vcr_cassettes/Maid_Tools/_location_city/given_a_JPEG_image/reports_the_known_location.yml +42 -0
  26. data/lib/maid/logger/logger.rb +63 -0
  27. data/lib/maid/maid.rb +6 -22
  28. data/lib/maid/repeat.rb +2 -2
  29. data/lib/maid/rule.rb +2 -2
  30. data/lib/maid/rule_container.rb +2 -2
  31. data/lib/maid/tools.rb +3 -3
  32. data/lib/maid/trash_migration.rb +2 -0
  33. data/lib/maid/version.rb +1 -1
  34. data/lib/maid/watch.rb +2 -2
  35. data/lib/maid.rb +3 -2
  36. data/maid.gemspec +14 -9
  37. data/release-please-config.json +18 -0
  38. data/script/docker-test +7 -0
  39. data/spec/dependency_spec.rb +1 -1
  40. data/spec/fakefs_helper.rb +13 -0
  41. data/spec/lib/maid/logger/logger_spec.rb +64 -0
  42. data/spec/lib/maid/maid_spec.rb +113 -103
  43. data/spec/lib/maid/rake/single_rule_spec.rb +1 -1
  44. data/spec/lib/maid/tools_spec.rb +384 -225
  45. data/spec/lib/maid/trash_migration_spec.rb +7 -5
  46. data/spec/spec_helper.rb +17 -1
  47. metadata +124 -44
  48. data/Vagrantfile +0 -14
  49. data/script/vagrant-provision +0 -43
  50. data/script/vagrant-test +0 -7
  51. data/script/vagrant-test-all +0 -34
data/Gemfile.lock ADDED
@@ -0,0 +1,226 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ maid (0.11.0)
5
+ deprecated (~> 3.0.0)
6
+ dimensions (>= 1.0.0, < 2.0)
7
+ escape (>= 0.0.1, < 0.1.0)
8
+ exifr (~> 1.3.10)
9
+ geocoder (~> 1.8.1)
10
+ listen (~> 3.8.0)
11
+ mime-types (~> 3.0, < 4.0)
12
+ rubyzip (~> 2.3.2)
13
+ rufus-scheduler (~> 3.8.2)
14
+ thor (~> 1.2.1)
15
+ xdg (~> 2.2.3)
16
+
17
+ GEM
18
+ remote: https://rubygems.org/
19
+ specs:
20
+ addressable (2.8.7)
21
+ public_suffix (>= 2.0.2, < 7.0)
22
+ ast (2.4.3)
23
+ base64 (0.2.0)
24
+ bigdecimal (3.1.9)
25
+ byebug (11.1.3)
26
+ coderay (1.1.3)
27
+ colored (1.2)
28
+ concurrent-ruby (1.3.5)
29
+ crack (1.0.0)
30
+ bigdecimal
31
+ rexml
32
+ csv (3.3.3)
33
+ date (3.4.1)
34
+ deprecated (3.0.1)
35
+ diff-lcs (1.6.1)
36
+ dimensions (1.3.0)
37
+ docile (1.4.1)
38
+ escape (0.0.4)
39
+ et-orbi (1.2.11)
40
+ tzinfo
41
+ exifr (1.3.10)
42
+ fakefs (2.4.0)
43
+ ffi (1.17.1)
44
+ ffi (1.17.1-x86_64-linux-gnu)
45
+ formatador (1.1.0)
46
+ fugit (1.11.1)
47
+ et-orbi (~> 1, >= 1.2.11)
48
+ raabro (~> 1.4)
49
+ fuubar (2.5.1)
50
+ rspec-core (~> 3.0)
51
+ ruby-progressbar (~> 1.4)
52
+ geocoder (1.8.5)
53
+ base64 (>= 0.1.0)
54
+ csv (>= 3.0.0)
55
+ guard (2.18.1)
56
+ formatador (>= 0.2.4)
57
+ listen (>= 2.7, < 4.0)
58
+ lumberjack (>= 1.0.12, < 2.0)
59
+ nenv (~> 0.1)
60
+ notiffany (~> 0.0)
61
+ pry (>= 0.13.0)
62
+ shellany (~> 0.0)
63
+ thor (>= 0.18.1)
64
+ guard-bundler (3.0.1)
65
+ bundler (>= 2.1, < 3)
66
+ guard (~> 2.2)
67
+ guard-compat (~> 1.1)
68
+ guard-compat (1.2.1)
69
+ guard-rspec (4.7.3)
70
+ guard (~> 2.1)
71
+ guard-compat (~> 1.1)
72
+ rspec (>= 2.99.0, < 4.0)
73
+ guard-rubocop (1.5.0)
74
+ guard (~> 2.0)
75
+ rubocop (< 2.0)
76
+ hashdiff (1.1.2)
77
+ io-console (0.8.0)
78
+ irb (1.15.1)
79
+ pp (>= 0.6.0)
80
+ rdoc (>= 4.0.0)
81
+ reline (>= 0.4.2)
82
+ json (2.10.2)
83
+ language_server-protocol (3.17.0.4)
84
+ lint_roller (1.1.0)
85
+ listen (3.8.0)
86
+ rb-fsevent (~> 0.10, >= 0.10.3)
87
+ rb-inotify (~> 0.9, >= 0.9.10)
88
+ logger (1.7.0)
89
+ lumberjack (1.2.10)
90
+ method_source (1.1.0)
91
+ mime-types (3.6.2)
92
+ logger
93
+ mime-types-data (~> 3.2015)
94
+ mime-types-data (3.2025.0325)
95
+ nenv (0.3.0)
96
+ notiffany (0.1.3)
97
+ nenv (~> 0.1)
98
+ shellany (~> 0.0)
99
+ ostruct (0.6.1)
100
+ parallel (1.26.3)
101
+ parser (3.3.7.3)
102
+ ast (~> 2.4.1)
103
+ racc
104
+ pp (0.6.2)
105
+ prettyprint
106
+ prettyprint (0.2.0)
107
+ prism (1.4.0)
108
+ pry (0.14.2)
109
+ coderay (~> 1.1)
110
+ method_source (~> 1.0)
111
+ pry-byebug (3.10.1)
112
+ byebug (~> 11.0)
113
+ pry (>= 0.13, < 0.15)
114
+ psych (5.2.3)
115
+ date
116
+ stringio
117
+ public_suffix (6.0.1)
118
+ raabro (1.4.0)
119
+ racc (1.8.1)
120
+ rainbow (3.1.1)
121
+ rake (13.0.6)
122
+ rake-notes (0.2.2)
123
+ colored
124
+ rake
125
+ rb-fsevent (0.11.2)
126
+ rb-inotify (0.10.1)
127
+ ffi (~> 1.0)
128
+ rdoc (6.13.0)
129
+ psych (>= 4.0.0)
130
+ redcarpet (3.6.1)
131
+ regexp_parser (2.10.0)
132
+ reline (0.6.0)
133
+ io-console (~> 0.5)
134
+ rexml (3.4.1)
135
+ rspec (3.12.0)
136
+ rspec-core (~> 3.12.0)
137
+ rspec-expectations (~> 3.12.0)
138
+ rspec-mocks (~> 3.12.0)
139
+ rspec-core (3.12.3)
140
+ rspec-support (~> 3.12.0)
141
+ rspec-expectations (3.12.4)
142
+ diff-lcs (>= 1.2.0, < 2.0)
143
+ rspec-support (~> 3.12.0)
144
+ rspec-mocks (3.12.7)
145
+ diff-lcs (>= 1.2.0, < 2.0)
146
+ rspec-support (~> 3.12.0)
147
+ rspec-support (3.12.2)
148
+ rubocop (1.75.1)
149
+ json (~> 2.3)
150
+ language_server-protocol (~> 3.17.0.2)
151
+ lint_roller (~> 1.1.0)
152
+ parallel (~> 1.10)
153
+ parser (>= 3.3.0.2)
154
+ rainbow (>= 2.2.2, < 4.0)
155
+ regexp_parser (>= 2.9.3, < 3.0)
156
+ rubocop-ast (>= 1.43.0, < 2.0)
157
+ ruby-progressbar (~> 1.7)
158
+ unicode-display_width (>= 2.4.0, < 4.0)
159
+ rubocop-ast (1.43.0)
160
+ parser (>= 3.3.7.2)
161
+ prism (~> 1.4)
162
+ rubocop-rake (0.6.0)
163
+ rubocop (~> 1.0)
164
+ rubocop-rspec (3.5.0)
165
+ lint_roller (~> 1.1)
166
+ rubocop (~> 1.72, >= 1.72.1)
167
+ ruby-progressbar (1.13.0)
168
+ rubyzip (2.3.2)
169
+ rufus-scheduler (3.8.2)
170
+ fugit (~> 1.1, >= 1.1.6)
171
+ shellany (0.0.1)
172
+ simplecov (0.22.0)
173
+ docile (~> 1.1)
174
+ simplecov-html (~> 0.11)
175
+ simplecov_json_formatter (~> 0.1)
176
+ simplecov-html (0.13.1)
177
+ simplecov_json_formatter (0.1.4)
178
+ stringio (3.1.6)
179
+ thor (1.2.2)
180
+ timecop (0.9.10)
181
+ tzinfo (2.0.6)
182
+ concurrent-ruby (~> 1.0)
183
+ unicode-display_width (3.1.4)
184
+ unicode-emoji (~> 4.0, >= 4.0.4)
185
+ unicode-emoji (4.0.4)
186
+ vcr (6.1.0)
187
+ webmock (3.18.1)
188
+ addressable (>= 2.8.0)
189
+ crack (>= 0.3.2)
190
+ hashdiff (>= 0.4.0, < 2.0.0)
191
+ xdg (2.2.5)
192
+ yard (0.9.37)
193
+
194
+ PLATFORMS
195
+ ruby
196
+ x86_64-linux
197
+
198
+ DEPENDENCIES
199
+ fakefs (~> 2.4.0)
200
+ fuubar (~> 2.5.1)
201
+ guard (~> 2.18.0)
202
+ guard-bundler (~> 3.0.1)
203
+ guard-rspec (~> 4.7.3)
204
+ guard-rubocop (~> 1.5.0)
205
+ irb (~> 1.15.1)
206
+ maid!
207
+ ostruct (~> 0.6.1)
208
+ pry-byebug (~> 3.10.1)
209
+ rake (~> 13.0.6)
210
+ rake-notes (~> 0.2.2)
211
+ rb-fsevent (~> 0.11.2)
212
+ rb-inotify (~> 0.10.1)
213
+ redcarpet (~> 3.6.0)
214
+ reline (~> 0.6.0)
215
+ rspec (~> 3.12.0)
216
+ rubocop (~> 1.50)
217
+ rubocop-rake (~> 0.6.0)
218
+ rubocop-rspec (~> 3.5.0)
219
+ simplecov (~> 0.22.0)
220
+ timecop (~> 0.9.6)
221
+ vcr (~> 6.1.0)
222
+ webmock (~> 3.18.1)
223
+ yard (>= 0.9.11)
224
+
225
+ BUNDLED WITH
226
+ 2.6.2
data/Guardfile CHANGED
@@ -27,6 +27,8 @@ end
27
27
 
28
28
  guard :rubocop, cli: ['--autocorrect', '--display-cop-names'] do
29
29
  watch('Gemfile')
30
+ watch('Vagrantfile')
31
+ watch('Rakefile')
30
32
  watch(%r{^(?!node_modules/).+\.rb$})
31
33
  watch(%r{(?:.+/)?\.rubocop(?:_todo)?\.yml$}) { |m| File.dirname(m[0]) }
32
34
  end
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Maid
2
2
 
3
- [![Gem Version](https://badge.fury.io/rb/maid.svg)](http://badge.fury.io/rb/maid)
3
+ [![Gem Version](https://badge.fury.io/rb/maid.svg)](https://badge.fury.io/rb/maid)
4
4
  [![Test](https://github.com/maid/maid/actions/workflows/test.yml/badge.svg)](https://github.com/maid/maid/actions/workflows/test.yml)
5
5
  [![Code Climate](https://codeclimate.com/github/maid/maid.svg)](https://codeclimate.com/github/maid/maid)
6
6
  [![Test Coverage](https://api.codeclimate.com/v1/badges/3898063fb5b3caf24044/test_coverage)](https://codeclimate.com/github/maid/maid/test_coverage)
@@ -10,10 +10,10 @@
10
10
 
11
11
  [Installation](#installation)
12
12
  | [Tutorial](#tutorial)
13
- | [Example](https://github.com/benjaminoakes/maid-example)
14
- | [User Community](https://github.com/benjaminoakes/maid/wiki)
13
+ | [Example](https://github.com/maid/maid-example)
14
+ | [User Community](https://github.com/maid/maid/wiki)
15
15
  | [Documentation][]
16
- | [Change Log](https://github.com/benjaminoakes/maid/blob/master/ChangeLog)
16
+ | [Changelog](CHANGELOG.md)
17
17
 
18
18
  Maid keeps files from sitting around too long, untouched. Many of the downloads and temporary files you collect can
19
19
  easily be categorized and handled appropriately by rules you define. Let the `maid` in your computer take care of the
@@ -33,46 +33,42 @@ general-purpose **advanced file renaming tool**.
33
33
  This project wouldn't be where it is today without its users and contributors. Thank you! See [AUTHORS][] and the
34
34
  [contributors graph][] for more info.
35
35
 
36
- [authors]: https://github.com/benjaminoakes/maid/blob/master/AUTHORS.md
37
- [contributors graph]: https://github.com/benjaminoakes/maid/graphs/contributors
36
+ [authors]: https://github.com/maid/maid/blob/master/AUTHORS.md
37
+ [contributors graph]: https://github.com/maid/maid/graphs/contributors
38
38
 
39
39
  ### For Users
40
40
 
41
- [
42
- ![Flattr this git repo](https://api.flattr.com/button/flattr-badge-large.png)
43
- ](https://flattr.com/submit/auto?user_id=benjaminoakes&url=https://github.com/benjaminoakes/maid&title=maid&language=en_GB&tags=github&category=software)
44
-
45
- * Participate in [beta testing](https://github.com/benjaminoakes/maid/issues/10)
46
- * [Report an issue](https://github.com/benjaminoakes/maid/issues) (bug or feature request)
47
- * Read through the [wiki](https://github.com/benjaminoakes/maid/wiki)
48
- * Even just [share a link to Maid](https://twitter.com/intent/tweet?related=benjaminoakes&text=Be+lazy%21+Let+Maid+clean+up+after+you%2C+based+on+rules+you+define&url=https%3A%2F%2Fgithub.com%2Fbenjaminoakes%2Fmaid) :)
41
+ * Participate in [beta testing](https://github.com/maid/maid/issues/10)
42
+ * [Report an issue](https://github.com/maid/maid/issues) (bug or feature request)
43
+ * Read through the [wiki](https://github.com/maid/maid/wiki)
44
+ * Even just [share a link to Maid](https://twitter.com/intent/tweet?related=maidgem&text=Be+lazy%21+Let+Maid+clean+up+after+you%2C+based+on+rules+you+define&url=https%3A%2F%2Fgithub.com%2Fmaid%2Fmaid) :)
49
45
 
50
46
  ### For Developers
51
47
 
52
- * Address a `TODO` or `FIXME` in the code.
53
- * Complete an issue (easy ones [are labelled](https://github.com/benjaminoakes/maid/issues?labels=difficulty-1&page=1&state=open), and issues for future releases are [grouped by milestone](https://github.com/benjaminoakes/maid/issues/milestones)).
48
+ * Address a `TODO` or `FIXME` in the code (list them with `rake notes`.)
49
+ * Fix an [existing issue](https://github.com/maid/maid/issues)
54
50
  * **Working on an issue?** Please leave a comment so others know.
55
- * See the [Contributing guide](https://github.com/benjaminoakes/maid/wiki/Contributing)
51
+ * See the [Contributing guide](https://github.com/maid/maid/wiki/Contributing)
56
52
 
57
53
  ## Buzz
58
54
 
59
55
  [
60
- ![Hacker News Logo](https://raw.github.com/benjaminoakes/maid/master/resources/hacker-news.png)
56
+ ![Hacker News Logo](https://raw.github.com/maid/maid/master/resources/hacker-news.png)
61
57
  ](http://news.ycombinator.com/)
62
58
 
63
59
  [Hazel for hackers](http://news.ycombinator.com/item?id=4928605) - December 16th, 2012 (peaked at #2)
64
60
 
65
- [![Ruby5 Logo](https://raw.github.com/benjaminoakes/maid/master/resources/ruby5.gif)](http://ruby5.envylabs.com/)
61
+ [![Ruby5 Logo](https://raw.github.com/maid/maid/master/resources/ruby5.gif)](http://ruby5.envylabs.com/)
66
62
 
67
63
  [Podcast #302](http://ruby5.envylabs.com/episodes/306-episode-302-august-31st-2012) (at 2:45) - August 31st, 2012
68
64
 
69
65
  [
70
- ![OneThingWell Logo](https://raw.github.com/benjaminoakes/maid/master/resources/OneThingWell.png)
66
+ ![OneThingWell Logo](https://raw.github.com/maid/maid/master/resources/OneThingWell.png)
71
67
  ](http://onethingwell.org/)
72
68
 
73
69
  [Maid](http://onethingwell.org/post/30455088809/maid) - August 29th, 2012
74
70
 
75
- [More...](https://github.com/benjaminoakes/maid/wiki/In-the-Media)
71
+ [More...](https://github.com/maid/maid/wiki/In-the-Media)
76
72
 
77
73
  ## Installation
78
74
 
@@ -91,38 +87,55 @@ Some features require OS X. See the [documentation][] for more details.
91
87
 
92
88
  ### Manual Installation
93
89
 
94
- First, you need Ruby.
95
-
96
- Consider `rbenv` or `rvm`, especially if only Ruby 1.8.7 is available (e.g. if you are using an older version of OS X).
97
-
98
- System Ruby works fine too, though:
90
+ First, you need Ruby 2.7 or 3. If you're starting without any Rubies, we
91
+ strongly recommend going for Ruby 3 as 2.7 is EOL.
99
92
 
100
- * **Mac OS X:** Ruby 2.0.0 comes preinstalled in OS X 10.9.
101
- * **Ubuntu:** Ruby is not preinstalled. To install Ruby 2.7: `sudo apt-get install ruby2.7`
102
- ([Interested in a package?](https://github.com/benjaminoakes/maid/issues/3))
93
+ Consider using [`rvm`](https://rvm.io/rvm/install), [`rbenv`](https://github.com/rbenv/rbenv#installation), [`rtx`](https://github.com/jdxcode/rtx), or [any other version management tool](https://github.com/bernardoduarte/awesome-version-managers).
103
94
 
104
- Then, you can install via RubyGems. Open a terminal and run:
95
+ Then, install via RubyGems. Open a terminal and run:
105
96
 
106
- gem install maid
107
-
108
- (Use `sudo` if using system Ruby.)
97
+ ```bash
98
+ gem install maid
99
+ ```
109
100
 
110
101
  At a later date, you can update by running:
111
102
 
112
- gem update maid
103
+ ```bash
104
+ gem update maid
105
+ ```
113
106
 
114
107
  If you decide you don't want Maid installed anymore, remove it:
115
108
 
116
- gem uninstall maid
109
+ ```bash
110
+ gem uninstall maid
111
+ ```
117
112
 
118
113
  **NOTE:** This does not remove any files under `~/.maid` or crontab entries. Please remove them at your convenience.
119
114
 
115
+ ### Install through RVM and a dedicated gemset
116
+
117
+ Install Ruby 3.2 and create a gemset:
118
+
119
+ `rvm install ruby-3.2 && rvm use 3.2 && rvm gemset create maid && rvm alias create maid ruby-3.2@maid`
120
+
121
+ Install maid:
122
+
123
+ `rvm use maid && gem install maid`
124
+
125
+ Update maid:
126
+
127
+ `rvm use maid && gem update maid`
128
+
129
+ Update ruby:
130
+
131
+ `rvm install ruby-3.3 && rvm gemset copy 3.{2,3}@maid && rvm alias maid 3.3@maid`
132
+
120
133
  ## Tutorial
121
134
 
122
135
  In a nutshell, Maid uses "rules" to define how files are handled. Once you have rules defined, you can either test what
123
136
  cleaning would do (`maid clean -n`) or actually clean (`maid clean -f`).
124
137
 
125
- To generate a [sample rules file](https://github.com/benjaminoakes/maid/blob/master/lib/maid/rules.sample.rb), run:
138
+ To generate a [sample rules file](lib/maid/rules.sample.rb), run:
126
139
 
127
140
  ```bash
128
141
  maid sample
@@ -182,11 +195,13 @@ end
182
195
 
183
196
  Then, this is the command to test, as well as some sample output:
184
197
 
185
- $ maid clean -nr some_rules.rb
186
- Rule: downloaded PDF books
187
- mv "/Users/ben/Downloads/book.pdf" "/Users/ben/Books/"
188
- mv "/Users/ben/Downloads/issue12.pdf" "/Users/ben/Books/"
189
- mv "/Users/ben/Downloads/spring2011newsletter.pdf" "/Users/ben/Books/"
198
+ ```bash
199
+ $ maid clean -nr some_rules.rb
200
+ Rule: downloaded PDF books
201
+ mv "/Users/ben/Downloads/book.pdf" "/Users/ben/Books/"
202
+ mv "/Users/ben/Downloads/issue12.pdf" "/Users/ben/Books/"
203
+ mv "/Users/ben/Downloads/spring2011newsletter.pdf" "/Users/ben/Books/"
204
+ ```
190
205
 
191
206
  For help with command line usage, run `maid help`. For more help, please see the links at the top of this README.
192
207
 
@@ -199,16 +214,20 @@ your computer stays a little tidier with as you teach it how to handle your comm
199
214
 
200
215
  To do this, edit your crontab in your tool of choice:
201
216
 
202
- crontab -e
217
+ ```bash
218
+ crontab -e
219
+ ```
203
220
 
204
221
  ...and have it invoke the `maid clean -f` command. The `--silent` option is provided to keep this from emailing you, if
205
222
  desired. A log of the actions taken is kept at `~/.maid/maid.log`.
206
223
 
207
224
  Example for every day at 1am:
208
225
 
209
- # minute hour day_of_month month day_of_week command_to_execute
210
- 0 1 * * * /bin/bash -li -c "maid clean --force --silent"
211
-
226
+ ```cron
227
+ # minute hour day_of_month month day_of_week command_to_execute
228
+ 0 1 * * * /bin/bash -li -c "maid clean --force --silent"
229
+ ```
230
+
212
231
  ### Running as a daemon
213
232
 
214
233
  To run Maid as a daemon you first have to specify watch/repeat rules.
@@ -252,13 +271,27 @@ end
252
271
 
253
272
  The command to run the daemon is `maid daemon`. Starting the daemon on login depends on the platform.
254
273
 
274
+ #### With RVM and cron
275
+
276
+ See [above](#install-through-rvm-and-a-dedicated-gemset) to install RVM and
277
+ maid in its own gemset.
278
+
279
+ Run maid daily in a cron:
280
+
281
+ ```cron
282
+ # /etc/cron.daily/maid
283
+
284
+ #!/usr/bin/env bash
285
+ sudo -Hu <your username> bash -li -c "<your username>/.rvm/wrappers/maid/maid clean --force --silent --rules ~/.maid/rules.rb"
286
+ ```
287
+
255
288
  #### Ubuntu
256
289
 
257
290
  You can run `maid daemon` as a normal startup application (Power/Gear Menu -> Startup Applications... -> Add).
258
291
 
259
- #### OSX
292
+ #### OS X
260
293
 
261
- Please see Jurriaan Pruis' blog post, [Maid as a Daemon on OS X](http://jurriaan.ninja/2015/01/01/maid-on-os-x.html). ([Automating this setup would be welcome as a pull request!](https://github.com/benjaminoakes/maid/issues/136))
294
+ Please see Jurriaan Pruis' blog post, [Maid as a Daemon on OS X](https://web.archive.org/web/20191228181605/jurriaan.ninja/2015/01/01/maid-on-os-x.html). ([Automating this setup would be welcome as a pull request!](https://github.com/maid/maid/issues/136))
262
295
 
263
296
  ### Rake Tasks
264
297
 
@@ -274,7 +307,7 @@ Maid::Rake::Task.new :clean do
274
307
  end
275
308
  ```
276
309
 
277
- In fact, the Maid project uses Maid in [its Rakefile](https://github.com/benjaminoakes/maid/blob/master/Rakefile).
310
+ In fact, the Maid project uses Maid in [its Rakefile](Rakefile).
278
311
 
279
312
  You can also provide a custom description:
280
313
 
@@ -296,4 +329,4 @@ ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
296
329
 
297
330
  GPLv2. See LICENSE for a copy.
298
331
 
299
- [documentation]: http://www.rubydoc.info/github/benjaminoakes/maid/master/Maid/Tools
332
+ [documentation]: https://www.rubydoc.info/github/maid/maid/master
data/Rakefile CHANGED
@@ -25,3 +25,12 @@ Maid::Rake::Task.new(:clean) do
25
25
  trash('pkg')
26
26
  trash('tmp')
27
27
  end
28
+
29
+ namespace :guard do
30
+ default_target_ruby_version = File.read('Dockerfile').match(/^FROM ruby:(.*)$/)[1]
31
+
32
+ desc "Run Guard in a Docker container (ruby-#{default_target_ruby_version})"
33
+ task :docker do
34
+ system('./script/docker-test')
35
+ end
36
+ end
data/SECURITY.md ADDED
@@ -0,0 +1,29 @@
1
+ # Security Policy
2
+
3
+ ## Supported Versions
4
+
5
+ ### Maid gem
6
+ | Version | Supported |
7
+ | ------------ | ------------------ |
8
+ | >= 0.10.0 | :heavy_check_mark: |
9
+ | 0.7.0 | :heavy_check_mark: |
10
+ | < 0.7.0 | :x: |
11
+
12
+ ### Ruby
13
+ | Version | Supported |
14
+ | ------------ | ------------------ |
15
+ | >= 3.0 | :heavy_check_mark: |
16
+ | 2.7 | :warning: |
17
+ | <= 2.6 | :x: |
18
+
19
+ > :warning: Ruby 2.7 became EOL on 2023-03-31 and might be dropped in the near
20
+ > future. We strongly recommend using Ruby 3+.
21
+
22
+ ## Reporting a Vulnerability
23
+
24
+ To report a vulnerability, please open an issue. We will investigate and
25
+ respond in a timely manner.
26
+
27
+ If the vulnerability is accepted, we will work on a patch. Bear in mind that
28
+ this is a community effort and we can't commit to specific timeframes other
29
+ than best effort.
@@ -0,0 +1,3 @@
1
+ Maid.rules do
2
+ rename('/tmp/maid-specs/perfect_man', '/tmp/maid-specs/buffalo_fuzz')
3
+ end
@@ -0,0 +1,42 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://nominatim.openstreetmap.org/reverse?accept-language=en&addressdetails=1&format=json&lat=-33.85608611111111&lon=151.219925
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - "*/*"
14
+ User-Agent:
15
+ - Ruby
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Server:
22
+ - nginx
23
+ Date:
24
+ - Fri, 21 Apr 2023 12:28:49 GMT
25
+ Content-Type:
26
+ - application/json; charset=UTF-8
27
+ Transfer-Encoding:
28
+ - chunked
29
+ Connection:
30
+ - keep-alive
31
+ Keep-Alive:
32
+ - timeout=20
33
+ Access-Control-Allow-Origin:
34
+ - "*"
35
+ Access-Control-Allow-Methods:
36
+ - OPTIONS,GET
37
+ body:
38
+ encoding: ASCII-8BIT
39
+ string: !binary |-
40
+ eyJwbGFjZV9pZCI6Mjk4ODA4MzUxLCJsaWNlbmNlIjoiRGF0YSDCqSBPcGVuU3RyZWV0TWFwIGNvbnRyaWJ1dG9ycywgT0RiTCAxLjAuIGh0dHBzOi8vb3NtLm9yZy9jb3B5cmlnaHQiLCJvc21fdHlwZSI6InJlbGF0aW9uIiwib3NtX2lkIjo5NTk5NzIzLCJsYXQiOiItMzMuODU2Mzc3NjUiLCJsb24iOiIxNTEuMjE1NTcxODMwNzQ1MDYiLCJkaXNwbGF5X25hbWUiOiJOb3J0aGVybiBCb2FyZHdhbGssIFF1YXkgUXVhcnRlciwgU3lkbmV5LCBDb3VuY2lsIG9mIHRoZSBDaXR5IG9mIFN5ZG5leSwgTmV3IFNvdXRoIFdhbGVzLCAyMDAwLCBBdXN0cmFsaWEiLCJhZGRyZXNzIjp7InJvYWQiOiJOb3J0aGVybiBCb2FyZHdhbGsiLCJuZWlnaGJvdXJob29kIjoiUXVheSBRdWFydGVyIiwic3VidXJiIjoiU3lkbmV5IiwiY2l0eSI6IlN5ZG5leSIsIm11bmljaXBhbGl0eSI6IkNvdW5jaWwgb2YgdGhlIENpdHkgb2YgU3lkbmV5Iiwic3RhdGUiOiJOZXcgU291dGggV2FsZXMiLCJJU08zMTY2LTItbHZsNCI6IkFVLU5TVyIsInBvc3Rjb2RlIjoiMjAwMCIsImNvdW50cnkiOiJBdXN0cmFsaWEiLCJjb3VudHJ5X2NvZGUiOiJhdSJ9LCJib3VuZGluZ2JveCI6WyItMzMuODU2Njc0MiIsIi0zMy44NTYxMDk2IiwiMTUxLjIxNDU1NzkiLCIxNTEuMjE1OTA4NCJdfQ==
41
+ recorded_at: Fri, 21 Apr 2023 12:28:49 GMT
42
+ recorded_with: VCR 6.1.0
@@ -0,0 +1,42 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://nominatim.openstreetmap.org/reverse?accept-language=en&addressdetails=1&format=json&lat=-33.85608611111111&lon=151.219925
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - "*/*"
14
+ User-Agent:
15
+ - Ruby
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Server:
22
+ - nginx
23
+ Date:
24
+ - Fri, 21 Apr 2023 12:29:51 GMT
25
+ Content-Type:
26
+ - application/json; charset=UTF-8
27
+ Transfer-Encoding:
28
+ - chunked
29
+ Connection:
30
+ - keep-alive
31
+ Keep-Alive:
32
+ - timeout=20
33
+ Access-Control-Allow-Origin:
34
+ - "*"
35
+ Access-Control-Allow-Methods:
36
+ - OPTIONS,GET
37
+ body:
38
+ encoding: ASCII-8BIT
39
+ string: !binary |-
40
+ eyJwbGFjZV9pZCI6Mjk4ODA4MzUxLCJsaWNlbmNlIjoiRGF0YSDCqSBPcGVuU3RyZWV0TWFwIGNvbnRyaWJ1dG9ycywgT0RiTCAxLjAuIGh0dHBzOi8vb3NtLm9yZy9jb3B5cmlnaHQiLCJvc21fdHlwZSI6InJlbGF0aW9uIiwib3NtX2lkIjo5NTk5NzIzLCJsYXQiOiItMzMuODU2Mzc3NjUiLCJsb24iOiIxNTEuMjE1NTcxODMwNzQ1MDYiLCJkaXNwbGF5X25hbWUiOiJOb3J0aGVybiBCb2FyZHdhbGssIFF1YXkgUXVhcnRlciwgU3lkbmV5LCBDb3VuY2lsIG9mIHRoZSBDaXR5IG9mIFN5ZG5leSwgTmV3IFNvdXRoIFdhbGVzLCAyMDAwLCBBdXN0cmFsaWEiLCJhZGRyZXNzIjp7InJvYWQiOiJOb3J0aGVybiBCb2FyZHdhbGsiLCJuZWlnaGJvdXJob29kIjoiUXVheSBRdWFydGVyIiwic3VidXJiIjoiU3lkbmV5IiwiY2l0eSI6IlN5ZG5leSIsIm11bmljaXBhbGl0eSI6IkNvdW5jaWwgb2YgdGhlIENpdHkgb2YgU3lkbmV5Iiwic3RhdGUiOiJOZXcgU291dGggV2FsZXMiLCJJU08zMTY2LTItbHZsNCI6IkFVLU5TVyIsInBvc3Rjb2RlIjoiMjAwMCIsImNvdW50cnkiOiJBdXN0cmFsaWEiLCJjb3VudHJ5X2NvZGUiOiJhdSJ9LCJib3VuZGluZ2JveCI6WyItMzMuODU2Njc0MiIsIi0zMy44NTYxMDk2IiwiMTUxLjIxNDU1NzkiLCIxNTEuMjE1OTA4NCJdfQ==
41
+ recorded_at: Fri, 21 Apr 2023 12:29:51 GMT
42
+ recorded_with: VCR 6.1.0
@@ -0,0 +1,63 @@
1
+ require 'forwardable'
2
+
3
+ module Maid
4
+ # Provides an abstraction over the ::Logger class to streamline logger
5
+ # instantiation, defaults, and interface.
6
+ class Logger
7
+ extend Forwardable
8
+
9
+ # !@method debug
10
+ # @see https://docs.ruby-lang.org/en/master/Logger.html
11
+ # !@method info
12
+ # @see https://docs.ruby-lang.org/en/master/Logger.html
13
+ # !@method warn
14
+ # @see https://docs.ruby-lang.org/en/master/Logger.html
15
+ # !@method error
16
+ # @see https://docs.ruby-lang.org/en/master/Logger.html
17
+ # !@method fatal
18
+ # @see https://docs.ruby-lang.org/en/master/Logger.html
19
+ # !@method unknown
20
+ # @see https://docs.ruby-lang.org/en/master/Logger.html
21
+ def_delegators :@logger, :debug, :info, :warn, :error, :fatal, :unknown
22
+
23
+ # Creates a new logger
24
+ # @param device [String, IO] the device to log to
25
+ # @param logger [::Logger] the logger to use
26
+ # @param level [Integer] the log level
27
+ # @return [::Logger] the new logger
28
+ # @see https://docs.ruby-lang.org/en/master/Logger.html#class-Logger-label-Entries
29
+ # @example Create a new logger and log an info message
30
+ # # with the Maid namespace
31
+ # logger = Logger.new(device: '/tmp/my.log')
32
+ # logger.info('hello!')
33
+ # # or
34
+ # logger.info { 'hello!' } # Preferred, see Ruby's Logger docs for details.
35
+ # @example Log a debug message with the full module's name
36
+ # module Maid
37
+ # class MyClass
38
+ # # ...
39
+ # def my_method
40
+ # logger.debug(self.class) { 'a message' } # => "Maid::MyClass: a message"
41
+ def initialize(device:, logger: ::Logger, level: ::Logger::INFO)
42
+ create_logfile_dir(device) if device.is_a? String
43
+
44
+ # Keep the 5 last logs, with a max size of 10MiB each.
45
+ logger_options = { shift_age: 5, shift_size: 10 * 1_048_576 }
46
+ @logger = logger.new(device, logger_options[:shift_age],
47
+ logger_options[:shift_size],)
48
+ @logger.progname = 'Maid'
49
+ @logger.level = level
50
+ @logger.debug(self.class) { "Will log to #{device} with level #{level}" }
51
+ end
52
+
53
+ private
54
+
55
+ # @return [::Logger] the ::Logger instance
56
+ attr_reader :logger
57
+
58
+ # @param filepath [String] full path to the log file
59
+ def create_logfile_dir(filepath)
60
+ FileUtils.mkdir_p(File.dirname(filepath))
61
+ end
62
+ end
63
+ end