archivist-client 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MzY4Y2RkMTIyYjllODFiM2I1MzM2OTQ4NzY4M2VmMGQ2NzcwMTM4MQ==
4
+ MTZkNjQ0ZjExM2RhYWI2ZTRjZGYxYWRhMzZmZmFiMDQzNDYxYzA3NA==
5
5
  data.tar.gz: !binary |-
6
- ZTAxZTNmNDlkODgwNDZjNzViYjlmNWRlNWUwYjkyODVhYjEwZjJlYw==
6
+ MzA3MDBlNWJkNjBiODA5MjQ3OGIwNGQ3MWY5MjUyZDI4YmYyOTFkMw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- OGM4NmFhN2YyOWJkZDEyOWU2NWJiZDU4YTEzMTUwOTA3YWQ5Zjc1NmE5MWI0
10
- OGE1ZTAxODJhMmM4MGYyOWExYWM0NDJkYmVhYmUxNDNlMDRkNmY3ZDhjZmMw
11
- OWNhZDdkMmI0NWNmN2JmMTA1NWU5Mzc5YWZjMDc3ZDQ0ZThiZTE=
9
+ ZTI2YjIzNDI0NTA2MDczYWMxNzI0MzhhMDYyMTA0NmFhZDY4ZjcwNmJiYzc2
10
+ MjNmNjU3YzU2ZmExNzBiMzg5MDdkZWVjNmFiMTRhZWQyYTVmYjZlNWMzYTBl
11
+ OGIwN2ViNTM3ZjA1NDFhOTU3NjA2MTA4OTY4YTM5NDRkNDU4NTY=
12
12
  data.tar.gz: !binary |-
13
- ZDg4NjEzMDQ3YmI0NmJjYjQzN2NjNWVjYzU0MjRiNmFkMjE3MjAwNzQzZWUw
14
- NjQwNTZmOTM5ZDU5NGJjYWFlOGFhNzk3MzIzMDhhM2E5NGNlOTU1MjFmNjkw
15
- MGQ4NjIzNjQ2N2M3MmEwNzljZWUzNWU0NzkyYWVjN2U0MTY0ZDE=
13
+ ZjE4Y2FjZTQ2MTIyZDgwNjYwNmI5OGU1MzI1NzI0YjhjZTRhN2UyODQwY2I1
14
+ ZGQwOWYwMDAwMTY4YTkwYzYyN2I4MDQ4Nzc2ODRkOGU1Y2I2Y2U2MzJhMzNk
15
+ MDkxN2I4OWIyYTU3NTMzMWJmZjA0MjdlZDdkNmQ0ZDgwZWE5NzE=
@@ -25,11 +25,13 @@ Gem::Specification.new do |gem|
25
25
  gem.add_development_dependency "bundler", ">= 1.0.0"
26
26
  gem.add_development_dependency "rspec", "~> 2.6"
27
27
  gem.add_development_dependency "debugger"
28
- gem.add_development_dependency "webmock"
28
+ gem.add_development_dependency "webmock", [">= 1.8.0", "< 1.16"]
29
29
  gem.add_development_dependency "vcr"
30
30
  gem.add_development_dependency "reek", ">= 1.2.8"
31
31
  gem.add_development_dependency "roodi", ">= 2.1.0"
32
32
  gem.add_development_dependency "gem-release", ">= 0.7.1"
33
+ gem.add_development_dependency "coveralls"
34
+ gem.add_development_dependency "rdoc", ">= 3.12"
33
35
 
34
36
  gem.add_dependency "virtus", "~> 1.0.0"
35
37
  gem.add_dependency "representable"
@@ -42,14 +42,16 @@ module Archivist
42
42
  def search(opts = {})
43
43
  Model::QueryResponse.new.tap do |qr|
44
44
  response = @conn.get('/advancedsearch.php', params(opts))
45
- Representation::QueryResponse.new(qr).from_json(response.body)
45
+ rep = Representation::QueryResponse.new(qr)
46
+ puts "#{rep.inspect}"
47
+ rep.from_json(response.body)
46
48
  end
47
49
  end
48
50
 
49
51
  private
50
52
 
51
53
  def query(opts)
52
- @filters.update!(opts)
54
+ @filters.update(opts)
53
55
  @filters.to_query
54
56
  end
55
57
 
@@ -26,27 +26,27 @@ module Archivist
26
26
 
27
27
  def initialize(opts)
28
28
  @options = {}
29
- self.update!(opts)
29
+ self.update(opts)
30
30
  end
31
31
 
32
- def update!(opts)
33
- self.prune_options!(opts)
34
- self.set_language!
35
- self.set_years!
36
- self.set_filters!
32
+ def update(opts)
33
+ self.prune_options(opts)
34
+ self.set_language
35
+ self.set_years
36
+ self.set_filters
37
37
  end
38
38
 
39
39
  # May result in a URI with filters looking like:
40
40
  # 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
41
41
  alias :to_query :to_s
42
42
  def to_query
43
- self.finalize_filters!
43
+ self.finalize_filters
44
44
  @filters.join(' AND ')
45
45
  end
46
46
 
47
47
  protected
48
48
 
