Module: Nutella::CurrentProjectUtils
- Defined in:
- lib/config/current_project.rb
Class Method Summary collapse
-
.config ⇒ PersistedHash
Builds a PersistedHash of the project nutella.json file and returns it.
-
.dir ⇒ String
Retrieves the current project directory.
-
.exist? ⇒ Boolean
Checks that the current directory is actually a nutella project.
Class Method Details
.config ⇒ PersistedHash
Builds a PersistedHash of the project nutella.json file and returns it. This method is used to ease access to the project nutella.json file.
30 31 32 33 34 35 36 37 38 |
# File 'lib/config/current_project.rb', line 30 def CurrentProjectUtils.config cur_prj_dir = Dir.pwd nutella_json_file = "#{cur_prj_dir}/nutella.json" if File.exist? nutella_json_file return PersistedHash.new nutella_json_file else console.error 'The current directory is not a nutella project: impossible to read nutella.json file' end end |
.dir ⇒ String
Retrieves the current project directory
42 43 44 |
# File 'lib/config/current_project.rb', line 42 def CurrentProjectUtils.dir Dir.pwd end |
.exist? ⇒ Boolean
Checks that the current directory is actually a nutella project
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/config/current_project.rb', line 10 def CurrentProjectUtils.exist? cur_prj_dir = Dir.pwd nutella_json_file = "#{cur_prj_dir}/nutella.json" # Check that there is a nutella.json file in the main directory of the project if File.exist? nutella_json_file conf = JSON.parse( IO.read(nutella_json_file) ) if conf['nutella_version'].nil? console.warn 'The current directory is not a nutella project: nutella_version unspecified in nutella.json file' return false end else console.warn 'The current directory is not a nutella project: impossible to read nutella.json file' return false end true end |