tayle 0.0.1 → 0.0.3

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: 4c3659dae92c4938d1fcd1b672acdaae573381d210e53c760960dac3ba03fe91
4
- data.tar.gz: f0a81610b40f35d0aae755aebd0e48f87eee4facc711cc8bad4167b8ebc5bfa2
3
+ metadata.gz: a65760090afbdffc216ac783b3d12eabb027d12cfc5e7400562c5bce648fecc2
4
+ data.tar.gz: 9472e410596c4cd47414279c191655731792626d4460be0defa6e3dd5e333dc2
5
5
  SHA512:
6
- metadata.gz: 315cec2e7111c0e0ce81ee01df7fe0c15cb96e24b7f9d778214dcdd45d3d6f3e8a6bde57111ba85d08105425410d223987f2eb17f2d4d1418a0c0da5d24f7937
7
- data.tar.gz: e5f7be6634d58b59df2dc222476b136ba481c388f7f022bad00a8f64240ef08442a9f937c9958568709e3e932cb160df8db39cfd257a85495fc1e8549934f956
6
+ metadata.gz: 1758346dbb7deb61cfcc5d2497bb475b7215fbb37568823ef1b2471af4a0a8160411eeb3e1107c299fa852cd07b4518721739d6499e6944275eac864e88783ea
7
+ data.tar.gz: 88c85b7d0bc9b67cc40d653a26c0e76c2fc5d39d5cc5226c3ea36662adda266e2ca4484198278ce73a111a32a41085d80f4b39cfd4f0d9fbe152b928e6a144c2
data/.rubocop.yml CHANGED
@@ -16,7 +16,7 @@ plugins:
16
16
 
17
17
  AllCops:
18
18
  NewCops: enable
19
- TargetRubyVersion: 4.0
19
+ TargetRubyVersion: 3.4
20
20
  Exclude:
21
21
  - bin/*
22
22
  - vendor/**/*
data/README.md CHANGED
@@ -27,7 +27,7 @@ Pass `position: :start` to read what the log already holds first, `writer_pid:`
27
27
  to stop once the process writing it does, and `tail_path:` to run a `tail`
28
28
  other than the first on `PATH`. See the rdoc on `Tayle` for the details.
29
29
 
30
- Requires GNU coreutils `tail` 8.28 or newer; anything else raises
30
+ Requires Ruby 3.4.10 or newer and GNU coreutils `tail` 8.28 or newer; any other `tail` raises
31
31
  `Tayle::Unsupported`.
32
32
 
33
33
  ## Development
data/Rakefile CHANGED
@@ -7,10 +7,13 @@ RSpec::Core::RakeTask.new(:spec)
7
7
  require "rubocop/rake_task"
8
8
  RuboCop::RakeTask.new
9
9
 
10
- require "gempilot/version_task"
11
- Gempilot::VersionTask.new
10
+ # gempilot needs Ruby 4.0, so the Gemfile leaves it out on 3.4 and these tasks go with it.
11
+ if Gem.loaded_specs.key?("gempilot")
12
+ require "gempilot/version_task"
13
+ Gempilot::VersionTask.new
12
14
 
13
- require "gempilot/zeitwerk_task"
14
- Gempilot::ZeitwerkTask.new
15
+ require "gempilot/zeitwerk_task"
16
+ Gempilot::ZeitwerkTask.new
17
+ end
15
18
 
16
19
  task default: [:spec, :rubocop]
data/lib/tayle/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Tayle
2
- VERSION = "0.0.1".freeze
2
+ VERSION = "0.0.3".freeze
3
3
  end
data/lib/tayle.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require "pathname"
1
2
  require "zeitwerk"
2
3
 
3
4
  ##
