lazer-rails 0.1.1 → 0.1.3
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.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/app/controllers/lazer/scopes_controller.rb +25 -4
- data/lib/lazer/version.rb +1 -1
- metadata +4 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4975e7de464d555dca3ff2f70d171a4f7bf95a54bfa8bd5dae0c8846f7e9ca99
|
4
|
+
data.tar.gz: df159f5a0feda0a168dda60fcd6ee50dc6f19c463bccd840c106288aaa3beb0d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bfad89b32fe73418e740819f6e1386c251696eacb149293347eb843ed35b37fd9fa9b96386a8d0c57b6b2df61ce6bedaed33b6ecbfc439b7fc7f29c5c22e4de8
|
7
|
+
data.tar.gz: 9e0073dc322d8e2a79482ae8b022f0677ae36f06014dcd8d74e0ec5132746bba96a2051469a9ed92be1556f0f21c6b405d7eb0fe146a104e7e5a24a0aac38c79
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Lazer Ruby Gem
|
2
2
|
|
3
|
-
This gem provides a Rails engine that allows Lazer to import your
|
3
|
+
This gem provides a Rails engine that allows Lazer to import your app's scopes and Active Record relationships.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
Add this line to your application's Gemfile:
|
@@ -19,7 +19,7 @@ Mount the engine:
|
|
19
19
|
|
20
20
|
```
|
21
21
|
# config/routes.rb
|
22
|
-
mount Lazer::Engine => "/lazer
|
22
|
+
mount Lazer::Engine => "/api/lazer"
|
23
23
|
```
|
24
24
|
|
25
25
|
Add a new codebase in Lazer to get an API key, then set it as an environment variable:
|
@@ -4,12 +4,26 @@ module Lazer
|
|
4
4
|
class ScopesController < ApplicationController
|
5
5
|
|
6
6
|
def show
|
7
|
-
|
8
|
-
|
7
|
+
require_page!; return if performed?
|
8
|
+
|
9
|
+
page = params[:page].to_i
|
10
|
+
models_per_page = 30
|
11
|
+
offset = (page - 1) * models_per_page
|
9
12
|
|
10
|
-
def try_all_models
|
11
13
|
Rails.application.eager_load!
|
12
|
-
|
14
|
+
all_models = ActiveRecord::Base.descendants.sort_by(&:name)
|
15
|
+
paged_models = all_models[offset, models_per_page] || []
|
16
|
+
|
17
|
+
result = {}
|
18
|
+
|
19
|
+
result[:count] = paged_models.length
|
20
|
+
result[:page] = page
|
21
|
+
result[:offset] = offset
|
22
|
+
result[:scopes] = fetch_scopes_for(paged_models)
|
23
|
+
render json: result.to_json
|
24
|
+
end
|
25
|
+
|
26
|
+
def fetch_scopes_for(models)
|
13
27
|
worked = []
|
14
28
|
failed = []
|
15
29
|
data = {}
|
@@ -67,5 +81,12 @@ module Lazer
|
|
67
81
|
result
|
68
82
|
end
|
69
83
|
|
84
|
+
def require_page!
|
85
|
+
if params[:page].blank?
|
86
|
+
render json: "You must specify a page param", status: 422
|
87
|
+
return
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
70
91
|
end
|
71
92
|
end
|
data/lib/lazer/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lazer-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vic Ramon
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: railties
|
@@ -65,11 +64,10 @@ files:
|
|
65
64
|
- lib/lazer/track_scopes.rb
|
66
65
|
- lib/lazer/version.rb
|
67
66
|
- lib/tasks/lazer_tasks.rake
|
68
|
-
homepage: https://www.github.com/vicramon/lazer-
|
67
|
+
homepage: https://www.github.com/vicramon/lazer-rails
|
69
68
|
licenses: []
|
70
69
|
metadata:
|
71
70
|
allowed_push_host: https://rubygems.org
|
72
|
-
post_install_message:
|
73
71
|
rdoc_options: []
|
74
72
|
require_paths:
|
75
73
|
- lib
|
@@ -84,8 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
84
82
|
- !ruby/object:Gem::Version
|
85
83
|
version: '0'
|
86
84
|
requirements: []
|
87
|
-
rubygems_version: 3.
|
88
|
-
signing_key:
|
85
|
+
rubygems_version: 3.6.7
|
89
86
|
specification_version: 4
|
90
87
|
summary: Provides secure endpoints to export info for Lazer Pro
|
91
88
|
test_files: []
|