Class: RakeOE::PrjFileCache
- Inherits:
-
Object
- Object
- RakeOE::PrjFileCache
- Defined in:
- lib/rakeoe/prj_file_cache.rb
Overview
Finds all project files and reads them into memory Maps project path => project file XXX DS: IDEA: generate all runtime dependencies at the beginning for each prj, XXX DS: e.g. lib includes, source files, dependency files etc. and cache those as own variable in @prj_list
Class Method Summary collapse
-
.contain?(prj_type, prj_name) ⇒ Boolean
Do we know anything about prj_name ?.
-
.directory(prj_type, prj_name) ⇒ Object
Returns the directory in which the prj is.
-
.exported_lib_incs(name) ⇒ Object
Returns exported include directories of a library project.
- .for_each(prj_type, &block) ⇒ Object
-
.get(prj_type, prj_name, setting) ⇒ Object
Returns specific value of a setting of the specified project.
-
.project_names(prj_type) ⇒ Object
Returns all found project names.
-
.sweep_recursive(dirs = []) ⇒ Object
Search, read and parse all project files in given directories and add them to prj_list according to their PRJ_TYPE setting.
Class Method Details
.contain?(prj_type, prj_name) ⇒ Boolean
Do we know anything about prj_name ?
62 63 64 65 |
# File 'lib/rakeoe/prj_file_cache.rb', line 62 def self.contain?(prj_type, prj_name) return false unless @prj_list.has_key?(prj_type) @prj_list[prj_type].has_key?(prj_name) end |
.directory(prj_type, prj_name) ⇒ Object
Returns the directory in which the prj is
76 77 78 79 |
# File 'lib/rakeoe/prj_file_cache.rb', line 76 def self.directory(prj_type, prj_name) return nil unless self.contain?(prj_type, prj_name) @prj_list[prj_type][prj_name]['PRJ_HOME'] end |
.exported_lib_incs(name) ⇒ Object
Returns exported include directories of a library project. If given name does not exist in local library projects, an empty array is returned.
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/rakeoe/prj_file_cache.rb', line 99 def self.exported_lib_incs(name) rv = [] # try LIB exported_inc_dirs = self.get('LIB', name, 'EXPORTED_INC_DIRS') if exported_inc_dirs.to_s.empty? # try SOLIB exported_inc_dirs = self.get('SOLIB', name, 'EXPORTED_INC_DIRS') unless exported_inc_dirs.to_s.empty? rv << self.get('SOLIB', name, 'PRJ_HOME') + '/' + dir end else exported_inc_dirs.split.each do |dir| rv << self.get('LIB', name, 'PRJ_HOME') + '/' + dir end end rv end |
.for_each(prj_type, &block) ⇒ Object
82 83 84 85 |
# File 'lib/rakeoe/prj_file_cache.rb', line 82 def self.for_each(prj_type, &block) return unless @prj_list.has_key?(prj_type) @prj_list[prj_type].each_pair &block end |
.get(prj_type, prj_name, setting) ⇒ Object
Returns specific value of a setting of the specified project
55 56 57 58 |
# File 'lib/rakeoe/prj_file_cache.rb', line 55 def self.get(prj_type, prj_name, setting) return nil unless self.contain?(prj_type, prj_name) @prj_list[prj_type][prj_name][setting] || nil end |
.project_names(prj_type) ⇒ Object
Returns all found project names
69 70 71 72 |
# File 'lib/rakeoe/prj_file_cache.rb', line 69 def self.project_names(prj_type) return [] unless @prj_list.has_key?(prj_type) @prj_list[prj_type].keys end |
.sweep_recursive(dirs = []) ⇒ Object
Search, read and parse all project files in given directories and add them to prj_list according to their PRJ_TYPE setting.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/rakeoe/prj_file_cache.rb', line 25 def self.sweep_recursive(dirs=[]) globs = dirs.map{|dir| dir+'/**/prj.rake'} all_prj_files = FileList[globs] raise "No projects inside #{dirs}?!" if all_prj_files.empty? all_prj_files.each do |file| # extract last path from prj.rake as project name dir = File.dirname(file) name = File.basename(dir) kvr = KeyValueReader.new(file) prj_type = kvr.get('PRJ_TYPE') raise "Attribute PRJ_TYPE not set in #{dir}/prj.rake" if prj_type.empty? # add attribute PRJ_HOME kvr.set('PRJ_HOME', dir) kvr.set('PRJ_FILE', file) @prj_list[prj_type] ||= {} if @prj_list[prj_type].member?(name) raise "#{dir}/prj.rake: project \"#{name}\" for PRJ_TYPE \'#{prj_type}\' already defined in #{@prj_list[prj_type][name]['PRJ_HOME']}" # XXX we should use a new attribute PRJ_NAME for conflicting project names ... end @prj_list[prj_type].merge!({name => kvr.env}) end end |