lucid_works 0.6.13 → 0.6.14
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/lib/lucid_works.rb +2 -4
- data/lib/lucid_works/associations.rb +2 -2
- data/lib/lucid_works/base.rb +2 -2
- data/lib/lucid_works/collection.rb +5 -5
- data/lib/lucid_works/field.rb +15 -0
- data/lib/lucid_works/version.rb +1 -1
- data/lucid_works.gemspec +1 -0
- data/spec/lib/lucid_works/collection_spec.rb +10 -10
- data/spec/lib/lucid_works/datasource_spec.rb +1 -1
- metadata +14 -3
data/lib/lucid_works.rb
CHANGED
@@ -6,13 +6,10 @@ end
|
|
6
6
|
require 'active_model'
|
7
7
|
require 'active_support/core_ext'
|
8
8
|
require 'active_support/inflector'
|
9
|
-
begin
|
10
|
-
require 'action_view/helpers/number_helper' # Optional formatter support
|
11
|
-
rescue LoadError
|
12
|
-
end
|
13
9
|
require 'restclient'
|
14
10
|
require 'json'
|
15
11
|
require 'rsolr'
|
12
|
+
require 'rsolr-ext'
|
16
13
|
require 'nokogiri'
|
17
14
|
|
18
15
|
require 'lucid_works/utils'
|
@@ -55,3 +52,4 @@ require 'lucid_works/logs/index/summary'
|
|
55
52
|
require 'lucid_works/version'
|
56
53
|
|
57
54
|
I18n.load_path += Dir.glob(File.join(File.dirname(__FILE__), '..', 'config', 'locales', '*.yml'))
|
55
|
+
I18n.reload! if Rails.env == 'development' rescue nil
|
@@ -113,7 +113,7 @@ module LucidWorks
|
|
113
113
|
|
114
114
|
class_eval <<-EOF, __FILE__, __LINE__ + 1
|
115
115
|
def #{resource}
|
116
|
-
@#{resource}_association ||= HasOne.new(self, #{resource_class_name}, #{options.to_s})
|
116
|
+
@#{resource}_association ||= Associations::HasOne.new(self, #{resource_class_name}, #{options.to_s})
|
117
117
|
end
|
118
118
|
|
119
119
|
def #{resource}!
|
@@ -137,7 +137,7 @@ module LucidWorks
|
|
137
137
|
|
138
138
|
class_eval <<-EOF, __FILE__, __LINE__ + 1
|
139
139
|
def #{resources}(options={})
|
140
|
-
@#{resources}_association ||= HasMany.new(self, #{resource_class_name}, #{options.to_s})
|
140
|
+
@#{resources}_association ||= Associations::HasMany.new(self, #{resource_class_name}, #{options.to_s})
|
141
141
|
@#{resources}_association.remember_find_options(options) unless options.empty?
|
142
142
|
@#{resources}_association
|
143
143
|
end
|
data/lib/lucid_works/base.rb
CHANGED
@@ -66,7 +66,7 @@ module LucidWorks
|
|
66
66
|
# end
|
67
67
|
|
68
68
|
def schema(&block)
|
69
|
-
@schema ||= Schema.new
|
69
|
+
@schema ||= LucidWorks::Schema.new
|
70
70
|
if block_given?
|
71
71
|
@schema.instance_eval(&block)
|
72
72
|
@schema.create_accessors_for_attributes(self)
|
@@ -205,7 +205,7 @@ module LucidWorks
|
|
205
205
|
# [{"history":[...history_models...],"id":372},{"history":[...history_models...],"id":371}]
|
206
206
|
JSON.parse(raw_response).each do |group_of_targets|
|
207
207
|
owner_id = group_of_targets['id']
|
208
|
-
owner = results_array.detect { |result| result.id == owner_id }
|
208
|
+
owner = results_array.detect { |result| result.id == owner_id.to_i }
|
209
209
|
targets = group_of_targets[target_name].collect do |target_attrs|
|
210
210
|
target_class.new(target_attrs.merge(:parent => owner, :persisted => true))
|
211
211
|
end
|
@@ -28,16 +28,16 @@ module LucidWorks
|
|
28
28
|
unless @rsolr
|
29
29
|
server_uri = self.server.host
|
30
30
|
@path_prefix = URI.parse(server_uri).path # The API key
|
31
|
-
@rsolr = RSolr.connect :url => server_uri.dup
|
31
|
+
@rsolr = RSolr::Ext.connect :url => server_uri.dup
|
32
32
|
end
|
33
33
|
@rsolr
|
34
34
|
end
|
35
35
|
|
36
36
|
# Perform a Solr search using RSolr
|
37
|
-
def search(search_params={}
|
38
|
-
|
39
|
-
|
40
|
-
resp = rsolr.
|
37
|
+
def search(search_params={})
|
38
|
+
search_params[:page] ||= 1
|
39
|
+
search_params[:per_page] ||= 10
|
40
|
+
resp = rsolr.find "#{@path_prefix}/solr/#{name}/select", search_params
|
41
41
|
if search_params[:wt] == :xml
|
42
42
|
data = Nokogiri.XML(resp)
|
43
43
|
raise "search received bad XML" unless data.root
|
data/lib/lucid_works/field.rb
CHANGED
@@ -3,6 +3,21 @@ module LucidWorks
|
|
3
3
|
class Field < Base
|
4
4
|
belongs_to :collection
|
5
5
|
|
6
|
+
schema do
|
7
|
+
attribute :name, :string, :primary_key => true, :omit_during_update => true
|
8
|
+
attribute :editable, :boolean, :omit_during_update => true
|
9
|
+
attributes :indexed, :stored, :facet, :include_in_results,
|
10
|
+
:search_by_default, :highlight, :multi_valued,
|
11
|
+
:term_vectors, :omit_tf,
|
12
|
+
:use_for_deduplication, :synonym_expansion,
|
13
|
+
:index_for_spellcheck, :index_for_autocomplete,
|
14
|
+
:query_time_stopword_handling,
|
15
|
+
:use_in_find_similar,
|
16
|
+
:type => :boolean
|
17
|
+
attribute :default_boost, :integer
|
18
|
+
attributes :field_type, :short_field_boost, :term_vectors, :default_value, :copy_fields, :type => :string
|
19
|
+
end
|
20
|
+
|
6
21
|
TYPES = [
|
7
22
|
'string',
|
8
23
|
'boolean',
|
data/lib/lucid_works/version.rb
CHANGED
data/lucid_works.gemspec
CHANGED
@@ -317,16 +317,16 @@ describe LucidWorks::Collection do
|
|
317
317
|
mock_server = double('server', :host => 'http://fake-solr-host.com/fake_access_path')
|
318
318
|
@collection.stub(:server) { mock_server }
|
319
319
|
@mock_rsolr_client = double("RSolr::Client")
|
320
|
-
RSolr.stub(:connect) { @mock_rsolr_client }
|
320
|
+
RSolr::Ext.stub(:connect) { @mock_rsolr_client }
|
321
321
|
end
|
322
322
|
|
323
|
-
it "should
|
324
|
-
@mock_rsolr_client.should_receive(:
|
325
|
-
.with(
|
326
|
-
:
|
323
|
+
it "should pass thru pagination variables" do
|
324
|
+
@mock_rsolr_client.should_receive(:find)
|
325
|
+
.with('/fake_access_path/solr/collection_to_search/select',
|
326
|
+
:q => 'fake_query', :wt => :ruby, :page => 33, :per_page => 44)
|
327
327
|
.and_return({})
|
328
328
|
|
329
|
-
@collection.search(
|
329
|
+
@collection.search(:q => 'fake_query', :wt => :ruby, :page => 33, :per_page => 44)
|
330
330
|
end
|
331
331
|
|
332
332
|
context "when requesting an XML response" do
|
@@ -335,16 +335,16 @@ describe LucidWorks::Collection do
|
|
335
335
|
end
|
336
336
|
|
337
337
|
it "should call RSolr.get to perform the search" do
|
338
|
-
@mock_rsolr_client.should_receive(:
|
339
|
-
.with(
|
340
|
-
:
|
338
|
+
@mock_rsolr_client.should_receive(:find)
|
339
|
+
.with('/fake_access_path/solr/collection_to_search/select',
|
340
|
+
:q => 'fake_query', :wt => :xml, :page => 1, :per_page => 10)
|
341
341
|
.and_return(@good_xml)
|
342
342
|
|
343
343
|
@collection.search(:q => 'fake_query', :wt => :xml)
|
344
344
|
end
|
345
345
|
|
346
346
|
it "should parse the XML results" do
|
347
|
-
@mock_rsolr_client.stub(:
|
347
|
+
@mock_rsolr_client.stub(:find) { @good_xml }
|
348
348
|
results = @collection.search(:q => 'fake_query', :wt => :xml)
|
349
349
|
results.should be_a(Nokogiri::XML::Document)
|
350
350
|
results.root.children.first.text.should == "FooBar"
|
@@ -297,7 +297,7 @@ describe LucidWorks::Datasource do
|
|
297
297
|
|
298
298
|
describe "#progress" do
|
299
299
|
before do
|
300
|
-
@datasource = LucidWorks::Datasource.
|
300
|
+
@datasource = LucidWorks::Datasource.create(
|
301
301
|
:collection => @collection,
|
302
302
|
:crawler => LucidWorks::Datasource::CRAWLERS['file'],
|
303
303
|
:type => 'file',
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: lucid_works
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.6.
|
5
|
+
version: 0.6.14
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Sam Pierson
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-
|
13
|
+
date: 2011-06-03 00:00:00 +01:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -69,7 +69,7 @@ dependencies:
|
|
69
69
|
type: :runtime
|
70
70
|
version_requirements: *id005
|
71
71
|
- !ruby/object:Gem::Dependency
|
72
|
-
name:
|
72
|
+
name: rsolr-ext
|
73
73
|
prerelease: false
|
74
74
|
requirement: &id006 !ruby/object:Gem::Requirement
|
75
75
|
none: false
|
@@ -79,6 +79,17 @@ dependencies:
|
|
79
79
|
version: "0"
|
80
80
|
type: :runtime
|
81
81
|
version_requirements: *id006
|
82
|
+
- !ruby/object:Gem::Dependency
|
83
|
+
name: nokogiri
|
84
|
+
prerelease: false
|
85
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
86
|
+
none: false
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: "0"
|
91
|
+
type: :runtime
|
92
|
+
version_requirements: *id007
|
82
93
|
description: Ruby wrapper for the LucidWorks REST API
|
83
94
|
email:
|
84
95
|
- sam.pierson@lucidimagination.com
|