From adef074df51252eff790f6ade2f3b89f15526ea9 Mon Sep 17 00:00:00 2001 From: "David A. Harding" Date: Fri, 4 Sep 2015 12:24:17 -0400 Subject: [PATCH] New plugin env.rb to make env vars available in templates --- .travis.yml | 4 ++++ _plugins/env.rb | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 _plugins/env.rb diff --git a/.travis.yml b/.travis.yml index 3d8be581..ff4df5c8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,5 +3,9 @@ rvm: - "2.0.0" sudo: false cache: bundler +env: + # http://docs.travis-ci.com/user/environment-variables/#Global-Variables + global: + - BITCOINORG_BUILD_TYPE=deployment script: make travis diff --git a/_plugins/env.rb b/_plugins/env.rb new file mode 100644 index 00000000..f9dd2f01 --- /dev/null +++ b/_plugins/env.rb @@ -0,0 +1,20 @@ +# This file is licensed under the MIT License (MIT) available on +# http://opensource.org/licenses/MIT. + +## env.rb takes select environmental variables and makes them available +## to the site templates. Currently, only variables starting with +## BITCOINORG_ are exported + +module Jekyll + class EnvGenerator < Generator + def generate(site) + ## If necessary, initialize env hash table + site.config["env"] = site.config["env"] ? site.config["env"] : {} + + ## Load matching environmental variables in to array + ENV.keys.grep /^BITCOINORG_/ do |key| + site.config['env'].merge!({ key => ENV[key] }) + end + end + end +end