achoo 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +6 -0
- data/Rakefile +73 -5
- data/bin/ical +15 -1
- data/lib/achoo/achievo.rb +1 -1
- data/lib/achoo/achievo/date_field.rb +35 -0
- data/lib/achoo/achievo/hour_administration_form.rb +3 -13
- data/lib/achoo/achievo/hour_registration_form.rb +13 -16
- data/lib/achoo/achievo/hour_registration_form_ranged.rb +4 -21
- data/lib/achoo/awake.rb +3 -8
- data/lib/achoo/extensions.rb +25 -2
- data/lib/achoo/system/pm_suspend.rb +1 -1
- data/lib/achoo/system/utmp_record.rb +1 -1
- data/lib/achoo/system/wtmp.rb +4 -0
- data/lib/achoo/temporal/timespan.rb +31 -43
- data/lib/achoo/term.rb +9 -5
- data/lib/achoo/ui/register_hours.rb +29 -25
- metadata +3 -3
- data/lib/achoo/achievo/form.rb +0 -22
data/CHANGES
CHANGED
data/Rakefile
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
require 'rake/gempackagetask'
|
4
|
-
require 'rake/rdoctask'
|
5
4
|
require 'rake/testtask'
|
6
5
|
require 'rubygems'
|
7
6
|
|
@@ -37,30 +36,99 @@ namespace 'test' do
|
|
37
36
|
t.test_files = FileList['test/acceptance/test*.rb']
|
38
37
|
end
|
39
38
|
|
39
|
+
end
|
40
|
+
|
41
|
+
namespace 'metrics' do
|
42
|
+
|
43
|
+
begin
|
44
|
+
require 'code_stats'
|
45
|
+
CodeStats::Tasks.new
|
46
|
+
rescue LoadError => e
|
47
|
+
warn "Package code_stats required for the metrics:code_stats task to be available."
|
48
|
+
end
|
49
|
+
|
40
50
|
desc 'Measures test coverage'
|
41
51
|
task :coverage do
|
42
52
|
rm_f('coverage')
|
43
|
-
system("rcov -T -Ilib test/unit/test_*.rb")
|
53
|
+
system("rcov -T -Ilib:test/lib test/unit/test_*.rb")
|
44
54
|
end
|
45
55
|
|
46
56
|
end
|
47
57
|
|
58
|
+
|
59
|
+
begin
|
60
|
+
require 'metric_fu'
|
61
|
+
MetricFu::Configuration.run do |config|
|
62
|
+
dirs = %w(lib bin)
|
63
|
+
|
64
|
+
# Define which metrics you want to use.
|
65
|
+
# [:churn, :saikuro, :stats, :flog, :flay, :reek, :roodi, :rcov]
|
66
|
+
# - :stats only works for rails applications
|
67
|
+
config.metrics = [:churn, :saikuro, :flog, :flay, :reek, :roodi, :rcov]
|
68
|
+
|
69
|
+
# [:flog, :flay, :reek, :roodi, :rcov]
|
70
|
+
config.graphs = [:flog, :flay, :reek, :roodi, :rcov]
|
71
|
+
|
72
|
+
config.flay = {
|
73
|
+
:dirs_to_flay => dirs,
|
74
|
+
:minimum_score => 0,
|
75
|
+
}
|
76
|
+
config.flog = { :dirs_to_flog => dirs }
|
77
|
+
config.reek = { :dirs_to_reek => dirs }
|
78
|
+
config.roodi = { :dirs_to_roodi => dirs }
|
79
|
+
config.saikuro = {
|
80
|
+
:output_directory => 'scratch_directory/saikuro',
|
81
|
+
:input_directory => dirs,
|
82
|
+
:cyclo => "",
|
83
|
+
:filter_cyclo => "0",
|
84
|
+
:warn_cyclo => "5",
|
85
|
+
:error_cyclo => "7",
|
86
|
+
:formater => "text" #this needs to be set to "text"
|
87
|
+
}
|
88
|
+
config.churn = {
|
89
|
+
:start_date => "1 year ago",
|
90
|
+
:minimum_churn_count => 10
|
91
|
+
}
|
92
|
+
config.rcov = {
|
93
|
+
:environment => '',
|
94
|
+
:test_files => ['test/unit/**/test_*.rb'],
|
95
|
+
:rcov_opts => ["--sort coverage",
|
96
|
+
"--no-html",
|
97
|
+
"--text-coverage",
|
98
|
+
"--no-color",
|
99
|
+
"--profile",
|
100
|
+
"--exclude /gems/,/test/",
|
101
|
+
"--include lib:test/lib",
|
102
|
+
]}
|
103
|
+
|
104
|
+
# :bluff or :gchart
|
105
|
+
config.graph_engine = :bluff
|
106
|
+
end
|
107
|
+
rescue LoadError => e
|
108
|
+
warn "Package metric_fu required for the metrics:all task to be available."
|
109
|
+
end
|
110
|
+
|
111
|
+
|
48
112
|
namespace 'doc' do
|
49
113
|
|
114
|
+
begin
|
115
|
+
require 'hanna/rdoctask'
|
116
|
+
rescue LoadError => e
|
117
|
+
warn "Package hanna recommended for better rdoc output."
|
118
|
+
require 'rake/rdoctask'
|
119
|
+
end
|
50
120
|
Rake::RDocTask.new do |rd|
|
51
121
|
rd.title = 'Achoo --- The Achievo CLI'
|
52
122
|
rd.main = "README.rdoc"
|
53
123
|
rd.rdoc_files.include("README.rdoc", "lib/**/*.rb")
|
54
|
-
rd.template = `allison --path`.chop + '.rb'
|
55
124
|
rd.options << '--line-numbers' << '--inline-source'
|
56
125
|
rd.rdoc_dir = 'doc'
|
57
126
|
end
|
58
|
-
|
59
127
|
end
|
60
128
|
|
61
129
|
desc 'Install development dependencies'
|
62
130
|
task :setup do
|
63
|
-
system 'gem install shoulda rack thin redgreen
|
131
|
+
system 'gem install shoulda rack thin redgreen metric_fu code_stats hanna'
|
64
132
|
end
|
65
133
|
|
66
134
|
desc 'Remove generated files and folders'
|
data/bin/ical
CHANGED
@@ -9,8 +9,22 @@ include Achoo::RCLoader
|
|
9
9
|
def main
|
10
10
|
load_rc
|
11
11
|
|
12
|
+
options = {
|
13
|
+
:date => Date.today,
|
14
|
+
}
|
15
|
+
|
16
|
+
optparse = OptionParser.new do|opts|
|
17
|
+
opts.banner = "Usage: $0 [options]"
|
18
|
+
|
19
|
+
opts.on( '-d', '--date [DATE]', 'FIX' ) do |date|
|
20
|
+
options[:date] = Date.parse(date)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
optparse.parse!
|
25
|
+
|
12
26
|
RC[:ical].each do |config|
|
13
|
-
Achoo::ICal.from_http_request(config).print_events(
|
27
|
+
Achoo::ICal.from_http_request(config).print_events(options[:date])
|
14
28
|
end
|
15
29
|
end
|
16
30
|
|
data/lib/achoo/achievo.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
require 'achoo'
|
2
|
+
require 'achoo/achievo/date_field'
|
2
3
|
|
3
4
|
module Achoo
|
4
5
|
module Achievo
|
5
|
-
autoload :Form, 'achoo/achievo/form.rb'
|
6
6
|
autoload :HourAdministrationForm, 'achoo/achievo/hour_administration_form.rb'
|
7
7
|
autoload :HourRegistrationForm, 'achoo/achievo/hour_registration_form.rb'
|
8
8
|
autoload :HourRegistrationFormRanged, 'achoo/achievo/hour_registration_form_ranged.rb'
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'achoo/achievo'
|
2
|
+
|
3
|
+
module Achoo
|
4
|
+
module Achievo
|
5
|
+
|
6
|
+
def self.DateField(attr_name, field_name)
|
7
|
+
Module.new do
|
8
|
+
define_method("#{attr_name}=") do |date|
|
9
|
+
# Day and month must be prefixed with '0' if single
|
10
|
+
# digit. Date.day and Date.month doesn't do this. Use strftime
|
11
|
+
send("#{attr_name}_day_field=", date.strftime('%d'))
|
12
|
+
send("#{attr_name}_month_field=", date.strftime('%m'))
|
13
|
+
send("#{attr_name}_year_field=", date.year)
|
14
|
+
end
|
15
|
+
|
16
|
+
define_method("#{attr_name}") do
|
17
|
+
Date.new(*[send("#{attr_name}_year_field"),
|
18
|
+
send("#{attr_name}_month_field"),
|
19
|
+
send("#{attr_name}_day_field")].collect {|e| e.to_i})
|
20
|
+
end
|
21
|
+
|
22
|
+
%w(day month year).each do |e|
|
23
|
+
define_method("#{attr_name}_#{e}_field") do
|
24
|
+
@form.field_with(:name => "#{field_name}[#{e}]").value
|
25
|
+
end
|
26
|
+
|
27
|
+
define_method("#{attr_name}_#{e}_field=") do |val|
|
28
|
+
@form.field_with(:name => "#{field_name}[#{e}]").value = val
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
@@ -3,7 +3,9 @@ require 'achoo/term/table'
|
|
3
3
|
|
4
4
|
module Achoo
|
5
5
|
module Achievo
|
6
|
-
class HourAdministrationForm
|
6
|
+
class HourAdministrationForm
|
7
|
+
|
8
|
+
include Achievo::DateField('date', 'viewdate')
|
7
9
|
|
8
10
|
def initialize(agent)
|
9
11
|
@agent = agent
|
@@ -74,18 +76,6 @@ module Achoo
|
|
74
76
|
@page = @form.submit
|
75
77
|
end
|
76
78
|
|
77
|
-
def day_field
|
78
|
-
@form.field_with(:name => 'viewdate[day]')
|
79
|
-
end
|
80
|
-
|
81
|
-
def month_field
|
82
|
-
@form.field_with(:name => 'viewdate[month]')
|
83
|
-
end
|
84
|
-
|
85
|
-
def year_field
|
86
|
-
@form.field_with(:name => 'viewdate[year]')
|
87
|
-
end
|
88
|
-
|
89
79
|
end
|
90
80
|
end
|
91
81
|
end
|
@@ -2,7 +2,9 @@ require 'achoo/achievo'
|
|
2
2
|
|
3
3
|
module Achoo
|
4
4
|
module Achievo
|
5
|
-
class HourRegistrationForm
|
5
|
+
class HourRegistrationForm
|
6
|
+
|
7
|
+
include Achievo::DateField('date', 'activitydate')
|
6
8
|
|
7
9
|
def initialize(agent)
|
8
10
|
@agent = agent
|
@@ -65,10 +67,17 @@ module Achoo
|
|
65
67
|
@form.billpercent = "billpercent.id='#{billing}'"
|
66
68
|
end
|
67
69
|
|
68
|
-
|
69
70
|
def worktime_periods
|
70
|
-
|
71
|
-
|
71
|
+
collect_options('workperiod')
|
72
|
+
end
|
73
|
+
|
74
|
+
def billing_options
|
75
|
+
collect_options('billpercent')
|
76
|
+
end
|
77
|
+
|
78
|
+
def collect_options(field_name, pattern)
|
79
|
+
@form.field_with(:name => field_name).options.collect do |opt|
|
80
|
+
[opt.value.match(/#{field_name}\.id='(\d+)'/)[1], opt.text]
|
72
81
|
end
|
73
82
|
end
|
74
83
|
|
@@ -178,18 +187,6 @@ module Achoo
|
|
178
187
|
body, nil, @agent)
|
179
188
|
end
|
180
189
|
|
181
|
-
def day_field
|
182
|
-
@form.field_with(:name => 'activitydate[day]')
|
183
|
-
end
|
184
|
-
|
185
|
-
def month_field
|
186
|
-
@form.field_with(:name => 'activitydate[month]')
|
187
|
-
end
|
188
|
-
|
189
|
-
def year_field
|
190
|
-
@form.field_with(:name => 'activitydate[year]')
|
191
|
-
end
|
192
|
-
|
193
190
|
def extract_number_from_projectid(projectid)
|
194
191
|
projectid.match(/project\.id='(\d+)'/)[1]
|
195
192
|
end
|
@@ -4,42 +4,25 @@ module Achoo
|
|
4
4
|
module Achievo
|
5
5
|
class HourRegistrationFormRanged < HourRegistrationForm
|
6
6
|
|
7
|
+
include Achievo::DateField('to_date', 'todate')
|
8
|
+
|
7
9
|
def initialize(agent)
|
8
10
|
super
|
9
|
-
|
10
11
|
@page = @agent.get(atk_submit_to_url(@page.link_with(:text => 'Select range').href))
|
11
12
|
@form = @page.form('entryform')
|
12
13
|
end
|
13
14
|
|
14
15
|
def date=(date_range)
|
15
16
|
super(date_range[0])
|
16
|
-
|
17
|
-
to_day_field.value = date_range[1].strftime('%d')
|
18
|
-
to_month_field.value = date_range[1].strftime('%m')
|
19
|
-
to_year_field.value = date_range[1].year
|
17
|
+
self.to_date = date_range[1]
|
20
18
|
end
|
21
19
|
|
22
20
|
def date
|
23
|
-
|
24
|
-
finish = Date.new(to_year_field.value.to_i, to_month_field.value.to_i,
|
25
|
-
to_day_field.value.to_i)
|
26
|
-
[start, finish]
|
21
|
+
[super, to_date()]
|
27
22
|
end
|
28
23
|
|
29
24
|
private
|
30
25
|
|
31
|
-
def to_day_field
|
32
|
-
@form.field_with(:name => 'todate[day]')
|
33
|
-
end
|
34
|
-
|
35
|
-
def to_month_field
|
36
|
-
@form.field_with(:name => 'todate[month]')
|
37
|
-
end
|
38
|
-
|
39
|
-
def to_year_field
|
40
|
-
@form.field_with(:name => 'todate[year]')
|
41
|
-
end
|
42
|
-
|
43
26
|
def date_to_s
|
44
27
|
date.map {|d| d.strftime("%Y-%m-%d")}.join(" -> ")
|
45
28
|
end
|
data/lib/achoo/awake.rb
CHANGED
@@ -7,7 +7,7 @@ module Achoo
|
|
7
7
|
class Awake
|
8
8
|
|
9
9
|
def initialize
|
10
|
-
log = wtmp.merge!(suspend)
|
10
|
+
log = wtmp.merge!(suspend).reverse
|
11
11
|
log.unshift(System::LogEntry.new(Time.now, :now))
|
12
12
|
@sessions = sessions(log)
|
13
13
|
end
|
@@ -69,16 +69,11 @@ module Achoo
|
|
69
69
|
end
|
70
70
|
|
71
71
|
def suspend
|
72
|
-
|
73
|
-
new_log = []
|
74
|
-
log.each do |entry|
|
75
|
-
new_log << System::LogEntry.new(entry.time, entry.event == 'Awake.' ? :awake : :suspend)
|
76
|
-
end
|
77
|
-
new_log
|
72
|
+
System::PMSuspend.new
|
78
73
|
end
|
79
74
|
|
80
75
|
def wtmp
|
81
|
-
log = System::Wtmp.new
|
76
|
+
log = System::Wtmp.new
|
82
77
|
new_log = []
|
83
78
|
log.each do |entry|
|
84
79
|
if entry.boot_event?
|
data/lib/achoo/extensions.rb
CHANGED
@@ -1,8 +1,12 @@
|
|
1
1
|
class Array
|
2
2
|
|
3
|
+
%w(merge!).each do |method|
|
4
|
+
raise "Method already defined: #{name}\##{method}" \
|
5
|
+
if method_defined?(method)
|
6
|
+
end
|
7
|
+
|
3
8
|
#
|
4
|
-
# Useful for merging two sorted arrays with Comparable
|
5
|
-
# elements.
|
9
|
+
# Useful for merging two sorted arrays with Comparable elements.
|
6
10
|
#
|
7
11
|
# The content of the two input arrays should not be trusted after
|
8
12
|
# being mistreated by this method.
|
@@ -22,3 +26,22 @@ class Array
|
|
22
26
|
end
|
23
27
|
|
24
28
|
end
|
29
|
+
|
30
|
+
|
31
|
+
class Integer
|
32
|
+
|
33
|
+
%w(day days hour hours minute minutes).each do |method|
|
34
|
+
raise "Method already defined: #{name}\##{method}" \
|
35
|
+
if method_defined?(method)
|
36
|
+
end
|
37
|
+
|
38
|
+
def day; self * 86400; end
|
39
|
+
alias days day
|
40
|
+
|
41
|
+
def hour; self * 3600; end
|
42
|
+
alias hours hour
|
43
|
+
|
44
|
+
def minute; self * 60; end
|
45
|
+
alias minutes minute
|
46
|
+
|
47
|
+
end
|
data/lib/achoo/system/wtmp.rb
CHANGED
@@ -3,51 +3,30 @@ require 'time'
|
|
3
3
|
|
4
4
|
module Achoo
|
5
5
|
module Temporal
|
6
|
-
class Timespan
|
7
|
-
|
8
|
-
SECONDS_IN_A_DAY = 86400
|
9
|
-
SECONDS_IN_AN_HOUR = 3600
|
10
|
-
SECONDS_IN_A_MINUTE = 60
|
11
|
-
|
12
|
-
attr :start
|
13
|
-
attr :end
|
6
|
+
class Timespan < Range
|
14
7
|
|
15
8
|
def initialize(start, end_)
|
16
9
|
raise ArgumentError.new('Nil in parameters not allowed') if start.nil? || end_.nil?
|
17
10
|
|
18
|
-
|
19
|
-
self.end = end_
|
20
|
-
end
|
21
|
-
|
22
|
-
def start=(timeish)
|
23
|
-
@start = to_time(timeish)
|
24
|
-
end
|
25
|
-
|
26
|
-
def end=(timeish)
|
27
|
-
@end = to_time(timeish)
|
11
|
+
super(to_time(start), to_time(end_))
|
28
12
|
end
|
29
13
|
|
30
14
|
def to_s
|
31
|
-
|
32
|
-
from_to = from_to_string
|
33
|
-
|
34
|
-
sprintf("(%s) %s", duration, from_to)
|
15
|
+
"(%s) %s" % [duration_string, from_to_string]
|
35
16
|
end
|
36
17
|
|
37
18
|
def contains?(timeish_or_timespan)
|
38
19
|
if timeish_or_timespan.is_a? Timespan
|
39
|
-
|
40
|
-
|
20
|
+
time = timeish_or_timespan
|
21
|
+
include?(time.first) && include?(time.last)
|
41
22
|
else
|
42
|
-
|
43
|
-
return start <= time && self.end >= time
|
23
|
+
include?(to_time(timeish_or_timespan))
|
44
24
|
end
|
45
25
|
end
|
46
26
|
|
47
27
|
def overlaps?(timespan)
|
48
|
-
|
49
|
-
|
50
|
-
|| contains?(timespan) || timespan.contains?(self)
|
28
|
+
include?(timespan.first) || include?(timespan.last) ||
|
29
|
+
timespan.contains?(self)
|
51
30
|
end
|
52
31
|
|
53
32
|
private
|
@@ -69,25 +48,33 @@ module Achoo
|
|
69
48
|
end
|
70
49
|
end
|
71
50
|
|
72
|
-
|
73
51
|
def duration_string
|
74
|
-
|
75
|
-
|
52
|
+
"%d+%02d:%02d" % duration
|
53
|
+
end
|
76
54
|
|
77
|
-
|
78
|
-
|
55
|
+
def duration
|
56
|
+
delta = last - first
|
57
|
+
d = delta.to_i / 1.day
|
79
58
|
|
80
|
-
delta = delta -
|
81
|
-
|
59
|
+
delta = delta - d.days
|
60
|
+
h = delta.to_i / 1.hour
|
82
61
|
|
83
|
-
|
62
|
+
delta = delta - h.hours
|
63
|
+
m = delta.to_i / 1.minute
|
64
|
+
|
65
|
+
return [d, h, m]
|
84
66
|
end
|
85
67
|
|
86
68
|
def from_to_string
|
87
69
|
today = Date.today
|
88
|
-
start_date =
|
89
|
-
end_date =
|
70
|
+
start_date = first.send(:to_date)
|
71
|
+
end_date = last.send(:to_date)
|
72
|
+
|
73
|
+
"%s - %s" % [from_as_string(start_date, today),
|
74
|
+
to_as_string(start_date, end_date, today)]
|
75
|
+
end
|
90
76
|
|
77
|
+
def from_as_string(start_date, today)
|
91
78
|
format = if start_date == today
|
92
79
|
"Today"
|
93
80
|
elsif start_date.month == today.month &&
|
@@ -98,8 +85,10 @@ module Achoo
|
|
98
85
|
else
|
99
86
|
"%a %e. %b %Y"
|
100
87
|
end
|
101
|
-
from =
|
88
|
+
from = first.strftime(format << " %R")
|
89
|
+
end
|
102
90
|
|
91
|
+
def to_as_string(start_date, end_date, today)
|
103
92
|
format = if end_date == start_date
|
104
93
|
"%R"
|
105
94
|
elsif end_date == today
|
@@ -112,11 +101,10 @@ module Achoo
|
|
112
101
|
else
|
113
102
|
"%a %e. %b %Y %R"
|
114
103
|
end
|
115
|
-
to =
|
116
|
-
|
117
|
-
sprintf "%s - %s", from, to
|
104
|
+
to = last.strftime(format)
|
118
105
|
end
|
119
106
|
|
120
107
|
end
|
121
108
|
end
|
122
109
|
end
|
110
|
+
|
data/lib/achoo/term.rb
CHANGED
@@ -8,13 +8,17 @@ module Achoo
|
|
8
8
|
autoload :Menu, 'achoo/term/menu'
|
9
9
|
autoload :Table, 'achoo/term/table'
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
BOLD = 1
|
12
|
+
UNDERLINE = 4
|
13
|
+
RED = 31
|
14
|
+
YELLOW = 33
|
14
15
|
|
15
|
-
def self.
|
16
|
+
def self.effect(code, text); "\e[#{code}m#{text}\e[0m"; end
|
16
17
|
|
17
|
-
def self.
|
18
|
+
def self.bold(text); effect(BOLD, text); end
|
19
|
+
def self.underline(text); effect(UNDERLINE, text); end
|
20
|
+
def self.warn(text); effect(YELLOW, text); end
|
21
|
+
def self.fatal(text); effect(RED, text); end
|
18
22
|
|
19
23
|
def self.password
|
20
24
|
`stty -echo`
|
@@ -47,27 +47,9 @@ module Achoo
|
|
47
47
|
|
48
48
|
|
49
49
|
def phase_chooser(form)
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
phases[answer.to_i-1][0]
|
54
|
-
end
|
55
|
-
|
56
|
-
|
57
|
-
def workperiod_chooser(form)
|
58
|
-
periods = form.worktime_periods
|
59
|
-
puts "Worktime periods"
|
60
|
-
answer = Term.choose('Period [1]', periods.collect {|p| p[1] }, nil, [''])
|
61
|
-
answer = '1' if answer.empty?
|
62
|
-
periods[answer.to_i-1][0]
|
63
|
-
end
|
64
|
-
|
65
|
-
def billing_chooser(form)
|
66
|
-
options = form.billing_options
|
67
|
-
puts "Billing options"
|
68
|
-
answer = Term.choose('Billing [1]', options.collect {|p| p[1] }, nil, [''])
|
69
|
-
answer = '1' if answer.empty?
|
70
|
-
options[answer.to_i-1][0]
|
50
|
+
chooser_helper(form.phases_for_selected_project,
|
51
|
+
"Phases",
|
52
|
+
'Phase')
|
71
53
|
end
|
72
54
|
|
73
55
|
|
@@ -87,6 +69,19 @@ module Achoo
|
|
87
69
|
return answer == '' ? '7.5' : answer
|
88
70
|
end
|
89
71
|
|
72
|
+
def workperiod_chooser(form)
|
73
|
+
chooser_helper(form.worktime_periods,
|
74
|
+
"Worktime periods",
|
75
|
+
'Period [1]',
|
76
|
+
true)
|
77
|
+
end
|
78
|
+
|
79
|
+
def billing_chooser(form)
|
80
|
+
chooser_helper(form.billing_options,
|
81
|
+
"Billing options",
|
82
|
+
'Billing [1]',
|
83
|
+
true)
|
84
|
+
end
|
90
85
|
|
91
86
|
def print_remark_help(date)
|
92
87
|
puts "VCS logs for #{date}:"
|
@@ -128,12 +123,21 @@ module Achoo
|
|
128
123
|
end
|
129
124
|
|
130
125
|
|
126
|
+
|
131
127
|
def all_projects_chooser(form)
|
132
|
-
|
133
|
-
|
134
|
-
|
128
|
+
chooser_helper(form.all_projects,
|
129
|
+
'All projects',
|
130
|
+
'Project')
|
135
131
|
end
|
136
|
-
|
132
|
+
|
133
|
+
def chooser_helper(options, heading, prompt, empty_allowed=false)
|
134
|
+
puts heading
|
135
|
+
extra = empty_allowed ? [''] : []
|
136
|
+
answer = Achoo::Term.choose(prompt, options.collect {|p| p[1] }, nil, [''])
|
137
|
+
answer = '1' if answer.empty?
|
138
|
+
options[answer.to_i-1][0]
|
139
|
+
end
|
140
|
+
|
137
141
|
end
|
138
142
|
end
|
139
143
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: achoo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- "Kjell-Magne \xC3\x98ierud"
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-
|
12
|
+
date: 2010-05-11 00:00:00 +02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -58,12 +58,12 @@ files:
|
|
58
58
|
- lib/achoo/ui/optionally_ranged_date_chooser.rb
|
59
59
|
- lib/achoo/ui/date_choosers.rb
|
60
60
|
- lib/achoo/ui/register_hours.rb
|
61
|
-
- lib/achoo/achievo/form.rb
|
62
61
|
- lib/achoo/achievo/lock_month_form.rb
|
63
62
|
- lib/achoo/achievo/login_form.rb
|
64
63
|
- lib/achoo/achievo/hour_registration_form.rb
|
65
64
|
- lib/achoo/achievo/hour_administration_form.rb
|
66
65
|
- lib/achoo/achievo/hour_registration_form_ranged.rb
|
66
|
+
- lib/achoo/achievo/date_field.rb
|
67
67
|
- lib/achoo/achievo/table.rb
|
68
68
|
- lib/achoo/system.rb
|
69
69
|
- lib/achoo/system/log_entry.rb
|
data/lib/achoo/achievo/form.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
require 'achoo/achievo'
|
2
|
-
|
3
|
-
module Achoo
|
4
|
-
module Achievo
|
5
|
-
class Form
|
6
|
-
|
7
|
-
def date=(date)
|
8
|
-
# Day and month must be prefixed with '0' if single
|
9
|
-
# digit. Date.day and Date.month doesn't do this. Use strftime
|
10
|
-
day_field.value = date.strftime('%d')
|
11
|
-
month_field.value = date.strftime('%m')
|
12
|
-
year_field.value = date.year
|
13
|
-
end
|
14
|
-
|
15
|
-
def date
|
16
|
-
Date.new(year_field.value.to_i, month_field.value.to_i,
|
17
|
-
day_field.value.to_i)
|
18
|
-
end
|
19
|
-
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|