Sha256: e896b3b02ec4df3f33d6356567aa977fc34e1d4a3e31b1d03205a7cc478b1da3

Contents?: true

Size: 1.11 KB

Versions: 157

Compression:

Stored size: 1.11 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
      unless @cli_init
        @cli_init = true
        #pp "going to load default cli config..."
        require_relative('cli/config/default')
      end
      @cli
    end
  end
end

require_relative 'assets/language'


ASSETS = Eco::Assets.new

Version data entries

157 entries across 157 versions & 1 rubygems

Version Path
eco-helpers-2.5.10 lib/eco/assets.rb
eco-helpers-2.5.9 lib/eco/assets.rb
eco-helpers-2.5.8 lib/eco/assets.rb
eco-helpers-2.5.7 lib/eco/assets.rb
eco-helpers-2.5.6 lib/eco/assets.rb
eco-helpers-2.5.5 lib/eco/assets.rb
eco-helpers-2.5.4 lib/eco/assets.rb
eco-helpers-2.5.3 lib/eco/assets.rb
eco-helpers-2.5.2 lib/eco/assets.rb
eco-helpers-2.5.1 lib/eco/assets.rb
eco-helpers-2.4.9 lib/eco/assets.rb
eco-helpers-2.4.8 lib/eco/assets.rb
eco-helpers-2.4.7 lib/eco/assets.rb
eco-helpers-2.4.6 lib/eco/assets.rb
eco-helpers-2.4.5 lib/eco/assets.rb
eco-helpers-2.4.4 lib/eco/assets.rb
eco-helpers-2.4.3 lib/eco/assets.rb
eco-helpers-2.4.2 lib/eco/assets.rb
eco-helpers-2.3.3 lib/eco/assets.rb
eco-helpers-2.3.2 lib/eco/assets.rb