streamd 0.1.0

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.
Files changed (6) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +21 -0
  3. data/README.md +30 -0
  4. data/Rakefile +4 -0
  5. data/lib/streamd.rb +43 -0
  6. metadata +72 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 7344aeb47fdd40ec48ca0d90b995f2eacbceb1ec81a69f68de7b889230874ff7
4
+ data.tar.gz: 821489d2b6d640e2a8ab9895fbff7142e55e20f432b838ee13fd9f76a6990447
5
+ SHA512:
6
+ metadata.gz: 970e1c771e8c303ec035c4fcf55aaa60822e6f0f6751d86aa4395c7e38034048a05169332ce64303224f47a95730cf9d495b04e1c0d81903a0e5e40df2db1ee1
7
+ data.tar.gz: b3d86893f333c1d14b4db9360d452510969b6156e4cdaf2f03e4bf5230ba28b8b9211cd3d94d1c905d1097d7a6aba254b8e12cef72bc17947e155d3241c9fb8d
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2026 TODO: Write your name
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,30 @@
1
+ # Streamd
2
+
3
+ Render markdown in stream
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ bundle add streamd
9
+ ```
10
+
11
+ If bundler is not being used to manage dependencies, install the gem by executing:
12
+
13
+ ```bash
14
+ gem install streamd
15
+ ```
16
+
17
+ ## Usage
18
+
19
+ ```ruby
20
+ markdown_stream = File.foreach('/path/to/file.md')
21
+ Streamd.print(markdown_stream)
22
+ ```
23
+
24
+ ## Development
25
+
26
+ Follow your heart.
27
+
28
+ ## License
29
+
30
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ task default: %i[]
data/lib/streamd.rb ADDED
@@ -0,0 +1,43 @@
1
+ require 'tty-live'
2
+ require 'glamour'
3
+
4
+ module Streamd
5
+ VERSION = "0.1.0"
6
+
7
+ def self.print(stream)
8
+ whole = ""
9
+ live = TTY::Live.new
10
+
11
+ enum = Enumerator.new do |e|
12
+ in_code_block = false
13
+ stream.each do |chunk|
14
+ curr = ""
15
+ chunk.each_char do |char|
16
+ whole << char
17
+ if whole =~ /\n`{3}[^`]\z/
18
+ in_code_block = !in_code_block
19
+ end
20
+ if whole =~ /\n[\n\s\t]*\n[^\n]\z/ && !in_code_block
21
+ e << [curr, true]
22
+ curr = char
23
+ next
24
+ end
25
+ curr << char
26
+ end
27
+ e << [curr, false]
28
+ end
29
+ end
30
+
31
+ current = ""
32
+ enum.each do |chunk, neo|
33
+ current << chunk
34
+ styled = Glamour.render(current, style: 'dracula', width: 180, preserve_newlines: true)
35
+ live.update(styled)
36
+ if neo
37
+ Kernel.print live.clear_lines(2)
38
+ live = TTY::Live.new
39
+ current.clear
40
+ end
41
+ end
42
+ end
43
+ end
metadata ADDED
@@ -0,0 +1,72 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: streamd
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - c
8
+ bindir: exe
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: glamour
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - "~>"
17
+ - !ruby/object:Gem::Version
18
+ version: 0.2.2
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - "~>"
24
+ - !ruby/object:Gem::Version
25
+ version: 0.2.2
26
+ - !ruby/object:Gem::Dependency
27
+ name: tty-live
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - "~>"
31
+ - !ruby/object:Gem::Version
32
+ version: 0.1.1
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: 0.1.1
40
+ email:
41
+ - 0xe0ffff@gmail.com
42
+ executables: []
43
+ extensions: []
44
+ extra_rdoc_files: []
45
+ files:
46
+ - LICENSE.txt
47
+ - README.md
48
+ - Rakefile
49
+ - lib/streamd.rb
50
+ homepage: https://github.com/kill-2/streamd
51
+ licenses:
52
+ - MIT
53
+ metadata:
54
+ allowed_push_host: https://rubygems.org
55
+ rdoc_options: []
56
+ require_paths:
57
+ - lib
58
+ required_ruby_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: 3.1.0
63
+ required_rubygems_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ requirements: []
69
+ rubygems_version: 3.6.9
70
+ specification_version: 4
71
+ summary: Render markdown is stream
72
+ test_files: []