Sha256: 6444566f59ae8f64218ff704f7a43f41c4f8c3f6019ea725a868c872cfe8bd5d

Contents?: true

Size: 872 Bytes

Versions: 1

Compression:

Stored size: 872 Bytes

Contents

require "platina_world/path"

module PlatinaWorld
  class TemplateManager
    attr_reader :template_file_pattern

    def initialize
      @template_file_pattern = "#{root_path}/*.{yml,yaml}".freeze
    end

    def show_items
      @all ||= all_files.each do |file|
        file.match(%r!#{root_path}/(?<attr>.*)\.(yml|yaml)!) do |m|
          puts m[:attr]
        end
      end
    end

    def root_path
      @root_path ||= Path.new("#{ENV['HOME']}/.platina_world".freeze)
    end

    def setup
      path = root_path.to_s
      if root_path.exist?
        PlatinaWorld::FileStatus.skip(path)
      else
        Dir.mkdir(path)
        PlatinaWorld::FileStatus.create(path)
      end
    end

    def expand(template)
      "#{root_path}/#{template}.yml"
    end

    private

    def all_files
      @all_files ||= Dir.glob(template_file_pattern)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
platina_world-0.1.5 lib/platina_world/template_manager.rb