gnomon 0.1.5 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/gnomon.rb +24 -24
- data/lib/gnomon/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2df2fb4bd5565c7a0e51b29646d1a403e6d083e9
|
4
|
+
data.tar.gz: bd3ecdcfb103a8078f8fdc26a7c5becd2d278ae7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0136237e49d7ca5b449e42320e26d5b416654cfee9f95adf4c8a4b3c0e29da9d0c2a2baef135b09deb0186c7e0ce00ab99ae9509f45b47f1300cc0b5cd0cb401
|
7
|
+
data.tar.gz: aff7291a48f8d79739d4022d3dd165df498f23d1df6fc895596ed3e8284f2e749ba604ee860910d119517bfa31449b19d4e06228a667e58db3d966114fbacc3d
|
data/lib/gnomon.rb
CHANGED
@@ -9,8 +9,8 @@ require 'date'
|
|
9
9
|
require 'thread'
|
10
10
|
require 'runify'
|
11
11
|
|
12
|
-
# Gnomon Class
|
13
|
-
# Root Class for Gnomon
|
12
|
+
# Gnomon Class:
|
13
|
+
# Root Class for Gnomon.
|
14
14
|
class Gnomon
|
15
15
|
|
16
16
|
# Runify
|
@@ -19,8 +19,8 @@ class Gnomon
|
|
19
19
|
# Defaults
|
20
20
|
DEFAULT_GRANULARITY = 1
|
21
21
|
|
22
|
-
# Construct
|
23
|
-
# Creates a new Gnomon instance
|
22
|
+
# Construct:
|
23
|
+
# Creates a new Gnomon instance.
|
24
24
|
# @param [Float] granularity The desired resolution of the event queue, in seconds
|
25
25
|
def initialize granularity = DEFAULT_GRANULARITY
|
26
26
|
|
@@ -37,8 +37,8 @@ class Gnomon
|
|
37
37
|
@lock = Mutex.new
|
38
38
|
end
|
39
39
|
|
40
|
-
# Schedule Event
|
41
|
-
# Schedules a generic event
|
40
|
+
# Schedule Event:
|
41
|
+
# Schedules a generic event.
|
42
42
|
# @param [Object] id An ID for later de-scheduling of this event
|
43
43
|
# @param [Symbol] mode The mode of scheduling - can be any of [ :at, :in, :every ]
|
44
44
|
# @param [Hash] mode_options Mode-specific options hash - See documentation for desired mode
|
@@ -68,8 +68,8 @@ class Gnomon
|
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
|
-
# Schedule Event at a given date/time
|
72
|
-
# Shortcut to schedule an event to be triggered once at a specific date/time
|
71
|
+
# Schedule Event at a given date/time:
|
72
|
+
# Shortcut to schedule an event to be triggered once at a specific date/time.
|
73
73
|
# @param [Object] id
|
74
74
|
# @param [String] date_time A date / time string
|
75
75
|
# @param [Object] args
|
@@ -78,8 +78,8 @@ class Gnomon
|
|
78
78
|
schedule id, :at, {}, date_time, *args, &block
|
79
79
|
end
|
80
80
|
|
81
|
-
# Schedule Event in a given number of seconds
|
82
|
-
# Shortcut to schedule an event to be triggered once after a given amount of time
|
81
|
+
# Schedule Event in a given number of seconds:
|
82
|
+
# Shortcut to schedule an event to be triggered once after a given amount of time.
|
83
83
|
# @param [Object] id
|
84
84
|
# @param [Float] time
|
85
85
|
# @param [Object] args
|
@@ -88,8 +88,8 @@ class Gnomon
|
|
88
88
|
schedule id, :in, {}, time, *args, &block
|
89
89
|
end
|
90
90
|
|
91
|
-
# Schedule Event at a given interval (seconds)
|
92
|
-
# Shortcut to schedule an event to be triggered periodically at a given time interval
|
91
|
+
# Schedule Event at a given interval (seconds):
|
92
|
+
# Shortcut to schedule an event to be triggered periodically at a given time interval.
|
93
93
|
# @param [Object] id
|
94
94
|
# @param [Float] interval
|
95
95
|
# @param [boolean] async When true, schedule the next trigger before actually running the event's block - otherwise, schedule the next trigger only once the event block completes
|
@@ -99,8 +99,8 @@ class Gnomon
|
|
99
99
|
schedule id, :every, { async: async }, interval, *args, &block
|
100
100
|
end
|
101
101
|
|
102
|
-
# De-schedule
|
103
|
-
# Removes one or more previously-scheduled events from the scheduler
|
102
|
+
# De-schedule:
|
103
|
+
# Removes one or more previously-scheduled events from the scheduler.
|
104
104
|
# @param [Object] id The ID of the event(s) to remove (all events with this ID will be removed)
|
105
105
|
# @param [Object] keep_running When true, the next trigger is maintained
|
106
106
|
def deschedule id, keep_running = false
|
@@ -120,8 +120,8 @@ class Gnomon
|
|
120
120
|
# Privates
|
121
121
|
private
|
122
122
|
|
123
|
-
# Enqueue Next Run
|
124
|
-
# Registers the next run for a given event into the event queue
|
123
|
+
# Enqueue Next Run:
|
124
|
+
# Registers the next run for a given event into the event queue.
|
125
125
|
# @param [Hash] event
|
126
126
|
def enqueue_next_run event
|
127
127
|
next_run = next_run event[:mode], event[:ts]
|
@@ -129,8 +129,8 @@ class Gnomon
|
|
129
129
|
@equeue.insert pos, { next_run: next_run, event: event }
|
130
130
|
end
|
131
131
|
|
132
|
-
# Determine Next Run
|
133
|
-
# Determines when to trigger the next run for a given event
|
132
|
+
# Determine Next Run:
|
133
|
+
# Determines when to trigger the next run for a given event.
|
134
134
|
# @param [Symbol] mode
|
135
135
|
# @param [Object] ts
|
136
136
|
# @return [Float] A floating-point timestamp representing the time at which to trigger the next run
|
@@ -145,14 +145,14 @@ class Gnomon
|
|
145
145
|
end
|
146
146
|
end
|
147
147
|
|
148
|
-
# Run
|
149
|
-
#
|
148
|
+
# Run:
|
149
|
+
# Executes the main loop.
|
150
150
|
def run
|
151
151
|
update until @stop
|
152
152
|
end
|
153
153
|
|
154
|
-
# Update
|
155
|
-
#
|
154
|
+
# Update:
|
155
|
+
# Updates Gnomon's internal states.
|
156
156
|
def update
|
157
157
|
|
158
158
|
# Synchronize { Trigger Next Event in Queue }
|
@@ -162,8 +162,8 @@ class Gnomon
|
|
162
162
|
sleep @granularity
|
163
163
|
end
|
164
164
|
|
165
|
-
# Trigger Event
|
166
|
-
# Triggers an event, executing its block and re-scheduling the next run when appropriate
|
165
|
+
# Trigger Event:
|
166
|
+
# Triggers an event, executing its block and re-scheduling the next run when appropriate.
|
167
167
|
# @param [Hash] event
|
168
168
|
def trigger event
|
169
169
|
|
data/lib/gnomon/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gnomon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eresse
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-03-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -101,7 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
101
101
|
version: '0'
|
102
102
|
requirements: []
|
103
103
|
rubyforge_project:
|
104
|
-
rubygems_version: 2.
|
104
|
+
rubygems_version: 2.5.1
|
105
105
|
signing_key:
|
106
106
|
specification_version: 4
|
107
107
|
summary: Simple event scheduling for Ruby
|