rake app:update

This commit is contained in:
Petko Bordjukov 2019-04-28 02:02:09 +03:00
parent 6ab333edf7
commit 88de288029
21 changed files with 245 additions and 86 deletions

View File

@ -2,7 +2,7 @@ source 'https://rubygems.org'
gem 'rails', '~> 5.0.1' gem 'rails', '~> 5.0.1'
gem 'sqlite3' gem 'sqlite3', '~> 1.3.6'
gem 'pg' gem 'pg'
gem 'sass-rails' gem 'sass-rails'
@ -30,7 +30,7 @@ gem 'carrierwave'
#gem 'rmagick' #gem 'rmagick'
gem "mini_magick" gem "mini_magick"
gem "refile", require: ['refile/rails', 'refile/simple_form'] gem "refile", github: 'refile/refile', require: ['refile/rails', 'refile/simple_form']
gem "image_processing" gem "image_processing"
gem 'puma', group: :production gem 'puma', group: :production

View File

@ -1,3 +1,11 @@
GIT
remote: git://github.com/refile/refile.git
revision: e910f5ca5a9060c307bd0a5e813f1fec73219ed5
specs:
refile (0.7.0)
mime-types
sinatra (>= 2.0.0, <= 3.0.0)
GEM GEM
remote: https://rubygems.org/ remote: https://rubygems.org/
specs: specs:
@ -197,7 +205,9 @@ GEM
mail (2.7.1) mail (2.7.1)
mini_mime (>= 0.1.1) mini_mime (>= 0.1.1)
method_source (0.9.2) method_source (0.9.2)
mime-types (2.99.3) mime-types (3.2.2)
mime-types-data (~> 3.2015)
mime-types-data (3.2019.0331)
mini_magick (4.9.3) mini_magick (4.9.3)
mini_mime (1.0.1) mini_mime (1.0.1)
mini_portile2 (2.4.0) mini_portile2 (2.4.0)
@ -208,12 +218,12 @@ GEM
railties (> 3.1, < 6) railties (> 3.1, < 6)
multi_json (1.13.1) multi_json (1.13.1)
multipart-post (2.0.0) multipart-post (2.0.0)
mustermann (1.0.3)
nenv (0.3.0) nenv (0.3.0)
nested_form (0.3.2) nested_form (0.3.2)
net-scp (2.0.0) net-scp (2.0.0)
net-ssh (>= 2.6.5, < 6.0.0) net-ssh (>= 2.6.5, < 6.0.0)
net-ssh (5.2.0) net-ssh (5.2.0)
netrc (0.11.0)
nio4r (2.3.1) nio4r (2.3.1)
nokogiri (1.10.3) nokogiri (1.10.3)
mini_portile2 (~> 2.4.0) mini_portile2 (~> 2.4.0)
@ -236,6 +246,8 @@ GEM
public_suffix (3.0.3) public_suffix (3.0.3)
puma (3.12.1) puma (3.12.1)
rack (2.0.7) rack (2.0.7)
rack-protection (2.0.5)
rack
rack-test (0.6.3) rack-test (0.6.3)
rack (>= 1.0) rack (>= 1.0)
rails (5.0.7.2) rails (5.0.7.2)
@ -275,17 +287,12 @@ GEM
rb-fsevent (0.10.3) rb-fsevent (0.10.3)
rb-inotify (0.10.0) rb-inotify (0.10.0)
ffi (~> 1.0) ffi (~> 1.0)
refile (0.3.0)
rest-client (~> 1.7.2)
regexp_parser (1.4.0) regexp_parser (1.4.0)
request_store (1.4.1) request_store (1.4.1)
rack (>= 1.4) rack (>= 1.4)
responders (2.4.1) responders (2.4.1)
actionpack (>= 4.2.0, < 6.0) actionpack (>= 4.2.0, < 6.0)
railties (>= 4.2.0, < 6.0) railties (>= 4.2.0, < 6.0)
rest-client (1.7.3)
mime-types (>= 1.16, < 3.0)
netrc (~> 0.7)
rqrcode (0.10.1) rqrcode (0.10.1)
chunky_png (~> 1.0) chunky_png (~> 1.0)
rspec (3.8.0) rspec (3.8.0)
@ -341,6 +348,11 @@ GEM
json (>= 1.8, < 3) json (>= 1.8, < 3)
simplecov-html (~> 0.10.0) simplecov-html (~> 0.10.0)
simplecov-html (0.10.2) simplecov-html (0.10.2)
sinatra (2.0.5)
mustermann (~> 1.0)
rack (~> 2.0)
rack-protection (= 2.0.5)
tilt (~> 2.0)
slim (4.0.1) slim (4.0.1)
temple (>= 0.7.6, < 0.9) temple (>= 0.7.6, < 0.9)
tilt (>= 2.0.6, < 2.1) tilt (>= 2.0.6, < 2.1)
@ -359,7 +371,7 @@ GEM
actionpack (>= 4.0) actionpack (>= 4.0)
activesupport (>= 4.0) activesupport (>= 4.0)
sprockets (>= 3.0.0) sprockets (>= 3.0.0)
sqlite3 (1.4.0) sqlite3 (1.3.13)
sshkit (1.18.2) sshkit (1.18.2)
net-scp (>= 1.1.2) net-scp (>= 1.1.2)
net-ssh (>= 2.8.0) net-ssh (>= 2.8.0)
@ -432,7 +444,7 @@ DEPENDENCIES
rails-erd rails-erd
rails-i18n rails-i18n
raphael-rails raphael-rails
refile refile!
rqrcode rqrcode
rspec-rails rspec-rails
sass-rails sass-rails
@ -443,7 +455,7 @@ DEPENDENCIES
slim-rails slim-rails
spring spring
spring-commands-rspec spring-commands-rspec
sqlite3 sqlite3 (~> 1.3.6)
uglifier uglifier
yaml_db yaml_db

