elastic_record 0.10.2 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,165 @@
1
+ GNU LESSER GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+
9
+ This version of the GNU Lesser General Public License incorporates
10
+ the terms and conditions of version 3 of the GNU General Public
11
+ License, supplemented by the additional permissions listed below.
12
+
13
+ 0. Additional Definitions.
14
+
15
+ As used herein, "this License" refers to version 3 of the GNU Lesser
16
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
17
+ General Public License.
18
+
19
+ "The Library" refers to a covered work governed by this License,
20
+ other than an Application or a Combined Work as defined below.
21
+
22
+ An "Application" is any work that makes use of an interface provided
23
+ by the Library, but which is not otherwise based on the Library.
24
+ Defining a subclass of a class defined by the Library is deemed a mode
25
+ of using an interface provided by the Library.
26
+
27
+ A "Combined Work" is a work produced by combining or linking an
28
+ Application with the Library. The particular version of the Library
29
+ with which the Combined Work was made is also called the "Linked
30
+ Version".
31
+
32
+ The "Minimal Corresponding Source" for a Combined Work means the
33
+ Corresponding Source for the Combined Work, excluding any source code
34
+ for portions of the Combined Work that, considered in isolation, are
35
+ based on the Application, and not on the Linked Version.
36
+
37
+ The "Corresponding Application Code" for a Combined Work means the
38
+ object code and/or source code for the Application, including any data
39
+ and utility programs needed for reproducing the Combined Work from the
40
+ Application, but excluding the System Libraries of the Combined Work.
41
+
42
+ 1. Exception to Section 3 of the GNU GPL.
43
+
44
+ You may convey a covered work under sections 3 and 4 of this License
45
+ without being bound by section 3 of the GNU GPL.
46
+
47
+ 2. Conveying Modified Versions.
48
+
49
+ If you modify a copy of the Library, and, in your modifications, a
50
+ facility refers to a function or data to be supplied by an Application
51
+ that uses the facility (other than as an argument passed when the
52
+ facility is invoked), then you may convey a copy of the modified
53
+ version:
54
+
55
+ a) under this License, provided that you make a good faith effort to
56
+ ensure that, in the event an Application does not supply the
57
+ function or data, the facility still operates, and performs
58
+ whatever part of its purpose remains meaningful, or
59
+
60
+ b) under the GNU GPL, with none of the additional permissions of
61
+ this License applicable to that copy.
62
+
63
+ 3. Object Code Incorporating Material from Library Header Files.
64
+
65
+ The object code form of an Application may incorporate material from
66
+ a header file that is part of the Library. You may convey such object
67
+ code under terms of your choice, provided that, if the incorporated
68
+ material is not limited to numerical parameters, data structure
69
+ layouts and accessors, or small macros, inline functions and templates
70
+ (ten or fewer lines in length), you do both of the following:
71
+
72
+ a) Give prominent notice with each copy of the object code that the
73
+ Library is used in it and that the Library and its use are
74
+ covered by this License.
75
+
76
+ b) Accompany the object code with a copy of the GNU GPL and this license
77
+ document.
78
+
79
+ 4. Combined Works.
80
+
81
+ You may convey a Combined Work under terms of your choice that,
82
+ taken together, effectively do not restrict modification of the
83
+ portions of the Library contained in the Combined Work and reverse
84
+ engineering for debugging such modifications, if you also do each of
85
+ the following:
86
+
87
+ a) Give prominent notice with each copy of the Combined Work that
88
+ the Library is used in it and that the Library and its use are
89
+ covered by this License.
90
+
91
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
92
+ document.
93
+
94
+ c) For a Combined Work that displays copyright notices during
95
+ execution, include the copyright notice for the Library among
96
+ these notices, as well as a reference directing the user to the
97
+ copies of the GNU GPL and this license document.
98
+
99
+ d) Do one of the following:
100
+
101
+ 0) Convey the Minimal Corresponding Source under the terms of this
102
+ License, and the Corresponding Application Code in a form
103
+ suitable for, and under terms that permit, the user to
104
+ recombine or relink the Application with a modified version of
105
+ the Linked Version to produce a modified Combined Work, in the
106
+ manner specified by section 6 of the GNU GPL for conveying
107
+ Corresponding Source.
108
+
109
+ 1) Use a suitable shared library mechanism for linking with the
110
+ Library. A suitable mechanism is one that (a) uses at run time
111
+ a copy of the Library already present on the user's computer
112
+ system, and (b) will operate properly with a modified version
113
+ of the Library that is interface-compatible with the Linked
114
+ Version.
115
+
116
+ e) Provide Installation Information, but only if you would otherwise
117
+ be required to provide such information under section 6 of the
118
+ GNU GPL, and only to the extent that such information is
119
+ necessary to install and execute a modified version of the
120
+ Combined Work produced by recombining or relinking the
121
+ Application with a modified version of the Linked Version. (If
122
+ you use option 4d0, the Installation Information must accompany
123
+ the Minimal Corresponding Source and Corresponding Application
124
+ Code. If you use option 4d1, you must provide the Installation
125
+ Information in the manner specified by section 6 of the GNU GPL
126
+ for conveying Corresponding Source.)
127
+
128
+ 5. Combined Libraries.
129
+
130
+ You may place library facilities that are a work based on the
131
+ Library side by side in a single library together with other library
132
+ facilities that are not Applications and are not covered by this
133
+ License, and convey such a combined library under terms of your
134
+ choice, if you do both of the following:
135
+
136
+ a) Accompany the combined library with a copy of the same work based
137
+ on the Library, uncombined with any other library facilities,
138
+ conveyed under the terms of this License.
139
+
140
+ b) Give prominent notice with the combined library that part of it
141
+ is a work based on the Library, and explaining where to find the
142
+ accompanying uncombined form of the same work.
143
+
144
+ 6. Revised Versions of the GNU Lesser General Public License.
145
+
146
+ The Free Software Foundation may publish revised and/or new versions
147
+ of the GNU Lesser General Public License from time to time. Such new
148
+ versions will be similar in spirit to the present version, but may
149
+ differ in detail to address new problems or concerns.
150
+
151
+ Each version is given a distinguishing version number. If the
152
+ Library as you received it specifies that a certain numbered version
153
+ of the GNU Lesser General Public License "or any later version"
154
+ applies to it, you have the option of following the terms and
155
+ conditions either of that published version or of any later version
156
+ published by the Free Software Foundation. If the Library as you
157
+ received it does not specify a version number of the GNU Lesser
158
+ General Public License, you may choose any version of the GNU Lesser
159
+ General Public License ever published by the Free Software Foundation.
160
+
161
+ If the Library as you received it specifies that a proxy can decide
162
+ whether future versions of the GNU Lesser General Public License shall
163
+ apply, that proxy's public statement of acceptance of any version is
164
+ permanent authorization for you to choose that version for the
165
+ Library.
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'elastic_record'
5
- s.version = '0.10.2'
5
+ s.version = '0.11.0'
6
6
  s.summary = 'Use Elastic Search with your objects'
