dilute 0.0.1 → 0.0.2

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/README.md CHANGED
@@ -29,6 +29,14 @@ define_type can some options: `server_url`, `index_name`, `type_name`
29
29
 
30
30
  define_type(server_url: "http://example.com/", index_name: "special_name", type_name: "something_else")
31
31
 
32
+ With a class set up you can:
33
+
34
+ note = Note.new({data: "whatever"})
35
+ note.save # Stored to ElasticSearch
36
+ Note.find(note.id) # fetches that stored record
37
+ Note.all # gets a bunch of notes
38
+ Note.all({}, 7) # gets noes, limited to 7 instead of the default 10.
39
+
32
40
  ## Contributing
33
41
 
34
42
  1. Fork it
@@ -33,7 +33,7 @@ module Dilute::Modelize
33
33
  if Kernel.const_defined? :Rails
34
34
  Rails.application.class.parent_name
35
35
  else
36
- "default_dilute_index_name"
36
+ "DefaultDiluteIndexName"
37
37
  end
38
38
  end
39
39
 
data/lib/dilute/type.rb CHANGED
@@ -18,11 +18,12 @@ class Dilute::Type
18
18
  end
19
19
 
20
20
  def index_name
21
- options[:index_name] # :qknt
21
+ # Ugly
22
+ index_name = "#{options[:index_name]}".gsub(/([A-Z])/) { "_#{$1.downcase}"}.sub(/\A_/,'')
22
23
  end
23
24
 
24
25
  def type_name
25
- options[:type_name] # :notes
26
+ options[:type_name]
26
27
  end
27
28
 
28
29
  def index
@@ -1,3 +1,3 @@
1
1
  module Dilute
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -44,4 +44,27 @@ describe Dilute::Modelize do
44
44
  true
45
45
  end
46
46
 
47
+ context "infering the index name" do
48
+ let(:dilute_class) do
49
+ Class.new do
50
+ include Dilute::Modelize
51
+ define_singleton_method :name do
52
+ "TestNameForDilute"
53
+ end
54
+
55
+ define_type do
56
+ attribute(:data).not_indexed
57
+ end
58
+ end
59
+ end
60
+
61
+ it "should save record" do
62
+ new_diluted.save
63
+ expect(new_diluted.attributes["_index"]).to eq "default_dilute_index_name"
64
+ expect(new_diluted.attributes["_type"]).to eq "test_name_for_dilutes"
65
+ end
66
+
67
+
68
+ end
69
+
47
70
  end
data/spec/spec_helper.rb CHANGED
@@ -21,6 +21,6 @@ require "dilute"
21
21
  def destroy_test_index!
22
22
  require "stretcher"
23
23
  server = Stretcher::Server.new("http://localhost:9200", log_level: :info)
24
- index = server.index("dilute_test_suite")
24
+ index = server.index("default_dilute_index_name")
25
25
  index.delete
26
26
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dilute
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -159,24 +159,19 @@ required_ruby_version: !ruby/object:Gem::Requirement
159
159
  - - ! '>='
160
160
  - !ruby/object:Gem::Version
161
161
  version: '0'
162
- segments:
163
- - 0
164
- hash: -1974874539562345975
165
162
  required_rubygems_version: !ruby/object:Gem::Requirement
166
163
  none: false
167
164
  requirements:
168
165
  - - ! '>='
169
166
  - !ruby/object:Gem::Version
170
167
  version: '0'
171
- segments:
172
- - 0
173
- hash: -1974874539562345975
174
168
  requirements: []
175
169
  rubyforge_project:
176
- rubygems_version: 1.8.25
170
+ rubygems_version: 1.8.23
177
171
  signing_key:
178
172
  specification_version: 3
179
173
  summary: An ActiveRecord-ish thing for using ElasticSearch through Stretcher.
180
174
  test_files:
181
175
  - spec/modelize_integration_spec.rb
182
176
  - spec/spec_helper.rb
177
+ has_rdoc: