Sha256: b25e68f95440615de02ef2870370ddc7ec952c17139c1a00998a9aa2da666c7b

Contents?: true

Size: 859 Bytes

Versions: 13

Compression:

Stored size: 859 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 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

13 entries across 13 versions & 1 rubygems

Version Path
sunzi-rails-0.2.13 lib/sunzi/cli/capistrano.rb
sunzi-rails-0.2.12 lib/sunzi/cli/capistrano.rb
sunzi-rails-0.2.11 lib/sunzi/cli/capistrano.rb
sunzi-rails-0.2.10 lib/sunzi/cli/capistrano.rb
sunzi-rails-0.2.9 lib/sunzi/cli/capistrano.rb
sunzi-rails-0.2.8 lib/sunzi/cli/capistrano.rb
sunzi-rails-0.2.7 lib/sunzi/cli/capistrano.rb
sunzi-rails-0.2.6 lib/sunzi/cli/capistrano.rb
sunzi-rails-0.2.5 lib/sunzi/cli/capistrano.rb
sunzi-rails-0.2.4 lib/sunzi/cli/capistrano.rb
sunzi-rails-0.2.3 lib/sunzi/cli/capistrano.rb
sunzi-rails-0.2.2 lib/sunzi/cli/capistrano.rb
sunzi-rails-0.2.1 lib/sunzi/cli/capistrano.rb