dor-fetcher 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +8 -8
  2. data/lib/dor-fetcher.rb +15 -2
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZWE0YWU4MjJhYzdmOWQ1ODhhYWVmOGRhYzIxMjQ4MTE2MjYzODJkYg==
4
+ MzQwNDg5YWQyMWEzODU2ZTE2NzlkOTAxMGM2NmJkZjg3ZGQ1YmY0Zg==
5
5
  data.tar.gz: !binary |-
6
- Njc5Y2Y4OWFkYzJhOTAxOWQ1ZDJiNmM2ZmE4NmVkNzI3N2JjOGIwZg==
6
+ MTNjYWQzZmY2NTQyMzUxZjM0ZjMxMTY5NmYyZjFiODcwNzBhZjdiOA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZjFlN2ZmMGVjOGRjYWE0ZTNlZjAwYWMxYmQ3YTY5ZTQ5YmE1ZjNmM2RmNDEw
10
- Yjc4NGQwNjhhMDNhNjllMWEzNjM2MTNmZjZmMDQzZmQ2MTBkNTQ5ZDBlMWZl
11
- MjgwNWVmZDhlOGFmNjk4NGVlZTMxMDVhZjdlZmE1YThiMjliZjc=
9
+ NjNhYjg3YzlmNmU5MzM2ZjRjOWYxYTIyYzUzMmU4N2VkNTZjNTNlYjk1YzA2
10
+ OWY1N2RlMmM0NThlYjNlNzVjMjUyY2JhZDBjMmUzZjlkOTZkYzkyZGUzMDI4
11
+ MTY1ODUyOGQxNDY4YjEzODdlMTAyYTE2ZWQ4MDhjOWM5ZDY1OWM=
12
12
  data.tar.gz: !binary |-
13
- ZjZlM2E3YzJiMzliOGQ0YjMwNWJhNjE1OGQxNTlkZWVlMzQ1YWE5NWYwNDZi
14
- NDgzNTQ1OTJkZjk4ZjYwZTVhZGQ4MmVmMmQ3Y2FmNmFiMjY5MzIxNTNiYzA2
15
- OTc2ODRhZDgyYzVhYjE2MGM2Zjg5YmJkMjI4ZTVmNDRiMGFiN2Q=
13
+ Nzg3ZmI3MTJkMjJhZmM0YWI1NDgzM2FmOGVlYjlmYjJjNzA0ZGE0ZjRkNGQy
14
+ ZTIzMGI0YjFiN2NlOTFiMDFhNWIzMDE4YThlMjlhODRjM2YwNmFiOTgyNGE1
15
+ Nzg4NDZmNTM2Y2NkYTU4ZDljZWZjZTgyZjRlMWE1NDVhY2FlNzQ=
data/lib/dor-fetcher.rb CHANGED
@@ -10,13 +10,26 @@ module DorFetcher
10
10
  @@default_service_url = 'http://127.0.0.1:3000'
11
11
 
12
12
  #Create a new instance of DorFetcher::Client
13
- #@param options [Hash] Currently supports only :service_url, the base
14
- #url for API queries. Defaults to http://127.0.0.1:3000
13
+ #@param options [Hash] Currently supports :service_url and :skip_heartbeat.
14
+ #:service_url is the base url for API queries. Defaults to http://127.0.0.1:3000
15
+ #:skip_heartbeat will tell the init to skip querying the :service_url and seeing if the API is responsive
15
16
  #@example
16
17
  # df = DorFetcher::Client.new({:service_url='http://SERVICEURL'})
17
18
  def initialize options = {}
18
19
  #TODO: Check for a well formed URL and a 200 from the destination before just accepting this
19
20
  @service_url = options[:service_url] || @@default_service_url
21
+
22
+ if not options[:skip_heartbeat]
23
+ raise "DorFetcher::Client Error! No response from #{@service_url}" if not self.is_alive
24
+ end
25
+ end
26
+
27
+ #Check to see if the dor-fetcher-service is responding to requests, this is a basic heart beat checker
28
+ #@return [Boolean] True for a service that responds, False for a service that does not.
29
+ def is_alive
30
+ resp = Net::HTTP.get_response(URI.parse(@service_url))
31
+ #Since dor-fetcher-service uses the is_alive gem, the main page should simply have okay on it
32
+ return "ok".eql?(resp.body)
20
33
  end
21
34
 
22
35
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dor-fetcher
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carrick Rogers
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-11-03 00:00:00.000000000 Z
13
+ date: 2014-11-06 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rspec