Class: Elsmore::Command
- Inherits:
-
Object
- Object
- Elsmore::Command
- Includes:
- Commander::Methods
- Defined in:
- lib/elsmore/command.rb
Instance Attribute Summary collapse
-
#emitter ⇒ Object
Returns the value of attribute emitter.
Instance Method Summary collapse
-
#initialize ⇒ Command
constructor
A new instance of Command.
- #run ⇒ Object
Constructor Details
Instance Attribute Details
#emitter ⇒ Object
Returns the value of attribute emitter.
7 8 9 |
# File 'lib/elsmore/command.rb', line 7 def emitter @emitter end |
Instance Method Details
#run ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/elsmore/command.rb', line 13 def run program :name, 'elsmore' program :version, Elsmore::VERSION program :description, 'A convenient scraper for archiving sites' program :help, 'Author', 'Cristiano Betta <[email protected]>' global_option('--debug') { emitter.debug! } command :snap do |c| c.syntax = 'spider <url> [options]' c.description = 'Spiders a URL within from the given page, sticking within the original domain' c.action do |args, | scraper = Elsmore::Scraper.new(args.first) scraper.emitter = emitter result = scraper.run emitter.newline emitter.newline emitter.say "Processed" emitter.pretty result[:processed] emitter.newline emitter.say "Could not be processed" emitter.pretty result[:invalid] end end alias_command :'go fetch', :'snap' default_command :snap run! end |