cuco 0.1.1 → 0.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5342bb409b3bd1e9febe557662bf308acc1ae727911401b4be2a0d0d8fb06c07
4
- data.tar.gz: 4948f0decd177693378761e046875a2808d4af80cfd0b17d5166aedfa4fb326c
3
+ metadata.gz: 7caa6f2db505a694828f8617ab2f84cfc8807e859e6a224f85da20c47baa7bf0
4
+ data.tar.gz: a37b963ca861435eec245de81b4e5f63e5ac3aa7e63f1ae262c96bc7a3471a50
5
5
  SHA512:
6
- metadata.gz: 6d0c34c445d0ac41e63589a8e240f2bf3b6fcdc3414b6f060009004b14bd720428a2c331637c8df9554ba73d824e76f25f54a52a9f245ca2f844abcf7a67e71e
7
- data.tar.gz: 9a9a183c7ee4aff77eb749797792cb7b686d490453ab92c72b6a3f03ecc2c331c723c69e4fd74f1f6f3bac40e556267d848eaf57a6c1761d4b7352c94c5aa8bc
6
+ metadata.gz: 69a8be2228d6913c8f0522d2f67a2053539f87fd786389d814367d77c2d4d99ab36a90f67bfc35b5e122ed0e9333e56a943cfdbb9b82448e37453c57d5b2eebc
7
+ data.tar.gz: 8a4cb238abdcd19ffbee6af5ebb3ad6e25bb41bb92b29b3cd17c46feb8d1ab1c8a86a72ddfb4cb47a3e8478c63e9a2f4c6bce77ccafb87f0aaebf9737bf4e86d
data/README.md CHANGED
@@ -72,6 +72,8 @@ since the whole command is custom.
72
72
  The above actions could just as easily call "jruby", "ruby --rubygems",
73
73
  "ruby -I lib", etc. or any combination of these.
74
74
 
75
+ See directory _scripts_ for samples.
76
+
75
77
  ## Miscellaneous
76
78
 
77
79
  *Cuco* is heavily inspired by:
data/bin/cuco CHANGED
@@ -3,9 +3,9 @@
3
3
  lib = File.expand_path("../lib/", __dir__)
4
4
  $LOAD_PATH.unshift lib unless $LOAD_PATH.include?(lib)
5
5
 
6
- require "version"
7
- require "cuco"
8
- require "controller"
6
+ require "cuco/version"
7
+ require "cuco/cuco"
8
+ require "cuco/controller"
9
9
  require "micro-optparse"
10
10
 
11
11
  options = Parser.new do |p|
@@ -1,7 +1,7 @@
1
1
  require "listen"
2
2
  require "singleton"
3
- require "cuco"
4
- require "script"
3
+ require "cuco/cuco"
4
+ require "cuco/script"
5
5
 
6
6
  class Controller
7
7
  include Singleton
@@ -1,5 +1,6 @@
1
1
  module Cuco
2
- VERSION = "0.1.1" # 2024-03-23
2
+ VERSION = "0.1.2" # 2024-05-21
3
+ # VERSION = "0.1.1" # 2024-03-23
3
4
  # VERSION = "0.1.0" # 2024-03-18
4
5
  # VERSION = "0.0.8" # 2024-03-18
5
6
  # VERSION = "0.0.7" # 2024-03-18
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cuco
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dittmar Krall
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-03-23 00:00:00.000000000 Z
11
+ date: 2024-05-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: micro-optparse
@@ -71,29 +71,17 @@ email: dittmar.krall@matiq.de
71
71
  executables:
72
72
  - cuco
73
73
  extensions: []
74
- extra_rdoc_files: []
74
+ extra_rdoc_files:
75
+ - README.md
76
+ - MIT-LICENSE
75
77
  files:
76
- - ".github/workflows/rake.yml"
77
- - ".ruby-gemset"
78
- - ".ruby-version"
79
- - ".watchr"
80
- - Gemfile
81
- - Gemfile.lock
82
- - LICENSE-MIT
78
+ - MIT-LICENSE
83
79
  - README.md
84
- - Rakefile
85
80
  - bin/cuco
