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 +4 -4
- data/PLANS.md +2 -0
- data/app/models/day_planner/log.rb +5 -0
- data/app/models/day_planner/task.rb +9 -0
- data/lib/day_planner/base.rb +3 -2
- data/lib/day_planner/generators/day_planner_generator.rb +29 -0
- data/lib/day_planner/templates/migrations/create_day_planner_log.rb +13 -0
- data/lib/day_planner/version.rb +2 -2
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 76c86b034100ccea52a8255db13af7ffdf288878
|
4
|
+
data.tar.gz: 2e6b31e856ff9cdccd6abc89d11692c026e7e08f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
@@ -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)
|
data/lib/day_planner/base.rb
CHANGED
@@ -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
|
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
|
|
data/lib/day_planner/version.rb
CHANGED
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.
|
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-
|
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: ''
|