Class: Configuration
- Inherits:
-
Object
- Object
- Configuration
- Defined in:
- lib/configuration.rb
Instance Method Summary collapse
- #_globalconfiguration_filename ⇒ Object
- #get_globalconfiguration ⇒ Object
- #has_globalconfiguration? ⇒ Boolean
-
#initialize(path) ⇒ Configuration
constructor
A new instance of Configuration.
- #set_globalconfiguration(model) ⇒ Object
Constructor Details
#initialize(path) ⇒ Configuration
Returns a new instance of Configuration.
12 13 14 |
# File 'lib/configuration.rb', line 12 def initialize(path) @path = path end |
Instance Method Details
#_globalconfiguration_filename ⇒ Object
16 17 18 |
# File 'lib/configuration.rb', line 16 def _globalconfiguration_filename() File.join(@path, '.pug_global') end |
#get_globalconfiguration ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'lib/configuration.rb', line 38 def get_globalconfiguration() begin file = File.open(_globalconfiguration_filename) model = YAML::load(file) if file != nil model ensure file.close if file != nil end end |
#has_globalconfiguration? ⇒ Boolean
20 21 22 |
# File 'lib/configuration.rb', line 20 def has_globalconfiguration? File.exists?(_globalconfiguration_filename) end |
#set_globalconfiguration(model) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/configuration.rb', line 24 def set_globalconfiguration(model) content = model.to_yaml begin file = File.new(_globalconfiguration_filename, 'w') file.write(content) ensure file.close end if !Dir.exists?(model.pugspath) Dir.mkdir(model.pugspath) end end |