youplot 0.3.0 → 0.3.5

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.
@@ -7,7 +7,7 @@ module YouPlot
7
7
  # * Here, I use Struct for 2 safety reason.
8
8
  # * The keys are static in Struct.
9
9
  # * Struct does not conflict with keyword arguments. Hash dose.
10
- Params = Struct.new(
10
+ PlotParams = Struct.new(
11
11
  # Sort me!
12
12
  :title,
13
13
  :width,
@@ -3,10 +3,11 @@
3
3
  require 'csv'
4
4
 
5
5
  module YouPlot
6
- module Preprocessing
6
+ # Read and interpret Delimiter-separated values format file or stream.
7
+ module DSV
7
8
  module_function
8
9
 
9
- def input(input, delimiter, headers, transpose)
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 transpose
60
- if headers
61
- arr.map { |row| row[1..-1] }
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 headers
66
- transpose2(arr[1..-1])
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module YouPlot
4
- VERSION = '0.3.0'
4
+ VERSION = '0.3.5'
5
5
  end
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.0
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: 2020-11-23 00:00:00.000000000 Z
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: "Create ASCII charts on the terminal with data from standard streams
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/params.rb
114
+ - lib/youplot/command/options.rb
115
115
  - lib/youplot/command/parser.rb
116
- - lib/youplot/preprocessing.rb
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.1.4
138
+ rubygems_version: 3.2.15
138
139
  signing_key:
139
140
  specification_version: 4
140
- summary: Create Ascii charts on your terminal.
141
+ summary: A command line tool for Unicode Plotting
141
142
  test_files: []