vandal_ui 0.3.3 → 0.4.0

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: 215b66b45930873c596c7cac0777dabc9514c415
4
- data.tar.gz: 49fc0f3f6ef119b79215493988f8f0958ed991a1
3
+ metadata.gz: 403cbddb72e485e62f024ea8cfc47e9e3efaccc1
4
+ data.tar.gz: 3785dabe03246e647faf9bb14976166065a77b87
5
5
  SHA512:
6
- metadata.gz: 9a7154a6ac29fdc83748cd43f8e983b2cf6764e8381f155e0e61326187f1b3655fcebb3e80d83547ae83dd5ca3381c60bac3cd961ffd72f763d18e301ec61c01
7
- data.tar.gz: ea5618976944dda41c74d54e7c7bea886f031af84c0b8ffcf2ba4ef1cc4b294244f69f482704bd1fbf57c504d738261b5750187d97161ad0b3b57f4f621913aa
6
+ metadata.gz: 39f13c66cf2a8f8f8c1969e05fddf897802070736554c1b8875324ecf24285c6645f32ef0002c9119055ade346c70b7dc80514974183d786ce0004af7f37bf61
7
+ data.tar.gz: 54c6994b1077e716b5a54ee647a7e83badccf35a64bc7d6b157eef1ed15bebe06838f61053495e0ad5ce89e5552d47525b849dc7f09a89c56b9d56c4cbc631f4
data/README.md CHANGED
@@ -1 +1,23 @@
1
- # Vandal
1
+ # Vandal UI
2
+
3
+ This is a Rails engine for
4
+ [Graphiti](https://graphiti-api.github.io/graphiti/guides/) APIs. It has
5
+ two main functions:
6
+
7
+ * `rake vandal:install` will copy static files to `public/<api_namespace>`.
8
+ * Mounting the engine adds an endpoint for a dynamically-generated
9
+ schema file:
10
+
11
+ ```ruby
12
+ # config/routes.rb
13
+
14
+ scope path: ApplicationResource.endpoint_namespace, defaults: { format: :jsonapi } do
15
+ # ... routes ...
16
+
17
+ mount VandalUi::Engine, at: '/vandal'
18
+ end
19
+ ```
20
+
21
+ If `ApplicationRecord.endpoint_namespace` is `/api/v1`, you'd get a
22
+ `/api/v1/vandal/schema.json` that would be referenced when loading the
23
+ UI.
@@ -0,0 +1,6 @@
1
+ class VandalUi::SchemasController < ActionController::API
2
+ def show
3
+ Rails.application.eager_load!
4
+ render json: Graphiti::Schema.generate
5
+ end
6
+ end
data/config/routes.rb ADDED
@@ -0,0 +1,3 @@
1
+ VandalUi::Engine.routes.draw do
2
+ get '/schema', to: 'vandal_ui/schemas#show'
3
+ end
data/lib/vandal_ui.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require "vandal_ui/version"
2
2
  require "vandal_ui/railtie" if defined?(Rails)
3
+ require "vandal_ui/engine" if defined?(Rails)
3
4
 
4
5
  module VandalUi
5
6
  end
@@ -0,0 +1,4 @@
1
+ module VandalUi
2
+ class Engine < ::Rails::Engine
3
+ end
4
+ end
@@ -2,7 +2,9 @@ namespace :vandal do
2
2
  task :install do
3
3
  cfg = YAML.load_file("#{Rails.root}/.graphiticfg.yml")
4
4
  namespace = cfg['namespace']
5
- schema_path = "#{namespace}/schema.json"
5
+
6
+ vandal_path = VandalUi::Engine.routes.find_script_name({})
7
+ schema_path = "#{vandal_path}/schema.json"
6
8
 
7
9
  source = File.join(File.dirname(__FILE__), 'static')
8
10
  destination = "#{Rails.root}/public/#{namespace}"
@@ -1,3 +1,3 @@
1
1
  module VandalUi
2
- VERSION = "0.3.3"
2
+ VERSION = "0.4.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vandal_ui
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lee Richmond
@@ -66,9 +66,12 @@ files:
66
66
  - Gemfile.lock
67
67
  - README.md
68
68
  - Rakefile
69
+ - app/controllers/vandal_ui/schemas_controller.rb
69
70
  - bin/console
70
71
  - bin/setup
72
+ - config/routes.rb
71
73
  - lib/vandal_ui.rb
74
+ - lib/vandal_ui/engine.rb
72
75
  - lib/vandal_ui/railtie.rb
73
76
  - lib/vandal_ui/static/assets/img/squares.png
74
77
  - lib/vandal_ui/static/css/app.ef4cd70f.css