Skip to content

Instantly share code, notes, and snippets.

@rsukale
Created February 23, 2017 00:47
Show Gist options
  • Save rsukale/38c3fecbd825741cb7526a8b106e1ba8 to your computer and use it in GitHub Desktop.
Save rsukale/38c3fecbd825741cb7526a8b106e1ba8 to your computer and use it in GitHub Desktop.
guide_classes
module GuidesHelper
def guides_list_props
dummyItem = {
url: 'foobar.com',
version: {
locale: 'en',
date: '2012-02-02',
firstVersion: 'v1.0',
currentVersion: 'v1.3'
},
href: '/foo',
tags: ['force.com', 'api', 'documentation'],
summary: 'batman',
description: 'Batmans secret identity is Bruce Wayne, an American billionaire, playboy, philanthropist, and owner of Wayne Enterprises. After witnessing the murder of his parents Thomas Wayne and Martha Wayne as a child, he swore vengeance against criminals, an oath tempered by a sense of justice. Wayne trains himself physically and intellectually and crafts a bat-inspired persona to fight crime.'
}
@guides = parse_guides({...})
@guides = Guide.new({...})
{
list: @guides
}
end
def parse_guide(hash)
title = hash[:dd] || 'foo'
href = ''
return {
paths: parse_paths(...),
}
end
class Guide
attr_reader :title, :paths
self.cache = {}
def self.all
self.cache = all_yml_files.each_with_object({}) do |yml, acc|
guide = new(yml)
acc[guide.name] = guide
end
end
def self.get(name)
cache[name] ||= new(read_the_yaml_file(name))
end
def title
super || 'generate my '
end
private
...
end
class Guide::Path
attr_reader :methods, :guide
end
def reference_guide_props
# Temporary stuff
labels = {
parameter: 'Parameter',
type: 'Type',
description: 'Description'
}
cols = ['parameter', 'type', 'description']
rows = [{
parameter: 'account_id',
type: 'string',
description: 'The account id'
}]
{
paths: {
'/pets': {
'get': {
'summary': 'Get a pet',
'href': 'get-get-summary'
}
},
'/buildings': {
'post': {
'summary': 'Build a building',
'href': 'post-'
}
}
},
currentPath: {
url: '/pets',
summary: 'Get a pet',
description: 'A description if available',
request_params: {
labels: labels,
cols: cols,
rows: rows
},
response_params: {
labels: labels,
cols: cols,
rows: rows
}
},
request: '$ curl https://api.stripe.com/v1/recipients/rp_19aAOR2eZvKYlo2CY3uUm6AA -u sk_test_BQokikJOvBiI2HlWgH4olfQ2',
responses: [
{
code: 200,
title: 'Ok',
schema: {account_id: 1, user_id: 2, player_id: 3}
},
{
code: 400,
title: 'Bad Request',
schema: {}
}
]
}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment