rails setup

This commit is contained in:
Mark Moser 2016-08-27 16:32:04 -05:00
parent ceb14fc74b
commit 8ff9ca02f8
15 changed files with 519 additions and 66 deletions

47
.gitignore vendored
View File

@ -12,6 +12,53 @@
/tmp/*
!/log/.keep
!/tmp/.keep
tmux*log
### Ruby ###
*.gem
*.rbc
/.config
/coverage/
/InstalledFiles
/pkg/
/spec/reports/
/spec/examples.txt
/test/tmp/
/test/version_tmp/
/tmp/
## Documentation cache and generated files:
/.yardoc/
/_yardoc/
/doc/
/rdoc/
## Environment normalisation:
/.bundle/
/vendor/bundle
/lib/bundler/man/
/vendor/assets/*
bower_components/
node_modules/
.DS_Store
## Public directory assets
public/assets
### Vim ###
[._]*.s[a-w][a-z]
[._]s[a-w][a-z]
*.un~
Session.vim
.netrwhist
*~
### Application Secrets ###
application.yml
# Ignore Byebug command history file.
.byebug_history
# Ignore application configuration
/config/application.yml
.container-setup

55
.rubocop.yml Normal file
View File

@ -0,0 +1,55 @@
AllCops:
Exclude:
- db/schema.rb
- db/seeds.rb
- bin/**/*
- vendor/assets/**/*
Style/AndOr:
Enabled: false
Style/ClassAndModuleChildren:
Exclude:
- test/test_helper.rb
Style/Documentation:
Enabled: false
Style/EmptyLines:
Exclude:
- config/initializers/sorcery.rb
Style/ExtraSpacing:
Exclude:
- db/migrate/**/*
Style/IndentationConsistency:
EnforcedStyle: rails
Exclude:
- config/routes.rb
Style/MethodDefParentheses:
Enabled: false
Style/SpaceBeforeFirstArg:
Exclude:
- config/routes.rb
Style/StringLiterals:
Enabled: false
Metrics/AbcSize:
Exclude:
- db/migrate/**/*
Metrics/LineLength:
Max: 110
Exclude:
- Rakefile
- config/**/*
- lib/tasks/**/*
- test/test_helper.rb
Metrics/MethodLength:
Exclude:
- db/migrate/*

63
Gemfile
View File

@ -1,48 +1,39 @@
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.0.0', '>= 5.0.0.1'
# Use mysql as the database for Active Record
gem 'figaro', '~> 1.1.1'
gem 'bcrypt', '~> 3.1.7'
gem 'mysql2', '>= 0.3.18', '< 0.5'
# Use Puma as the app server
gem 'puma', '~> 3.0'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
gem 'rails', '~> 5.0', '>= 5.0.0.1'
# Use jquery as the JavaScript library
gem 'jbuilder', '~> 2.6'
gem 'jquery-rails'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'json', '~> 2.0.2'
gem 'puma', '~> 3.0'
gem 'sass-rails', '~> 5.0'
gem 'settingslogic', '~> 2.0.9'
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 3.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platform: :mri
end
gem 'uglifier', '>= 1.3.0'
group :development do
# Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
gem 'rack-livereload'
gem 'web-console'
gem 'listen', '~> 3.0.5'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
end
group :development, :test do
gem 'awesome_print'
gem 'binding_of_caller'
gem 'byebug', platform: :mri
gem 'guard'
gem 'guard-livereload'
gem 'guard-minitest'
gem 'guard-rubocop'
gem 'guard-shell'
gem 'listen', '~> 3.0'
gem 'minitest-reporters'
gem 'pry-byebug'
gem 'pry-rails'
gem 'rubocop', '~> 0.42.0'
gem 'simplecov', require: false
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

267
Gemfile.lock Normal file
View File

@ -0,0 +1,267 @@
GEM
remote: https://rubygems.org/
specs:
actioncable (5.0.0.1)
actionpack (= 5.0.0.1)
nio4r (~> 1.2)
websocket-driver (~> 0.6.1)
actionmailer (5.0.0.1)
actionpack (= 5.0.0.1)
actionview (= 5.0.0.1)
activejob (= 5.0.0.1)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (5.0.0.1)
actionview (= 5.0.0.1)
activesupport (= 5.0.0.1)
rack (~> 2.0)
rack-test (~> 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (5.0.0.1)
activesupport (= 5.0.0.1)
builder (~> 3.1)
erubis (~> 2.7.0)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
activejob (5.0.0.1)
activesupport (= 5.0.0.1)
globalid (>= 0.3.6)
activemodel (5.0.0.1)
activesupport (= 5.0.0.1)
activerecord (5.0.0.1)
activemodel (= 5.0.0.1)
activesupport (= 5.0.0.1)
arel (~> 7.0)
activesupport (5.0.0.1)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (~> 0.7)
minitest (~> 5.1)
tzinfo (~> 1.1)
ansi (1.5.0)
arel (7.1.1)
ast (2.3.0)
awesome_print (1.7.0)
bcrypt (3.1.11)
binding_of_caller (0.7.2)
debug_inspector (>= 0.0.1)
builder (3.2.2)
byebug (9.0.5)
coderay (1.1.1)
concurrent-ruby (1.0.2)
debug_inspector (0.0.2)
docile (1.1.5)
em-websocket (0.5.1)
eventmachine (>= 0.12.9)
http_parser.rb (~> 0.6.0)
erubis (2.7.0)
eventmachine (1.2.0.1)
execjs (2.7.0)
ffi (1.9.14)
figaro (1.1.1)
thor (~> 0.14)
formatador (0.2.5)
globalid (0.3.7)
activesupport (>= 4.1.0)
guard (2.14.0)
formatador (>= 0.2.4)
listen (>= 2.7, < 4.0)
lumberjack (~> 1.0)
nenv (~> 0.1)
notiffany (~> 0.0)
pry (>= 0.9.12)
shellany (~> 0.0)
thor (>= 0.18.1)
guard-compat (1.2.1)
guard-livereload (2.5.2)
em-websocket (~> 0.5)
guard (~> 2.8)
guard-compat (~> 1.0)
multi_json (~> 1.8)
guard-minitest (2.4.6)
guard-compat (~> 1.2)
minitest (>= 3.0)
guard-rubocop (1.2.0)
guard (~> 2.0)
rubocop (~> 0.20)
guard-shell (0.7.1)
guard (>= 2.0.0)
guard-compat (~> 1.0)
http_parser.rb (0.6.0)
i18n (0.7.0)
jbuilder (2.6.0)
activesupport (>= 3.0.0, < 5.1)
multi_json (~> 1.2)
jquery-rails (4.2.1)
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
json (2.0.2)
listen (3.1.5)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
ruby_dep (~> 1.2)
loofah (2.0.3)
nokogiri (>= 1.5.9)
lumberjack (1.0.10)
mail (2.6.4)
mime-types (>= 1.16, < 4)
method_source (0.8.2)
mime-types (3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521)
mini_portile2 (2.1.0)
minitest (5.9.0)
minitest-reporters (1.1.11)
ansi
builder
minitest (>= 5.0)
ruby-progressbar
multi_json (1.12.1)
mysql2 (0.4.4)
nenv (0.3.0)
nio4r (1.2.1)
nokogiri (1.6.8)
mini_portile2 (~> 2.1.0)
pkg-config (~> 1.1.7)
notiffany (0.1.1)
nenv (~> 0.1)
shellany (~> 0.0)
parser (2.3.1.2)
ast (~> 2.2)
pkg-config (1.1.7)
powerpack (0.1.1)
pry (0.10.4)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
slop (~> 3.4)
pry-byebug (3.4.0)
byebug (~> 9.0)
pry (~> 0.10)
pry-rails (0.3.4)
pry (>= 0.9.10)
puma (3.6.0)
rack (2.0.1)
rack-livereload (0.3.16)
rack
rack-test (0.6.3)
rack (>= 1.0)
rails (5.0.0.1)
actioncable (= 5.0.0.1)
actionmailer (= 5.0.0.1)
actionpack (= 5.0.0.1)
actionview (= 5.0.0.1)
activejob (= 5.0.0.1)
activemodel (= 5.0.0.1)
activerecord (= 5.0.0.1)
activesupport (= 5.0.0.1)
bundler (>= 1.3.0, < 2.0)
railties (= 5.0.0.1)
sprockets-rails (>= 2.0.0)
rails-dom-testing (2.0.1)
activesupport (>= 4.2.0, < 6.0)
nokogiri (~> 1.6.0)
rails-html-sanitizer (1.0.3)
loofah (~> 2.0)
railties (5.0.0.1)
actionpack (= 5.0.0.1)
activesupport (= 5.0.0.1)
method_source
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rainbow (2.1.0)
rake (11.2.2)
rb-fsevent (0.9.7)
rb-inotify (0.9.7)
ffi (>= 0.5.0)
rubocop (0.42.0)
parser (>= 2.3.1.1, < 3.0)
powerpack (~> 0.1)
rainbow (>= 1.99.1, < 3.0)
ruby-progressbar (~> 1.7)
unicode-display_width (~> 1.0, >= 1.0.1)
ruby-progressbar (1.8.1)
ruby_dep (1.4.0)
sass (3.4.22)
sass-rails (5.0.6)
railties (>= 4.0.0, < 6)
sass (~> 3.1)
sprockets (>= 2.8, < 4.0)
sprockets-rails (>= 2.0, < 4.0)
tilt (>= 1.1, < 3)
settingslogic (2.0.9)
shellany (0.0.1)
simplecov (0.12.0)
docile (~> 1.1.0)
json (>= 1.8, < 3)
simplecov-html (~> 0.10.0)
simplecov-html (0.10.0)
slop (3.6.0)
spring (1.7.2)
spring-watcher-listen (2.0.0)
listen (>= 2.7, < 4.0)
spring (~> 1.2)
sprockets (3.7.0)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.1.1)
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
thor (0.19.1)
thread_safe (0.3.5)
tilt (2.0.5)
turbolinks (5.0.1)
turbolinks-source (~> 5)
turbolinks-source (5.0.0)
tzinfo (1.2.2)
thread_safe (~> 0.1)
uglifier (3.0.2)
execjs (>= 0.3.0, < 3)
unicode-display_width (1.1.0)
web-console (3.3.1)
actionview (>= 5.0)
activemodel (>= 5.0)
debug_inspector
railties (>= 5.0)
websocket-driver (0.6.4)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.2)
PLATFORMS
ruby
DEPENDENCIES
awesome_print
bcrypt (~> 3.1.7)
binding_of_caller
byebug
figaro (~> 1.1.1)
guard
guard-livereload
guard-minitest
guard-rubocop
guard-shell
jbuilder (~> 2.6)
jquery-rails
json (~> 2.0.2)
listen (~> 3.0)
minitest-reporters
mysql2 (>= 0.3.18, < 0.5)
pry-byebug
pry-rails
puma (~> 3.0)
rack-livereload
rails (~> 5.0, >= 5.0.0.1)
rubocop (~> 0.42.0)
sass-rails (~> 5.0)
settingslogic (~> 2.0.9)
simplecov
spring
spring-watcher-listen (~> 2.0.0)
turbolinks (~> 5)
uglifier (>= 1.3.0)
web-console
BUNDLED WITH
1.12.5

36
Guardfile Normal file
View File

@ -0,0 +1,36 @@
# guard 'livereload' do
# watch(%r{app/assets/.+\.(scss|css|js|erb)})
# watch(%r{app/views/.+\.(erb|haml|slim)$})
# watch(%r{app/controllers/.+\.rb})
# watch(%r{app/helpers/.+\.rb})
# watch(%r{public/.+\.(css|js|html)})
# watch(%r{config/locales/.+\.yml})
#
# # Rails Assets Pipeline
# watch(%r{(app|vendor)(/assets/\w+/(.+\.(scss|css|js|erb|html|png|jpg))).*}) do |m|
# "/assets/#{m[3]}"
# end
# end
guard :minitest, spring: true, all_after_pass: true do
watch(%r{^test/test_helper\.rb$}) { 'test' }
watch(%r{^test/(.*)\/?(.*)_test\.rb$})
# run tests when touching files matching: /app/**/*.rb
watch(%r{^app/(.*/)?([^/]+)\.rb$}) { |m| ["test/#{m[1]}#{m[2]}_test.rb", "test/#{m[1]}#{m[2]}"] }
# run tests when touching files matching: /lib/**/*.rb
watch(%r{^lib/(.*/)?([^/]+)\.rb$}) { |m| ["test/lib/#{m[1]}#{m[2]}_test.rb", "test/lib/#{m[1]}#{m[2]}"] }
# run controller/integration test when touching erb files
watch(%r{^app/views/((?!_mailer).)*([^/]+)\.erb$}) { ["test/controllers", "test/integration"] }
# run mailers/integration test when touching mailer erb files
watch(%r{^app/views/(.*_mailer/)?([^/]+)\.erb$}) { ["test/mailers", "test/integration"] }
end
guard :rubocop do
watch(/.+\.rb$/)
watch(/Rakefile/)
watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
end

