diff --git a/UnicodePlot.html b/UnicodePlot.html index e85346a..c02c0ff 100644 --- a/UnicodePlot.html +++ b/UnicodePlot.html @@ -6,7 +6,7 @@
# File 'lib/youplot/command.rb', line 30 @@ -691,6 +709,24 @@ 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 [:progressive] stop = false @@ -767,9 +803,9 @@ diff --git a/YouPlot/DSV.html b/YouPlot/DSV.html index 2f568fd..36fbac3 100644 --- a/YouPlot/DSV.html +++ b/YouPlot/DSV.html @@ -6,7 +6,7 @@Module: YouPlot::DSV - — Documentation by YARD 0.9.27 + — Documentation by YARD 0.9.28 @@ -460,9 +460,9 @@ diff --git a/YouPlot/Data.html b/YouPlot/Data.html index 6616693..6686251 100644 --- a/YouPlot/Data.html +++ b/YouPlot/Data.html @@ -6,7 +6,7 @@Class: YouPlot::Data - — Documentation by YARD 0.9.27 + — Documentation by YARD 0.9.28 @@ -300,9 +300,9 @@ diff --git a/YouPlot/Options.html b/YouPlot/Options.html index 5dafa14..8e89390 100644 --- a/YouPlot/Options.html +++ b/YouPlot/Options.html @@ -6,7 +6,7 @@Class: YouPlot::Options - — Documentation by YARD 0.9.27 + — Documentation by YARD 0.9.28 @@ -1103,9 +1103,9 @@ diff --git a/YouPlot/Parameters.html b/YouPlot/Parameters.html index 75d7d5b..6c38d83 100644 --- a/YouPlot/Parameters.html +++ b/YouPlot/Parameters.html @@ -6,7 +6,7 @@Class: YouPlot::Parameters - — Documentation by YARD 0.9.27 + — Documentation by YARD 0.9.28 @@ -1881,9 +1881,9 @@ diff --git a/YouPlot/Parser.html b/YouPlot/Parser.html index c289f44..b719c8a 100644 --- a/YouPlot/Parser.html +++ b/YouPlot/Parser.html @@ -6,7 +6,7 @@Class: YouPlot::Parser - — Documentation by YARD 0.9.27 + — Documentation by YARD 0.9.28 @@ -153,6 +153,64 @@Returns the value of attribute command.
+ + + +
Returns the value of attribute config.
+Returns the value of attribute config_file.
+-14 15 16 17 @@ -624,10 +769,17 @@ 28 29 30 -31+31 +32 +33 +34 +35 +36 +37 +38
# File 'lib/youplot/parser.rb', line 14 +# File 'lib/youplot/parser.rb', line 15 def initialize @command = nil @@ -646,6 +798,12 @@ ) @params = Parameters.new + + if @config_file = find_config_file + ENV['MYYOUPLOTRC'] = @config_file + @config = read_config_file(config_file) + configure(config) + end end
Returns the value of attribute config.
+ + +
+ + + +11 +12 +13+ |
+
+ # File 'lib/youplot/parser.rb', line 11 + +def config + @config +end+ |
+
Returns the value of attribute config_file.
+ + +
+ + + +11 +12 +13+ |
+
+ # File 'lib/youplot/parser.rb', line 11 + +def config_file + @config_file +end+ |
+
-33 -34 -35 -36 -37 -38 -39 40 41 42 @@ -909,25 +1146,40 @@ 45 46 47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 +48+ +
# File 'lib/youplot/parser.rb', line 40 + +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+
+ + + 67 68 69 @@ -941,8 +1193,45 @@ 77 78 79 -80 -81 +80+ |
+
+ # File 'lib/youplot/parser.rb', line 67 + +def configure(config) + option_member = @options.members + params_member = @params.members + config.each do |k, v| + k = k.to_sym + if option_member.include?(k) + @options[k] = v + elsif params_member.include?(k) + @params[k] = v + else + raise Error, "Unknown option/param: #{k}" + end + end +end+ |
+
+ + + 82 83 84 @@ -973,10 +1262,59 @@ 109 110 111 -112+112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 |
- # File 'lib/youplot/parser.rb', line 33 +# File 'lib/youplot/parser.rb', line 82 def create_base_parser OptionParser.new do |parser| @@ -1078,45 +1416,45 @@-114 -115 -116 -117 -118 -119 -120 -121 -122 -123 -124 -125 -126 -127 -128 -129 -130 -131 -132 -133 -134 -135 -136 -137 -138 -139 -140 -141 -142 -143 -144 -145 -146 -147 -148 -149+163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 |
- # File 'lib/youplot/parser.rb', line 114 +# File 'lib/youplot/parser.rb', line 163 def create_main_parser @main_parser = create_base_parser @@ -1174,55 +1512,6 @@-205 -206 -207 -208 -209 -210 -211 -212 -213 -214 -215 -216 -217 -218 -219 -220 -221 -222 -223 -224 -225 -226 -227 -228 -229 -230 -231 -232 -233 -234 -235 -236 -237 -238 -239 -240 -241 -242 -243 -244 -245 -246 -247 -248 -249 -250 -251 -252 -253 254 255 256 @@ -1258,10 +1547,61 @@ 286 287 288 -289+289 +290 +291 +292 +293 +294 +295 +296 +297 +298 +299 +300 +301 +302 +303 +304 +305 +306 +307 +308 +309 +310 +311 +312 +313 +314 +315 +316 +317 +318 +319 +320 +321 +322 +323 +324 +325 +326 +327 +328 +329 +330 +331 +332 +333 +334 +335 +336 +337 +338 +339 +340 |
- # File 'lib/youplot/parser.rb', line 205 +# File 'lib/youplot/parser.rb', line 254 def create_sub_parser @sub_parser = create_base_parser @@ -1338,6 +1678,8 @@ [:color_names] = v end + when :config + else = "uplot: unrecognized command '#{command}'" if YouPlot.run_as_executable? @@ -1351,6 +1693,52 @@ |
+ + + +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60+ |
+
+ # File 'lib/youplot/parser.rb', line 50 + +def find_config_file + config_file_path = nil + candidate_paths.each do |file| + path = File.(file) + if File.exist?(path) + config_file_path = path + break + end + end + config_file_path +end+ |
+
-291 -292 -293 -294 -295 -296 -297 -298 -299 -300 -301 -302 -303 -304 -305 -306 -307+342 +343 +344 +345 +346 +347 +348 +349 +350 +351 +352 +353 +354 +355 +356 +357 +358
# File 'lib/youplot/parser.rb', line 291 +# File 'lib/youplot/parser.rb', line 342 def (argv = ARGV) begin @@ -1409,6 +1797,38 @@
+ + + +62 +63 +64 +65+ |
+
+ # File 'lib/youplot/parser.rb', line 62 + +def read_config_file(path) + require 'yaml' + YAML.load_file(path) +end+ |
+
-164 -165 -166 -167 -168 -169+213 +214 +215 +216 +217 +218
# File 'lib/youplot/parser.rb', line 164 +# File 'lib/youplot/parser.rb', line 213 def sub_parser_add_canvas canvas_types = UnicodePlot::Canvas::CANVAS_CLASS_MAP.keys.join(', ') @@ -1462,16 +1882,16 @@-189 -190 -191 -192 -193 -194 -195+238 +239 +240 +241 +242 +243 +244
# File 'lib/youplot/parser.rb', line 189 +# File 'lib/youplot/parser.rb', line 238 def sub_parser_add_fmt_xyxy sub_parser.on_head('--fmt STR', String, @@ -1500,16 +1920,16 @@-197 -198 -199 -200 -201 -202 -203+246 +247 +248 +249 +250 +251 +252
# File 'lib/youplot/parser.rb', line 197 +# File 'lib/youplot/parser.rb', line 246 def sub_parser_add_fmt_yx sub_parser.on_head('--fmt STR', String, @@ -1538,14 +1958,14 @@-183 -184 -185 -186 -187+232 +233 +234 +235 +236
# File 'lib/youplot/parser.rb', line 183 +# File 'lib/youplot/parser.rb', line 232 def sub_parser_add_grid sub_parser.on_head('--[no-]grid', TrueClass, 'draws grid-lines at the origin') do |v| @@ -1572,14 +1992,14 @@-151 -152 -153 -154 -155+200 +201 +202 +203 +204
# File 'lib/youplot/parser.rb', line 151 +# File 'lib/youplot/parser.rb', line 200 def sub_parser_add_symbol sub_parser.on_head('--symbol STR', String, 'character to be used to plot the bars') do |v| @@ -1606,14 +2026,14 @@-171 -172 -173 -174 -175+220 +221 +222 +223 +224
# File 'lib/youplot/parser.rb', line 171 +# File 'lib/youplot/parser.rb', line 220 def sub_parser_add_xlim sub_parser.on_head('--xlim FLOAT,FLOAT', Array, 'plotting range for the x coordinate') do |v| @@ -1640,15 +2060,15 @@-157 -158 -159 -160 -161 -162+206 +207 +208 +209 +210 +211
# File 'lib/youplot/parser.rb', line 157 +# File 'lib/youplot/parser.rb', line 206 def sub_parser_add_xscale = UnicodePlot::ValueTransformer::PREDEFINED_TRANSFORM_FUNCTIONS.keys.join(', ') @@ -1676,14 +2096,14 @@-177 -178 -179 -180 -181+226 +227 +228 +229 +230
# File 'lib/youplot/parser.rb', line 177 +# File 'lib/youplot/parser.rb', line 226 def sub_parser_add_ylim sub_parser.on_head('--ylim FLOAT,FLOAT', Array, 'plotting range for the y coordinate') do |v| @@ -1700,9 +2120,9 @@ diff --git a/YouPlot/Parser/Error.html b/YouPlot/Parser/Error.html index cc2bdfa..5b2de19 100644 --- a/YouPlot/Parser/Error.html +++ b/YouPlot/Parser/Error.html @@ -6,7 +6,7 @@Exception: YouPlot::Parser::Error - — Documentation by YARD 0.9.27 + — Documentation by YARD 0.9.28 @@ -114,9 +114,9 @@ diff --git a/_index.html b/_index.html index f7d870a..f7ace9f 100644 --- a/_index.html +++ b/_index.html @@ -4,7 +4,7 @@- Documentation by YARD 0.9.27 + Documentation by YARD 0.9.28 @@ -52,7 +52,7 @@ -diff --git a/frames.html b/frames.html index 54704af..a65e936 100644 --- a/frames.html +++ b/frames.html @@ -2,7 +2,7 @@ -Documentation by YARD 0.9.27
+diff --git a/file.README.html b/file.README.html index 44b7c29..cdfdeb5 100644 --- a/file.README.html +++ b/file.README.html @@ -6,7 +6,7 @@Documentation by YARD 0.9.28
Alphabetic Index
@@ -238,9 +238,9 @@File: README - — Documentation by YARD 0.9.27 + — Documentation by YARD 0.9.28 @@ -400,9 +400,9 @@ If so, please feel free to contact us.Documentation by YARD 0.9.27 +Documentation by YARD 0.9.28