lib/rubber/commands/vulcanize.rb
# figures out the roles that a project has by looking in the
# project's directory tree, as well as the roles the current
# vulcanize  will be contributing
figures out the roles that a project has by looking in the
project's directory tree, as well as the roles the current
vulcanize  will be contributing
figures out the roles that a project has by looking in the project ' s directory tree as well as the roles the current vulcanize will be contributing
def project_roles
        return @project_roles if @project_roles
        roles = []
        roles.concat Dir["#{destination_root}/config/rubber/role/*"].collect {|f| File.basename(f) }
        roles.concat Dir["#{destination_root}/script/*/role/*"].collect {|f| File.basename(f) }
        Dir["#{destination_root}/config/rubber/rubber*.yml"].each do |yml|
          rubber_yml = YAML.load(File.read(yml)) rescue {}
          roles.concat(rubber_yml['roles'].keys) rescue nil
          roles.concat(rubber_yml['role_dependencies'].keys) rescue nil
          roles.concat(rubber_yml['role_dependencies'].values) rescue nil
        end
        roles << 'examples' 
        @template_dependencies.each do |name|
          template_dir = File.join(self.class.source_root, name, '')
          Dir["#{template_dir}/config/rubber/rubber*.yml"].each do |yml|
            rubber_yml = YAML.load(File.read(yml)) rescue {}
            roles.concat(rubber_yml['roles'].keys) rescue nil
            roles.concat(rubber_yml['role_dependencies'].keys) rescue nil
            roles.concat(rubber_yml['role_dependencies'].values) rescue nil
          end
        end
        @project_roles = roles.flatten.uniq
      end
def project_roles return @project_roles if @project_roles roles = [ ] roles . concat Dir [ "#{destination_root}/config/rubber/role/*" ] . collect { | f | File . basename ( f ) } roles . concat Dir [ "#{destination_root}/script/*/role/*" ] . collect { | f | File . basename ( f ) } Dir [ "#{destination_root}/config/rubber/rubber*.yml" ] . each do | yml | rubber_yml = YAML . load ( File . read ( yml ) ) rescue { } roles . concat ( rubber_yml [ 'roles' ] . keys ) rescue nil roles . concat ( rubber_yml [ 'role_dependencies' ] . keys ) rescue nil roles . concat ( rubber_yml [ 'role_dependencies' ] . values ) rescue nil end roles << 'examples' @template_dependencies . each do | name | template_dir = File . join ( self . class . source_root , name , '' ) Dir [ "#{template_dir}/config/rubber/rubber*.yml" ] . each do | yml | rubber_yml = YAML . load ( File . read ( yml ) ) rescue { } roles . concat ( rubber_yml [ 'roles' ] . keys ) rescue nil roles . concat ( rubber_yml [ 'role_dependencies' ] . keys ) rescue nil roles . concat ( rubber_yml [ 'role_dependencies' ] . values ) rescue nil end end @project_roles = roles . flatten . uniq end
figures out the roles that a project has by looking in the
project's directory tree, as well as the roles the current
vulcanize  will be contributing
figures out the roles that a project has by looking in the project ' s directory tree as well as the roles the current vulcanize will be contributing
# first grab all the roles from the project # slight hack for collectd/munin scripts # then grab all the roles from templates we are currently vulcanizing