oedipus-dm 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -24,7 +24,7 @@ realtime indexes and multi-dimensional faceted search via ruby.
24
24
 
25
25
  - Sphinx >= 2.0.2
26
26
  - Ruby >= 1.9
27
- - Mysql client development libraries
27
+ - Mysql client development libraries >= 4.1
28
28
 
29
29
  ## Installation
30
30
 
@@ -46,7 +46,7 @@ interface is not supported.
46
46
  require "oedipus-dm"
47
47
 
48
48
  Oedipus::DataMapper.configure do |config|
49
- config.host = "localhost"
49
+ config.host = "127.0.0.1"
50
50
  config.port = 9306
51
51
  end
52
52
  ```
@@ -55,9 +55,13 @@ In Rails you can do this in an initializer for example. If you prefer not to
55
55
  use a global configuration, it is possible to specify how to connect on a
56
56
  per-index basis instead.
57
57
 
58
+ You should use '127.0.0.1' instead of 'localhost', in order to prevent the
59
+ MySQL library from using a UNIX socket, which Sphinx doesn't currently
60
+ support.
61
+
58
62
  ### Defining an Index
59
63
 
60
- The most basic way to connect sphinx index with your model is to define a
64
+ The most basic way to connect a sphinx index with your model is to define a
61
65
  `.index` method on the model itself. Oedipus doesn't directly mix behaviour
62
66
  into your models by default, as experience suggests this makes testing in
63
67
  isolation more difficult (note that you can easily have a standalone `Index`
@@ -98,7 +102,7 @@ connection settings, pass the `:connection` option.
98
102
  def self.index
99
103
  @index ||= Oedipus::DataMapper::Index.new(
100
104
  self,
101
- connection: Oedipus.connect("localhost:9306")
105
+ connection: Oedipus.connect("127.0.0.1:9306")
102
106
  )
103
107
  end
104
108
  ```
@@ -108,15 +112,17 @@ end
108
112
  By default, the only field that Oedipus will map with your model is the `:id`
109
113
  attribute, which it will try to map with the key of your model. This
110
114
  configuration will work fine for non-realtime indexes in most cases, but it
111
- is not optimized for many cases.
115
+ is not optimal when you have attributes in your index that can be mapped with
116
+ your model.
112
117
 
113
118
  When Oedipus finds search results, it pulls out all the attributes defined in
114
119
  your index, then tries to map them to instances of your model. Mapping `:id`
115
120
  alone means that DataMapper will load all of your resources from the database
116
121
  when you first try to access any other attribute.
117
122
 
118
- Chances are, you have some attributes in your index that can be mapped to your
119
- model, avoiding the extra database hit. You can add these mappings like so.
123
+ Chances are, you have some (or lots of) attributes in your index that can be
124
+ mapped to your model, avoiding the extra database hit. You can add these
125
+ mappings like so.
120
126
 
121
127
  ``` ruby
122
128
  Oedipus::DataMapper::Index.new(self) do |idx|
@@ -125,10 +131,12 @@ Oedipus::DataMapper::Index.new(self) do |idx|
125
131
  end
126
132
  ```
127
133
 
128
- `Index#map` takes the name of the attribute in your index. By default it will
129
- map 1:1 with a property of the same name in your model. If the property name
130
- in your model differs from that in the index, you may specify that with the
131
- `:with` option, as you see with the `:views` attribute above.
134
+ The `#map` method takes the name of the attribute in your index. By default
135
+ it will map 1:1 with a property of the same name in your model. If the
136
+ property name in your model differs from that in the index, you may specify
137
+ that with the `:with` option, as you see with the `:views` attribute above.
138
+
139
+ You may also map arbitrary methods in your model— Oedipus will figure this out.
132
140
 
133
141
  Now when Oedipus loads your search results, they will be loaded with `:id`,
134
142
  `:user_id` and `:view_count` pre-loaded.
