firew0rks 0.2.0 → 0.4.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 596195788e67951a2d044b9f116fccb51c5a55f6269d1eb78b19ed4206d046e6
4
- data.tar.gz: 39231044034cfafb1ffcc704b297bf86e19df5b732897b4ac2336cd55c903b7c
3
+ metadata.gz: 4cb414800994a7b2c2eba1bf1ee4975276d193d8f55faed801dfe16712a6f0bd
4
+ data.tar.gz: 7163d85c07f349bac8af2c13c6f947ba492875023c2650cdb698bc8fcc7119b2
5
5
  SHA512:
6
- metadata.gz: 2cc443a96481e40c9a15211ea2f8449e5e09dddf07e609f0ff6aea2a48246ef5fa8dce3bf32692704af79d921171290766edaf79f07c6d54cba7fbfbb0234024
7
- data.tar.gz: 5c940bc4b31813098c3a5b330cf6c9198681fcc41b2dc460a50d30e6463f58ea61c2b10d181d666832e075886b76da926c36785e26d8abfa8612fa5548d2a48c
6
+ metadata.gz: 32fcbb0c09cee2846e773c87249a19a65726688b82d7e0a94060bee9a335373eef5b2abb216890916f6b765cb870da8fa74b8a62c11b21569f35b7596b1e3309
7
+ data.tar.gz: b55ae081cad59d27d8a998ace6fbf01103fc84839cc409a1ea15a468a8241143bcbcb39dc009e8376a6d9a030b5852f681086a5d9799d8b5911fd3282435caed
data/README.md CHANGED
@@ -2,22 +2,24 @@
2
2
 
3
3
  Play fireworks text art animations in your terminal!
4
4
 
5
+ ![fireworks_show](./fireworks_show.gif)
6
+
5
7
  ## Installation
6
8
 
7
- `gem install firew0rks`
9
+ `$ gem install firew0rks`
8
10
 
9
11
  ## Usage
10
12
 
11
- 1) run program
13
+ 1) Run program
12
14
 
13
- `firew0rks`
15
+ `$ firew0rks`
14
16
 
15
- 2) quit
17
+ 2) Quit
16
18
 
17
19
  `Ctrl + C`
18
20
 
19
21
  ## Acknowledgments
20
- This project is a Ruby version of [text_art_animations](https://github.com/rvizzz/text_art_animations) by rvizzz. Thank you for the inspiration and the amazing ASCII art animations!
22
+ This project is a Ruby version of [text_art_animations](https://github.com/rvizzz/text_art_animations) by [rvizzz](https://github.com/rvizzz). Thank you for the inspiration and the amazing ASCII art animations!
21
23
 
22
24
  ## Contributing
23
25
 
data/exe/firew0rks CHANGED
@@ -1,24 +1,31 @@
1
1
  #!/usr/bin/env ruby
2
- require_relative "../lib/firew0rks.rb"
3
- require 'reline'
2
+ require_relative "../lib/firew0rks"
3
+ require_relative "../lib/firew0rks/terminal"
4
4
 
5
- terminal = Reline::ANSI.new
6
- terminal.hide_cursor
7
-
8
- begin
9
- Fireworks.new.run
10
- rescue => error
11
- puts error
12
- ensure
13
- terminal.show_cursor
5
+ def setup
6
+ Terminal.open_buffer
7
+ Terminal.hide_cursor
8
+ Terminal.clear_screen
14
9
  end
15
10
 
11
+ def clean_up
12
+ Terminal.close_buffer
13
+ Terminal.clear_screen
14
+ Terminal.show_cursor
15
+ end
16
16
 
17
17
  trap("INT") {
18
- terminal.show_cursor
18
+ clean_up
19
+ puts ""
20
+ puts "Bye."
19
21
  exit 0
20
22
  }
21
23
 
22
- at_exit {
23
- terminal.show_cursor
24
- }
24
+ begin
25
+ setup
26
+ Fireworks.new.run
27
+ rescue => error
28
+ puts error
29
+ ensure
30
+ clean_up
31
+ end
Binary file
@@ -0,0 +1,34 @@
1
+ # ANSI_escape_code
2
+ # Ref: https://xn--rpa.cc/irl/term.html
3
+ # https://en.wikipedia.org/wiki/ANSI_escape_code#CSIsection
4
+
5
+ class Terminal
6
+ class << self
7
+
8
+ def clear_buffer
9
+ print "\x1b[3J"
10
+ end
11
+
12
+ def clear_screen
13
+ print "\x1b[2J"
14
+ end
15
+
16
+ def hide_cursor
17
+ print "\x1b[?25l"
18
+ end
19
+
20
+ def show_cursor
21
+ print "\x1b[?25h"
22
+ end
23
+
24
+ def open_buffer
25
+ # 打开特殊缓存
26
+ print "\x1b[?1049h"
27
+ end
28
+
29
+ def close_buffer
30
+ # 关闭特殊缓存
31
+ print "\x1b[?1049l"
32
+ end
33
+ end
34
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Firew0rks
4
- VERSION = "0.2.0"
4
+ VERSION = "0.4.0"
5
5
  end
data/lib/firew0rks.rb CHANGED
@@ -3,6 +3,7 @@ require "io/console"
3
3
  require_relative "firew0rks/version"
4
4
  require_relative "firew0rks/frame"
5
5
  require_relative "firew0rks/error"
6
+ require_relative "firew0rks/terminal"
6
7
 
7
8
 
8
9
  class Fireworks
@@ -14,7 +15,7 @@ class Fireworks
14
15
 
15
16
 
16
17
  def clear_screen
17
- $stdout.clear_screen
18
+ Terminal.clear_buffer
18
19
  end
19
20
 
20
21
  def init_screen
@@ -27,7 +28,7 @@ class Fireworks
27
28
  if !@first_frame
28
29
  $stdout.print @backspace_adjust
29
30
  end
30
-
31
+ clear_screen
31
32
  $stdout.print content
32
33
  @first_frame = false
33
34
  sleep(0.05)
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: firew0rks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark24
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-01-01 00:00:00.000000000 Z
10
+ date: 2025-01-03 00:00:00.000000000 Z
11
11
  dependencies: []
12
12
  description: "Fireworks in your terminal \U0001F386 power by Ruby"
13
13
  email:
@@ -21,6 +21,7 @@ files:
21
21
  - README.md
22
22
  - Rakefile
23
23
  - exe/firew0rks
24
+ - fireworks_show.gif
24
25
  - lib/firew0rks.rb
25
26
  - lib/firew0rks/error.rb
26
27
  - lib/firew0rks/frame.rb
@@ -174,6 +175,7 @@ files:
174
175
  - lib/firew0rks/frames/97.txt
175
176
  - lib/firew0rks/frames/98.txt
176
177
  - lib/firew0rks/frames/99.txt
178
+ - lib/firew0rks/terminal.rb
177
179
  - lib/firew0rks/version.rb
178
180
  - sig/firew0rks.rbs
179
181
  homepage: https://github.com/Mark24Code/firew0rks