chores_kit 0.2.3 → 0.2.4
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/.rubocop.yml +3 -0
- data/Gemfile.lock +17 -1
- data/bin/rubocop +29 -0
- data/chores_kit.gemspec +1 -0
- data/lib/chores_kit/chore/embedded_task.rb +29 -0
- data/lib/chores_kit/chore/notification.rb +2 -0
- data/lib/chores_kit/chore/task.rb +3 -2
- data/lib/chores_kit/chore.rb +18 -6
- data/lib/chores_kit/dag/dag.rb +7 -3
- data/lib/chores_kit/definition_proxy.rb +2 -0
- data/lib/chores_kit/version.rb +1 -1
- data/lib/chores_kit.rb +2 -2
- metadata +18 -3
- data/lib/chores_kit/dag/vertex.rb +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 19ec873d34bb484993376797e28863ff73d6c94cb05620dfcc30cc4e0d87b0cc
|
4
|
+
data.tar.gz: b62cf334ae1f2bbe2b67c545ebda1a58c780a9c2796db50b76f17d4e470956c0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b487d0884cabbb4d686dbc8728bb7b4bfb87035c6493daad774322d158b6bf4595f30e20de0087b817a994430eef84a1f20ab58308e712233b831611c5253bc
|
7
|
+
data.tar.gz: 8751c3ad24e492571dec91d7300c6b5799aa8168e0b915f61d2aab005c4191ea2d42c439e43ebcf468ccef6beb126a4d987f984c152bdebb86da4eec637df377
|
data/.rubocop.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
chores_kit (0.2.
|
4
|
+
chores_kit (0.2.4)
|
5
5
|
as-duration (~> 0.1.1)
|
6
6
|
dag (~> 0.0.9)
|
7
7
|
|
@@ -9,9 +9,15 @@ GEM
|
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
11
|
as-duration (0.1.1)
|
12
|
+
ast (2.4.0)
|
12
13
|
byebug (10.0.0)
|
13
14
|
dag (0.0.9)
|
14
15
|
diff-lcs (1.3)
|
16
|
+
parallel (1.12.1)
|
17
|
+
parser (2.5.0.4)
|
18
|
+
ast (~> 2.4.0)
|
19
|
+
powerpack (0.1.1)
|
20
|
+
rainbow (3.0.0)
|
15
21
|
rake (10.5.0)
|
16
22
|
rspec (3.7.0)
|
17
23
|
rspec-core (~> 3.7.0)
|
@@ -26,6 +32,15 @@ GEM
|
|
26
32
|
diff-lcs (>= 1.2.0, < 2.0)
|
27
33
|
rspec-support (~> 3.7.0)
|
28
34
|
rspec-support (3.7.1)
|
35
|
+
rubocop (0.53.0)
|
36
|
+
parallel (~> 1.10)
|
37
|
+
parser (>= 2.5)
|
38
|
+
powerpack (~> 0.1)
|
39
|
+
rainbow (>= 2.2.2, < 4.0)
|
40
|
+
ruby-progressbar (~> 1.7)
|
41
|
+
unicode-display_width (~> 1.0, >= 1.0.1)
|
42
|
+
ruby-progressbar (1.9.0)
|
43
|
+
unicode-display_width (1.3.0)
|
29
44
|
|
30
45
|
PLATFORMS
|
31
46
|
ruby
|
@@ -36,6 +51,7 @@ DEPENDENCIES
|
|
36
51
|
chores_kit!
|
37
52
|
rake (~> 10.0)
|
38
53
|
rspec (~> 3.0)
|
54
|
+
rubocop (~> 0.53.0)
|
39
55
|
|
40
56
|
BUNDLED WITH
|
41
57
|
1.16.1
|
data/bin/rubocop
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'rubocop' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 150) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("rubocop", "rubocop")
|
data/chores_kit.gemspec
CHANGED
@@ -0,0 +1,29 @@
|
|
1
|
+
module ChoresKit
|
2
|
+
module EmbeddedTask
|
3
|
+
def name
|
4
|
+
task.name
|
5
|
+
end
|
6
|
+
|
7
|
+
def run
|
8
|
+
puts "Running task #{name}"
|
9
|
+
task.run
|
10
|
+
|
11
|
+
return unless successors
|
12
|
+
|
13
|
+
Thread.abort_on_exception = true
|
14
|
+
threads = []
|
15
|
+
|
16
|
+
threads << Thread.new do
|
17
|
+
successors.map(&:run)
|
18
|
+
end
|
19
|
+
|
20
|
+
threads.map(&:join)
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def task
|
26
|
+
self[:task]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -2,13 +2,14 @@ module ChoresKit
|
|
2
2
|
class Task
|
3
3
|
attr_reader :name
|
4
4
|
|
5
|
-
def initialize(name, args
|
5
|
+
def initialize(name, *args)
|
6
6
|
@name = name
|
7
7
|
@args = args
|
8
|
-
@command = block
|
9
8
|
end
|
10
9
|
|
10
|
+
# rubocop:disable Style/MethodMissing
|
11
11
|
def method_missing(name, *args)
|
12
12
|
end
|
13
|
+
# rubocop:enable Style/MethodMissing
|
13
14
|
end
|
14
15
|
end
|
data/lib/chores_kit/chore.rb
CHANGED
@@ -5,15 +5,15 @@ require 'as-duration'
|
|
5
5
|
|
6
6
|
module ChoresKit
|
7
7
|
class Chore
|
8
|
-
attr_reader :name
|
8
|
+
attr_reader :name
|
9
9
|
|
10
|
-
DEFAULT_NOTIFICATIONS = [
|
10
|
+
DEFAULT_NOTIFICATIONS = %i[successful failed].freeze
|
11
11
|
|
12
12
|
def initialize(name)
|
13
13
|
@name = name
|
14
14
|
@metadata = {}
|
15
15
|
|
16
|
-
@dag = DAG.new
|
16
|
+
@dag = DAG.new(mixin: EmbeddedTask)
|
17
17
|
@tasks = @dag.vertices
|
18
18
|
|
19
19
|
@notifications = {}
|
@@ -24,6 +24,7 @@ module ChoresKit
|
|
24
24
|
@metadata[:description] = string
|
25
25
|
end
|
26
26
|
|
27
|
+
# rubocop:disable Metrics/AbcSize
|
27
28
|
def schedule(options)
|
28
29
|
raise "Couldn't parse start time from attributes" if options[:at].nil?
|
29
30
|
raise "Couldn't parse interval from attributes" unless options[:every].nil? || options[:every].is_a?(AS::Duration)
|
@@ -36,6 +37,7 @@ module ChoresKit
|
|
36
37
|
every: options[:every]
|
37
38
|
}
|
38
39
|
end
|
40
|
+
# rubocop:enable Metrics/AbcSize
|
39
41
|
|
40
42
|
def retry_failed(options)
|
41
43
|
raise "Couldn't parse retry interval from attributes" unless options[:wait].nil? || options[:wait].is_a?(AS::Duration)
|
@@ -56,9 +58,13 @@ module ChoresKit
|
|
56
58
|
raise "Couldn't create task without a name" if name.nil?
|
57
59
|
raise "Couldn't create task without a block" unless block_given?
|
58
60
|
|
59
|
-
|
61
|
+
task = Task.new(name, params)
|
62
|
+
task.instance_eval(&block)
|
63
|
+
|
64
|
+
@dag.add_vertex(name: name, task: task)
|
60
65
|
end
|
61
66
|
|
67
|
+
# rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
|
62
68
|
def run(task, options = {})
|
63
69
|
from = options[:triggered_by] || options[:upstream] || task
|
64
70
|
to = options[:triggers] || options[:downstream] || task
|
@@ -74,14 +80,20 @@ module ChoresKit
|
|
74
80
|
raise "Multiple upstream tasks aren't supported" if from.is_a?(Array)
|
75
81
|
raise "Multiple downstream tasks aren't supported" if to.is_a?(Array)
|
76
82
|
|
77
|
-
#
|
78
|
-
|
83
|
+
# Set explicit root task and skip further processing if the Chore has
|
84
|
+
# just one task defined or if only one of its tasks is set to run
|
85
|
+
if tasks.one? || from == to
|
86
|
+
@dag.root = @dag.find_by(name: from)
|
87
|
+
return
|
88
|
+
end
|
79
89
|
|
80
90
|
v1 = @dag.vertices.detect { |vertex| vertex[:name] == from }
|
81
91
|
v2 = @dag.vertices.detect { |vertex| vertex[:name] == to }
|
82
92
|
|
83
93
|
@dag.add_edge(from: v1, to: v2)
|
94
|
+
@dag.root = v1
|
84
95
|
end
|
96
|
+
# rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
|
85
97
|
|
86
98
|
# After-run callbacks
|
87
99
|
def notify(*options, &block)
|
data/lib/chores_kit/dag/dag.rb
CHANGED
@@ -3,11 +3,15 @@ require 'dag'
|
|
3
3
|
module ChoresKit
|
4
4
|
class DAG < ::DAG
|
5
5
|
def root
|
6
|
-
@vertices.detect { |v| v.ancestors.empty? }
|
6
|
+
@root ||= @vertices.detect { |v| v.ancestors.empty? }
|
7
7
|
end
|
8
8
|
|
9
|
-
def
|
10
|
-
@vertices
|
9
|
+
def find_by(name:)
|
10
|
+
@vertices.detect { |v| v.name == name }
|
11
|
+
end
|
12
|
+
|
13
|
+
def root=(vertex)
|
14
|
+
@root = vertex
|
11
15
|
end
|
12
16
|
end
|
13
17
|
end
|
@@ -6,6 +6,7 @@ module ChoresKit
|
|
6
6
|
@chore = Chore.new(name)
|
7
7
|
end
|
8
8
|
|
9
|
+
# rubocop:disable Style/MethodMissing
|
9
10
|
def method_missing(name, *args, &block)
|
10
11
|
args = {} if args.empty?
|
11
12
|
|
@@ -15,5 +16,6 @@ module ChoresKit
|
|
15
16
|
@chore.send(name, *args)
|
16
17
|
end
|
17
18
|
end
|
19
|
+
# rubocop:enable Style/MethodMissing
|
18
20
|
end
|
19
21
|
end
|
data/lib/chores_kit/version.rb
CHANGED
data/lib/chores_kit.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
require 'chores_kit/dag/dag'
|
2
|
-
require 'chores_kit/dag/vertex'
|
3
2
|
|
4
3
|
require 'chores_kit/chore'
|
5
|
-
require 'chores_kit/chore/
|
4
|
+
require 'chores_kit/chore/embedded_task'
|
6
5
|
require 'chores_kit/chore/notification'
|
6
|
+
require 'chores_kit/chore/task'
|
7
7
|
require 'chores_kit/definition_proxy'
|
8
8
|
require 'chores_kit/chores'
|
9
9
|
require 'chores_kit/version'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chores_kit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lennard Timm
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03-
|
11
|
+
date: 2018-03-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: as-duration
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '3.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rubocop
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 0.53.0
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 0.53.0
|
97
111
|
description:
|
98
112
|
email:
|
99
113
|
- hi@lenn4rd.io
|
@@ -113,15 +127,16 @@ files:
|
|
113
127
|
- bin/console
|
114
128
|
- bin/rake
|
115
129
|
- bin/rspec
|
130
|
+
- bin/rubocop
|
116
131
|
- bin/setup
|
117
132
|
- chores_kit.gemspec
|
118
133
|
- lib/chores_kit.rb
|
119
134
|
- lib/chores_kit/chore.rb
|
135
|
+
- lib/chores_kit/chore/embedded_task.rb
|
120
136
|
- lib/chores_kit/chore/notification.rb
|
121
137
|
- lib/chores_kit/chore/task.rb
|
122
138
|
- lib/chores_kit/chores.rb
|
123
139
|
- lib/chores_kit/dag/dag.rb
|
124
|
-
- lib/chores_kit/dag/vertex.rb
|
125
140
|
- lib/chores_kit/definition_proxy.rb
|
126
141
|
- lib/chores_kit/version.rb
|
127
142
|
homepage: https://github.com/lenn4rd/chores_kit
|