Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
# frozen_string_literal: true

$LOAD_PATH.unshift File.join(__dir__, 'lib')

require 'bundler'
env = ENV['APP_ENV'] || 'development'
Bundler.require(:default, env)
require_relative 'config/environment'

require 'application_configuration'
ApplicationConfiguration.load!
Expand All @@ -27,7 +23,7 @@ namespace :assets do
end
# rubocop:enable Rake/Desc

unless env == 'production'
unless ENV.fetch('RACK_ENV', 'development') == 'production'
require 'fileutils'
require 'haml_lint/rake_task'
require 'rdoc/task'
Expand Down
8 changes: 2 additions & 6 deletions config.ru
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
# frozen_string_literal: true

$LOAD_PATH.unshift File.join(__dir__, 'lib')

require 'bundler'
env = ENV['APP_ENV'] = ENV.fetch('RACK_ENV', 'development')
Bundler.require(:default, env)
require_relative 'config/environment'

require 'application_configuration'
ApplicationConfiguration.load!

require 'application_assets'
require 'dev_training_application'

map(ApplicationAssets::ASSET_ROOT) { run ApplicationAssets.new } unless env == 'production'
map(ApplicationAssets::ASSET_ROOT) { run ApplicationAssets.new } if ENV.fetch('RACK_ENV', 'development') != 'production'
map('/') { run DevTrainingApplication }
5 changes: 2 additions & 3 deletions config/deploy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@
set :application, 'dev-training-web'
set :repo_url, 'https://github.com/umts/dev-training-web.git'
set :branch, 'main'
set :deploy_to, "/srv/#{fetch :application}"

set :app_env, fetch(:stage)
set :default_env, { APP_ENV: fetch(:app_env) }

set :deploy_to, "/srv/#{fetch :application}"
set :default_env, { RACK_ENV: fetch(:app_env) }

set :keep_releases, 5

Expand Down
5 changes: 5 additions & 0 deletions config/environment.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# frozen_string_literal: true

$LOAD_PATH.unshift File.expand_path('../lib', __dir__)
require 'bundler/setup'
Bundler.require(:default, ENV.fetch('RACK_ENV', 'development'))
2 changes: 1 addition & 1 deletion coverage/.last_run.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"result": {
"line": 98.11,
"line": 98.13,
"branch": 85.71
}
}
2 changes: 1 addition & 1 deletion lib/application_configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def self.load!
Figaro.adapter = Figaro::Application
Figaro.application = Figaro::Application.new(
path: config_file,
environment: ENV['APP_ENV'] || 'development'
environment: ENV['RACK_ENV'] || 'development'
)
Figaro.load
end
Expand Down
5 changes: 1 addition & 4 deletions script/console
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require 'bundler'

$LOAD_PATH.unshift File.join(__dir__, '..', 'lib')
Bundler.require(:default, :development)
require_relative '../config/environment'

require 'application_configuration'
ApplicationConfiguration.load!
Expand Down
7 changes: 3 additions & 4 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
# frozen_string_literal: true

require 'bundler'
Bundler.require(:default, :test)

require 'simplecov'
SimpleCov.start do
enable_coverage :branch
load_profile 'test_frameworks'
add_filter %r{^/vendor/}
track_files 'lib/**/*.rb'
end

$LOAD_PATH.unshift File.join(__dir__, '..', 'lib')
ENV['RACK_ENV'] = 'test'
require_relative '../config/environment'

Dir.glob(File.join(__dir__, 'support/**/*.rb')).each { |f| require f }

Expand Down