Sha256: b7f338a4e9f92a0daf5a6cd2308d9f05002e8e54bde0fbb1b5619e0711ce8600

Contents?: true

Size: 825 Bytes

Versions: 1

Compression:

Stored size: 825 Bytes

Contents

require 'pty'
require 'shellwords'

namespace :env_json do
  desc 'print env_json computed environment'
  task print_env: :environment do
    pp EnvJson.env
  end

  desc 'load env into ElasticBeanstalk'
  task :eb do
    EnvJson.load_env_from_source_with_overrides(Rails.root.join('config/env.json'), ENV.fetch('RAILS_ENV'))

    eb_formated_env = EnvJson.env.map{|key,value| "#{Shellwords.escape key}=#{Shellwords.escape value}" }.join(' ')
    begin
      PTY.spawn("eb setenv -v #{eb_formated_env}") do |stdin, stdout, pid|
        begin
          stdin.each { |line| print line }
        rescue Errno::EIO
          puts "Errno:EIO error, but this probably just means that the process has finished giving output"
        end
      end
    rescue PTY::ChildExited
      puts "The child process exited!"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
env_json-0.2.2 lib/env_json/rails_tasks.rb