View File

@ -1,8 +1,9 @@
#!/usr/bin/env ruby #!/usr/bin/env ruby
begin begin
load File.expand_path("../spring", __FILE__) load File.expand_path('../spring', __FILE__)
rescue LoadError rescue LoadError => e
raise unless e.message.include?('spring')
end end
APP_PATH = File.expand_path('../../config/application', __FILE__) APP_PATH = File.expand_path('../config/application', __dir__)
require_relative '../config/boot' require_relative '../config/boot'
require 'rails/commands' require 'rails/commands'

View File

@ -1,7 +1,8 @@
#!/usr/bin/env ruby #!/usr/bin/env ruby
begin begin
load File.expand_path("../spring", __FILE__) load File.expand_path('../spring', __FILE__)
rescue LoadError rescue LoadError => e
raise unless e.message.include?('spring')
end end
require_relative '../config/boot' require_relative '../config/boot'
require 'rake' require 'rake'

View File

@ -1,7 +1,8 @@
#!/usr/bin/env ruby #!/usr/bin/env ruby
begin begin
load File.expand_path("../spring", __FILE__) load File.expand_path('../spring', __FILE__)
rescue LoadError rescue LoadError => e
raise unless e.message.include?('spring')
end end
require 'bundler/setup' require 'bundler/setup'
load Gem.bin_path('rspec-core', 'rspec') load Gem.bin_path('rspec-core', 'rspec')

View File

