blacklight_cql 0.9.0
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/MIT-LICENSE +20 -0
- data/README.rdoc +142 -0
- data/Rakefile +43 -0
- data/VERSION +1 -0
- data/app/controllers/blacklight_cql/explain_controller.rb +17 -0
- data/app/helpers/blacklight_cql/explain_helper.rb +44 -0
- data/app/views/blacklight_cql/explain/explain.xml.builder +30 -0
- data/config/routes.rb +10 -0
- data/init.rb +1 -0
- data/install.rb +1 -0
- data/lib/blacklight_cql/blacklight_to_solr.rb +115 -0
- data/lib/blacklight_cql/solr_helper_extension.rb +24 -0
- data/lib/blacklight_cql/template_helper_extension.rb +19 -0
- data/lib/blacklight_cql.rb +25 -0
- data/rails/init.rb +32 -0
- data/spec/app_root/app/controllers/application_controller.rb +2 -0
- data/spec/app_root/config/boot.rb +115 -0
- data/spec/app_root/config/database.yml +31 -0
- data/spec/app_root/config/environment.rb +30 -0
- data/spec/app_root/config/environments/in_memory.rb +0 -0
- data/spec/app_root/config/environments/mysql.rb +0 -0
- data/spec/app_root/config/environments/postgresql.rb +0 -0
- data/spec/app_root/config/environments/sqlite.rb +0 -0
- data/spec/app_root/config/environments/sqlite3.rb +0 -0
- data/spec/app_root/config/routes.rb +4 -0
- data/spec/app_root/lib/blacklight/search_fields.rb +97 -0
- data/spec/app_root/lib/console_with_fixtures.rb +4 -0
- data/spec/blacklight_to_solr_spec.rb +50 -0
- data/spec/data/luke.yaml +75 -0
- data/spec/data/zeerex-2.0.xsd +482 -0
- data/spec/marc_data/chomsky.mrc +1 -0
- data/spec/marc_data/social_journal.mrc +1 -0
- data/spec/rcov.opts +2 -0
- data/spec/spec.opts +4 -0
- data/spec/spec_helper.rb +73 -0
- data/spec/views/explain.xml.builder_spec.rb +125 -0
- data/tasks/blacklight_cql_tasks.rake +4 -0
- data/uninstall.rb +1 -0
- metadata +146 -0
@@ -0,0 +1,125 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
require 'markup_validity' # for validating against XML Schema
|
4
|
+
|
5
|
+
describe "Explain view" do
|
6
|
+
before do
|
7
|
+
config = Class.new do
|
8
|
+
include Blacklight::SearchFields
|
9
|
+
|
10
|
+
def config
|
11
|
+
{
|
12
|
+
:search_fields => [
|
13
|
+
{
|
14
|
+
:display_label => "Title",
|
15
|
+
:key => "title",
|
16
|
+
:solr_parameters => {
|
17
|
+
:qf => "something"
|
18
|
+
},
|
19
|
+
:solr_local_parameters => {
|
20
|
+
:pf => "$something"
|
21
|
+
}
|
22
|
+
},
|
23
|
+
{
|
24
|
+
:display_label => "Author",
|
25
|
+
:key => "author",
|
26
|
+
:solr_parameters => {
|
27
|
+
:qf => "au_something^10 au_else^100"
|
28
|
+
}
|
29
|
+
}
|
30
|
+
|
31
|
+
]
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
end.new
|
36
|
+
assigns[:field_config] = config
|
37
|
+
assigns[:luke_response] = YAML::load( File.open( File.expand_path(File.dirname(__FILE__) + '/../data/luke.yaml') ) )
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
render "blacklight_cql/explain/explain.xml.builder"
|
42
|
+
# Put it in a rexml doc for things that can't be easily tested
|
43
|
+
# with have_tag
|
44
|
+
@response_xml = REXML::Document.new(response.body.to_s)
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should render a valid ZeeRex 2.0 xml document" do
|
48
|
+
schema = File.open(File.expand_path(File.dirname(__FILE__) + "/../data/zeerex-2.0.xsd")).read
|
49
|
+
|
50
|
+
response.body.should be_valid_with_schema(schema)
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should start with an explain element" do
|
54
|
+
response.should have_tag('explain[xmlns="http://explain.z3950.org/dtd/2.0/"]')
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should have a serverInfo block" do
|
58
|
+
response.should have_tag("serverInfo[protocol='http-cql']") do
|
59
|
+
with_tag("host", :text => request.host)
|
60
|
+
with_tag("port", :text => request.port)
|
61
|
+
with_tag("database", :text => url_for(:controller => "/catalog", :action => "index", :search_field => BlacklightCql::SolrHelperExtension.pseudo_search_field[:key]))
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should include an indexInfo with context set prefixes" do
|
66
|
+
response.should have_tag("indexInfo") do
|
67
|
+
with_tag("set[name=#{CqlRuby.to_solr_defaults[:solr_field_prefix]}][identifier='#{
|
68
|
+
url_for(:controller => "/catalog",
|
69
|
+
:action => "index",
|
70
|
+
:anchor => "local_solr_field",
|
71
|
+
:only_path => false)}']")
|
72
|
+
with_tag("set[name=#{CqlRuby.to_solr_defaults[:blacklight_field_prefix]}][identifier='#{
|
73
|
+
url_for(:controller => "/catalog",
|
74
|
+
:action => "index",
|
75
|
+
:anchor => "local_app_field",
|
76
|
+
:only_path => false)}']")
|
77
|
+
with_tag("set[name=solr][identifier='http://purl.org/net/cql-context-set/solr']")
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
describe "for the config'd dismax field with :key 'title'" do
|
82
|
+
before do
|
83
|
+
@title_index_el = @response_xml.get_elements("/explain/indexInfo/index").find {|e| e.elements["title"].text == "Title" }.to_s
|
84
|
+
end
|
85
|
+
|
86
|
+
it "should have an indexInfo block" do
|
87
|
+
@title_index_el.should_not be_nil
|
88
|
+
end
|
89
|
+
it "should have explain title 'Title'" do
|
90
|
+
@title_index_el.should have_tag("title", :text => "Title")
|
91
|
+
end
|
92
|
+
it "should have a map element with proper context set" do
|
93
|
+
@title_index_el.should have_tag("map") do
|
94
|
+
with_tag("name[set=#{CqlRuby.to_solr_defaults[:blacklight_field_prefix]}]",
|
95
|
+
:text => "title")
|
96
|
+
end
|
97
|
+
end
|
98
|
+
it "should have configInfo with exactly two relations" do
|
99
|
+
@title_index_el.should have_tag("configInfo") do
|
100
|
+
with_tag("supports", :count => 2)
|
101
|
+
with_tag("supports[type=relation]", :text=> "=")
|
102
|
+
with_tag("supports[type=relation]", :text=> "solr.dismax")
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
it "should include an indexed solr field from luke response" do
|
108
|
+
solr_index_el = @response_xml.get_elements("/explain/indexInfo/index").find {|e| e.elements["title"].text == "subject_unstem_search" }.to_s
|
109
|
+
|
110
|
+
solr_index_el.should have_tag("map") do
|
111
|
+
with_tag("name[set=#{CqlRuby.to_solr_defaults[:solr_field_prefix]}]",
|
112
|
+
:text => "subject_unstem_search")
|
113
|
+
end
|
114
|
+
|
115
|
+
solr_index_el.should have_tag("configInfo") do
|
116
|
+
["==", "=", ">=", ">", "<=", "<", "<>", "within", "adj", "all", "any"].each do |relation|
|
117
|
+
with_tag("supports[type=relation]", :text => relation)
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
it "should not include a non-indexed solr field from luke response" do
|
123
|
+
@response_xml.get_elements("/explain/indexInfo/index").find {|e| e.elements["title"].text == "url_suppl_display" }.should be_nil
|
124
|
+
end
|
125
|
+
end
|
data/uninstall.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# Uninstall hook code here
|
metadata
ADDED
@@ -0,0 +1,146 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: blacklight_cql
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 59
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 9
|
9
|
+
- 0
|
10
|
+
version: 0.9.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Jonathan Rochkind
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-06-28 00:00:00 -04:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: cql-ruby
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 61
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
- 8
|
33
|
+
- 1
|
34
|
+
version: 0.8.1
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: markup_validity
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
hash: 3
|
46
|
+
segments:
|
47
|
+
- 0
|
48
|
+
version: "0"
|
49
|
+
type: :development
|
50
|
+
version_requirements: *id002
|
51
|
+
description: May have parts that can be used outside a Blacklight app too with a big of refactoring, let me know if interested.
|
52
|
+
email: rochkind@jhu.edu
|
53
|
+
executables: []
|
54
|
+
|
55
|
+
extensions: []
|
56
|
+
|
57
|
+
extra_rdoc_files:
|
58
|
+
- README.rdoc
|
59
|
+
files:
|
60
|
+
- MIT-LICENSE
|
61
|
+
- README.rdoc
|
62
|
+
- Rakefile
|
63
|
+
- VERSION
|
64
|
+
- app/controllers/blacklight_cql/explain_controller.rb
|
65
|
+
- app/helpers/blacklight_cql/explain_helper.rb
|
66
|
+
- app/views/blacklight_cql/explain/explain.xml.builder
|
67
|
+
- config/routes.rb
|
68
|
+
- init.rb
|
69
|
+
- install.rb
|
70
|
+
- lib/blacklight_cql.rb
|
71
|
+
- lib/blacklight_cql/blacklight_to_solr.rb
|
72
|
+
- lib/blacklight_cql/solr_helper_extension.rb
|
73
|
+
- lib/blacklight_cql/template_helper_extension.rb
|
74
|
+
- rails/init.rb
|
75
|
+
- spec/app_root/app/controllers/application_controller.rb
|
76
|
+
- spec/app_root/config/boot.rb
|
77
|
+
- spec/app_root/config/database.yml
|
78
|
+
- spec/app_root/config/environment.rb
|
79
|
+
- spec/app_root/config/environments/in_memory.rb
|
80
|
+
- spec/app_root/config/environments/mysql.rb
|
81
|
+
- spec/app_root/config/environments/postgresql.rb
|
82
|
+
- spec/app_root/config/environments/sqlite.rb
|
83
|
+
- spec/app_root/config/environments/sqlite3.rb
|
84
|
+
- spec/app_root/config/routes.rb
|
85
|
+
- spec/app_root/lib/blacklight/search_fields.rb
|
86
|
+
- spec/app_root/lib/console_with_fixtures.rb
|
87
|
+
- spec/blacklight_to_solr_spec.rb
|
88
|
+
- spec/data/luke.yaml
|
89
|
+
- spec/data/zeerex-2.0.xsd
|
90
|
+
- spec/marc_data/chomsky.mrc
|
91
|
+
- spec/marc_data/social_journal.mrc
|
92
|
+
- spec/rcov.opts
|
93
|
+
- spec/spec.opts
|
94
|
+
- spec/spec_helper.rb
|
95
|
+
- spec/views/explain.xml.builder_spec.rb
|
96
|
+
- tasks/blacklight_cql_tasks.rake
|
97
|
+
- uninstall.rb
|
98
|
+
has_rdoc: true
|
99
|
+
homepage: http://github.com/projectblacklight/blacklight_cql
|
100
|
+
licenses: []
|
101
|
+
|
102
|
+
post_install_message:
|
103
|
+
rdoc_options:
|
104
|
+
- --charset=UTF-8
|
105
|
+
require_paths:
|
106
|
+
- lib
|
107
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
108
|
+
none: false
|
109
|
+
requirements:
|
110
|
+
- - ">="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
hash: 3
|
113
|
+
segments:
|
114
|
+
- 0
|
115
|
+
version: "0"
|
116
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
|
+
none: false
|
118
|
+
requirements:
|
119
|
+
- - ">="
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
hash: 3
|
122
|
+
segments:
|
123
|
+
- 0
|
124
|
+
version: "0"
|
125
|
+
requirements: []
|
126
|
+
|
127
|
+
rubyforge_project:
|
128
|
+
rubygems_version: 1.3.7
|
129
|
+
signing_key:
|
130
|
+
specification_version: 3
|
131
|
+
summary: Add CQL query support to a Blacklight app
|
132
|
+
test_files:
|
133
|
+
- spec/blacklight_to_solr_spec.rb
|
134
|
+
- spec/spec_helper.rb
|
135
|
+
- spec/app_root/app/controllers/application_controller.rb
|
136
|
+
- spec/app_root/lib/console_with_fixtures.rb
|
137
|
+
- spec/app_root/lib/blacklight/search_fields.rb
|
138
|
+
- spec/app_root/config/environments/postgresql.rb
|
139
|
+
- spec/app_root/config/environments/sqlite3.rb
|
140
|
+
- spec/app_root/config/environments/sqlite.rb
|
141
|
+
- spec/app_root/config/environments/in_memory.rb
|
142
|
+
- spec/app_root/config/environments/mysql.rb
|
143
|
+
- spec/app_root/config/environment.rb
|
144
|
+
- spec/app_root/config/routes.rb
|
145
|
+
- spec/app_root/config/boot.rb
|
146
|
+
- spec/views/explain.xml.builder_spec.rb
|