trackable_tasks 0.0.13 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,5 +1,9 @@
1
1
  == unreleased changes
2
2
 
3
+ * Added an optional finally method to the TrackableTask::Base
4
+ * Moved the rake task to a railtie
5
+ * Added a basic stats system
6
+
3
7
  == 0.0.13
4
8
 
5
9
  * Updated the index and show views to give better formatted error messages
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- trackable_tasks (0.0.12)
4
+ trackable_tasks (0.0.13)
5
5
  rails (>= 3.0.7)
6
6
  trackable_tasks
7
7
 
data/README.rdoc CHANGED
@@ -13,7 +13,7 @@ Run the install generator and migrate.
13
13
  rails generate trackable_tasks:install
14
14
  rake db:migrate
15
15
 
16
- The generator also adds lib/tasks/trackable_tasks.rake. There should be a new rake task called trackable_task:run.
16
+ There should be a new rake task called trackable_task:run.
17
17
 
18
18
  = How to use
19
19
 
@@ -21,14 +21,18 @@ Create a trackable task. Override the run method and put the code that needs to
21
21
 
22
22
  class MyTask < AbstractTrackableTask
23
23
  def run
24
- log "hello"
24
+ log "code with error catching and recovery"
25
25
  end
26
+
27
+ def finally
28
+ log "optional code that is called after run finishes"
29
+ end
26
30
  end
27
31
 
28
- This creates a new dynamic rake task. Run the trackable task using either rake task. The RAISL_ENV can also be specified here.
32
+ This creates a new dynamic rake task. Run the trackable task using either rake task. The RAILS_ENV can also be specified here.
29
33
 
30
34
  rake trackable_task:my_task
31
- rake trackable_task:run task_num=my_task
35
+ rake trackable_task:run task_name=my_task
32
36
 
33
37
  The results can be found by looking in:
34
38
 
@@ -41,7 +45,7 @@ The log_text and error_text methods store logging and error information. If an
41
45
  Log levels can be set when running with a rake task
42
46
 
43
47
  rake trackable_task:my_task log_level=notice
44
- rake trackable_task:run task_num=my_task log_level=error
48
+ rake trackable_task:run task_name=my_task log_level=error
45
49
 
46
50
  Setting the log level here determines the highest level of logs that will be saved by the task. The three log levels are 'error', 'notice', and 'debug'.
47
51
 
@@ -57,10 +61,6 @@ Inside the script, the log function is used to store data to the task_run logs.
57
61
 
58
62
  The error level logs write to task_run.log_text. Notice and debug level logs write to task_run.log_text.
59
63
 
60
- == Future Work
61
-
62
- * Adding a basic controller and views to show the trackable task runs.
63
-
64
64
  == Contributing to trackable_tasks
65
65
 
66
66
  * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.13
1
+ 0.1.0
@@ -4,13 +4,7 @@ class TrackableTasks::TaskRunsController < ApplicationController
4
4
  # Lists all tasks in task run
5
5
  # Defaults to show today's tasks but can also show by week or all time
6
6
  def index
7
- if params[:timeframe] =='week'
8
- @task_runs = TrackableTasks::TaskRun.newest_first.this_week
9
- elsif params[:timeframe] == 'all'
10
- @task_runs = TrackableTasks::TaskRun.newest_first
11
- else
12
- @task_runs = TrackableTasks::TaskRun.newest_first.today
13
- end
7
+ @task_runs = TrackableTasks::TaskRun.newest_first.by_timeframe(params[:timeframe])
14
8
 
15
9
  # Paginate with kaminari if it is installed
16
10
  begin
@@ -24,6 +18,12 @@ class TrackableTasks::TaskRunsController < ApplicationController
24
18
  format.html # index.html.erb
25
19
  end
26
20
  end
21
+
22
+ def stats
23
+ @task_runs = TrackableTasks::TaskRun.newest_first.today
24
+ @today_percentages = TrackableTasks::TaskRun.percentages_by_task_type("today")
25
+ @week_percentages = TrackableTasks::TaskRun.percentages_by_task_type("week")
26
+ end
27
27
 
28
28
  # Lists specific task run
29
29
  def show
@@ -4,6 +4,8 @@ module TrackableTasks
4
4
  class TaskRun < ActiveRecord::Base
5
5
  set_table_name "trackable_tasks_task_runs"
6
6
 
7
+ attr_accessible :start_time, :end_time, :task_type, :success
8
+
7
9
  validates_presence_of :start_time, :task_type
8
10
  validates_inclusion_of :success, :in => [true, false]
9
11
  validate :end_time_after_start_time
@@ -21,6 +23,40 @@ module TrackableTasks
21
23
  # this may have some odd effects on things that are 7 days but less than 7 * 24 hours old
22
24
  scope :this_week, lambda { where(["trackable_tasks_task_runs.start_time >= ?", 7.days.ago]) }
23
25
 
26
+ # Restrict task runs by a time period of today, this week or all time
27
+ #
28
+ # @param String timeframe Which tasks to look for, 'all', 'week', or 'today'
29
+ def self.by_timeframe(timeframe)
30
+ if timeframe =='week'
31
+ this_week
32
+ elsif timeframe == 'all'
33
+ all
34
+ else
35
+ today
36
+ end
37
+ end
38
+
39
+ # @param time_period String Whether to search for today's tasks or this week's tasks
40
+ # @return Hash Percentage of tasks that succeeded today organized by task name
41
+ def self.percentages_by_task_type(timeframe = "")
42
+ task_runs = by_timeframe(timeframe)
43
+ puts task_runs.inspect
44
+
45
+ task_types = task_runs.collect { |tr| tr.task_type }.uniq
46
+ puts task_types.inspect
47
+
48
+ percentages = []
49
+ task_types.each do |task_type|
50
+ runs = task_runs.where(:task_type => task_type).count
51
+ percentages << {
52
+ :name => task_type,
53
+ :runs => runs,
54
+ :percentage => 100 * task_runs.where(:task_type => task_type, :success => true).count / runs,
55
+ }
56
+ end
57
+ return percentages.sort { |p| p[:percentage] }
58
+ end
59
+
24
60
  # Appends the input text onto the log text
