archivist-client 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +15 -0
  2. data/README.md +107 -0
  3. data/archivist-client.gemspec +37 -0
  4. data/lib/archivist.rb +2 -0
  5. data/lib/archivist/client/base.rb +63 -0
  6. data/lib/archivist/client/version.rb +5 -0
  7. data/lib/archivist/models.rb +7 -0
  8. data/lib/archivist/models/body.rb +15 -0
  9. data/lib/archivist/models/document.rb +48 -0
  10. data/lib/archivist/models/file_format.rb +18 -0
  11. data/lib/archivist/models/format_index.rb +20 -0
  12. data/lib/archivist/models/header.rb +15 -0
  13. data/lib/archivist/models/parameters.rb +17 -0
  14. data/lib/archivist/models/query_response.rb +23 -0
  15. data/lib/archivist/representations.rb +9 -0
  16. data/lib/archivist/representations/body.rb +19 -0
  17. data/lib/archivist/representations/document.rb +17 -0
  18. data/lib/archivist/representations/file_format.rb +21 -0
  19. data/lib/archivist/representations/format_index.rb +17 -0
  20. data/lib/archivist/representations/header.rb +19 -0
  21. data/lib/archivist/representations/parameters.rb +19 -0
  22. data/lib/archivist/representations/query_response.rb +21 -0
  23. data/spec/client_spec.rb +17 -0
  24. data/spec/fixtures/document.json +7 -0
  25. data/spec/fixtures/download_files.xml +109 -0
  26. data/spec/fixtures/query-response.json +1 -0
  27. data/spec/fixtures/vcr/download.yml +1506 -0
  28. data/spec/fixtures/vcr/links.yml +127 -0
  29. data/spec/fixtures/vcr/search.yml +110 -0
  30. data/spec/models/body_spec.rb +7 -0
  31. data/spec/models/document_spec.rb +27 -0
  32. data/spec/models/file_format_spec.rb +9 -0
  33. data/spec/models/format_index_spec.rb +9 -0
  34. data/spec/models/header_spec.rb +7 -0
  35. data/spec/models/parameters_spec.rb +7 -0
  36. data/spec/models/query_response_spec.rb +7 -0
  37. data/spec/representations/document_spec.rb +17 -0
  38. data/spec/representations/format_index_spec.rb +32 -0
  39. data/spec/representations/query_response_spec.rb +28 -0
  40. data/spec/spec_helper.rb +12 -0
  41. metadata +272 -0
