maid 0.10.0.pre.alpha.1 → 0.10.0.pre.alpha.2

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.
data/lib/maid/app.rb CHANGED
@@ -8,18 +8,18 @@ class Maid::App < Thor
8
8
 
9
9
  desc 'introduction', 'Become aquainted with maid'
10
10
  def introduction
11
- say <<EOF
12
- #{Maid::UserAgent.short}
13
- #{'=' * Maid::UserAgent.short.length}
11
+ say <<~EOF
12
+ #{Maid::UserAgent.short}
13
+ #{'=' * Maid::UserAgent.short.length}
14
14
 
15
- #{Maid::SUMMARY}
15
+ #{Maid::SUMMARY}
16
16
 
17
- * Tutorial: https://github.com/benjaminoakes/maid#tutorial
18
- * Community & examples: https://github.com/benjaminoakes/maid/wiki
19
- * Documentation: http://www.rubydoc.info/gems/maid/#{Maid::VERSION}/Maid/Tools
17
+ * Tutorial: https://github.com/benjaminoakes/maid#tutorial
18
+ * Community & examples: https://github.com/benjaminoakes/maid/wiki
19
+ * Documentation: http://www.rubydoc.info/gems/maid/#{Maid::VERSION}/Maid/Tools
20
20
 
21
- For more information, run "maid help".
22
- EOF
21
+ For more information, run "maid help".
22
+ EOF
23
23
  end
24
24
 
25
25
  def self.sample_rules_path
@@ -27,10 +27,10 @@ EOF
27
27
  end
28
28
 
29
29
  desc 'clean', 'Clean based on rules'
30
- method_option :rules, :type => :string, :aliases => %w(-r)
31
- method_option :noop, :type => :boolean, :aliases => %w(-n --dry-run)
32
- method_option :force, :type => :boolean, :aliases => %w(-f)
33
- method_option :silent, :type => :boolean, :aliases => %w(-s)
30
+ method_option :rules, type: :string, aliases: %w[-r]
31
+ method_option :noop, type: :boolean, aliases: %w[-n --dry-run]
32
+ method_option :force, type: :boolean, aliases: %w[-f]
33
+ method_option :silent, type: :boolean, aliases: %w[-s]
34
34
  def clean
35
35
  maid = Maid::Maid.new(maid_options(options))
36
36
 
@@ -43,16 +43,14 @@ EOF
43
43
  return
44
44
  end
45
45
 
46
- unless options.silent? || options.noop?
47
- say "Logging actions to #{ maid.log_device.inspect }"
48
- end
46
+ say "Logging actions to #{maid.log_device.inspect}" unless options.silent? || options.noop?
49
47
 
50
48
  maid.load_rules
51
49
  maid.clean
52
50
  end
53
51
 
54
52
  desc 'version', 'Print version information (optionally: system info)'
55
- method_option :long, :type => :boolean, :aliases => %w(-l)
53
+ method_option :long, type: :boolean, aliases: %w[-l]
56
54
  def version
57
55
  if options.long?
58
56
  say Maid::UserAgent.value
@@ -64,53 +62,49 @@ EOF
64
62
  # Since this happens a lot by mistake
65
63
  map '--version' => :version
66
64
 
67
- desc 'sample', "Create sample rules at #{ self.sample_rules_path }"
65
+ desc 'sample', "Create sample rules at #{sample_rules_path}"
68
66
  def sample
69
67
  path = self.class.sample_rules_path
70
68
 
71
69
  FileUtils.mkdir_p(File.dirname(path))
72
70
  File.open(path, 'w').puts(File.read(File.join(File.dirname(__FILE__), 'rules.sample.rb')))
73
71
 
74
- say "Sample rules created at #{ path.inspect }", :green
72
+ say "Sample rules created at #{path.inspect}", :green
75
73
  end
76
-
74
+
77
75
  desc 'daemon', 'Runs the watch/repeat rules in a daemon'
78
- method_option :rules, :type => :string, :aliases => %w(-r)
79
- method_option :silent, :type => :boolean, :aliases => %w(-s)
76
+ method_option :rules, type: :string, aliases: %w[-r]
77
+ method_option :silent, type: :boolean, aliases: %w[-s]
80
78
  def daemon
81
79
  maid = Maid::Maid.new(maid_options(options))