25
61
  #
26
62
  # I am aware that these two methods are duplicates nd we could merge them
@@ -45,13 +81,24 @@ module TrackableTasks
45
81
  # If there is no end_time, display 'Run has not completed.'
46
82
  # @return [String] The run time formatted in hours, minutes and seconds
47
83
  # @return [String] Message that run has not completed
48
- def run_time
84
+ def display_run_time
49
85
  if self.end_time
50
- return Time.at(self.end_time - self.start_time).gmtime.strftime('%R:%S')
86
+ return run_time_or_time_elapsed.gmtime.strftime('%R:%S')
51
87
  else
52
88
  return "Run has not completed."
53
89
  end
54
90
  end
91
+
92
+ # Creates run time based on start and end time
93
+ # If there is no end_time, returns time between start and now
94
+ # @return [Time] The run time object
95
+ def run_time_or_time_elapsed
96
+ if self.end_time
97
+ return Time.at(self.end_time - self.start_time)
98
+ else
99
+ return Time.at(Time.now - self.start_time)
100
+ end
101
+ end
55
102
 
56
103
  # Determines error message color based on success and whether or not there is error text
57
104
  # Return value corresponds to a css color
@@ -0,0 +1,166 @@
1
+ <%= javascript_include_tag "http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js" %>
2
+
3
+ <div id='chart_container' style="width: 800px; height: 800px; background-color: gray; overflow:scroll; position: relative;" >
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>
27
+ <% end %>
28
+ <% end %>
29
+ <% end %>
30
+ </div>
31
+ </div>
32
+
33
+ <script>
34
+ var now = <%= Time.now.to_i %>
35
+
36
+ function Bin() {
37
+ this.task_runs = []
38
+
39
+ this.add_task_run = function(task_run) {
40
+ this.task_runs.push(task_run);
41
+ }
42
+
43
+ this.has_room_and_duplicate_type_for = function(task_run) {
44
+ this.has_duplicate_type_for(task_run) && this.has_room_for(task_run)
45
+ }
46
+
47
+ //returns true if at least one of the existing task types matches the given one
48
+ this.has_duplicate_type_for = function(task_run) {
49
+ task_type = task_run.attr('data-task_type');
50
+ for(var i = 0; i < this.task_runs.length; i++) {
51
+ if(this.task_runs[i].attr('data-task_type') == task_type) {
52
+ return true;
53
+ }
54
+ }
55
+ return false;
56
+ }
57
+
58
+ this.has_room_for = function(task_run) {
59
+ for(var i = 0; i < this.task_runs.length; i++) {
60
+ if(this.overlap(this.task_runs[i], task_run)) {
61
+ return false;
62
+ }
63
+ }
64
+ return true;
65
+ }
66
+
67
+ //returns true if b overlaps a
68
+ //checks if the beginning or end of b is contained within a
69
+ this.overlap = function(run_a, run_b) {
70
+ var a_start = parseInt(run_a.attr('data-start_time'))
71
+ var a_end = a_start + parseInt(run_a.attr('data-run_time'))
72
+ var b_start = parseInt(run_b.attr('data-start_time'))
73
+ var b_end = b_start + parseInt(run_b.attr('data-run_time'))
74
+
75
+ //if a's runtime includes the beginning of b
76
+ //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 )) {
78
+ return true
79
+ } else if((b_start < a_start && b_end >= a_start) || (b_start < a_end && b_end >= a_end )) {
80
+ return true
81
+ } else {
82
+ return false
83
+ }
84
+ }
85
+ }
86
+
87
+ function FirstFitPacker() {
88
+ this.bins = []
89
+
90
+ this.pack = function(task_runs) {
91
+ for(var i = 0; i < task_runs.length; i++) {
92
+ var task_run = $(task_runs[i])
93
+ var bin = this.first_fit_bin_pack(task_run);
94
+ bin.add_task_run($(task_run));
95
+ }
96
+ return this.bins
97
+ }
98
+
99
+ this.first_fit_bin_pack = function(task_run) {
100
+ var bin;
101
+
102
+ //first try a bin that already contains this task type
103
+ bin = this.first_bin_with_duplicate_task_type(task_run);
104
+ if(bin !== undefined) {
105
+ return bin
106
+ }
107
+
108
+ //then try any bin
109
+ bin = this.first_bin_with_room(task_run)
110
+ if(bin !== undefined) {
111
+ return bin
112
+ }
113
+
114
+ //make a new bin if nothing fits/base case
115
+ var new_bin = new Bin()
116
+ this.bins.push(new_bin)
117
+ return new_bin
118
+ }
119
+
120
+ this.first_bin_with_duplicate_task_type = function(task_run) {
121
+ for(var i = 0; i < this.bins.length; i++) {
122
+ if(this.bins[i].has_room_and_duplicate_type_for(task_run)) {
123
+ return this.bins[i]
124
+ }
125
+ }
126
+ return
127
+ }
128
+
129
+ this.first_bin_with_room = function(task_run) {
130
+ for(var i = 0; i < this.bins.length; i++) {
131
+ if(this.bins[i].has_room_for(task_run)) {
132
+ return this.bins[i]
133
+ }
134
+ }
135
+ return
136
+ }
137
+ }
138
+
139
+ //returns an array of task runs, longest run time first
140
+ function ordered_task_runs() {
141
+ return $('.task_run').sort(function(a, b) {
142
+ ar = $(a).attr('data-run_time');
143
+ br = $(b).attr('data-run_time');
144
+
145
+ return (ar < br) ? -1 : (ar > br) ? 1 : 0;
146
+ });
147
+ }
148
+
149
+ $(document).ready(function() {
150
+ $('.task_run').each(function() {
151
+ $(this).css('top', (now - $(this).attr("data-start_time")) / 10);
152
+ });
153
+ });
154
+
155
+ function align_task_runs_by_bins(bins) {
156
+ for(var i = 0; i < bins.length; i++) {
157
+ for(var j = 0; j < bins[i].task_runs.length; j++) {
158
+ bins[i].task_runs[j].css('left', 190 * i + "px");
159
+ }
160
+ }
161
+ }
162
+
163
+ var p = new FirstFitPacker();
164
+ var bin_ordering = p.pack(ordered_task_runs());
165
+ align_task_runs_by_bins(bin_ordering)
166
+ </script>
@@ -0,0 +1,22 @@
1
+ <div class="percentages">
2
+ <table>
3
+ <tr>
4
+ <th>Task</th>
5
+ <th>Runs</th>
6
+ <th>Success %</th>
7
+ </tr>
8
+ <% unless task_stats.empty? %>
9
+ <% task_stats.each do |stat| %>
10
+ <tr>
11
+ <td><%= stat[:name] %></td>
12
+ <td><%= stat[:runs] %></td>
13
+ <td><%= stat[:percentage] %>%</td>
14
+ </tr>
15
+ <% end %>
16
+ <% else %>
17
+ <tr>
18
+ <td>There are no records for this time period.</td>
19
+ </tr>
20
+ <% end %>
21
+ </table>
22
+ </div>
@@ -21,7 +21,7 @@
21
21
  <tr>
