From 92f8a843691a65cb3235cb6fdb08881660e6ceb9 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 1 Aug 2020 20:16:33 +1200 Subject: [PATCH 1/2] Remove figaro gem and use rails-dotenv --- Gemfile | 3 +- Gemfile.lock | 8 +-- config/application.yml.example => env-example | 54 +++++++------------ 3 files changed, 25 insertions(+), 40 deletions(-) rename config/application.yml.example => env-example (58%) diff --git a/Gemfile b/Gemfile index ea30dda3f..325a228f5 100644 --- a/Gemfile +++ b/Gemfile @@ -48,7 +48,6 @@ gem 'js-routes' # provides access to Rails routes in Javascript gem 'cancancan' # for checking member privileges gem 'csv_shaper' # CSV export -gem 'figaro' # for handling config via ENV variables gem 'gibbon', '~>1.2.0' # for Mailchimp newsletter subscriptions # Maps @@ -163,6 +162,8 @@ group :development, :test do gem 'rubocop-rspec' gem 'webrat' # provides HTML matchers for view tests + gem 'dotenv-rails' + # cli utils gem 'coveralls', require: false # coverage analysis gem 'haml-i18n-extractor', require: false diff --git a/Gemfile.lock b/Gemfile.lock index b7f896cb1..5998f06f9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -163,6 +163,10 @@ GEM discard (1.2.0) activerecord (>= 4.2, < 7) docile (1.1.5) + dotenv (2.7.6) + dotenv-rails (2.7.6) + dotenv (= 2.7.6) + railties (>= 3.2) elasticsearch (6.8.2) elasticsearch-api (= 6.8.2) elasticsearch-transport (= 6.8.2) @@ -193,8 +197,6 @@ GEM faraday_middleware (1.0.0) faraday (~> 1.0) ffi (1.13.0) - figaro (1.2.0) - thor (>= 0.14.0, < 2) flickraw (0.9.10) font-awesome-sass (5.13.0) sassc (>= 1.11) @@ -613,12 +615,12 @@ DEPENDENCIES database_cleaner devise discard (~> 1.0) + dotenv-rails elasticsearch (< 7.0.0) factory_bot_rails faker faraday faraday_middleware - figaro flickraw font-awesome-sass friendly_id diff --git a/config/application.yml.example b/env-example similarity index 58% rename from config/application.yml.example rename to env-example index fdd60d407..1a046716c 100644 --- a/config/application.yml.example +++ b/env-example @@ -15,7 +15,7 @@ # Settings in this file will be available to you as ENV['WHATEVER'] -# NOTE: please prefix all environment variables with GROWSTUFF_ to make +# NOTE=please prefix all environment variables with GROWSTUFF_ to make # it easy to identify which were set by us vs. the system or anyone else ############################################################################## @@ -26,10 +26,10 @@ # It's the only one without "GROWSTUFF_" prefix. # To generate a real one, use 'rake secret' (you don't need to for # dev, though.) -RAILS_SECRET_TOKEN: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" +RAILS_SECRET_TOKEN="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" # name that appears on the site, eg. in page titles -GROWSTUFF_SITE_NAME: Growstuff (dev) +GROWSTUFF_SITE_NAME="Growstuff (dev)" # Mailchimp is used for subscribing/unsubscribing people from the newsletter # To fetch list IDs using Gibbon (and thus find the ID of your newsletter): @@ -37,45 +37,27 @@ GROWSTUFF_SITE_NAME: Growstuff (dev) # Gibbon::API.api_key = '...' # gb = Gibbon::API.new # puts gb.lists.list.to_yaml -GROWSTUFF_MAILCHIMP_APIKEY: "" -GROWSTUFF_MAILCHIMP_NEWSLETTER_ID: "" +GROWSTUFF_MAILCHIMP_APIKEY="" +GROWSTUFF_MAILCHIMP_NEWSLETTER_ID="" # Used for connecting member accounts to Twitter # Get Twitter key from https://dev.twitter.com/apps -GROWSTUFF_TWITTER_KEY: "" -GROWSTUFF_TWITTER_SECRET: "" +GROWSTUFF_TWITTER_KEY="" +GROWSTUFF_TWITTER_SECRET="" # Used for connecting member accounts to Flickr # Get Flickr key from http://www.flickr.com/services/apps/create/apply/ -GROWSTUFF_FLICKR_KEY: "" -GROWSTUFF_FLICKR_SECRET: "" +GROWSTUFF_FLICKR_KEY="" +GROWSTUFF_FLICKR_SECRET="" # https://developers.facebook.com/ -GROWSTUFF_FACEBOOK_KEY: "" -GROWSTUFF_FACEBOOK_SECRET: "" +GROWSTUFF_FACEBOOK_KEY="" +GROWSTUFF_FACEBOOK_SECRET="" -GROWSTUFF_MAPBOX_MAP_ID: "" -GROWSTUFF_MAPBOX_ACCESS_TOKEN: "" - -############################################################################## -# Other environments -# You can override the above for staging, production, etc. -# To push these settings to Heroku, use "rake figaro:heroku --app=whatever". -# To see current settings on Heroku, use "heroku config --app=whatever". -############################################################################## - -### EMAil addres for notifier and mailers to use as from -GROWSTUFF_EMAIL: 'noreply@dev.growstuff.org' - -test: - GROWSTUFF_SITE_NAME: Growstuff (test) - -# Note: there is no good way to deploy settings from Figaro to -# Travis-CI. If you need env vars set there in order for tests to pass, -# set them in .travis.yml - -staging: - GROWSTUFF_SITE_NAME: Growstuff (staging) - -production: - GROWSTUFF_SITE_NAME: Growstuff +# Elasticsearch is used for flexible search and it requires another component +# to be installed. To make it easy for people who don't need to test this feature +# it's been turned off for test and development environment as a default. +# If you want to test this functionality, install elasticsearch and +# set this flag to "true". +GROWSTUFF_ELASTICSEARCH="true" +GROWSTUFF_EMAIL='noreply@dev.growstuff.org' From 3596ef1a10eeef5620400fe5fcc235289c18b9be Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 2 Aug 2020 08:20:52 +1200 Subject: [PATCH 2/2] Ignore the .env file --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 96147c719..46fc54a4c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ .byebug_history .bundle +.env # Folders to ignore /log