lhs 9.1.0 → 9.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lhs.rb +6 -1
- data/lib/lhs/version.rb +1 -1
- data/spec/autoloading_spec.rb +19 -0
- data/spec/dummy/app/controllers/application_controller.rb +4 -0
- data/spec/dummy/app/models/user.rb +4 -0
- data/spec/dummy/config/initializers/lhc.rb +3 -0
- data/spec/dummy/config/routes.rb +1 -1
- data/spec/support/cleanup.rb +32 -0
- metadata +10 -8
- data/spec/support/cleanup_configuration.rb +0 -15
- data/spec/support/cleanup_endpoints.rb +0 -5
- data/spec/support/cleanup_records.rb +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 580d8981ba9059cb3e1e5a5d598313e167421279
|
4
|
+
data.tar.gz: 561ba57069262b2c87a825b935b933522daac02f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1aaad8a56559f5a27c4fd5b9a82d31732525c8eb11e20d6b5b30b3b3913749caf7bc674bc71fa837c6c7cb9bb032983358f4fe3017e6621b6b8ace5bd04b9b8a
|
7
|
+
data.tar.gz: 2b298c29b539f34559693c83489809919005f7879a63731c217aecd07df222e9fcfa5646949775b9d0f1f8ee8ed3475fac472bf345f3619b55a506b92efbace4
|
data/lib/lhs.rb
CHANGED
@@ -7,10 +7,14 @@ module LHS
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def call(env)
|
10
|
+
self.class.require_records
|
11
|
+
@app.call(env)
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.require_records
|
10
15
|
Dir.glob(Rails.root.join('app/models/**/*.rb')).each do |file|
|
11
16
|
require_dependency file if File.read(file).match('LHS::Record')
|
12
17
|
end
|
13
|
-
@app.call(env)
|
14
18
|
end
|
15
19
|
end
|
16
20
|
end
|
@@ -20,6 +24,7 @@ Gem.find_files('lhs/**/*.rb').sort.each { |path| require path }
|
|
20
24
|
# Preload all the LHS::Records that are defined in app/models
|
21
25
|
class Engine < Rails::Engine
|
22
26
|
initializer 'Load all LHS::Records from app/models/**' do |app|
|
27
|
+
LHS::RequireLhsRecords.require_records
|
23
28
|
next if app.config.cache_classes
|
24
29
|
|
25
30
|
app.config.middleware.use LHS::RequireLhsRecords
|
data/lib/lhs/version.rb
CHANGED
@@ -0,0 +1,19 @@
|
|
1
|
+
require "rails_helper"
|
2
|
+
|
3
|
+
describe LHS, type: :request do
|
4
|
+
context 'autoloading' do
|
5
|
+
it "pre/re-loads all LHS classes initialy,|
|
6
|
+
because it's necessary for endpoint-to-record-class-discovery",
|
7
|
+
cleanup_before: false do
|
8
|
+
all_endpoints = LHS::Record::Endpoints.all
|
9
|
+
expect(all_endpoints[':datastore/v2/users']).to be
|
10
|
+
expect(all_endpoints[':datastore/v2/users/:id']).to be
|
11
|
+
expect(
|
12
|
+
User.endpoints.detect { |endpoint| endpoint.url == ':datastore/v2/users' }
|
13
|
+
).to be
|
14
|
+
expect(
|
15
|
+
User.endpoints.detect { |endpoint| endpoint.url == ':datastore/v2/users/:id' }
|
16
|
+
).to be
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/spec/dummy/config/routes.rb
CHANGED
@@ -3,7 +3,7 @@ Rails.application.routes.draw do
|
|
3
3
|
# See how all your routes lay out with "rake routes".
|
4
4
|
|
5
5
|
# You can have the root of your site routed with "root"
|
6
|
-
|
6
|
+
root 'application#root'
|
7
7
|
|
8
8
|
# Example of regular route:
|
9
9
|
# get 'products/:id' => 'catalog#view'
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'lhc'
|
2
|
+
class LHC::Config
|
3
|
+
|
4
|
+
def _cleanup
|
5
|
+
@endpoints = {}
|
6
|
+
@placeholders = {}
|
7
|
+
@interceptors = nil
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
class LHS::Record
|
12
|
+
|
13
|
+
CHILDREN = []
|
14
|
+
|
15
|
+
def self.inherited(child)
|
16
|
+
CHILDREN.push(child)
|
17
|
+
super
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
RSpec.configure do |config|
|
23
|
+
config.before(:each) do |spec|
|
24
|
+
next if spec.metadata.key?(:cleanup_before) && spec.metadata[:cleanup_before] == false
|
25
|
+
LHC::Config.instance._cleanup
|
26
|
+
LHS::Record::Endpoints.all = {}
|
27
|
+
LHS::Record::CHILDREN.each do |child|
|
28
|
+
child.endpoints = [] if !child.name['LHS']
|
29
|
+
child.configuration({}) if !child.name['LHS']
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lhs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 9.1.
|
4
|
+
version: 9.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- https://github.com/local-ch/lhs/graphs/contributors
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-03-
|
11
|
+
date: 2017-03-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lhc
|
@@ -233,6 +233,7 @@ files:
|
|
233
233
|
- lib/lhs/version.rb
|
234
234
|
- script/ci/build.sh
|
235
235
|
- spec/.DS_Store
|
236
|
+
- spec/autoloading_spec.rb
|
236
237
|
- spec/collection/accessors_spec.rb
|
237
238
|
- spec/collection/collection_items_spec.rb
|
238
239
|
- spec/collection/configurable_spec.rb
|
@@ -265,6 +266,7 @@ files:
|
|
265
266
|
- spec/dummy/app/mailers/.keep
|
266
267
|
- spec/dummy/app/models/.keep
|
267
268
|
- spec/dummy/app/models/concerns/.keep
|
269
|
+
- spec/dummy/app/models/user.rb
|
268
270
|
- spec/dummy/app/views/form_for.html.erb
|
269
271
|
- spec/dummy/app/views/layouts/application.html.erb
|
270
272
|
- spec/dummy/bin/bundle
|
@@ -282,6 +284,7 @@ files:
|
|
282
284
|
- spec/dummy/config/initializers/cookies_serializer.rb
|
283
285
|
- spec/dummy/config/initializers/filter_parameter_logging.rb
|
284
286
|
- spec/dummy/config/initializers/inflections.rb
|
287
|
+
- spec/dummy/config/initializers/lhc.rb
|
285
288
|
- spec/dummy/config/initializers/mime_types.rb
|
286
289
|
- spec/dummy/config/initializers/session_store.rb
|
287
290
|
- spec/dummy/config/initializers/wrap_parameters.rb
|
@@ -357,9 +360,7 @@ files:
|
|
357
360
|
- spec/record/where_spec.rb
|
358
361
|
- spec/record/where_values_hash_spec.rb
|
359
362
|
- spec/spec_helper.rb
|
360
|
-
- spec/support/
|
361
|
-
- spec/support/cleanup_endpoints.rb
|
362
|
-
- spec/support/cleanup_records.rb
|
363
|
+
- spec/support/cleanup.rb
|
363
364
|
- spec/support/fixtures/json/feedback.json
|
364
365
|
- spec/support/fixtures/json/feedbacks.json
|
365
366
|
- spec/support/fixtures/json/localina_content_ad.json
|
@@ -391,6 +392,7 @@ signing_key:
|
|
391
392
|
specification_version: 4
|
392
393
|
summary: Rails gem providing an easy, active-record-like interface for http json services
|
393
394
|
test_files:
|
395
|
+
- spec/autoloading_spec.rb
|
394
396
|
- spec/collection/accessors_spec.rb
|
395
397
|
- spec/collection/collection_items_spec.rb
|
396
398
|
- spec/collection/configurable_spec.rb
|
@@ -423,6 +425,7 @@ test_files:
|
|
423
425
|
- spec/dummy/app/mailers/.keep
|
424
426
|
- spec/dummy/app/models/.keep
|
425
427
|
- spec/dummy/app/models/concerns/.keep
|
428
|
+
- spec/dummy/app/models/user.rb
|
426
429
|
- spec/dummy/app/views/form_for.html.erb
|
427
430
|
- spec/dummy/app/views/layouts/application.html.erb
|
428
431
|
- spec/dummy/bin/bundle
|
@@ -440,6 +443,7 @@ test_files:
|
|
440
443
|
- spec/dummy/config/initializers/cookies_serializer.rb
|
441
444
|
- spec/dummy/config/initializers/filter_parameter_logging.rb
|
442
445
|
- spec/dummy/config/initializers/inflections.rb
|
446
|
+
- spec/dummy/config/initializers/lhc.rb
|
443
447
|
- spec/dummy/config/initializers/mime_types.rb
|
444
448
|
- spec/dummy/config/initializers/session_store.rb
|
445
449
|
- spec/dummy/config/initializers/wrap_parameters.rb
|
@@ -515,9 +519,7 @@ test_files:
|
|
515
519
|
- spec/record/where_spec.rb
|
516
520
|
- spec/record/where_values_hash_spec.rb
|
517
521
|
- spec/spec_helper.rb
|
518
|
-
- spec/support/
|
519
|
-
- spec/support/cleanup_endpoints.rb
|
520
|
-
- spec/support/cleanup_records.rb
|
522
|
+
- spec/support/cleanup.rb
|
521
523
|
- spec/support/fixtures/json/feedback.json
|
522
524
|
- spec/support/fixtures/json/feedbacks.json
|
523
525
|
- spec/support/fixtures/json/localina_content_ad.json
|
@@ -1,19 +0,0 @@
|
|
1
|
-
class LHS::Record
|
2
|
-
|
3
|
-
CHILDREN = []
|
4
|
-
|
5
|
-
def self.inherited(child)
|
6
|
-
CHILDREN.push(child)
|
7
|
-
super
|
8
|
-
end
|
9
|
-
|
10
|
-
end
|
11
|
-
|
12
|
-
RSpec.configure do |config|
|
13
|
-
config.before(:each) do
|
14
|
-
LHS::Record::CHILDREN.each do |child|
|
15
|
-
child.endpoints = [] if !child.name['LHS']
|
16
|
-
child.configuration({}) if !child.name['LHS']
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|