82
-
80
+
83
81
  if Maid::TrashMigration.needed?
84
82
  migrate_trash
85
83
  return
86
84
  end
87
85
 
88
- unless options.silent?
89
- say "Logging actions to #{ maid.log_device.inspect }"
90
- end
91
-
86
+ say "Logging actions to #{maid.log_device.inspect}" unless options.silent?
87
+
92
88
  maid.load_rules
93
89
  maid.daemonize
94
90
  end
95
91
 
96
92
  desc 'logs', 'Manages logs written by maid'
97
- method_option :path, :type => :boolean, :aliases => %w(-p)
98
- method_option :tail, :type => :boolean, :aliases => %w(-t)
93
+ method_option :path, type: :boolean, aliases: %w[-p]
94
+ method_option :tail, type: :boolean, aliases: %w[-t]
99
95
  def logs
100
96
  maid = Maid::Maid.new(maid_options(options))
101
97
 
102
98
  if options.path?
103
99
  say maid.log_device
104
- else
105
- unless File.readable?(maid.log_device)
106
- error "Log file #{maid.log_device} does not exist."
100
+ elsif File.readable?(maid.log_device)
101
+ if options.tail?
102
+ system("tail -f #{maid.log_device}")
107
103
  else
108
- if options.tail?
109
- system("tail -f #{maid.log_device}")
110
- else
111
- say `tail #{maid.log_device}`
112
- end
104
+ say `tail #{maid.log_device}`
113
105
  end
106
+ else
107
+ error "Log file #{maid.log_device} does not exist."
114
108
  end
115
109
  end
116
110
 
@@ -120,18 +114,16 @@ EOF
120
114
 
121
115
  if options['noop']
122
116
  # You're testing, so a simple log goes to STDOUT and no actions are taken
123
- h[:file_options] = { :noop => true }
117
+ h[:file_options] = { noop: true }
124
118
 
125
119
  unless options['silent']
126
120
  h[:logger] = false
127
121
  h[:log_device] = STDOUT
128
- h[:log_formatter] = lambda { |_, _, _, msg| "#{ msg }\n" }
122
+ h[:log_formatter] = ->(_, _, _, msg) { "#{msg}\n" }
129
123
  end
130
124
  end
131
125
 
132
- if options['rules']
133
- h[:rules_path] = options['rules']
134
- end
126
+ h[:rules_path] = options['rules'] if options['rules']
135
127
 
136
128
  h
137
129
  end
@@ -144,15 +136,20 @@ EOF
144
136
  migration = Maid::TrashMigration
145
137
  banner('Trash Migration', :yellow)
146
138
 
147
- say <<-EOF
139
+ say <<~EOF
148
140
 
149
- You are using Linux and have a "~/.Trash" directory. If you used Maid 0.1.2 or earlier, that directory may exist because Maid incorrectly moved trash files there.
141
+ You are using Linux and have a "~/.Trash" directory. If you used Maid 0.1.2 or earlier, that directory may exist because Maid incorrectly moved trash files there.
150
142
 
151
- But no worries. Maid can migrate those files to the correct place.
143
+ But no worries. Maid can migrate those files to the correct place.
152
144
 
153
145
  EOF
154
146
 
155
- response = ask("Would you like Maid to move the files in #{ migration.incorrect_trash.inspect } to #{ migration.correct_trash.inspect }?", :limited_to => %w(Y N))
147
+ response = ask(
148
+ "Would you like Maid to move the files in #{migration.incorrect_trash.inspect} " \
149
+ "to #{migration.correct_trash.inspect}?", limited_to: %w[
150
+ Y N
151
+ ],
152
+ )
156
153
 
157
154
  case response
158
155
  when 'Y'
@@ -163,16 +160,16 @@ But no worries. Maid can migrate those files to the correct place.
163
160
 
164
161
  say('Migrated. See the Maid log for details.')
165
162
  when 'N'
166
- say <<-EOF
163
+ say <<~EOF
167
164
 
168
- Running Maid again will continue to give this warning until #{ migration.incorrect_trash.inspect } no longer exists, or the environment variable MAID_NO_MIGRATE_TRASH has a value.
165
+ Running Maid again will continue to give this warning until #{migration.incorrect_trash.inspect} no longer exists, or the environment variable MAID_NO_MIGRATE_TRASH has a value.
169
166
 
