culturegrid 0.1.0 → 0.1.2

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.2
@@ -0,0 +1,81 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{culturegrid}
8
+ s.version = "0.1.2"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["steflewandowski"]
12
+ s.date = %q{2011-01-15}
13
+ s.description = %q{Simple access to the CultureGrid API}
14
+ s.email = %q{stef@stef.io}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt"
17
+ ]
18
+ s.files = [
19
+ "Gemfile",
20
+ "Gemfile.lock",
21
+ "LICENSE.txt",
22
+ "Rakefile",
23
+ "VERSION",
24
+ "culturegrid.gemspec",
25
+ "lib/culturegrid.rb",
26
+ "readme.md",
27
+ "spec/culturegrid_spec.rb",
28
+ "spec/example_response.xml",
29
+ "spec/spec_helper.rb"
30
+ ]
31
+ s.homepage = %q{http://github.com/stefl/culturegrid}
32
+ s.licenses = ["MIT"]
33
+ s.require_paths = ["lib"]
34
+ s.rubygems_version = %q{1.3.7}
35
+ s.summary = %q{Simple access to the CultureGrid API}
36
+ s.test_files = [
37
+ "spec/culturegrid_spec.rb",
38
+ "spec/spec_helper.rb"
39
+ ]
40
+
41
+ if s.respond_to? :specification_version then
42
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
43
+ s.specification_version = 3
44
+
45
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
46
+ s.add_runtime_dependency(%q<hashie>, [">= 0"])
47
+ s.add_runtime_dependency(%q<weary>, [">= 0"])
48
+ s.add_runtime_dependency(%q<nokogiri>, [">= 0"])
49
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
50
+ s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
51
+ s.add_development_dependency(%q<rcov>, [">= 0"])
52
+ s.add_runtime_dependency(%q<nokogiri>, [">= 0"])
53
+ s.add_runtime_dependency(%q<hashie>, [">= 0"])
54
+ s.add_runtime_dependency(%q<weary>, [">= 0"])
55
+ s.add_development_dependency(%q<rspec>, [">= 0"])
56
+ else
57
+ s.add_dependency(%q<hashie>, [">= 0"])
58
+ s.add_dependency(%q<weary>, [">= 0"])
59
+ s.add_dependency(%q<nokogiri>, [">= 0"])
60
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
61
+ s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
62
+ s.add_dependency(%q<rcov>, [">= 0"])
63
+ s.add_dependency(%q<nokogiri>, [">= 0"])
64
+ s.add_dependency(%q<hashie>, [">= 0"])
65
+ s.add_dependency(%q<weary>, [">= 0"])
66
+ s.add_dependency(%q<rspec>, [">= 0"])
67
+ end
68
+ else
69
+ s.add_dependency(%q<hashie>, [">= 0"])
70
+ s.add_dependency(%q<weary>, [">= 0"])
71
+ s.add_dependency(%q<nokogiri>, [">= 0"])
72
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
73
+ s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
74
+ s.add_dependency(%q<rcov>, [">= 0"])
75
+ s.add_dependency(%q<nokogiri>, [">= 0"])
76
+ s.add_dependency(%q<hashie>, [">= 0"])
77
+ s.add_dependency(%q<weary>, [">= 0"])
78
+ s.add_dependency(%q<rspec>, [">= 0"])
79
+ end
80
+ end
81
+
@@ -6,7 +6,7 @@ require 'weary'
6
6
  module CultureGrid
7
7
 
8
8
  def self.search(terms, opts={})
9
- CultureGrid::Index.new.search(terms)
9
+ CultureGrid::Index.new.search(terms, opts)
10
10
  end
11
11
 
12
12
  class Index
@@ -19,11 +19,12 @@ module CultureGrid
19
19
  q = []
20
20
  opts[:version] ||= "2.2"
21
21
  opts[:indent] ||= "on"
22
+ opts[:start] ||= "0"
23
+ opts[:rows] ||= "10"
22
24
  opts.each_pair do |opt,val|
23
25
  q << "#{opt}=#{CGI::escape(val)}"
24
26
  end
25
27
  url = "#{@base}?#{q.join("&")}"
26
- puts url
27
28
 
28
29
  Nokogiri::XML(Weary.get(url).perform.body)
29
30
  end
@@ -61,7 +62,8 @@ module CultureGrid
61
62
  end
62
63
  end
63
64
  end
64
- puts hash.inspect
65
+ hash["id"] = hash["aggregator.internal.id"]
66
+ hash["title"] = hash["dc.title"].first rescue "Untitled"
65
67
  super(hash, default, &blk) rescue super({})
66
68
  end
67
69
  end
@@ -1,6 +1,9 @@
1
+ $:.unshift(File.expand_path(File.join(File.dirname(__FILE__))))
1
2
  $:.unshift(File.expand_path(File.join(File.dirname(__FILE__), "..","lib")))
3
+
2
4
  require 'spec_helper'
3
5
  require "culturegrid"
6
+ require 'json'
4
7
 
5
8
  describe CultureGrid::Index do
6
9
 
@@ -26,6 +29,15 @@ describe CultureGrid::Index do
26
29
  @grid.search("scree").first["dc.title"].should eql(["Screes near Badger Slacks"])
27
30
  @grid.search("scree").first["pndsterms.thumbnail"].should eql("https://www.hpacde.org.uk/kirklees/jpgs_kirklees/k006195.jpg")
28
31
  end
32
+
33
+ it "should get a document's title" do
34
+ @grid.search("scree").first.title.should eql("Screes near Badger Slacks")
35
+ end
36
+
37
+ it "should serialize Doc objects with an ID and title" do
38
+ JSON.parse(@grid.search("scree").first.to_json)["id"].should eql(2082977)
39
+ JSON.parse(@grid.search("scree").first.to_json)["title"].should eql("Screes near Badger Slacks")
40
+ end
29
41
 
30
42
  end
31
43
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: culturegrid
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 31
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 0
10
- version: 0.1.0
9
+ - 2
10
+ version: 0.1.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - steflewandowski
@@ -176,6 +176,7 @@ files:
176
176
  - LICENSE.txt
177
177
  - Rakefile
178
178
  - VERSION
179
+ - culturegrid.gemspec
179
180
  - lib/culturegrid.rb
180
181
  - readme.md
181
182
  - spec/culturegrid_spec.rb