Class: Polka::Bootstrapper
- Inherits:
-
Object
- Object
- Polka::Bootstrapper
- Defined in:
- lib/polka/bootstrapper.rb
Class Method Summary collapse
Instance Method Summary collapse
- #configure(config_hash) ⇒ Object
- #copy(*files) ⇒ Object
-
#initialize(home_dir, dotfile_dir) ⇒ Bootstrapper
constructor
A new instance of Bootstrapper.
- #setup ⇒ Object
Constructor Details
#initialize(home_dir, dotfile_dir) ⇒ Bootstrapper
Returns a new instance of Bootstrapper.
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/polka/bootstrapper.rb', line 3 def initialize(home_dir, dotfile_dir) @home_dir = home_dir @dotfile_dir = dotfile_dir DotfileGroup.all_files = dotfiles_in_dotfile_dir symlinking = lambda { |dest, src| FileUtils.ln_s(dest, src) } = lambda { |dest, src| FileUtils.cp(dest, src) } @symlink = DotfileGroup.new(symlinking, " Symlinking files") @copy = DotfileGroup.new(, " Copying files") @parsed_copy = DotfileGroup.new(Operations::ParsedCopying, " Parsing and copying files") @inclusive_groups = [@symlink, @copy, @parsed_copy] @exclude = DotfileGroup.new exclude("Dotfile") end |
Class Method Details
.from_dotfile(dotfile, home_dir) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/polka/bootstrapper.rb', line 19 def self.from_dotfile(dotfile, home_dir) bootstrapper = new(home_dir, File.(File.dirname(dotfile))) bootstrapper.instance_eval(dotfile.read) return bootstrapper end |
Instance Method Details
#configure(config_hash) ⇒ Object
62 63 64 |
# File 'lib/polka/bootstrapper.rb', line 62 def configure(config_hash) Polka.config.merge!(config_hash) end |
#copy(*files) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/polka/bootstrapper.rb', line 40 def copy(*files) if (files) group = erb?(files[0]) ? @parsed_copy : @copy (files, group) else error_msg = "Cannot copy :all_other_files, please copy files explicitly." raise ArgumentError, error_msg if files.include?(:all_other_files) erb = files.select { |fn| erb?(fn) } not_erb = files - erb add_files_to_group(not_erb, @copy) erb_dotfiles = erb.map { |erbfile| create_dotfile(erbfile, File.basename(erbfile, '.erb')) } @parsed_copy.add(erb_dotfiles) unless erb_dotfiles.empty? end end |