active_facets 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE.txt +21 -0
- data/README.md +206 -0
- data/Rakefile +29 -0
- data/lib/active_facets.rb +93 -0
- data/lib/active_facets/acts_as_active_facet.rb +131 -0
- data/lib/active_facets/config.rb +263 -0
- data/lib/active_facets/document_cache.rb +52 -0
- data/lib/active_facets/errors/attribute_error.rb +6 -0
- data/lib/active_facets/errors/configuration_error.rb +14 -0
- data/lib/active_facets/errors/lookup_error.rb +6 -0
- data/lib/active_facets/resource_manager.rb +124 -0
- data/lib/active_facets/serializer/base.rb +291 -0
- data/lib/active_facets/serializer/facade.rb +223 -0
- data/lib/active_facets/version.rb +3 -0
- data/lib/rails/generators/active_facets/install/install_generator.rb +21 -0
- data/lib/rails/generators/active_facets/install/templates/active_facets.yml +17 -0
- data/lib/rails/generators/active_facets/install/templates/initializer.rb +82 -0
- data/lib/tasks/active_facets_tasks.rake +4 -0
- metadata +317 -0
@@ -0,0 +1,21 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module ActiveFacets
|
4
|
+
module Generators
|
5
|
+
class InstallGenerator < Rails::Generators::Base
|
6
|
+
desc 'Creates a ActiveFacets gem configuration file at config/active_facets.yml, and an initializer at config/initializers/active_facets.rb'
|
7
|
+
|
8
|
+
def self.source_root
|
9
|
+
@_af_source_root ||= File.expand_path("../templates", __FILE__)
|
10
|
+
end
|
11
|
+
|
12
|
+
def create_config_file
|
13
|
+
template 'active_facets.yml', File.join('config', 'active_facets.yml')
|
14
|
+
end
|
15
|
+
|
16
|
+
def create_initializer_file
|
17
|
+
template 'initializer.rb', File.join('config', 'initializers', 'active_facets.rb')
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
default:
|
2
|
+
opts_key: af_opts
|
3
|
+
fields_key: fields
|
4
|
+
field_overrides_key: field_overrides
|
5
|
+
version_key: version
|
6
|
+
filters_key: filters
|
7
|
+
cache_force_key: cache_force
|
8
|
+
filters_force_key: cache_force
|
9
|
+
strict_lookups: false
|
10
|
+
preload_associations: false
|
11
|
+
cache_enabled: false
|
12
|
+
filters_enabled: false
|
13
|
+
test:
|
14
|
+
strict_lookups: false
|
15
|
+
preload_associations: false
|
16
|
+
cache_enabled: false
|
17
|
+
filters_enabled: false
|
@@ -0,0 +1,82 @@
|
|
1
|
+
ActiveFacets.configure do |config|
|
2
|
+
config_file_path = File.join(Rails.root, 'config', 'active_facets.yml')
|
3
|
+
environment = ENV["RAILS_ENV"] || ENV["RACK_ENV"] || 'development'
|
4
|
+
|
5
|
+
@config_file = YAML::load_file(config_file_path)
|
6
|
+
@env_config = (@config_file['default'] || {}).merge(@config_file[environment] || {})
|
7
|
+
|
8
|
+
# The version to use if none is designated in context for serialization. 1.0 by default.
|
9
|
+
# config.default_version = 1.0
|
10
|
+
|
11
|
+
# The symbol which acts as the options key that designates context for serialization. :rsb_opts by default.
|
12
|
+
# config.opts_key = @env_config['opts_key'].to_sym
|
13
|
+
|
14
|
+
# The symbol which acts as the context key that designates fields for serialization. :fields by default.
|
15
|
+
# config.fields_key = @env_config['fields_key'].to_sym
|
16
|
+
|
17
|
+
# The symbol which acts as the context key that designates field overrides for serialization. :field_overrides by default.
|
18
|
+
# config.field_overrides_key = @env_config['field_overrides_key'].to_sym
|
19
|
+
|
20
|
+
# The symbol which acts as the context key that designates version for serialization. :version by default.
|
21
|
+
# config.version_key = @env_config['version_key'].to_sym
|
22
|
+
|
23
|
+
# The symbol which acts as the context key that designates filters for serialization. :filters by default.
|
24
|
+
# config.filters_key = @env_config['filters_key'].to_sym
|
25
|
+
|
26
|
+
# The symbol which acts as the context key that designates force for cache. :cache_force by default.
|
27
|
+
# config.cache_force_key = @env_config['cache_force_key'].to_sym
|
28
|
+
|
29
|
+
# The symbol which acts as the context key that designates filters state override. :filters_force by default.
|
30
|
+
# config.filters_force_key = @env_config['filters_force_key'].to_sym
|
31
|
+
|
32
|
+
# Tell if exception should be raised when serializer_mapper returns nil. False by default.
|
33
|
+
# config.strict_lookups = @env_config['strict_lookups']
|
34
|
+
|
35
|
+
# Tell if associations should be preloaded to mitigate N+1 problems. False by default.
|
36
|
+
# config.preload_associations = @env_config['preload_associations']
|
37
|
+
|
38
|
+
# Tell serializers to cache
|
39
|
+
# config.cache_enabled = @env_config['cache_enabled']
|
40
|
+
|
41
|
+
# Tell ActiveRecord to treat enable acts_as_active_facet for all models. False by default.
|
42
|
+
# config.acts_as_active_facet_enabled = @env_config['acts_as_active_facet_enabled']
|
43
|
+
|
44
|
+
# Tell serializers to enable/disable filters
|
45
|
+
# config.filters_enabled = @env_config['filters_enabled']
|
46
|
+
|
47
|
+
# Default options for Rails.cache.fetch
|
48
|
+
# config.default_cache_options = { expires_in: 5.minutes }
|
49
|
+
|
50
|
+
# Tell document cache adaptor to use
|
51
|
+
# config.document_cache = ::ActiveFacets::DocumentCache
|
52
|
+
|
53
|
+
# Tell which filters and field_overrides apply to a given resource
|
54
|
+
# config.resource_mapper do |resource_class|
|
55
|
+
# [].tap do |map|
|
56
|
+
# until(resource_class.superclass == BasicObject) do
|
57
|
+
# map << resource_class.name.tableize
|
58
|
+
# resource_class = resource_class.superclass
|
59
|
+
# end
|
60
|
+
# end
|
61
|
+
# end
|
62
|
+
|
63
|
+
# Tell which serializer to apply for a given resource
|
64
|
+
# config.serializer_mapper do |resource_class, serializer, type, version, options|
|
65
|
+
# case type
|
66
|
+
# when :serializer
|
67
|
+
# (version.to_s + '::' + resource_class.name.camelcase + type.to_s.camecase).constantize.new
|
68
|
+
# else
|
69
|
+
# (version.to_s + '::' + resource_class.name.camelcase + type.to_s.camecase).constantize
|
70
|
+
# end
|
71
|
+
# end
|
72
|
+
|
73
|
+
# Define global filters to apply for all resources
|
74
|
+
# config.global_filter(:active) do |state = :enabled|
|
75
|
+
# case state.to_sym
|
76
|
+
# when :enabled
|
77
|
+
# enabled if respond_to?(:enabled)
|
78
|
+
# when :disabled
|
79
|
+
# disabled
|
80
|
+
# end
|
81
|
+
# end
|
82
|
+
end
|
metadata
ADDED
@@ -0,0 +1,317 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: active_facets
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.2.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- The Honest Company
|
8
|
+
- Jay Crouch
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2016-04-18 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rails
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: 3.2.22
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: 3.2.22
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: oj
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: w_g
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: 0.4.1
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: 0.4.1
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: bundler
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '1.11'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '1.11'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: sqlite3
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: rspec-rails
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
type: :development
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
- !ruby/object:Gem::Dependency
|
99
|
+
name: test-unit
|
100
|
+
requirement: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
type: :development
|
106
|
+
prerelease: false
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
112
|
+
- !ruby/object:Gem::Dependency
|
113
|
+
name: factory_girl_rails
|
114
|
+
requirement: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - ">="
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
type: :development
|
120
|
+
prerelease: false
|
121
|
+
version_requirements: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - ">="
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: database_cleaner
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - ">="
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '0'
|
133
|
+
type: :development
|
134
|
+
prerelease: false
|
135
|
+
version_requirements: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - ">="
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '0'
|
140
|
+
- !ruby/object:Gem::Dependency
|
141
|
+
name: ffaker
|
142
|
+
requirement: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - ">="
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '0'
|
147
|
+
type: :development
|
148
|
+
prerelease: false
|
149
|
+
version_requirements: !ruby/object:Gem::Requirement
|
150
|
+
requirements:
|
151
|
+
- - ">="
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
version: '0'
|
154
|
+
- !ruby/object:Gem::Dependency
|
155
|
+
name: fivemat
|
156
|
+
requirement: !ruby/object:Gem::Requirement
|
157
|
+
requirements:
|
158
|
+
- - ">="
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: '0'
|
161
|
+
type: :development
|
162
|
+
prerelease: false
|
163
|
+
version_requirements: !ruby/object:Gem::Requirement
|
164
|
+
requirements:
|
165
|
+
- - ">="
|
166
|
+
- !ruby/object:Gem::Version
|
167
|
+
version: '0'
|
168
|
+
- !ruby/object:Gem::Dependency
|
169
|
+
name: fuubar
|
170
|
+
requirement: !ruby/object:Gem::Requirement
|
171
|
+
requirements:
|
172
|
+
- - ">="
|
173
|
+
- !ruby/object:Gem::Version
|
174
|
+
version: '0'
|
175
|
+
type: :development
|
176
|
+
prerelease: false
|
177
|
+
version_requirements: !ruby/object:Gem::Requirement
|
178
|
+
requirements:
|
179
|
+
- - ">="
|
180
|
+
- !ruby/object:Gem::Version
|
181
|
+
version: '0'
|
182
|
+
- !ruby/object:Gem::Dependency
|
183
|
+
name: parallel_tests
|
184
|
+
requirement: !ruby/object:Gem::Requirement
|
185
|
+
requirements:
|
186
|
+
- - ">="
|
187
|
+
- !ruby/object:Gem::Version
|
188
|
+
version: '0'
|
189
|
+
type: :development
|
190
|
+
prerelease: false
|
191
|
+
version_requirements: !ruby/object:Gem::Requirement
|
192
|
+
requirements:
|
193
|
+
- - ">="
|
194
|
+
- !ruby/object:Gem::Version
|
195
|
+
version: '0'
|
196
|
+
- !ruby/object:Gem::Dependency
|
197
|
+
name: pry
|
198
|
+
requirement: !ruby/object:Gem::Requirement
|
199
|
+
requirements:
|
200
|
+
- - ">="
|
201
|
+
- !ruby/object:Gem::Version
|
202
|
+
version: '0'
|
203
|
+
type: :development
|
204
|
+
prerelease: false
|
205
|
+
version_requirements: !ruby/object:Gem::Requirement
|
206
|
+
requirements:
|
207
|
+
- - ">="
|
208
|
+
- !ruby/object:Gem::Version
|
209
|
+
version: '0'
|
210
|
+
- !ruby/object:Gem::Dependency
|
211
|
+
name: pry-rails
|
212
|
+
requirement: !ruby/object:Gem::Requirement
|
213
|
+
requirements:
|
214
|
+
- - ">="
|
215
|
+
- !ruby/object:Gem::Version
|
216
|
+
version: '0'
|
217
|
+
type: :development
|
218
|
+
prerelease: false
|
219
|
+
version_requirements: !ruby/object:Gem::Requirement
|
220
|
+
requirements:
|
221
|
+
- - ">="
|
222
|
+
- !ruby/object:Gem::Version
|
223
|
+
version: '0'
|
224
|
+
- !ruby/object:Gem::Dependency
|
225
|
+
name: pry-nav
|
226
|
+
requirement: !ruby/object:Gem::Requirement
|
227
|
+
requirements:
|
228
|
+
- - ">="
|
229
|
+
- !ruby/object:Gem::Version
|
230
|
+
version: '0'
|
231
|
+
type: :development
|
232
|
+
prerelease: false
|
233
|
+
version_requirements: !ruby/object:Gem::Requirement
|
234
|
+
requirements:
|
235
|
+
- - ">="
|
236
|
+
- !ruby/object:Gem::Version
|
237
|
+
version: '0'
|
238
|
+
- !ruby/object:Gem::Dependency
|
239
|
+
name: pry-stack_explorer
|
240
|
+
requirement: !ruby/object:Gem::Requirement
|
241
|
+
requirements:
|
242
|
+
- - ">="
|
243
|
+
- !ruby/object:Gem::Version
|
244
|
+
version: '0'
|
245
|
+
type: :development
|
246
|
+
prerelease: false
|
247
|
+
version_requirements: !ruby/object:Gem::Requirement
|
248
|
+
requirements:
|
249
|
+
- - ">="
|
250
|
+
- !ruby/object:Gem::Version
|
251
|
+
version: '0'
|
252
|
+
- !ruby/object:Gem::Dependency
|
253
|
+
name: rapido
|
254
|
+
requirement: !ruby/object:Gem::Requirement
|
255
|
+
requirements:
|
256
|
+
- - ">="
|
257
|
+
- !ruby/object:Gem::Version
|
258
|
+
version: '0'
|
259
|
+
type: :development
|
260
|
+
prerelease: false
|
261
|
+
version_requirements: !ruby/object:Gem::Requirement
|
262
|
+
requirements:
|
263
|
+
- - ">="
|
264
|
+
- !ruby/object:Gem::Version
|
265
|
+
version: '0'
|
266
|
+
description: Fast JSON serializer for nested PORO and ActiveRecord Objects supporting
|
267
|
+
decoration, field filters, record filters and caching
|
268
|
+
email:
|
269
|
+
- i.jaycrouch@gmail.com
|
270
|
+
executables: []
|
271
|
+
extensions: []
|
272
|
+
extra_rdoc_files: []
|
273
|
+
files:
|
274
|
+
- MIT-LICENSE.txt
|
275
|
+
- README.md
|
276
|
+
- Rakefile
|
277
|
+
- lib/active_facets.rb
|
278
|
+
- lib/active_facets/acts_as_active_facet.rb
|
279
|
+
- lib/active_facets/config.rb
|
280
|
+
- lib/active_facets/document_cache.rb
|
281
|
+
- lib/active_facets/errors/attribute_error.rb
|
282
|
+
- lib/active_facets/errors/configuration_error.rb
|
283
|
+
- lib/active_facets/errors/lookup_error.rb
|
284
|
+
- lib/active_facets/resource_manager.rb
|
285
|
+
- lib/active_facets/serializer/base.rb
|
286
|
+
- lib/active_facets/serializer/facade.rb
|
287
|
+
- lib/active_facets/version.rb
|
288
|
+
- lib/rails/generators/active_facets/install/install_generator.rb
|
289
|
+
- lib/rails/generators/active_facets/install/templates/active_facets.yml
|
290
|
+
- lib/rails/generators/active_facets/install/templates/initializer.rb
|
291
|
+
- lib/tasks/active_facets_tasks.rake
|
292
|
+
homepage: https://github.com/honest/active_facets
|
293
|
+
licenses:
|
294
|
+
- MIT
|
295
|
+
metadata:
|
296
|
+
allowed_push_host: https://rubygems.org
|
297
|
+
post_install_message:
|
298
|
+
rdoc_options: []
|
299
|
+
require_paths:
|
300
|
+
- lib
|
301
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
302
|
+
requirements:
|
303
|
+
- - ">="
|
304
|
+
- !ruby/object:Gem::Version
|
305
|
+
version: '0'
|
306
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
307
|
+
requirements:
|
308
|
+
- - ">="
|
309
|
+
- !ruby/object:Gem::Version
|
310
|
+
version: '0'
|
311
|
+
requirements: []
|
312
|
+
rubyforge_project:
|
313
|
+
rubygems_version: 2.4.8
|
314
|
+
signing_key:
|
315
|
+
specification_version: 4
|
316
|
+
summary: Inline JSON serializer
|
317
|
+
test_files: []
|