lib/fast/shortcut.rb in ffast-0.2.0 vs lib/fast/shortcut.rb in ffast-0.2.2
- old
+ new
@@ -5,11 +5,16 @@
class << self
# Where to search for `Fastfile` archives?
# 1. Current directory that the command is being runned
# 2. Home folder
# 3. Using the `FAST_FILE_DIR` variable to set an extra folder
- LOOKUP_FAST_FILES_DIRECTORIES = [Dir.pwd, ENV['HOME'], ENV['FAST_FILE_DIR']].freeze
+ LOOKUP_FAST_FILES_DIRECTORIES = [
+ Dir.pwd,
+ ENV['HOME'],
+ ENV['FAST_FILE_DIR'],
+ File.join(File.dirname(__FILE__), '..', '..')
+ ].compact.map(&File.method(:expand_path)).uniq.freeze
# Store predefined searches with default paths through shortcuts.
# define your Fastfile in you root folder or
# @example Shortcut for finding validations in rails models
# Fast.shortcut(:validations, "(send nil {validate validates})", "app/models")
@@ -27,11 +32,11 @@
# @return [Array<String>] with existent Fastfiles from {LOOKUP_FAST_FILES_DIRECTORIES}.
def fast_files
@fast_files ||= LOOKUP_FAST_FILES_DIRECTORIES.compact
.map { |dir| File.join(dir, 'Fastfile') }
- .select(&File.method(:exists?))
+ .select(&File.method(:exist?))
end
# Loads `Fastfiles` from {.fast_files} list
def load_fast_files!
fast_files.each(&method(:load))
@@ -58,10 +63,10 @@
# the options from previous alias and replacing the files with the
# @param [Array] extra_args
def merge_args(extra_args)
all_args = (@args + extra_args).uniq
options = all_args.select { |arg| arg.start_with? '-' }
- files = extra_args.select(&File.method(:exists?))
+ files = extra_args.select(&File.method(:exist?))
command = (@args - options - files).first
[command, *options, *files]
end