wayback 0.2.1 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ YTE4MGY4YmU2ODhjODEyYTI1YTdjNThjOGNmYjg4MDZhODhkMTBjYQ==
5
+ data.tar.gz: !binary |-
6
+ ZTY2ZWM1ZDllZWFjNDBkOGVlM2Q3YTY5ODYyZGFmZGFmNTY5MjY0Yw==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ MTVkYjk3OTVlZDE0ZDNjY2VmNzJjYjk2MGQ2N2NlZmQ3MmRhZWIzNzY3ZTRm
10
+ OWViNDFmNzVhMWY4YjUxYjJiMzRhN2U0YzIzNmM5YmY4ZDk4YjFiZTg3Mjk4
11
+ OGZlNWQ1YTViN2YyYzBjNTBlMWE3ZGEwMDkyNTg5ZjM2ZjViM2Q=
12
+ data.tar.gz: !binary |-
13
+ YTUzNTNkNTc0MTFkZDQ5NjY5NDlkNThiNmE5NDE0NDBjZDUxZWQ1MTc5NjJl
14
+ NzgyOTU1YmM1NWVjNWFjOWQ0YTMzMzdlMGUzOThhZmUzNWVlMDQ4ZDJjMmVj
15
+ OGVjNjZmMTBiYWRmNzZmMjcwYzUwYTgzNGJhYzZhODMxNWJlODk=
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ 0.3.0
2
+ -----
3
+ * Support for Archive's /availablity check.
4
+
1
5
  0.2.0
2
6
  -----
3
7
  * Archive.org has changed their endpoint URLs to http://web.archive.org/web. Version 0.2.0 corrects this issue with the new ENDPOINT_PATH configuration for handling the /web path.
data/README.md CHANGED
@@ -39,6 +39,8 @@ The current defaults configurations for this gem are:
39
39
  Wayback.configure do |c|
40
40
  c.endpoint = 'http://web.archive.org'
41
41
  c.endpoint_path = '/web'