170
- Exiting...
167
+ Exiting...
171
168
  EOF
172
169
 
173
- exit -1
170
+ exit(-1)
174
171
  else
175
- raise "Reached 'impossible' case (response: #{ response.inspect })"
172
+ raise "Reached 'impossible' case (response: #{response.inspect})"
176
173
  end
177
174
  end
178
175
 
data/lib/maid/maid.rb CHANGED
@@ -9,18 +9,20 @@ require 'xdg'
9
9
  class Maid::Maid
10
10
  include Maid::RuleContainer
11
11
  DEFAULTS = {
12
- :progname => 'Maid',
12
+ progname: 'Maid',
13
13
 
14
- :log_device => File.expand_path('~/.maid/maid.log'),
15
- # We don't want the log files to grow without check, but 50 MB doesn't seem too bad. (We're going with a larger size just for safety right now.)
16
- :log_shift_age => 5,
17
- :log_shift_size => 10 * 1_048_576, # 10 * 1 MB
14
+ log_device: File.expand_path('~/.maid/maid.log'),
15
+ # We don't want the log files to grow without check, but 50 MB doesn't seem
16
+ # too bad. (We're going with a larger size just for safety right now.)
17
+ log_shift_age: 5,
18
+ log_shift_size: 10 * 1_048_576, # 10 * 1 MB
18
19
 
19
- :rules_path => File.expand_path('~/.maid/rules.rb'),
20
- :file_options => { :noop => false }, # for `FileUtils`
20
+ rules_path: File.expand_path('~/.maid/rules.rb'),
21
+ file_options: { noop: false }, # for `FileUtils`
21
22
  }.freeze
22
23
 
23
24
  attr_reader :file_options, :logger, :log_device, :rules_path, :trash_path, :watches, :repeats
25
+
24
26
  include ::Maid::Tools
25
27
 
26
28
  # Make a new Maid, setting up paths for the log and trash.
@@ -30,16 +32,16 @@ class Maid::Maid
30
32
  # Maid::Maid.new(:log_device => '/home/username/log/maid.log', :trash_path => '/home/username/my_trash')
31
33
  #
32
34
  def initialize(options = {})
33
- options = DEFAULTS.merge(options.reject { |k, v| v.nil? })
35
+ options = DEFAULTS.merge(options.reject { |_k, v| v.nil? })
34
36
 
35
37
  # TODO: Refactor and simplify (see also https://github.com/benjaminoakes/maid/pull/48#discussion_r1683942)
36
- @logger = unless options[:logger]
37
- @log_device = options[:log_device]
38
- FileUtils.mkdir_p(File.dirname(@log_device)) unless @log_device.kind_of?(IO)
39
- @logger = Logger.new(@log_device, options[:log_shift_age], options[:log_shift_size])
40
- else
41
- options[:logger]
42
- end
38
+ @logger = if options[:logger]
39
+ options[:logger]
40
+ else
41
+ @log_device = options[:log_device]
42
+ FileUtils.mkdir_p(File.dirname(@log_device)) unless @log_device.is_a?(IO)
43
+ @logger = Logger.new(@log_device, options[:log_shift_age], options[:log_shift_size])
44
+ end
43
45
 
44
46
  @logger.progname = options[:progname]
45
47
  @logger.formatter = options[:log_formatter] if options[:log_formatter]
@@ -59,16 +61,16 @@ class Maid::Maid
59
61
 
60
62
  # Start cleaning, based on the rules defined at rules_path.
61
63
  def clean
62
- unless @log_device.kind_of?(IO)
63
- @logger.info "v#{ Maid::VERSION }"
64
+ unless @log_device.is_a?(IO)
65
+ @logger.info "v#{Maid::VERSION}"
64
66
  @logger.info 'Started'
65
67
  end
66
68
 
67
69
  follow_rules
68
70
 
69
- unless @log_device.kind_of?(IO)
70
- @logger.info 'Finished'
71
- end
71
+ return if @log_device.is_a?(IO)
72
+
73
+ @logger.info 'Finished'
72
74
  end
73
75
 
74
76
  # Add the rules at rules_path.
@@ -82,26 +84,26 @@ class Maid::Maid
82
84
  Kernel.load(path)
83
85
  end
84
86
  rescue LoadError => e
85
- STDERR.puts e.message
87
+ warn e.message
86
88
  end