7
7
  s.description = 'Find your records with elastic search'
8
8
 
@@ -10,6 +10,7 @@ module ElasticRecord
10
10
  def create(index_name = new_index_name)
11
11
  connection.json_put "/#{index_name}"
12
12
  update_mapping(index_name)
13
+ update_settings(index_name)
13
14
  index_name
14
15
  end
15
16
 
@@ -53,6 +54,10 @@ module ElasticRecord
53
54
  connection.json_put "/#{index_name}/#{type}/_mapping", type => mapping
54
55
  end
55
56
 
57
+ def update_settings(index_name = alias_name)
58
+ connection.json_put "/#{index_name}/_settings", settings
59
+ end
60
+
56
61
  def refresh(index_name = alias_name)
57
62
  connection.json_post "/#{index_name}/_refresh"
58
63
  end
@@ -0,0 +1,13 @@
1
+ module ElasticRecord
2
+ class Index
3
+ module Settings
4
+ def settings=(mapping)
5
+ settings.deep_merge!(mapping)
6
+ end
7
+
8
+ def settings
9
+ @settings ||= {}
10
+ end
11
+ end
12
+ end
13
+ end
@@ -3,6 +3,7 @@ require 'elastic_record/index/documents'
3
3
  require 'elastic_record/index/manage'
4
4
  require 'elastic_record/index/mapping'
5
5
  require 'elastic_record/index/percolator'
6
+ require 'elastic_record/index/settings'
6
7
  require 'net/http'
7
8
 
8
9
  module ElasticRecord
@@ -11,6 +12,7 @@ module ElasticRecord
11
12
  include Manage
12
13
  include Mapping
13
14
  include Percolator
15
+ include Settings
14
16
  include Deferred
15
17
 
16
18
  attr_accessor :model
@@ -21,6 +23,9 @@ module ElasticRecord
21
23
  @disabled = false
22
24
  end
23
25
 
26
+ # def initialize_copy(other)
27
+ # end
28
+
24
29
  def alias_name
25
30
  @alias_name ||= model.base_class.model_name.collection
