Sha256: 00deb0dfd3afae24f20e6ba96e3dac722c9940220324364ca0230a5bdcf84b55

Contents?: true

Size: 996 Bytes

Versions: 1

Compression:

Stored size: 996 Bytes

Contents

require_relative "aid/version"

module Aid
  def self.load_paths
    @load_paths ||= [
      File.expand_path(File.dirname(__FILE__) + "/aid/scripts"),
      ".aid",
      "#{Aid.project_root}/.aid",
      ENV['AID_PATH']
    ].compact
  end

  def self.load_scripts!
    load_paths.each do |path|
      Dir.glob("#{path}/**/*.rb").each do |file|
        require File.expand_path(file)
      end
    end
  end

  def self.script_name
    ARGV.first
  end

  def self.script_args
    ARGV[1..-1]
  end

  def self.project_root
    @project_root ||= begin
      current_search_dir = Dir.pwd

      loop do
        git_dir = "#{current_search_dir}/.git"

        return current_search_dir if Dir.exists?(git_dir)
        break if current_search_dir == "/"

        current_search_dir = File.expand_path("#{current_search_dir}/..")
      end

      nil
    end
  end
end

require_relative "aid/colorize"
require_relative "aid/inheritable"
require_relative "aid/script"
require_relative "aid/scripts"

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
aid-0.1.3 lib/aid.rb