Class: PlatinaWorld::TemplateManager
- Inherits:
-
Object
- Object
- PlatinaWorld::TemplateManager
- Defined in:
- lib/platina_world/template_manager.rb
Instance Attribute Summary collapse
-
#root_path ⇒ Object
readonly
Returns the value of attribute root_path.
-
#template_file_pattern ⇒ Object
readonly
Returns the value of attribute template_file_pattern.
Instance Method Summary collapse
- #all ⇒ Object
- #exist? ⇒ Boolean
- #file(template) ⇒ Object
-
#initialize ⇒ TemplateManager
constructor
A new instance of TemplateManager.
- #setup ⇒ Object
Constructor Details
#initialize ⇒ TemplateManager
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_path ⇒ Object (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_pattern ⇒ Object (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
#all ⇒ Object
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
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 |
#setup ⇒ Object
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 |