day_planner 0.1.0.pre13.2 → 0.1.0.pre15

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ea1a8388bee3db6d14b3f8e87ae7a015ea6fb9e9
4
- data.tar.gz: 1a3add64f1cf3ea29bcaf0ce9e5821360e02d8f9
3
+ metadata.gz: 76c86b034100ccea52a8255db13af7ffdf288878
4
+ data.tar.gz: 2e6b31e856ff9cdccd6abc89d11692c026e7e08f
5
5
  SHA512:
6
- metadata.gz: d444e21d7abbca089a2ce5082fd91d3dc6e91d1162cf93e629a88a8c3121b18bd366ceb6c5169654af7ef5d2ad8fcc8f7a8b81608db2d57bcbce040be196d6cf
7
- data.tar.gz: 23e61d289e2b28534dc1f54afe4699c07ddc200442c8dc308b84ef49f33b426b341df838455a741d319fe8e99f9af5bb0787dd4bbac142f2536afc5b021e2c05
6
+ metadata.gz: 6f2c7d5e8314258dec3f4255c09c0f3acbfc82ec319ca2e9a29aded05a2ff40e8e3c8d46adfdc1024079cb7b46aac0b6fe403503f64a3e443674d33e3f22d200
7
+ data.tar.gz: e6943f50012e19967acbbfd9c25a56dc23c309f028ba6fcd6655e4a8aae99a90d22630c82d8549905f1a424880416b2296caecc4a388b245a45dded5e3fb6fc9
data/PLANS.md CHANGED
@@ -12,6 +12,8 @@ This is basically a gimme as long as we're already recording stuff in a database
12
12
  HIGH PRIORITY: I want to be able to monitor the elaborate new scheduling algorithm appropriately. This needs to be optional, but it would be nice to have the ability to monitor at least how well the task adheres to the timeline.
13
13
  * Optional generator task to create a table of task history whatnot? Check for it on initialize and then start writing to it if it's there.
14
14
  * Read history, add method to calculate number of times task performed over timeframe.
15
+ * ActiveRecord::Base.connection.table_exists?('day_planner_task_log') welp then check for it
16
+ * new rails generator to create that migration
15
17
 
16
18
  ### Attempt some degree of control with multi-process instances ###
17
19
  Not sure exactly how to do this.
@@ -0,0 +1,5 @@
1
+ module DayPlanner
2
+ class Log < ActiveRecord::Base
3
+ self.table_name = :day_planner_log
4
+ end
5
+ end
@@ -16,10 +16,19 @@ module DayPlanner
16
16
  fields = {}
17
17
  fields[:name] = options.delete(:name) if options[:name]
18
18
  fields[:interval] = options.delete(:every).to_i if options[:every]
19
+ fields[:last_execution] = Time.parse("1/1/1")
19
20
 
20
21
  task = DayPlanner::Task.create(fields)
21
22
  end
22
23
 
24
+ def log
25
+ if ActiveRecord::Base.connection.table_exists?('day_planner_log')
26
+ DayPlanner::Log.create(name: name, interval: interval, datetime: Time.now)
27
+ else
28
+ puts "I refuse to log!"
29
+ end
30
+ end
31
+
23
32
  def check_name
24
33
  if name.present?
25
34
  tasks = Task.where(name: name)
@@ -34,7 +34,7 @@ module DayPlanner
34
34
 
35
35
  def clear_tasks
36
36
  @@tasks = []
37
- ActiveRecord::Base.connection.execute("DELETE FROM #{DayPlanner::Task.table_name} WHERE true;")
37
+ ActiveRecord::Base.connection.execute("DELETE FROM #{DayPlanner::Task.table_name} WHERE 1;")
38
38
  DayPlanner::Task.reset_table_sequence
39
39
  end
40
40
 
@@ -106,7 +106,7 @@ module DayPlanner
106
106
  if task.nil?
107
107
  @@tasks.select!{ |item| item.id != t.id }
108
108
  else
109
- if task.last_execution.nil? || (time > task.next_execution && time > task.last_execution + (task.interval / 2))
109
+ if task.last_execution.nil? || task.next_execution.nil? || (time > task.next_execution && time > task.last_execution + (task.interval / 2))
110
110
  task.last_execution = time
111
111
 
112
112
  if !task.next_execution.nil?
@@ -117,6 +117,7 @@ module DayPlanner
117
117
 
118
118
  task.save!
119
119
 
120
+ t.log
120
121
  t.block.call
121
122
  end
122
123
  end
@@ -3,6 +3,35 @@ require 'rails/generators'
3
3
 
4
4
  module DayPlanner
5
5
  module Generators
6
+ class LogGenerator < ::Rails::Generators::Base
7
+ include ::Rails::Generators::Migration
8
+
9
+ source_root File.expand_path('../../templates', __FILE__)
10
+
11
+ def copy_migrations
12
+ copy_migration "create_day_planner_log"
13
+ end
14
+
15
+ protected
16
+
17
+ def copy_migration(filename)
18
+ if self.class.migration_exists?("db/migrate", filename)
19
+ say_status("skipped", "Migration #{filename} already exists")
20
+ else
21
+ migration_template("migrations/#{filename}.rb", "db/migrate/#{filename}.rb")
22
+ end
23
+ end
24
+
25
+ def self.next_migration_number(path)
26
+ unless @previous_migration_number
27
+ @previous_migration_number = Time.now.utc.strftime('%Y%m%d%H%M%S').to_i
28
+ else
29
+ @previous_migration_number += 1
30
+ end
31
+ @previous_migration_number.to_s
32
+ end
33
+ end
34
+
6
35
  class InstallGenerator < ::Rails::Generators::Base
7
36
  include ::Rails::Generators::Migration
8
37
 
@@ -0,0 +1,13 @@
1
+ class CreateDayPlannerLog < ActiveRecord::Migration
2
+ def up
3
+ create_table :day_planner_log do |t|
4
+ t.string :name
5
+ t.integer :interval
6
+ t.datetime :datetime
7
+ end
8
+ end
9
+
10
+ def down
11
+ drop_table :day_planner_log
12
+ end
13
+ end
@@ -2,8 +2,8 @@ module DayPlanner
2
2
  MAJOR = 0
3
3
  MINOR = 1
4
4
  TINY = 0
5
- PRE = "pre13"
6
- BUILD = 2
5
+ PRE = "pre15"
6
+ BUILD = nil
7
7
 
8
8
  VERSION = [MAJOR, MINOR, TINY, PRE, BUILD].compact.join(".")
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: day_planner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.pre13.2
4
+ version: 0.1.0.pre15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Damon Siefert
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-02 00:00:00.000000000 Z
11
+ date: 2014-01-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -80,6 +80,7 @@ files:
80
80
  - PLANS.md
81
81
  - README.md
82
82
  - Rakefile
83
+ - app/models/day_planner/log.rb
83
84
  - app/models/day_planner/task.rb
84
85
  - day_planner.gemspec
85
86
  - lib/active_record/reset_table_sequence.rb
@@ -87,6 +88,7 @@ files:
87
88
  - lib/day_planner/base.rb
88
89
  - lib/day_planner/engine.rb
89
90
  - lib/day_planner/generators/day_planner_generator.rb
91
+ - lib/day_planner/templates/migrations/create_day_planner_log.rb
90
92
  - lib/day_planner/templates/migrations/create_day_planner_tasks.rb
91
93
  - lib/day_planner/version.rb
92
94
  homepage: ''