87
89
 
88
- def watch(path, options = {}, &rules)
89
- @watches << ::Maid::Watch.new(self, path, options, &rules)
90
+ def watch(path, options = {}, &block)
91
+ @watches << ::Maid::Watch.new(self, path, options, &block)
90
92
  end
91
93
 
92
- def repeat(timestring, options = {}, &rules)
93
- @repeats << ::Maid::Repeat.new(self, timestring, options, &rules)
94
+ def repeat(timestring, options = {}, &block)
95
+ @repeats << ::Maid::Repeat.new(self, timestring, options, &block)
94
96
  end
95
97
 
96
98
  # Daemonizes the process by starting all watches and repeats and joining
97
99
  # the threads of the schedulers/watchers
98
100
  def daemonize
99
101
  if @watches.empty? && @repeats.empty?
100
- STDERR.puts 'Cannot run daemon. Nothing to watch or repeat.'
102
+ warn 'Cannot run daemon. Nothing to watch or repeat.'
101
103
  else
102
104
  all = @watches + @repeats
103
105
  all.each(&:run)
104
- trap("SIGINT") do
106
+ trap('SIGINT') do
105
107
  # Running in a thread fixes celluloid ThreadError
106
108
  Thread.new do
107
109
  all.each(&:stop)
@@ -115,18 +117,16 @@ class Maid::Maid
115
117
  # Run a shell command.
116
118
  #--
117
119
  # Delegates to `Kernel.\``. Made primarily for testing other commands and some error handling.
