youplot 0.4.3 → 0.4.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -0
- data/lib/youplot/command.rb +32 -3
- data/lib/youplot/parser.rb +53 -1
- data/lib/youplot/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a924bdaf315e9b7b8afa65d0f02cdbb22c213fbf80908e2ae30d12d1bc3d9338
|
4
|
+
data.tar.gz: ea42f957954e37d8d1f4eaf3c789e52188f96aff1afbf99dae6179be14ab06d5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 602975a225b979ad6ca2a43ef038f18a23b48f034ddb2a06ffa3f4ca0d61cb805e6ef314afd00a897f8bc869fcce8b27fee895ac6e0f3f82bc7cbe8531369632
|
7
|
+
data.tar.gz: 0d9f77815d3c2e7f338dfe42f0b501a51dd9dd3de06cc367a7ee3de52e049a6a7e55ee3afc4cc2a525a724b07412f5807feba3c9aea33966d407d38d96fb8601
|
data/README.md
CHANGED
@@ -241,6 +241,10 @@ bundle exec rake install # Installation from source code
|
|
241
241
|
bundle exec exe/uplot # Run youplot (Try out the edited code)
|
242
242
|
```
|
243
243
|
|
244
|
+
Do you need commit rights to my repository?
|
245
|
+
Do you want to get admin rights and take over the project?
|
246
|
+
If so, please feel free to contact us.
|
247
|
+
|
244
248
|
### Acknowledgements
|
245
249
|
|
246
250
|
* [sampo grafiikka](https://jypg.net/sampo_grafiikka) - Project logo creation
|
data/lib/youplot/command.rb
CHANGED
@@ -40,6 +40,24 @@ module YouPlot
|
|
40
40
|
return
|
41
41
|
end
|
42
42
|
|
43
|
+
# config command
|
44
|
+
if @command == :config
|
45
|
+
if ENV['MYYOUPLOTRC']
|
46
|
+
puts "config file : #{ENV['MYYOUPLOTRC']}"
|
47
|
+
puts parser.config.inspect
|
48
|
+
else
|
49
|
+
puts <<~EOS
|
50
|
+
You don't have a config file. The default config file paths are:
|
51
|
+
./.youplot.yml, ./.youplotrc, ~/.youplot.yml, ~/.youplotrc
|
52
|
+
You can specify a config file with the environment variable MYYOUPLOTRC.
|
53
|
+
File format is YAML. For example:
|
54
|
+
width : 40
|
55
|
+
height : 20
|
56
|
+
EOS
|
57
|
+
end
|
58
|
+
return
|
59
|
+
end
|
60
|
+
|
43
61
|
# progressive mode
|
44
62
|
if options[:progressive]
|
45
63
|
stop = false
|
@@ -63,9 +81,15 @@ module YouPlot
|
|
63
81
|
# normal mode
|
64
82
|
else
|
65
83
|
# Sometimes the input file does not end with a newline code.
|
66
|
-
|
84
|
+
begin
|
85
|
+
begin
|
86
|
+
input = Kernel.gets(nil)
|
87
|
+
rescue Errno::ENOENT => e
|
88
|
+
warn e.message
|
89
|
+
next
|
90
|
+
end
|
67
91
|
main(input)
|
68
|
-
end
|
92
|
+
end until input
|
69
93
|
end
|
70
94
|
end
|
71
95
|
|
@@ -135,7 +159,12 @@ module YouPlot
|
|
135
159
|
rescue CSV::MalformedCSVError => e
|
136
160
|
warn 'Failed to parse the text. '
|
137
161
|
warn 'Please try to set the correct character encoding with --encoding option.'
|
138
|
-
|
162
|
+
warn e.backtrace.grep(/youplot/).first
|
163
|
+
exit 1
|
164
|
+
rescue ArgumentError => e
|
165
|
+
warn 'Failed to parse the text. '
|
166
|
+
warn e.backtrace.grep(/youplot/).first
|
167
|
+
exit 1
|
139
168
|
end
|
140
169
|
|
141
170
|
data
|
data/lib/youplot/parser.rb
CHANGED
@@ -9,7 +9,8 @@ module YouPlot
|
|
9
9
|
class Error < StandardError; end
|
10
10
|
|
11
11
|
attr_reader :command, :options, :params,
|
12
|
-
:main_parser, :sub_parser
|
12
|
+
:main_parser, :sub_parser,
|
13
|
+
:config_file, :config
|
13
14
|
|
14
15
|
def initialize
|
15
16
|
@command = nil
|
@@ -28,6 +29,55 @@ module YouPlot
|
|
28
29
|
)
|
29
30
|
|
30
31
|
@params = Parameters.new
|
32
|
+
|
33
|
+
if @config_file = find_config_file
|
34
|
+
ENV['MYYOUPLOTRC'] = @config_file
|
35
|
+
@config = read_config_file(config_file)
|
36
|
+
configure(config)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def candidate_paths
|
41
|
+
paths = []
|
42
|
+
paths << ENV['MYYOUPLOTRC'] if ENV['MYYOUPLOTRC']
|
43
|
+
paths << '.youplot.yml'
|
44
|
+
paths << '.youplotrc'
|
45
|
+
paths << File.join(ENV['HOME'], '.youplotrc') if ENV['HOME']
|
46
|
+
paths << File.join(ENV['HOME'], '.youplot.yml') if ENV['HOME']
|
47
|
+
paths
|
48
|
+
end
|
49
|
+
|
50
|
+
def find_config_file
|
51
|
+
config_file_path = nil
|
52
|
+
candidate_paths.each do |file|
|
53
|
+
path = File.expand_path(file)
|
54
|
+
if File.exist?(path)
|
55
|
+
config_file_path = path
|
56
|
+
break
|
57
|
+
end
|
58
|
+
end
|
59
|
+
config_file_path
|
60
|
+
end
|
61
|
+
|
62
|
+
def read_config_file(path)
|
63
|
+
require 'yaml'
|
64
|
+
YAML.load_file(path)
|
65
|
+
end
|
66
|
+
|
67
|
+
def configure(config)
|
68
|
+
option_members = @options.members
|
69
|
+
param_members = @params.members
|
70
|
+
# It would be more useful to be able to configure by plot type
|
71
|
+
config.each do |k, v|
|
72
|
+
k = k.to_sym
|
73
|
+
if option_members.include?(k)
|
74
|
+
@options[k] = v
|
75
|
+
elsif param_members.include?(k)
|
76
|
+
@params[k] = v
|
77
|
+
else
|
78
|
+
raise Error, "Unknown option/param: #{k}"
|
79
|
+
end
|
80
|
+
end
|
31
81
|
end
|
32
82
|
|
33
83
|
def create_base_parser
|
@@ -277,6 +327,8 @@ module YouPlot
|
|
277
327
|
options[:color_names] = v
|
278
328
|
end
|
279
329
|
|
330
|
+
when :config
|
331
|
+
|
280
332
|
else
|
281
333
|
error_message = "uplot: unrecognized command '#{command}'"
|
282
334
|
if YouPlot.run_as_executable?
|
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.4.
|
4
|
+
version: 0.4.4
|
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: 2022-08-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: unicode_plot
|
@@ -65,7 +65,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
65
65
|
- !ruby/object:Gem::Version
|
66
66
|
version: '0'
|
67
67
|
requirements: []
|
68
|
-
rubygems_version: 3.
|
68
|
+
rubygems_version: 3.3.7
|
69
69
|
signing_key:
|
70
70
|
specification_version: 4
|
71
71
|
summary: A command line tool for Unicode Plotting
|