We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 343e63e + 1de90c6 commit 388fff5Copy full SHA for 388fff5
.github/workflows/test.yml
@@ -14,7 +14,7 @@ jobs:
14
LC_ALL: en_US.UTF-8
15
16
strategy:
17
- matrix: { ruby: ['3.2', '3.3', '3.4'] }
+ matrix: { ruby: ['3.2', '3.3', '3.4', '4.0'] }
18
19
steps:
20
- name: Checkout code
bashly.gemspec
@@ -17,16 +17,17 @@ Gem::Specification.new do |s|
s.add_dependency 'colsole', '~> 1.0'
s.add_dependency 'completely', '~> 0.7.0'
- s.add_dependency 'filewatcher', '~> 2.0'
21
s.add_dependency 'gtx', '~> 0.1.1'
+ s.add_dependency 'listen', '~> 3.9'
22
s.add_dependency 'lp', '~> 0.2.0'
23
- s.add_dependency 'mister_bin', '~> 0.8.1'
+ s.add_dependency 'mister_bin', '~> 0.9.0'
24
s.add_dependency 'requires', '~> 1.1'
25
s.add_dependency 'tty-markdown', '~> 0.7.2'
26
27
- # Sub-dependenceis (Ruby 3.3.5 warnings)
28
- s.add_dependency 'logger', '>= 1', '< 3' # required by filewatcher
29
- s.add_dependency 'ostruct', '>= 0', '< 2' # required by json
+ # Missing sub-dependencies
+ # logger: required and not bundled by `listen` 3.9.0
+ # ref: https://github.com/guard/listen/issues/591
30
+ s.add_dependency 'logger', '~> 1.7'
31
32
s.metadata = {
33
'bug_tracker_uri' => 'https://github.com/bashly-framework/bashly/issues',
examples/render-mandoc/docs/download.1
@@ -1,6 +1,6 @@
1
.\" Automatically generated by Pandoc 3.2
2
.\"
3
-.TH "download" "1" "December 2025" "Version 0.1.0" "Sample application"
+.TH "download" "1" "January 2026" "Version 0.1.0" "Sample application"
4
.SH NAME
5
\f[B]download\f[R] \- Sample application
6
.SH SYNOPSIS
examples/render-mandoc/docs/download.md
% download(1) Version 0.1.0 | Sample application
% Lana Lang
-% December 2025
+% January 2026
NAME
==================================================
lib/bashly.rb
@@ -12,7 +12,7 @@ module Bashly
12
13
autoloads 'bashly', %i[
CLI Config ConfigValidator Library LibrarySource LibrarySourceConfig
- MessageStrings RenderContext RenderSource Settings VERSION
+ MessageStrings RenderContext RenderSource Settings VERSION Watch
]
autoloads 'bashly/concerns', %i[
lib/bashly/commands/generate.rb
@@ -1,5 +1,3 @@
-require 'filewatcher'
-
module Bashly
module Commands
class Generate < Base
@@ -41,7 +39,7 @@ def run
41
39
def watch
42
40
quiet_say "g`watching` #{Settings.source_dir}\n"
43
44
- Filewatcher.new([Settings.source_dir]).watch do
+ Watch.new(Settings.source_dir).on_change do
45
reset
46
generate
47
rescue Bashly::ConfigurationError => e
lib/bashly/commands/render.rb
@@ -1,4 +1,3 @@
require 'tty-markdown'
@@ -75,7 +74,7 @@ def render
75
74
76
say "g`watching`\n"
77
78
- Filewatcher.new(watchables).watch do
+ Watch.new(*watchables).on_change do
79
render
80
say "g`waiting`\n"
81
end
lib/bashly/watch.rb
@@ -0,0 +1,52 @@
+require 'listen'
+
+module Bashly
+ # File system watcher - an ergonomic wrapper around the Listen gem
+ class Watch
+ attr_reader :dirs, :options
7
8
+ DEFAULT_OPTIONS = {
9
+ force_polling: true,
10
+ latency: 1.0,
11
+ }.freeze
+ def initialize(*dirs, **options)
+ @options = DEFAULT_OPTIONS.merge(options).freeze
+ @dirs = dirs.empty? ? ['.'] : dirs
+ end
+ def on_change(&)
+ start(&)
+ wait
+ ensure
+ stop
+ private
+ def build_listener
+ listen.to(*dirs, **options) do |modified, added, removed|
+ yield changes(modified, added, removed)
+ def start(&block)
34
+ raise ArgumentError, 'block required' unless block
35
36
+ @listener = build_listener(&block)
37
+ @listener.start
38
+ def stop
+ @listener&.stop
+ @listener = nil
+ def changes(modified, added, removed)
+ { modified:, added:, removed: }
48
49
+ def listen = Listen
50
+ def wait = sleep
51
52
+end
spec/approvals/examples/dependencies-alt
@@ -24,4 +24,4 @@ args: none
deps:
- ${deps[git]} = /usr/bin/git
- ${deps[http_client]} = /usr/bin/curl
-- ${deps[ruby]} = /home/vagrant/.rbenv/versions/3.4.1/bin/ruby
+- ${deps[ruby]} = /home/vagrant/.rbenv/versions/4.0.0/bin/ruby
spec/bashly/commands/generate_spec.rb
@@ -229,20 +229,20 @@
229
230
let(:bashly_config_path) { "#{source_dir}/bashly.yml" }
231
let(:bashly_config) { YAML.load_file bashly_config_path }
232
- let(:watcher_double) { instance_double Filewatcher, watch: nil }
+ let(:watch_double) { instance_double Watch, on_change: nil }
233
234
it 'generates immediately and on change' do
235
- allow(Filewatcher).to receive(:new).and_return(watcher_double)
236
- allow(watcher_double).to receive(:watch).and_yield
+ allow(Watch).to receive(:new).and_return(watch_double)
+ allow(watch_double).to receive(:on_change).and_yield
237
238
expect { subject.execute %w[generate --watch] }
239
.to output_approval('cli/generate/watch')
240
241
242
context 'when ConfigurationError is raised during watch' do
243
it 'shows the error gracefully and continues to watch' do
244
245
- allow(watcher_double).to receive(:watch) do |&block|
+ allow(watch_double).to receive(:on_change) do |&block|
246
bashly_config['invalid_option'] = 'error this'
247
File.write bashly_config_path, bashly_config.to_yaml
248
block.call
0 commit comments