Skip to content
This repository was archived by the owner on Nov 1, 2022. It is now read-only.

Commit 2d1d9d3

Browse files
committed
Initial commit
0 parents  commit 2d1d9d3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+950
-0
lines changed

.gitignore

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# See https://help.github.com/articles/ignoring-files for more about ignoring files.
2+
#
3+
# If you find yourself ignoring temporary files generated by your text editor
4+
# or operating system, you probably want to add a global ignore instead:
5+
# git config --global core.excludesfile '~/.gitignore_global'
6+
7+
# Ignore bundler config.
8+
/.bundle
9+
10+
# Ignore the default SQLite database.
11+
/db/*.sqlite3
12+
/db/*.sqlite3-journal
13+
14+
# Ignore all logfiles and tempfiles.
15+
/log/*
16+
!/log/.keep
17+
/tmp

Gemfile

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
source 'https://rubygems.org'
2+
3+
4+
gem 'rails', '4.2.0'
5+
6+
gem 'rails-api'
7+
8+
gem 'spring', :group => :development
9+
10+
11+
gem 'sqlite3'
12+
13+
gem 'apipie-rails'
14+
15+
16+
# To use ActiveModel has_secure_password
17+
# gem 'bcrypt', '~> 3.1.7'
18+
19+
# To use Jbuilder templates for JSON
20+
# gem 'jbuilder'
21+
22+
# Use unicorn as the app server
23+
# gem 'unicorn'
24+
25+
# Deploy with Capistrano
26+
# gem 'capistrano', :group => :development
27+
28+
# To use debugger
29+
# gem 'ruby-debug19', :require => 'ruby-debug'

Gemfile.lock

+115
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
GEM
2+
remote: https://rubygems.org/
3+
specs:
4+
actionmailer (4.2.0)
5+
actionpack (= 4.2.0)
6+
actionview (= 4.2.0)
7+
activejob (= 4.2.0)
8+
mail (~> 2.5, >= 2.5.4)
9+
rails-dom-testing (~> 1.0, >= 1.0.5)
10+
actionpack (4.2.0)
11+
actionview (= 4.2.0)
12+
activesupport (= 4.2.0)
13+
rack (~> 1.6.0)
14+
rack-test (~> 0.6.2)
15+
rails-dom-testing (~> 1.0, >= 1.0.5)
16+
rails-html-sanitizer (~> 1.0, >= 1.0.1)
17+
actionview (4.2.0)
18+
activesupport (= 4.2.0)
19+
builder (~> 3.1)
20+
erubis (~> 2.7.0)
21+
rails-dom-testing (~> 1.0, >= 1.0.5)
22+
rails-html-sanitizer (~> 1.0, >= 1.0.1)
23+
activejob (4.2.0)
24+
activesupport (= 4.2.0)
25+
globalid (>= 0.3.0)
26+
activemodel (4.2.0)
27+
activesupport (= 4.2.0)
28+
builder (~> 3.1)
29+
activerecord (4.2.0)
30+
activemodel (= 4.2.0)
31+
activesupport (= 4.2.0)
32+
arel (~> 6.0)
33+
activesupport (4.2.0)
34+
i18n (~> 0.7)
35+
json (~> 1.7, >= 1.7.7)
36+
minitest (~> 5.1)
37+
thread_safe (~> 0.3, >= 0.3.4)
38+
tzinfo (~> 1.1)
39+
apipie-rails (0.3.1)
40+
json
41+
arel (6.0.0)
42+
builder (3.2.2)
43+
erubis (2.7.0)
44+
globalid (0.3.3)
45+
activesupport (>= 4.1.0)
46+
hike (1.2.3)
47+
i18n (0.7.0)
48+
json (1.8.2)
49+
loofah (2.0.1)
50+
nokogiri (>= 1.5.9)
51+
mail (2.6.3)
52+
mime-types (>= 1.16, < 3)
53+
mime-types (2.4.3)
54+
mini_portile (0.6.2)
55+
minitest (5.5.1)
56+
multi_json (1.10.1)
57+
nokogiri (1.6.6.2)
58+
mini_portile (~> 0.6.0)
59+
rack (1.6.0)
60+
rack-test (0.6.3)
61+
rack (>= 1.0)
62+
rails (4.2.0)
63+
actionmailer (= 4.2.0)
64+
actionpack (= 4.2.0)
65+
actionview (= 4.2.0)
66+
activejob (= 4.2.0)
67+
activemodel (= 4.2.0)
68+
activerecord (= 4.2.0)
69+
activesupport (= 4.2.0)
70+
bundler (>= 1.3.0, < 2.0)
71+
railties (= 4.2.0)
72+
sprockets-rails
73+
rails-api (0.4.0)
74+
actionpack (>= 3.2.11)
75+
railties (>= 3.2.11)
76+
rails-deprecated_sanitizer (1.0.3)
77+
activesupport (>= 4.2.0.alpha)
78+
rails-dom-testing (1.0.5)
79+
activesupport (>= 4.2.0.beta, < 5.0)
80+
nokogiri (~> 1.6.0)
81+
rails-deprecated_sanitizer (>= 1.0.1)
82+
rails-html-sanitizer (1.0.1)
83+
loofah (~> 2.0)
84+
railties (4.2.0)
85+
actionpack (= 4.2.0)
86+
activesupport (= 4.2.0)
87+
rake (>= 0.8.7)
88+
thor (>= 0.18.1, < 2.0)
89+
rake (10.4.2)
90+
spring (1.3.3)
91+
sprockets (2.12.3)
92+
hike (~> 1.2)
93+
multi_json (~> 1.0)
94+
rack (~> 1.0)
95+
tilt (~> 1.1, != 1.3.0)
96+
sprockets-rails (2.2.4)
97+
actionpack (>= 3.0)
98+
activesupport (>= 3.0)
99+
sprockets (>= 2.8, < 4.0)
100+
sqlite3 (1.3.10)
101+
thor (0.19.1)
102+
thread_safe (0.3.4)
103+
tilt (1.4.1)
104+
tzinfo (1.2.2)
105+
thread_safe (~> 0.1)
106+
107+
PLATFORMS
108+
ruby
109+
110+
DEPENDENCIES
111+
apipie-rails
112+
rails (= 4.2.0)
113+
rails-api
114+
spring
115+
sqlite3

README.rdoc

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
== README
2+
3+
This README would normally document whatever steps are necessary to get the
4+
application up and running.
5+
6+
Things you may want to cover:
7+
8+
* Ruby version
9+
10+
* System dependencies
11+
12+
* Configuration
13+
14+
* Database creation
15+
16+
* Database initialization
17+
18+
* How to run the test suite
19+
20+
* Services (job queues, cache servers, search engines, etc.)
21+
22+
* Deployment instructions
23+
24+
* ...
25+
26+
27+
Please feel free to use a different markup language if you do not plan to run
28+
<tt>rake doc:app</tt>.

Rakefile

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Add your own tasks in files placed in lib/tasks ending in .rake,
2+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3+
4+
require File.expand_path('../config/application', __FILE__)
5+
6+
Rails.application.load_tasks

app/assets/images/.keep

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
class ApplicationController < ActionController::API
2+
end

app/controllers/concerns/.keep

Whitespace-only changes.

app/controllers/posts_controller.rb

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
class PostsController < ApplicationController
2+
before_action :set_post, only: [:show, :update, :destroy]
3+
4+
# GET /posts
5+
# GET /posts.json
6+
api!
7+
def index
8+
@posts = Post.all
9+
10+
render json: @posts
11+
end
12+
13+
# GET /posts/1
14+
# GET /posts/1.json
15+
api :GET, '/posts/:id'
16+
param :id, :number
17+
def show
18+
render json: @post
19+
end
20+
21+
# POST /posts
22+
# POST /posts.json
23+
def create
24+
@post = Post.new(post_params)
25+
26+
if @post.save
27+
render json: @post, status: :created, location: @post
28+
else
29+
render json: @post.errors, status: :unprocessable_entity
30+
end
31+
end
32+
33+
# PATCH/PUT /posts/1
34+
# PATCH/PUT /posts/1.json
35+
def update
36+
@post = Post.find(params[:id])
37+
38+
if @post.update(post_params)
39+
head :no_content
40+
else
41+
render json: @post.errors, status: :unprocessable_entity
42+
end
43+
end
44+
45+
# DELETE /posts/1
46+
# DELETE /posts/1.json
47+
def destroy
48+
@post.destroy
49+
50+
head :no_content
51+
end
52+
53+
private
54+
55+
def set_post
56+
@post = Post.find(params[:id])
57+
end
58+
59+
def post_params
60+
params.require(:post).permit(:title, :content)
61+
end
62+
end

app/mailers/.keep

Whitespace-only changes.

app/models/.keep

Whitespace-only changes.

app/models/concerns/.keep

Whitespace-only changes.

app/models/post.rb

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
class Post < ActiveRecord::Base
2+
end

bin/bundle

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env ruby
2+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3+
load Gem.bin_path('bundler', 'bundle')

bin/rails

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env ruby
2+
begin
3+
load File.expand_path("../spring", __FILE__)
4+
rescue LoadError
5+
end
6+
APP_PATH = File.expand_path('../../config/application', __FILE__)
7+
require_relative '../config/boot'
8+
require 'rails/commands'

bin/rake

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env ruby
2+
begin
3+
load File.expand_path("../spring", __FILE__)
4+
rescue LoadError
5+
end
6+
require_relative '../config/boot'
7+
require 'rake'
8+
Rake.application.run

bin/setup

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env ruby
2+
require 'pathname'
3+
4+
# path to your application root.
5+
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
6+
7+
Dir.chdir APP_ROOT do
8+
# This script is a starting point to setup your application.
9+
# Add necessary setup steps to this file:
10+
11+
puts "== Installing dependencies =="
12+
system "gem install bundler --conservative"
13+
system "bundle check || bundle install"
14+
15+
# puts "\n== Copying sample files =="
16+
# unless File.exist?("config/database.yml")
17+
# system "cp config/database.yml.sample config/database.yml"
18+
# end
19+
20+
puts "\n== Preparing database =="
21+
system "bin/rake db:setup"
22+
23+
puts "\n== Removing old logs and tempfiles =="
24+
system "rm -f log/*"
25+
system "rm -rf tmp/cache"
26+
27+
puts "\n== Restarting application server =="
28+
system "touch tmp/restart.txt"
29+
end

bin/spring

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env ruby
2+
3+
# This file loads spring without using Bundler, in order to be fast.
4+
# It gets overwritten when you run the `spring binstub` command.
5+
6+
unless defined?(Spring)
7+
require "rubygems"
8+
require "bundler"
9+
10+
if match = Bundler.default_lockfile.read.match(/^GEM$.*?^ (?: )*spring \((.*?)\)$.*?^$/m)
11+
Gem.paths = { "GEM_PATH" => [Bundler.bundle_path.to_s, *Gem.path].uniq }
12+
gem "spring", match[1]
13+
require "spring/binstub"
14+
end
15+
end

config.ru

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# This file is used by Rack-based servers to start the application.
2+
3+
require ::File.expand_path('../config/environment', __FILE__)
4+
run Rails.application

config/application.rb

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
require File.expand_path('../boot', __FILE__)
2+
3+
require 'rails/all'
4+
5+
# Require the gems listed in Gemfile, including any gems
6+
# you've limited to :test, :development, or :production.
7+
Bundler.require(*Rails.groups)
8+
9+
module RailsApipieSample
10+
class Application < Rails::Application
11+
# Settings in config/environments/* take precedence over those specified here.
12+
# Application configuration should go into files in config/initializers
13+
# -- all .rb files in that directory are automatically loaded.
14+
15+
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
16+
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
17+
# config.time_zone = 'Central Time (US & Canada)'
18+
19+
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
20+
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
21+
# config.i18n.default_locale = :de
22+
23+
# Do not swallow errors in after_commit/after_rollback callbacks.
24+
config.active_record.raise_in_transactional_callbacks = true
25+
end
26+
end

config/boot.rb

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
2+
3+
require 'bundler/setup' # Set up gems listed in the Gemfile.

config/database.yml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# SQLite version 3.x
2+
# gem install sqlite3
3+
#
4+
# Ensure the SQLite 3 gem is defined in your Gemfile
5+
# gem 'sqlite3'
6+
#
7+
default: &default
8+
adapter: sqlite3
9+
pool: 5
10+
timeout: 5000
11+
12+
development:
13+
<<: *default
14+
database: db/development.sqlite3
15+
16+
# Warning: The database defined as "test" will be erased and
17+
# re-generated from your development database when you run "rake".
18+
# Do not set this db to the same as development or production.
19+
test:
20+
<<: *default
21+
database: db/test.sqlite3
22+
23+
production:
24+
<<: *default
25+
database: db/production.sqlite3

0 commit comments

Comments
 (0)