elasticsearch-rails-dynamic-json-support 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e90128e9d7f2fba2eace315fe74fc64f5bae2697
4
- data.tar.gz: d3cc2b9c4a717af5a2e161e8de4ed57f94d8d089
3
+ metadata.gz: e92105a25788097c08f205783d49a2ca4ffc488d
4
+ data.tar.gz: 27ad97de60bfef4b595e836913799ebf5eba7592
5
5
  SHA512:
6
- metadata.gz: bdc56f2cff4774c20d42ec2f7b25fbd775a263ca2dd32f8d47665488e6c96b5e590343c1bbdfae4b7436b88d1667175258ca20621d13bbbfa1273fa47ecc228c
7
- data.tar.gz: 619d02707e0a92fcc7757506175171b9c83218c171e9a176c6f65b037e59b3aec6e8bb1e886ea9276d5c0efacd4771e903e9e7268d19751851903dc5f927d820
6
+ metadata.gz: 1de5aa05408a2f2bb3fc5d5a56669d77a24bb72a35a19c727d4390965e816b88694f62045fc7e1f12cf10eb19aac5061ad0e9af7405fefc138283a269f1704e4
7
+ data.tar.gz: 2c1ed2db427152286624d55d020c227f4175fe72fa9ab2f07c6f070052c88740a57e0d2905642e3a467b2a12525da886558944818c96e1a7f695ab7e3cb27426
data/README.md CHANGED
@@ -97,25 +97,25 @@ Example usage (which solves the 2 issues above) is as given below:
97
97
  end
98
98
  ```
99
99
 
100
- # Issues
100
+ # ToDos
101
101
 
102
- - Tests.. since I don't have time to write test case for this project yet.
103
- - Due to the `lazy-loading` of model in rails, you need to specifically specify
104
- the model in rails. Like in the `Review` class above, it's reference to
105
- `Article`
102
+ - [ ] Tests.. since I don't have time to write test case for this project yet.
103
+ - [ ] Due to the `lazy-loading` of model in rails, you need to specifically
104
+ specify the model in rails. Like in the `Review` class above, it's reference
105
+ to `Article` (to make sure that `Article` class is loaded before `Review`)
106
+ - [ ] Auto generation of mapping
106
107
 
107
- == Contributing to elasticsearch-rails-dynamic-json-support
108
+ # Contributing to elasticsearch-rails-dynamic-json-support
108
109
 
109
- * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
110
- * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
111
- * Fork the project.
112
- * Start a feature/bugfix branch.
113
- * Commit and push until you are happy with your contribution.
114
- * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
115
- * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
116
-
117
- == Copyright
118
-
119
- Copyright (c) 2016 Song Yangyu. See LICENSE.txt for
120
- further details.
110
+ - Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
111
+ - Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
112
+ - Fork the project.
113
+ - Start a feature/bugfix branch.
114
+ - Commit and push until you are happy with your contribution.
115
+ - Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
116
+ - Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
117
+
118
+ # Copyright
119
+
120
+ Copyright (c) 2016 Song Yangyu. See LICENSE.txt for further details.
121
121
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.4
1
+ 0.0.5
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: elasticsearch-rails-dynamic-json-support 0.0.4 ruby lib
5
+ # stub: elasticsearch-rails-dynamic-json-support 0.0.5 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "elasticsearch-rails-dynamic-json-support".freeze
9
- s.version = "0.0.4"
9
+ s.version = "0.0.5"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib".freeze]
13
13
  s.authors = ["Song Yangyu".freeze]
14
- s.date = "2016-08-30"
14
+ s.date = "2016-08-31"
15
15
  s.description = "Enhance elasticsearch-rails with `elasticsearch_json_changes` to translate the attribute changes into document updates".freeze
16
16
  s.email = "flyfy1@gmail.com".freeze
17
17
  s.extra_rdoc_files = [
@@ -41,7 +41,7 @@ module Elasticsearch
41
41
  class_methods do
42
42
 
43
43
  # attributes is a pair of <key, block>
44
- def es_register_attributes *attributes
44
+ def es_register_attrs *attributes
45
45
  hashed_attributes = attributes.extract_options!
46
46
 
47
47
  attributes.each do |k|
@@ -59,6 +59,9 @@ module Elasticsearch
59
59
  key_name = key_name.to_s
60
60
  return json_relationship_registry[key_name] unless blk
61
61
 
62
+ # If key_name has been defined, then fail fast
63
+ fail "json key_name has been already defined: #{key_name} for class #{self.name}" if json_relationship_registry[key_name]
64
+
62
65
  relationship_name = key_name unless relationship_name
63
66
  relationship_name = relationship_name.to_s
64
67
 
@@ -87,11 +90,19 @@ module Elasticsearch
87
90
 
88
91
  def to_indexed_json(record, options = {})
89
92
  result = {}
93
+ exclude_keys = options[:exclude_keys]
94
+ exclude_keys = [] unless exclude_keys
95
+ exclude_keys = exclude_keys.map(&:to_s)
96
+
90
97
  json_attribute_registry.each do |k, blk|
98
+ k = k.to_s
99
+ next if exclude_keys.include? k
91
100
  result[k] = blk[record]
92
101
  end
93
102
 
94
103
  json_relationship_registry.each do |k, actor|
104
+ k = k.to_s
105
+ next if exclude_keys.include? k
95
106
  result[k] = actor.to_json(record)
96
107
  end
97
108
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elasticsearch-rails-dynamic-json-support
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Song Yangyu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-30 00:00:00.000000000 Z
11
+ date: 2016-08-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: elasticsearch-rails