elastics-legacy 1.0.5
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/LICENSE +20 -0
- data/README.md +14 -0
- data/VERSION +1 -0
- data/elastics-legacy.gemspec +19 -0
- data/lib/elastics/deprecation.rb +214 -0
- data/lib/elastics-legacy.rb +4 -0
- data/lib/flex/rails.rb +1 -0
- metadata +70 -0
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2012-2013 by Domizio Demichelis
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# elastics-legacy
|
2
|
+
|
3
|
+
[](http://badge.fury.io/rb/elastics-legacy)
|
4
|
+
|
5
|
+
Provides out-of-the box legacy compatibility (with flex and old versions). Use it for a smooth migration to the new gems. Read the [How to migrate from Flex 0.x](http://elastics.github.io/elastics/doc/7-Tutorials/2-Migrate-from-0.x.html) tutorial.
|
6
|
+
|
7
|
+
## Credits
|
8
|
+
|
9
|
+
Special thanks for their sponsorship to [Escalate Media](http://www.escalatemedia.com) and [Barquin International](http://www.barquin.com).
|
10
|
+
|
11
|
+
## Copyright
|
12
|
+
|
13
|
+
Copyright (c) 2012-2013 by [Domizio Demichelis](mailto://dd.nexus@gmail.com)<br>
|
14
|
+
See [LICENSE](https://github.com/elastics/elastics/blob/master/elastics-scopes/LICENSE) for details.
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.0.5
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'date'
|
2
|
+
version = File.read(File.expand_path('../VERSION', __FILE__)).strip
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = 'elastics-legacy'
|
6
|
+
s.summary = 'Adds legacy compatibility and deprecations warnings.'
|
7
|
+
s.description = 'Provides out-of-the box legacy compatibility (with flex and old versions). Use it for a smooth migration to the new gems.'
|
8
|
+
s.homepage = 'http://elastics.github.io/elastics'
|
9
|
+
s.authors = ["Domizio Demichelis"]
|
10
|
+
s.email = 'dd.nexus@gmail.com'
|
11
|
+
s.files = `git ls-files -z`.split("\0")
|
12
|
+
s.version = version
|
13
|
+
s.date = Date.today.to_s
|
14
|
+
s.required_rubygems_version = ">= 1.3.6"
|
15
|
+
s.rdoc_options = %w[--charset=UTF-8]
|
16
|
+
s.license = 'MIT'
|
17
|
+
|
18
|
+
s.add_runtime_dependency 'elastics-client', version
|
19
|
+
end
|
@@ -0,0 +1,214 @@
|
|
1
|
+
module Elastics
|
2
|
+
|
3
|
+
module Deprecation
|
4
|
+
|
5
|
+
extend self
|
6
|
+
|
7
|
+
def warn(old, new, called=1)
|
8
|
+
message = "#{old} is deprecated in favour of #{new}, and will be removed in a next version. Please, read the upgrade notes at http://elastics.github.io/elastics/doc/7-Tutorials/2-Migrate-from-0.x.html. "
|
9
|
+
message << "(called at: #{caller[called]})" if called
|
10
|
+
Conf.logger.warn message
|
11
|
+
end
|
12
|
+
|
13
|
+
module Module
|
14
|
+
def extended(obj)
|
15
|
+
Deprecation.warn(self, self::NEW_MODULE, 2)
|
16
|
+
obj.extend self::NEW_MODULE
|
17
|
+
end
|
18
|
+
def included(base)
|
19
|
+
Deprecation.warn(self, self::NEW_MODULE, 2)
|
20
|
+
base.send :include, self::NEW_MODULE
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
### Deprecation of Flex methods ###
|
27
|
+
|
28
|
+
def info(*names)
|
29
|
+
Deprecation.warn 'Flex.info', 'Elastics.doc'
|
30
|
+
doc *names
|
31
|
+
end
|
32
|
+
|
33
|
+
def process_bulk(options={})
|
34
|
+
Deprecation.warn 'Flex.process_bulk(:collection => collection)', 'Elastics.post_bulk_collection(collection, options)'
|
35
|
+
post_bulk_collection(options.delete(:collection), options)
|
36
|
+
end
|
37
|
+
|
38
|
+
def import_collection(collection, options={})
|
39
|
+
Deprecation.warn 'Flex.import_collection', 'Elastics.post_bulk_collection'
|
40
|
+
post_bulk_collection(collection, options.merge(:action => 'index'))
|
41
|
+
end
|
42
|
+
|
43
|
+
def delete_collection(collection, options={})
|
44
|
+
Deprecation.warn 'Flex.delete_collection(collection)', 'Elastics.post_bulk_collection(collection, :action => "delete")'
|
45
|
+
post_bulk_collection(collection, options.merge(:action => 'delete'))
|
46
|
+
end
|
47
|
+
|
48
|
+
def bulk(*vars)
|
49
|
+
Deprecation.warn 'Flex.bulk(:lines => lines_bulk_string)', 'Elastics.post_bulk_string(:bulk_string => lines_bulk_string)'
|
50
|
+
vars = Vars.new(*vars)
|
51
|
+
post_bulk_string(:bulk_string => vars[:lines])
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
### Deprecation of Configuration methods ###
|
56
|
+
|
57
|
+
Configuration.instance_eval do
|
58
|
+
# temprary deprecation warnings
|
59
|
+
def base_uri
|
60
|
+
Deprecation.warn 'Flex::Configuration.base_uri', 'Elastics::Configuration.http_client.base_uri'
|
61
|
+
http_client.base_uri
|
62
|
+
end
|
63
|
+
def base_uri=(val)
|
64
|
+
Deprecation.warn 'Flex::Configuration.base_uri=', 'Elastics::Configuration.http_client.base_uri='
|
65
|
+
http_client.base_uri = val
|
66
|
+
end
|
67
|
+
def http_client_options
|
68
|
+
Deprecation.warn 'Flex::Configuration.http_client_options', 'Elastics::Configuration.http_client.options'
|
69
|
+
http_client.options
|
70
|
+
end
|
71
|
+
def http_client_options=(val)
|
72
|
+
Deprecation.warn 'Flex::Configuration.http_client_options=', 'Elastics::Configuration.http_client.options='
|
73
|
+
http_client.options = val
|
74
|
+
end
|
75
|
+
def raise_proc
|
76
|
+
Deprecation.warn 'Flex::Configuration.raise_proc', 'Elastics::Configuration.http_client.raise_proc'
|
77
|
+
http_client.raise_proc
|
78
|
+
end
|
79
|
+
def raise_proc=(val)
|
80
|
+
Deprecation.warn 'Flex::Configuration.raise_proc=', 'Elastics::Configuration.http_client.raise_proc='
|
81
|
+
http_client.raise_proc = val
|
82
|
+
end
|
83
|
+
def flex_models
|
84
|
+
elastics_models
|
85
|
+
end
|
86
|
+
def flex_active_models
|
87
|
+
elastics_active_models
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
module Rails
|
92
|
+
class Logger
|
93
|
+
def log_to_stdout
|
94
|
+
Deprecation.warn 'Flex::Configuration.logger.log_to_stdout', 'Elastics::Configuration.logger.log_to_stderr'
|
95
|
+
log_to_stderr
|
96
|
+
end
|
97
|
+
def log_to_stdout=(val)
|
98
|
+
Deprecation.warn 'Flex::Configuration.logger.log_to_stdout=', 'Elastics::Configuration.logger.log_to_stderr='
|
99
|
+
self.log_to_stderr = val
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
class Variables
|
105
|
+
def add(*hashes)
|
106
|
+
Deprecation.warn 'Flex::Variables#add', 'Elastics::Variables#deep_merge!'
|
107
|
+
replace deep_merge(*hashes)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
|
112
|
+
module Struct::Mergeable
|
113
|
+
def add(*hashes)
|
114
|
+
Deprecation.warn 'Flex::Variables#add', 'Variables#deep_merge!'
|
115
|
+
replace deep_merge(*hashes)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
|
120
|
+
module Loader
|
121
|
+
NEW_MODULE = Templates
|
122
|
+
extend Deprecation::Module
|
123
|
+
end
|
124
|
+
|
125
|
+
|
126
|
+
module ClassProxy::Loader
|
127
|
+
NEW_MODULE = ClassProxy::Templates
|
128
|
+
extend Deprecation::Module
|
129
|
+
end
|
130
|
+
|
131
|
+
|
132
|
+
module ClassProxy::Templates
|
133
|
+
module Doc
|
134
|
+
def info(*names)
|
135
|
+
Deprecation.warn 'flex.info', 'elastics.doc'
|
136
|
+
doc *names
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
|
142
|
+
module Result::Collection
|
143
|
+
NEW_MODULE = Struct::Paginable
|
144
|
+
extend Deprecation::Module
|
145
|
+
end
|
146
|
+
|
147
|
+
|
148
|
+
module Model
|
149
|
+
def self.included(base)
|
150
|
+
if defined?(Elastics::ModelIndexer)
|
151
|
+
Deprecation.warn 'Flex::Model', 'Elastics::ModelIndexer'
|
152
|
+
base.send :include, Elastics::ModelIndexer
|
153
|
+
else
|
154
|
+
raise NotImplementedError, %(Elastics does not include "Flex::Model" anymore. Please, require the "elastics-models" gem, and include "Elastics::ModelIndexer" instead.)
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
|
160
|
+
module RelatedModel
|
161
|
+
def self.included(base)
|
162
|
+
if defined?(Elastics::ModelSyncer)
|
163
|
+
Deprecation.warn 'Flex::RelatedModel', 'Elastics::ModelSyncer'
|
164
|
+
base.send :include, Elastics::ModelSyncer
|
165
|
+
else
|
166
|
+
raise NotImplementedError, %(Elastics does not include "Flex::RelatedModel" anymore. Please, require the "elastics-models" gem, and include "Elastics::ModelSyncer" instead.)
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
%w[Templates ModelSyncer ModelIndexer ActiveModel].each do |mod|
|
172
|
+
module_eval <<-ruby
|
173
|
+
if defined?(#{mod})
|
174
|
+
module #{mod}
|
175
|
+
class << self
|
176
|
+
alias_method :original_included, :included
|
177
|
+
def included(base)
|
178
|
+
original_included(base)
|
179
|
+
|
180
|
+
def base.flex
|
181
|
+
elastics
|
182
|
+
end
|
183
|
+
|
184
|
+
def base.elastics_result(result)
|
185
|
+
respond_to?(:flex_result) ? flex_result(result) : result
|
186
|
+
end
|
187
|
+
|
188
|
+
end
|
189
|
+
end
|
190
|
+
alias_method :flex, :elastics if method_defined?(:elastics)
|
191
|
+
end
|
192
|
+
end
|
193
|
+
ruby
|
194
|
+
end
|
195
|
+
|
196
|
+
module Legacy
|
197
|
+
|
198
|
+
extend self
|
199
|
+
|
200
|
+
def fix_models
|
201
|
+
(Elastics::Conf.elastics_models + Elastics::Conf.elastics_active_models).each do |mod|
|
202
|
+
mod = eval("::#{mod}") if mod.is_a?(String)
|
203
|
+
mod.class_eval do
|
204
|
+
alias_method :flex_id, :elastics_id if method_defined?(:elastics_id)
|
205
|
+
alias_method :flex_type, :elastics_type if method_defined?(:elastics_type)
|
206
|
+
alias_method :flex_index, :elastics_index if method_defined?(:elastics_index)
|
207
|
+
alias_method :flex_parent, :elastics_parent if method_defined?(:elastics_parent)
|
208
|
+
alias_method :flex_routing, :elastics_routing if method_defined?(:elastics_routing)
|
209
|
+
end
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
213
|
+
end
|
214
|
+
end
|
data/lib/flex/rails.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
raise NotImplementedError, %(The "flex/rails" file has been replaced by the "elastics-rails" gem. Please, use "elastics-rails" in place of "flex" in Rails applications. Change "gem 'flex', require => 'flex/rails'" to "gem 'elastics-rails'", and add the `elastics-legacy` gem to your Gemfile. Please, read the upgrade notes at http://elastics.github.io/elastics/doc/7-Tutorials/2-Migrate-from-0.x.html.)
|
metadata
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: elastics-legacy
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.5
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Domizio Demichelis
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-08-20 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: elastics-client
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - '='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 1.0.5
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - '='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 1.0.5
|
30
|
+
description: Provides out-of-the box legacy compatibility (with flex and old versions).
|
31
|
+
Use it for a smooth migration to the new gems.
|
32
|
+
email: dd.nexus@gmail.com
|
33
|
+
executables: []
|
34
|
+
extensions: []
|
35
|
+
extra_rdoc_files: []
|
36
|
+
files:
|
37
|
+
- LICENSE
|
38
|
+
- README.md
|
39
|
+
- VERSION
|
40
|
+
- elastics-legacy.gemspec
|
41
|
+
- lib/elastics-legacy.rb
|
42
|
+
- lib/elastics/deprecation.rb
|
43
|
+
- lib/flex/rails.rb
|
44
|
+
homepage: http://elastics.github.io/elastics
|
45
|
+
licenses:
|
46
|
+
- MIT
|
47
|
+
post_install_message:
|
48
|
+
rdoc_options:
|
49
|
+
- --charset=UTF-8
|
50
|
+
require_paths:
|
51
|
+
- lib
|
52
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ! '>='
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '0'
|
58
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
59
|
+
none: false
|
60
|
+
requirements:
|
61
|
+
- - ! '>='
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: 1.3.6
|
64
|
+
requirements: []
|
65
|
+
rubyforge_project:
|
66
|
+
rubygems_version: 1.8.25
|
67
|
+
signing_key:
|
68
|
+
specification_version: 3
|
69
|
+
summary: Adds legacy compatibility and deprecations warnings.
|
70
|
+
test_files: []
|