Sha256: 427df039f2796b1c229626157b3468d55d024a6a7c9d592f942bc1b55feab0ce

Contents?: true

Size: 759 Bytes

Versions: 9

Compression:

Stored size: 759 Bytes

Contents

module Sunzi
  module Cli::Capistrano
    extend self

    attr_accessor :env
    @env = {}

    def load_env(stage)
      deploy_path = File.expand_path('config/deploy.rb')
      stage_path = File.expand_path("config/deploy/#{stage}.rb")
      instance_eval(File.read(deploy_path), deploy_path)
      instance_eval(File.read(stage_path), stage_path)
      @env = HashWithIndifferentAccess.new(@env)
    end

    def set(key, value)
      @env[key] = value
    end

    def fetch(key, value = nil)
      if @env.has_key?(key)
        @env[key]
      else
        @env[key] = value
      end
    end

    def method_missing(name, *args, &block)
      if caller.join.include? 'load_env'
        # do nothing
      else
        super
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
sunzi-rails-0.2.21 lib/sunzi/cli/capistrano.rb
sunzi-rails-0.2.20 lib/sunzi/cli/capistrano.rb
sunzi-rails-0.3.0 lib/sunzi/cli/capistrano.rb
sunzi-rails-0.2.19 lib/sunzi/cli/capistrano.rb
sunzi-rails-0.2.18 lib/sunzi/cli/capistrano.rb
sunzi-rails-0.2.17 lib/sunzi/cli/capistrano.rb
sunzi-rails-0.2.16 lib/sunzi/cli/capistrano.rb
sunzi-rails-0.2.15 lib/sunzi/cli/capistrano.rb
sunzi-rails-0.2.14 lib/sunzi/cli/capistrano.rb