trackable_tasks 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,5 +1,11 @@
1
1
  == unreleased changes
2
2
 
3
+ == 0.1.1
4
+ * Testing updates
5
+ * New chart formatting
6
+
7
+ == 0.1.0
8
+
3
9
  * Added an optional finally method to the TrackableTask::Base
4
10
  * Moved the rake task to a railtie
5
11
  * Added a basic stats system
data/Gemfile.lock CHANGED
@@ -1,44 +1,44 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- trackable_tasks (0.0.13)
4
+ trackable_tasks (0.1.0)
5
5
  rails (>= 3.0.7)
6
6
  trackable_tasks
7
7
 
8
8
  GEM
9
9
  remote: http://rubygems.org/
10
10
  specs:
11
- actionmailer (3.1.4)
12
- actionpack (= 3.1.4)
13
- mail (~> 2.3.0)
14
- actionpack (3.1.4)
15
- activemodel (= 3.1.4)
16
- activesupport (= 3.1.4)
11
+ actionmailer (3.2.8)
12
+ actionpack (= 3.2.8)
13
+ mail (~> 2.4.4)
14
+ actionpack (3.2.8)
15
+ activemodel (= 3.2.8)
16
+ activesupport (= 3.2.8)
17
17
  builder (~> 3.0.0)
18
18
  erubis (~> 2.7.0)
19
- i18n (~> 0.6)
20
- rack (~> 1.3.6)
21
- rack-cache (~> 1.1)
22
- rack-mount (~> 0.8.2)
19
+ journey (~> 1.0.4)
20
+ rack (~> 1.4.0)
21
+ rack-cache (~> 1.2)
23
22
  rack-test (~> 0.6.1)
24
- sprockets (~> 2.0.3)
25
- activemodel (3.1.4)
26
- activesupport (= 3.1.4)
23
+ sprockets (~> 2.1.3)
24
+ activemodel (3.2.8)
25
+ activesupport (= 3.2.8)
27
26
  builder (~> 3.0.0)
28
- i18n (~> 0.6)
29
- activerecord (3.1.4)
30
- activemodel (= 3.1.4)
31
- activesupport (= 3.1.4)
32
- arel (~> 2.2.3)
27
+ activerecord (3.2.8)
28
+ activemodel (= 3.2.8)
29
+ activesupport (= 3.2.8)
30
+ arel (~> 3.0.2)
33
31
  tzinfo (~> 0.3.29)
34
- activeresource (3.1.4)
35
- activemodel (= 3.1.4)
36
- activesupport (= 3.1.4)
37
- activesupport (3.1.4)
32
+ activeresource (3.2.8)
33
+ activemodel (= 3.2.8)
34
+ activesupport (= 3.2.8)
35
+ activesupport (3.2.8)
36
+ i18n (~> 0.6)
38
37
  multi_json (~> 1.0)
38
+ addressable (2.3.2)
39
39
  archive-tar-minitar (0.5.2)
40
- arel (2.2.3)
41
- builder (3.0.0)
40
+ arel (3.0.2)
41
+ builder (3.0.3)
42
42
  capybara (1.1.2)
43
43
  mime-types (>= 1.16)
44
44
  nokogiri (>= 1.3.3)
@@ -46,75 +46,69 @@ GEM
46
46
  rack-test (>= 0.5.4)
47
47
  selenium-webdriver (~> 2.0)
48
48
  xpath (~> 0.1.4)
49
- childprocess (0.3.1)
50
- ffi (~> 1.0.6)
51
- ci_reporter (1.7.0)
49
+ childprocess (0.3.5)
50
+ ffi (>= 1.0.6, ~> 1.0)
51
+ ci_reporter (1.7.3)
52
52
  builder (>= 2.1.2)
53
53
  columnize (0.3.6)
54
+ cucumber (1.2.1)
54
55
  builder (>= 2.1.2)
55
- cucumber (= 1.1.9)
56
- diff-lcs (>= 1.1.2)
57
- gherkin (~> 2.9.0)
56
+ diff-lcs (>= 1.1.3)
57
+ gherkin (~> 2.11.0)
58
58
  json (>= 1.4.6)
59
- term-ansicolor (>= 1.0.6)
60
- cucumber (1.1.9)
61
- builder (>= 2.1.2)
62
- diff-lcs (>= 1.1.2)
63
- gherkin (~> 2.9.0)
64
- json (>= 1.4.6)
65
- term-ansicolor (>= 1.0.6)
66
59
  cucumber-rails (1.3.0)
67
60
  capybara (>= 1.1.2)
68
61
  cucumber (>= 1.1.8)
69
62
  nokogiri (>= 1.5.0)
70
- database_cleaner (0.7.1)
63
+ database_cleaner (0.9.1)
71
64
  diff-lcs (1.1.3)
72
65
  erubis (2.7.0)
73
- ffi (1.0.11)
74
- gherkin (2.9.0)
66
+ ffi (1.1.5)
67
+ gherkin (2.11.5)
75
68
  json (>= 1.4.6)
