class Project
Attributes
directories[R]
files[R]
other[R]
path[R]
templates[R]
Public Class Methods
new(path, template_engines: [:mustache, :erb], addon: false)
click to toggle source
# File app/project/project.rb, line 2 def initialize path, template_engines: [:mustache, :erb], addon: false @path = path @files = [] @templates = RBCM::Project::TemplateList.new @other = [] @directories = [] @template_engines = template_engines load_files path end
Public Instance Methods
addons()
click to toggle source
# File app/project/project.rb, line 29 def addons @files.each.addons.flatten end
all_addons(project=self)
click to toggle source
collect addons recursively
# File app/project/project.rb, line 34 def all_addons project=self ( project.addons + project.addons.collect{|project| all_addons project} ).flatten end
capabilities()
click to toggle source
# File app/project/project.rb, line 14 def capabilities files.each.capabilities.flatten.compact end
definitions(type=nil)
click to toggle source
# File app/project/project.rb, line 18 def definitions type=nil with files.each.definitions.flatten do return select{|definition| definition.type == type} if type return self end end
template(name)
click to toggle source
TODO?
# File app/project/project.rb, line 40 def template name # @templates.find{|name| name...} end
Private Instance Methods
load_files(path)
click to toggle source
# File app/project/project.rb, line 46 def load_files path if File.directory? path Dir["#{path}/**/*"].each do |file_path| if file_path.end_with? ".rb" @files.append RBCM::Project::ProjectFile.new( project: self, path: file_path ) elsif @template_engines.include? file_path.split(".").last.to_sym @templates.append RBCM::Project::Template.new( project: self, path: file_path ) elsif File.directory? path @directories << file_path.sub(@path, "") else @other << file_path.sub(@path, "") end end else @files = [ RBCM::Project::ProjectFile.new( project: self, path: path ) ] end raise "ERROR: empty project" unless @files.any? end