@ -1,29 +1,34 @@
#!/usr/bin/env ruby #!/usr/bin/env ruby
require 'pathname' require 'pathname'
require 'fileutils'
include FileUtils
# path to your application root. # path to your application root.
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
Dir.chdir APP_ROOT do def system!(*args)
# This script is a starting point to setup your application. system(*args) || abort("\n== Command #{args} failed ==")
# Add necessary setup steps to this file: end
puts "== Installing dependencies ==" chdir APP_ROOT do
system "gem install bundler --conservative" # This script is a starting point to setup your application.
system "bundle check || bundle install" # Add necessary setup steps to this file.
puts '== Installing dependencies =='
system! 'gem install bundler --conservative'
system('bundle check') || system!('bundle install')
# puts "\n== Copying sample files ==" # puts "\n== Copying sample files =="
# unless File.exist?("config/database.yml") # unless File.exist?('config/database.yml')
# system "cp config/database.yml.sample config/database.yml" # cp 'config/database.yml.sample', 'config/database.yml'
# end # end
puts "\n== Preparing database ==" puts "\n== Preparing database =="
system "bin/rake db:setup" system! 'bin/rails db:setup'
puts "\n== Removing old logs and tempfiles ==" puts "\n== Removing old logs and tempfiles =="
system "rm -f log/*" system! 'bin/rails log:clear tmp:clear'
system "rm -rf tmp/cache"
puts "\n== Restarting application server ==" puts "\n== Restarting application server =="
system "touch tmp/restart.txt" system! 'bin/rails restart'
end end

View File

@ -1,18 +1,17 @@
#!/usr/bin/env ruby #!/usr/bin/env ruby
# This file loads spring without using Bundler, in order to be fast # This file loads spring without using Bundler, in order to be fast.
# It gets overwritten when you run the `spring binstub` command # It gets overwritten when you run the `spring binstub` command.
unless defined?(Spring) unless defined?(Spring)
require "rubygems" require 'rubygems'
require "bundler" require 'bundler'
if match = Bundler.default_lockfile.read.match(/^GEM$.*?^ spring \((.*?)\)$.*?^$/m) lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read)
ENV["GEM_PATH"] = ([Bundler.bundle_path.to_s] + Gem.path).join(File::PATH_SEPARATOR) spring = lockfile.specs.detect { |spec| spec.name == "spring" }
ENV["GEM_HOME"] = "" if spring
Gem.paths = ENV Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path
gem 'spring', spring.version
gem "spring", match[1] require 'spring/binstub'
require "spring/binstub"
end end
end end

29
bin/update Executable file
View File

@ -0,0 +1,29 @@
#!/usr/bin/env ruby
require 'pathname'
require 'fileutils'
include FileUtils
# path to your application root.
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
def system!(*args)
system(*args) || abort("\n== Command #{args} failed ==")
end
chdir APP_ROOT do
# This script is a way to update your development environment automatically.
# Add necessary update steps to this file.
puts '== Installing dependencies =='
system! 'gem install bundler --conservative'
system('bundle check') || system!('bundle install')
puts "\n== Updating database =="
system! 'bin/rails db:migrate'
puts "\n== Removing old logs and tempfiles =="
system! 'bin/rails log:clear tmp:clear'
puts "\n== Restarting application server =="
system! 'bin/rails restart'
end

View File

@ -1,4 +1,4 @@
require File.expand_path('../boot', __FILE__) require_relative 'boot'
require 'rails/all' require 'rails/all'
@ -21,7 +21,6 @@ module Clarion
config.i18n.available_locales = [:bg, :en] config.i18n.available_locales = [:bg, :en]
config.i18n.default_locale = :bg config.i18n.default_locale = :bg
config.active_record.raise_in_transactional_callbacks = true
config.generators do |g| config.generators do |g|
g.test_framework :rspec, fixtures: true, g.test_framework :rspec, fixtures: true,

View File

@ -1,3 +1,3 @@
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
require 'bundler/setup' # Set up gems listed in the Gemfile. require 'bundler/setup' # Set up gems listed in the Gemfile.

9
config/cable.yml Normal file
View File

@ -0,0 +1,9 @@
development:
adapter: async
test:
adapter: async
production:
adapter: redis
url: redis://localhost:6379/1

View File

