barebones 1.0.0.0 → 1.0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e9de26ec348e44f68db6bcb250cabe0c05a0d57e
4
- data.tar.gz: 18b35bd17aa110dc60f465606d1215c692a37186
3
+ metadata.gz: 6730d84018a95de05e6d6a911df3375a2bfd5d15
4
+ data.tar.gz: 3b6359919ce2d8c0f28915bf486c057817faabf3
5
5
  SHA512:
6
- metadata.gz: '01903bbe5d5ede62183242c35ae213c2a311bcd195accf0b2e21894693153cdfcac88fc17688ee6ad7661d5b2c0bba87e5c619ab91f56692fd84bac240fcf5ad'
7
- data.tar.gz: d3de2c5ea3ac84b1e8631f4d8e46aea9ea24eb0c2eb9fe61d02005f41914d14c316a064b6b8410bae50bd822ec15a15dc5a6b9d619b1234bca6a430e5818312e
6
+ metadata.gz: 13fbdf96ed289e8fc4c642ec8cbdec3d2a39bc0fbe63242395dd8bccdcf68a50bd4e225018808a200f783ebca6d3d36b7c2115727a7051ce60e00f1f6d40e00f
7
+ data.tar.gz: dd3503fd99e785af18e154d4c1b31eaa8dd05505be8bfb1bab82f1c39f8491c65b54b88da66af7f3eb049295d8a14a54846eaf846d2f407113c1b343ba1e08af
data/README.md CHANGED
@@ -44,7 +44,7 @@ Barebones' [Gemfile](templates/Gemfile.erb) includes various preconfigured gems
44
44
  * [Byebug](https://github.com/deivid-rodriguez/byebug) for debugging
45
45
  * [Pry Byebug](https://github.com/deivid-rodriguez/pry-byebug) for debugging background jobs
46
46
  * [Web Console](https://github.com/rails/web-console) for debugging views
47
- * [Awesome Print](https://github.com/michaeldv/awesome_print) for pretty printing command line objects
47
+ * [Awesome Print](https://github.com/awesome-print/awesome_print) for pretty printing command line objects
48
48
 
49
49
  ##Testing
50
50
  * [Minitest](https://github.com/blowmage/minitest-rails) for TDD/BDD
@@ -76,4 +76,4 @@ PostgreSQL (9.4) on your local machine.
76
76
  Barebones is copyright © 2015-2016 Danny Yu.
77
77
  It is free software, and may be redistributed under the terms specified in the [LICENSE] file.
78
78
 
79
- [LICENSE]: LICENSE
79
+ [LICENSE]: LICENSE
data/barebones.gemspec CHANGED
@@ -3,7 +3,7 @@ require "date"
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "barebones"
6
- s.version = "1.0.0.0"
6
+ s.version = "1.0.0.1"
7
7
  s.date = Date.today.to_s
8
8
  s.licenses = ['MIT']
9
9
  s.summary = "Rails template generator"
@@ -75,9 +75,8 @@ module Barebones
75
75
  def create_api_layouts
76
76
  empty_directory "app/views/layouts/api/v1"
77
77
  template "layout.json.jbuilder", "app/views/layouts/api/v1/application.json.jbuilder"
78
- empty_directory "app/views/api/defaults"
79
- create_file "app/views/api/defaults/success.json.jbuilder"
80
- create_file "app/views/api/defaults/fail.json.jbuilder"
78
+ empty_directory "app/views/api/v1/defaults"
79
+ create_file "app/views/api/v1/defaults/default.json.jbuilder"
81
80
  end
82
81
 
83
82
  def customize_secrets
@@ -42,6 +42,7 @@ gem "carrierwave"
42
42
  gem "resque"
43
43
  gem "resque-scheduler"
44
44
  gem 'sinatra', github: 'sinatra/sinatra', branch: 'master'
45
+ gem 'rack-protection', github: 'sinatra/rack-protection'
45
46
  <% end %>
46
47
 
47
48
  # Database
@@ -1,18 +1,48 @@
1
1
  # <%= app_name.humanize %>
2
2
 
3
- ### Getting Started
3
+ ## Getting Started
4
4
 
5
- ## Setting Up Postgresql
5
+ ### Setting Up Postgresql
6
6
  `psql`
7
- `CREATE ROLE <%= app_name.parameterize.underscore %>_admin`
7
+ `CREATE ROLE <%= app_name.parameterize.underscore %>_admin;`
8
8
  `ALTER ROLE <%= app_name.parameterize.underscore %>_admin WITH LOGIN CREATEDB REPLICATION SUPERUSER;`
9
- `rake db:migrate`
10
- `rake db:setup`
9
+ `\q`
11
10
 
12
- ## Setting Up The Server
11
+ ### Installing Dependencies
12
+
13
+ To run this code, you must have Rails 5.0 and Ruby 2.3.1 installed. Then you just have to run:
14
+
15
+ `bundle install`
16
+
17
+ ### Setting Up The Server
13
18
 
14
19
  `bundle install`
15
- `rake db:migrate db:setup`
20
+ `rake db:setup db:migrate db:seed`
21
+
22
+ ### Hosts Files
23
+ The API uses a subdomain so if you wish to run this code locally, in your `/etc/hosts` file, you should add:
24
+
25
+ ```
26
+ 127.0.0.1 api.localhost.local
27
+ 127.0.0.1 devapi.localhost.local
28
+ ```
29
+
30
+ ### Running The Server
31
+ Run `rails s -p [port#]` to start the server.
32
+
33
+ ## The API
34
+
35
+ All local requests to the API should be done through the subdomain: `http://devapi.localhost.local:{PORT#}/`
36
+ All API requests default to using an accept header with `application/com.<%= app_name.parameterize.underscore %>_admin.v1` unless otherwise specified.
37
+
38
+ ### Standard Response Structure
39
+
40
+ The JSON response is modeled after the [JSend](https://labs.omniti.com/labs/jsend) Standard:
41
+
42
+ ```
43
+ {
44
+ status : 200,
45
+ data : {...}
46
+ }
16
47
 
17
- ## Running The Server
18
- Run `rails s -p [port#]` to start the server.
48
+ ```
@@ -3,25 +3,16 @@ module ApiDefaults
3
3
 
4
4
  # Default Paths
5
5
  API_VIEW_PATH = "api/v1"
6
- API_DEFAULT_SUCCESS_PATH = "defaults/success"
7
- API_DEFAULT_FAIL_PATH = "defaults/fail"
8
-
9
- # Statuses
10
- SUCCESS = 200
11
- INTERNAL_SERVER_ERROR = 500
6
+ API_DEFAULT_PATH = "defaults/default"
12
7
 
13
8
  included do
14
9
  layout 'api/v1/application'
15
10
 
16
- def render_api_success(path=ApiDefaults::API_DEFAULT_SUCCESS_PATH)
17
- @status = ApiDefaults::SUCCESS
18
- return render template: "#{API_VIEW_PATH}/#{path}", status: ApiDefaults::SUCCESS
11
+ def render_api(status, path=ApiDefaults::API_DEFAULT_PATH)
12
+ @status = status
13
+ return render template: "#{API_VIEW_PATH}/#{path}", status: status
19
14
  end
20
15
 
21
- def render_api_fail(path=ApiDefaults::API_DEFAULT_FAIL_PATH)
22
- @status = ApiDefaults::INTERNAL_SERVER_ERROR
23
- return render template: "#{API_VIEW_PATH}/#{path}", status: ApiDefaults::INTERNAL_SERVER_ERROR
24
- end
25
16
  end
26
17
 
27
18
  end
@@ -1,5 +1,7 @@
1
1
  class Api::V1::ConfigsController < Api::V1::ApplicationController
2
+
2
3
  def ping
3
- return render_api_success("configs/ping")
4
+ return render_api(200, "configs/ping")
4
5
  end
6
+
5
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: barebones
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.0
4
+ version: 1.0.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Danny Yu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-14 00:00:00.000000000 Z
11
+ date: 2016-07-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails