Class: AppleManifestRails::TemplateDir
- Inherits:
-
Object
- Object
- AppleManifestRails::TemplateDir
- Defined in:
- lib/apple_manifest_rails/template_dir.rb
Defined Under Namespace
Classes: InvalidTemplateDirError, TemplateMissingError
Constant Summary collapse
- EXPECTED_TEMPLATES =
%w{Profile.mobileconfig manifest.plist}
Instance Attribute Summary collapse
-
#dir ⇒ Object
Returns the value of attribute dir.
Instance Method Summary collapse
-
#initialize(dir) ⇒ TemplateDir
constructor
A new instance of TemplateDir.
- #join(*args) ⇒ Object
Constructor Details
#initialize(dir) ⇒ TemplateDir
Returns a new instance of TemplateDir.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/apple_manifest_rails/template_dir.rb', line 8 def initialize dir errors = [] self.dir = File.(dir.to_s) if File.directory?(self.dir) EXPECTED_TEMPLATES.each do |t| path = self.join(t) unless File.exists?(path) errors << "Template missing! #{path}" end end else raise InvalidTemplateDirError, "Expected a template directory! #{self.dir}" end if errors.size > 0 raise TemplateMissingError, errors.join("\n") end end |
Instance Attribute Details
#dir ⇒ Object
Returns the value of attribute dir.
3 4 5 |
# File 'lib/apple_manifest_rails/template_dir.rb', line 3 def dir @dir end |
Instance Method Details
#join(*args) ⇒ Object
26 27 28 |
# File 'lib/apple_manifest_rails/template_dir.rb', line 26 def join *args File.join(self.dir, args) end |