Module: Place

Defined in:
lib/place.rb,
lib/place/link.rb,
lib/place/user.rb,
lib/place/comment.rb,
lib/place/project.rb,
lib/place/work_item.rb,
lib/place/time_point.rb,
lib/place/work_record.rb,
lib/place/participation.rb

Defined Under Namespace

Classes: Comment, Link, Participation, Project, TimePoint, User, WorkItem, WorkRecord

Constant Summary collapse

VERSION =
'0.1.1'

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.confObject



28
29
30
# File 'lib/place.rb', line 28

def self.conf
  @conf
end

.loggerObject



32
33
34
# File 'lib/place.rb', line 32

def self.logger
  @log
end

.logger_setup(filename = nil) ⇒ Object



36
37
38
39
40
41
42
43
# File 'lib/place.rb', line 36

def self.logger_setup(filename=nil)
  unless filename.nil?
    @log = Logger.new(filename)
  else	  
    @log = Logger.new(STDERR)
	end
	@log.level = Logger::INFO   
end

.setup(repository_path) ⇒ Object



23
24
25
26
# File 'lib/place.rb', line 23

def self.setup(repository_path)
  @conf['base'] = repository_path
	Ohm.connect
end

Instance Method Details

#gather!(project_url = nil) ⇒ Object

Collect and retrieve all repo information, for each contained project If a project url is specified, it retrieves only info on this project BEWARE: each gather flush the whole database!



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/place.rb', line 48

def gather!(project_url=nil)
  start_time = Time.now.to_i
	
  path = @conf['base']  # without ending '.polarion'
  Ohm.flush
	
	Project.collect_all(path)
  User.collect_all(path)
	
	unless project_url.nil?
 prj = Project.find_by_url(project_url)
 prj.retrieve
	else
    Project.all.each{|prj| prj.retrieve}
	end
	
	Ohm.redis.set 'updated_duration', Time.now.to_i - start_time
end

#reset!Object



84
85
86
# File 'lib/place.rb', line 84

def reset!
  Ohm.flush
end

#to_hours(duration) ⇒ Object

from duration to number of hours (1d == 8h)



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/place.rb', line 89

def to_hours(duration)
  return nil if duration.nil?

  case duration
    when /([\d\/\s]*)d\s*([\d\/\s]*)h/
   days  = normalize($1)
   hours = normalize($2)
 when /([\d\/\s]*)d/
   days  = normalize($1)
   hours = 0.0
 when /([\d\/\s]*)h/
	    days  = 0.0
   hours = normalize($1)
  else
    days  = 0
    hours = 0
  end
	
 8*days.to_f + hours.to_f
end

#updated!Object

Write last update timespent for the whole database



68
69
70
# File 'lib/place.rb', line 68

def updated!
  Ohm.redis.set 'updated', Time.now.strftime("%d.%m.%Y %H:%M:%S")
end

#updated?Boolean

Returns:

  • (Boolean)


76
77
78
# File 'lib/place.rb', line 76

def updated?
  not updated_at.nil?
end

#updated_atObject



72
73
74
# File 'lib/place.rb', line 72

def updated_at
  Ohm.redis.get 'updated'
end

#updated_durationObject



80
81
82
# File 'lib/place.rb', line 80

def updated_duration
  Ohm.redis.get 'updated_duration'
end