class Dotman::DotfileConfiguration
Public Class Methods
new()
click to toggle source
# File lib/dotman/dotfile_configuration.rb, line 3 def initialize @actions, @host_aliases = [], {} end
Public Instance Methods
alias_host(from, to)
click to toggle source
# File lib/dotman/dotfile_configuration.rb, line 15 def alias_host(from, to) @host_aliases[from] = to end
link(from, to: nil, **args)
click to toggle source
# File lib/dotman/dotfile_configuration.rb, line 7 def link(from, to: nil, **args) add_action Action::Link.new(from, to), args end
to_script(env)
click to toggle source
# File lib/dotman/dotfile_configuration.rb, line 11 def to_script(env) [header(env), actions, footer].join end
Private Instance Methods
actions()
click to toggle source
# File lib/dotman/dotfile_configuration.rb, line 29 def actions actions_list.map(&:to_s).join("\n\n").strip end
actions_list()
click to toggle source
# File lib/dotman/dotfile_configuration.rb, line 33 def actions_list [Action::Init.new.to_statement, *@actions] end
add_action(action, args)
click to toggle source
# File lib/dotman/dotfile_configuration.rb, line 21 def add_action(action, args) @actions << Shell::Statement.new(satisfies_args(args), action.to_statement) end
header(env)
click to toggle source
# File lib/dotman/dotfile_configuration.rb, line 37 def header(env) return <<~EOF #!/bin/bash set -e HOST="$(hostname -s)" BASE_DIR="#{env[:base]}" HOME_DIR="#{env[:home]}" echo HOST="#{'$HOST'.bold}" echo BASE_DIR="#{'$BASE_DIR'.bold}" echo HOME_DIR="#{'$HOME_DIR'.bold}" echo "#{['Starting...'].shelljoin.green}" EOF end
satisfies_args(args)
click to toggle source
# File lib/dotman/dotfile_configuration.rb, line 25 def satisfies_args(args) Shell.satisfies_args(@host_aliases, **args) end