22
22
  <td> <%= task_run.task_type %> </td>
23
23
  <td> <%= task_run.start_time.strftime('%D %r') %> </td>
24
- <td> <%= task_run.run_time %>
24
+ <td> <%= task_run.display_run_time %>
25
25
  <td> <span style="color: <%= task_run.status_color %>"><%= task_run.success %> </span></td>
26
26
  <td> <%= link_to 'Show', task_run %> </td>
27
27
  </tr>
@@ -2,7 +2,7 @@
2
2
 
3
3
  <p><strong>Start time: </strong> <%= @task_run.start_time.strftime('%D %r') %> </p>
4
4
  <p><strong>End time: </strong> <%= @task_run.end_time.strftime('%D %r') if @task_run.end_time %> </p>
5
- <p><strong>Run time: </strong> <%= @task_run.run_time %> </p>
5
+ <p><strong>Run time: </strong> <%= @task_run.display_run_time %> </p>
6
6
  <p><strong>Success: </strong> <span style="color: <%= @task_run.status_color %>"> <%= @task_run.success %> </span></p>
7
7
  <p>
8
8
  <strong>Error text: </strong>
@@ -0,0 +1,10 @@
1
+ <h1>Stats BETA</h1>
2
+
3
+ <h2>Today's Stats</h2>
4
+ <%= render :partial => "percentages", :locals => {:task_stats => @today_percentages } %>
5
+
6
+ <h2>This Week's Stats</h2>
7
+ <%= render :partial => "percentages", :locals => {:task_stats => @week_percentages } %>
8
+
9
+ <h2>Chart</h2>
10
+ <%= render :partial => "chart", :locals => { :task_runs => @task_runs } %>
data/config/routes.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  Rails.application.routes.draw do
2
2
  namespace :trackable_tasks do
3
3
  resources :task_runs
4
+ root :to => "task_runs#stats", :as => :root
4
5
  end
5
- end
6
+ end
@@ -28,11 +28,6 @@ DESC
28
28
  end
29
29
  end
30
30
 
31
- # Creates the rake file
32
- def copy_rake_file
33
- copy_file "trackable_tasks.rake", "lib/tasks/trackable_tasks.rake"
34
- end
35
-
36
31
  # Creates the migration
37
32
  def copy_migration
38
33
  migration_template "migrations/install_migration.rb.erb", "db/migrate/create_trackable_task_tables.rb"
@@ -47,6 +47,9 @@ module TrackableTasks
47
47
  # this calls task with error catching
48
48
  # if an error is caught, sets success to false and records the error
49
49
  # either way, sets an end time and saves the task run information
50
+ #
51
+ # After the run completes, whether or not the run succeeds, run finally
52
+ # If finally has an error, don't catch it
50
53
  def run_task
51
54
  begin
52
55
  run
@@ -55,6 +58,9 @@ module TrackableTasks
55
58
  @task_run.add_error_text(e.backtrace.inspect)
56
59
  @task_run.success = false
57
60
  end
61
+
62
+ finally
63
+
58
64
  @task_run.end_time = Time.now
59
65
  @task_run.save
60
66
  end
@@ -65,6 +71,13 @@ module TrackableTasks
65
71
  raise NotImplementedError.new("The run method must be overridden")
66
72
  end
67
73
 
74
+ # The finally method can be optionally overridden for code that must run after run is completed
75
+ # This could be for things like temp file cleanup
76
+ #
77
+ # Note that errors are not caught and logged here
78
+ def finally
79
+ end
80
+
68
81
  # Adds test to the log for the task run
69
82
  # Depending on the @log_level, save or don't save the text
70
83
  # If the level is :error, save to the error log
@@ -1,11 +1,11 @@
1
1
  require 'rails'
2
-
3
2
  require 'trackable_tasks/config'
3
+ require 'rake'
4
4
 
5
5
  module TrackableTasks
6
6
  class Railtie < ::Rails::Railtie
7
- initializer 'trackable_tasks' do |app|
8
- # add mixins here
7
+ rake_tasks do
8
+ load File.expand_path('../tasks/trackable_tasks.rake', __FILE__)
9
9
  end
10
10
  end
11
11
  end
@@ -34,7 +34,6 @@ namespace :trackable_task do
34
34
  # @param [String] The name of the task class
35
35
  # @param [String] The log level for the task
36
36
  def run_trackable_task(task_name, log_level)
37
- #puts "I am running #{task_name} at log level #{log_level}"
38
37
  require "#{::Rails.root.to_s}/lib/trackable_tasks/#{task_name}.rb"
39
38
  # if the class exists
40
39
  trackable_task = task_name.camelize.constantize.new(log_level)
@@ -2,4 +2,4 @@
2
2
  require File.join(%w{trackable_tasks base})
3
3
 
4
4
  require "trackable_tasks/engine"
