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 43 44 45 46 47 48 49 50 51 52 53 |
# 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>' 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 scraper.run emitter.newline emitter.newline emitter.say "Processed" emitter.pretty scraper.processed emitter.newline emitter.say "Could not be processed" emitter.pretty scraper.invalid emitter.newline emitter.say "Run 'elsmore serve #{args.first}' to start a webserver on port 8000 with your local copy" end end alias_command :'go fetch', :'snap' default_command :snap command :serve do |c| c.syntax = 'serve <folder_name>' c.description = 'Serve local folder' c.action do |args, | exec "ruby -run -ehttpd ./#{ARGV[1]} -p8000" end end run! end |