youplot 0.3.0 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +165 -67
- data/exe/uplot +1 -1
- data/exe/youplot +1 -1
- data/lib/youplot.rb +9 -1
- data/lib/youplot/backends/processing.rb +24 -0
- data/lib/youplot/backends/unicode_plot_backend.rb +73 -36
- data/lib/youplot/command.rb +152 -58
- data/lib/youplot/command/options.rb +19 -0
- data/lib/youplot/command/parser.rb +227 -183
- data/lib/youplot/command/{params.rb → plot_params.rb} +1 -1
- data/lib/youplot/{preprocessing.rb → dsv.rb} +15 -24
- data/lib/youplot/version.rb +1 -1
- metadata +9 -8
@@ -3,10 +3,11 @@
|
|
3
3
|
require 'csv'
|
4
4
|
|
5
5
|
module YouPlot
|
6
|
-
|
6
|
+
# Read and interpret Delimiter-separated values format file or stream.
|
7
|
+
module DSV
|
7
8
|
module_function
|
8
9
|
|
9
|
-
def
|
10
|
+
def parse(input, delimiter, headers, transpose)
|
10
11
|
arr = parse_as_csv(input, delimiter)
|
11
12
|
headers = get_headers(arr, headers, transpose)
|
12
13
|
series = get_series(arr, headers, transpose)
|
@@ -24,10 +25,10 @@ module YouPlot
|
|
24
25
|
Data.new(headers, series)
|
25
26
|
elsif h_size > s_size
|
26
27
|
warn "\e[35mThe number of headers is greater than the number of series.\e[0m"
|
27
|
-
exit 1
|
28
|
+
exit 1 if YouPlot.run_as_executable?
|
28
29
|
elsif h_size < s_size
|
29
30
|
warn "\e[35mThe number of headers is less than the number of series.\e[0m"
|
30
|
-
exit 1
|
31
|
+
exit 1 if YouPlot.run_as_executable?
|
31
32
|
end
|
32
33
|
end
|
33
34
|
end
|
@@ -56,31 +57,21 @@ module YouPlot
|
|
56
57
|
end
|
57
58
|
|
58
59
|
def get_series(arr, headers, transpose)
|
59
|
-
if
|
60
|
-
if
|
61
|
-
|
60
|
+
if headers
|
61
|
+
if arr.size > 1
|
62
|
+
if transpose
|
63
|
+
arr.map { |row| row[1..-1] }
|
64
|
+
else
|
65
|
+
transpose2(arr[1..-1])
|
66
|
+
end
|
62
67
|
else
|
63
|
-
arr
|
68
|
+
Array.new(arr[0].size, [])
|
64
69
|
end
|
65
|
-
elsif
|
66
|
-
|
70
|
+
elsif transpose
|
71
|
+
arr
|
67
72
|
else
|
68
73
|
transpose2(arr)
|
69
74
|
end
|
70
75
|
end
|
71
|
-
|
72
|
-
def count_values(arr)
|
73
|
-
# tally was added in Ruby 2.7
|
74
|
-
if Enumerable.method_defined? :tally
|
75
|
-
arr.tally
|
76
|
-
else
|
77
|
-
# https://github.com/marcandre/backports
|
78
|
-
arr.each_with_object(Hash.new(0)) { |item, res| res[item] += 1 }
|
79
|
-
.tap { |h| h.default = nil }
|
80
|
-
end
|
81
|
-
.sort { |a, b| a[1] <=> b[1] }
|
82
|
-
.reverse
|
83
|
-
.transpose
|
84
|
-
end
|
85
76
|
end
|
86
77
|
end
|
data/lib/youplot/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: youplot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kojix2
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-05-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: unicode_plot
|
@@ -94,8 +94,7 @@ dependencies:
|
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
|
-
description:
|
98
|
-
in the \npipeline. \n"
|
97
|
+
description: A command line tool for Unicode Plotting
|
99
98
|
email:
|
100
99
|
- 2xijok@gmail.com
|
101
100
|
executables:
|
@@ -109,11 +108,13 @@ files:
|
|
109
108
|
- exe/uplot
|
110
109
|
- exe/youplot
|
111
110
|
- lib/youplot.rb
|
111
|
+
- lib/youplot/backends/processing.rb
|
112
112
|
- lib/youplot/backends/unicode_plot_backend.rb
|
113
113
|
- lib/youplot/command.rb
|
114
|
-
- lib/youplot/command/
|
114
|
+
- lib/youplot/command/options.rb
|
115
115
|
- lib/youplot/command/parser.rb
|
116
|
-
- lib/youplot/
|
116
|
+
- lib/youplot/command/plot_params.rb
|
117
|
+
- lib/youplot/dsv.rb
|
117
118
|
- lib/youplot/version.rb
|
118
119
|
homepage: https://github.com/kojix2/youplot
|
119
120
|
licenses:
|
@@ -134,8 +135,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
134
135
|
- !ruby/object:Gem::Version
|
135
136
|
version: '0'
|
136
137
|
requirements: []
|
137
|
-
rubygems_version: 3.
|
138
|
+
rubygems_version: 3.2.15
|
138
139
|
signing_key:
|
139
140
|
specification_version: 4
|
140
|
-
summary:
|
141
|
+
summary: A command line tool for Unicode Plotting
|
141
142
|
test_files: []
|