cruise 0.2.0 → 0.2.1

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: fb4d8ff794d947b973ff33779fdb29414d254a2960d8789ff8051b8323481134
4
- data.tar.gz: 12510283a397763ea9b33152884e5c1a2082fb0ed25ee5b35daf7ca6659b4826
3
+ metadata.gz: 56816599df213ccbde29d06aa61ef5c29ab1dfc804f499be0f0d0459f5323872
4
+ data.tar.gz: d9392f2285f1232cefb6fb77673e974b0f2f602575002241f5573b8c7210b335
5
5
  SHA512:
6
- metadata.gz: ffd8d400b7e194c945ce3d1fbf9728d45cdb9b47b0654c80eb5abd109144de5e8ba1040d7a845ee9e08bd44334127c2fea30941158013e81d5302a022b202b3e
7
- data.tar.gz: '0993a6184ed81d6d4bb00f6ff0b1d9d89d5dc27e00b333d4a950dc96d7eb8b0efe0d55b375e73fd8c460e0c3c2378169205ca9e725d1672dd18a4fd1acde0c04'
6
+ metadata.gz: 639275228d40ed88daf1b4a6cf805133b7122aaad93ba06e68a5bca72854a816c1d246bb60e17cc6b6bda6aac00f5e24622e0a40d988959f7fc1f65b73e224e0
7
+ data.tar.gz: 1b5dd3b61fbeef8b6f96c35613d7c17b42cc81d887929131199b6c022024cd452f2821c7510b1be41657ab86232e5baf144860a644b1dbd3ce2bedc3aa10978e
data/Cargo.lock CHANGED
@@ -143,7 +143,7 @@ checksum = "1d07550c9036bf2ae0c684c4297d503f838287c83c53686d05370d0e139ae570"
143
143
 
144
144
  [[package]]
145
145
  name = "cruise"