View File

@ -1,24 +1 @@
# README
This README would normally document whatever steps are necessary to get the
application up and running.
Things you may want to cover:
* Ruby version
* System dependencies
* Configuration
* Database creation
* Database initialization
* How to run the test suite
* Services (job queues, cache servers, search engines, etc.)
* Deployment instructions
* ...
A simple FTP Virtual User manager

View File

@ -0,0 +1,6 @@
class AppConfig < Settingslogic
source "#{Rails.root}/config/application.yml"
namespace Rails.env
suppress_errors Rails.env.production?
load!
end

View File

@ -11,5 +11,13 @@ module FtpManager
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
config.action_mailer.default_url_options = { host: ENV['full_app_url'] }
config.generators do |g|
g.assets false
g.helper false
g.routes false
end
end
end

View File

@ -0,0 +1,20 @@
# Add configuration values here, as shown below.
defaults: &defaults
mysql_host: "localhost"
mysql_usr: "user"
mysql_pwd: "password"
full_app_url: "localhost:3000"
development:
<<: *defaults
test:
<<: *defaults
production:
<<: *defaults
mysql_usr: "user"
mysql_pwd: "password!"
secret_key_base: "super-long-secret-key-base"
full_app_url: "production.domain.com/sub-folder/"

View File

@ -13,8 +13,9 @@ default: &default
adapter: mysql2
encoding: utf8
pool: 5
username: root
password:
host: <%= ENV['mysql_host'] %>
username: <%= ENV['mysql_usr'] %>
password: <%= ENV['mysql_pwd'] %>
socket: /var/run/mysqld/mysqld.sock
development:

