toucan_cli 0.0.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 +7 -0
- data/lib/toucan_cli/application.rb +55 -0
- data/lib/toucan_cli/configuration.rb +11 -0
- data/lib/toucan_cli/screen.rb +55 -0
- data/lib/toucan_cli/version.rb +3 -0
- data/lib/toucan_cli.rb +25 -0
- metadata +105 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: '02309cc6b95d6418d6cfd5f1cef7a435a4fb3eeb2ae9e62145a590f917150134'
|
4
|
+
data.tar.gz: 55b9aa47a1d796e401d654bea99b3ba025ca9e0ba84d11ca6748f1a9d36e9ceb
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 275ee10b73d37f1e1a559e769a49a21d233bf3769ba83e94c6e4ad969a2f0e3b5d2298971fbd50f39484f4e5e945df13a7179f872d9e4dc1e2fa01da35defaab
|
7
|
+
data.tar.gz: 322450d405bda89cae0243c644d0b77ea6f336deb9f879ac4787ea99aaac59c7ee8be82bb52345639631cafc938f4241e54992ca0d9cb18ee743f5ab0ac78061
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module ToucanCLI
|
2
|
+
class Application
|
3
|
+
def initialize
|
4
|
+
@screen = Screen.new
|
5
|
+
end
|
6
|
+
|
7
|
+
def inputs
|
8
|
+
Thread.new do
|
9
|
+
loop do
|
10
|
+
input = @screen.iqueue.pop
|
11
|
+
next unless input
|
12
|
+
|
13
|
+
yield(input)
|
14
|
+
refresh
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def outputs
|
20
|
+
@screen.start do
|
21
|
+
yield
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def outputs_loop
|
26
|
+
@screen.start do
|
27
|
+
loop do
|
28
|
+
yield
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def clear
|
34
|
+
@screen.owin.clear
|
35
|
+
refresh
|
36
|
+
end
|
37
|
+
|
38
|
+
def puts(string)
|
39
|
+
@screen.owin.addstr("#{string}\n")
|
40
|
+
refresh
|
41
|
+
end
|
42
|
+
|
43
|
+
def print(string)
|
44
|
+
@screen.owin.addstr(string)
|
45
|
+
refresh
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def refresh
|
51
|
+
@screen.owin.refresh
|
52
|
+
@screen.iwin.refresh
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module ToucanCLI
|
2
|
+
class Screen
|
3
|
+
attr_accessor :iqueue, :iwin, :owin
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
@iqueue = Queue.new
|
7
|
+
Curses.init_screen
|
8
|
+
Curses.crmode
|
9
|
+
|
10
|
+
draw_output_window
|
11
|
+
draw_input_window
|
12
|
+
feed_iqueue
|
13
|
+
end
|
14
|
+
|
15
|
+
def start
|
16
|
+
begin
|
17
|
+
loop do
|
18
|
+
yield
|
19
|
+
end
|
20
|
+
ensure
|
21
|
+
@iwin.close if @iwin
|
22
|
+
@owin.close if @owin
|
23
|
+
|
24
|
+
Curses.close_screen
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
# Curses::Window.new(height, width, top, left)
|
31
|
+
def draw_output_window
|
32
|
+
@owin = Curses::Window.new((Curses.lines - 2), Curses.cols, 0, 0)
|
33
|
+
@owin.setpos(0, 0)
|
34
|
+
@owin.scrollok(true)
|
35
|
+
@owin.setscrreg(0, (Curses.lines - 2))
|
36
|
+
@owin.refresh
|
37
|
+
end
|
38
|
+
|
39
|
+
def draw_input_window
|
40
|
+
@iwin = Curses::Window.new(1, Curses.cols, (Curses.lines - 1), 0)
|
41
|
+
@iwin.setpos(1, 2)
|
42
|
+
@iwin.scrollok(true)
|
43
|
+
end
|
44
|
+
|
45
|
+
def feed_iqueue
|
46
|
+
Thread.new do
|
47
|
+
loop do
|
48
|
+
@iwin.refresh
|
49
|
+
@iqueue << @iwin.getstr()
|
50
|
+
@iwin.clear
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
data/lib/toucan_cli.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'curses'
|
2
|
+
require 'thread'
|
3
|
+
|
4
|
+
require 'toucan_cli/application'
|
5
|
+
require 'toucan_cli/configuration'
|
6
|
+
require 'toucan_cli/screen'
|
7
|
+
require 'toucan_cli/version'
|
8
|
+
|
9
|
+
module ToucanCLI
|
10
|
+
class << self
|
11
|
+
attr_writer :configuration
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.configuration
|
15
|
+
@configuration ||= Configuration.new
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.reset
|
19
|
+
@configuration = Configuration.new
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.configure
|
23
|
+
yield configuration
|
24
|
+
end
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: toucan_cli
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Fernando Schuindt
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-09-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.16'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.16'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: curses
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.2'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.2'
|
69
|
+
description:
|
70
|
+
email:
|
71
|
+
- f.schuindtcs@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- lib/toucan_cli.rb
|
77
|
+
- lib/toucan_cli/application.rb
|
78
|
+
- lib/toucan_cli/configuration.rb
|
79
|
+
- lib/toucan_cli/screen.rb
|
80
|
+
- lib/toucan_cli/version.rb
|
81
|
+
homepage: https://github.com/fschuindt/toucan
|
82
|
+
licenses:
|
83
|
+
- MIT
|
84
|
+
metadata: {}
|
85
|
+
post_install_message:
|
86
|
+
rdoc_options: []
|
87
|
+
require_paths:
|
88
|
+
- lib
|
89
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - ">="
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
requirements: []
|
100
|
+
rubyforge_project:
|
101
|
+
rubygems_version: 2.7.6
|
102
|
+
signing_key:
|
103
|
+
specification_version: 4
|
104
|
+
summary: A Ruby framework to craft small yet amazing CLI applications.
|
105
|
+
test_files: []
|