Sha256: 9c5152be69e4a39a7982e714c7d561347c2c03ddcb986753135e6ddd8cac817e

Contents?: true

Size: 1.17 KB

Versions: 2

Compression:

Stored size: 1.17 KB

Contents

# handles current project files

require 'singleton'
require 'json'

module Nutella
  
  class Project
    
    include Singleton
    
    # Check that the current directory is actually a nutella project
    def exist?
      @prj_dir = Dir.pwd
      if File.exist?("#{@prj_dir}/conf/project.json")
        conf = JSON.parse( IO.read("#{@prj_dir}/conf/project.json") )
        if conf["nutella_version"].nil?
          console.warn "The current directory is not a Nutella project"
          return false
        end
      else
        console.warn "The current directory is not a Nutella project"
        return false
      end
      return true
    end
  
    # Returns the value for an entry in the project configuration file
    def config
      @prj_dir = Dir.pwd
      if File.exist? "#{@prj_dir}/conf/project.json" 
        return ConfigHash.new "#{@prj_dir}/conf/project.json"
        else
          console.error "The current directory is not a Nutella project! Impossible to get project configuration file"
        end
    end
    
    # Returns current project directory
    def dir
      Dir.pwd
    end
    
  end
  
  
  def Nutella.currentProject
    Project.instance
  end
  
end



Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
nutella_framework-0.1.2 lib/config/project.rb
nutella_framework-0.1.0 lib/config/project.rb