Module: Warp::Dir

Defined in:
lib/warp/dir.rb,
lib/warp/dir.rb,
lib/warp/dir/point.rb,
lib/warp/dir/store.rb,
lib/warp/dir/config.rb,
lib/warp/dir/errors.rb,
lib/warp/dir/app/cli.rb,
lib/warp/dir/command.rb,
lib/warp/dir/version.rb,
lib/warp/dir/commander.rb,
lib/warp/dir/formatter.rb,
lib/warp/dir/command/ls.rb,
lib/warp/dir/serializer.rb,
lib/warp/dir/app/response.rb,
lib/warp/dir/command/warp.rb,
lib/warp/dir/serializer/base.rb,
lib/warp/dir/serializer/dotfile.rb

Defined Under Namespace

Modules: App, Errors, Serializer Classes: Command, Commander, Config, Formatter, Point, Store

Constant Summary collapse

INSTALL_TIME =

tried in order.

Time.now
DOTFILES =
%w(.bash_profile .bashrc .profile .bash_login).map{|f| "~/#{f}" }
SHELL_WRAPPER_FILE =
"#{PROJECT_HOME}/bin/warp-dir.bash"
SHELL_WRAPPER_DEST =
"#{::Dir.home}/.bash_wd"
SHELL_WRAPPER_REGX =
%r[WarpDir \(v(\d+\.\d+\.\d+)]
SHELL_WRAPPER_SRCE =
<<-eof
# WarpDir (v#{Warp::Dir::VERSION}, appended on #{INSTALL_TIME}) BEGIN
[[ -f ~/.bash_wd ]] && source ~/.bash_wd
# WarpDir (v#{Warp::Dir::VERSION}, appended on #{INSTALL_TIME}) END
eof
VERSION =
'1.7.0'
INSTALL_NOTICE =
@install_notice
SERIALIZERS =
{}

Class Method Summary collapse

Class Method Details

.absolute(path) ⇒ Object



35
36
37
# File 'lib/warp/dir.rb', line 35

def absolute(path)
  path.gsub '~', ::Dir.home
end

.commanderObject



61
62
63
# File 'lib/warp/dir.rb', line 61

def commander
  ::Warp::Dir::Commander.instance
end

.default_configObject



39
40
41
# File 'lib/warp/dir.rb', line 39

def default_config
  relative Warp::Dir::Config::DEFAULTS[:warprc]
end

.eval_context?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/warp/dir.rb', line 23

def eval_context?
  ENV['WARP_DIR_SHELL'] == 'yes'
end

.on(type, &block) ⇒ Object



57
58
59
# File 'lib/warp/dir.rb', line 57

def on(type, &block)
  Warp::Dir::App::Response.new.type(type).configure(&block)
end

.pwdObject



27
28
29
# File 'lib/warp/dir.rb', line 27

def pwd
  %x(pwd).chomp.gsub ::Dir.home, '~'
end

.relative(path) ⇒ Object



31
32
33
# File 'lib/warp/dir.rb', line 31

def relative(path)
  path.gsub ::Dir.home, '~'
end

.require_all_from(folder) ⇒ Object



19
20
21
# File 'lib/warp/dir.rb', line 19

def require_all_from(folder)
  ::Dir.glob("#{Warp::PROJECT_LIBS}#{folder}/*.rb") { |file| Kernel.require file }
end

.sort_by(collection, field) ⇒ Object



43
44
45
# File 'lib/warp/dir.rb', line 43

def sort_by(collection, field)
  collection.sort { |a, b| a.send(field) <=> b.send(field) }
end