Class: Powirb::Handler
- Inherits:
-
Object
- Object
- Powirb::Handler
- Defined in:
- lib/powirb/handler.rb
Overview
This class represent the workitems handler, that is an “iterator” over workitems in the same projects.
- Author
-
Carlo Pecchia ([email protected])
- Copyright
-
Copyright © 2011 Carlo Pecchia
- License
-
See LICENSE file
Instance Attribute Summary collapse
-
#project_path ⇒ Object
readonly
Returns the value of attribute project_path.
Instance Method Summary collapse
-
#initialize(project_path) ⇒ Handler
constructor
Initialize the handler with the project path (usually a subversion working copy).
-
#workitems(conditions = nil) ⇒ Object
Return all workitems in the project.
-
#workitems_paths ⇒ Object
Returns the path for workitems in the specified project.
Constructor Details
#initialize(project_path) ⇒ Handler
Initialize the handler with the project path (usually a subversion working copy)
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/powirb/handler.rb', line 15 def initialize(project_path) unless File.exist?(project_path) msg = "Invalid project path '#{project_path}'" Powirb.log.error(msg) raise msg end @project_path = project_path Powirb.log.debug("Initialized handler for #{@project_path}") # workitems are stored in a big hash, indexed by 'wid's @space = {} self.workitems_paths.each do |path| Dir[File.join(@project_path, path, "/**/workitem.xml")].each do |filename| wid = File.dirname(filename).split(/\//).last @space[wid] = Workitem.new(filename) Powirb.log.debug("Added workitem from #{filename}") end end Powirb.log.debug("Found #{@space.keys.size} workitems.") end |
Instance Attribute Details
#project_path ⇒ Object (readonly)
Returns the value of attribute project_path.
11 12 13 |
# File 'lib/powirb/handler.rb', line 11 def project_path @project_path end |
Instance Method Details
#workitems(conditions = nil) ⇒ Object
Return all workitems in the project
37 38 39 40 41 42 43 |
# File 'lib/powirb/handler.rb', line 37 def workitems(conditions=nil) return @space if conditions.nil? # Return only workitems for which *all* specified conditions are true @space.select do |wid,wi| conditions.map{|k,v| wi[k] == v}.reduce(:&) end end |
#workitems_paths ⇒ Object
Returns the path for workitems in the specified project
46 47 48 49 |
# File 'lib/powirb/handler.rb', line 46 def workitems_paths [ File.join('.polarion', 'tracker', 'workitems'), File.join('modules', '**', 'workitems') ] end |