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.0'
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.conf ⇒ Object
29
30
31
|
# File 'lib/place.rb', line 29
def self.conf
@conf
end
|
.logger ⇒ Object
33
34
35
|
# File 'lib/place.rb', line 33
def self.logger
@log
end
|
.logger_setup(filename = nil) ⇒ Object
37
38
39
40
41
42
43
44
|
# File 'lib/place.rb', line 37
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
24
25
26
27
|
# File 'lib/place.rb', line 24
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!
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
# File 'lib/place.rb', line 49
def gather!(project_url=nil)
start_time = Time.now.to_i
path = @conf['base'] 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
85
86
87
|
# File 'lib/place.rb', line 85
def reset!
Ohm.flush
end
|
#to_hours(duration) ⇒ Object
from duration to number of hours (1d == 8h)
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
# File 'lib/place.rb', line 90
def to_hours(duration)
return nil if duration.nil?
if duration =~ /(\d+)d\s(\d+)h/
days, hours = $1.to_f, $2.to_f
elsif duration =~ /(\d+)\/(\d+)d/
days = $1.to_f / $2.to_f
hours = 0
elsif duration =~ /(\d+)\/(\d+)h/
days = 0
hours = $1.to_f / $2.to_f
elsif duration =~ /(\d+)d/
days, hours = $1.to_f, 0
elsif duration =~ /(\d+)h/
days, hours = 0, $1.to_f
else
days, hours = 0, 0
end
(8*days + hours)
end
|
#updated! ⇒ Object
Write last update timespent for the whole database
69
70
71
|
# File 'lib/place.rb', line 69
def updated!
Ohm.redis.set 'updated', Time.now.strftime("%d.%m.%Y %H:%M:%S")
end
|
#updated? ⇒ Boolean
77
78
79
|
# File 'lib/place.rb', line 77
def updated?
not updated_at.nil?
end
|
#updated_at ⇒ Object
73
74
75
|
# File 'lib/place.rb', line 73
def updated_at
Ohm.redis.get 'updated'
end
|
#updated_duration ⇒ Object
81
82
83
|
# File 'lib/place.rb', line 81
def updated_duration
Ohm.redis.get 'updated_duration'
end
|