5
- #require "trackable_tasks/railtie"
5
+ require "trackable_tasks/railtie"
@@ -0,0 +1,7 @@
1
+ Feature: task_run controller stats page
2
+
3
+ Scenario: Seeing daily stats
4
+
5
+ Scenario: Seeing weekly stats
6
+
7
+ Scenario: The chart
@@ -8,7 +8,7 @@ Then (/^I should see "([^"]*)" $/) do |no_reconds|
8
8
  end
9
9
 
10
10
  Given /^a task_run exists$/ do
11
- TrackableTasks::TaskRun.create(:start_time => Time.now, :task_type => 'Test Task', :success => true)
11
+ TrackableTasks::TaskRun.create!(:start_time => Time.now, :task_type => 'Test Task', :success => true)
12
12
  end
13
13
 
14
14
  Given /^a task_run exists with the following values$/ do |table|
@@ -18,8 +18,7 @@ Given /^a task_run exists with the following values$/ do |table|
18
18
  attributes[key_pair["key"]] = key_pair["value"]
19
19
  end
20
20
  end
21
- TrackableTasks::TaskRun.create(attributes)
22
- TrackableTasks::TaskRun.all.count.should > 0
21
+ TrackableTasks::TaskRun.create!(attributes)
23
22
  end
24
23
 
25
24
  Given /^end_time does not exist$/ do
@@ -23,6 +23,7 @@ Feature: task_run controller index and show pages
23
23
  | task_type | Task type 3 |
24
24
  | success | true |
25
25
  When I go to the task_run index page
26
+ And I follow "All Time"
26
27
  Then status_color should be green
27
28
 
28
29
  Scenario: should show task run on the show page
@@ -166,20 +166,26 @@ describe TaskRun do
166
166
  end
167
167
  end
168
168
 
169
- describe "run_time method" do
169
+ describe "display_run_time method" do
170
170
  before(:each) do
171
171
  @run = TaskRun.new()
172
172
  end
173
+
174
+ it "should call run_time_or_time_elapsed" do
175
+ @run.should_receive(:run_time_or_time_elapsed).and_return(Time.now)
176
+ @run.end_time = Time.now
177
+ @run.display_run_time
178
+ end
173
179
 
174
180
  it "should return the time formatted in hours, minutes and seconds if end_time is true" do
175
181
  @run.start_time = Time.at(3)
176
182
  @run.end_time = Time.at(946702800)
177
- @run.run_time.should == Time.at(@run.end_time - @run.start_time).gmtime.strftime('%R:%S')
183
+ @run.display_run_time.should == Time.at(@run.end_time - @run.start_time).gmtime.strftime('%R:%S')
178
184
  end
179
185
 
180
186
  it "should return a string 'Run has not completed' if end_time is false" do
181
187
  @run.end_time = false
182
- @run.run_time.should == "Run has not completed."
188
+ @run.display_run_time.should == "Run has not completed."
183
189
  end
184
190
  end
185
191
 
@@ -7,7 +7,7 @@ describe "trackable_task rake tasks" do
7
7
  before(:each) do
8
8
  @rake = Rake::Application.new
9
9
  Rake.application = @rake
10
- Rake.application.rake_require "dummy/lib/tasks/trackable_tasks"
10
+ Rake.application.rake_require "../../lib/trackable_tasks/tasks/trackable_tasks"
11
11
  Rake::Task.define_task(:environment)
12
12
  end
13
13
 
@@ -84,6 +84,17 @@ describe TrackableTasks::Base do
84
84
  @task_run = TrackableTasks::TaskRun.last
85
85
  @task_run.success.should be_false
86
86
  end
87
+
88
+ it "should call finally after run" do
89
+ @mt.should_receive(:finally)
90
+ @mt.run_task
91
+ end
92
+
93
+ it "should call finally even in run errors" do
94
+ @erroring_task = ErroringTask.new
95
+ @erroring_task.should_receive(:finally)
96
+ @erroring_task.run_task
97
+ end
87
98
  end
88
99
 
