Class: Place::TimePoint
- Inherits:
-
Ohm::Model
- Object
- Ohm::Model
- Place::TimePoint
- Defined in:
- lib/place/time_point.rb
Overview
A TimePoint is a “named milestone”
Class Attribute Summary collapse
-
.rules ⇒ Object
Returns the value of attribute rules.
Class Method Summary collapse
-
.collect_all(base_url) ⇒ Object
Collect all timepoints (url) under a given project url.
- .find_by_tid(tid) ⇒ Object
Instance Method Summary collapse
-
#retrieve ⇒ Object
Retrieve a specific timepoint data (name, time, description).
Class Attribute Details
.rules ⇒ Object
Returns the value of attribute rules.
17 18 19 |
# File 'lib/place/time_point.rb', line 17 def rules @rules end |
Class Method Details
.collect_all(base_url) ⇒ Object
Collect all timepoints (url) under a given project url
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/place/time_point.rb', line 25 def self.collect_all(base_url) Dir.glob(base_url + '/tracker/timepoints/*.xml').each do |filename| TimePoint.create( :tid => File.basename(filename, '.xml'), :url => filename, :project => Project.find_by_url(base_url) ) Place.logger.info("collected timepoint at #{filename}") end end |
.find_by_tid(tid) ⇒ Object
48 49 50 51 52 |
# File 'lib/place/time_point.rb', line 48 def self.find_by_tid(tid) return nil if tid.nil? tps = self.find(:tid => tid.to_s) tps.nil? ? nil : tps[0] end |
Instance Method Details
#retrieve ⇒ Object
Retrieve a specific timepoint data (name, time, description)
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/place/time_point.rb', line 37 def retrieve content = IO.readlines(url).join('') doc = Nokogiri::XML(content) self.class.rules.each_pair do |k,v| tmp = doc.xpath(v) self.send("#{k}=", tmp[0].content) unless tmp[0].nil? end Place.logger.info("retrieved timepoint #{self.url}") self.save end |