26
31
  end
@@ -9,6 +9,11 @@ module ElasticRecord
9
9
  end
10
10
 
11
11
  module ClassMethods
12
+ # def inherited(child)
13
+ # super
14
+ # child.elastic_index = elastic_index.dup
15
+ # end
16
+
12
17
  def elastic_connection
13
18
  @elastic_connection ||= ElasticRecord::Connection.new(ElasticRecord::Config.servers)
14
19
  end
@@ -28,6 +33,10 @@ module ElasticRecord
28
33
  def elastic_index
29
34
  @elastic_index ||= ElasticRecord::Index.new(self)
30
35
  end
36
+
37
+ def elastic_index=(index)
38
+ @elastic_index = index
39
+ end
31
40
  end
32
41
 
33
42
  def arelastic
@@ -10,7 +10,7 @@ class ElasticRecord::Index::ManageTest < MiniTest::Spec
10
10
  index.disable_deferring!
11
11
  index.delete_all
12
12
  end
13
-
13
+
14
14
  def test_create
15
15
  assert !index.exists?('widgets_foo')
16
16
 
@@ -45,6 +45,7 @@ class ElasticRecord::Index::ManageTest < MiniTest::Spec
45
45
  end
46
46
 
47
47
  private
48
+
48
49
  def index
49
50
  @index ||= Widget.elastic_index
50
51
  end
@@ -1,4 +1,15 @@
1
1
  require 'helper'
2
2
 
3
3
  class ElasticRecord::Index::MappingTest < MiniTest::Spec
4
+ def test_default_mapping
5
+ mapping = index.mapping
6
+
7
+ refute_nil mapping[:_source]
8
+ refute_nil mapping[:properties]
9
+ end
10
+
11
+ private
12
+ def index
13
+ @index ||= ElasticRecord::Index.new(Widget)
14
+ end
4
15
  end
@@ -0,0 +1,14 @@
1
+ require 'helper'
2
+
3
+ class ElasticRecord::Index::SettingsTest < MiniTest::Spec
4
+ def test_default_settings
5
+ expected = {}
6
+ assert_equal expected, ElasticRecord::Index.new(Widget).settings
7
+ end
8
+
9
+ private
10
+
11
+ def index
12
+ @index ||= ElasticRecord::Index.new(Widget)
13
+ end
14
+ end
@@ -1,6 +1,9 @@
1
1
  require 'helper'
2
2
 
3
3
  class ElasticRecord::ModelTest < MiniTest::Spec
4
+ class InheritedModel < Widget
5
+ end
6
+
4
7
  # def test_elastic_connection
5
8
  # connection = Widget.elastic_connection
6
9
  #
@@ -20,4 +23,8 @@ class ElasticRecord::ModelTest < MiniTest::Spec
20
23
 
21
24
  assert_equal Widget, index.model
22
25
  end
26
+
27
+ # def test_elastic_index_inheritence
28
+ # refute_equal Widget.elastic_index.object_id, InheritedModel.elastic_index.object_id
29
+ # end
23
30
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elastic_record
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.2
4
+ version: 0.11.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-04 00:00:00.000000000 Z
12
+ date: 2012-12-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: arelastic
@@ -53,7 +53,7 @@ files:
53
53
  - .gitignore
54
54
  - .travis.yml
55
55
  - Gemfile
56
- - MIT-LICENSE
56
+ - LICENSE
57
57
  - README.rdoc
58
58
  - Rakefile
59
59
  - elastic_record.gemspec
@@ -67,6 +67,7 @@ files:
67
67
  - lib/elastic_record/index/manage.rb
68
68
  - lib/elastic_record/index/mapping.rb
69
69
  - lib/elastic_record/index/percolator.rb
70
+ - lib/elastic_record/index/settings.rb
70
71
  - lib/elastic_record/log_subscriber.rb
71
72
  - lib/elastic_record/lucene.rb
72
73
  - lib/elastic_record/model.rb
@@ -96,6 +97,7 @@ files:
96
97
  - test/elastic_record/index/manage_test.rb
97
98
  - test/elastic_record/index/mapping_test.rb
98
99
  - test/elastic_record/index/percolator_test.rb
100
+ - test/elastic_record/index/settings_test.rb
99
101
  - test/elastic_record/index_test.rb
100
102
  - test/elastic_record/log_subscriber_test.rb
101
103
  - test/elastic_record/lucene_test.rb
data/MIT-LICENSE DELETED
@@ -1,20 +0,0 @@
1
- Copyright (c) 2012 Matthew Higgins
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.