solr_mapper 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +8 -2
- data/Rakefile +1 -1
- data/lib/solr_mapper.rb +1 -0
- data/lib/solr_mapper/solr_document.rb +8 -1
- data/solr_mapper.gemspec +1 -1
- data/spec/url_spec.rb +29 -0
- metadata +3 -3
data/README.rdoc
CHANGED
@@ -30,7 +30,14 @@ gem install solr_mapper
|
|
30
30
|
|
31
31
|
class Thing
|
32
32
|
include SolrDocument
|
33
|
-
|
33
|
+
|
34
|
+
# base urls can also be defined by rails environments
|
35
|
+
@base_url = {
|
36
|
+
:development => 'http://somehost/solr_thing',
|
37
|
+
:test => 'http://localhost:8080/solr_thing',
|
38
|
+
:production => 'http://somehost/solr_thing'
|
39
|
+
}
|
40
|
+
|
34
41
|
@per_page = 10
|
35
42
|
|
36
43
|
has_many :stuffs
|
@@ -89,7 +96,6 @@ gem install solr_mapper
|
|
89
96
|
# deletes reference and destroys stuff from index
|
90
97
|
Thing.find(2).stuffs.destroy(stuff)
|
91
98
|
|
92
|
-
|
93
99
|
== Copyright
|
94
100
|
|
95
101
|
Copyright 2010 The Skunkworx.
|
data/Rakefile
CHANGED
@@ -16,7 +16,7 @@ require 'rubygems'
|
|
16
16
|
require 'rake'
|
17
17
|
require 'echoe'
|
18
18
|
|
19
|
-
Echoe.new('solr_mapper', '0.1.
|
19
|
+
Echoe.new('solr_mapper', '0.1.6') do |p|
|
20
20
|
p.description = "Object Document Mapper for the Apache Foundation's Solr search platform"
|
21
21
|
p.url = "http://github.com/skunkworx/solr_mapper"
|
22
22
|
p.author = "Chris Umbel"
|
data/lib/solr_mapper.rb
CHANGED
@@ -47,7 +47,14 @@ module SolrMapper
|
|
47
47
|
qs = build_qs(opts)
|
48
48
|
qs = '?' + qs unless qs.empty?
|
49
49
|
|
50
|
-
|
50
|
+
if self.base_url.kind_of?(Hash) && ENV['RAILS_ENV']
|
51
|
+
self.base_url = ActiveSupport::HashWithIndifferentAccess.new(self.base_url) unless self.base_url.kind_of?(ActiveSupport::HashWithIndifferentAccess)
|
52
|
+
base = self.base_url[ENV['RAILS_ENV']]
|
53
|
+
else
|
54
|
+
base = base_url
|
55
|
+
end
|
56
|
+
|
57
|
+
URI::escape("#{base}/#{path}#{qs}")
|
51
58
|
end
|
52
59
|
|
53
60
|
# create a querystring from a hash
|
data/solr_mapper.gemspec
CHANGED
data/spec/url_spec.rb
CHANGED
@@ -32,5 +32,34 @@ describe SolrDocument do
|
|
32
32
|
Thing.build_url("update").should == "#{Thing.base_url}/update"
|
33
33
|
end
|
34
34
|
|
35
|
+
it "should build URLs accepting hashes for the environment" do
|
36
|
+
ENV['RAILS_ENV'] = 'test'
|
37
|
+
|
38
|
+
class AnotherThing
|
39
|
+
include SolrDocument
|
40
|
+
@base_url = {
|
41
|
+
:development => 'http://somehost/solr_thing',
|
42
|
+
:test => 'http://localhost:8080/solr_thing',
|
43
|
+
:production => 'http://somehost/solr_thing'
|
44
|
+
}
|
45
|
+
end
|
46
|
+
|
47
|
+
AnotherThing.build_url('select').should == 'http://localhost:8080/solr_thing/select'
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should build URLs accepting hashes for the environment via string keys" do
|
51
|
+
ENV['RAILS_ENV'] = 'test'
|
52
|
+
|
53
|
+
class AnotherThing
|
54
|
+
include SolrDocument
|
55
|
+
@base_url = {
|
56
|
+
'development' => 'http://somehost/solr_thing',
|
57
|
+
'test' => 'http://localhost:8080/solr_thing',
|
58
|
+
'production' => 'http://somehost/solr_thing'
|
59
|
+
}
|
60
|
+
end
|
61
|
+
|
62
|
+
AnotherThing.build_url('select').should == 'http://localhost:8080/solr_thing/select'
|
63
|
+
end
|
35
64
|
end
|
36
65
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solr_mapper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 6
|
10
|
+
version: 0.1.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Chris Umbel
|