Browse Source

Ensure we can set per-app-env ENV vars

tags/0.3.0^2
Bèr Kessels 9 months ago
parent
commit
07386f9adf
6 changed files with 14 additions and 6 deletions
  1. 7
    0
      .env.test
  2. 1
    1
      Makefile
  3. 0
    2
      Rakefile
  4. 4
    0
      config/environment.rb
  5. 1
    0
      config/event_sourcery.rb
  6. 1
    3
      lib/hours.rb

+ 7
- 0
.env.test View File

@@ -0,0 +1,7 @@
PORT=3000
# Postgres Config. See https://www.postgresql.org/docs/9.1/libpq-envars.html
DB_USER=postgres
DB_HOST=localhost
DB_PASSWORD=TinLopeTuckBuckTonsVangBeakKink
DB_NAME=hours_test
DB_PORT=5432

+ 1
- 1
Makefile View File

@@ -1,6 +1,5 @@
CMD_PREFIX=bundle exec
CONTAINER_NAME=hours_development
include .env

# You want latexmk to *always* run, because make does not have all the info.
# Also, include non-file targets in .PHONY so they are run regardless of any
@@ -13,6 +12,7 @@ all: test lint
db: docker db-setup

# CUSTOM BUILD RULES
test: export APP_ENV=test
test:
$(CMD_PREFIX) ruby -I lib:test:. -e "Dir.glob('**/*_test.rb') { |f| require(f) }"
lint:

+ 0
- 2
Rakefile View File

@@ -2,8 +2,6 @@

$LOAD_PATH.unshift '.'

require 'dotenv/load'

task :event_sourcery do
require 'config/event_sourcery.rb'
end

+ 4
- 0
config/environment.rb View File

@@ -1,5 +1,9 @@
# frozen_string_literal: true

require 'dotenv'
root = Pathname.new(File.join(__dir__, '..'))
Dotenv.load(root.join(".env.#{ENV['APP_ENV']}"), root.join(".env"))

##
# Setup of database.
Hours.configure do |config|

+ 1
- 0
config/event_sourcery.rb View File

@@ -1,4 +1,5 @@
# frozen_string_literal: true
require_relative './environment.rb'

##
# Configure the event sourcery databases.

+ 1
- 3
lib/hours.rb View File

@@ -1,7 +1,5 @@
# frozen_string_literal: true

require 'dotenv/load'

require 'event_sourcery'
require 'event_sourcery/postgres'
require 'sequel-postgis-georuby'
@@ -45,7 +43,7 @@ module Hours
end

def self.environment
ENV.fetch('RACK_ENV', 'development')
ENV.fetch('RACK_ENV', ENV['APP_ENV'] || 'development')
end

def self.event_store

Loading…
Cancel
Save