Class: Archaeo::Cli
- Inherits:
-
Thor
- Object
- Thor
- Archaeo::Cli
- Defined in:
- lib/archaeo/cli.rb
Overview
Command-line interface powered by Thor.
Constant Summary collapse
- CDX_OPTION_MAP =
{ from: :from, to: :to, match_type: :match_type, filter: :filters, collapse: :collapse, sort: :sort, limit: :limit, }.freeze
Instance Method Summary collapse
- #available(url) ⇒ Object
- #fetch(url, timestamp) ⇒ Object
- #near(url, timestamp) ⇒ Object
- #newest(url) ⇒ Object
- #oldest(url) ⇒ Object
- #save(url) ⇒ Object
- #snapshots(url) ⇒ Object
Instance Method Details
#available(url) ⇒ Object
46 47 48 49 50 51 52 53 54 |
# File 'lib/archaeo/cli.rb', line 46 def available(url) result = AvailabilityApi.new.near(url) if result.available? puts "Available: #{result.archive_url}" else puts "Not available" exit 1 end end |
#fetch(url, timestamp) ⇒ Object
67 68 69 70 71 72 73 |
# File 'lib/archaeo/cli.rb', line 67 def fetch(url, ) page = Fetcher.new.fetch( url, timestamp: , identity: [:identity] ) $stdout.write(page.content) end |
#near(url, timestamp) ⇒ Object
28 29 30 31 |
# File 'lib/archaeo/cli.rb', line 28 def near(url, ) snap = CdxApi.new.near(url, timestamp: ) puts snap.archive_url end |
#newest(url) ⇒ Object
40 41 42 43 |
# File 'lib/archaeo/cli.rb', line 40 def newest(url) snap = CdxApi.new.newest(url) puts snap.archive_url end |
#oldest(url) ⇒ Object
34 35 36 37 |
# File 'lib/archaeo/cli.rb', line 34 def oldest(url) snap = CdxApi.new.oldest(url) puts snap.archive_url end |