sublayer 0.1.0.pre.alpha.2 → 0.1.0.pre.alpha.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sublayer/agents/base.rb +47 -0
- data/lib/sublayer/version.rb +1 -1
- data/lib/sublayer.rb +2 -0
- data/sublayer.gemspec +1 -0
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 80d1bcf936b12b7638feb1ddc87d0369dd7438f535837e0c0353ffa4e717a9ac
|
4
|
+
data.tar.gz: a2113a776870928e115e62a318e29e149ecc791633ad7b47f218a9f4d3df75ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee8d2b20c430e814e400a224f351ac0dd8d4f4e0428f30fc490a3085d40f3fd1e3112044ab9365d4373e4ce1e4035a3a5acf58522fb9d63ec17abc75daa9efff
|
7
|
+
data.tar.gz: 5c35b019b2e111f935f171fce4d22681195cc0c9d4f40f066283497cd5a99e090505dd8acfc05a3dabd7c241f8455c4c32a2b3916f4f71eb14c1c1f34b235abb
|
data/lib/sublayer/agents/base.rb
CHANGED
@@ -1,6 +1,53 @@
|
|
1
1
|
module Sublayer
|
2
2
|
module Agents
|
3
3
|
class Base
|
4
|
+
class << self
|
5
|
+
attr_accessor :goal_condition_block, :trigger_condition_block, :trigger_on_files_changed_block, :check_status_block, :step_block
|
6
|
+
|
7
|
+
def trigger_condition(&block)
|
8
|
+
self.trigger_condition_block = block
|
9
|
+
end
|
10
|
+
|
11
|
+
def trigger_on_files_changed(&block)
|
12
|
+
self.trigger_on_files_changed_block = block
|
13
|
+
end
|
14
|
+
|
15
|
+
def goal_condition(&block)
|
16
|
+
self.goal_condition_block = block
|
17
|
+
end
|
18
|
+
|
19
|
+
def check_status(&block)
|
20
|
+
self.check_status_block = block
|
21
|
+
end
|
22
|
+
|
23
|
+
def step(&block)
|
24
|
+
self.step_block = block
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def run
|
29
|
+
files_to_listen_to = instance_eval(&self.class.trigger_on_files_changed_block).map { |file| File.expand_path(file) }
|
30
|
+
folders = files_to_listen_to.map { |file| File.dirname(file) }.uniq
|
31
|
+
|
32
|
+
listener = Listen.to(*folders) do |modified, added, removed|
|
33
|
+
if files_to_listen_to.any? { |file| modified.include?(file) }
|
34
|
+
take_step
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
listener.start
|
39
|
+
|
40
|
+
take_step
|
41
|
+
|
42
|
+
sleep
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def take_step
|
48
|
+
instance_eval(&self.class.check_status_block)
|
49
|
+
instance_eval(&self.class.step_block) unless instance_eval(&self.class.goal_condition_block)
|
50
|
+
end
|
4
51
|
end
|
5
52
|
end
|
6
53
|
end
|
data/lib/sublayer/version.rb
CHANGED
data/lib/sublayer.rb
CHANGED
data/sublayer.gemspec
CHANGED
@@ -36,6 +36,7 @@ Gem::Specification.new do |spec|
|
|
36
36
|
spec.add_dependency "zeitwerk"
|
37
37
|
spec.add_dependency "nokogiri", "~> 1.16.5"
|
38
38
|
spec.add_dependency "httparty"
|
39
|
+
spec.add_dependency "listen"
|
39
40
|
|
40
41
|
spec.add_development_dependency "rspec", "~> 3.12"
|
41
42
|
spec.add_development_dependency "pry", "~> 0.14"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sublayer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.0.pre.alpha.
|
4
|
+
version: 0.1.0.pre.alpha.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Scott Werner
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: listen
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: rspec
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|