42
+ c.json_endpoint = 'http://archive.org'
43
+ c.json_endpoint_path = '/wayback'
42
44
  c.connection_options = {
43
45
  :headers => {:user_agent => "Wayback Ruby Gem #{Wayback::Version}"},
44
46
  :request => {:open_timeout => 5, :timeout => 10},
@@ -54,6 +56,8 @@ Wayback.configure do |c|
54
56
  builder.use Wayback::Response::RaiseError, Wayback::Error::ClientError
55
57
  # Handle 5xx server responses
56
58
  builder.use Wayback::Response::RaiseError, Wayback::Error::ServerError
59
+ # Parse closest available JSON result
60
+ builder.use Wayback::Response::ParseAvailablity
57
61
  # Parse memento page
58
62
  builder.use Wayback::Response::ParseMementoPage
59
63
  # Parse link-format with custom memento parser
@@ -72,10 +76,18 @@ Wayback.configure do |c|
72
76
  Wayback.list('http://www.xolator.com')
73
77
  ```
74
78
 
79
+ **Fetch closest known page to a specified date**
80
+
81
+ ```ruby
82
+ Wayback.available('http://www.xolator.com', 20130613055153)
83
+ Wayback.available('http://www.xolator.com', :first)
84
+ Wayback.available('http://www.xolator.com', :last)
85
+ ```
86
+
75
87
  **Fetch a specific archived page**
76
88
 
77
89
  ```ruby
78
- Wayback.page('http://www.xolator.com', 1363488758)
90
+ Wayback.page('http://www.xolator.com', 20130613055153)
79
91
  Wayback.page('http://www.xolator.com', :first)
80
92
  Wayback.page('http://www.xolator.com', :last)
81
93
  ```
data/lib/wayback.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'wayback/archive'
2
+ require 'wayback/availability'
2
3
  require 'wayback/client'
3
4
  require 'wayback/configurable'
4
5
  require 'wayback/default'
@@ -18,6 +18,40 @@ module Wayback
18
18
  object_from_response(Wayback::Archive, :get, "/timemap/link/#{url}", options)
19
19
  end
20
20
 
21
+ # Return a page's information from the closest known timestamp
22
+ #
23
+ # @return [Wayback::Archive]
24
+ # @param url [String] The page URI that of which was archived.
25
+ # @param date [String, Symbol, Date, DateTime, Time, Fixnum, Integer, Float] A date or symbol to describe which dated archive page. Symbols include :first and :last. Strings are converted to integer timestamps.
26
+ # @param options [Hash] A customizable set of options.
27
+ # @example Return the the closest timestamp information about a page.
28
+ # Wayback.available('http://gleu.ch')
29
+ def available(url, date=0, options={})
30
+ archive_date = case date.class.to_s
31
+ when 'Time'
32
+ date
33
+ when 'Date', 'DateTime'
34
+ date.to_time
35
+ when 'Symbol'
36
+ (date == :first ? 19690101000000 : Time.now)
37
+ when 'String'
38
+ Time.parse(date).strftime('%Y%m%d%H%M%S')
39
+ when 'Fixnum', 'Integer', 'Float'
40
+ # Epoch vs date string as number
41
+ (date.to_i <= Time.now.to_i ? Time.at(date.to_i) : Time.parse(date.to_i.to_s))
42
+ else
43
+ raise Wayback::Error::ClientError
44
+ end
45
+
46
+ # Format accordingly
47
+ archive_date = archive_date.strftime('%Y%m%d%H%M%S') if archive_date.class == Time
48
+
49
+ options[:url] = url
50
+ options[:timestamp] = archive_date
51
+
52
+ object_from_response(Wayback::Availability, :json_get, "/available", options)
53
+ end
54
+
21
55
  # Returns the HTML contents of an archive page, fetched by date
22
56
  #
23
57
  # @raise [Wayback::Error::Unauthorized] Error raised when supplied user credentials are not valid.
@@ -0,0 +1,13 @@
1
+ require 'wayback/identity'
2
+
3
+ module Wayback
4
+ class Availability < Wayback::Identity
5
+
6
+ attr_reader :available, :timestamp, :url, :status
7
+
8
+
9
+ private
10
+
11
+
12
+ end
13
+ end
@@ -42,6 +42,10 @@ module Wayback
42
42
  request(:put, path, params)
43
43
  end
44
44
 
45
+ # Perform an HTTP GET request from JSON API
46
+ def json_get(path, params={})
47
+ json_request(:get, path, params)
48
+ end
45
49
 
46
50
  private
47
51
 
@@ -58,5 +62,18 @@ module Wayback
58
62
  @connection ||= Faraday.new(@endpoint, @connection_options.merge(:builder => @middleware))
59
63
  end
60
64
 
65
+ def json_request(method, path, params={}, signature_params=params)
66
+ json_connection.send(method.to_sym, path.insert(0, @json_endpoint_path), params).env
67
+ rescue Faraday::Error::ClientError
68
+ raise Wayback::Error::ClientError
69
+ end
70
+
71
+ # Returns a Faraday::Connection object
72
+ #
73
+ # @return [Faraday::Connection]
74
+ def json_connection
75
+ @json_connection ||= Faraday.new(@json_endpoint, @connection_options.merge(:builder => @middleware))
76
+ end
77
+
61
78
  end
62
79
  end
@@ -4,7 +4,7 @@ require 'wayback/error/configuration_error'
4
4
  module Wayback
5
5
  module Configurable
6
6
  extend Forwardable
7
- attr_accessor :endpoint, :endpoint_path, :connection_options, :identity_map, :middleware
7
+ attr_accessor :endpoint, :endpoint_path, :json_endpoint, :json_endpoint_path, :connection_options, :identity_map, :middleware
8
8
  def_delegator :options, :hash
9
9
 
10
10
  class << self
@@ -13,6 +13,8 @@ module Wayback
13
13
  @keys ||= [
14
14
  :endpoint,
15
15
  :endpoint_path,
16
+ :json_endpoint,
17
+ :json_endpoint_path,
16
18
  :connection_options,
17
19
  :identity_map,
18
20
  :middleware
@@ -4,6 +4,7 @@ require 'wayback/configurable'
4
4
  require 'wayback/error/client_error'
5
5
  require 'wayback/error/server_error'
6
6
  require 'wayback/response/raise_error'
7
+ require 'wayback/response/parse_availability'
7
8
  require 'wayback/response/parse_memento'
8
9
  require 'wayback/response/parse_memento_page'
9
10
  require 'wayback/version'
@@ -12,6 +13,8 @@ module Wayback
12
13
  module Default
13
14
  ENDPOINT = 'http://web.archive.org' unless defined? Wayback::Default::ENDPOINT
14
15
  ENDPOINT_PATH = '/web' unless defined? Wayback::Default::ENDPOINT_PATH
16
+ JSON_ENDPOINT = 'http://archive.org' unless defined? Wayback::Default::JSON_ENDPOINT
17
+ JSON_ENDPOINT_PATH = '/wayback' unless defined? Wayback::Default::JSON_ENDPOINT_PATH
15
18
  CONNECTION_OPTIONS = {
16
19
  :headers => {:user_agent => "Wayback Ruby Gem #{Wayback::Version}"},
17
20
  :request => {:open_timeout => 5, :timeout => 10},
@@ -27,6 +30,8 @@ module Wayback
27
30
  builder.use Wayback::Response::RaiseError, Wayback::Error::ClientError
28
31
  # Handle 5xx server responses
29
32
  builder.use Wayback::Response::RaiseError, Wayback::Error::ServerError
33
+ # Parse closest available JSON result
34
+ builder.use Wayback::Response::ParseAvailablity
30
35
  # Parse memento page
31
36
  builder.use Wayback::Response::ParseMementoPage
32
37
  # Parse link-format with custom memento parser
@@ -52,6 +57,14 @@ module Wayback
52
57
  ENDPOINT_PATH
53
58
  end
54
59
 
60
+ def json_endpoint
61
+ JSON_ENDPOINT
62
+ end
63
+
64
+ def json_endpoint_path
65
+ JSON_ENDPOINT_PATH
66
+ end
67
+
55
68
  def connection_options
56
69
  CONNECTION_OPTIONS
57
70
  end
@@ -0,0 +1,30 @@
1
+ require 'faraday'
2
+ require 'json'
3
+
4
+ module Wayback
5
+ module Response
6
+ class ParseAvailablity < Faraday::Response::Middleware
7
+
8
+ def parse(body)
9
+ case body
10
+ when /^\{/
11
+ obj = JSON.parse(body, :symbolize_names => true)[:archived_snapshots][:closest] rescue nil
12
+ obj[:id] = obj[:timestamp] if obj && obj[:timestamp]
13
+ obj
14
+ else
15
+ nil
16
+ end
17
+ end
18
+
19
+ def on_complete(env)
20
+ if respond_to?(:parse) && ((env[:response_headers] && env[:response_headers]['content-type']) || '').match(/^application\/javascript/i)
21
+ env[:body] = parse(env[:body]) unless unparsable_status_codes.include?(env[:status])
22
+ end
23
+ end
24
+
25
+ def unparsable_status_codes
26
+ [204, 301, 302, 304]
27
+ end
28
+ end
29
+ end
30
+ end
@@ -1,7 +1,7 @@
1
1
  module Wayback
2
2
  class Version
3
3
  MAJOR = 0 unless defined? Wayback::Version::MAJOR
4
- MINOR = 2 unless defined? Wayback::Version::MINOR
4
+ MINOR = 3 unless defined? Wayback::Version::MINOR
5
5
  PATCH = 1 unless defined? Wayback::Version::PATCH
6
6
  PRE = nil unless defined? Wayback::Version::PRE
7
7
 
@@ -0,0 +1 @@
1
+ {"archived_snapshots":{"closest":{"available":true,"url":"http://web.archive.org/web/20050422173123/http://www.gleuch.com:80/","timestamp":"20050422173123","status":"200"}}}
data/spec/helper.rb CHANGED
@@ -40,6 +40,10 @@ def a_put(path)
40
40
  a_request(:put, Wayback::Default::ENDPOINT + Wayback::Default::ENDPOINT_PATH + path)
41
41
  end
42
42
 
43
+ def a_json_get(path)
44
+ a_request(:get, Wayback::Default::JSON_ENDPOINT + Wayback::Default::JSON_ENDPOINT_PATH + path)
45
+ end
46
+
43
47
  def stub_delete(path)
44
48
  stub_request(:delete, Wayback::Default::ENDPOINT + Wayback::Default::ENDPOINT_PATH + path)
45
49
  end
@@ -56,6 +60,10 @@ def stub_put(path)
56
60
  stub_request(:put, Wayback::Default::ENDPOINT + Wayback::Default::ENDPOINT_PATH + path)
57
61
  end
58
62
 
63
+ def stub_json_get(path)
64
+ stub_request(:get, Wayback::Default::JSON_ENDPOINT + Wayback::Default::JSON_ENDPOINT_PATH + path)
65
+ end
66
+
59
67
  def fixture_path
60
68
  File.expand_path("../fixtures", __FILE__)
61
69
  end
@@ -12,10 +12,12 @@ describe Wayback::API::Archive do
12
12
  before do
13
13
  stub_get("/timemap/link/gleu.ch").to_return(:body => fixture("list.timemap"), :headers => {:content_type => "application/link-format"})
14
14
  end
15
+
15
16
  it "requests the correct resource" do
16
17
  @client.list('gleu.ch')
17
18
  expect(a_get("/timemap/link/gleu.ch")).to have_been_made
18
19
  end
20
+
19
21
  it "returns the link data" do
20
22
  timemap = @client.list('gleu.ch')
21
23
  expect(timemap).to be_a Wayback::Archive
@@ -25,9 +27,96 @@ describe Wayback::API::Archive do
25
27
  end
26
28
  end
27
29
 
30
+ describe "#available" do
31
+ before do
32
+ stub_json_get("/available?timestamp=19691231190000&url=gleu.ch").to_return(:body => fixture("available.json"), :headers => {:content_type => "application/javascript"})
33
+ @timenow = Time.now
34
+ end
35
+
36
+ it "requests the correct resource" do
37
+ @client.available('gleu.ch', 0)
38
+ expect(a_json_get("/available?timestamp=19691231190000&url=gleu.ch")).to have_been_made
39
+ end
40
+ it "returns the link data" do
41
+ closest = @client.available('gleu.ch')
42
+ expect(closest).to be_a Wayback::Availability
43
+ expect(closest.id).to eq ('20050422173123')
44
+ expect(closest.timestamp).to eq('20050422173123')
45
+ expect(closest.url).to eq('http://web.archive.org/web/20050422173123/http://www.gleuch.com:80/')
46
+ expect(closest.status).to eq('200')
47
+ expect(closest.available).to be_true
48
+ end
49
+
50
+ # it "returns the desired page on date" do
51
+ # stub_json_get("/available?timestamp=#{@timenow.to_i}&url=gleu.ch").to_return(:body => fixture("available.json"), :headers => {:content_type => "application/javascript"})
52
+ # stub_json_get("/available?timestamp=#{@timenow.to_i}&url=gleu.ch").to_return(:body => fixture("available.json"), :headers => {:content_type => "application/javascript"})
53
+ # closest = @client.available('gleu.ch', @timenow.to_i)
54
+ # expect(closest).to be_a Wayback::Availability
55
+ # expect(closest.id).to eq ('20050422173123')
56
+ # end
57
+
58
+ it "returns the first desired page" do
59
+ stub_json_get("/available?timestamp=0&url=gleu.ch").to_return(:body => fixture("available.json"), :headers => {:content_type => "application/javascript"})
60
+ closest = @client.available('gleu.ch', :first)
61
+ expect(closest).to be_a Wayback::Availability
62
+ expect(closest.id).to eq ('20050422173123')
63
+ end
64
+
65
+ it "returns the desired page for Time" do
66
+ stub_json_get("/available?timestamp=#{@timenow.strftime('%Y%m%d%H%M%S')}&url=gleu.ch").to_return(:body => fixture("available.json"), :headers => {:content_type => "application/javascript"})
67
+ closest = @client.available('gleu.ch', @timenow)
68
+ expect(closest).to be_a Wayback::Availability
69
+ expect(closest.id).to eq ('20050422173123')
70
+ end
71
+
72
+ it "returns the desired page for Date" do
73
+ stub_json_get("/available?timestamp=#{Time.parse(Date.today.to_s).strftime('%Y%m%d%H%M%S')}&url=gleu.ch").to_return(:body => fixture("available.json"), :headers => {:content_type => "application/javascript"})
74
+ closest = @client.available('gleu.ch', Date.today)
75
+ expect(closest).to be_a Wayback::Availability
76
+ expect(closest.id).to eq ('20050422173123')
77
+ end
78
+
79
+ it "returns the desired page for DateTime" do
80
+ stub_json_get("/available?timestamp=#{Time.parse(DateTime.new(2013,1,1).to_s).strftime('%Y%m%d%H%M%S')}&url=gleu.ch").to_return(:body => fixture("available.json"), :headers => {:content_type => "application/javascript"})
81
+ closest = @client.available('gleu.ch', DateTime.new(2013,1,1))
82
+ expect(closest).to be_a Wayback::Availability
83
+ expect(closest.id).to eq ('20050422173123')
84
+ end
85
+
86
+ it "returns the desired page for String" do
87
+ stub_json_get("/available?timestamp=#{@timenow.strftime('%Y%m%d%H%M%S')}&url=gleu.ch").to_return(:body => fixture("available.json"), :headers => {:content_type => "application/javascript"})
88
+ closest = @client.available('gleu.ch', @timenow.to_s)
89
+ expect(closest).to be_a Wayback::Availability
90
+ expect(closest.id).to eq ('20050422173123')
91
+ end
92
+
93
+ it "returns the desired page for Fixnum" do
94
+ stub_json_get("/available?timestamp=#{@timenow.strftime('%Y%m%d%H%M%S')}&url=gleu.ch").to_return(:body => fixture("available.json"), :headers => {:content_type => "application/javascript"})
95
+ closest = @client.available('gleu.ch', @timenow.to_i)
96
+ expect(closest).to be_a Wayback::Availability
97
+ expect(closest.id).to eq ('20050422173123')
98
+ end
99
+
100
+ it "returns the desired page for Float" do
101
+ stub_json_get("/available?timestamp=#{@timenow.strftime('%Y%m%d%H%M%S')}&url=gleu.ch").to_return(:body => fixture("available.json"), :headers => {:content_type => "application/javascript"})
102
+ closest = @client.available('gleu.ch', @timenow.to_f)
103
+ expect(closest).to be_a Wayback::Availability
104
+ expect(closest.id).to eq ('20050422173123')
105
+ end
106
+
107
+ [[0], {:a => 'b'}, File].each do |t|
108
+ it "returns error for #{t.class}" do
109
+ expect{page = @client.available('gleu.ch', t)}.to raise_error(Wayback::Error::ClientError)
110
+ end
111
+ end
112
+
113
+
114
+ end
115
+
28
116
  describe "#page" do
29
117
  before do
30
118
  stub_get("/20130129170322/gleu.ch").to_return(:body => fixture("page.html"), :headers => {:content_type => "text/html"})
119
+ @timenow = Time.now
31
120
  end
32
121
 
33
122
  it "requests the correct resource" do
@@ -52,7 +141,7 @@ describe Wayback::API::Archive do
52
141
  end
53
142
 
54
143
  it "returns the last desired page" do
55
- stub_get("/#{Time.now.strftime('%Y%m%d%H%M%S')}/gleu.ch").to_return(:body => fixture("page.html"), :headers => {:content_type => "text/html"})
144
+ stub_get("/#{@timenow.strftime('%Y%m%d%H%M%S')}/gleu.ch").to_return(:body => fixture("page.html"), :headers => {:content_type => "text/html"})
56
145
 
57
146
  page = @client.page('gleu.ch', :last)
58
147
  expect(page).to be_a Wayback::Page
@@ -60,9 +149,9 @@ describe Wayback::API::Archive do
60
149
  end
61
150
 
62
151
  it "returns the desired page for Time" do
63
- stub_get("/#{Time.now.strftime('%Y%m%d%H%M%S')}/gleu.ch").to_return(:body => fixture("page.html"), :headers => {:content_type => "text/html"})
152
+ stub_get("/#{@timenow.strftime('%Y%m%d%H%M%S')}/gleu.ch").to_return(:body => fixture("page.html"), :headers => {:content_type => "text/html"})
64
153
 
65
- page = @client.page('gleu.ch', Time.now)
154
+ page = @client.page('gleu.ch', @timenow)
66
155
  expect(page).to be_a Wayback::Page
67
156
  expect(page.html).to match(/^\<\!DOCTYPE html\>.*http\:\/\/gleu\.ch.*\<\/html\>/im)
68
157
  end
@@ -84,23 +173,23 @@ describe Wayback::API::Archive do
84
173
  end
85
174
 
86
175
  it "returns the desired page for String" do
87
- stub_get("/#{Time.now.strftime('%Y%m%d%H%M%S')}/gleu.ch").to_return(:body => fixture("page.html"), :headers => {:content_type => "text/html"})
176
+ stub_get("/#{@timenow.strftime('%Y%m%d%H%M%S')}/gleu.ch").to_return(:body => fixture("page.html"), :headers => {:content_type => "text/html"})
88
177
 
89
- page = @client.page('gleu.ch', Time.now.to_s)
178
+ page = @client.page('gleu.ch', @timenow.to_s)
90
179
  expect(page).to be_a Wayback::Page
91
180
  expect(page.html).to match(/^\<\!DOCTYPE html\>.*http\:\/\/gleu\.ch.*\<\/html\>/im)
92
181
  end
93
182
 
94
183
  it "returns the desired page for Fixnum" do
95
- stub_get("/#{Time.now.strftime('%Y%m%d%H%M%S')}/gleu.ch").to_return(:body => fixture("page.html"), :headers => {:content_type => "text/html"})
96
- page = @client.page('gleu.ch', Time.now.to_i)
184
+ stub_get("/#{@timenow.strftime('%Y%m%d%H%M%S')}/gleu.ch").to_return(:body => fixture("page.html"), :headers => {:content_type => "text/html"})
185
+ page = @client.page('gleu.ch', @timenow.to_i)
97
186
  expect(page).to be_a Wayback::Page
98
187
  expect(page.html).to match(/^\<\!DOCTYPE html\>.*http\:\/\/gleu\.ch.*\<\/html\>/im)
99
188
  end
100
189
 
101
190
  it "returns the desired page for Float" do
102
- stub_get("/#{Time.now.strftime('%Y%m%d%H%M%S')}/gleu.ch").to_return(:body => fixture("page.html"), :headers => {:content_type => "text/html"})
103
- page = @client.page('gleu.ch', Time.now.to_f)
191
+ stub_get("/#{@timenow.strftime('%Y%m%d%H%M%S')}/gleu.ch").to_return(:body => fixture("page.html"), :headers => {:content_type => "text/html"})
192
+ page = @client.page('gleu.ch', @timenow.to_f)
104
193
  expect(page).to be_a Wayback::Page
105
194
  expect(page.html).to match(/^\<\!DOCTYPE html\>.*http\:\/\/gleu\.ch.*\<\/html\>/im)
106
195
  end
@@ -34,6 +34,8 @@ describe Wayback::Client do
34
34
  :connection_options => {:timeout => 10},
35
35
  :endpoint => 'http://xolator.com/',
36
36
  :endpoint_path => '',
37
+ :json_endpoint => 'http://api.xolator.com/',
38
+ :json_endpoint_path => '',
37
39
  :middleware => Proc.new{},
38
40
  :identity_map => ::Hash
39
41
  }
@@ -107,9 +109,26 @@ describe Wayback::Client do
107
109
 
108
110
  describe "#request" do
109
111
  it "catches Faraday errors" do
110
- subject.stub!(:connection).and_raise(Faraday::Error::ClientError.new("Oops"))
112
+ subject.stub(:connection).and_raise(Faraday::Error::ClientError.new("Oops"))
111
113
  expect{subject.send(:request, :get, "/path")}.to raise_error Wayback::Error::ClientError
112
114
  end
113
115
  end
114
116
 
117
+ describe "#json connection" do
118
+ it "looks like Faraday connection" do
119
+ expect(subject.send(:json_connection)).to respond_to(:run_request)
120
+ end
121
+ it "memoizes the connection" do
122
+ c1, c2 = subject.send(:json_connection), subject.send(:json_connection)
123
+ expect(c1.object_id).to eq c2.object_id
124
+ end
125
+ end
126
+
127
+ describe "#json_request" do
128
+ it "catches Faraday errors" do
129
+ subject.stub(:json_connection).and_raise(Faraday::Error::ClientError.new("Oops"))
130
+ expect{subject.send(:json_request, :get, "/path")}.to raise_error Wayback::Error::ClientError
131
+ end
132
+ end
133
+
115
134
  end
data/wayback.gemspec CHANGED
@@ -6,10 +6,11 @@ require 'wayback/version'
6
6
  Gem::Specification.new do |spec|
7
7
  spec.add_dependency 'faraday', ['~> 0.8', '< 0.10']
8
8
  spec.add_dependency 'faraday_middleware', ['~> 0.9', '< 0.10']
9
+ spec.add_dependency 'json', '~> 1.8'
9
10
  spec.add_development_dependency 'bundler', '~> 1.0'
10
11
  spec.authors = ["Greg Leuch"]
11
12
  # spec.cert_chain = ['certs/gleuch.pem']
12
- spec.description = %q{A Ruby interface to the Archive.org's Wayback Machine Memento API.}
13
+ spec.description = %q{A Ruby interface to the Archive.org's Wayback Machine JSON and Memento APIs.}
13
14
  spec.email = ['greg@xolator.com']
14
15
  spec.files = %w(.yardopts CHANGELOG.md CONTRIBUTING.md LICENSE.md README.md Rakefile wayback.gemspec)
15
16
  spec.files += Dir.glob("lib/**/*.rb")
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wayback
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
5
- prerelease:
4
+ version: 0.3.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Greg Leuch
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-09-26 00:00:00.000000000 Z
11
+ date: 2014-01-14 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: faraday
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ~>
20
18
  - !ruby/object:Gem::Version
@@ -25,7 +23,6 @@ dependencies:
25
23
  type: :runtime
26
24
  prerelease: false
27
25
  version_requirements: !ruby/object:Gem::Requirement
28
- none: false
29
26
  requirements:
30
27
  - - ~>
31
28
  - !ruby/object:Gem::Version
@@ -36,7 +33,6 @@ dependencies:
36
33
  - !ruby/object:Gem::Dependency
37
34
  name: faraday_middleware
38
35
  requirement: !ruby/object:Gem::Requirement
39
- none: false
40
36
  requirements:
41
37
  - - ~>
42
38
  - !ruby/object:Gem::Version
@@ -47,7 +43,6 @@ dependencies:
47
43
  type: :runtime
48
44
  prerelease: false
49
45
  version_requirements: !ruby/object:Gem::Requirement
50
- none: false
51
46
  requirements:
52
47
  - - ~>
53
48
  - !ruby/object:Gem::Version
@@ -55,10 +50,23 @@ dependencies:
55
50
  - - <
56
51
  - !ruby/object:Gem::Version
57
52
  version: '0.10'
53
+ - !ruby/object:Gem::Dependency
54
+ name: json
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ~>
58
+ - !ruby/object:Gem::Version
59
+ version: '1.8'
60
+ type: :runtime
61
+ prerelease: false
62
+ version_requirements: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ~>
65
+ - !ruby/object:Gem::Version
66
+ version: '1.8'
58
67
  - !ruby/object:Gem::Dependency
59
68
  name: bundler
60
69
  requirement: !ruby/object:Gem::Requirement
61
- none: false
62
70
  requirements:
63
71
  - - ~>
64
72
  - !ruby/object:Gem::Version
@@ -66,12 +74,12 @@ dependencies:
66
74
  type: :development
67
75
  prerelease: false
68
76
  version_requirements: !ruby/object:Gem::Requirement
69
- none: false
70
77
  requirements:
71
78
  - - ~>
72
79
  - !ruby/object:Gem::Version
73
80
  version: '1.0'
74
- description: A Ruby interface to the Archive.org's Wayback Machine Memento API.
81
+ description: A Ruby interface to the Archive.org's Wayback Machine JSON and Memento
82
+ APIs.
75
83
  email:
76
84
  - greg@xolator.com
77
85
  executables: []
@@ -88,6 +96,7 @@ files:
88
96
  - lib/wayback/api/archive.rb
89
97
  - lib/wayback/api/utils.rb
90
98
  - lib/wayback/archive.rb
99
+ - lib/wayback/availability.rb
91
100
  - lib/wayback/base.rb
92
101
  - lib/wayback/client.rb
93
102
  - lib/wayback/configurable.rb
@@ -115,11 +124,13 @@ files:
115
124
  - lib/wayback/identity.rb
116
125
  - lib/wayback/identity_map.rb
117
126
  - lib/wayback/page.rb
127
+ - lib/wayback/response/parse_availability.rb
118
128
  - lib/wayback/response/parse_memento.rb
119
129
  - lib/wayback/response/parse_memento_page.rb
120
130
  - lib/wayback/response/raise_error.rb
121
131
  - lib/wayback/version.rb
122
132
  - lib/wayback.rb
133
+ - spec/fixtures/available.json
123
134
  - spec/fixtures/list.timemap
124
135
  - spec/fixtures/page.html
125
136
  - spec/helper.rb
@@ -136,29 +147,29 @@ files:
136
147
  homepage: http://github.com/XOlator/wayback_gem/
137
148
  licenses:
138
149
  - MIT
150
+ metadata: {}
139
151
  post_install_message:
140
152
  rdoc_options: []
141
153
  require_paths:
142
154
  - lib
143
155
  required_ruby_version: !ruby/object:Gem::Requirement
144
- none: false
145
156
  requirements:
146
157
  - - ! '>='
147
158
  - !ruby/object:Gem::Version
148
159
  version: '0'
149
160
  required_rubygems_version: !ruby/object:Gem::Requirement
150
- none: false
151
161
  requirements:
152
162
  - - ! '>='
153
163
  - !ruby/object:Gem::Version
154
164
  version: 1.3.6
155
165
  requirements: []
156
166
  rubyforge_project:
157
- rubygems_version: 1.8.25
167
+ rubygems_version: 2.1.10
158
168
  signing_key:
159
- specification_version: 3
160
- summary: A Ruby interface to the Archive.org's Wayback Machine Memento API.
169
+ specification_version: 4
170
+ summary: A Ruby interface to the Archive.org's Wayback Machine JSON and Memento APIs.
161
171
  test_files:
172
+ - spec/fixtures/available.json
162
173
  - spec/fixtures/list.timemap
163
174
  - spec/fixtures/page.html
164
175
  - spec/helper.rb