@ -1,5 +1,5 @@
# Load the Rails application. # Load the Rails application.
require File.expand_path('../application', __FILE__) require_relative 'application'
# Initialize the Rails application. # Initialize the Rails application.
Rails.application.initialize! Rails.application.initialize!

View File

@ -9,16 +9,30 @@ Rails.application.configure do
# Do not eager load code on boot. # Do not eager load code on boot.
config.eager_load = false config.eager_load = false
# Show full error reports and disable caching. # Show full error reports.
config.consider_all_requests_local = true config.consider_all_requests_local = true
# Enable/disable caching. By default caching is disabled.
if Rails.root.join('tmp/caching-dev.txt').exist?
config.action_controller.perform_caching = true
config.cache_store = :memory_store
config.public_file_server.headers = {
'Cache-Control' => 'public, max-age=172800'
}
else
config.action_controller.perform_caching = false config.action_controller.perform_caching = false
config.cache_store = :null_store
end
# Don't care if the mailer can't send. # Don't care if the mailer can't send.
config.action_mailer.raise_delivery_errors = false config.action_mailer.raise_delivery_errors = false
# Use localhost for default host # Use localhost for default host
config.action_mailer.default_url_options = {host: 'localhost:3000'} config.action_mailer.default_url_options = {host: 'localhost:3000'}
config.action_mailer.default_options = {from: 'no-reply@example.com'} config.action_mailer.default_options = {from: 'no-reply@example.com'}
config.action_mailer.perform_caching = false
# Print deprecation notices to the Rails logger. # Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log config.active_support.deprecation = :log
@ -31,18 +45,13 @@ Rails.application.configure do
# number of complex assets. # number of complex assets.
config.assets.debug = true config.assets.debug = true
# Asset digests allow you to set far-future HTTP expiration dates on all assets, # Suppress logger output for asset requests.
# yet still be able to expire them through the digest params. config.assets.quiet = true
config.assets.digest = true
# Adds additional error checking when serving assets at runtime.
# Checks for improperly declared sprockets dependencies.
# Raises helpful error messages.
config.assets.raise_runtime_errors = true
# Raises error for missing translations # Raises error for missing translations
# config.action_view.raise_on_missing_translations = true # config.action_view.raise_on_missing_translations = true
# Compatibility with a future rails version # Use an evented file watcher to asynchronously detect changes in source code,
config.active_record.raise_in_transactional_callbacks = true # routes, locales, etc. This feature depends on the listen gem.
# config.file_watcher = ActiveSupport::EventedFileUpdateChecker
end end

View File