View File

@ -47,7 +47,7 @@ Rails.application.configure do
config.log_level = :debug
# Prepend all log lines with the following tags.
config.log_tags = [ :request_id ]
config.log_tags = [:request_id]
# Use a different cache store in production.
# config.cache_store = :mem_cache_store

View File

@ -19,4 +19,4 @@ test:
# Do not keep production secrets in the repository,
# instead read values from the environment.
production:
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
secret_key_base: <%= ENV["secret_key_base"] %>

15
db/schema.rb Normal file
View File

@ -0,0 +1,15 @@
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative source for your
# database schema. If you need to create the application database on another
# system, you should be using db:schema:load, not running all the migrations
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 0) do
end

View File

@ -0,0 +1,17 @@
require 'test_helper'
class AppConfigTest < ActiveSupport::TestCase
test "verify sample file exists" do
assert File.exist? "#{Rails.root}/config/application.yml.sample"
end
test "verify config file exists" do
assert File.exist? "#{Rails.root}/config/application.yml"
end
test 'config can load and return proper values' do
config = AppConfig.new
assert_equal 'localhost', config.mysql_host
end
end

View File

@ -1,10 +1,23 @@
ENV['RAILS_ENV'] ||= 'test'
# https://github.com/colszowka/simplecov
require 'simplecov'
SimpleCov.start 'rails' do
add_group 'Models', %w(app/models app/validators)
add_group 'PORO', %w(app/services)
end
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
require "minitest/autorun"
require 'minitest/reporters'
Dir[Rails.root.join("test/test_helpers/**/*.rb")].each { |f| require f }
Minitest::Reporters.use! [Minitest::Reporters::DefaultReporter.new(color: true)]
class ActiveSupport::TestCase
ActiveRecord::Migration.check_pending!
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
fixtures :all
# Add more helper methods to be used by all tests here...
end