146
- version = "0.2.0"
146
+ version = "0.2.1"
147
147
  dependencies = [
148
148
  "cbindgen",
149
149
  "globset",
data/Rakefile CHANGED
@@ -85,5 +85,15 @@ rescue LoadError => e
85
85
  end
86
86
  end
87
87
 
88
+ desc "Generate RBS signatures from the inline annotations"
89
+ task :rbs do
90
+ sh "bundle exec rbs-inline --opt-out --output=sig/ lib/"
91
+ end
92
+
93
+ desc "Type check with Steep"
94
+ task :steep do
95
+ sh "bundle exec steep check"
96
+ end
97
+
88
98
  task test: :compile
89
- task default: [:compile, :test]
99
+ task default: [:compile, :test, :steep]
data/cruise.gemspec CHANGED
@@ -24,6 +24,7 @@ Gem::Specification.new do |spec|
24
24
  "Cargo.lock",
25
25
  "Rakefile",
26
26
  "lib/**/*.rb",
27
+ "sig/**/*.rbs",
27
28
  "ext/cruise/build.rs",
28
29
  "ext/cruise/Cargo.toml",
29
30
  "ext/cruise/cbindgen.toml",
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "cruise"
3
- version = "0.2.0"
3
+ version = "0.2.1"
4
4
  edition = "2021"
5
5
  authors = ["Marco Roth <marco.roth@intergga.ch>"]
6
6
  description = "A fast, OS-native file watcher for Ruby"
data/lib/cruise/event.rb CHANGED
@@ -2,17 +2,21 @@
2
2
 
3
3
  module Cruise
4
4
  class Event
5
- attr_reader :path, :kind
5
+ attr_reader :path #: String
6
+ attr_reader :kind #: String
6
7
 
8
+ #: (String path, String kind) -> void
7
9
  def initialize(path, kind)
8
10
  @path = path
9
11
  @kind = kind
10
12
  end
11
13
 
14
+ #: () -> String
12
15
  def inspect
13
16
  "#<Cruise::Event kind=#{kind.inspect} path=#{path.inspect}>"
14
17
  end
15
18
 
19
+ #: () -> String
16
20
  def to_s
17
21
  "#{kind}: #{path}"
18
22
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Cruise
4
- VERSION = "0.2.0"
4
+ VERSION = "0.2.1"
5
5
  end
@@ -2,31 +2,36 @@
2
2
 
3
3
  module Cruise
4
4
  class Watcher
5
+ #: (*paths paths, ?glob: globs?, ?debounce: debounce, ?only: kinds?) -> void
5
6
  def initialize(*paths, glob: nil, debounce: DEFAULT_DEBOUNCE, only: nil)
6
7
  paths = paths.flatten.grep(String)
7
8
 
8
9
  raise ArgumentError, "Cruise::Watcher requires at least one path" if paths.empty?
9
10
 
10
- glob_patterns = glob ? Array(glob) : []
11
- only_kinds = only ? Array(only).map(&:to_s) : []
11
+ glob_patterns = glob ? Array(glob) : [] #: Array[String]
12
+ only_kinds = only ? Array(only).map(&:to_s) : [] #: Array[String]
12
13
 
13
14
  initialize_native(paths, debounce.to_f, glob_patterns, only_kinds)
14
15
  end
15
16
 
17
+ #: () -> IO
16
18
  def io
17
19
  raise NotImplementedError, "Cruise::Watcher#io is provided by the native extension"
18
20
  end
19
21
 
22
+ #: () -> Event?
20
23
  def poll
21
24
  raise NotImplementedError, "Cruise::Watcher#poll is provided by the native extension"
22
25
  end
23
26
 
27
+ #: () -> void
24
28
  def close
25
29
  raise NotImplementedError, "Cruise::Watcher#close is provided by the native extension"
26
30
  end
27
31
 
28
32
  private
29
33
 
34
+ #: (Array[String] paths, Float debounce, Array[String] globs, Array[String] only_kinds) -> void
30
35
  def initialize_native(_paths, _debounce, _globs, _only_kinds)
31
36
  raise NotImplementedError, "Cruise::Watcher#initialize_native is provided by the native extension"
32
37
  end
data/lib/cruise.rb CHANGED
@@ -7,7 +7,7 @@ require_relative "cruise/event"
7
7
  require_relative "cruise/watcher"
8
8
 
9
9
  begin
10
- ruby_version = RUBY_VERSION.split(".")[0..1].join(".")
10
+ ruby_version = RUBY_VERSION.split(".").take(2).join(".")
11
11
 
12
12
  begin
13
13
  require "cruise/#{ruby_version}/cruise"
@@ -19,7 +19,7 @@ rescue LoadError => e
19
19
  end
20
20
 
21
21
  module Cruise
22
- DEFAULT_DEBOUNCE = 0.1
22
+ DEFAULT_DEBOUNCE = 0.1 #: Float
23
23
 
24
24
  class << self
25
25
  # Watch one or more paths and yield a Cruise::Event for each change.
@@ -28,6 +28,7 @@ module Cruise
28
28
  # IO#wait_readable, so this releases the GVL for other threads and, when a
29
29
  # Fiber scheduler is set (e.g. inside Async), yields to other fibers instead
30
30
  # of blocking the reactor.
31
+ #: (*paths paths, ?glob: globs?, ?debounce: debounce, ?only: kinds?, ?callback: callback?) ?{ (Event) -> void } -> void
31
32
  def watch(*paths, glob: nil, debounce: DEFAULT_DEBOUNCE, only: nil, callback: nil, &block)
32
33
  callback = block || callback
33
34
 
@@ -54,6 +55,7 @@ module Cruise
54
55
 
55
56
  private
56
57
 
58
+ #: (IO io) -> bool
57
59
  def drain_wakeups(io)
58
60
  loop { io.read_nonblock(4096) }
59
61
  rescue IO::WaitReadable
@@ -0,0 +1,18 @@
1
+ # Generated from lib/cruise/event.rb with RBS::Inline
2
+
3
+ module Cruise
4
+ class Event
5
+ attr_reader path: String
6
+
7
+ attr_reader kind: String
8
+
9
+ # : (String path, String kind) -> void
10
+ def initialize: (String path, String kind) -> void
11
+
12
+ # : () -> String
13
+ def inspect: () -> String
14
+
15
+ # : () -> String
16
+ def to_s: () -> String
17
+ end
18
+ end
@@ -0,0 +1,13 @@
1
+ # Note: This file is hand written, `rbs-inline` does not generate this file.
2
+
3
+ module Cruise
4
+ type paths = String | Array[String]
5
+
6
+ type globs = String | Array[String]
7
+
8
+ type kinds = String | Symbol | Array[String | Symbol]
9
+
10
+ type debounce = _ToF
11
+
12
+ type callback = ^(Event) -> void
13
+ end
@@ -0,0 +1,5 @@
1
+ # Generated from lib/cruise/version.rb with RBS::Inline
2
+
3
+ module Cruise
4
+ VERSION: ::String
5
+ end
@@ -0,0 +1,22 @@
1
+ # Generated from lib/cruise/watcher.rb with RBS::Inline
2
+
3
+ module Cruise
4
+ class Watcher
5
+ # : (*paths paths, ?glob: globs?, ?debounce: debounce, ?only: kinds?) -> void
6
+ def initialize: (*paths paths, ?glob: globs?, ?debounce: debounce, ?only: kinds?) -> void
7
+
8
+ # : () -> IO
9
+ def io: () -> IO
10
+
11
+ # : () -> Event?
12
+ def poll: () -> Event?
13
+
14
+ # : () -> void
15
+ def close: () -> void
16
+
17
+ private
18
+
19
+ # : (Array[String] paths, Float debounce, Array[String] globs, Array[String] only_kinds) -> void
20
+ def initialize_native: (Array[String] paths, Float debounce, Array[String] globs, Array[String] only_kinds) -> void
21
+ end
22
+ end
data/sig/cruise.rbs ADDED
@@ -0,0 +1,17 @@
1
+ # Generated from lib/cruise.rb with RBS::Inline
2
+
3
+ module Cruise
4
+ DEFAULT_DEBOUNCE: Float
5
+
6
+ # Watch one or more paths and yield a Cruise::Event for each change.
7
+ #
8
+ # Blocks until interrupted. Waiting happens on the watcher's pipe via
9
+ # IO#wait_readable, so this releases the GVL for other threads and, when a
10
+ # Fiber scheduler is set (e.g. inside Async), yields to other fibers instead
11
+ # of blocking the reactor.
12
+ # : (*paths paths, ?glob: globs?, ?debounce: debounce, ?only: kinds?, ?callback: callback?) ?{ (Event) -> void } -> void
13
+ def self.watch: (*paths paths, ?glob: globs?, ?debounce: debounce, ?only: kinds?, ?callback: callback?) ?{ (Event) -> void } -> void
14
+
15
+ # : (IO io) -> bool
16
+ private def self.drain_wakeups: (IO io) -> bool
17
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cruise
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marco Roth
@@ -36,6 +36,11 @@ files:
36
36
  - lib/cruise/event.rb
37
37
  - lib/cruise/version.rb
38
38
  - lib/cruise/watcher.rb
39
+ - sig/cruise.rbs
40
+ - sig/cruise/event.rbs
41
+ - sig/cruise/types.rbs
42
+ - sig/cruise/version.rbs
43
+ - sig/cruise/watcher.rbs
39
44
  homepage: https://github.com/marcoroth/cruise
40
45
  licenses:
41
46
  - MIT