@ -14,15 +14,9 @@ Rails.application.configure do
config.consider_all_requests_local = false config.consider_all_requests_local = false
config.action_controller.perform_caching = true config.action_controller.perform_caching = true
# Enable Rack::Cache to put a simple HTTP cache in front of your application
# Add `rack-cache` to your Gemfile before enabling this.
# For large-scale production use, consider using a caching reverse proxy like
# NGINX, varnish or squid.
# config.action_dispatch.rack_cache = true
# Disable serving static files from the `/public` folder by default since # Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this. # Apache or NGINX already handles this.
config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present? config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
# Compress JavaScripts and CSS. # Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier config.assets.js_compressor = :uglifier
@ -31,16 +25,20 @@ Rails.application.configure do
# Do not fallback to assets pipeline if a precompiled asset is missed. # Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = false config.assets.compile = false
# Asset digests allow you to set far-future HTTP expiration dates on all assets,
# yet still be able to expire them through the digest params.
config.assets.digest = true
# `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.action_controller.asset_host = 'http://assets.example.com'
# Specifies the header that your server uses for sending files. # Specifies the header that your server uses for sending files.
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
# Mount Action Cable outside main process or domain
# config.action_cable.mount_path = nil
# config.action_cable.url = 'wss://example.com/cable'
# config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
config.force_ssl = true config.force_ssl = true
@ -49,16 +47,15 @@ Rails.application.configure do
config.log_level = :debug config.log_level = :debug
# Prepend all log lines with the following tags. # Prepend all log lines with the following tags.
# config.log_tags = [ :subdomain, :uuid ] config.log_tags = [ :request_id ]
# Use a different logger for distributed setups.
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
# Use a different cache store in production. # Use a different cache store in production.
# config.cache_store = :mem_cache_store # config.cache_store = :mem_cache_store
# Enable serving of images, stylesheets, and JavaScripts from an asset server. # Use a real queuing backend for Active Job (and separate queues per environment)
# config.action_controller.asset_host = 'http://assets.example.com' # config.active_job.queue_adapter = :resque
# config.active_job.queue_name_prefix = "clarion_#{Rails.env}"
config.action_mailer.perform_caching = false
# Ignore bad email addresses and do not raise email delivery errors. # Ignore bad email addresses and do not raise email delivery errors.
# Set this to true and configure the email server for immediate delivery to raise delivery errors. # Set this to true and configure the email server for immediate delivery to raise delivery errors.
@ -78,6 +75,16 @@ Rails.application.configure do
# Use default logging formatter so that PID and timestamp are not suppressed. # Use default logging formatter so that PID and timestamp are not suppressed.
config.log_formatter = ::Logger::Formatter.new config.log_formatter = ::Logger::Formatter.new
# Use a different logger for distributed setups.
# require 'syslog/logger'
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
if ENV["RAILS_LOG_TO_STDOUT"].present?
logger = ActiveSupport::Logger.new(STDOUT)
logger.formatter = config.log_formatter
config.logger = ActiveSupport::TaggedLogging.new(logger)
end
# Do not dump schema after migrations. # Do not dump schema after migrations.
config.active_record.dump_schema_after_migration = false config.active_record.dump_schema_after_migration = false
end end

View File

@ -12,9 +12,11 @@ Rails.application.configure do
# preloads Rails for running tests, you may have to set it to true. # preloads Rails for running tests, you may have to set it to true.
config.eager_load = false config.eager_load = false
# Configure static file server for tests with Cache-Control for performance. # Configure public file server for tests with Cache-Control for performance.
config.serve_static_files = true config.public_file_server.enabled = true
config.static_cache_control = 'public, max-age=3600' config.public_file_server.headers = {
'Cache-Control' => 'public, max-age=3600'
}
# Show full error reports and disable caching. # Show full error reports and disable caching.
config.consider_all_requests_local = true config.consider_all_requests_local = true
@ -25,6 +27,7 @@ Rails.application.configure do
# Disable request forgery protection in test environment. # Disable request forgery protection in test environment.
config.action_controller.allow_forgery_protection = false config.action_controller.allow_forgery_protection = false
config.action_mailer.perform_caching = false
# Tell Action Mailer not to deliver emails to the real world. # Tell Action Mailer not to deliver emails to the real world.
# The :test delivery method accumulates sent emails in the # The :test delivery method accumulates sent emails in the
@ -34,10 +37,6 @@ Rails.application.configure do
# Use localhost for default host # Use localhost for default host
config.action_mailer.default_url_options = {host: 'localhost:3000'} config.action_mailer.default_url_options = {host: 'localhost:3000'}
config.action_mailer.default_options = {from: 'no-reply@example.com'} config.action_mailer.default_options = {from: 'no-reply@example.com'}
# Randomize the order test cases are executed.
config.active_support.test_order = :random
# Print deprecation notices to the stderr. # Print deprecation notices to the stderr.
config.active_support.deprecation = :stderr config.active_support.deprecation = :stderr

View File

@ -0,0 +1,8 @@
# Be sure to restart your server when you modify this file.
# ActiveSupport::Reloader.to_prepare do
# ApplicationController.renderer.defaults.merge!(
# http_host: 'example.org',
# https: false
# )
# end