data/rakelib/rbs.rake ADDED
@@ -0,0 +1,61 @@
1
+ require "yaml"
2
+
3
+ namespace :rbs do
4
+ root_dir = Pathname(__dir__).parent
5
+ collection_yaml = root_dir / "rbs_collection.yaml"
6
+ collection_dir = root_dir / ".gem_rbs_collection"
7
+ manifest = root_dir / "sig" / "manifest.yaml"
8
+
9
+ # The stdlib signatures sig/manifest.yaml names, as rbs -r flags; the
10
+ # manifest only applies by itself when the gem's sig is loaded as a library.
11
+ stdlib_flags = lambda do
12
+ YAML.safe_load_file(manifest).fetch("dependencies").flat_map { ["-r", it.fetch("name")] }
13
+ end
14
+
15
+ desc "Install the rbs collection rbs_collection.lock.yaml pins"
16
+ task setup: ["rbs:collection:install"]
17
+
18
+ desc "Remove the installed rbs collection"
19
+ task :clobber do
20
+ rm_rf collection_dir
21
+ end
22
+
23
+ desc "Check every signature under sig parses and names only types that exist"
24
+ task validate: ["rbs:collection:install"] do
25
+ sh "bundle", "exec", "rbs", "-I", "sig", *stdlib_flags.call, "validate"
26
+ end
27
+
28
+ # Enumerators go unchecked: the checker samples one by iterating, and the
29
+ # Enumerator #each returns blocks on tail until the log grows.
30
+ desc "Run the specs with every Tayle call checked against its signature"
31
+ task test: ["rbs:collection:install"] do
32
+ env = {
33
+ "RBS_TEST_TARGET" => "Tayle,Tayle::*",
34
+ "RBS_TEST_OPT" => ["-I", "sig", *stdlib_flags.call].join(" "),
35
+ "RBS_TEST_LOGLEVEL" => "warn",
36
+ "RBS_TEST_DOUBLE_SUITE" => "rspec",
37
+ "RBS_TEST_UNCHECKED_CLASSES" => "Enumerator",
38
+ "RUBYOPT" => "-r rbs/test/setup",
39
+ }
40
+ sh env, "bundle", "exec", "rspec"
41
+ end
42
+
43
+ namespace :collection do
44
+ file collection_yaml.to_s do
45
+ sh "bundle exec rbs collection init"
46
+ end
47
+
48
+ desc "Write rbs_collection.yaml if it is missing"
49
+ task init: [collection_yaml.to_s]
50
+
51
+ desc "Install the gem RBS files the collection lists"
52
+ task install: ["rbs:collection:init"] do
53
+ sh "bundle exec rbs collection install"
54
+ end
55
+
56
+ desc "Re-resolve the collection and rewrite rbs_collection.lock.yaml"
57
+ task :update do
58
+ sh "bundle exec rbs collection update"
59
+ end
60
+ end
61
+ end
data/sig/manifest.yaml ADDED
@@ -0,0 +1,2 @@
1
+ dependencies:
2
+ - name: pathname
@@ -0,0 +1,26 @@
1
+ class Tayle
2
+ # Private constants; RBS has no private_constant.
3
+ POSITIONS: Array[position]
4
+
5
+ # The tail invocation: argv for one path, writer and start position.
6
+ class Command < Data
7
+ attr_reader executable: Pathname
8
+ attr_reader path: Pathname
9
+ attr_reader writer: Writer?
10
+ attr_reader position: position
11
+
12
+ def self.new: (executable: Pathname, path: String | Pathname, writer: Writer?, position: position) -> instance
13
+ | (Pathname executable, String | Pathname path, Writer? writer, position position) -> instance
14
+
15
+ def self.members: () -> [:executable, :path, :writer, :position]
16
+
17
+ # Raises ArgumentError for any Symbol but :start or :end.
18
+ def initialize: (executable: Pathname, path: String | Pathname, writer: Writer?, position: Symbol) -> void
19
+
20
+ def argv: () -> Array[String]
21
+
22
+ private
23
+
24
+ def first_byte: () -> Integer
25
+ end
26
+ end
@@ -0,0 +1,22 @@
1
+ class Tayle
2
+ OLDEST_SUPPORTED_VERSION: [Integer, Integer]
3
+
4
+ # A located tail executable and its coreutils version, nil when not GNU.
5
+ class GnuTail < Data
6
+ attr_reader executable: Pathname
7
+ attr_reader version: [Integer, Integer]?
8
+
9
+ def self.new: (executable: Pathname, version: [Integer, Integer]?) -> instance
10
+ | (Pathname executable, [Integer, Integer]? version) -> instance
11
+
12
+ def self.members: () -> [:executable, :version]
13
+
14
+ def self.locate: (String | Pathname command) -> instance
15
+
16
+ private def self.list_candidates: (String | Pathname command) -> Array[Pathname]
17
+
18
+ private def self.read_version: (Pathname executable) -> [Integer, Integer]?
19
+
20
+ def check_supported: () -> void
21
+ end
22
+ end
@@ -0,0 +1,3 @@
1
+ class Tayle
2
+ VERSION: String
3
+ end
@@ -0,0 +1,17 @@
1
+ class Tayle
2
+ # The process writing the log; tail --pid exits once it is reaped.
3
+ class Writer < Data
4
+ attr_reader pid: Integer
5
+
6
+ def self.new: (pid: Integer | String) -> instance
7
+ | (Integer | String pid) -> instance
8
+
9
+ def self.members: () -> [:pid]
10
+
11
+ def initialize: (pid: Integer | String) -> void
12
+
13
+ def flag: () -> String
14
+
15
+ def gone?: () -> bool
16
+ end
17
+ end
data/sig/tayle.rbs ADDED
@@ -0,0 +1,39 @@
1
+ class Tayle
2
+ include Enumerable[String]
3
+
4
+ # Where reading begins: the file's current end, or its first byte.
5
+ type position = :start | :end
6
+
7
+ LOADER: Zeitwerk::GemLoader
8
+
9
+ class Unsupported < StandardError
10
+ end
11
+
12
+ class Exited < StandardError
13
+ # nil if something else reaped tail first.
14
+ attr_reader status: Process::Status?
15
+
16
+ def initialize: (status: Process::Status?) -> void
17
+ end
18
+
19
+ attr_reader lines_read: Integer
20
+
21
+ # Any Symbol reaches Command, which raises ArgumentError unless it is :start or :end;
22
+ # writer_pid is coerced with Integer(), so a non-numeric String raises the same.
23
+ def initialize: (String | Pathname path, ?writer_pid: (Integer | String)?, ?tail_path: String | Pathname, ?position: Symbol) ?{ (Tayle) -> void } -> void
24
+
25
+ def path: () -> Pathname
26
+
27
+ def position: () -> position
28
+
29
+ def each: (?chomp: bool) { (String) -> void } -> self
30
+ | (?chomp: bool) -> Enumerator[String, self]
31
+
32
+ alias each_line each
33
+
34
+ def close: () -> void
35
+
36
+ private
37
+
38
+ def yield_and_close: [T] () { (Tayle) -> T } -> T
39
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tayle
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Gillis
@@ -40,6 +40,13 @@ files:
40
40
  - lib/tayle/gnu_tail.rb
41
41
  - lib/tayle/version.rb
42
42
  - lib/tayle/writer.rb
43
+ - rakelib/rbs.rake
44
+ - sig/manifest.yaml
45
+ - sig/tayle.rbs
46
+ - sig/tayle/command.rbs
47
+ - sig/tayle/gnu_tail.rbs
48
+ - sig/tayle/version.rbs
49
+ - sig/tayle/writer.rbs
43
50
  licenses:
44
51
  - MIT
45
52
  metadata:
@@ -51,7 +58,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
51
58
  requirements:
52
59
  - - ">="
53
60
  - !ruby/object:Gem::Version
54
- version: 4.0.6
61
+ version: 3.4.10
55
62
  required_rubygems_version: !ruby/object:Gem::Requirement
56
63
  requirements:
57
64
  - - ">="