termplot 0.3.0 → 0.3.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 +4 -4
- data/.gitignore +2 -0
- data/README.md +7 -3
- data/doc/demo.png +0 -0
- data/lib/termplot/consumers/base_consumer.rb +1 -1
- data/lib/termplot/consumers/single_source_consumer.rb +1 -1
- data/lib/termplot/message_broker.rb +6 -3
- data/lib/termplot/version.rb +1 -1
- metadata +6 -7
- data/lib/termplot/widget_dsl.rb +0 -130
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '068a1b08253b8e5993572546e7b73409b0ff5750a1aaa671d3d6c907b621128f'
|
4
|
+
data.tar.gz: a6ce340dac417d5999e7fd6018efd931731ecabcc2d894ff8430a5bd6c9d6bb3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fe102cf42e2e1017ca2f3327c65847dbece92aeeea5de3c05b72e384bf3cfc6eb0dd602c7fa03585282ea747e88c167e8259e724ecbd30b64618c4dbce9ddc53
|
7
|
+
data.tar.gz: 13967f3be92508cc0fcc8dcc65eb9f0625ac359e30853ceaeed30e778863a7298eef38b55efe64d615ca61e9e37bcd781247c98b5e64967a46af9208deacf80c
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# Termplot
|
2
2
|
|
3
|
+
[](https://badge.fury.io/rb/termplot)
|
4
|
+
|
3
5
|
Termplot is a simple terminal plotting tool for visualising streaming data.
|
4
6
|
|
5
7
|

|
@@ -76,7 +78,7 @@ ping example.com |
|
|
76
78
|
```
|
77
79
|

|
78
80
|
|
79
|
-
##### Plot histogram of data from column 33 of a CSV file
|
81
|
+
##### Plot histogram of data from column 33 of a CSV file:
|
80
82
|
```
|
81
83
|
cat file.csv | cut -d, -f33 | tail -n +2 |
|
82
84
|
termplot -- --hist -r30 -t "Data" --color light_black
|
@@ -117,7 +119,7 @@ You can configure termplot to set up a multi-chart dashboard using a ruby
|
|
117
119
|
configuration file:
|
118
120
|
|
119
121
|
```
|
120
|
-
termplot --file FILE
|
122
|
+
termplot [--file/-f] FILE
|
121
123
|
```
|
122
124
|
|
123
125
|
The configuration file uses a simple ruby DSL to arrange charts into rows and
|
@@ -125,7 +127,9 @@ columns. Each chart will take a command and optionally an interval as well as
|
|
125
127
|
formatting options. Termplot will then run the command at the specified interval
|
126
128
|
and render the resulting data into the charts.
|
127
129
|
|
128
|
-
Example
|
130
|
+
#### Example
|
131
|
+
|
132
|
+
File (sample.rb):
|
129
133
|
```ruby
|
130
134
|
col do
|
131
135
|
row do
|
data/doc/demo.png
CHANGED
Binary file
|
@@ -31,7 +31,7 @@ module Termplot
|
|
31
31
|
Shell.init(clear: options.full_screen)
|
32
32
|
renderer_thread.start
|
33
33
|
|
34
|
-
# Blocks main thread
|
34
|
+
# Blocks main thread to produce values from the producer pool
|
35
35
|
producer_pool.start_and_block
|
36
36
|
|
37
37
|
# At this point producer threads have all exited, tell renderer to
|
@@ -29,8 +29,7 @@ module Termplot
|
|
29
29
|
|
30
30
|
def closed?
|
31
31
|
mutex.synchronize do
|
32
|
-
brokers.count
|
33
|
-
brokers.all?(:closed?)
|
32
|
+
(brokers.count == 0) || brokers.all?(&:closed?)
|
34
33
|
end
|
35
34
|
end
|
36
35
|
|
@@ -73,7 +72,7 @@ module Termplot
|
|
73
72
|
register_callbacks
|
74
73
|
end
|
75
74
|
|
76
|
-
def on_message(block
|
75
|
+
def on_message(&block)
|
77
76
|
on_message_callbacks.push(block)
|
78
77
|
end
|
79
78
|
|
@@ -92,6 +91,10 @@ module Termplot
|
|
92
91
|
queue.close
|
93
92
|
end
|
94
93
|
|
94
|
+
def closed?
|
95
|
+
queue.closed?
|
96
|
+
end
|
97
|
+
|
95
98
|
private
|
96
99
|
attr_reader :sender, :receiver, :queue, :on_message_callbacks
|
97
100
|
|
data/lib/termplot/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: termplot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martin Nyaga
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-10-18 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Plot time series charts in your terminal
|
14
14
|
email:
|
@@ -68,7 +68,6 @@ files:
|
|
68
68
|
- lib/termplot/shell.rb
|
69
69
|
- lib/termplot/utils/ansi_safe_string.rb
|
70
70
|
- lib/termplot/version.rb
|
71
|
-
- lib/termplot/widget_dsl.rb
|
72
71
|
- lib/termplot/widgets.rb
|
73
72
|
- lib/termplot/widgets/base_widget.rb
|
74
73
|
- lib/termplot/widgets/border.rb
|
@@ -86,7 +85,7 @@ metadata:
|
|
86
85
|
homepage_uri: https://github.com/Martin-Nyaga/termplot
|
87
86
|
source_code_uri: https://github.com/Martin-Nyaga/termplot
|
88
87
|
changelog_uri: https://github.com/Martin-Nyaga/termplot
|
89
|
-
post_install_message:
|
88
|
+
post_install_message:
|
90
89
|
rdoc_options: []
|
91
90
|
require_paths:
|
92
91
|
- lib
|
@@ -101,8 +100,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
101
100
|
- !ruby/object:Gem::Version
|
102
101
|
version: '0'
|
103
102
|
requirements: []
|
104
|
-
rubygems_version: 3.
|
105
|
-
signing_key:
|
103
|
+
rubygems_version: 3.2.3
|
104
|
+
signing_key:
|
106
105
|
specification_version: 4
|
107
106
|
summary: Plot time series charts in your terminal
|
108
107
|
test_files: []
|
data/lib/termplot/widget_dsl.rb
DELETED
@@ -1,130 +0,0 @@
|
|
1
|
-
require "termplot/positioned_widget"
|
2
|
-
require "termplot/widgets"
|
3
|
-
|
4
|
-
module Termplot
|
5
|
-
module DSL
|
6
|
-
module Widgets
|
7
|
-
def timeseries(attrs)
|
8
|
-
attrs = merge_defaults(attrs)
|
9
|
-
children.push(TimeSeriesConfig.new(attrs))
|
10
|
-
end
|
11
|
-
|
12
|
-
def statistics(attrs)
|
13
|
-
attrs = merge_defaults(attrs)
|
14
|
-
children.push(StatisticsConfig.new(attrs))
|
15
|
-
end
|
16
|
-
|
17
|
-
def histogram(attrs)
|
18
|
-
attrs = merge_defaults(attrs)
|
19
|
-
children.push(HistogramConfig.new(attrs))
|
20
|
-
end
|
21
|
-
|
22
|
-
private
|
23
|
-
|
24
|
-
def merge_defaults(attrs)
|
25
|
-
Termplot::Options.default_options.merge(attrs)
|
26
|
-
end
|
27
|
-
|
28
|
-
class WidgetConfig
|
29
|
-
attr_reader(
|
30
|
-
:title,
|
31
|
-
:command,
|
32
|
-
:interval,
|
33
|
-
:col,
|
34
|
-
:row,
|
35
|
-
:cols,
|
36
|
-
:rows,
|
37
|
-
:debug
|
38
|
-
)
|
39
|
-
|
40
|
-
def initialize(opts)
|
41
|
-
@title = opts[:title]
|
42
|
-
|
43
|
-
@command = opts[:command]
|
44
|
-
@interval = opts[:interval]
|
45
|
-
@debug = opts[:debug]
|
46
|
-
|
47
|
-
post_initialize(opts)
|
48
|
-
end
|
49
|
-
|
50
|
-
def post_initialize(opts)
|
51
|
-
# Implemented in subclasses
|
52
|
-
end
|
53
|
-
|
54
|
-
def set_dimensions(rows, cols, start_row, start_col)
|
55
|
-
@rows = rows
|
56
|
-
@cols = cols
|
57
|
-
@row = start_row
|
58
|
-
@col = start_col
|
59
|
-
end
|
60
|
-
|
61
|
-
def flatten
|
62
|
-
self
|
63
|
-
end
|
64
|
-
|
65
|
-
def positioned_widget
|
66
|
-
@positioned_widget ||= PositionedWidget.new(
|
67
|
-
row: row,
|
68
|
-
col: col,
|
69
|
-
widget: widget
|
70
|
-
)
|
71
|
-
end
|
72
|
-
|
73
|
-
def widget
|
74
|
-
raise "Must be implemented"
|
75
|
-
end
|
76
|
-
|
77
|
-
def producer_options
|
78
|
-
ProducerOptions.new(command: command, interval: interval)
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
class TimeSeriesConfig < WidgetConfig
|
83
|
-
attr_reader :color, :line_style
|
84
|
-
def post_initialize(opts)
|
85
|
-
@color = opts[:color]
|
86
|
-
@line_style = opts[:line_style]
|
87
|
-
end
|
88
|
-
|
89
|
-
def widget
|
90
|
-
@widget ||= Termplot::Widgets::TimeSeriesWidget.new(
|
91
|
-
title: title,
|
92
|
-
line_style: line_style,
|
93
|
-
color: color,
|
94
|
-
cols: cols,
|
95
|
-
rows: rows,
|
96
|
-
debug: debug
|
97
|
-
)
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
class StatisticsConfig < WidgetConfig
|
102
|
-
def widget
|
103
|
-
@widget ||= Termplot::Widgets::StatisticsWidget.new(
|
104
|
-
title: title,
|
105
|
-
cols: cols,
|
106
|
-
rows: rows,
|
107
|
-
debug: debug
|
108
|
-
)
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
class HistogramConfig < WidgetConfig
|
113
|
-
attr_reader :color
|
114
|
-
def post_initialize(opts)
|
115
|
-
@color = opts[:color]
|
116
|
-
end
|
117
|
-
|
118
|
-
def widget
|
119
|
-
@widget ||= Termplot::Widgets::HistogramWidget.new(
|
120
|
-
title: title,
|
121
|
-
color: color,
|
122
|
-
cols: cols,
|
123
|
-
rows: rows,
|
124
|
-
debug: debug
|
125
|
-
)
|
126
|
-
end
|
127
|
-
end
|
128
|
-
end
|
129
|
-
end
|
130
|
-
end
|