jakewendt-active_record_sunspotter 0.0.12 → 4.0.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.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1cbf38085cf568de0799a1f8ce7ebb52545b26ff
|
4
|
+
data.tar.gz: ce140ffcd58a91c4eb55e5a4b8a2861e723bb8f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 84df83b33a7dcd53314a4561054c45d46007b879dbcd7e2867f1fd2cf09cdc3ea3502decf9fdedf8d9d83bf2f808a0457b1be5d40b7d1ef2d8be0336fe090cff
|
7
|
+
data.tar.gz: 47eba5dffe54913b9f5b99b5974f23a87622913f67f9a61e11f01f44ede4a8754ce2f4feb809fc3d625ef7f7936e6f4dd9e9ab101028ce6bb5b90134cdfee111
|
@@ -10,9 +10,20 @@ require 'active_record_sunspotter/search_sunspot_for'
|
|
10
10
|
require 'active_record_sunspotter/sunspot_helper'
|
11
11
|
|
12
12
|
|
13
|
+
# sunspot_rails_2.0.0 uses methods that are deprecated in rails 4
|
14
|
+
# sunspot_rails_2.1.0 (or sunspot_2.1.0 or sunspot_solr_2.1.0) won't compile (java issues)
|
15
|
+
# copied in this 1 file
|
16
|
+
require 'active_record_sunspotter/sunspot_rails_2.1.0_sunspot_rails_adapters'
|
17
|
+
|
18
|
+
|
13
19
|
if defined?(Rails)
|
14
20
|
require 'active_record_sunspotter/rails/engine'
|
15
21
|
require 'active_record_sunspotter/rails/railtie'
|
16
22
|
|
23
|
+
# sunspot_solr-2.0.0 uses "Rails::VERSION::MAJOR == 3" which stops tasks from loading.
|
24
|
+
#if defined?(Rails::Railtie)
|
25
|
+
require 'sunspot/solr/railtie'
|
26
|
+
#end
|
27
|
+
|
17
28
|
ActionController::Base.append_view_path( File.join(File.dirname(__FILE__), '../vendor/views'))
|
18
29
|
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
module Sunspot #:nodoc:
|
2
|
+
module Rails #:nodoc:
|
3
|
+
#
|
4
|
+
# This module provides Sunspot Adapter implementations for ActiveRecord
|
5
|
+
# models.
|
6
|
+
#
|
7
|
+
module Adapters
|
8
|
+
class ActiveRecordInstanceAdapter < Sunspot::Adapters::InstanceAdapter
|
9
|
+
#
|
10
|
+
# Return the primary key for the adapted instance
|
11
|
+
#
|
12
|
+
# ==== Returns
|
13
|
+
#
|
14
|
+
# Integer:: Database ID of model
|
15
|
+
#
|
16
|
+
def id
|
17
|
+
@instance.id
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
class ActiveRecordDataAccessor < Sunspot::Adapters::DataAccessor
|
22
|
+
# options for the find
|
23
|
+
attr_accessor :include
|
24
|
+
attr_reader :select
|
25
|
+
|
26
|
+
def initialize(clazz)
|
27
|
+
super(clazz)
|
28
|
+
@inherited_attributes = [:include, :select]
|
29
|
+
end
|
30
|
+
|
31
|
+
#
|
32
|
+
# Set the fields to select from the database. This will be passed
|
33
|
+
# to ActiveRecord.
|
34
|
+
#
|
35
|
+
# ==== Parameters
|
36
|
+
#
|
37
|
+
# value<Mixed>:: String of comma-separated columns or array of columns
|
38
|
+
#
|
39
|
+
def select=(value)
|
40
|
+
value = value.join(', ') if value.respond_to?(:join)
|
41
|
+
@select = value
|
42
|
+
end
|
43
|
+
|
44
|
+
#
|
45
|
+
# Get one ActiveRecord instance out of the database by ID
|
46
|
+
#
|
47
|
+
# ==== Parameters
|
48
|
+
#
|
49
|
+
# id<String>:: Database ID of model to retreive
|
50
|
+
#
|
51
|
+
# ==== Returns
|
52
|
+
#
|
53
|
+
# ActiveRecord::Base:: ActiveRecord model
|
54
|
+
#
|
55
|
+
def load(id)
|
56
|
+
@clazz.where(@clazz.primary_key => id).merge(scope_for_load).first
|
57
|
+
end
|
58
|
+
|
59
|
+
#
|
60
|
+
# Get a collection of ActiveRecord instances out of the database by ID
|
61
|
+
#
|
62
|
+
# ==== Parameters
|
63
|
+
#
|
64
|
+
# ids<Array>:: Database IDs of models to retrieve
|
65
|
+
#
|
66
|
+
# ==== Returns
|
67
|
+
#
|
68
|
+
# Array:: Collection of ActiveRecord models
|
69
|
+
#
|
70
|
+
def load_all(ids)
|
71
|
+
@clazz.where(@clazz.primary_key => ids).merge(scope_for_load)
|
72
|
+
end
|
73
|
+
|
74
|
+
private
|
75
|
+
|
76
|
+
def scope_for_load
|
77
|
+
scope = relation
|
78
|
+
scope = scope.includes(@include) if @include.present?
|
79
|
+
scope = scope.select(@select) if @select.present?
|
80
|
+
scope
|
81
|
+
end
|
82
|
+
|
83
|
+
# COMPATIBILITY: Rails 4 has deprecated the 'scoped' method in favour of 'all'
|
84
|
+
def relation
|
85
|
+
::Rails.version >= '4' ? @clazz.all : @clazz.scoped
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jakewendt-active_record_sunspotter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 4.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- George 'Jake' Wendt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sunspot_rails
|
@@ -42,14 +42,14 @@ dependencies:
|
|
42
42
|
name: progress_bar
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
description: active_record_sunspotter
|
@@ -65,6 +65,7 @@ files:
|
|
65
65
|
- lib/active_record_sunspotter/search_sunspot_for.rb
|
66
66
|
- lib/active_record_sunspotter/sunspot_column.rb
|
67
67
|
- lib/active_record_sunspotter/sunspot_helper.rb
|
68
|
+
- lib/active_record_sunspotter/sunspot_rails_2.1.0_sunspot_rails_adapters.rb
|
68
69
|
- lib/active_record_sunspotter/sunspot_rails_server.rb
|
69
70
|
- lib/active_record_sunspotter/sunspotability.rb
|
70
71
|
- lib/jakewendt-active_record_sunspotter.rb
|
@@ -93,12 +94,12 @@ require_paths:
|
|
93
94
|
- lib
|
94
95
|
required_ruby_version: !ruby/object:Gem::Requirement
|
95
96
|
requirements:
|
96
|
-
- -
|
97
|
+
- - ">="
|
97
98
|
- !ruby/object:Gem::Version
|
98
99
|
version: '0'
|
99
100
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
101
|
requirements:
|
101
|
-
- -
|
102
|
+
- - ">="
|
102
103
|
- !ruby/object:Gem::Version
|
103
104
|
version: '0'
|
104
105
|
requirements: []
|