@@ -9,6 +9,6 @@
9
9
 
10
10
  module Oedipus
11
11
  module DataMapper
12
- VERSION = "0.0.5"
12
+ VERSION = "0.0.6"
13
13
  end
14
14
  end
@@ -31,14 +31,14 @@ module Oedipus
31
31
  #
32
32
  # @return [Connection]
33
33
  def connection
34
- @connection ||= Connection.new(host: config.host, port: config.port)
34
+ @connection ||= Connection.new(host: config.host, port: config.port, verify: config.verify)
35
35
  end
36
36
 
37
37
  # Returns the configuration options.
38
38
  #
39
39
  # @return [Struct<host, port>]
40
40
  def config
41
- @config ||= Struct.new(:host, :port).new("localhost", 9306)
41
+ @config ||= Struct.new(:host, :port, :verify).new("localhost", 9306, true)
42
42
  end
43
43
  end
44
44
  end
@@ -1,25 +1,15 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe Oedipus::DataMapper::Index do
4
- include Oedipus::RSpec::TestHarness
5
-
6
- before(:all) do
7
- set_data_dir File.expand_path("../../data", __FILE__)
8
- set_searchd ENV["SEARCHD"]
9
- start_searchd
10
- end
11
-
12
- after(:all) { stop_searchd }
4
+ include_context "oedipus test rig"
5
+ include_context "oedipus posts_rt"
13
6
 
14
7
  before(:each) do
15
8
  Post.destroy!
16
9
  User.destroy!
17
- empty_indexes
18
10
  end
19
11
 
20
- let(:conn) do
21
- Oedipus::Connection.new(searchd_host)
22
- end
12
+ let(:conn) { connection }
23
13
 
24
14
  let(:index) do
25
15
  Oedipus::DataMapper::Index.new(Post, name: :posts_rt, connection: conn) do |idx|
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require "rspec"
2
2
  require "oedipus-dm"
3
- require "oedipus/rspec/test_harness"
3
+ require "oedipus/rspec/test_rig"
4
4
  require "dm-pager"
5
5
 
6
6
  Dir[File.expand_path("../support/**/*.rb", __FILE__)].each { |f| require f }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oedipus-dm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-07 00:00:00.000000000 Z
12
+ date: 2012-05-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: oedipus
16
- requirement: &6993440 !ruby/object:Gem::Requirement
16
+ requirement: &14190380 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 0.0.5
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *6993440
24
+ version_requirements: *14190380
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: dm-core
27
- requirement: &6989940 !ruby/object:Gem::Requirement
27
+ requirement: &14196800 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '1.2'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *6989940
35
+ version_requirements: *14196800
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rake
38
- requirement: &7004880 !ruby/object:Gem::Requirement
38
+ requirement: &14207400 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *7004880
46
+ version_requirements: *14207400
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rspec
49
- requirement: &7002480 !ruby/object:Gem::Requirement
49
+ requirement: &14217140 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *7002480
57
+ version_requirements: *14217140
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: dm-pager
60
- requirement: &7000960 !ruby/object:Gem::Requirement
60
+ requirement: &14214160 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,7 +65,7 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *7000960
68
+ version_requirements: *14214160
69
69
  description: ! '== DataMapper Integration for Oedipus
70
70
 
71
71
 
@@ -117,7 +117,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
117
117
  version: '0'
118
118
  segments:
119
119
  - 0
120
- hash: -2768834143295324576
120
+ hash: -1092648085512523153
121
121
  required_rubygems_version: !ruby/object:Gem::Requirement
122
122
  none: false
123
123
  requirements:
@@ -126,7 +126,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
126
126
  version: '0'
127
127
  segments:
128
128
  - 0
129
- hash: -2768834143295324576
129
+ hash: -1092648085512523153
130
130
  requirements: []
131
131
  rubyforge_project:
132
132
  rubygems_version: 1.8.11