Module: Nutella::CurrentAppUtils
- Defined in:
- lib/config/current_app_utils.rb
Overview
This module contains a series of utilities methods to handle the nutella application contained in the directory we are at this moment
Class Method Summary collapse
-
.config ⇒ PersistedHash
Builds a PersistedHash of the application nutella.json file and returns it.
-
.exist? ⇒ Boolean
Checks that the current directory is actually a nutella application.
Class Method Details
.config ⇒ PersistedHash
Builds a PersistedHash of the application nutella.json file and returns it. This method is used to ease access to the app nutella.json file.
35 36 37 38 39 40 41 42 43 |
# File 'lib/config/current_app_utils.rb', line 35 def CurrentAppUtils.config cur_app_dir = Dir.pwd nutella_json_file = "#{cur_app_dir}/nutella.json" if File.exist? nutella_json_file return PersistedHash.new(nutella_json_file) else raise 'The current directory is not a nutella app: impossible to read nutella.json file' end end |
.exist? ⇒ Boolean
Checks that the current directory is actually a nutella application
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/config/current_app_utils.rb', line 11 def CurrentAppUtils.exist? cur_app_dir = Dir.pwd nutella_json_file = "#{cur_app_dir}/nutella.json" # Check that there is a nutella.json file in the main directory of the application if File.exist? nutella_json_file begin conf = JSON.parse( IO.read(nutella_json_file) ) rescue console.warn 'The nutella.json file for this application does not contain properly formatted JSON' return false end if conf['nutella_version'].nil? return false end else return false end true end |