Sha256: f0aaeeb97c37ee958edec6182f7856e5e856bfb910c09e459a6e22d8c05dd9f7

Contents?: true

Size: 745 Bytes

Versions: 2

Compression:

Stored size: 745 Bytes

Contents

require "fileutils"

module Muxify
  class Linker
    TMUXINATOR_CONFIG_PATH = File.expand_path(File.join(ENV.fetch('HOME'), '.tmuxinator')).freeze
    private_constant :TMUXINATOR_CONFIG_PATH

    def self.call(*args)
      new(*args).call
    end

    def initialize(root:)
      @root = File.expand_path(root)
    end

    def call
      FileUtils.mkdir_p(TMUXINATOR_CONFIG_PATH)
      File.open(config_path, 'w') { |f| f << contents }
    end

    private

    attr_reader :root

    def config_path
      File.join(TMUXINATOR_CONFIG_PATH, "#{name}.yml")
    end

    def name
      File.basename(root)
    end

    def contents
      <<-ERB.strip
        <% require 'muxify' %><%= Muxify::Builder.('#{root}') %>
      ERB
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
muxify-0.1.1 lib/muxify/linker.rb
muxify-0.1.0 lib/muxify/linker.rb