Sha256: 1b599d25fdda5077ef88509219d0ef42699e7de5c594bf854c55421003dbfe48

Contents?: true

Size: 1.1 KB

Versions: 30

Compression:

Stored size: 1.1 KB

Contents

module Eco
  class Assets

    attr_reader :active_config

    def initialize
      @active_config = :default
      @cli      = Eco::CLI.new
      @cli_init = false
    end

    def session(key: active_config, update_active: true)
      config(key: key, update_active: update_active).session.tap do |session|
        yield(session) if block_given?
      end
    end

    def config(key: active_config, update_active: true)
      configs[:default] ||= Eco::API::Session::Config.new(key)
      unless configs.key?(key)
        @active_config = key unless !update_active
        configs[key]   = configs[:default].clone(key)
      end
      configs[key].tap do |config|
        config.active_api(key) if config.apis.defined?(key)
        yield(config) if block_given?
      end
    end

    def configs
      @configs ||= {}
    end

    def cli(&block)
      unless @cli_init
        @cli_init = true
        require_relative('cli_default')
      end
      @cli.tap { yield(@cli) if block_given? }
    end
  end
end

require_relative 'assets/language'

ASSETS = Eco::Assets.new

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
eco-helpers-3.0.7 lib/eco/assets.rb
eco-helpers-3.0.6 lib/eco/assets.rb
eco-helpers-3.0.5 lib/eco/assets.rb
eco-helpers-3.0.4 lib/eco/assets.rb
eco-helpers-3.0.3 lib/eco/assets.rb
eco-helpers-3.0.2 lib/eco/assets.rb
eco-helpers-3.0.1 lib/eco/assets.rb
eco-helpers-3.0.0 lib/eco/assets.rb
eco-helpers-2.7.25 lib/eco/assets.rb
eco-helpers-2.7.24 lib/eco/assets.rb
eco-helpers-2.7.23 lib/eco/assets.rb
eco-helpers-2.7.22 lib/eco/assets.rb
eco-helpers-2.7.21 lib/eco/assets.rb
eco-helpers-2.7.20 lib/eco/assets.rb
eco-helpers-2.7.19 lib/eco/assets.rb
eco-helpers-2.7.18 lib/eco/assets.rb
eco-helpers-2.7.17 lib/eco/assets.rb
eco-helpers-2.7.16 lib/eco/assets.rb
eco-helpers-2.7.15 lib/eco/assets.rb
eco-helpers-2.7.14 lib/eco/assets.rb