Class: Ecic::Project

Inherits:
Object
  • Object
show all
Defined in:
lib/ecic/project.rb

Constant Summary collapse

SCRIPT_ECIC =
File.join('src',  'config', 'ecic.rb')
LIBRARIES_CFG_SCRIPT =
File.join('src',  'config', 'libraries.rb')

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root = Project::root) ⇒ Project

Returns a new instance of Project.



10
11
12
13
# File 'lib/ecic/project.rb', line 10

def initialize(root = Project::root)
  @libraries = []
  @root = root
end

Instance Attribute Details

#librariesObject

Returns the value of attribute libraries.



5
6
7
# File 'lib/ecic/project.rb', line 5

def libraries
  @libraries
end

#rootObject (readonly)

Returns the value of attribute root.



6
7
8
# File 'lib/ecic/project.rb', line 6

def root
  @root
end

Class Method Details

.root(path = Pathname.new(Dir.pwd)) ⇒ Object

Function that returns the root directory of a ECIC project This is used by some generators to check if a command is called from within an ECIC project folder



21
22
23
24
25
26
27
28
# File 'lib/ecic/project.rb', line 21

def self.root(path = Pathname.new(Dir.pwd))
  if File.exists?(File.join(path, SCRIPT_ECIC))
    return path
  elsif path.root?
    return nil
  end
  return root(path.parent)
end

Instance Method Details

#has_library?(lib_name) ⇒ Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/ecic/project.rb', line 44

def has_library?(lib_name)
  libraries.any? {|l| l.name == lib_name }
end

#libraryObject

Function used by ‘library.create’ method used in src/confic/libraries.rb



53
54
55
56
57
# File 'lib/ecic/project.rb', line 53

def library
  new_lib = Library.new(self)
  libraries << new_lib
  new_lib
end

#load_librariesObject



30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/ecic/project.rb', line 30

def load_libraries
  lib_file = File.join(@root, LIBRARIES_CFG_SCRIPT)
  if File.exists?(lib_file)
    begin
      eval File.read(lib_file)
    rescue Exception => exc
      raise "Syntax error occurred while reading #{lib_file}: #{exc.message}"
    end  
#      else
#        raise "Could not read library definitions from #{lib_file}"
  end
end

#load_sourcesObject



59
60
61
# File 'lib/ecic/project.rb', line 59

def load_sources
  libraries.each { |lib| lib.load_sources }
end