mirror of
https://github.com/red-data-tools/YouPlot.git
synced 2025-09-19 02:18:08 +08:00
Compare commits
2 Commits
v0.4.4
...
kojix2-rea
Author | SHA1 | Date | |
---|---|---|---|
![]() |
b8a187a1bf | ||
![]() |
87bb24e236 |
5
.github/workflows/ci.yml
vendored
5
.github/workflows/ci.yml
vendored
@@ -7,11 +7,12 @@ jobs:
|
||||
strategy:
|
||||
matrix:
|
||||
os: ['ubuntu', 'macos']
|
||||
ruby: [ '2.4', '2.5', '2.6', '2.7', '3.0', '3.1' ]
|
||||
ruby: [ '2.4', '2.5', '2.6', '2.7', '3.0' ]
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: ruby/setup-ruby@v1
|
||||
with:
|
||||
ruby-version: ${{ matrix.ruby }}
|
||||
bundler-cache: true
|
||||
- run: gem install bundler
|
||||
- run: bundle install
|
||||
- run: bundle exec rake test
|
||||
|
23
.github/workflows/doc.yml
vendored
23
.github/workflows/doc.yml
vendored
@@ -1,23 +0,0 @@
|
||||
name: doc
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: ruby/setup-ruby@v1
|
||||
with:
|
||||
ruby-version: 3.1
|
||||
- name: Generate document
|
||||
run: gem install -N yard && yard doc
|
||||
- name: Publish Documentation on GitHub Pages
|
||||
uses: peaceiris/actions-gh-pages@v3
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
publish_dir: ./doc
|
6
Gemfile
6
Gemfile
@@ -4,9 +4,3 @@ source 'https://rubygems.org'
|
||||
|
||||
# Specify your gem's dependencies in youplot.gemspec
|
||||
gemspec
|
||||
|
||||
group :test do
|
||||
gem 'rake'
|
||||
gem 'simplecov'
|
||||
gem 'test-unit'
|
||||
end
|
||||
|
@@ -241,10 +241,6 @@ bundle exec rake install # Installation from source code
|
||||
bundle exec exe/uplot # Run youplot (Try out the edited code)
|
||||
```
|
||||
|
||||
Do you need commit rights to my repository?
|
||||
Do you want to get admin rights and take over the project?
|
||||
If so, please feel free to contact us.
|
||||
|
||||
### Acknowledgements
|
||||
|
||||
* [sampo grafiikka](https://jypg.net/sampo_grafiikka) - Project logo creation
|
||||
|
@@ -6,12 +6,6 @@ require_relative 'youplot/parameters'
|
||||
require_relative 'youplot/command'
|
||||
|
||||
module YouPlot
|
||||
# @run_as_executable = true / false
|
||||
# YouPlot behaves slightly differently when run as a command line tool
|
||||
# and when run as a script (e.g. for testing). In the event of an error,
|
||||
# when run as a command line tool, YouPlot will display a short error message
|
||||
# and exit abnormally. When run as a script, it will just raise an error.
|
||||
@run_as_executable = false
|
||||
class << self
|
||||
attr_accessor :run_as_executable
|
||||
|
||||
@@ -19,4 +13,5 @@ module YouPlot
|
||||
@run_as_executable
|
||||
end
|
||||
end
|
||||
@run_as_executable = false
|
||||
end
|
||||
|
@@ -127,10 +127,11 @@ module YouPlot
|
||||
|
||||
def plot_xyxy(data, method1, params)
|
||||
headers = data.headers
|
||||
series2 = data.series
|
||||
.map { |s| s.map(&:to_f) }
|
||||
.each_slice(2).to_a
|
||||
series = data.series
|
||||
method2 = get_method2(method1)
|
||||
series.map! { |s| s.map(&:to_f) }
|
||||
series2 = series.each_slice(2).to_a
|
||||
series = nil
|
||||
params.name ||= headers[0] if headers
|
||||
params.xlim ||= series2.map(&:first).flatten.minmax # why need?
|
||||
params.ylim ||= series2.map(&:last).flatten.minmax # why need?
|
||||
|
@@ -40,24 +40,6 @@ module YouPlot
|
||||
return
|
||||
end
|
||||
|
||||
# config command
|
||||
if @command == :config
|
||||
if ENV['MYYOUPLOTRC']
|
||||
puts "config file : #{ENV['MYYOUPLOTRC']}"
|
||||
puts parser.config.inspect
|
||||
else
|
||||
puts <<~EOS
|
||||
You don't have a config file. The default config file paths are:
|
||||
./.youplot.yml, ./.youplotrc, ~/.youplot.yml, ~/.youplotrc
|
||||
You can specify a config file with the environment variable MYYOUPLOTRC.
|
||||
File format is YAML. For example:
|
||||
width : 40
|
||||
height : 20
|
||||
EOS
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
# progressive mode
|
||||
if options[:progressive]
|
||||
stop = false
|
||||
@@ -81,15 +63,9 @@ module YouPlot
|
||||
# normal mode
|
||||
else
|
||||
# Sometimes the input file does not end with a newline code.
|
||||
begin
|
||||
begin
|
||||
input = Kernel.gets(nil)
|
||||
rescue Errno::ENOENT => e
|
||||
warn e.message
|
||||
next
|
||||
end
|
||||
while (input = Kernel.gets(nil))
|
||||
main(input)
|
||||
end until input
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -159,12 +135,7 @@ module YouPlot
|
||||
rescue CSV::MalformedCSVError => e
|
||||
warn 'Failed to parse the text. '
|
||||
warn 'Please try to set the correct character encoding with --encoding option.'
|
||||
warn e.backtrace.grep(/youplot/).first
|
||||
exit 1
|
||||
rescue ArgumentError => e
|
||||
warn 'Failed to parse the text. '
|
||||
warn e.backtrace.grep(/youplot/).first
|
||||
exit 1
|
||||
raise e
|
||||
end
|
||||
|
||||
data
|
||||
|
@@ -9,8 +9,7 @@ module YouPlot
|
||||
class Error < StandardError; end
|
||||
|
||||
attr_reader :command, :options, :params,
|
||||
:main_parser, :sub_parser,
|
||||
:config_file, :config
|
||||
:main_parser, :sub_parser
|
||||
|
||||
def initialize
|
||||
@command = nil
|
||||
@@ -29,55 +28,6 @@ module YouPlot
|
||||
)
|
||||
|
||||
@params = Parameters.new
|
||||
|
||||
if @config_file = find_config_file
|
||||
ENV['MYYOUPLOTRC'] = @config_file
|
||||
@config = read_config_file(config_file)
|
||||
configure(config)
|
||||
end
|
||||
end
|
||||
|
||||
def candidate_paths
|
||||
paths = []
|
||||
paths << ENV['MYYOUPLOTRC'] if ENV['MYYOUPLOTRC']
|
||||
paths << '.youplot.yml'
|
||||
paths << '.youplotrc'
|
||||
paths << File.join(ENV['HOME'], '.youplotrc') if ENV['HOME']
|
||||
paths << File.join(ENV['HOME'], '.youplot.yml') if ENV['HOME']
|
||||
paths
|
||||
end
|
||||
|
||||
def find_config_file
|
||||
config_file_path = nil
|
||||
candidate_paths.each do |file|
|
||||
path = File.expand_path(file)
|
||||
if File.exist?(path)
|
||||
config_file_path = path
|
||||
break
|
||||
end
|
||||
end
|
||||
config_file_path
|
||||
end
|
||||
|
||||
def read_config_file(path)
|
||||
require 'yaml'
|
||||
YAML.load_file(path)
|
||||
end
|
||||
|
||||
def configure(config)
|
||||
option_members = @options.members
|
||||
param_members = @params.members
|
||||
# It would be more useful to be able to configure by plot type
|
||||
config.each do |k, v|
|
||||
k = k.to_sym
|
||||
if option_members.include?(k)
|
||||
@options[k] = v
|
||||
elsif param_members.include?(k)
|
||||
@params[k] = v
|
||||
else
|
||||
raise Error, "Unknown option/param: #{k}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def create_base_parser
|
||||
@@ -145,7 +95,7 @@ module YouPlot
|
||||
parser.on('-M', '--monochrome', TrueClass, 'no colouring even if writing to a tty') do |_v|
|
||||
UnicodePlot::IOContext.define_method(:color?) { false } # FIXME
|
||||
end
|
||||
parser.on('--encoding STR', String, 'specify the input encoding') do |v|
|
||||
parser.on('--encoding STR', String, 'Specify the input encoding') do |v|
|
||||
options[:encoding] = v
|
||||
end
|
||||
# Optparse adds the help option, but it doesn't show up in usage.
|
||||
@@ -327,8 +277,6 @@ module YouPlot
|
||||
options[:color_names] = v
|
||||
end
|
||||
|
||||
when :config
|
||||
|
||||
else
|
||||
error_message = "uplot: unrecognized command '#{command}'"
|
||||
if YouPlot.run_as_executable?
|
||||
|
@@ -1,5 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module YouPlot
|
||||
VERSION = '0.4.4'
|
||||
VERSION = '0.4.2'
|
||||
end
|
||||
|
@@ -19,5 +19,10 @@ Gem::Specification.new do |spec|
|
||||
spec.executables = %w[uplot youplot]
|
||||
spec.require_paths = ['lib']
|
||||
|
||||
spec.add_dependency 'unicode_plot', '>= 0.0.5'
|
||||
spec.add_runtime_dependency 'unicode_plot'
|
||||
spec.add_development_dependency 'bundler'
|
||||
spec.add_development_dependency 'rake'
|
||||
spec.add_development_dependency 'rubocop'
|
||||
spec.add_development_dependency 'simplecov'
|
||||
spec.add_development_dependency 'test-unit'
|
||||
end
|
||||
|
Reference in New Issue
Block a user