This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Rails style guided+ | |
#-------------------- 1. includes and extend -------------- | |
#-------------------- 2. default scope -------------------- | |
#-------------------- 3. inner classes -------------------- | |
#-------------------- 4. constants ------------------------ | |
#-------------------- 5. attr related macros -------------- | |
#-------------------- 6. enums ---------------------------- | |
#-------------------- 7. scopes --------------------------- | |
#-------------------- 8. has and belongs ------------------ | |
#-------------------- 9. accept nested macros ------------ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% module_namespacing do -%> | |
class <%= class_name %> < <%= parent_class_name.classify %> | |
# Rails style guided+ | |
#-------------------- 1. includes and extend -------------- | |
#-------------------- 2. default scope -------------------- | |
#-------------------- 3. inner classes -------------------- | |
#-------------------- 5. attr related macros -------------- | |
#-------------------- 6. enums ---------------------------- | |
#-------------------- 7. scopes --------------------------- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# in order to access ENV you need to include your env recipe | |
include_recipe 'application::env' | |
chef_gem 'aws-sdk' do | |
version '2.7.9' | |
end | |
require 'aws-sdk' | |
owc = Aws::OpsWorks::Client.new( region: 'us-east-1' ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# spec/integration/blogs_spec.rb | |
require 'swagger_helper' | |
describe 'Blogs API' do | |
path '/blogs' do | |
post 'Creates a blog' do | |
tags 'Blogs' | |
consumes 'application/json', 'application/xml' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require_relative "../../spec_helper" | |
document Albums::Create do | |
meta :group, "Albums" | |
meta :request_method, "POST" | |
meta :request_path, "/albums" | |
meta :description, "Creates a new album with the given parameters." | |
param "name", "Name of the album", required: true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UsersController < ApplicationController | |
resource_description do | |
formats [:json] | |
api_versions 'public' | |
end | |
api :POST, '/users' 'Create user' | |
description 'Create user with specifed user params' | |
param :user, Hash, desc: 'User information' do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Api::V1::UsersController < ApplicationController | |
..... | |
# POST /users | |
swagger_api :create do | |
summary "To create user" | |
notes "Implementation notes, such as required params, example queries for apis are written here." | |
param :form, "user[name]", :string, :required, "Name of user" | |
param :form, "user[age]", :integer, :optional, "Age of user" | |
param_list :form, "user[status]", :string, :required, "Status of user, can be active or inactive" | |
response :success |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#cards_api_test.rb | |
require 'test_helper' | |
require 'mini_apivore_helper' | |
class CardsApiTest < MiniApivoreTest | |
#------- DEFINE CLASS SPECIFIC NAMED ROUTE HELPERS ---------------- | |
def __get_cards(expectation) | |
check_route( :get, '/cards.json', expectation ) | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AutocompleteControllerDoc | |
include Swagger::Blocks | |
swagger_path '/autocomplete.json' do | |
operation :get, | |
summary: 'Fetches autocompletes on Cards titles and tags', | |
description: 'Returns nearest completions for words in card titles and tags,'\ | |
' respects card restrictions and privacy rules', | |
tags: ['autocomple'] do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
EXPLAIN ANALYZE SELECT id, title FROM "cards" | |
WHERE (title_tsv @@ to_tsquery( 'english', '(o:*|o)')) AND collection_id = 624 | |
LIMIT 10; | |
QUERY PLAN | |
----------------------------------------------------------------------------------------------------------------------------------------------------------------- | |
Limit (cost=408.55..447.93 rows=10 width=57) (actual time=273.000..273.103 rows=10 loops=1) | |
-> Bitmap Heap Scan on cards (cost=408.55..554.24 rows=37 width=57) (actual time=272.999..273.101 rows=10 loops=1) | |
Recheck Cond: ((collection_id = 624) AND (title_tsv @@ '''o'':* | ''o'''::tsquery) ) | |
Heap Blocks: exact=10 | |
-> BitmapAnd (cost=408.55..408.55 rows=37 width=0) (actual time=272.973..272.973 rows=0 loops=1) |