Sha256: 01c184b75362096e08b3b922b5b640b232c22794be70b5f48d0c0682a9174b1c

Contents?: true

Size: 563 Bytes

Versions: 1

Compression:

Stored size: 563 Bytes

Contents

require 'yaml'

module Ginbin
  class ItemsFromConfig
    include Enumerable 

    def each
      (local_items + home_items).each do |item|
        yield item
      end
    end

    def local_items
      return [] if at_home?
      return [] unless File.exist? '.ginbin.yml'
      YAML.load_file('.ginbin.yml')["commands"]
    end

    def home_items
      return [] unless File.exist? File.join(Dir.home, '.ginbin.yml')

      YAML.load_file(File.join(Dir.home, '.ginbin.yml'))["commands"]
    end

    def at_home?
      Dir.getwd == Dir.home
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ginbin-1.0.1 lib/ginbin/items_from_config.rb