Class: DiffbotSimple::V2::Crawlbot
- Inherits:
-
Object
- Object
- DiffbotSimple::V2::Crawlbot
- Includes:
- ApiHelper
- Defined in:
- lib/diffbot_simple/v2/crawlbot.rb
Overview
Complies to www.diffbot.com/dev/docs/crawl/
Instance Method Summary collapse
-
#all ⇒ Array
Get all your crawls as an array The “jobs” parameter is stripped and only the array is returned.
-
#delete(name: nil) ⇒ Hash
Deletes a crawl.
-
#pause(name: nil) ⇒ Hash
Pauses a crawl.
- #post_initialize ⇒ Object
-
#restart(name: nil) ⇒ Hash
Restarts a crawl.
-
#result(name: nil) ⇒ Array
Get the crawl-result (downloadJson from diffbot crawl).
-
#single_crawl(name: nil, **options) ⇒ Hash
Gets, creates or updates a named crawl.
-
#unpause(name: nil) ⇒ Hash
Unpauses/ resumes a crawl.
Methods included from ApiHelper
#initialize, #to_crawl_api_url
Instance Method Details
#all ⇒ Array
Get all your crawls as an array The “jobs” parameter is stripped and only the array is returned
12 13 14 |
# File 'lib/diffbot_simple/v2/crawlbot.rb', line 12 def all execute_call()[:jobs] end |
#delete(name: nil) ⇒ Hash
Deletes a crawl
32 33 34 35 |
# File 'lib/diffbot_simple/v2/crawlbot.rb', line 32 def delete name: nil raise ArgumentError.new "Must pass a name for the crawl to delete" unless name execute_call name: name, delete: 1 end |
#pause(name: nil) ⇒ Hash
Pauses a crawl
41 42 43 |
# File 'lib/diffbot_simple/v2/crawlbot.rb', line 41 def pause name: nil single_crawl name: name, pause: 1 end |
#post_initialize ⇒ Object
5 6 7 |
# File 'lib/diffbot_simple/v2/crawlbot.rb', line 5 def post_initialize @api = :crawl end |
#restart(name: nil) ⇒ Hash
Restarts a crawl
57 58 59 60 |
# File 'lib/diffbot_simple/v2/crawlbot.rb', line 57 def restart name: nil raise ArgumentError.new "Must pass a name for the crawl to restart" unless name execute_call name: name, restart: 1 end |
#result(name: nil) ⇒ Array
Get the crawl-result (downloadJson from diffbot crawl)
66 67 68 69 70 71 |
# File 'lib/diffbot_simple/v2/crawlbot.rb', line 66 def result name: nil crawl = single_crawl name: name download_url = crawl[:downloadJson] response = api_client.get download_url symbolize response end |
#single_crawl(name: nil, **options) ⇒ Hash
Gets, creates or updates a named crawl
@**options options from www.diffbot.com/dev/docs/crawl/ when updating or creating a crawl
21 22 23 24 25 26 |
# File 'lib/diffbot_simple/v2/crawlbot.rb', line 21 def single_crawl name: nil, ** raise ArgumentError.new "Must pass a name for the crawl" unless name response = execute_call .merge(name: name) jobs = response[:jobs] jobs.first end |
#unpause(name: nil) ⇒ Hash
Unpauses/ resumes a crawl
49 50 51 |
# File 'lib/diffbot_simple/v2/crawlbot.rb', line 49 def unpause name: nil single_crawl name: name, pause: 0 end |