76
69
  git (1.2.5)
77
70
  hike (1.2.1)
78
- i18n (0.6.0)
71
+ i18n (0.6.1)
79
72
  jeweler (1.6.4)
80
73
  bundler (~> 1.0)
81
74
  git (>= 1.2.5)
82
75
  rake
83
- json (1.6.6)
76
+ journey (1.0.4)
77
+ json (1.7.5)
78
+ libwebsocket (0.1.5)
79
+ addressable
84
80
  linecache19 (0.5.12)
85
81
  ruby_core_source (>= 0.1.4)
86
- mail (2.3.3)
82
+ mail (2.4.4)
87
83
  i18n (>= 0.4.0)
88
84
  mime-types (~> 1.16)
89
85
  treetop (~> 1.4.8)
90
- mime-types (1.18)
91
- multi_json (1.2.0)
92
- nokogiri (1.5.2)
86
+ mime-types (1.19)
87
+ multi_json (1.3.6)
88
+ nokogiri (1.5.5)
93
89
  polyglot (0.3.3)
94
- rack (1.3.6)
90
+ rack (1.4.1)
95
91
  rack-cache (1.2)
96
92
  rack (>= 0.4)
97
- rack-mount (0.8.3)
98
- rack (>= 1.0.0)
99
93
  rack-ssl (1.3.2)
100
94
  rack
101
- rack-test (0.6.1)
95
+ rack-test (0.6.2)
102
96
  rack (>= 1.0)
103
- rails (3.1.4)
104
- actionmailer (= 3.1.4)
105
- actionpack (= 3.1.4)
106
- activerecord (= 3.1.4)
107
- activeresource (= 3.1.4)
108
- activesupport (= 3.1.4)
97
+ rails (3.2.8)
98
+ actionmailer (= 3.2.8)
99
+ actionpack (= 3.2.8)
100
+ activerecord (= 3.2.8)
101
+ activeresource (= 3.2.8)
102
+ activesupport (= 3.2.8)
109
103
  bundler (~> 1.0)
110
- railties (= 3.1.4)
111
- railties (3.1.4)
112
- actionpack (= 3.1.4)
113
- activesupport (= 3.1.4)
104
+ railties (= 3.2.8)
105
+ railties (3.2.8)
106
+ actionpack (= 3.2.8)
107
+ activesupport (= 3.2.8)
114
108
  rack-ssl (~> 1.3.2)
115
109
  rake (>= 0.8.7)
116
110
  rdoc (~> 3.4)
117
- thor (~> 0.14.6)
111
+ thor (< 2.0, >= 0.14.6)
118
112
  rake (0.9.2.2)
119
113
  rcov (0.9.11)
120
114
  rdoc (3.12)
@@ -142,24 +136,23 @@ GEM
142
136
  ruby-debug-base19 (>= 0.11.19)
143
137
  ruby_core_source (0.1.5)
144
138
  archive-tar-minitar (>= 0.5.2)
145
- rubyzip (0.9.6.1)
146
- selenium-webdriver (2.20.0)
139
+ rubyzip (0.9.9)
140
+ selenium-webdriver (2.25.0)
147
141
  childprocess (>= 0.2.5)
148
- ffi (~> 1.0)
142
+ libwebsocket (~> 0.1.3)
149
143
  multi_json (~> 1.0)
150
144
  rubyzip
151
- sprockets (2.0.3)
145
+ sprockets (2.1.3)
152
146
  hike (~> 1.2)
153
147
  rack (~> 1.0)
154
148
  tilt (!= 1.3.0, ~> 1.1)
155
- sqlite3 (1.3.5)
156
- term-ansicolor (1.0.7)
157
- thor (0.14.6)
149
+ sqlite3 (1.3.6)
150
+ thor (0.16.0)
158
151
  tilt (1.3.3)
159
- treetop (1.4.10)
152
+ treetop (1.4.11)
160
153
  polyglot
161
154
  polyglot (>= 0.3.1)
162
- tzinfo (0.3.32)
155
+ tzinfo (0.3.33)
163
156
  xpath (0.1.4)
164
157
  nokogiri (~> 1.3)
165
158
  yard (0.6.8)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
@@ -26,7 +26,7 @@ module TrackableTasks
26
26
  # Restrict task runs by a time period of today, this week or all time
27
27
  #
28
28
  # @param String timeframe Which tasks to look for, 'all', 'week', or 'today'
29
- def self.by_timeframe(timeframe)
29
+ def self.by_timeframe(timeframe = "")
30
30
  if timeframe =='week'
31
31
  this_week
32
32
  elsif timeframe == 'all'
@@ -40,10 +40,7 @@ module TrackableTasks
40
40
  # @return Hash Percentage of tasks that succeeded today organized by task name
41
41
  def self.percentages_by_task_type(timeframe = "")
42
42
  task_runs = by_timeframe(timeframe)
43
- puts task_runs.inspect
44
-
45
43
  task_types = task_runs.collect { |tr| tr.task_type }.uniq
46
- puts task_types.inspect
47
44
 