86
- - cuco.gemspec
87
- - lib/controller.rb
88
- - lib/cuco.rb
89
- - lib/script.rb
90
- - lib/version.rb
91
- - test/controller2_test.rb
92
- - test/controller_test.rb
93
- - test/coverage_test.rb
94
- - test/cuco_test.rb
95
- - test/script_test.rb
96
- - test/test_helper.rb
81
+ - lib/cuco/controller.rb
82
+ - lib/cuco/cuco.rb
83
+ - lib/cuco/script.rb
84
+ - lib/cuco/version.rb
97
85
  homepage: http://www.matiq.de
98
86
  licenses:
99
87
  - MIT
@@ -113,7 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
113
101
  - !ruby/object:Gem::Version
114
102
  version: '0'
115
103
  requirements: []
116
- rubygems_version: 3.5.6
104
+ rubygems_version: 3.5.9
117
105
  signing_key:
118
106
  specification_version: 4
119
107
  summary: A file watcher
@@ -1,31 +0,0 @@
1
- # see also https://github.com/whitequark/parser/blob/master/.github/workflows/test.yml
2
- name: Rake
3
-
4
- on: [push]
5
-
6
- jobs:
7
- test:
8
- strategy:
9
- fail-fast: false
10
- matrix:
11
- os: [ubuntu-latest]
12
- ruby: ["3.0", 3.3]
13
- test_command: ["bundle exec rake"]
14
- runs-on: ${{ matrix.os }}
15
-
16
- steps:
17
- - uses: actions/checkout@v3
18
- - name: Set up Ruby
19
- uses: ruby/setup-ruby@v1
20
- with:
21
- ruby-version: ${{ matrix.ruby_version }}
22
- # bundler-cache: true
23
- # - name: Build and test with Rake
24
- # run: bundle exec rake
25
- - name: Bundle install
26
- run: |
27
- bundle config path /home/runner/bundle
28
- bundle install
29
- bundle update
30
- - name: test with Rake
31
- run: ${{ matrix.test_command }}
data/.ruby-gemset DELETED
@@ -1 +0,0 @@
1
- rails-7.1
data/.ruby-version DELETED
@@ -1 +0,0 @@
1
- ruby-3.3.0
data/.watchr DELETED
@@ -1,9 +0,0 @@
1
- watch('test/.*_test\.rb$') { |md| run_it(md[0]) }
2
- watch('lib/(.*)\.rb$') { |md| run_it("test/#{md[1]}_test.rb") }
3
-
4
- def run_it(file)
5
- system %(bundle exec ruby -I test #{file})
6
- end
7
-
8
- Signal.trap("QUIT") { system("bundle exec rake") } # Ctrl-\ or ctrl-4
9
- Signal.trap("INT") { abort("Interrupted\n") } # Ctrl-C
data/Gemfile DELETED
@@ -1,11 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gemspec
4
-
5
- group :test do
6
- # gem "benchmark-ips"
7
- gem "minitest-spec-rails"
8
- gem "ricecream"
9
- gem "standard", require: false
10
- gem "simplecov", require: false
11
- end
data/Gemfile.lock DELETED
@@ -1,184 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- cuco (0.1.1)
5
- listen
6
- micro-optparse
7
-
8
- GEM
9
- remote: https://rubygems.org/
10
- specs:
11
- actionpack (7.1.3.2)
12
- actionview (= 7.1.3.2)
13
- activesupport (= 7.1.3.2)
14
- nokogiri (>= 1.8.5)
15
- racc
16
- rack (>= 2.2.4)
17
- rack-session (>= 1.0.1)
18
- rack-test (>= 0.6.3)
19
- rails-dom-testing (~> 2.2)
20
- rails-html-sanitizer (~> 1.6)
21
- actionview (7.1.3.2)
22
- activesupport (= 7.1.3.2)
23
- builder (~> 3.1)
24
- erubi (~> 1.11)
25
- rails-dom-testing (~> 2.2)
26
- rails-html-sanitizer (~> 1.6)
27
- activesupport (7.1.3.2)
28
- base64
29
- bigdecimal
30
- concurrent-ruby (~> 1.0, >= 1.0.2)
31
- connection_pool (>= 2.2.5)
32
- drb
33
- i18n (>= 1.6, < 2)
34
- minitest (>= 5.1)
35
- mutex_m
36
- tzinfo (~> 2.0)
37
- ast (2.4.2)
38
- base64 (0.2.0)
39
- bigdecimal (3.1.7)
40
- builder (3.2.4)
41
- concurrent-ruby (1.2.3)
42
- connection_pool (2.4.1)
43
- crass (1.0.6)
44
- docile (1.4.0)
45
- drb (2.2.1)
46
- erubi (1.12.0)
47
- ffi (1.16.3)
48
- i18n (1.14.4)
49
- concurrent-ruby (~> 1.0)
50
- io-console (0.7.2)
51
- irb (1.12.0)
52
- rdoc
53
- reline (>= 0.4.2)
54
- json (2.7.1)
55
- language_server-protocol (3.17.0.3)
56
- lint_roller (1.1.0)
57
- listen (3.9.0)
58
- rb-fsevent (~> 0.10, >= 0.10.3)
59
- rb-inotify (~> 0.9, >= 0.9.10)
60
- loofah (2.22.0)
61
- crass (~> 1.0.2)
62
- nokogiri (>= 1.12.0)
63
- micro-optparse (1.2.1)
64
- minitest (5.22.3)
65
- minitest-spec-rails (7.2.0)
66
- minitest (>= 5.0)
67
- railties (>= 4.1)
68
- mutex_m (0.2.0)
69
- nokogiri (1.16.3-aarch64-linux)
70
- racc (~> 1.4)
71
- nokogiri (1.16.3-arm-linux)
72
- racc (~> 1.4)
73
- nokogiri (1.16.3-arm64-darwin)
74
- racc (~> 1.4)
75
- nokogiri (1.16.3-x86-linux)
76
- racc (~> 1.4)
77
- nokogiri (1.16.3-x86_64-darwin)
78
- racc (~> 1.4)
79
- nokogiri (1.16.3-x86_64-linux)
80
- racc (~> 1.4)
81
- parallel (1.24.0)
82
- parser (3.3.0.5)
83
- ast (~> 2.4.1)
84
- racc
85
- psych (5.1.2)
86
- stringio
87
- racc (1.7.3)
88
- rack (3.0.10)
89
- rack-session (2.0.0)
90
- rack (>= 3.0.0)
91
- rack-test (2.1.0)
92
- rack (>= 1.3)
93
- rackup (2.1.0)
94
- rack (>= 3)
95
- webrick (~> 1.8)
96
- rails-dom-testing (2.2.0)
97
- activesupport (>= 5.0.0)
98
- minitest
99
- nokogiri (>= 1.6)
100
- rails-html-sanitizer (1.6.0)
101
- loofah (~> 2.21)
102
- nokogiri (~> 1.14)
103
- railties (7.1.3.2)
104
- actionpack (= 7.1.3.2)
105
- activesupport (= 7.1.3.2)
106
- irb
107
- rackup (>= 1.0.0)
108
- rake (>= 12.2)
109
- thor (~> 1.0, >= 1.2.2)
110
- zeitwerk (~> 2.6)
111
- rainbow (3.1.1)
112
- rake (13.1.0)
113
- rb-fsevent (0.11.2)
114
- rb-inotify (0.10.1)
115
- ffi (~> 1.0)
116
- rdoc (6.6.3.1)
117
- psych (>= 4.0.0)
118
- regexp_parser (2.9.0)
119
- reline (0.4.3)
120
- io-console (~> 0.5)
121
- rexml (3.2.6)
122
- ricecream (0.2.1)
123
- rubocop (1.62.1)
124
- json (~> 2.3)
125
- language_server-protocol (>= 3.17.0)
126
- parallel (~> 1.10)
127
- parser (>= 3.3.0.2)
128
- rainbow (>= 2.2.2, < 4.0)
129
- regexp_parser (>= 1.8, < 3.0)
130
- rexml (>= 3.2.5, < 4.0)
131
- rubocop-ast (>= 1.31.1, < 2.0)
132
- ruby-progressbar (~> 1.7)
133
- unicode-display_width (>= 2.4.0, < 3.0)
134
- rubocop-ast (1.31.2)
135
- parser (>= 3.3.0.4)
136
- rubocop-performance (1.20.2)
137
- rubocop (>= 1.48.1, < 2.0)
138
- rubocop-ast (>= 1.30.0, < 2.0)
139
- ruby-progressbar (1.13.0)
140
- simplecov (0.22.0)
141
- docile (~> 1.1)
142
- simplecov-html (~> 0.11)
143
- simplecov_json_formatter (~> 0.1)
144
- simplecov-html (0.12.3)
145
- simplecov_json_formatter (0.1.4)
146
- standard (1.35.1)
147
- language_server-protocol (~> 3.17.0.2)
148
- lint_roller (~> 1.0)
149
- rubocop (~> 1.62.0)
150
- standard-custom (~> 1.0.0)
151
- standard-performance (~> 1.3)
152
- standard-custom (1.0.2)
153
- lint_roller (~> 1.0)
154
- rubocop (~> 1.50)
155
- standard-performance (1.3.1)
156
- lint_roller (~> 1.1)
157
- rubocop-performance (~> 1.20.2)
158
- stringio (3.1.0)
159
- thor (1.3.1)
160
- tzinfo (2.0.6)
161
- concurrent-ruby (~> 1.0)
162
- unicode-display_width (2.5.0)
163
- webrick (1.8.1)
164
- zeitwerk (2.6.13)
165
-
166
- PLATFORMS
167
- aarch64-linux
168
- arm-linux
169
- arm64-darwin
170
- x86-linux
171
- x86_64-darwin
172
- x86_64-linux
173
-
174
- DEPENDENCIES
175
- cuco!
176
- minitest
177
- minitest-spec-rails
178
- rake
179
- ricecream
180
- simplecov
181
- standard
182
-
183
- BUNDLED WITH
184
- 2.5.6
data/Rakefile DELETED
@@ -1,11 +0,0 @@
1
- require "rake"
2
- require "rake/testtask"
3
- require "bundler/gem_tasks"
4
-
5
- Rake::TestTask.new do |t|
6
- t.libs.push "test"
7
- t.pattern = "test/*_test.rb"
8
- end
9
-
10
- desc "Default: run unit tests."
11
- task default: :test
data/cuco.gemspec DELETED
@@ -1,24 +0,0 @@
1
- require File.expand_path("../lib/version", __FILE__)
2
-
3
- Gem::Specification.new do |s|
4
- s.name = "cuco"
5
- s.version = Cuco::VERSION
6
- s.summary = "A file watcher"
7
- s.description = "A simple and flexible file watcher"
8
-
9
- s.authors = ["Dittmar Krall"]
10
- s.email = "dittmar.krall@matiq.de"
11
- s.homepage = "http://www.matiq.de"
12
- s.license = "MIT"
13
-
14
- s.files = `git ls-files`.split("\n")
15
- s.executables = `git ls-files -- bin/*`
16
- .split("\n").map { |f| File.basename(f) }
17
- s.require_paths = ["lib"]
18
-
19
- s.add_runtime_dependency "micro-optparse"
20
- s.add_runtime_dependency "listen"
21
-
22
- s.add_development_dependency "minitest"
23
- s.add_development_dependency "rake"
24
- end
@@ -1,59 +0,0 @@
1
- require "test_helper"
2
-
3
- class R
4
- class << self
5
- attr_accessor :acc
6
- end
7
- end
8
-
9
- describe Controller do
10
- let(:cntrl) { Controller.instance }
11
-
12
- def setup
13
- R.acc = ""
14
- G.init({}, [])
15
- G.script = Script.new <<~EOS
16
- watch('file') { R.acc << "n" }
17
- watch('file', :added) { R.acc << "a" }
18
- watch('file', :modified) { R.acc << "m" }
19
- EOS
20
- end
21
-
22
- def teardown
23
- cntrl.stop
24
- end
25
-
26
- it "fails with unknown what pattern" do
27
- cntrl.file_run("fail", nil)
28
- assert_equal "", R.acc
29
- end
30
-
31
- it "considers event_type nil" do
32
- check nil, "n"
33
- end
34
-
35
- it "considers event_type :added" do
36
- check :added, "an"
37
- end
38
-
39
- it "considers event_type :modified" do
40
- check :modified, "mn"
41
- end
42
-
43
- it "receives a matchdata" do
44
- G.script = Script.new "watch('ab(.)') { |m|
45
- R.acc << m[0]
46
- R.acc << m[1]
47
- }"
48
-
49
- cntrl.file_run("abc", nil)
50
- assert_equal "abcc", R.acc
51
- end
52
-
53
- private
54
-
55
- def check(type, expected)
56
- cntrl.file_run("file", type)
57
- assert_equal expected, R.acc
58
- end
59
- end
@@ -1,45 +0,0 @@
1
- require "test_helper"
2
-
3
- describe Controller do
4
- let(:cntrl) { Controller.instance }
5
- let(:regexp) { '.*\.rb' }
6
-
7
- def setup
8
- G.init({}, [])
9
- end
10
-
11
- def teardown
12
- cntrl.stop
13
- end
14
-
15
- it "stops" do
16
- cntrl.stop
17
- assert_nil cntrl.listener
18
- end
19
-
20
- it "runs" do
21
- assert_raises(Timeout::Error) do
22
- Timeout.timeout(0.1) { cntrl.run }
23
- end
24
-
25
- assert cntrl.listener
26
- end
27
-
28
- it "read .watchr" do
29
- assert_raises(Timeout::Error) do
30
- Timeout.timeout(0.1) { cntrl.run }
31
- end
32
- end
33
-
34
- it "run" do
35
- G.script = Script.new "watch('#{regexp}') { raise IOError }"
36
-
37
- assert_raises(IOError) { cntrl.file_run "a.rb" }
38
- end
39
-
40
- it "does not run" do
41
- G.script = Script.new "watch('#{regexp}') { raise IOError }"
42
-
43
- cntrl.file_run "a.no"
44
- end
45
- end
@@ -1,19 +0,0 @@
1
- require "test_helper"
2
-
3
- describe "Coverage" do
4
- let(:cntrl) { Controller.instance }
5
-
6
- def setup
7
- G.init({}, [])
8
- end
9
-
10
- it "coverage run files" do
11
- names = []
12
- cntrl.run_files(names, nil)
13
- end
14
-
15
- it "coverage run files script" do
16
- names = [G.scriptname]
17
- cntrl.run_files(names, nil)
18
- end
19
- end
data/test/cuco_test.rb DELETED
@@ -1,34 +0,0 @@
1
- require "test_helper"
2
-
3
- describe Cuco do
4
- def setup
5
- G.init({}, [])
6
- end
7
-
8
- it "usage" do
9
- out, _err = capture_io do
10
- puts `bin/cuco -h`
11
- end
12
-
13
- assert_match(/Usage/, out)
14
- end
15
-
16
- it "coverage G.print " do
17
- out, err = capture_io do
18
- G.print
19
- end
20
-
21
- assert out
22
- assert_equal "", err
23
- assert_match(/scriptname/, out)
24
- assert_match(/.watchr/, out)
25
- assert_match(/pwd/, out)
26
- end
27
-
28
- it "options" do
29
- options = {opt: 1234}
30
- G.init options, []
31
-
32
- assert_equal options, G.options
33
- end
34
- end
data/test/script_test.rb DELETED
@@ -1,29 +0,0 @@
1
- require "test_helper"
2
-
3
- describe Script do
4
- it "checks script" do
5
- script = Script.new ""
6
- assert script.instance_of?(Script)
7
- assert_equal %i[watch __rules].sort, script.public_methods(false).sort
8
- end
9
-
10
- it "has no watcher" do
11
- script = Script.new "n = 123"
12
- assert_equal 0, script.__rules.size
13
- end
14
-
15
- it "has one watcher" do
16
- script = Script.new "n = 456; watch('.rb') { }"
17
-
18
- assert_equal 1, script.__rules.size
19
- end
20
-
21
- it "calls a watcher" do
22
- pattern = '\.rb'
23
- value = 123
24
- script = Script.new "n = #{value}; watch('#{pattern}') { n }"
25
-
26
- rule = script.__rules.last
27
- assert_equal [pattern, value], [rule.pattern, rule.proc.call]
28
- end
29
- end
data/test/test_helper.rb DELETED
@@ -1,15 +0,0 @@
1
- if ENV["COVERAGE"]
2
- require "simplecov"
3
-
4
- SimpleCov.start do
5
- add_filter "/test/"
6
- end
7
- end
8
-
9
- require "minitest/autorun"
10
- require "ricecream"
11
-
12
- require "controller"
13
- require "cuco"
14
- require "script"
15
- require "timeout"
File without changes
File without changes
File without changes