118
- def cmd(command) #:nodoc:
119
- if supported_command?(command)
120
- %x(#{ command })
121
- else
122
- raise NotImplementedError, "Unsupported system command: #{ command.inspect }"
123
- end
120
+ def cmd(command) # :nodoc:
121
+ raise NotImplementedError, "Unsupported system command: #{command.inspect}" unless supported_command?(command)
122
+
123
+ `#{command}`
124
124
  end
125
125
 
126
126
  private
127
127
 
128
128
  # Does the OS support this command?
129
- def supported_command?(command) #:nodoc:
129
+ def supported_command?(command) # :nodoc:
130
130
  @@supported_commands ||= {}
131
131
 
132
132
  command_name = command.strip.split(/\s+/)[0]
@@ -134,20 +134,20 @@ class Maid::Maid
134
134
  # TODO: Instead of using `which`, use an alternative listed at:
135
135
  #
136
136
  # http://stackoverflow.com/questions/592620/check-if-a-program-exists-from-a-bash-script
137
- @@supported_commands[command_name] = supported ? supported : !%x(which #{ command_name }).empty?
137
+ @@supported_commands[command_name] = supported || !`which #{command_name}`.empty?
138
138
  end
139
139
 
140
140
  def default_trash_path
141
141
  # TODO: Refactor module declaration so this can be `Platform`
142
142
  if Maid::Platform.linux?
143
143
  # See the [FreeDesktop.org Trash specification](http://www.ramendik.ru/docs/trashspec.html)
144
- path = "#{ XDG['DATA_HOME'] }/Trash/files"
144
+ path = "#{XDG['DATA_HOME']}/Trash/files"
145
145
  elsif Maid::Platform.osx?
146
146
  path = File.expand_path('~/.Trash')
147
147
  else
148
- raise NotImplementedError, "Unknown default trash path (unsupported host OS: #{ Maid::Platform.host_os.inspect })"
148
+ raise NotImplementedError, "Unknown default trash path (unsupported host OS: #{Maid::Platform.host_os.inspect})"
149
149
  end
150
150
 
151
- "#{ path }/"
151
+ "#{path}/"
152
152
  end
153
153
  end
@@ -33,32 +33,32 @@ module Maid::NumericExtensions
33
33
  def seconds
34
34
  self
35
35
  end
36
- alias :second :seconds
36
+ alias second seconds
37
37
 
38
38
  def minutes
39
39
  self * 60
40
40
  end
41
- alias :minute :minutes
41
+ alias minute minutes
42
42
 
43
43
  def hours
44
44
  self * 3600
45
45
  end
46
- alias :hour :hours
46
+ alias hour hours
47
47
 
48
48
  def days
49
49
  self * 24.hours
50
50
  end
51
- alias :day :days
51
+ alias day days
52
52
 
53
53
  def weeks
54
54
  self * 7.days
55
55
  end
56
- alias :week :weeks
56
+ alias week weeks
57
57
 
58
58
  def fortnights
59
59
  self * 2.weeks
60
60
  end
61
- alias :fortnight :fortnights
61
+ alias fortnight fortnights
62
62
 
63
63
  # Reads best without arguments: 10.minutes.ago
64
64
  def ago(time = ::Time.now)
@@ -66,7 +66,7 @@ module Maid::NumericExtensions
66
66
  end
67
67
 
68
68
  # Reads best with argument: 10.minutes.until(time)
69
- alias :until :ago
69
+ alias until ago
70
70
 
71
71
  # Reads best with argument: 10.minutes.since(time)
72
72
  def since(time = ::Time.now)
@@ -74,21 +74,22 @@ module Maid::NumericExtensions
74
74
  end
75
75
 
76
76
  # Reads best without arguments: 10.minutes.from_now
77
- alias :from_now :since
77
+ alias from_now since
78
78
 
79
79
  ######################
80
80
  ### Maid additions ###
81
81
  ######################
82
82
 
83
- # TODO find a better place for these to live?
83
+ # TODO: find a better place for these to live?
84
84
 
85
85
  # Reads well in a case like:
86
86
  #
87
87
  # 1.week.since? accessed_at('filename')
88
88
  def since?(other_time)
89
- other_time < self.ago
89
+ other_time < ago
90
90
  end
91
91
  end
92
+
92
93
  module SizeToKb
93
94
  # Enables Computer disk size conversion into kilobytes.
94
95
  #
@@ -100,29 +101,29 @@ module Maid::NumericExtensions
100
101
  def kb
101
102
  self
102
103
  end
103
- alias :kilobytes :kb
104
- alias :kilobyte :kb
105
- alias :kB :kb
104
+ alias kilobytes kb
105
+ alias kilobyte kb
106
+ alias kB kb
106
107
 
107
108
  def mb
108
- self * 1024 ** 1
109
+ self * (1024**1)
109
110
  end
110
- alias :megabytes :mb
111
- alias :megabyte :mb
112
- alias :mB :mb
111
+ alias megabytes mb
112
+ alias megabyte mb
113
+ alias mB mb
113
114
 
114
115
  def gb
115
- self * 1024 ** 2
116
+ self * (1024**2)
116
117
  end
117
- alias :gigabytes :gb
118
- alias :gigabyte :gb
119
- alias :gB :gb
118
+ alias gigabytes gb
119
+ alias gigabyte gb
120
+ alias gB gb
120
121
 
121
122
  def tb
122
- self * 1024 ** 3
123
+ self * (1024**3)
123
124
  end
124
- alias :terabytes :tb
125
- alias :terabyte :tb
126
- alias :tB :tb
125
+ alias terabytes tb
126
+ alias terabyte tb
127
+ alias tB tb
127
128
  end
128
129
  end
data/lib/maid/platform.rb CHANGED
@@ -15,7 +15,7 @@ module Maid::Platform
15
15
  end
16
16
 
17
17
  def has_tag_available?
18
- osx? && system("which -s tag")
18
+ osx? && system('which -s tag')
19
19
  end
20
20
  end
21
21
 
@@ -29,7 +29,7 @@ module Maid
29
29
 
30
30
  def define
31
31
  desc task_description
32
- task *args do |task|
32
+ task(*args) do |task|
33
33
  SingleRule.perform(task.name, task_proc)
34
34
  end
35
35
  end
data/lib/maid/repeat.rb CHANGED
@@ -1,24 +1,24 @@
1
1
  require 'rufus-scheduler'
2
2
  class Maid::Repeat
3
3
  include Maid::RuleContainer
4
-
4
+
5
5
  attr_reader :timestring, :scheduler, :logger
6
-
7
- def initialize(maid, timestring, options = {}, &rules)
6
+
7
+ def initialize(maid, timestring, options = {}, &block)
8
8
  @maid = maid
9
9
  @logger = maid.logger # TODO: Maybe it's better to create seperate loggers?
10
10
  @scheduler = Rufus::Scheduler.singleton
11
11
  @timestring = timestring
12
12
  @options = options
13
- initialize_rules(&rules)
13
+ initialize_rules(&block)
14
14
  end
15
15
 
16
16
  def run
17
- unless rules.empty?
18
- @scheduler.repeat(timestring, @options) { follow_rules }
19
- end
17
+ return if rules.empty?
18
+
19
+ @scheduler.repeat(timestring, @options) { follow_rules }
20
20
  end
21
-
21
+
22
22
  def stop
23
23
  @scheduler.shutdown(:join) # Join the work threads
24
24
  end
@@ -3,9 +3,9 @@ module Maid::RuleContainer
3
3
  attr_reader :rules
4
4
 
5
5
  # initialize_rules
6
- def initialize_rules(&rules)
6
+ def initialize_rules(&block)
7
7
  @rules ||= []
8
- instance_exec(&rules)
8
+ instance_exec(&block)
9
9
  end
10
10
 
11
11
  # Register a rule with a description and instructions (lambda function).
@@ -16,7 +16,7 @@ module Maid::RuleContainer
16
16
  # Follow all registered rules.
17
17
  def follow_rules(*args)
18
18
  @rules.each do |rule|
19
- @logger.info("Rule: #{ rule.description }") unless @logger.nil?
19
+ @logger.info("Rule: #{rule.description}") unless @logger.nil?
20
20
  rule.follow(*args)
21
21
  end
22
22
  end
@@ -8,12 +8,14 @@
8
8
  # what they do, you might run into unwanted results!
9
9
  #
10
10
  # Don't forget, it's just Ruby! You can define custom methods and use them below:
11
- #
11
+ #
12
12
  # def magic(*)
13
13
  # # ...
14
14
  # end
15
- #
16
- # If you come up with some cool tools of your own, please send me a pull request on GitHub! Also, please consider sharing your rules with others via [the wiki](https://github.com/benjaminoakes/maid/wiki).
15
+ #
16
+ # If you come up with some cool tools of your own, please send me a pull
17
+ # request on GitHub! Also, please consider sharing your rules with others via
18
+ # [the wiki](https://github.com/benjaminoakes/maid/wiki).
17
19
  #
18
20
  # For more help on Maid:
19
21
  #
@@ -39,37 +41,35 @@ Maid.rules do
39
41
  end
40
42
 
41
43
  rule 'Mac OS X applications in zip files' do
42
- found = dir('~/Downloads/*.zip').select { |path|
43
- zipfile_contents(path).any? { |c| c.match(/\.app\/Contents\//) }
44
- }
44
+ found = dir('~/Downloads/*.zip').select do |path|
45
+ zipfile_contents(path).any? { |c| c.match(%r{\.app/Contents/}) }
46
+ end
45
47
 
46
48
  trash(found)
47
49
  end
48
50
 
49
51
  rule 'Misc Screenshots' do
50
52
  dir('~/Desktop/Screen shot *').each do |path|
51
- if 1.week.since?(accessed_at(path))
52
- move(path, '~/Documents/Misc Screenshots/')
53
- end
53
+ move(path, '~/Documents/Misc Screenshots/') if 1.week.since?(accessed_at(path))
54
54
  end
55
55
  end
56
56
 
57
57
  # NOTE: Currently, only Mac OS X supports `duration_s`.
58
58
  rule 'MP3s likely to be music' do
59
59
  dir('~/Downloads/*.mp3').each do |path|
60
- if duration_s(path) > 30.0
61
- move(path, '~/Music/iTunes/iTunes Media/Automatically Add to iTunes/')
62
- end
60
+ move(path, '~/Music/iTunes/iTunes Media/Automatically Add to iTunes/') if duration_s(path) > 30.0
63
61
  end
64
62
  end
65
-
63
+
66
64
  # NOTE: Currently, only Mac OS X supports `downloaded_from`.
67
65
  rule 'Old files downloaded while developing/testing' do
68
66
  dir('~/Downloads/*').each do |path|
69
- if downloaded_from(path).any? { |u| u.match('http://localhost') || u.match('http://staging\.yourcompany\.com') } &&
70
- 1.week.since?(accessed_at(path))
71
- trash(path)
72
- end
67
+ next unless downloaded_from(path).any? do |u|
68
+ u.match('http://localhost') || u.match('http://staging\.yourcompany\.com')
69
+ end &&
70
+ 1.week.since?(accessed_at(path))
71
+
72
+ trash(path)
73
73
  end
74
74
  end
75
75
  end