FE updates

pull/316/head
Rick Carlino 2017-03-06 18:17:16 -06:00
parent ea35a202d8
commit 8fa3eb1213
5 changed files with 26 additions and 6 deletions

View File

@ -18,6 +18,7 @@ gem "fog-google", git: "https://github.com/fog/fog-google"
gem "rest-client" # If you see this, delete this. gem "rest-client" # If you see this, delete this.
gem "pg" gem "pg"
gem "batch_api" gem "batch_api"
gem "json-schema-generator"
# Error reporting tools. # Error reporting tools.
# Active on the "official" FarmBot server, set the appropriate ENV # Active on the "official" FarmBot server, set the appropriate ENV

View File

@ -114,6 +114,10 @@ GEM
domain_name (~> 0.5) domain_name (~> 0.5)
i18n (0.7.0) i18n (0.7.0)
json (1.8.3) json (1.8.3)
json-schema-generator (0.0.9)
jsonpath
jsonpath (0.5.8)
multi_json
jwt (1.5.6) jwt (1.5.6)
launchy (2.4.3) launchy (2.4.3)
addressable (~> 2.3) addressable (~> 2.3)
@ -266,6 +270,7 @@ DEPENDENCIES
faker faker
figaro figaro
fog-google! fog-google!
json-schema-generator
jwt jwt
letter_opener letter_opener
mutations (~> 0.8.0) mutations (~> 0.8.0)

View File

@ -1,6 +1,7 @@
class JsonSchemaIdea require_relative "./doc_page"
@all = {}
class DocGen
@all = {}
BLACK_LIST = ["/api/sequences/:id (PATCH)", BLACK_LIST = ["/api/sequences/:id (PATCH)",
"/api/sequences (POST)"] "/api/sequences (POST)"]
@ -18,7 +19,12 @@ class JsonSchemaIdea
@all.select!{|k, v| v.length > 0} @all.select!{|k, v| v.length > 0}
# TOO LONG TO DOCUMENT - IGNORE INSTEAD. # TOO LONG TO DOCUMENT - IGNORE INSTEAD.
BLACK_LIST.map {|k| @all.delete(k) } BLACK_LIST.map {|k| @all.delete(k) }
binding.pry @all
.map do |key, y|
url, verb = key.split(" ")
DocPage.new(url, verb, JSON.parse(JSON::SchemaGenerator
.generate(key, y.to_json))["items"])
end
end end
def self.from_json(request) def self.from_json(request)

8
spec/doc_page.rb 100644
View File

@ -0,0 +1,8 @@
class DocPage
attr_reader :url, :verb, :schema
def initialize(url, verb, schema)
@url = url
@verb = verb
@schema = schema
end
end

View File

@ -13,7 +13,7 @@ ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../../config/environment', __FILE__) require File.expand_path('../../config/environment', __FILE__)
require 'rspec/rails' require 'rspec/rails'
require_relative './stuff' require_relative './stuff'
require_relative './json_schema_idea' require_relative './doc_gen'
Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f } Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
@ -37,12 +37,12 @@ RSpec.configure do |config|
if ENV['DOCS'] if ENV['DOCS']
config.after(:each, type: :controller) do config.after(:each, type: :controller) do
JsonSchemaIdea.add(request) DocGen.add(request)
SmarfDoc.run!(request, response) SmarfDoc.run!(request, response)
end end
config.after(:suite) do config.after(:suite) do
JsonSchemaIdea.finish! DocGen.finish!#.tap{ |x| binding.pry }
SmarfDoc.finish! SmarfDoc.finish!
end end
end end