Method: QB::Role#initialize
- Defined in:
- lib/qb/role.rb
#initialize(path, search_dir: nil) ⇒ Role
Instantiate a Role.
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 |
# File 'lib/qb/role.rb', line 216 def initialize path, search_dir: nil @path = if path.is_a?(Pathname) then path else Pathname.new(path) end # check it... unless @path.exist? raise Errno::ENOENT.new @path.to_s end unless @path.directory? raise Errno::ENOTDIR.new @path.to_s end @display_path = self.class.to_display_path @path @meta_path = if (@path + 'meta' + 'qb').exist? @path + 'meta' + 'qb' elsif (@path + 'meta' + 'qb.yml').exist? @path + 'meta' + 'qb.yml' else raise Errno::ENOENT.new "#{ @path.join('meta').to_s }/[qb|qb.yml]" end if search_dir.nil? @name = @path.to_s.split(File::SEPARATOR).last else @name = @path.relative_path_from(search_dir).to_s end end |