View File

@ -1,3 +1,5 @@
# Be sure to restart your server when you modify this file. # Be sure to restart your server when you modify this file.
# Specify a serializer for the signed and encrypted cookie jars.
# Valid options are :json, :marshal, and :hybrid.
Rails.application.config.action_dispatch.cookies_serializer = :json Rails.application.config.action_dispatch.cookies_serializer = :json

View File

@ -0,0 +1,25 @@
# Be sure to restart your server when you modify this file.
#
# This file contains migration options to ease your Rails 5.0 upgrade.
#
# Once upgraded flip defaults one by one to migrate to the new default.
#
# Read the Guide for Upgrading Ruby on Rails for more info on each option.
Rails.application.config.action_controller.raise_on_unfiltered_parameters = true
# Enable per-form CSRF tokens. Previous versions had false.
Rails.application.config.action_controller.per_form_csrf_tokens = false
# Enable origin-checking CSRF mitigation. Previous versions had false.
Rails.application.config.action_controller.forgery_protection_origin_check = false
# Make Ruby 2.4 preserve the timezone of the receiver when calling `to_time`.
# Previous versions had false.
ActiveSupport.to_time_preserves_timezone = false
# Require `belongs_to` associations by default. Previous versions had false.
Rails.application.config.active_record.belongs_to_required_by_default = false
# Do not halt callback chains when a callback returns false. Previous versions had true.
ActiveSupport.halt_callback_chains_on_return_false = true

View File

@ -5,7 +5,7 @@
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
ActiveSupport.on_load(:action_controller) do ActiveSupport.on_load(:action_controller) do
wrap_parameters format: [:json] if respond_to?(:wrap_parameters) wrap_parameters format: [:json]
end end
# To enable root element in JSON for ActiveRecord objects. # To enable root element in JSON for ActiveRecord objects.

47
config/puma.rb Normal file
View File

@ -0,0 +1,47 @@
# Puma can serve each request in a thread from an internal thread pool.
# The `threads` method setting takes two numbers a minimum and maximum.
# Any libraries that use thread pools should be configured to match
# the maximum value specified for Puma. Default is set to 5 threads for minimum
# and maximum, this matches the default thread size of Active Record.
#
threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }.to_i
threads threads_count, threads_count
# Specifies the `port` that Puma will listen on to receive requests, default is 3000.
#
port ENV.fetch("PORT") { 3000 }
# Specifies the `environment` that Puma will run in.
#
environment ENV.fetch("RAILS_ENV") { "development" }
# Specifies the number of `workers` to boot in clustered mode.
# Workers are forked webserver processes. If using threads and workers together
# the concurrency of the application would be max `threads` * `workers`.
# Workers do not work on JRuby or Windows (both of which do not support
# processes).
#
# workers ENV.fetch("WEB_CONCURRENCY") { 2 }
# Use the `preload_app!` method when specifying a `workers` number.
# This directive tells Puma to first boot the application and load code
# before forking the application. This takes advantage of Copy On Write
# process behavior so workers use less memory. If you use this option
# you need to make sure to reconnect any threads in the `on_worker_boot`
# block.
#
# preload_app!
# The code in the `on_worker_boot` will be called if you are using
# clustered mode by specifying a number of `workers`. After each worker
# process is booted this block will be run, if you are using `preload_app!`
# option you will want to use this block to reconnect to any threads
# or connections that may have been created at application boot, Ruby
# cannot share connections between processes.
#
# on_worker_boot do
# ActiveRecord::Base.establish_connection if defined?(ActiveRecord)
# end
# Allow puma to be restarted by `rails restart` command.
plugin :tmp_restart

6
config/spring.rb Normal file
View File

@ -0,0 +1,6 @@
%w(
.ruby-version
.rbenv-vars
tmp/restart.txt
tmp/caching-dev.txt
).each { |path| Spring.watch(path) }