Sha256: bbff52d254582d6290e140f64f40315e9be4f12097b5ba3938d29c3e52648415

Contents?: true

Size: 729 Bytes

Versions: 2

Compression:

Stored size: 729 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: :environment do
    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

2 entries across 2 versions & 1 rubygems

Version Path
env_json-0.2.1 lib/env_json/rails_tasks.rb
env_json-0.2.0 lib/env_json/rails_tasks.rb