Class: Maid::App
- Inherits:
-
Thor
- Object
- Thor
- Maid::App
- Defined in:
- lib/maid/app.rb
Class Method Summary collapse
Instance Method Summary collapse
- #clean ⇒ Object
- #daemon ⇒ Object
- #introduction ⇒ Object
- #logs ⇒ Object
- #sample ⇒ Object
- #version ⇒ Object
Class Method Details
.sample_rules_path ⇒ Object
25 26 27 |
# File 'lib/maid/app.rb', line 25 def self.sample_rules_path File.join(File.dirname(Maid::Maid::DEFAULTS[:rules_path]), 'rules.sample.rb') end |
Instance Method Details
#clean ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/maid/app.rb', line 34 def clean maid = Maid::Maid.new(()) unless .noop? || .force? warn 'Running "maid clean" without a flag is deprecated. Please use "maid clean --noop" or "maid clean --force".' end if Maid::TrashMigration.needed? migrate_trash return end say "Logging actions to #{maid.log_device.inspect}" unless .silent? || .noop? maid.load_rules maid.clean end |
#daemon ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/maid/app.rb', line 78 def daemon maid = Maid::Maid.new(()) if Maid::TrashMigration.needed? migrate_trash return end say "Logging actions to #{maid.log_device.inspect}" unless .silent? maid.load_rules maid.daemonize end |
#introduction ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/maid/app.rb', line 10 def introduction say <<~EOF #{Maid::UserAgent.short} #{'=' * Maid::UserAgent.short.length} #{Maid::SUMMARY} * Tutorial: https://github.com/benjaminoakes/maid#tutorial * Community & examples: https://github.com/benjaminoakes/maid/wiki * Documentation: http://www.rubydoc.info/gems/maid/#{Maid::VERSION}/Maid/Tools For more information, run "maid help". EOF end |
#logs ⇒ Object
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/maid/app.rb', line 95 def logs maid = Maid::Maid.new(()) if .path? say maid.log_device elsif File.readable?(maid.log_device) if .tail? system("tail -f #{maid.log_device}") else say `tail #{maid.log_device}` end else error "Log file #{maid.log_device} does not exist." end end |
#sample ⇒ Object
66 67 68 69 70 71 72 73 |
# File 'lib/maid/app.rb', line 66 def sample path = self.class.sample_rules_path FileUtils.mkdir_p(File.dirname(path)) File.open(path, 'w').puts(File.read(File.join(File.dirname(__FILE__), 'rules.sample.rb'))) say "Sample rules created at #{path.inspect}", :green end |
#version ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/maid/app.rb', line 54 def version if .long? say Maid::UserAgent.value else say Maid::VERSION end end |