@@ -0,0 +1,127 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://archive.org/download/firstbooknapole00gruagoog/firstbooknapole00gruagoog_files.xml
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.8.8
12
+ Accept-Encoding:
13
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
+ Accept:
15
+ - ! '*/*'
16
+ response:
17
+ status:
18
+ code: 302
19
+ message: Moved Temporarily
20
+ headers:
21
+ Server:
22
+ - nginx/1.1.19
23
+ Date:
24
+ - Thu, 07 Nov 2013 03:22:15 GMT
25
+ Content-Type:
26
+ - text/html; charset=UTF-8
27
+ Transfer-Encoding:
28
+ - chunked
29
+ Connection:
30
+ - keep-alive
31
+ X-Powered-By:
32
+ - PHP/5.3.10-1ubuntu3.2
33
+ Accept-Ranges:
34
+ - bytes
35
+ Location:
36
+ - http://ia700307.us.archive.org/23/items/firstbooknapole00gruagoog/firstbooknapole00gruagoog_files.xml
37
+ body:
38
+ encoding: US-ASCII
39
+ string: ''
40
+ http_version:
41
+ recorded_at: Thu, 07 Nov 2013 03:22:15 GMT
42
+ - request:
43
+ method: get
44
+ uri: http://ia700307.us.archive.org/23/items/firstbooknapole00gruagoog/firstbooknapole00gruagoog_files.xml
45
+ body:
46
+ encoding: US-ASCII
47
+ string: ''
48
+ headers:
49
+ User-Agent:
50
+ - Faraday v0.8.8
51
+ Accept-Encoding:
52
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
53
+ Accept:
54
+ - ! '*/*'
55
+ response:
56
+ status:
57
+ code: 200
58
+ message: !binary |-
59
+ T0s=
60
+ headers:
61
+ !binary "U2VydmVy":
62
+ - !binary |-
63
+ bmdpbngvMS4xLjE5
64
+ !binary "RGF0ZQ==":
65
+ - !binary |-
66
+ VGh1LCAwNyBOb3YgMjAxMyAwMzoyMjoxNSBHTVQ=
67
+ !binary "Q29udGVudC1UeXBl":
68
+ - !binary |-
69
+ dGV4dC94bWw=
70
+ !binary "TGFzdC1Nb2RpZmllZA==":
71
+ - !binary |-
72
+ RnJpLCAxOSBOb3YgMjAxMCAwMzowNTozNyBHTVQ=
73
+ !binary "VHJhbnNmZXItRW5jb2Rpbmc=":
74
+ - !binary |-
75
+ Y2h1bmtlZA==
76
+ !binary "Q29ubmVjdGlvbg==":
77
+ - !binary |-
78
+ a2VlcC1hbGl2ZQ==
79
+ !binary "RXhwaXJlcw==":
80
+ - !binary |-
81
+ VGh1LCAwNyBOb3YgMjAxMyAwOToyMjoxNSBHTVQ=
82
+ !binary "Q2FjaGUtQ29udHJvbA==":
83
+ - !binary |-
84
+ bWF4LWFnZT0yMTYwMA==
85
+ !binary "Q29udGVudC1FbmNvZGluZw==":
86
+ - !binary |-
87
+ Z3ppcA==
88
+ body:
89
+ encoding: ASCII-8BIT
90
+ string: !binary |-
91
+ H4sIAAAAAAAAA61Y2W4aSRR9z1cgP8xbSO2LxibyJHLkmUkmUpxRkhd0ayOd
92
+ GLAAW3G+fk7RYMBAZNBYXnAtXd3nnnvuuX368sfwunOXJ9NmPDo74V120smj
93
+ OE7NaHB28vHq4rk7edl7dlqa6zztPet05p86Ixrms5PSTKazMB5/H9HN+Doz
94
+ Npjc0mA8HvSHeUZdXPmkMx3fTiLW1pFEMzqpF6mXGU+GNOu9XQyfvlgMtLPD
95
+ WTPMPS6UFMri+/RFO9LOTpufddJieP5xsSfpXvbWuSiSCcFlbhNZpgtF5QJx
96
+ zwvhOljVro+TKEUva82Klv70Rfv/4oSvxHsxBMlVdMSiL9KVyI3Q0kibgrfG
97
+ 4cacEzYx3EVdjp14CuD0dJhSnsbu19k6TuNJM2hGdP00nJarn9eA9Goopi+b
98
+ dGam8dU5vj6fn//5Gw1vfh/ns3ksT19s7lg8bcVTSGv1BqDUBoE7rT1jAs/Z
99
+ jrSbFiGqs9YY6zZDFLf2tiOLvTVUUgRubRDRZBOycyoD4OiS88ZTEOuhmuNL
100
+ WC9j4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nEWBfnBFkVkLffVaj3UnwNzrD8X99mP
117
+ 2YoDeyvI62//3l59ujo4x7r1jFWM1uyQiTq4oCFfzjqTBPyjhyWXKgc0AArP
118
+ tadQSw+XuB6XeXi5RHmvqVDtcEuCFheecoTh2VU9kEI21erCZTGkGRfMoC2A
119
+ f1UqWm/QNnjLBI5bon8Uwhut1C8QvrvtfHr798EQ95eeaw/MhfGglUUTAOfh
120
+ lQHmFIVHd1VUBix7YBa2hmDeCazlFCQOl8LMFs7WKDSRFhx/4OPSDyWl0GMI
121
+ wwLgRaHKMGIJfQPklCllc45JiiSOr9Jzlj2RxYfj+0sPpHTMmrR2jEklmYOP
122
+ VLJ4pVASUZvByD34yio+W/hKqdBCISpb+MLSa56qnG3hawo0Qit0EcFEzpUQ
123
+ GVXYCpk4ygvqSy0asMPH83j+BmHTbB74TgANUCogCF4LOEqWeGYobGRkFPAQ
124
+ js9vbwHVMsvav3hz8R/MlD5c6RAAAA==
125
+ http_version:
126
+ recorded_at: Thu, 07 Nov 2013 03:22:16 GMT
127
+ recorded_with: VCR 2.2.5
@@ -0,0 +1,110 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://archive.org/advancedsearch.php?fl%5B0%5D=identifier&fl%5B1%5D=title&fl%5B2%5D=creator&fl%5B3%5D=date&fl%5B4%5D=language&fl%5B5%5D=mediattype&output=json&page=1&q=mediatype:texts%20AND%20-mediatype:collection%20AND%20(language:eng%20OR%20language:English)%20AND%20date:%5B1500-01-01%20TO%201550-12-31%5D&rows=50&sort%5B0%5D=date%20asc
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.8.8
12
+ Accept-Encoding:
13
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
+ Accept:
15
+ - ! '*/*'
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: !binary |-
20
+ T0s=
21
+ headers:
22
+ !binary "U2VydmVy":
23
+ - !binary |-
24
+ bmdpbngvMS4xLjE5
25
+ !binary "RGF0ZQ==":
26
+ - !binary |-
27
+ V2VkLCAwNiBOb3YgMjAxMyAwMzoxMDowMyBHTVQ=
28
+ !binary "Q29udGVudC1UeXBl":
29
+ - !binary |-
30
+ YXBwbGljYXRpb24vanNvbg==
31
+ !binary "VHJhbnNmZXItRW5jb2Rpbmc=":
32
+ - !binary |-
33
+ Y2h1bmtlZA==
34
+ !binary "Q29ubmVjdGlvbg==":
35
+ - !binary |-
36
+ a2VlcC1hbGl2ZQ==
37
+ !binary "WC1Qb3dlcmVkLUJ5":
38
+ - !binary |-
39
+ UEhQLzUuMy4xMC0xdWJ1bnR1My4y
40
+ !binary "Q29udGVudC1FbmNvZGluZw==":
41
+ - !binary |-
42
+ Z3ppcA==
43
+ body:
44
+ encoding: ASCII-8BIT
45
+ string: !binary |-
46
+ H4sIAAAAAAAAA9Va224byRH9lQYfggQYKkNSpC55WMiSHa3hi2IpWSCCsGjO
47
+ 9HDanuke90XUrOEn/0i+IYt8gV/9UTnVMyQ1FCPaC1jRAoJETt+qq05VnarR
48
+ h54RttLKilPBU2F6hx961nHnbe8wjnp/u5Cl6B0O8LHihpd4+qH31mq1MzdZ
49
+ 77DXi3rvpcKHUqSSu7oSh07cOMuOXp2w/uphootCJE5qFUb+WHA183wmDoWa
50
+ sddv2PL7UzUrpM3/FKal3InDy8E4jvvxAD/s4jUbjMdxfzDsjwZXODwrcLZM
51
+ hXIyk8JETrpCRIkR3GkT0fposXXUSEMyYqHVxmEpzWDcJngiFW3T3AkaCMMx
52
+ 3e/bb7e6zv+4Htt8v4s4Pgw//+zedPWc7jwnIckG+Gz0HCbpjePex4/41pqS
53
+ jKR8+Ux7lfYORwNct7kQzJjqBCsuP/SCqrD23FdVIUrcnTnNjnVZCpMIZkQF
54
+ FVl2yFIui5olwIgvuGFcpcwZYGU5RVrrRcqmNXO5YE88tO+ZztgzbYScqbDi
55
+ RJfCOpksD4jYiQCkXDgYkxcH41JkFAgGu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mR8KOFu0NtKKFMfSmHIMJGjDoR4TgYHEO3kYZ+j+GlhQg
105
+ UOD9OVJTyjzFkL/qFNwg9L3nGl0c8jp0Voy+bogC2ij0nwsgDgtxm/YX95Rs
106
+ 8ZSud+slfZJ7g8bV7Ti00cQdDLZK1BmpD5qDm6Kzs2aduzXoMSbBnisSgbRK
107
+ 1eeY6MPVx4//BfDUIWmcIwAA
108
+ http_version:
109
+ recorded_at: Wed, 06 Nov 2013 03:10:04 GMT
110
+ recorded_with: VCR 2.2.5
@@ -0,0 +1,7 @@
1
+ require_relative '../spec_helper'
2
+
3
+ describe Archivist::Model::Body do
4
+ it "initializes" do
5
+ Archivist::Model::Body.new
6
+ end
7
+ end
@@ -0,0 +1,27 @@
1
+ require_relative '../spec_helper'
2
+
3
+ describe Archivist::Model::Document do
4
+ let(:document) { Archivist::Model::Document.new }
5
+
6
+ it "initializes" do
7
+ document
8
+ end
9
+
10
+ it "has download_xml_path" do
11
+ document.identifier = "xyz"
12
+ document.index_xml_path.should == "/download/xyz/xyz_files.xml"
13
+ end
14
+
15
+ context "downloading" do
16
+ before do
17
+ document.identifier = "firstbooknapole00gruagoog"
18
+ end
19
+
20
+ it "downloads a book" do
21
+ VCR.use_cassette('download') do
22
+ book = document.download
23
+ book[10021..10050].should == "pilots the vessel and weathers"
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,9 @@
1
+ require_relative '../spec_helper'
2
+
3
+ describe Archivist::Model::FileFormat do
4
+ let(:format) { Archivist::Model::FileFormat.new }
5
+
6
+ it "initializes" do
7
+ format
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ require_relative '../spec_helper'
2
+
3
+ describe Archivist::Model::FormatIndex do
4
+ let(:index) { Archivist::Model::FormatIndex.new }
5
+
6
+ it "initializes" do
7
+ index
8
+ end
9
+ end
@@ -0,0 +1,7 @@
1
+ require_relative '../spec_helper'
2
+
3
+ describe Archivist::Model::Header do
4
+ it "initializes" do
5
+ Archivist::Model::Header.new
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ require_relative '../spec_helper'
2
+
3
+ describe Archivist::Model::Parameters do
4
+ it "initializes" do
5
+ Archivist::Model::Parameters.new
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ require_relative '../spec_helper'
2
+
3
+ describe Archivist::Model::QueryResponse do
4
+ it "initializes" do
5
+ Archivist::Model::QueryResponse.new
6
+ end
7
+ end
@@ -0,0 +1,17 @@
1
+ require_relative '../spec_helper'
2
+
3
+ describe Archivist::Representation::Document do
4
+ let(:json) { File.read(fixture('document.json')) }
5
+ let(:doc) { Archivist::Model::Document.new }
6
+ let(:rep) { Archivist::Representation::Document.new(doc).from_json(json) }
7
+
8
+ it "parses" do
9
+ rep
10
+ end
11
+
12
+ it "has properties" do
13
+ rep.title.should == "Document"
14
+ rep.languages.should == ["eng"]
15
+ rep.date.should == Date.new(1501, 1, 1)
16
+ end
17
+ end
@@ -0,0 +1,32 @@
1
+ require_relative '../spec_helper'
2
+
3
+ describe Archivist::Representation::FormatIndex do
4
+ let(:xml) { File.read(fixture('download_files.xml')) }
5
+ let(:index) { Archivist::Model::FormatIndex.new }
6
+ let(:rep) { Archivist::Representation::FormatIndex.new(index).from_xml(xml) }
7
+
8
+ it "parses" do
9
+ rep
10
+ end
11
+
12
+ context "represented" do
13
+ before do
14
+ rep
15
+ end
16
+
17
+ it "has properties" do
18
+ index.formats.size.should == 12
19
+ index.formats.first.format.should == "Metadata"
20
+ index.formats.first.name.should == "firstbooknapole00gruagoog_meta.xml"
21
+ end
22
+
23
+ it "has a square bracket lookup" do
24
+ index["Metadata"].name.should == "firstbooknapole00gruagoog_meta.xml"
25
+ index["DjVuTXT"].name.should == "firstbooknapole00gruagoog_djvu.txt"
26
+ end
27
+
28
+ it "has a text_format" do
29
+ index.text_format.name.should == "firstbooknapole00gruagoog_djvu.txt"
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,28 @@
1
+ require_relative '../spec_helper'
2
+
3
+ describe Archivist::Representation::QueryResponse do
4
+ let(:json) { File.read(fixture('query-response.json')) }
5
+ let(:response) { Archivist::Model::QueryResponse.new }
6
+ let(:rep) { Archivist::Representation::QueryResponse.new(response).from_json(json) }
7
+
8
+ it "parses" do
9
+ rep
10
+ end
11
+
12
+ it "has header" do
13
+ rep.header.status.should == 0
14
+ end
15
+
16
+ it "has body" do
17
+ rep.body.docs.size.should == 31
18
+ rep.body.num_found == 31
19
+ end
20
+
21
+ it "has query time" do
22
+ rep.header.qtime.should == 5
23
+ end
24
+
25
+ it "has docs" do
26
+ rep.body.docs.first.languages.should == ["eng"]
27
+ end
28
+ end
@@ -0,0 +1,12 @@
1
+ require 'vcr'
2
+ require 'archivist/models'
3
+ require 'archivist/representations/query_response'
4
+
5
+ def fixture(filename)
6
+ File.join(File.dirname(__FILE__), 'fixtures', filename)
7
+ end
8
+
9
+ VCR.configure do |c|
10
+ c.cassette_library_dir = fixture('vcr')
11
+ c.hook_into :webmock
12
+ end
metadata ADDED
@@ -0,0 +1,272 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: archivist-client
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Duane Johnson
8
+ - Peter Boling
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-12-31 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rake
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ! '>='
19
+ - !ruby/object:Gem::Version
20
+ version: '0'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ! '>='
26
+ - !ruby/object:Gem::Version
27
+ version: '0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: bundler
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ! '>='
33
+ - !ruby/object:Gem::Version
34
+ version: 1.0.0
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ! '>='
40
+ - !ruby/object:Gem::Version
41
+ version: 1.0.0
42
+ - !ruby/object:Gem::Dependency
43
+ name: rspec
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ~>
47
+ - !ruby/object:Gem::Version
48
+ version: '2.6'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ~>
54
+ - !ruby/object:Gem::Version
55
+ version: '2.6'
56
+ - !ruby/object:Gem::Dependency
57
+ name: debugger
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ - !ruby/object:Gem::Dependency
71
+ name: webmock
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ! '>='
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ - !ruby/object:Gem::Dependency
85
+ name: vcr
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ! '>='
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ! '>='
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ - !ruby/object:Gem::Dependency
99
+ name: reek
100
+ requirement: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ! '>='
103
+ - !ruby/object:Gem::Version
104
+ version: 1.2.8
105
+ type: :development
106
+ prerelease: false
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ! '>='
110
+ - !ruby/object:Gem::Version
111
+ version: 1.2.8
112
+ - !ruby/object:Gem::Dependency
113
+ name: roodi
114
+ requirement: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ! '>='
117
+ - !ruby/object:Gem::Version
118
+ version: 2.1.0
119
+ type: :development
120
+ prerelease: false
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: 2.1.0
126
+ - !ruby/object:Gem::Dependency
127
+ name: virtus
128
+ requirement: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - ~>
131
+ - !ruby/object:Gem::Version
132
+ version: 1.0.0
133
+ type: :runtime
134
+ prerelease: false
135
+ version_requirements: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - ~>
138
+ - !ruby/object:Gem::Version
139
+ version: 1.0.0
140
+ - !ruby/object:Gem::Dependency
141
+ name: representable
142
+ requirement: !ruby/object:Gem::Requirement
143
+ requirements:
144
+ - - ! '>='
145
+ - !ruby/object:Gem::Version
146
+ version: '0'
147
+ type: :runtime
148
+ prerelease: false
149
+ version_requirements: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - ! '>='
152
+ - !ruby/object:Gem::Version
153
+ version: '0'
154
+ - !ruby/object:Gem::Dependency
155
+ name: faraday
156
+ requirement: !ruby/object:Gem::Requirement
157
+ requirements:
158
+ - - ! '>='
159
+ - !ruby/object:Gem::Version
160
+ version: '0'
161
+ type: :runtime
162
+ prerelease: false
163
+ version_requirements: !ruby/object:Gem::Requirement
164
+ requirements:
165
+ - - ! '>='
166
+ - !ruby/object:Gem::Version
167
+ version: '0'
168
+ - !ruby/object:Gem::Dependency
169
+ name: faraday_middleware
170
+ requirement: !ruby/object:Gem::Requirement
171
+ requirements:
172
+ - - ! '>='
173
+ - !ruby/object:Gem::Version
174
+ version: '0'
175
+ type: :runtime
176
+ prerelease: false
177
+ version_requirements: !ruby/object:Gem::Requirement
178
+ requirements:
179
+ - - ! '>='
180
+ - !ruby/object:Gem::Version
181
+ version: '0'
182
+ description: archivist-client queries archive.org for book data and downloads some
183
+ things.
184
+ email:
185
+ - duane.johnson@gmail.com
186
+ - peter.boling@gmail.com
187
+ executables: []
188
+ extensions: []
189
+ extra_rdoc_files: []
190
+ files:
191
+ - archivist-client.gemspec
192
+ - README.md
193
+ - lib/archivist/client/base.rb
194
+ - lib/archivist/client/version.rb
195
+ - lib/archivist/models/body.rb
196
+ - lib/archivist/models/document.rb
197
+ - lib/archivist/models/file_format.rb
198
+ - lib/archivist/models/format_index.rb
199
+ - lib/archivist/models/header.rb
200
+ - lib/archivist/models/parameters.rb
201
+ - lib/archivist/models/query_response.rb
202
+ - lib/archivist/models.rb
203
+ - lib/archivist/representations/body.rb
204
+ - lib/archivist/representations/document.rb
205
+ - lib/archivist/representations/file_format.rb
206
+ - lib/archivist/representations/format_index.rb
207
+ - lib/archivist/representations/header.rb
208
+ - lib/archivist/representations/parameters.rb
209
+ - lib/archivist/representations/query_response.rb
210
+ - lib/archivist/representations.rb
211
+ - lib/archivist.rb
212
+ - spec/client_spec.rb
213
+ - spec/fixtures/document.json
214
+ - spec/fixtures/download_files.xml
215
+ - spec/fixtures/query-response.json
216
+ - spec/fixtures/vcr/download.yml
217
+ - spec/fixtures/vcr/links.yml
218
+ - spec/fixtures/vcr/search.yml
219
+ - spec/models/body_spec.rb
220
+ - spec/models/document_spec.rb
221
+ - spec/models/file_format_spec.rb
222
+ - spec/models/format_index_spec.rb
223
+ - spec/models/header_spec.rb
224
+ - spec/models/parameters_spec.rb
225
+ - spec/models/query_response_spec.rb
226
+ - spec/representations/document_spec.rb
227
+ - spec/representations/format_index_spec.rb
228
+ - spec/representations/query_response_spec.rb
229
+ - spec/spec_helper.rb
230
+ homepage: http://github.com/canadaduane/archivist-client
231
+ licenses:
232
+ - MIT
233
+ metadata: {}
234
+ post_install_message:
235
+ rdoc_options: []
236
+ require_paths:
237
+ - lib
238
+ required_ruby_version: !ruby/object:Gem::Requirement
239
+ requirements:
240
+ - - ! '>='
241
+ - !ruby/object:Gem::Version
242
+ version: 1.9.0
243
+ required_rubygems_version: !ruby/object:Gem::Requirement
244
+ requirements:
245
+ - - ! '>='
246
+ - !ruby/object:Gem::Version
247
+ version: '0'
248
+ requirements: []
249
+ rubyforge_project:
250
+ rubygems_version: 2.1.11
251
+ signing_key:
252
+ specification_version: 4
253
+ summary: archivist-client is an archive.org client library
254
+ test_files:
255
+ - spec/client_spec.rb
256
+ - spec/fixtures/document.json
257
+ - spec/fixtures/download_files.xml
258
+ - spec/fixtures/query-response.json
259
+ - spec/fixtures/vcr/download.yml
260
+ - spec/fixtures/vcr/links.yml
261
+ - spec/fixtures/vcr/search.yml
262
+ - spec/models/body_spec.rb
263
+ - spec/models/document_spec.rb
264
+ - spec/models/file_format_spec.rb
265
+ - spec/models/format_index_spec.rb
266
+ - spec/models/header_spec.rb
267
+ - spec/models/parameters_spec.rb
268
+ - spec/models/query_response_spec.rb
269
+ - spec/representations/document_spec.rb
270
+ - spec/representations/format_index_spec.rb
271
+ - spec/representations/query_response_spec.rb
272
+ - spec/spec_helper.rb