49
- def prune_options!(opts)
49
+ def prune_options(opts)
50
50
  # Save the options we need to build the filter
51
51
  @options.merge!(opts)
52
52
  # Remove the options used from the passed in options, so they don't get converted into parameters
@@ -55,21 +55,21 @@ module Archivist
55
55
  end
56
56
  end
57
57
 
58
- # Only overwrite if update! options has language key
59
- def set_language!
58
+ # Only overwrite if update options has language key
59
+ def set_language
60
60
  @language = @options[:language] if @options.has_key?(:language)
61
61
  end
62
62
 
63
- def set_years!
63
+ def set_years
64
64
  start = @options[:start_year]
65
65
  finish = @options[:end_year]
66
66
  @start_year = "#{start}-01-01" if start
67
67
  @end_year = "#{finish}-12-31" if finish
68
- self.validate_years!
68
+ self.validate_years
69
69
  end
70
70
 
71
71
  # If one is provided, they must *both* be provided
72
- def validate_years!
72
+ def validate_years
73
73
  unless @start_year && @end_year
74
74
  raise FilterException, ":start_year and :end_year must always be provided together, but only :start_year provided as #{@start_year}." if @start_year
75
75
  raise FilterException, ":start_year and :end_year must always be provided together, but only :end_year provided as #{@end_year}." if @end_year
@@ -77,12 +77,12 @@ module Archivist
77
77
  return true
78
78
  end
79
79
 
80
- def set_filters!
80
+ def set_filters
81
81
  @filters = Array(@options[:filters]) # If opts[:filters] is nil => self.array is []
82
82
  @filters |= DEFAULT_FILTERS
83
83
  end
84
84
 
85
- def add_language_filter!
85
+ def add_language_filter
86
86
  @filters << if @language
87
87
  "language:#{@language}"
88
88
  else
@@ -90,13 +90,13 @@ module Archivist
90
90
  end
91
91
  end
92
92
 
93
- def add_date_filter!
93
+ def add_date_filter
94
94
  @filters << "date:[#{@start_year} TO #{@end_year}]"
95
95
  end
96
96
 
97
- def finalize_filters!
98
- self.add_language_filter!
99
- self.add_date_filter!
97
+ def finalize_filters
98
+ self.add_language_filter
99
+ self.add_date_filter
100
100
  self
101
101
  end
102
102
  end
@@ -1,5 +1,5 @@
1
1
  module Archivist
2
2
  module Client
3
- VERSION = '0.1.3'
3
+ VERSION = '0.1.4'
4
4
  end
5
5
  end
@@ -28,7 +28,8 @@ module Archivist
28
28
  def format_index
29
29
  response = @conn.get(index_xml_path)
30
30
  Model::FormatIndex.new.tap do |idx|
31
- Representation::FormatIndex.new(idx).from_xml(response.body)
31
+ rep = Representation::FormatIndex.new(idx)
32
+ rep.from_xml(response.body)
32
33
  end
33
34
  end
34
35
 
@@ -1,6 +1,10 @@
1
1
  require 'vcr'
2
- require 'archivist/models'
3
- require 'archivist/representations/query_response'
2
+
3
+ # For code coverage, must be required before all application / gem / library code.
4
+ require 'coveralls'
5
+ Coveralls.wear!
6
+
7
+ require 'archivist-client'
4
8
 
5
9
  def fixture(filename)
6
10
  File.join(File.dirname(__FILE__), 'fixtures', filename)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: archivist-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Duane Johnson
@@ -73,14 +73,20 @@ dependencies:
73
73
  requirements:
74
74
  - - ! '>='
75
75
  - !ruby/object:Gem::Version
76
- version: '0'
76
+ version: 1.8.0
77
+ - - <
78
+ - !ruby/object:Gem::Version
79
+ version: '1.16'
77
80
  type: :development
78
81
  prerelease: false
79
82
  version_requirements: !ruby/object:Gem::Requirement
80
83
  requirements:
81
84
  - - ! '>='
82
85
  - !ruby/object:Gem::Version
83
- version: '0'
86
+ version: 1.8.0
87
+ - - <
88
+ - !ruby/object:Gem::Version
89
+ version: '1.16'
84
90
  - !ruby/object:Gem::Dependency
85
91
  name: vcr
86
92
  requirement: !ruby/object:Gem::Requirement
@@ -137,6 +143,34 @@ dependencies:
137
143
  - - ! '>='
138
144
  - !ruby/object:Gem::Version
139
145
  version: 0.7.1
146
+ - !ruby/object:Gem::Dependency
147
+ name: coveralls
148
+ requirement: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ! '>='
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ type: :development
154
+ prerelease: false
155
+ version_requirements: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ! '>='
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ - !ruby/object:Gem::Dependency
161
+ name: rdoc
162
+ requirement: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ! '>='
165
+ - !ruby/object:Gem::Version
166
+ version: '3.12'
167
+ type: :development
168
+ prerelease: false
169
+ version_requirements: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ! '>='
172
+ - !ruby/object:Gem::Version
173
+ version: '3.12'
140
174
  - !ruby/object:Gem::Dependency
141
175
  name: virtus
142
176
  requirement: !ruby/object:Gem::Requirement