Sha256: efc7bd0f94c6cb2a8a9f5646bdf93e8dc860c3a17a340852c12fcdbcaabe8566

Contents?: true

Size: 1.86 KB

Versions: 1

Compression:

Stored size: 1.86 KB

Contents

require 'ansi'
require 'erb'

module DotfilesInstaller; end

require 'dotfiles_installer/actions'
require 'dotfiles_installer/utilities'
require 'dotfiles_installer/runner'

# The dotfiles installer parses a sourcedir and links files to a homedir:
# - The installer provides install and uninstall commands that guide and update
#   as it performs its linkings.
# - Any source files with the '.erb' extension are rendered then linked
# - Nested files are linked to a corresponding dir made in the homedir
# - Uninstalls remove each symlink and its dir (if empty)

# the sourcedir, ~/.dotfiles:
# - bash
#   - aliases
#   - colors
# - bin
#   - a_script
# - gemrc
# - gitconfig.erb
# - gitignore
# _ irbrc

# installs in the homedir, ~:
# - .bash
#   - aliases      --> /Users/xxx/.dotfiles/bash/aliases
#   - colors       --> /Users/xxx/.dotfiles/bash/colors
# - .bin
#   - a_script     --> /Users/xxx/.dotfiles/bin/a_script
# - .gemrc         --> /Users/xxx/.dotfiles/gemrc
# - .gitconfig     --> /Users/xxx/.dotfiles/~gitconfig
# - .gitignore     --> /Users/xxx/.dotfiles/gitignore
# _ .irbrc         --> /Users/xxx/.dotfiles/irbrc

module DotfilesInstaller

  class Base
    include Utilities

    attr_reader :sourcedir, :homedir, :options

    def initialize(sourcedir, *args)
      @sourcedir = sourcedir
      @options = args.last.kind_of?(::Hash) ? args.pop : {}
      @homedir = args.pop || ENV["HOME"]
    end

  end

  # run the install or uninstall printing to $stdout and reading from $stdin
  class Interactive < Base

    def install
      Runner.new($stdout).install(self.source_map) do |prompt, inputs|
        $stdout.print "#{prompt} #{inputs} "
        $stdin.gets.chomp
      end
    end

    def uninstall
      Runner.new($stdout).uninstall(self.source_map) do |prompt, inputs|
        $stdout.print "#{prompt} #{inputs} "
        $stdin.gets.chomp
      end
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dotfiles-installer-1.0.0 lib/dotfiles_installer.rb