cuco 0.1.5 → 0.1.8
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/MIT-LICENSE +1 -1
- data/README.md +1 -1
- data/lib/cuco/controller.rb +2 -2
- data/lib/cuco/version.rb +3 -1
- data/lib/cuco/version.rb.bak +4 -1
- metadata +16 -5
- data/bin/cuco.bak +0 -20
- data/lib/cuco/controller.rb.bak +0 -66
- data/lib/cuco/script.rb.bak +0 -16
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 170a17c7fb9c122b0308d11cd3d1da6a9af94a1fb6ec3ff5a7d1c73545f3a125
|
|
4
|
+
data.tar.gz: e2a66d97e7ce648d003b24cd55314765c88deae7ba064e5ead72100b5d332afd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a96e3539b23c5cc3805f2640e0423b7eccd6e4db658dae160c36da20d9241561d493cc7707b4f1e624870aff232212dc52a7aea6b5c1288ba293d0fa414c964e
|
|
7
|
+
data.tar.gz: 21be157050b093ca131478fe9ab93b5076d3b94bee7aaaf06fbb93ddf6f6f5b2a041b78db88cc77797d5e31c0e4bd4d3d7875f1e99246ab24c82ce2e876a76d9
|
data/MIT-LICENSE
CHANGED
data/README.md
CHANGED
|
@@ -83,5 +83,5 @@ See directory _scripts_ for samples.
|
|
|
83
83
|
* gem watchr
|
|
84
84
|
* gem observr (a follow-up of gem watchr)
|
|
85
85
|
|
|
86
|
-
Copyright (c) 2024-
|
|
86
|
+
Copyright (c) 2024-2026 Dittmar Krall (www.matiq.com),
|
|
87
87
|
released under the [MIT license](https://opensource.org/licenses/MIT).
|
data/lib/cuco/controller.rb
CHANGED
data/lib/cuco/version.rb
CHANGED
data/lib/cuco/version.rb.bak
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
module Cuco
|
|
2
|
-
VERSION = "0.1.
|
|
2
|
+
VERSION = "0.1.7" # 2026-04-07
|
|
3
|
+
# VERSION = "0.1.6" # 2025-12-28
|
|
4
|
+
# VERSION = "0.1.5" # 2025-12-28
|
|
5
|
+
# VERSION = "0.1.4" # 2025-06-21
|
|
3
6
|
# VERSION = "0.1.3" # 2025-05-28
|
|
4
7
|
# VERSION = "0.1.2" # 2024-05-21
|
|
5
8
|
# VERSION = "0.1.1" # 2024-03-23
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: cuco
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.8
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Dittmar Krall
|
|
@@ -23,6 +23,20 @@ dependencies:
|
|
|
23
23
|
- - ">="
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
25
|
version: '0'
|
|
26
|
+
- !ruby/object:Gem::Dependency
|
|
27
|
+
name: logger
|
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
|
29
|
+
requirements:
|
|
30
|
+
- - ">="
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '0'
|
|
33
|
+
type: :runtime
|
|
34
|
+
prerelease: false
|
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - ">="
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: '0'
|
|
26
40
|
- !ruby/object:Gem::Dependency
|
|
27
41
|
name: micro-optparse
|
|
28
42
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -77,12 +91,9 @@ files:
|
|
|
77
91
|
- MIT-LICENSE
|
|
78
92
|
- README.md
|
|
79
93
|
- bin/cuco
|
|
80
|
-
- bin/cuco.bak
|
|
81
94
|
- lib/cuco/controller.rb
|
|
82
|
-
- lib/cuco/controller.rb.bak
|
|
83
95
|
- lib/cuco/cuco.rb
|
|
84
96
|
- lib/cuco/script.rb
|
|
85
|
-
- lib/cuco/script.rb.bak
|
|
86
97
|
- lib/cuco/version.rb
|
|
87
98
|
- lib/cuco/version.rb.bak
|
|
88
99
|
homepage: http://www.matiq.de
|
|
@@ -103,7 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
103
114
|
- !ruby/object:Gem::Version
|
|
104
115
|
version: '0'
|
|
105
116
|
requirements: []
|
|
106
|
-
rubygems_version: 4.0.
|
|
117
|
+
rubygems_version: 4.0.6
|
|
107
118
|
specification_version: 4
|
|
108
119
|
summary: A file watcher
|
|
109
120
|
test_files: []
|
data/bin/cuco.bak
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
#! /usr/bin/env ruby
|
|
2
|
-
|
|
3
|
-
lib = File.expand_path("../lib/", __dir__)
|
|
4
|
-
$LOAD_PATH.unshift lib unless $LOAD_PATH.include?(lib)
|
|
5
|
-
|
|
6
|
-
require "cuco/version"
|
|
7
|
-
require "cuco/cuco"
|
|
8
|
-
require "cuco/controller"
|
|
9
|
-
require "micro-optparse"
|
|
10
|
-
|
|
11
|
-
options = Parser.new do |p|
|
|
12
|
-
p.banner = "Usage: cuco [options] [.watchr] # a file watcher"
|
|
13
|
-
p.version = "cuco #{Cuco::VERSION}"
|
|
14
|
-
p.option :debug, "Debugging output", default: false
|
|
15
|
-
end.process!
|
|
16
|
-
|
|
17
|
-
G.init(options, ARGV)
|
|
18
|
-
|
|
19
|
-
G.script = Script.new File.read(G.scriptname)
|
|
20
|
-
Controller.instance.run
|
data/lib/cuco/controller.rb.bak
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
require "listen"
|
|
2
|
-
require "singleton"
|
|
3
|
-
require "cuco/cuco"
|
|
4
|
-
require "cuco/script"
|
|
5
|
-
|
|
6
|
-
class Controller
|
|
7
|
-
include Singleton
|
|
8
|
-
|
|
9
|
-
attr_reader :listener
|
|
10
|
-
|
|
11
|
-
def run
|
|
12
|
-
puts "*** Controller.run" if debug
|
|
13
|
-
@listener = Listen.to(".") do |modified, added, removed|
|
|
14
|
-
run_files(modified, :modified)
|
|
15
|
-
run_files(added, :added)
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
@listener.start
|
|
19
|
-
puts "*** Listen started" if debug
|
|
20
|
-
sleep
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def stop
|
|
24
|
-
puts "*** Controller.stop" if debug
|
|
25
|
-
@listener&.stop
|
|
26
|
-
G.script = nil
|
|
27
|
-
@listener = nil
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def run_files(files, type)
|
|
31
|
-
puts "*** Controller.run_files(#{files}, #{type})" if debug
|
|
32
|
-
if files.include?(G.scriptname)
|
|
33
|
-
G.script = Script.new File.read(G.scriptname)
|
|
34
|
-
return
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
files.map! { |filename| filename[G.pwd_length + 1..] }
|
|
38
|
-
files.each { |filename| file_run(filename, type) }
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
def file_run(pattern, type = nil)
|
|
42
|
-
puts "*** file_run(#{pattern}, #{type})" if debug
|
|
43
|
-
rules = find_rules(pattern, type)
|
|
44
|
-
rules.each { |rule| match_run(rule, pattern) }
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
private
|
|
48
|
-
|
|
49
|
-
def find_rules(pattern, type)
|
|
50
|
-
puts "*** find_rules(#{pattern}, #{type})" if debug
|
|
51
|
-
G.script.__rules.reverse.select { |rule|
|
|
52
|
-
pattern.match(rule.pattern) &&
|
|
53
|
-
(rule.event_type.nil? || rule.event_type == type)
|
|
54
|
-
}
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
def match_run(rule, pattern)
|
|
58
|
-
md = pattern.match(rule.pattern)
|
|
59
|
-
puts "*** match_run #{rule}" if debug
|
|
60
|
-
rule.proc.call(md) if md
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
def debug
|
|
64
|
-
G.options[:debug]
|
|
65
|
-
end
|
|
66
|
-
end
|
data/lib/cuco/script.rb.bak
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
class Script
|
|
2
|
-
attr_accessor :__rules
|
|
3
|
-
|
|
4
|
-
def initialize(str)
|
|
5
|
-
@__rules = []
|
|
6
|
-
|
|
7
|
-
instance_eval str
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def watch(pattern, type = nil, &block)
|
|
11
|
-
@__rules << Rule.new(pattern, type, block)
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
# $ sudo sh -c "echo fs.inotify.max_user_watches=524288 >> /etc/sysctl.conf"
|
|
16
|
-
# $ sudo sysctl -p
|