Class: RBCM::Project::ProjectFile

Inherits:
Object
  • Object
show all
Defined in:
app/project/file.rb

Overview

extracts capabilities and definitions from project files

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project:, path:) ⇒ ProjectFile

Returns a new instance of ProjectFile.



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/project/file.rb', line 4

def initialize project:, path:
  @project = project
  @path = path
  @definitions = []
  @capabilities = []
  @addons = []
  file = File.read path
  method_names_cache = methods(false)
  instance_eval file
  sandbox = RBCM::Project::Sandbox.dup
  sandbox.module_eval(file)
  sandbox.instance_methods.each do |name|
    raise "ERROR: capability name '#{name}' not allowed" if [:node, :group].include? name
    @capabilities.append RBCM::Project::Capability.new(
      name:         name,
      content:      sandbox.instance_method(name),
      project_file: self
    )
  end
end

Instance Attribute Details

#addon_namesObject (readonly)

Returns the value of attribute addon_names.



25
26
27
# File 'app/project/file.rb', line 25

def addon_names
  @addon_names
end

#addonsObject (readonly)

Returns the value of attribute addons.



25
26
27
# File 'app/project/file.rb', line 25

def addons
  @addons
end

#capabilitiesObject (readonly)

Returns the value of attribute capabilities.



25
26
27
# File 'app/project/file.rb', line 25

def capabilities
  @capabilities
end

#definitionsObject (readonly)

Returns the value of attribute definitions.



25
26
27
# File 'app/project/file.rb', line 25

def definitions
  @definitions
end

#pathObject (readonly)

Returns the value of attribute path.



25
26
27
# File 'app/project/file.rb', line 25

def path
  @path
end

#projectObject (readonly)

Returns the value of attribute project.



25
26
27
# File 'app/project/file.rb', line 25

def project
  @project
end