cuco 0.1.4 → 0.1.5
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/bin/cuco.bak +20 -0
- data/lib/cuco/controller.rb +2 -1
- data/lib/cuco/controller.rb.bak +66 -0
- data/lib/cuco/script.rb.bak +16 -0
- data/lib/cuco/version.rb +2 -1
- data/lib/cuco/version.rb.bak +12 -0
- metadata +7 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: da43539e4975102b7ac2d30a329f21d244bb8ffa4ed09c8dc4823111add7f120
|
|
4
|
+
data.tar.gz: fca413743949d03ad50227b8bb747a473360fe744d6cf025a1fa8d9da204a175
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: dfc93f2adcf8af167b5f279394fd4fa02d4ef0d3ff8ef23c388a96be95cb182cc911bc6561cf63e3b6d35a87bdbbd5bbfe7e4462cfecc8aea8d857c9354f3db2
|
|
7
|
+
data.tar.gz: 8d116846524b8fa3fc2cafca48570fbcf31c49e4d1310d821e3496aabdcaefa5a2e6aa71e6b23305e769138da4cd74f23864f52d072d0da8e4a8a9520034d922
|
data/bin/cuco.bak
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
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
CHANGED
|
@@ -0,0 +1,66 @@
|
|
|
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
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
data/lib/cuco/version.rb
CHANGED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
module Cuco
|
|
2
|
+
VERSION = "0.1.4" # 2025-06-21
|
|
3
|
+
# VERSION = "0.1.3" # 2025-05-28
|
|
4
|
+
# VERSION = "0.1.2" # 2024-05-21
|
|
5
|
+
# VERSION = "0.1.1" # 2024-03-23
|
|
6
|
+
# VERSION = "0.1.0" # 2024-03-18
|
|
7
|
+
# VERSION = "0.0.8" # 2024-03-18
|
|
8
|
+
# VERSION = "0.0.7" # 2024-03-18
|
|
9
|
+
# VERSION = "0.0.3" # 2024-03-12
|
|
10
|
+
# VERSION = "0.0.2" # 2024-03-11
|
|
11
|
+
# VERSION = "0.0.1" # 2024-03-05
|
|
12
|
+
end
|
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.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Dittmar Krall
|
|
@@ -77,10 +77,14 @@ files:
|
|
|
77
77
|
- MIT-LICENSE
|
|
78
78
|
- README.md
|
|
79
79
|
- bin/cuco
|
|
80
|
+
- bin/cuco.bak
|
|
80
81
|
- lib/cuco/controller.rb
|
|
82
|
+
- lib/cuco/controller.rb.bak
|
|
81
83
|
- lib/cuco/cuco.rb
|
|
82
84
|
- lib/cuco/script.rb
|
|
85
|
+
- lib/cuco/script.rb.bak
|
|
83
86
|
- lib/cuco/version.rb
|
|
87
|
+
- lib/cuco/version.rb.bak
|
|
84
88
|
homepage: http://www.matiq.de
|
|
85
89
|
licenses:
|
|
86
90
|
- MIT
|
|
@@ -90,7 +94,7 @@ require_paths:
|
|
|
90
94
|
- lib
|
|
91
95
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
92
96
|
requirements:
|
|
93
|
-
- - "
|
|
97
|
+
- - ">="
|
|
94
98
|
- !ruby/object:Gem::Version
|
|
95
99
|
version: '3'
|
|
96
100
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
@@ -99,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
99
103
|
- !ruby/object:Gem::Version
|
|
100
104
|
version: '0'
|
|
101
105
|
requirements: []
|
|
102
|
-
rubygems_version:
|
|
106
|
+
rubygems_version: 4.0.3
|
|
103
107
|
specification_version: 4
|
|
104
108
|
summary: A file watcher
|
|
105
109
|
test_files: []
|