Sha256: 166da04bb9821f30b30be196ac348ce52fce1ffd7fa2a032e5393ad6f046916a
Contents?: true
Size: 795 Bytes
Versions: 1
Compression:
Stored size: 795 Bytes
Contents
require "ginbin/command" require 'yaml' module Ginbin class Commands include Enumerable def each (local_commads + home_commads).each do |command_desc| if command_desc['title'].nil? yield Command.new(cmd: command_desc, title: command_desc) else yield Command.new(cmd: command_desc['cmd'], title: command_desc['title']) end end end def local_commads return [] if at_home? return [] unless File.exists? '.ginbin.yml' YAML.load_file('.ginbin.yml')["commands"] end def home_commads return [] unless File.exists? 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-0.1.0 | lib/ginbin/commands.rb |