yuuki 0.1.0 → 0.1.3
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/.DS_Store +0 -0
- data/.gitignore +0 -1
- data/Gemfile +2 -0
- data/README.md +26 -1
- data/Rakefile +12 -2
- data/lib/yuuki/caller.rb +154 -116
- data/lib/yuuki/error.rb +4 -2
- data/lib/yuuki/periodic.rb +77 -0
- data/lib/yuuki/runner.rb +51 -40
- data/lib/yuuki/version.rb +3 -1
- data/lib/yuuki.rb +3 -1
- data/sig/yuuki/caller.rbs +25 -0
- data/sig/yuuki/error.rbs +7 -0
- data/sig/yuuki/periodic.rbs +19 -0
- data/sig/yuuki/runner.rbs +14 -0
- data/sig/yuuki/version.rbs +6 -0
- data/yuuki.gemspec +23 -21
- metadata +15 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 49851d0c15f259e4c54568ff173a45b9ae9316e25c4120fd3d12926f2560fcfb
|
|
4
|
+
data.tar.gz: f17a0f2ec8d4de59becb43c9f6e4de08de3b38534583250f1899da127576188c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a2ef440f3446c5d737abfa611f81731b06905189013c3220560a00a9f0e23d6422180a699934a9161711390a49d2e5bbf61f5178bd4316c6c1bcc2e1bad33889
|
|
7
|
+
data.tar.gz: 895d9874e7455840667ea75a90bb02c669d5b384a88b0412ee3bd4be58082465489317b483d2b8e28de81d6d2224f5819bb6af5b34fb1bb9a907b1db053e4164
|
data/.DS_Store
ADDED
|
Binary file
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
|
@@ -20,7 +20,32 @@ Or install it yourself as:
|
|
|
20
20
|
|
|
21
21
|
## Usage
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
```ruby
|
|
24
|
+
require 'yuuki'
|
|
25
|
+
|
|
26
|
+
class HogeClass
|
|
27
|
+
extend Yuuki::Runner
|
|
28
|
+
|
|
29
|
+
add :a
|
|
30
|
+
def a
|
|
31
|
+
puts 'a'
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
add :b
|
|
35
|
+
tag :b, :tag_b
|
|
36
|
+
def b
|
|
37
|
+
puts 'b'
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
yuuki = Yuuki::Caller.new(HogeClass)
|
|
42
|
+
yuuki.run
|
|
43
|
+
# a
|
|
44
|
+
# b
|
|
45
|
+
|
|
46
|
+
yuuki.run_tag(:tag_b)
|
|
47
|
+
# b
|
|
48
|
+
```
|
|
24
49
|
|
|
25
50
|
## Contributing
|
|
26
51
|
|
data/Rakefile
CHANGED
|
@@ -1,2 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'bundler/gem_tasks'
|
|
4
|
+
require 'rake/testtask'
|
|
5
|
+
|
|
6
|
+
Rake::TestTask.new(:test) do |t|
|
|
7
|
+
t.libs << 'test'
|
|
8
|
+
t.libs << 'lib'
|
|
9
|
+
t.test_files = FileList['test/**/*_test.rb']
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
task default: %i[test]
|
data/lib/yuuki/caller.rb
CHANGED
|
@@ -1,135 +1,173 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'set'
|
|
1
4
|
require 'yuuki/runner'
|
|
2
5
|
|
|
3
6
|
module Yuuki
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
def initialize(*klass)
|
|
12
|
-
@runners = []
|
|
13
|
-
@threads = []
|
|
14
|
-
add(*klass)
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def add(*klass)
|
|
18
|
-
klass.each do |klass|
|
|
19
|
-
instance = klass.new
|
|
20
|
-
instance.instance_variable_set(:@caller, self)
|
|
21
|
-
info = klass.instance_variable_get(:@runner_info) || {}
|
|
22
|
-
methods = klass.public_instance_methods(false)
|
|
23
|
-
methods |= klass.instance_variable_get(:@runner_adds) || []
|
|
24
|
-
methods -= klass.instance_variable_get(:@runner_excepts) || []
|
|
25
|
-
@runners += methods.map do |method|
|
|
26
|
-
tags = info.dig(method, :tags) || []
|
|
27
|
-
exclude = !!info.dig(method, :exclude)
|
|
28
|
-
threading = !!info.dig(method, :threading)
|
|
29
|
-
priority = info.dig(method, :priority) || 0
|
|
30
|
-
Runner.new(instance.method(method), tags, exclude, threading, priority)
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
@runners.sort_by!{|e| -e.priority}
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
def run(**args)
|
|
37
|
-
run_internal(@runners.reject(&:exclude), args)
|
|
38
|
-
end
|
|
7
|
+
class Caller
|
|
8
|
+
# requires all the rb files in the given directory
|
|
9
|
+
# @param [String] require_dir directory
|
|
10
|
+
# @param [Boolean] recursive
|
|
11
|
+
def self.require_dir(require_dir, recursive: false)
|
|
12
|
+
Dir.glob(recursive ? "#{require_dir}/**/*.rb" : "#{require_dir}/*.rb"){|file| require file}
|
|
13
|
+
end
|
|
39
14
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
15
|
+
# @param [Object] instances
|
|
16
|
+
def initialize(*instances)
|
|
17
|
+
@instances = Set.new
|
|
18
|
+
@threads = []
|
|
19
|
+
add(*instances)
|
|
20
|
+
end
|
|
43
21
|
|
|
44
|
-
|
|
45
|
-
|
|
22
|
+
# adds instances to yuuki
|
|
23
|
+
# @param [Object] instances
|
|
24
|
+
def add(*instances)
|
|
25
|
+
instances.each do |instance|
|
|
26
|
+
# create instance if class is given
|
|
27
|
+
if instance.is_a?(Class)
|
|
28
|
+
klass = instance
|
|
29
|
+
# check the klass is extended
|
|
30
|
+
raise Yuuki::Error, 'Runner instance must be extend Yuuki::Runner' unless klass.singleton_class.include?(Yuuki::Runner)
|
|
31
|
+
instance = instance.allocate
|
|
32
|
+
instance.instance_variable_set(:@yuuki, self)
|
|
33
|
+
instance.send(:initialize)
|
|
34
|
+
else
|
|
35
|
+
# check the klass is extended
|
|
36
|
+
raise Yuuki::Error, 'Runner instance must be extend Yuuki::Runner' unless instance.class.singleton_class.include?(Yuuki::Runner)
|
|
37
|
+
# add @yuuki to the instance
|
|
38
|
+
instance.instance_variable_set(:@yuuki, self)
|
|
46
39
|
end
|
|
47
40
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
41
|
+
# regist
|
|
42
|
+
@instances << instance
|
|
43
|
+
end
|
|
44
|
+
end
|
|
51
45
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
46
|
+
# returns runners
|
|
47
|
+
# @return [Array<[Method, Hash<Symbol, Object>]>]
|
|
48
|
+
def runners
|
|
49
|
+
list = @instances.flat_map do |instance|
|
|
50
|
+
methods = instance.class.instance_variable_get(:@yuuki_methods)
|
|
51
|
+
methods.select{|_sig, meta| meta[:enabled]}.map{|sig, meta| [instance.method(sig), meta]}
|
|
52
|
+
end
|
|
53
|
+
list.sort_by{|_method, meta| -(meta[:priority] || 0)}
|
|
54
|
+
end
|
|
55
55
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
# runs all methods
|
|
57
|
+
# @param [Object] args arguments
|
|
58
|
+
def run(**args, &block)
|
|
59
|
+
run_internal(runners, args, &block)
|
|
60
|
+
end
|
|
59
61
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
# runs all selected methods
|
|
63
|
+
# @param [Proc] proc_select
|
|
64
|
+
# @param [Object] args arguments
|
|
65
|
+
def run_select(proc_select, **args, &block)
|
|
66
|
+
run_internal(runners.select(&proc_select), args, &block)
|
|
67
|
+
end
|
|
65
68
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
+
# runs all methods with the specified tags
|
|
70
|
+
# @param [Symbol] tags
|
|
71
|
+
# @param [Object] args arguments
|
|
72
|
+
def run_tag(*tags, **args, &block)
|
|
73
|
+
run_select(proc{|_method, meta| meta[:tags]&.intersect?(tags)}, **args, &block)
|
|
74
|
+
end
|
|
69
75
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
76
|
+
# runs the specific method
|
|
77
|
+
# @param [Class, nil] klass
|
|
78
|
+
# @param [Symbol, nil] method_sig method name
|
|
79
|
+
# @param [Object] args arguments
|
|
80
|
+
def run_method(klass, method_sig, **args, &block)
|
|
81
|
+
select_proc = proc do |method, _meta|
|
|
82
|
+
flag_klass = klass ? method.receiver.instance_of?(klass) : true
|
|
83
|
+
flag_method = method_sig ? method.name == method_sig : true
|
|
84
|
+
flag_klass && flag_method
|
|
85
|
+
end
|
|
86
|
+
run_select(select_proc, **args, &block)
|
|
87
|
+
end
|
|
74
88
|
|
|
75
|
-
|
|
89
|
+
# joins all runnning threads
|
|
90
|
+
def join
|
|
91
|
+
@threads.each(&:join)
|
|
92
|
+
@threads.select!(&:alive?)
|
|
93
|
+
end
|
|
76
94
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
95
|
+
# returns whether any thread is alive
|
|
96
|
+
# @return [Boolean]
|
|
97
|
+
def alive?
|
|
98
|
+
@threads.select!(&:alive?)
|
|
99
|
+
!@threads.empty?
|
|
100
|
+
end
|
|
101
|
+
alias running? alive?
|
|
102
|
+
|
|
103
|
+
private
|
|
104
|
+
|
|
105
|
+
def run_internal(runners, args, &block)
|
|
106
|
+
@threads.select!(&:alive?)
|
|
107
|
+
runners.each do |method, meta|
|
|
108
|
+
if meta[:thread]
|
|
109
|
+
thread = Thread.new(method, args, block) do |thread_method, thread_args, thread_block|
|
|
110
|
+
run_method_internal(thread_method, thread_args, &thread_block)
|
|
111
|
+
end
|
|
112
|
+
thread.priority = meta[:priority] || 0
|
|
113
|
+
@threads << thread
|
|
114
|
+
else
|
|
115
|
+
run_method_internal(method, args, &block)
|
|
88
116
|
end
|
|
117
|
+
end
|
|
118
|
+
end
|
|
89
119
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
120
|
+
def run_method_internal(method, args, &block)
|
|
121
|
+
params = method.parameters
|
|
122
|
+
return method[] if params.empty?
|
|
123
|
+
params_array = []
|
|
124
|
+
params_hash = {}
|
|
125
|
+
params_block = nil
|
|
126
|
+
nonspecified_last_opt = nil
|
|
127
|
+
params.each do |type, name|
|
|
128
|
+
case type
|
|
129
|
+
when :req
|
|
130
|
+
raise Yuuki::Error, "A required argument '#{name}' was not found on running #{method.owner}::#{method.name}" unless args.key?(name)
|
|
131
|
+
params_array << args[name]
|
|
132
|
+
when :opt
|
|
133
|
+
# if parameters do not contain the :opt argument, treat it as not specified
|
|
134
|
+
next nonspecified_last_opt = name unless args.key?(name)
|
|
135
|
+
if nonspecified_last_opt
|
|
136
|
+
# if there already exist non-specified :opt arguments, no more specified :opt argument is allowed
|
|
137
|
+
raise Yuuki::Error, "A required argument '#{nonspecified_last_opt}' was not found"\
|
|
138
|
+
" on running #{method.owner}::#{method.name}"" with optional argument '#{name}'"
|
|
139
|
+
end
|
|
140
|
+
params_array << args[name]
|
|
141
|
+
when :rest
|
|
142
|
+
next unless args.key?(name)
|
|
143
|
+
if nonspecified_last_opt
|
|
144
|
+
# if there already exist non-specified :opt arguments, the :rest argument cannot be handled
|
|
145
|
+
raise Yuuki::Error, "A required argument '#{nonspecified_last_opt}' not found"\
|
|
146
|
+
" on running #{method.owner}::#{method.name}"" with rest argument '#{name}'"
|
|
147
|
+
end
|
|
148
|
+
if args[name].respond_to?(:to_ary)
|
|
149
|
+
params_array += args[name]
|
|
150
|
+
else
|
|
151
|
+
params_array << args[name]
|
|
152
|
+
end
|
|
153
|
+
when :keyreq
|
|
154
|
+
raise Yuuki::Error, "A required key argument '#{name}' was not found on running #{method.owner}::#{method.name}" unless args.key?(name)
|
|
155
|
+
params_hash[name] = args[name]
|
|
156
|
+
when :key
|
|
157
|
+
params_hash[name] = args[name] if args.key?(name)
|
|
158
|
+
when :keyrest
|
|
159
|
+
next unless args.key?(name)
|
|
160
|
+
if args[name].respond_to?(:to_hash)
|
|
161
|
+
params_hash.merge!(args[name])
|
|
162
|
+
else
|
|
163
|
+
params_hash[name] = args[name]
|
|
164
|
+
end
|
|
165
|
+
when :block
|
|
166
|
+
params_block = args[name]
|
|
133
167
|
end
|
|
168
|
+
end
|
|
169
|
+
params_block = block unless params.any?{|type, _| type == :block}
|
|
170
|
+
params_hash.empty? ? method[*params_array, ¶ms_block] : method[*params_array, **params_hash, ¶ms_block]
|
|
134
171
|
end
|
|
172
|
+
end
|
|
135
173
|
end
|
data/lib/yuuki/error.rb
CHANGED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'yuuki/caller'
|
|
4
|
+
require 'yuuki/runner'
|
|
5
|
+
|
|
6
|
+
module Yuuki
|
|
7
|
+
module Runner
|
|
8
|
+
# sets interval to the method
|
|
9
|
+
# @param [Symbol] methods method names
|
|
10
|
+
# @param [Integer] interval
|
|
11
|
+
def periodic(*methods, interval)
|
|
12
|
+
@yuuki_methods ||= {}
|
|
13
|
+
methods.each do |method|
|
|
14
|
+
@yuuki_methods[method] ||= {}
|
|
15
|
+
@yuuki_methods[method][:periodic] = interval
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# sets whether the method run at the first time
|
|
20
|
+
# @param [Symbol] methods method names
|
|
21
|
+
# @param [Boolean] enabled
|
|
22
|
+
def first_run(*methods, enabled: true)
|
|
23
|
+
@yuuki_methods ||= {}
|
|
24
|
+
methods.each do |method|
|
|
25
|
+
@yuuki_methods[method] ||= {}
|
|
26
|
+
@yuuki_methods[method][:first_run] = enabled
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
module Yuuki
|
|
33
|
+
# @attr_reader [Boolean] first_run
|
|
34
|
+
# @attr_reader [Float] current_time
|
|
35
|
+
class PeriodicCaller < Caller
|
|
36
|
+
attr_reader :first_run, :current_time
|
|
37
|
+
|
|
38
|
+
def initialize(*instances)
|
|
39
|
+
super
|
|
40
|
+
@first_run = true
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# sets error callback
|
|
44
|
+
# @yield [error]
|
|
45
|
+
# @yieldparam [Exception] error
|
|
46
|
+
def on_error(&block)
|
|
47
|
+
@on_error = block
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# runs the periodic caller
|
|
51
|
+
# @param [Numeric] gmtoff GMT Offset
|
|
52
|
+
# @param [Object] args arguments
|
|
53
|
+
def run(gmtoff = Time.now.gmtoff, **args, &block)
|
|
54
|
+
last_time = nil
|
|
55
|
+
loop do
|
|
56
|
+
@current_time = Time.now.to_f
|
|
57
|
+
begin
|
|
58
|
+
select_proc = proc do |_method, meta|
|
|
59
|
+
next true if @first_run && meta[:first_run]
|
|
60
|
+
next false unless meta[:periodic]
|
|
61
|
+
next false unless last_time
|
|
62
|
+
c = @current_time + gmtoff
|
|
63
|
+
l = last_time + gmtoff
|
|
64
|
+
next true if (l.div(meta[:periodic]) + 1) * meta[:periodic] <= c
|
|
65
|
+
end
|
|
66
|
+
run_select(select_proc, **args, &block)
|
|
67
|
+
rescue
|
|
68
|
+
@on_error ? @on_error[$!] : raise
|
|
69
|
+
end
|
|
70
|
+
@first_run = false
|
|
71
|
+
|
|
72
|
+
last_time = @current_time
|
|
73
|
+
((@current_time + 1).floor - Time.now.to_f).tap{|e| sleep e if e > 0}
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
data/lib/yuuki/runner.rb
CHANGED
|
@@ -1,48 +1,59 @@
|
|
|
1
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
class RunnerBase
|
|
5
|
-
class << self
|
|
6
|
-
private
|
|
7
|
-
|
|
8
|
-
def add(*methods)
|
|
9
|
-
@runner_adds ||= []
|
|
10
|
-
@runner_adds |= methods
|
|
11
|
-
end
|
|
3
|
+
require 'set'
|
|
12
4
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
5
|
+
module Yuuki
|
|
6
|
+
module Runner
|
|
7
|
+
# adds methods to yuuki
|
|
8
|
+
# @param [Symbol] methods method names
|
|
9
|
+
def add(*methods)
|
|
10
|
+
@yuuki_methods ||= {}
|
|
11
|
+
methods.each do |method|
|
|
12
|
+
@yuuki_methods[method] ||= {}
|
|
13
|
+
@yuuki_methods[method][:enabled] = true
|
|
14
|
+
end
|
|
15
|
+
end
|
|
17
16
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
# deletes methods from yuuki
|
|
18
|
+
# @param [Symbol] methods method names
|
|
19
|
+
def delete(*methods)
|
|
20
|
+
@yuuki_methods ||= {}
|
|
21
|
+
methods.each do |method|
|
|
22
|
+
@yuuki_methods[method] ||= {}
|
|
23
|
+
@yuuki_methods[method][:enabled] = false
|
|
24
|
+
end
|
|
25
|
+
end
|
|
24
26
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
# adds tags to the method
|
|
28
|
+
# @param [Symbol] method method name
|
|
29
|
+
# @param [Symbol] tags tag names
|
|
30
|
+
def tag(method, *tags)
|
|
31
|
+
@yuuki_methods ||= {}
|
|
32
|
+
@yuuki_methods[method] ||= {}
|
|
33
|
+
@yuuki_methods[method][:tags] ||= Set.new
|
|
34
|
+
@yuuki_methods[method][:tags].merge(tags)
|
|
35
|
+
end
|
|
32
36
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
# enables threading for the methods
|
|
38
|
+
# @param [Symbol] methods method names
|
|
39
|
+
# @param [Boolean] enabled
|
|
40
|
+
def thread(*methods, enabled: true)
|
|
41
|
+
@yuuki_methods ||= {}
|
|
42
|
+
methods.each do |method|
|
|
43
|
+
@yuuki_methods[method] ||= {}
|
|
44
|
+
@yuuki_methods[method][:thread] = enabled
|
|
45
|
+
end
|
|
46
|
+
end
|
|
40
47
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
48
|
+
# sets priority to the method
|
|
49
|
+
# @param [Symbol] methods method names
|
|
50
|
+
# @param [Numeric] priority
|
|
51
|
+
def priority(*methods, priority)
|
|
52
|
+
@yuuki_methods ||= {}
|
|
53
|
+
methods.each do |method|
|
|
54
|
+
@yuuki_methods[method] ||= {}
|
|
55
|
+
@yuuki_methods[method][:priority] = priority
|
|
56
|
+
end
|
|
47
57
|
end
|
|
58
|
+
end
|
|
48
59
|
end
|
data/lib/yuuki/version.rb
CHANGED
data/lib/yuuki.rb
CHANGED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# TypeProf 0.21.2
|
|
2
|
+
|
|
3
|
+
# Classes
|
|
4
|
+
module Yuuki
|
|
5
|
+
class Caller
|
|
6
|
+
@instances: Set[untyped]
|
|
7
|
+
@threads: Array[Thread]
|
|
8
|
+
|
|
9
|
+
def self.require_dir: (String require_dir, ?recursive: bool) -> void
|
|
10
|
+
def initialize: (*untyped instances) -> void
|
|
11
|
+
def add: (*untyped instances) -> void
|
|
12
|
+
def runners: -> Array[untyped]
|
|
13
|
+
def run: (**untyped) -> void
|
|
14
|
+
def run_select: (^(Method, Hash[Symbol, untyped]) -> bool proc_select, **untyped) -> void
|
|
15
|
+
def run_tag: (*Symbol tags, **untyped) -> void
|
|
16
|
+
def run_method: (Class klass, Symbol method_sig, **untyped) -> void
|
|
17
|
+
def join: -> void
|
|
18
|
+
def alive?: -> bool
|
|
19
|
+
alias running? alive?
|
|
20
|
+
|
|
21
|
+
private
|
|
22
|
+
def run_internal: (Array[untyped] runners, Hash[Symbol, untyped] args) -> void
|
|
23
|
+
def run_method_internal: (Method method, Hash[Symbol, untyped] args) -> void
|
|
24
|
+
end
|
|
25
|
+
end
|
data/sig/yuuki/error.rbs
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# TypeProf 0.21.2
|
|
2
|
+
|
|
3
|
+
# Classes
|
|
4
|
+
module Yuuki
|
|
5
|
+
module Runner
|
|
6
|
+
def periodic: (Symbol method, Integer interval) -> void
|
|
7
|
+
def first_run: (Symbol method, ?enabled: bool) -> void
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
class PeriodicCaller < Caller
|
|
11
|
+
@on_error: Proc
|
|
12
|
+
|
|
13
|
+
attr_reader first_run: bool
|
|
14
|
+
attr_reader current_time: Float
|
|
15
|
+
def initialize: (*untyped instances) -> void
|
|
16
|
+
def on_error: {(Exception) -> void} -> void
|
|
17
|
+
def run: (?Integer gmtoff, **untyped) -> void
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# TypeProf 0.21.2
|
|
2
|
+
|
|
3
|
+
# Classes
|
|
4
|
+
module Yuuki
|
|
5
|
+
module Runner
|
|
6
|
+
@yuuki_methods: Hash[Symbol, Hash[Symbol, untyped]]
|
|
7
|
+
|
|
8
|
+
def add: (*Symbol methods) -> void
|
|
9
|
+
def delete: (*Symbol methods) -> void
|
|
10
|
+
def tag: (Symbol method, *Symbol tags) -> void
|
|
11
|
+
def thread: (*Symbol methods, ?enabled: bool) -> void
|
|
12
|
+
def priority: (*Symbol methods, Numeric priority) -> void
|
|
13
|
+
end
|
|
14
|
+
end
|
data/yuuki.gemspec
CHANGED
|
@@ -1,28 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
|
4
|
+
$:.unshift(lib) unless $:.include?(lib)
|
|
3
5
|
require 'yuuki/version'
|
|
4
6
|
|
|
5
7
|
Gem::Specification.new do |spec|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
spec.name = 'yuuki'
|
|
9
|
+
spec.version = Yuuki::VERSION
|
|
10
|
+
spec.authors = ['Ishotihadus']
|
|
11
|
+
spec.email = ['hanachan.pao@gmail.com']
|
|
10
12
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
spec.summary = 'A caller / runner framework for Ruby'
|
|
14
|
+
spec.description = 'A caller / runner framework for Ruby.'
|
|
15
|
+
spec.homepage = 'https://github.com/ishotihadus/yuuki'
|
|
16
|
+
spec.license = 'MIT'
|
|
15
17
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
`git ls-files -z`.split("\x0").reject
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
# Specify which files should be added to the gem when it is released.
|
|
19
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
20
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
|
21
|
+
`git ls-files -z`.split("\x0").reject{|f| f.match(%r{^(test|spec|features)/})}
|
|
22
|
+
end
|
|
23
|
+
spec.bindir = 'exe'
|
|
24
|
+
spec.executables = spec.files.grep(%r{^exe/}){|f| File.basename(f)}
|
|
25
|
+
spec.require_paths = ['lib']
|
|
24
26
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
spec.add_development_dependency 'bundler'
|
|
28
|
+
spec.add_development_dependency 'pry'
|
|
29
|
+
spec.add_development_dependency 'rake'
|
|
28
30
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: yuuki
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ishotihadus
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2022-04-30 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -25,7 +25,7 @@ dependencies:
|
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
26
|
version: '0'
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
|
-
name:
|
|
28
|
+
name: pry
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
30
30
|
requirements:
|
|
31
31
|
- - ">="
|
|
@@ -39,7 +39,7 @@ dependencies:
|
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
40
|
version: '0'
|
|
41
41
|
- !ruby/object:Gem::Dependency
|
|
42
|
-
name:
|
|
42
|
+
name: rake
|
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
|
44
44
|
requirements:
|
|
45
45
|
- - ">="
|
|
@@ -59,6 +59,7 @@ executables: []
|
|
|
59
59
|
extensions: []
|
|
60
60
|
extra_rdoc_files: []
|
|
61
61
|
files:
|
|
62
|
+
- ".DS_Store"
|
|
62
63
|
- ".gitignore"
|
|
63
64
|
- Gemfile
|
|
64
65
|
- LICENSE.txt
|
|
@@ -69,14 +70,20 @@ files:
|
|
|
69
70
|
- lib/yuuki.rb
|
|
70
71
|
- lib/yuuki/caller.rb
|
|
71
72
|
- lib/yuuki/error.rb
|
|
73
|
+
- lib/yuuki/periodic.rb
|
|
72
74
|
- lib/yuuki/runner.rb
|
|
73
75
|
- lib/yuuki/version.rb
|
|
76
|
+
- sig/yuuki/caller.rbs
|
|
77
|
+
- sig/yuuki/error.rbs
|
|
78
|
+
- sig/yuuki/periodic.rbs
|
|
79
|
+
- sig/yuuki/runner.rbs
|
|
80
|
+
- sig/yuuki/version.rbs
|
|
74
81
|
- yuuki.gemspec
|
|
75
82
|
homepage: https://github.com/ishotihadus/yuuki
|
|
76
83
|
licenses:
|
|
77
84
|
- MIT
|
|
78
85
|
metadata: {}
|
|
79
|
-
post_install_message:
|
|
86
|
+
post_install_message:
|
|
80
87
|
rdoc_options: []
|
|
81
88
|
require_paths:
|
|
82
89
|
- lib
|
|
@@ -91,8 +98,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
91
98
|
- !ruby/object:Gem::Version
|
|
92
99
|
version: '0'
|
|
93
100
|
requirements: []
|
|
94
|
-
rubygems_version: 3.
|
|
95
|
-
signing_key:
|
|
101
|
+
rubygems_version: 3.3.3
|
|
102
|
+
signing_key:
|
|
96
103
|
specification_version: 4
|
|
97
104
|
summary: A caller / runner framework for Ruby
|
|
98
105
|
test_files: []
|