Class: PlatinaWorld::TemplateManager

Inherits:
Object
  • Object
show all
Defined in:
lib/platina_world/template_manager.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTemplateManager

Returns a new instance of TemplateManager.



7
8
9
10
# File 'lib/platina_world/template_manager.rb', line 7

def initialize
  @root_path = "#{ENV['HOME']}/.platina_world".freeze
  @template_file_pattern = "#{root_path}/*.{yml,yaml}".freeze
end

Instance Attribute Details

#root_pathObject (readonly)

Returns the value of attribute root_path.



5
6
7
# File 'lib/platina_world/template_manager.rb', line 5

def root_path
  @root_path
end

#template_file_patternObject (readonly)

Returns the value of attribute template_file_pattern.



5
6
7
# File 'lib/platina_world/template_manager.rb', line 5

def template_file_pattern
  @template_file_pattern
end

Instance Method Details

#allObject



12
13
14
15
16
17
18
# File 'lib/platina_world/template_manager.rb', line 12

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

#exist?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/platina_world/template_manager.rb', line 33

def exist?
  ::File.exist?(root_path)
end

#file(template) ⇒ Object



29
30
31
# File 'lib/platina_world/template_manager.rb', line 29

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

#setupObject



20
21
22
23
24
25
26
27
# File 'lib/platina_world/template_manager.rb', line 20

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