Class: Maid::App
- Inherits:
-
Thor
- Object
- Thor
- Maid::App
- Defined in:
- lib/maid/app.rb
Overview
rubocop:disable Metrics/ClassLength
Class Method Summary collapse
Instance Method Summary collapse
- #clean ⇒ Object
- #daemon ⇒ Object
- #introduction ⇒ Object
- #logs ⇒ Object
- #sample ⇒ Object
- #version ⇒ Object
Class Method Details
.exit_on_failure? ⇒ Boolean
9 10 11 |
# File 'lib/maid/app.rb', line 9 def self.exit_on_failure? true end |
.sample_rules_path ⇒ Object
29 30 31 |
# File 'lib/maid/app.rb', line 29 def self.sample_rules_path File.join(File.dirname(Maid::Maid::DEFAULTS[:rules_path]), 'rules.sample.rb') end |
Instance Method Details
#clean ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/maid/app.rb', line 38 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
82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/maid/app.rb', line 82 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
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/maid/app.rb', line 14 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
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/maid/app.rb', line 99 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
70 71 72 73 74 75 76 77 |
# File 'lib/maid/app.rb', line 70 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
58 59 60 61 62 63 64 |
# File 'lib/maid/app.rb', line 58 def version if .long? say Maid::UserAgent.value else say Maid::VERSION end end |