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 "pg"
gem "batch_api"
gem "json-schema-generator"
# Error reporting tools.
# Active on the "official" FarmBot server, set the appropriate ENV

View File

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

View File

@ -1,6 +1,7 @@
class JsonSchemaIdea
@all = {}
require_relative "./doc_page"
class DocGen
@all = {}
BLACK_LIST = ["/api/sequences/:id (PATCH)",
"/api/sequences (POST)"]
@ -18,7 +19,12 @@ class JsonSchemaIdea
@all.select!{|k, v| v.length > 0}
# TOO LONG TO DOCUMENT - IGNORE INSTEAD.
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
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 'rspec/rails'
require_relative './stuff'
require_relative './json_schema_idea'
require_relative './doc_gen'
Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
@ -37,12 +37,12 @@ RSpec.configure do |config|
if ENV['DOCS']
config.after(:each, type: :controller) do
JsonSchemaIdea.add(request)
DocGen.add(request)
SmarfDoc.run!(request, response)
end
config.after(:suite) do
JsonSchemaIdea.finish!
DocGen.finish!#.tap{ |x| binding.pry }
SmarfDoc.finish!
end
end