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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aaff1cafef6e0987bf8da2abdd710698579dcdc6dad6342ff3c96a0c4c3658c9
4
- data.tar.gz: cadcfea3f989a281a24727789e8d5fce6f3353c88a0a06763c75e1cb19873a44
3
+ metadata.gz: 80d1bcf936b12b7638feb1ddc87d0369dd7438f535837e0c0353ffa4e717a9ac
4
+ data.tar.gz: a2113a776870928e115e62a318e29e149ecc791633ad7b47f218a9f4d3df75ca
5
5
  SHA512:
6
- metadata.gz: 35fbfcaf0a12f16f596ae254f40c0cc694253e4f26a42b0a8356e720700e2032be60b9b62e9728c66b5bd81c5e466e745a3d4336999ebe9ec85541a4dde6d35b
7
- data.tar.gz: ad74821c9ac29108fa6969729427d9bd6d6f359119f1456fe942bc944594a2eba0824a106a6623f77708341f8b2d6a020bbef5145b8f168aa8549d6fce2160f9
6
+ metadata.gz: ee8d2b20c430e814e400a224f351ac0dd8d4f4e0428f30fc490a3085d40f3fd1e3112044ab9365d4373e4ce1e4035a3a5acf58522fb9d63ec17abc75daa9efff
7
+ data.tar.gz: 5c35b019b2e111f935f171fce4d22681195cc0c9d4f40f066283497cd5a99e090505dd8acfc05a3dabd7c241f8455c4c32a2b3916f4f71eb14c1c1f34b235abb
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Sublayer
4
- VERSION = "0.1.0-alpha.2"
4
+ VERSION = "0.1.0-alpha.3"
5
5
  end
data/lib/sublayer.rb CHANGED
@@ -8,6 +8,8 @@ require 'ostruct'
8
8
  require "httparty"
9
9
  require "openai"
10
10
  require "nokogiri"
11
+ require "listen"
12
+
11
13
  require_relative "sublayer/version"
12
14
 
13
15
  loader = Zeitwerk::Loader.for_gem
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.2
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