Sha256: a1f5b698f79d358b25ad98886541c6db0b1ea1d46c68831c536b67c28a64249c

Contents?: true

Size: 924 Bytes

Versions: 2

Compression:

Stored size: 924 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 lock(version); end
    def namespace(options = {}); 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 server(name, properties = {})
      @env[:server] = {name: name}.merge(properties)
    end

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sunzi-rails-0.2.0 lib/sunzi/cli/capistrano.rb
sunzi-rails-0.1.0 lib/sunzi/cli/capistrano.rb