48
45
  percentages = []
49
46
  task_types.each do |task_type|
@@ -2,31 +2,32 @@
2
2
 
3
3
  <div id='chart_container' style="width: 800px; height: 800px; background-color: gray; overflow:scroll; position: relative;" >
4
4
  <div id='chart' style="min-height: 10000px; position: absolute; top: 0; left: 0;" >
5
- <% unless task_runs.empty? %>
6
- <% task_runs.each do |task_run| %>
7
- <% run_time = task_run.run_time_or_time_elapsed.to_i > 200 ? task_run.run_time_or_time_elapsed.to_i : 200 %>
8
- <%= link_to trackable_tasks_task_run_path(task_run) do %>
9
- <div
10
- id="task_run_<%= task_run.id.to_s %>"
11
- class="task_run"
12
- data-id="<%= task_run.id.to_s %>"
13
- data-start_time="<%= task_run.start_time.to_i %>"
14
- data-run_time="<%= run_time %>"
15
- data-task_type="<%= task_run.task_type %>"
16
- style="
17
- position: absolute;
18
- min-height: 1px;
19
- height: <%= run_time / 10 %>px;
20
- width: 150px;
21
- padding: 0px 10px;
22
- margin: 10px;
23
- background-color: <%= task_run.status_color %>;
24
- color: black;" >
25
- <%= task_run.task_type %>
26
- </div>
5
+ <% unless task_runs.empty? %>
6
+ <% task_runs.each_with_index do |task_run, index| %>
7
+ <% run_time = task_run.run_time_or_time_elapsed.to_i > 8000 ? 8000 : task_run.run_time_or_time_elapsed.to_i %>
8
+ <% height = (Math.log(run_time+3)*20).to_int %>
9
+ <%= link_to trackable_tasks_task_run_path(task_run) do %>
10
+ <div
11
+ id="task_run_<%= task_run.id.to_s %>"
12
+ class="task_run"
13
+ data-id="<%= task_run.id.to_s %>"
14
+ data-start_time="<%= task_run.start_time.to_i %>"
15
+ data-run_time="<%= run_time %>"
16
+ data-task_type="<%= task_run.task_type %>"
17
+ style="
18
+ position: absolute;
19
+ min-height: 20px;
20
+ height: <%= height %>px;
21
+ width: 150px;
22
+ padding: 0px 10px;
23
+ margin: 10px;
24
+ background-color: <%= task_run.status_color %>;
25
+ color: black;" >
26
+ <%= task_run.task_type %> -index: <%= task_run.id %>
27
+ </div>
28
+ <% end %>
27
29
  <% end %>
28
30
  <% end %>
29
- <% end %>
30
31
  </div>
31
32
  </div>
32
33
 
