christmas_tree 0.2.0 → 1.0.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 +4 -4
- data/README.md +12 -4
- data/exe/christmas_tree +15 -13
- data/lib/christmas_tree/version.rb +1 -1
- data/lib/christmas_tree.rb +12 -7
- metadata +2 -3
- data/christmas_tree.rb +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5840d380fbc6bff2e848d22dda5d1b5193d3c05c4c4dbfef80fd6f2b916f40c8
|
4
|
+
data.tar.gz: 529cac1c7665e8b3beb7a39cdb8382e200ead7a9d5b98aa1a0710b2734d44ccd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a5378d86fbbd6dd3dfd880fb36b9b8142408c93217e34050701c407e95cfddb7b17679dbbe56ef35e7a995808ccd1d73f62597e606d29c7f3afabd17394cdcf6
|
7
|
+
data.tar.gz: 84d5385b70aa219d490c75bebc79ca6252779ff7e6d3afb3e1226d801a84d9a8f0280dc6c7a8583a78f3f7364a6cde75102720f7f69590c51db21325b83421b6
|
data/README.md
CHANGED
@@ -7,7 +7,15 @@ christmas tree cli
|
|
7
7
|
System dependencies:
|
8
8
|
|
9
9
|
- Ruby 3.0+
|
10
|
-
- Ncurses:
|
10
|
+
- Ncurses:
|
11
|
+
- Macos: `brew install ncurses`
|
12
|
+
- Linux: `apt install libncurses5-dev` or `apt install libncursesw5-dev`
|
13
|
+
|
14
|
+
Gem dependencies
|
15
|
+
|
16
|
+
Ruby below 3.0, need install gems by manually:
|
17
|
+
|
18
|
+
- Curses: `gem install curses`
|
11
19
|
|
12
20
|
# local run
|
13
21
|
|
@@ -17,7 +25,7 @@ System dependencies:
|
|
17
25
|
|
18
26
|
## add your name
|
19
27
|
|
20
|
-
`./christmas_tree.rb --
|
28
|
+
`./christmas_tree.rb --merry_to <your name>`
|
21
29
|
|
22
30
|
# remote run
|
23
31
|
|
@@ -27,7 +35,7 @@ System dependencies:
|
|
27
35
|
|
28
36
|
### add your name
|
29
37
|
|
30
|
-
`gem exec christmas_tree --
|
38
|
+
`gem exec christmas_tree --merry_to <yourname>`
|
31
39
|
|
32
40
|
## use Curl
|
33
41
|
|
@@ -35,7 +43,7 @@ System dependencies:
|
|
35
43
|
|
36
44
|
### add your name
|
37
45
|
|
38
|
-
`ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Mark24Code/christmas_tree/main/christmas_tree.rb)" --
|
46
|
+
`ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Mark24Code/christmas_tree/main/christmas_tree.rb)" -- --merry_to <your name>`
|
39
47
|
|
40
48
|
# preview
|
41
49
|
|
data/exe/christmas_tree
CHANGED
@@ -1,21 +1,23 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
require '
|
3
|
-
require_relative '../lib/christmas_tree'
|
2
|
+
require 'optparse'
|
4
3
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
options = {}
|
5
|
+
OptionParser.new do |opts|
|
6
|
+
opts.banner = "Usage: christmas_tree [options]"
|
7
|
+
|
8
|
+
opts.on("-nNAME", "--name=NAME", "name") do |name|
|
9
|
+
options[:name] = name
|
10
|
+
end
|
9
11
|
|
10
|
-
|
11
|
-
|
12
|
-
|
12
|
+
opts.on("-mNAME", "--merry_to=NAME", "name") do |name|
|
13
|
+
options[:name] = name
|
14
|
+
end
|
15
|
+
end.parse!
|
13
16
|
|
14
|
-
opts.on("-mNAME", "--merry_to=NAME", "name") do |name|
|
15
|
-
options[:name] = name
|
16
|
-
end
|
17
|
-
end.parse!
|
18
17
|
|
18
|
+
begin
|
19
|
+
require 'curses'
|
20
|
+
require_relative '../lib/christmas_tree'
|
19
21
|
ChristmasTree::Tree.new(options[:name]).draw
|
20
22
|
ensure
|
21
23
|
Curses.close_screen
|
data/lib/christmas_tree.rb
CHANGED
@@ -1,15 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative "christmas_tree/version"
|
4
|
-
|
5
|
-
require 'optparse'
|
6
4
|
require 'curses'
|
7
5
|
|
8
|
-
|
9
|
-
Curses.init_screen
|
10
|
-
Curses.noecho
|
11
|
-
Curses.curs_set(0)
|
12
|
-
|
13
6
|
COLORS_ORDER = [
|
14
7
|
:black, :red, :green, :yellow, :blue, :magenta, :cyan, :white,
|
15
8
|
:bright_black, :bright_red, :bright_green, :bright_yellow,
|
@@ -54,6 +47,7 @@ module ChristmasTree
|
|
54
47
|
class Tree
|
55
48
|
CHAR_SPACE = ' '
|
56
49
|
def initialize(name = nil, layer_count = 10)
|
50
|
+
init_curses
|
57
51
|
@name = name
|
58
52
|
@buffer_count = layer_count
|
59
53
|
@scale = 3
|
@@ -65,6 +59,16 @@ module ChristmasTree
|
|
65
59
|
@width = nil
|
66
60
|
end
|
67
61
|
|
62
|
+
def init_curses
|
63
|
+
Curses.init_screen
|
64
|
+
Curses.noecho
|
65
|
+
Curses.curs_set(0)
|
66
|
+
end
|
67
|
+
|
68
|
+
def tree_star
|
69
|
+
@buffer << [Token.new("★", :yellow, :bold)]
|
70
|
+
end
|
71
|
+
|
68
72
|
def tree_crown
|
69
73
|
(1..@buffer_count).each do |count|
|
70
74
|
total = 2*count-1
|
@@ -138,6 +142,7 @@ module ChristmasTree
|
|
138
142
|
def draw_canvas
|
139
143
|
@buffer = []
|
140
144
|
border(3)
|
145
|
+
tree_star
|
141
146
|
tree_crown
|
142
147
|
tree_trunk
|
143
148
|
footer_text
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: christmas_tree
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark24Code
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-12-
|
11
|
+
date: 2023-12-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: curses
|
@@ -36,7 +36,6 @@ files:
|
|
36
36
|
- README.md
|
37
37
|
- Rakefile
|
38
38
|
- christmas_tree.gemspec
|
39
|
-
- christmas_tree.rb
|
40
39
|
- demo.png
|
41
40
|
- exe/christmas_tree
|
42
41
|
- lib/christmas_tree.rb
|
data/christmas_tree.rb
DELETED
File without changes
|