89
100
  describe "run method" do
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "trackable_tasks"
8
- s.version = "0.0.13"
8
+ s.version = "0.1.0"
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-04-25"
12
+ s.date = "2012-05-11"
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 = [
@@ -28,17 +28,20 @@ Gem::Specification.new do |s|
28
28
  "VERSION",
29
29
  "app/controllers/trackable_tasks/task_runs_controller.rb",
30
30
  "app/models/trackable_tasks/task_run.rb",
31
+ "app/views/trackable_tasks/task_runs/_chart.html.erb",
32
+ "app/views/trackable_tasks/task_runs/_percentages.html.erb",
31
33
  "app/views/trackable_tasks/task_runs/index.html.erb",
32
34
  "app/views/trackable_tasks/task_runs/show.html.erb",
35
+ "app/views/trackable_tasks/task_runs/stats.html.erb",
33
36
  "config/routes.rb",
34
37
  "lib/generators/trackable_tasks/install_generator.rb",
35
38
  "lib/generators/trackable_tasks/templates/migrations/install_migration.rb.erb",
36
- "lib/generators/trackable_tasks/templates/trackable_tasks.rake",
37
39
  "lib/trackable_tasks.rb",
38
40
  "lib/trackable_tasks/base.rb",
39
41
  "lib/trackable_tasks/config.rb",
40
42
  "lib/trackable_tasks/engine.rb",
41
43
  "lib/trackable_tasks/railtie.rb",
44
+ "lib/trackable_tasks/tasks/trackable_tasks.rake",
42
45
  "spec/dummy/Rakefile",
43
46
  "spec/dummy/app/controllers/application_controller.rb",
44
47
  "spec/dummy/app/helpers/application_helper.rb",
@@ -60,13 +63,13 @@ Gem::Specification.new do |s|
60
63
  "spec/dummy/config/routes.rb",
61
64
  "spec/dummy/db/migrate/20110826183240_create_trackable_task_tables.rb",
62
65
  "spec/dummy/db/schema.rb",
66
+ "spec/dummy/features/stats.feature",
63
67
  "spec/dummy/features/step_definitions/trackable_tasks_steps.rb",
64
68
  "spec/dummy/features/step_definitions/web_steps.rb",
65
69
  "spec/dummy/features/support/env.rb",
66
70
  "spec/dummy/features/support/paths.rb",
67
71
  "spec/dummy/features/support/selectors.rb",
68
72
  "spec/dummy/features/task_run.feature",
69
- "spec/dummy/lib/tasks/trackable_tasks.rake",
70
73
  "spec/dummy/lib/trackable_tasks/my_task.rb",
71
74
  "spec/dummy/public/404.html",
72
75
  "spec/dummy/public/422.html",
@@ -175,6 +178,34 @@ Gem::Specification.new do |s|
175
178
  s.add_development_dependency(%q<jeweler>, ["~> 1.6.3"])
176
179
  s.add_development_dependency(%q<json>, [">= 0"])
177
180
  s.add_development_dependency(%q<ci_reporter>, [">= 0"])
181
+ s.add_development_dependency(%q<jeweler>, ["~> 1.6.3"])
182
+ s.add_development_dependency(%q<capybara>, [">= 0.4.0"])
183
+ s.add_development_dependency(%q<sqlite3>, [">= 0"])
184
+ s.add_development_dependency(%q<ruby-debug19>, [">= 0"])
185
+ s.add_development_dependency(%q<rspec>, ["~> 2.6.0"])
186
+ s.add_development_dependency(%q<rspec-rails>, ["~> 2.6.1"])
187
+ s.add_development_dependency(%q<yard>, ["~> 0.6.0"])
188
+ s.add_development_dependency(%q<cucumber>, [">= 0"])
189
+ s.add_development_dependency(%q<cucumber-rails>, [">= 0"])
190
+ s.add_development_dependency(%q<database_cleaner>, [">= 0"])
191
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
192
+ s.add_development_dependency(%q<jeweler>, ["~> 1.6.3"])
193
+ s.add_development_dependency(%q<json>, [">= 0"])
194
+ s.add_development_dependency(%q<ci_reporter>, [">= 0"])
195
+ s.add_development_dependency(%q<jeweler>, ["~> 1.6.3"])
196
+ s.add_development_dependency(%q<capybara>, [">= 0.4.0"])
197
+ s.add_development_dependency(%q<sqlite3>, [">= 0"])
198
+ s.add_development_dependency(%q<ruby-debug19>, [">= 0"])
199
+ s.add_development_dependency(%q<rspec>, ["~> 2.6.0"])
200
+ s.add_development_dependency(%q<rspec-rails>, ["~> 2.6.1"])
201
+ s.add_development_dependency(%q<yard>, ["~> 0.6.0"])
202
+ s.add_development_dependency(%q<cucumber>, [">= 0"])
203
+ s.add_development_dependency(%q<cucumber-rails>, [">= 0"])
204
+ s.add_development_dependency(%q<database_cleaner>, [">= 0"])
205
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
206
+ s.add_development_dependency(%q<jeweler>, ["~> 1.6.3"])
207
+ s.add_development_dependency(%q<json>, [">= 0"])
208
+ s.add_development_dependency(%q<ci_reporter>, [">= 0"])
178
209
  else
179
210
  s.add_dependency(%q<trackable_tasks>, [">= 0"])
180
211
  s.add_dependency(%q<rails>, [">= 3.0.7"])
@@ -252,6 +283,34 @@ Gem::Specification.new do |s|
252
283
  s.add_dependency(%q<jeweler>, ["~> 1.6.3"])
253
284
  s.add_dependency(%q<json>, [">= 0"])
254
285
  s.add_dependency(%q<ci_reporter>, [">= 0"])
286
+ s.add_dependency(%q<jeweler>, ["~> 1.6.3"])
287
+ s.add_dependency(%q<capybara>, [">= 0.4.0"])
288
+ s.add_dependency(%q<sqlite3>, [">= 0"])
289
+ s.add_dependency(%q<ruby-debug19>, [">= 0"])
290
+ s.add_dependency(%q<rspec>, ["~> 2.6.0"])
291
+ s.add_dependency(%q<rspec-rails>, ["~> 2.6.1"])
292
+ s.add_dependency(%q<yard>, ["~> 0.6.0"])
293
+ s.add_dependency(%q<cucumber>, [">= 0"])
294
+ s.add_dependency(%q<cucumber-rails>, [">= 0"])
295
+ s.add_dependency(%q<database_cleaner>, [">= 0"])
296
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
297
+ s.add_dependency(%q<jeweler>, ["~> 1.6.3"])
298
+ s.add_dependency(%q<json>, [">= 0"])
299
+ s.add_dependency(%q<ci_reporter>, [">= 0"])
300
+ s.add_dependency(%q<jeweler>, ["~> 1.6.3"])
301
+ s.add_dependency(%q<capybara>, [">= 0.4.0"])
302
+ s.add_dependency(%q<sqlite3>, [">= 0"])
303
+ s.add_dependency(%q<ruby-debug19>, [">= 0"])
304
+ s.add_dependency(%q<rspec>, ["~> 2.6.0"])
305
+ s.add_dependency(%q<rspec-rails>, ["~> 2.6.1"])
306
+ s.add_dependency(%q<yard>, ["~> 0.6.0"])
307
+ s.add_dependency(%q<cucumber>, [">= 0"])
308
+ s.add_dependency(%q<cucumber-rails>, [">= 0"])
309
+ s.add_dependency(%q<database_cleaner>, [">= 0"])
310
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
311
+ s.add_dependency(%q<jeweler>, ["~> 1.6.3"])
312
+ s.add_dependency(%q<json>, [">= 0"])
313
+ s.add_dependency(%q<ci_reporter>, [">= 0"])
255
314
  end
256
315
  else
257
316
  s.add_dependency(%q<trackable_tasks>, [">= 0"])
@@ -330,6 +389,34 @@ Gem::Specification.new do |s|
330
389
  s.add_dependency(%q<jeweler>, ["~> 1.6.3"])
331
390
  s.add_dependency(%q<json>, [">= 0"])
332
391
  s.add_dependency(%q<ci_reporter>, [">= 0"])
392
+ s.add_dependency(%q<jeweler>, ["~> 1.6.3"])
393
+ s.add_dependency(%q<capybara>, [">= 0.4.0"])
394
+ s.add_dependency(%q<sqlite3>, [">= 0"])
395
+ s.add_dependency(%q<ruby-debug19>, [">= 0"])
396
+ s.add_dependency(%q<rspec>, ["~> 2.6.0"])
397
+ s.add_dependency(%q<rspec-rails>, ["~> 2.6.1"])
398
+ s.add_dependency(%q<yard>, ["~> 0.6.0"])
399
+ s.add_dependency(%q<cucumber>, [">= 0"])
400
+ s.add_dependency(%q<cucumber-rails>, [">= 0"])
401
+ s.add_dependency(%q<database_cleaner>, [">= 0"])
402
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
403
+ s.add_dependency(%q<jeweler>, ["~> 1.6.3"])
404
+ s.add_dependency(%q<json>, [">= 0"])
405
+ s.add_dependency(%q<ci_reporter>, [">= 0"])
406
+ s.add_dependency(%q<jeweler>, ["~> 1.6.3"])
407
+ s.add_dependency(%q<capybara>, [">= 0.4.0"])
408
+ s.add_dependency(%q<sqlite3>, [">= 0"])
409
+ s.add_dependency(%q<ruby-debug19>, [">= 0"])
410
+ s.add_dependency(%q<rspec>, ["~> 2.6.0"])
411
+ s.add_dependency(%q<rspec-rails>, ["~> 2.6.1"])
412
+ s.add_dependency(%q<yard>, ["~> 0.6.0"])
413
+ s.add_dependency(%q<cucumber>, [">= 0"])
414
+ s.add_dependency(%q<cucumber-rails>, [">= 0"])
415
+ s.add_dependency(%q<database_cleaner>, [">= 0"])
416
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
417
+ s.add_dependency(%q<jeweler>, ["~> 1.6.3"])
418
+ s.add_dependency(%q<json>, [">= 0"])
419
+ s.add_dependency(%q<ci_reporter>, [">= 0"])
333
420
  end
334
421
  end
335
422
 
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: trackable_tasks
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.13
5
+ version: 0.1.0
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-04-25 00:00:00 Z
13
+ date: 2012-05-11 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: trackable_tasks
@@ -848,6 +848,314 @@ dependencies:
848
848
  type: :development
849
849
  prerelease: false
850
850
  version_requirements: *id076
851
+ - !ruby/object:Gem::Dependency
852
+ name: jeweler
853
+ requirement: &id077 !ruby/object:Gem::Requirement
854
+ none: false
855
+ requirements:
856
+ - - ~>
857
+ - !ruby/object:Gem::Version
858
+ version: 1.6.3
859
+ type: :development
860
+ prerelease: false
861
+ version_requirements: *id077
862
+ - !ruby/object:Gem::Dependency
863
+ name: capybara
864
+ requirement: &id078 !ruby/object:Gem::Requirement
865
+ none: false
866
+ requirements:
867
+ - - ">="
868
+ - !ruby/object:Gem::Version
869
+ version: 0.4.0
870
+ type: :development
871
+ prerelease: false
872
+ version_requirements: *id078
873
+ - !ruby/object:Gem::Dependency
874
+ name: sqlite3
875
+ requirement: &id079 !ruby/object:Gem::Requirement
876
+ none: false
877
+ requirements:
878
+ - - ">="
879
+ - !ruby/object:Gem::Version
880
+ version: "0"
881
+ type: :development
882
+ prerelease: false
883
+ version_requirements: *id079
884
+ - !ruby/object:Gem::Dependency
885
+ name: ruby-debug19
886
+ requirement: &id080 !ruby/object:Gem::Requirement
887
+ none: false
888
+ requirements:
889
+ - - ">="
890
+ - !ruby/object:Gem::Version
891
+ version: "0"
892
+ type: :development
893
+ prerelease: false
894
+ version_requirements: *id080
895
+ - !ruby/object:Gem::Dependency
896
+ name: rspec
897
+ requirement: &id081 !ruby/object:Gem::Requirement
898
+ none: false
899
+ requirements:
900
+ - - ~>
901
+ - !ruby/object:Gem::Version
902
+ version: 2.6.0
903
+ type: :development
904
+ prerelease: false
905
+ version_requirements: *id081
906
+ - !ruby/object:Gem::Dependency
907
+ name: rspec-rails
908
+ requirement: &id082 !ruby/object:Gem::Requirement
909
+ none: false
910
+ requirements:
911
+ - - ~>
912
+ - !ruby/object:Gem::Version
913
+ version: 2.6.1
914
+ type: :development
915
+ prerelease: false
916
+ version_requirements: *id082
917
+ - !ruby/object:Gem::Dependency
918
+ name: yard
919
+ requirement: &id083 !ruby/object:Gem::Requirement
920
+ none: false
921
+ requirements:
922
+ - - ~>
923
+ - !ruby/object:Gem::Version
924
+ version: 0.6.0
925
+ type: :development
926
+ prerelease: false
927
+ version_requirements: *id083
928
+ - !ruby/object:Gem::Dependency
929
+ name: cucumber
930
+ requirement: &id084 !ruby/object:Gem::Requirement
931
+ none: false
932
+ requirements:
933
+ - - ">="
934
+ - !ruby/object:Gem::Version
935
+ version: "0"
936
+ type: :development
937
+ prerelease: false
938
+ version_requirements: *id084
939
+ - !ruby/object:Gem::Dependency
940
+ name: cucumber-rails
941
+ requirement: &id085 !ruby/object:Gem::Requirement
942
+ none: false
943
+ requirements:
944
+ - - ">="
945
+ - !ruby/object:Gem::Version
946
+ version: "0"
947
+ type: :development
948
+ prerelease: false
949
+ version_requirements: *id085
950
+ - !ruby/object:Gem::Dependency
951
+ name: database_cleaner
952
+ requirement: &id086 !ruby/object:Gem::Requirement
953
+ none: false
954
+ requirements:
955
+ - - ">="
956
+ - !ruby/object:Gem::Version
957
+ version: "0"
958
+ type: :development
959
+ prerelease: false
960
+ version_requirements: *id086
961
+ - !ruby/object:Gem::Dependency
962
+ name: bundler
963
+ requirement: &id087 !ruby/object:Gem::Requirement
964
+ none: false
965
+ requirements:
966
+ - - ~>
967
+ - !ruby/object:Gem::Version
968
+ version: 1.0.0
969
+ type: :development
970
+ prerelease: false
971
+ version_requirements: *id087
972
+ - !ruby/object:Gem::Dependency
973
+ name: jeweler
974
+ requirement: &id088 !ruby/object:Gem::Requirement
975
+ none: false
976
+ requirements:
977
+ - - ~>
978
+ - !ruby/object:Gem::Version
979
+ version: 1.6.3
980
+ type: :development
981
+ prerelease: false
982
+ version_requirements: *id088
983
+ - !ruby/object:Gem::Dependency
984
+ name: json
985
+ requirement: &id089 !ruby/object:Gem::Requirement
986
+ none: false
987
+ requirements:
988
+ - - ">="
989
+ - !ruby/object:Gem::Version
990
+ version: "0"
991
+ type: :development
992
+ prerelease: false
993
+ version_requirements: *id089
994
+ - !ruby/object:Gem::Dependency
995
+ name: ci_reporter
996
+ requirement: &id090 !ruby/object:Gem::Requirement
997
+ none: false
998
+ requirements:
999
+ - - ">="
1000
+ - !ruby/object:Gem::Version
1001
+ version: "0"
1002
+ type: :development
1003
+ prerelease: false
1004
+ version_requirements: *id090
1005
+ - !ruby/object:Gem::Dependency
1006
+ name: jeweler
1007
+ requirement: &id091 !ruby/object:Gem::Requirement
1008
+ none: false
1009
+ requirements:
1010
+ - - ~>
1011
+ - !ruby/object:Gem::Version
1012
+ version: 1.6.3
1013
+ type: :development
1014
+ prerelease: false
1015
+ version_requirements: *id091
1016
+ - !ruby/object:Gem::Dependency
1017
+ name: capybara
1018
+ requirement: &id092 !ruby/object:Gem::Requirement
1019
+ none: false
1020
+ requirements:
1021
+ - - ">="
1022
+ - !ruby/object:Gem::Version
1023
+ version: 0.4.0
1024
+ type: :development
1025
+ prerelease: false
1026
+ version_requirements: *id092
1027
+ - !ruby/object:Gem::Dependency
1028
+ name: sqlite3
1029
+ requirement: &id093 !ruby/object:Gem::Requirement
1030
+ none: false
1031
+ requirements:
1032
+ - - ">="
1033
+ - !ruby/object:Gem::Version
1034
+ version: "0"
1035
+ type: :development
1036
+ prerelease: false
1037
+ version_requirements: *id093
1038
+ - !ruby/object:Gem::Dependency
1039
+ name: ruby-debug19
1040
+ requirement: &id094 !ruby/object:Gem::Requirement
1041
+ none: false
1042
+ requirements:
1043
+ - - ">="
1044
+ - !ruby/object:Gem::Version
1045
+ version: "0"
1046
+ type: :development
1047
+ prerelease: false
1048
+ version_requirements: *id094
1049
+ - !ruby/object:Gem::Dependency
1050
+ name: rspec
1051
+ requirement: &id095 !ruby/object:Gem::Requirement
1052
+ none: false
1053
+ requirements:
1054
+ - - ~>
1055
+ - !ruby/object:Gem::Version
1056
+ version: 2.6.0
1057
+ type: :development
1058
+ prerelease: false
1059
+ version_requirements: *id095
1060
+ - !ruby/object:Gem::Dependency
1061
+ name: rspec-rails
1062
+ requirement: &id096 !ruby/object:Gem::Requirement
1063
+ none: false
1064
+ requirements:
1065
+ - - ~>
1066
+ - !ruby/object:Gem::Version
1067
+ version: 2.6.1
1068
+ type: :development
1069
+ prerelease: false
1070
+ version_requirements: *id096
1071
+ - !ruby/object:Gem::Dependency
1072
+ name: yard
1073
+ requirement: &id097 !ruby/object:Gem::Requirement
1074
+ none: false
1075
+ requirements:
1076
+ - - ~>
1077
+ - !ruby/object:Gem::Version
1078
+ version: 0.6.0
1079
+ type: :development
1080
+ prerelease: false
1081
+ version_requirements: *id097
1082
+ - !ruby/object:Gem::Dependency
1083
+ name: cucumber
1084
+ requirement: &id098 !ruby/object:Gem::Requirement
1085
+ none: false
1086
+ requirements:
1087
+ - - ">="
1088
+ - !ruby/object:Gem::Version
1089
+ version: "0"
1090
+ type: :development
1091
+ prerelease: false
1092
+ version_requirements: *id098
1093
+ - !ruby/object:Gem::Dependency
1094
+ name: cucumber-rails
1095
+ requirement: &id099 !ruby/object:Gem::Requirement
1096
+ none: false
1097
+ requirements:
1098
+ - - ">="
1099
+ - !ruby/object:Gem::Version
1100
+ version: "0"
1101
+ type: :development
1102
+ prerelease: false
1103
+ version_requirements: *id099
1104
+ - !ruby/object:Gem::Dependency
1105
+ name: database_cleaner
1106
+ requirement: &id100 !ruby/object:Gem::Requirement
1107
+ none: false
1108
+ requirements:
1109
+ - - ">="
1110
+ - !ruby/object:Gem::Version
1111
+ version: "0"
1112
+ type: :development
1113
+ prerelease: false
1114
+ version_requirements: *id100
1115
+ - !ruby/object:Gem::Dependency
1116
+ name: bundler
1117
+ requirement: &id101 !ruby/object:Gem::Requirement
1118
+ none: false
1119
+ requirements:
1120
+ - - ~>
1121
+ - !ruby/object:Gem::Version
1122
+ version: 1.0.0
1123
+ type: :development
1124
+ prerelease: false
1125
+ version_requirements: *id101
1126
+ - !ruby/object:Gem::Dependency
1127
+ name: jeweler
1128
+ requirement: &id102 !ruby/object:Gem::Requirement
1129
+ none: false
1130
+ requirements:
1131
+ - - ~>
1132
+ - !ruby/object:Gem::Version
1133
+ version: 1.6.3
1134
+ type: :development
1135
+ prerelease: false
1136
+ version_requirements: *id102
1137
+ - !ruby/object:Gem::Dependency
1138
+ name: json
1139
+ requirement: &id103 !ruby/object:Gem::Requirement
1140
+ none: false
1141
+ requirements:
1142
+ - - ">="
1143
+ - !ruby/object:Gem::Version
1144
+ version: "0"
1145
+ type: :development
1146
+ prerelease: false
1147
+ version_requirements: *id103
1148
+ - !ruby/object:Gem::Dependency
1149
+ name: ci_reporter
1150
+ requirement: &id104 !ruby/object:Gem::Requirement
1151
+ none: false
1152
+ requirements:
1153
+ - - ">="
1154
+ - !ruby/object:Gem::Version
1155
+ version: "0"
1156
+ type: :development
1157
+ prerelease: false
1158
+ version_requirements: *id104
851
1159
  description: Adds tracking to rake tasks including error capturing and logging.
852
1160
  email: jeremiah@cloudspace.com
853
1161
  executables: []
@@ -869,17 +1177,20 @@ files:
869
1177
  - VERSION
870
1178
  - app/controllers/trackable_tasks/task_runs_controller.rb
871
1179
  - app/models/trackable_tasks/task_run.rb
1180
+ - app/views/trackable_tasks/task_runs/_chart.html.erb
1181
+ - app/views/trackable_tasks/task_runs/_percentages.html.erb
872
1182
  - app/views/trackable_tasks/task_runs/index.html.erb
873
1183
  - app/views/trackable_tasks/task_runs/show.html.erb
1184
+ - app/views/trackable_tasks/task_runs/stats.html.erb
874
1185
  - config/routes.rb
875
1186
  - lib/generators/trackable_tasks/install_generator.rb
876
1187
  - lib/generators/trackable_tasks/templates/migrations/install_migration.rb.erb
877
- - lib/generators/trackable_tasks/templates/trackable_tasks.rake
878
1188
  - lib/trackable_tasks.rb
879
1189
  - lib/trackable_tasks/base.rb
880
1190
  - lib/trackable_tasks/config.rb
881
1191
  - lib/trackable_tasks/engine.rb
882
1192
  - lib/trackable_tasks/railtie.rb
1193
+ - lib/trackable_tasks/tasks/trackable_tasks.rake
883
1194
  - spec/dummy/Rakefile
884
1195
  - spec/dummy/app/controllers/application_controller.rb
885
1196
  - spec/dummy/app/helpers/application_helper.rb
@@ -901,13 +1212,13 @@ files:
901
1212
  - spec/dummy/config/routes.rb
902
1213
  - spec/dummy/db/migrate/20110826183240_create_trackable_task_tables.rb
903
1214
  - spec/dummy/db/schema.rb
1215
+ - spec/dummy/features/stats.feature
904
1216
  - spec/dummy/features/step_definitions/trackable_tasks_steps.rb
905
1217
  - spec/dummy/features/step_definitions/web_steps.rb
906
1218
  - spec/dummy/features/support/env.rb
907
1219
  - spec/dummy/features/support/paths.rb
908
1220
  - spec/dummy/features/support/selectors.rb
909
1221
  - spec/dummy/features/task_run.feature
910
- - spec/dummy/lib/tasks/trackable_tasks.rake
911
1222
  - spec/dummy/lib/trackable_tasks/my_task.rb
912
1223
  - spec/dummy/public/404.html
913
1224
  - spec/dummy/public/422.html
@@ -942,7 +1253,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
942
1253
  requirements:
943
1254
  - - ">="
944
1255
  - !ruby/object:Gem::Version
945
- hash: 2669986837491187862
1256
+ hash: -2307237475125108397
946
1257
  segments:
947
1258
  - 0
948
1259
  version: "0"
@@ -1,48 +0,0 @@
1
- include Rake::DSL
2
-
3
- # Careful when editing this file. It may be overwritten when the gem is updated.
4
- namespace :trackable_task do
5
-
6
- # loads the trackable tasks from /lib/trackable_tasks
7
- # this may be moved to a config file at some point
8
- trackable_task_list = []
9
- Dir.foreach("#{::Rails.root.to_s}/lib/trackable_tasks/") do |file_name|
10
- next if file_name == "." || file_name == ".."
11
- file_name['.rb'] = ''
12
- trackable_task_list.push(file_name.to_sym)
13
- end
14
-
15
- # turns the array of trackable tasks into individual rake tasks
16
- trackable_task_list.each do |task_name|
17
- desc "Trackable task for #{task_name.to_s.camelize}. Optionally set the log_level ENV variable to debug, notice, and error."
18
- task task_name => :environment do |t|
19
- log_level = ENV["log_level"]
20
- run_trackable_task(task_name.to_s, log_level)
21
- end
22
- end
23
-
24
- # single rake task that can run any trackable task
25
- desc "Runs a trackable task by passing in the task as an argument"
26
- task :run => :environment do |t|
27
- task_name = ENV["task_name"]
28
- log_level = ENV["log_level"]
29
- run_trackable_task(task_name, log_level)
30
- end
31
-
32
- # Runs the trackable task by constantizing the task name, initializing, and calling run task
33
- #
34
- # @param [String] The name of the task class
35
- # @param [String] The log level for the task
36
- def run_trackable_task(task_name, log_level)
37
- #puts "I am running #{task_name} at log level #{log_level}"
38
- require "#{::Rails.root.to_s}/lib/trackable_tasks/#{task_name}.rb"
39
- # if the class exists
40
- trackable_task = task_name.camelize.constantize.new(log_level)
41
- # if the class has a superclass of trackable task base
42
- if trackable_task.class.superclass == TrackableTasks::Base
43
- trackable_task.run_task
44
- else
45
- puts "The task #{task_name} was not an instance of TrackableTasks::Base."
46
- end
47
- end
48
- end