@@ -58,6 +59,10 @@ function Bin() {
58
59
  this.has_room_for = function(task_run) {
59
60
  for(var i = 0; i < this.task_runs.length; i++) {
60
61
  if(this.overlap(this.task_runs[i], task_run)) {
62
+
63
+ var other_top = parseInt(this.task_runs[i].css('top'));
64
+ task_run.css('top', other_top + "px");
65
+
61
66
  return false;
62
67
  }
63
68
  }
@@ -74,9 +79,9 @@ function Bin() {
74
79
 
75
80
  //if a's runtime includes the beginning of b
76
81
  //if a's runtime includes the end of b
77
- if((a_start < b_start && a_end >= b_start) || (a_start < b_end && a_end >= b_end )) {
82
+ if((a_start <= b_start && a_end >= b_start) || (a_start <= b_end && a_end >= b_end )) {
78
83
  return true
79
- } else if((b_start < a_start && b_end >= a_start) || (b_start < a_end && b_end >= a_end )) {
84
+ } else if((b_start <= a_start && b_end >= a_start) || (b_start <= a_end && b_end >= a_end )) {
80
85
  return true
81
86
  } else {
82
87
  return false
@@ -114,21 +119,24 @@ function FirstFitPacker() {
114
119
  //make a new bin if nothing fits/base case
115
120
  var new_bin = new Bin()
116
121
  this.bins.push(new_bin)
122
+ new_bin.index = this.bins.length;
117
123
  return new_bin
118
124
  }
119
125
 
120
126
  this.first_bin_with_duplicate_task_type = function(task_run) {
121
127
  for(var i = 0; i < this.bins.length; i++) {
122
128
  if(this.bins[i].has_room_and_duplicate_type_for(task_run)) {
129
+ this.bins[i].index = i;
123
130
  return this.bins[i]
124
131
  }
125
132
  }
126
133
  return
127
134
  }
128
-
135
+
129
136
  this.first_bin_with_room = function(task_run) {
130
137
  for(var i = 0; i < this.bins.length; i++) {
131
138
  if(this.bins[i].has_room_for(task_run)) {
139
+ this.bins[i].index = i;
132
140
  return this.bins[i]
133
141
  }
134
142
  }
@@ -147,20 +155,74 @@ function ordered_task_runs() {
147
155
  }
148
156
 
149
157
  $(document).ready(function() {
158
+ var p = new FirstFitPacker();
159
+ var bin_ordering = p.pack(ordered_task_runs());
160
+ align_task_runs_by_bins(bin_ordering)
161
+
162
+ var prev_height = 0;
163
+ var prev_task;
150
164
  $('.task_run').each(function() {
151
165
  $(this).css('top', (now - $(this).attr("data-start_time")) / 10);
166
+
167
+ $(this).css('top', prev_height + "px");
168
+
169
+ if(typeof prev_task != 'undefined')
170
+ {
171
+ div_overlap(prev_task, $(this));
172
+ }
173
+
174
+ prev_height = 2 + parseInt($(this).css('top')) + parseInt($(this).css('height'));
175
+ prev_task = $(this);
176
+
152
177
  });
153
178
  });
154
179
 
180
+ function div_overlap(run_a, run_b) {
181
+ var a_start = parseInt(run_a.attr('data-start_time'))
182
+ var a_end = a_start + parseInt(run_a.attr('data-run_time'))
183
+ var b_start = parseInt(run_b.attr('data-start_time'))
184
+ var b_end = b_start + parseInt(run_b.attr('data-run_time'))
185
+ var a_runtime = a_end - a_start;
186
+ var b_runtime = b_end - b_start;
187
+
188
+ var top_to_change = parseInt(run_b.css('top'));
189
+ var diff;
190
+
191
+ if((a_start <= b_start && a_end >= b_end)) {
192
+ diff = Math.abs(b_start - a_end);
193
+ diff /= a_runtime;
194
+ diff *= parseInt(run_a.css('height'));
195
+ run_a.css('top', (top_to_change-diff) + "px" );
196
+
197
+ } else if((a_start >= b_start && a_end <= b_end)) {
198
+ diff = Math.abs(a_start - b_end);
199
+ diff /= b_runtime;
200
+ diff *= parseInt(run_b.css('height'));
201
+ run_b.css('top', (top_to_change-diff) + "px" );
202
+
203
+ } else if((a_start <= b_start && a_end >= b_start) || (b_start <= a_end && b_end >= a_end )) {
204
+ diff = Math.abs(a_end - b_start);
205
+ diff /= b_runtime;
206
+ diff *= parseInt(run_b.css('height'));
207
+ run_a.css('top', (top_to_change-diff) + "px" );
208
+
209
+ } else if((b_start <= a_start && b_end >= a_start) || (a_start <= b_end && a_end >= b_end )) {
210
+ diff = Math.abs(b_end - a_start);
211
+ diff /= a_runtime;
212
+ diff *= parseInt(run_a.css('height'));
213
+ run_b.css('top', (top_to_change-diff) + "px" );
214
+
215
+ } else {
216
+ return false
217
+ }
218
+ }
219
+
155
220
  function align_task_runs_by_bins(bins) {
156
221
  for(var i = 0; i < bins.length; i++) {
157
222
  for(var j = 0; j < bins[i].task_runs.length; j++) {
158
- bins[i].task_runs[j].css('left', 190 * i + "px");
223
+ bins[i].task_runs[j].css('left', ((190 * i) +30) + "px");
159
224
  }
160
225
  }
161
226
  }
162
227
 
163
- var p = new FirstFitPacker();
164
- var bin_ordering = p.pack(ordered_task_runs());
165
- align_task_runs_by_bins(bin_ordering)
166
228
  </script>
@@ -1,3 +1,4 @@
1
+ <!--
1
2
  <h1>Stats BETA</h1>
2
3
 
3
4
  <h2>Today's Stats</h2>
@@ -5,6 +6,6 @@
5
6
 
6
7
  <h2>This Week's Stats</h2>
7
8
  <%= render :partial => "percentages", :locals => {:task_stats => @week_percentages } %>
8
-
9
+ -->
9
10
  <h2>Chart</h2>
10
11
  <%= render :partial => "chart", :locals => { :task_runs => @task_runs } %>
@@ -1,3 +1,4 @@
1
+ # encoding: UTF-8
1
2
  # This file is auto-generated from the current state of the database. Instead
2
3
  # of editing this file, please use the migrations feature of Active Record to
3
4
  # incrementally modify your database, and then regenerate this schema definition.
@@ -0,0 +1,7 @@
1
+ class DebugTask < TrackableTasks::Base
2
+
3
+ # test of the tracking and logging systems
4
+ def run
5
+ log("Debug level log", :debug)
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ class ErrorTask < TrackableTasks::Base
2
+
3
+ # test of the tracking and logging systems
4
+ def run
5
+ log("Error level log", :error)
6
+ end
7
+ end
@@ -1,6 +1,8 @@
1
1
  class MyTask < TrackableTasks::Base
2
+
2
3
  # test of the tracking and logging systems
3
4
  def run
5
+ sleep(5+rand(120))
4
6
  log("Error level log", :error)
5
7
  log("Notice level log", :notice)
6
8
  log("Debug level log", :debug)
@@ -0,0 +1,7 @@
1
+ class NoticeTask < TrackableTasks::Base
2
+
3
+ # test of the tracking and logging systems
4
+ def run
5
+ log("Notice level log", :notice)
6
+ end
7
+ end
@@ -36,39 +36,12 @@ describe TaskRun do
36
36
  end
37
37
 
38
38
  it "end time should be after start time" do
39
+ @run.start_time = 5.minutes.ago
40
+ @run.end_time = 10.minutes.ago
41
+ @run.should have(1).error_on(:end_time)
39
42
  end
40
43
  end
41
44
 
42
- describe "add_log_text method" do
43
- before(:each) do
44
- @run = TaskRun.new()
45
- @text = "This trackable task is cool"
46
- end
47
-
48
- it "should take one parameter" do
49
- @run.method(:add_log_text).arity.should == 1
50
- end
51
-
52
- it "should add a newline after the input text" do
53
- @run.add_log_text(@text)
54
- @run.log_text.should == (@text + "\n")
55
- end
56
-
57
- it "should save the string to the log_text if it is empty" do
58
- @run.add_log_text(@text)
59
- @run.log_text.should match @text
60
- end
61
-
62
- it "should append the string to the text if it is not empty" do
63
- original_text = "first log text"
64
- @run.log_text = original_text
65
- @run.add_log_text(@text)
66
- @run.log_text.should match original_text
67
- @run.log_text.should match @text
68
- end
69
-
70
- end
71
-
72
45
  describe "today scope" do
73
46
  before(:each) do
74
47
  @today = TrackableTasks::TaskRun.create!(:task_type => "test task", :start_time => 5.hours.ago, :end_time => 3.hours.ago, :success => true)
@@ -114,6 +87,79 @@ describe TaskRun do
114
87
  end
115
88
  end
116
89
 
90
+ describe "by_timeframe class method" do
91
+ it "should call this_week if the timeframe is 'week'" do
92
+ TrackableTasks::TaskRun.should_receive(:this_week)
93
+ TrackableTasks::TaskRun.by_timeframe('week')
94
+ end
95
+
96
+ it "should call all if the timeframe is 'all'" do
97
+ TrackableTasks::TaskRun.should_receive(:all)
98
+ TrackableTasks::TaskRun.by_timeframe('all')
99
+ end
100
+
101
+ it "should call today if the timeframe is anything else" do
102
+ TrackableTasks::TaskRun.should_receive(:today)
103
+ TrackableTasks::TaskRun.by_timeframe('today')
104
+ end
105
+
106
+ it "should call today if the timeframe is anything else" do
107
+ TrackableTasks::TaskRun.should_receive(:today)
108
+ TrackableTasks::TaskRun.by_timeframe()
109
+ end
110
+ end
111
+
112
+ describe "percentages_by_task_type class method" do
113
+ before(:each) do
114
+ @run1 = TrackableTasks::TaskRun.create(:start_time => 5.minutes.ago, :end_time => 1.minute.ago, :task_type => "my_task", :success => true)
115
+ @run2 = TrackableTasks::TaskRun.create(:start_time => 5.minutes.ago, :end_time => 1.minute.ago, :task_type => "my_task", :success => false)
116
+ end
117
+
118
+ it "should call by_timeframe" do
119
+ TrackableTasks::TaskRun.should_receive(:by_timeframe).and_return([])
120
+ TrackableTasks::TaskRun.percentages_by_task_type
121
+ end
122
+
123
+ it "should return a hash of percentages" do
124
+ output = TrackableTasks::TaskRun.percentages_by_task_type
125
+ output.should == [{
126
+ :name => "my_task",
127
+ :runs => 2,
128
+ :percentage => 50
129
+ }]
130
+ end
131
+ end
132
+
133
+ describe "add_log_text method" do
134
+ before(:each) do
135
+ @run = TaskRun.new()
136
+ @text = "This trackable task is cool"
137
+ end
138
+
139
+ it "should take one parameter" do
140
+ @run.method(:add_log_text).arity.should == 1
141
+ end
142
+
143
+ it "should add a newline after the input text" do
144
+ @run.add_log_text(@text)
145
+ @run.log_text.should == (@text + "\n")
146
+ end
147
+
148
+ it "should save the string to the log_text if it is empty" do
149
+ @run.add_log_text(@text)
150
+ @run.log_text.should match @text
151
+ end
152
+
153
+ it "should append the string to the text if it is not empty" do
154
+ original_text = "first log text"
155
+ @run.log_text = original_text
156
+ @run.add_log_text(@text)
157
+ @run.log_text.should match original_text
158
+ @run.log_text.should match @text
159
+ end
160
+
161
+ end
162
+
117
163
  describe "add_error_text method" do
118
164
  before(:each) do
119
165
  @run = TaskRun.new()
@@ -143,28 +189,6 @@ describe TaskRun do
143
189
  end
144
190
  end
145
191
 
146
- describe "status_color method" do
147
- before(:each) do
148
- @run = TaskRun.new()
149
- end
150
-
151
- it "should return green if success is true and error_text is empty (nil)" do
152
- @run.success = true
153
- @run.error_text = nil
154
- @run.status_color.should == "green"
155
- end
156
-
157
- it "should return yellow if success is true but there is error_text" do
158
- @run.success = true
159
- @run.error_text = "Error text"
160
- @run.status_color.should == "yellow"
161
- end
162
-
163
- it "should return red if success is false" do
164
- @run.success = false
165
- @run.status_color.should == "red"
166
- end
167
- end
168
192
 
169
193
  describe "display_run_time method" do
170
194
  before(:each) do
@@ -189,4 +213,42 @@ describe TaskRun do
189
213
  end
190
214
  end
191
215
 
216
+ describe "run_time_or_time_elapsed method" do
217
+ before(:each) do
218
+ @run = TrackableTasks::TaskRun.new(:start_time => 5.minutes.ago, :end_time => 3.minutes.ago)
219
+ end
220
+
221
+ it "should return the runtime if end date is set" do
222
+ @run.run_time_or_time_elapsed.should == Time.at(@run.end_time - @run.start_time)
223
+ end
224
+
225
+ # this one has the potential to fail if ruby is running slowly or it is running in between seconds
226
+ it "should return the time elapsed between the start time and now if end date is not set" do
227
+ @run.end_time = nil
228
+ @run.run_time_or_time_elapsed.to_i.should == (Time.at(Time.now - @run.start_time).to_i)
229
+ end
230
+ end
231
+
232
+ describe "status_color method" do
233
+ before(:each) do
234
+ @run = TaskRun.new()
235
+ end
236
+
237
+ it "should return green if success is true and error_text is empty (nil)" do
238
+ @run.success = true
239
+ @run.error_text = nil
240
+ @run.status_color.should == "green"
241
+ end
242
+
243
+ it "should return yellow if success is true but there is error_text" do
244
+ @run.success = true
245
+ @run.error_text = "Error text"
246
+ @run.status_color.should == "yellow"
247
+ end
248
+
249
+ it "should return red if success is false" do
250
+ @run.success = false
251
+ @run.status_color.should == "red"
252
+ end
253
+ end
192
254
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "trackable_tasks"
8
- s.version = "0.1.0"
8
+ s.version = "0.1.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jeremiah Hemphill"]
12
- s.date = "2012-05-11"
12
+ s.date = "2012-10-15"
13
13
  s.description = "Adds tracking to rake tasks including error capturing and logging."
14
14
  s.email = "jeremiah@cloudspace.com"
15
15
  s.extra_rdoc_files = [
@@ -70,7 +70,10 @@ Gem::Specification.new do |s|
70
70
  "spec/dummy/features/support/paths.rb",
71
71
  "spec/dummy/features/support/selectors.rb",
72
72
  "spec/dummy/features/task_run.feature",
73
+ "spec/dummy/lib/trackable_tasks/debug_task.rb",
74
+ "spec/dummy/lib/trackable_tasks/error_task.rb",
73
75
  "spec/dummy/lib/trackable_tasks/my_task.rb",
76
+ "spec/dummy/lib/trackable_tasks/notice_task.rb",
74
77
  "spec/dummy/public/404.html",
75
78
  "spec/dummy/public/422.html",
76
79
  "spec/dummy/public/500.html",
@@ -206,6 +209,20 @@ Gem::Specification.new do |s|
206
209
  s.add_development_dependency(%q<jeweler>, ["~> 1.6.3"])
207
210
  s.add_development_dependency(%q<json>, [">= 0"])
208
211
  s.add_development_dependency(%q<ci_reporter>, [">= 0"])
212
+ s.add_development_dependency(%q<jeweler>, ["~> 1.6.3"])
213
+ s.add_development_dependency(%q<capybara>, [">= 0.4.0"])
214
+ s.add_development_dependency(%q<sqlite3>, [">= 0"])
215
+ s.add_development_dependency(%q<ruby-debug19>, [">= 0"])
216
+ s.add_development_dependency(%q<rspec>, ["~> 2.6.0"])
217
+ s.add_development_dependency(%q<rspec-rails>, ["~> 2.6.1"])
218
+ s.add_development_dependency(%q<yard>, ["~> 0.6.0"])
219
+ s.add_development_dependency(%q<cucumber>, [">= 0"])
220
+ s.add_development_dependency(%q<cucumber-rails>, [">= 0"])
221
+ s.add_development_dependency(%q<database_cleaner>, [">= 0"])
222
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
223
+ s.add_development_dependency(%q<jeweler>, ["~> 1.6.3"])
224
+ s.add_development_dependency(%q<json>, [">= 0"])
225
+ s.add_development_dependency(%q<ci_reporter>, [">= 0"])
209
226
  else
210
227
  s.add_dependency(%q<trackable_tasks>, [">= 0"])
211
228
  s.add_dependency(%q<rails>, [">= 3.0.7"])
@@ -311,6 +328,20 @@ Gem::Specification.new do |s|
311
328
  s.add_dependency(%q<jeweler>, ["~> 1.6.3"])
312
329
  s.add_dependency(%q<json>, [">= 0"])
313
330
  s.add_dependency(%q<ci_reporter>, [">= 0"])
331
+ s.add_dependency(%q<jeweler>, ["~> 1.6.3"])
332
+ s.add_dependency(%q<capybara>, [">= 0.4.0"])
333
+ s.add_dependency(%q<sqlite3>, [">= 0"])
334
+ s.add_dependency(%q<ruby-debug19>, [">= 0"])
335
+ s.add_dependency(%q<rspec>, ["~> 2.6.0"])
336
+ s.add_dependency(%q<rspec-rails>, ["~> 2.6.1"])
337
+ s.add_dependency(%q<yard>, ["~> 0.6.0"])
338
+ s.add_dependency(%q<cucumber>, [">= 0"])
339
+ s.add_dependency(%q<cucumber-rails>, [">= 0"])
340
+ s.add_dependency(%q<database_cleaner>, [">= 0"])
341
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
342
+ s.add_dependency(%q<jeweler>, ["~> 1.6.3"])
343
+ s.add_dependency(%q<json>, [">= 0"])
344
+ s.add_dependency(%q<ci_reporter>, [">= 0"])
314
345
  end
315
346
  else
316
347
  s.add_dependency(%q<trackable_tasks>, [">= 0"])
@@ -417,6 +448,20 @@ Gem::Specification.new do |s|
417
448
  s.add_dependency(%q<jeweler>, ["~> 1.6.3"])
418
449
  s.add_dependency(%q<json>, [">= 0"])
419
450
  s.add_dependency(%q<ci_reporter>, [">= 0"])
451
+ s.add_dependency(%q<jeweler>, ["~> 1.6.3"])
452
+ s.add_dependency(%q<capybara>, [">= 0.4.0"])
453
+ s.add_dependency(%q<sqlite3>, [">= 0"])
454
+ s.add_dependency(%q<ruby-debug19>, [">= 0"])
455
+ s.add_dependency(%q<rspec>, ["~> 2.6.0"])
456
+ s.add_dependency(%q<rspec-rails>, ["~> 2.6.1"])
457
+ s.add_dependency(%q<yard>, ["~> 0.6.0"])
458
+ s.add_dependency(%q<cucumber>, [">= 0"])
459
+ s.add_dependency(%q<cucumber-rails>, [">= 0"])
460
+ s.add_dependency(%q<database_cleaner>, [">= 0"])
461
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
462
+ s.add_dependency(%q<jeweler>, ["~> 1.6.3"])
463
+ s.add_dependency(%q<json>, [">= 0"])
464
+ s.add_dependency(%q<ci_reporter>, [">= 0"])
420
465
  end
421
466
  end
422
467
 
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: trackable_tasks
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.0
5
+ version: 0.1.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Jeremiah Hemphill
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2012-05-11 00:00:00 Z
13
+ date: 2012-10-15 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: trackable_tasks
@@ -1156,6 +1156,160 @@ dependencies:
1156
1156
  type: :development
1157
1157
  prerelease: false
1158
1158
  version_requirements: *id104
1159
+ - !ruby/object:Gem::Dependency
1160
+ name: jeweler
1161
+ requirement: &id105 !ruby/object:Gem::Requirement
1162
+ none: false
1163
+ requirements:
1164
+ - - ~>
1165
+ - !ruby/object:Gem::Version
1166
+ version: 1.6.3
1167
+ type: :development
1168
+ prerelease: false
1169
+ version_requirements: *id105
1170
+ - !ruby/object:Gem::Dependency
1171
+ name: capybara
1172
+ requirement: &id106 !ruby/object:Gem::Requirement
1173
+ none: false
1174
+ requirements:
1175
+ - - ">="
1176
+ - !ruby/object:Gem::Version
1177
+ version: 0.4.0
1178
+ type: :development
1179
+ prerelease: false
1180
+ version_requirements: *id106
1181
+ - !ruby/object:Gem::Dependency
1182
+ name: sqlite3
1183
+ requirement: &id107 !ruby/object:Gem::Requirement
1184
+ none: false
1185
+ requirements:
1186
+ - - ">="
1187
+ - !ruby/object:Gem::Version
1188
+ version: "0"
1189
+ type: :development
1190
+ prerelease: false
1191
+ version_requirements: *id107
1192
+ - !ruby/object:Gem::Dependency
1193
+ name: ruby-debug19
1194
+ requirement: &id108 !ruby/object:Gem::Requirement
1195
+ none: false
1196
+ requirements:
1197
+ - - ">="
1198
+ - !ruby/object:Gem::Version
1199
+ version: "0"
1200
+ type: :development
1201
+ prerelease: false
1202
+ version_requirements: *id108
1203
+ - !ruby/object:Gem::Dependency
1204
+ name: rspec
1205
+ requirement: &id109 !ruby/object:Gem::Requirement
1206
+ none: false
1207
+ requirements:
1208
+ - - ~>
1209
+ - !ruby/object:Gem::Version
1210
+ version: 2.6.0
1211
+ type: :development
1212
+ prerelease: false
1213
+ version_requirements: *id109
1214
+ - !ruby/object:Gem::Dependency
1215
+ name: rspec-rails
1216
+ requirement: &id110 !ruby/object:Gem::Requirement
1217
+ none: false
1218
+ requirements:
1219
+ - - ~>
1220
+ - !ruby/object:Gem::Version
1221
+ version: 2.6.1
1222
+ type: :development
1223
+ prerelease: false
1224
+ version_requirements: *id110
1225
+ - !ruby/object:Gem::Dependency
1226
+ name: yard
1227
+ requirement: &id111 !ruby/object:Gem::Requirement
1228
+ none: false
1229
+ requirements:
1230
+ - - ~>
1231
+ - !ruby/object:Gem::Version
1232
+ version: 0.6.0
1233
+ type: :development
1234
+ prerelease: false
1235
+ version_requirements: *id111
1236
+ - !ruby/object:Gem::Dependency
1237
+ name: cucumber
1238
+ requirement: &id112 !ruby/object:Gem::Requirement
1239
+ none: false
1240
+ requirements:
1241
+ - - ">="
1242
+ - !ruby/object:Gem::Version
1243
+ version: "0"
1244
+ type: :development
1245
+ prerelease: false
1246
+ version_requirements: *id112
1247
+ - !ruby/object:Gem::Dependency
1248
+ name: cucumber-rails
1249
+ requirement: &id113 !ruby/object:Gem::Requirement
1250
+ none: false
1251
+ requirements:
1252
+ - - ">="
1253
+ - !ruby/object:Gem::Version
1254
+ version: "0"
1255
+ type: :development
1256
+ prerelease: false
1257
+ version_requirements: *id113
1258
+ - !ruby/object:Gem::Dependency
1259
+ name: database_cleaner
1260
+ requirement: &id114 !ruby/object:Gem::Requirement
1261
+ none: false
1262
+ requirements:
1263
+ - - ">="
1264
+ - !ruby/object:Gem::Version
1265
+ version: "0"
1266
+ type: :development
1267
+ prerelease: false
1268
+ version_requirements: *id114
1269
+ - !ruby/object:Gem::Dependency
1270
+ name: bundler
1271
+ requirement: &id115 !ruby/object:Gem::Requirement
1272
+ none: false
1273
+ requirements:
1274
+ - - ~>
1275
+ - !ruby/object:Gem::Version
1276
+ version: 1.0.0
1277
+ type: :development
1278
+ prerelease: false
1279
+ version_requirements: *id115
1280
+ - !ruby/object:Gem::Dependency
1281
+ name: jeweler
1282
+ requirement: &id116 !ruby/object:Gem::Requirement
1283
+ none: false
1284
+ requirements:
1285
+ - - ~>
1286
+ - !ruby/object:Gem::Version
1287
+ version: 1.6.3
1288
+ type: :development
1289
+ prerelease: false
1290
+ version_requirements: *id116
1291
+ - !ruby/object:Gem::Dependency
1292
+ name: json
1293
+ requirement: &id117 !ruby/object:Gem::Requirement
1294
+ none: false
1295
+ requirements:
1296
+ - - ">="
1297
+ - !ruby/object:Gem::Version
1298
+ version: "0"
1299
+ type: :development
1300
+ prerelease: false
1301
+ version_requirements: *id117
1302
+ - !ruby/object:Gem::Dependency
1303
+ name: ci_reporter
1304
+ requirement: &id118 !ruby/object:Gem::Requirement
1305
+ none: false
1306
+ requirements:
1307
+ - - ">="
1308
+ - !ruby/object:Gem::Version
1309
+ version: "0"
1310
+ type: :development
1311
+ prerelease: false
1312
+ version_requirements: *id118
1159
1313
  description: Adds tracking to rake tasks including error capturing and logging.
1160
1314
  email: jeremiah@cloudspace.com
1161
1315
  executables: []
@@ -1219,7 +1373,10 @@ files:
1219
1373
  - spec/dummy/features/support/paths.rb
1220
1374
  - spec/dummy/features/support/selectors.rb
1221
1375
  - spec/dummy/features/task_run.feature
1376
+ - spec/dummy/lib/trackable_tasks/debug_task.rb
1377
+ - spec/dummy/lib/trackable_tasks/error_task.rb
1222
1378
  - spec/dummy/lib/trackable_tasks/my_task.rb
1379
+ - spec/dummy/lib/trackable_tasks/notice_task.rb
1223
1380
  - spec/dummy/public/404.html
1224
1381
  - spec/dummy/public/422.html
1225
1382
  - spec/dummy/public/500.html
@@ -1253,7 +1410,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
1253
1410
  requirements:
1254
1411
  - - ">="
1255
1412
  - !ruby/object:Gem::Version
1256
- hash: -2307237475125108397
1413
+ hash: 3508837051035824591
1257
1414
  segments:
1258
1415
  - 0
1259
1416
  version: "0"