ctioga2 0.6 → 0.6.1

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.
data/Changelog CHANGED
@@ -1,3 +1,10 @@
1
+ ctioga2 (0.6.1)
2
+
3
+ * Fix crash when a curve has no points within the plot boundaries
4
+ * Work around encoding problems arising on windows
5
+
6
+ -- Vincent <vincent.fourmond@9online.fr> Mon 9 Sep 22:19:01 CEST 2013
7
+
1
8
  ctioga2 (0.6)
2
9
 
3
10
  * Fix various problems related to file names and directories
@@ -17,7 +17,7 @@ require 'ctioga2/commands/parsers/file'
17
17
 
18
18
  module CTioga2
19
19
 
20
- Version::register_svn_info('$Revision: 497 $', '$Date: 2013-09-04 22:07:55 +0200 (Wed, 04 Sep 2013) $')
20
+ Version::register_svn_info('$Revision: 508 $', '$Date: 2013-09-09 22:13:14 +0200 (Mon, 09 Sep 2013) $')
21
21
 
22
22
  module Commands
23
23
 
@@ -60,6 +60,9 @@ EOH
60
60
  [ CmdArg.new('file')],
61
61
  {'log' => CmdArg.new('boolean') }
62
62
  ) do |plotmaker, file, opts|
63
+ # Work around bug on windows !
64
+ file = Utils::transcode_until_found(file)
65
+
63
66
  if opts['log']
64
67
  tg = file.sub(/(\.ct2)?$/, '-log.txt')
65
68
  Log::log_to(tg, "ctioga2 version '#{CTioga2::Version::version}' starting at #{Time.now} to process file: #{file}")
@@ -21,7 +21,7 @@ require 'ctioga2/commands/doc/doc'
21
21
 
22
22
  module CTioga2
23
23
 
24
- Version::register_svn_info('$Revision: 492 $', '$Date: 2013-09-03 21:54:09 +0200 (Tue, 03 Sep 2013) $')
24
+ Version::register_svn_info('$Revision: 508 $', '$Date: 2013-09-09 22:13:14 +0200 (Mon, 09 Sep 2013) $')
25
25
 
26
26
  # This module contains the real core of ctioga2: a set of classes
27
27
  # that implement the concept of commands. Each command translates
@@ -210,9 +210,10 @@ module CTioga2
210
210
  if ! @plotmaker_target.figure_name
211
211
  @plotmaker_target.figure_name = file.gsub(/\.[^.]+$/,'')
212
212
  end
213
+
213
214
  dir = File::dirname(file)
214
215
  base = File::basename(file)
215
-
216
+
216
217
  Dir::chdir(dir) do
217
218
  @file_parser.run_command_file(base, self)
218
219
  end
@@ -19,7 +19,7 @@ require 'Dobjects/Function'
19
19
 
20
20
  module CTioga2
21
21
 
22
- Version::register_svn_info('$Revision: 474 $', '$Date: 2013-08-31 15:05:39 +0200 (Sat, 31 Aug 2013) $')
22
+ Version::register_svn_info('$Revision: 505 $', '$Date: 2013-09-05 22:18:57 +0200 (Thu, 05 Sep 2013) $')
23
23
 
24
24
  module Graphics
25
25
 
@@ -111,7 +111,17 @@ module CTioga2
111
111
  t.append_point_to_path(x, y)
112
112
  end
113
113
  else
114
+
115
+ # Hmmmm. This may get the wrong thing if you happen to
116
+ # draw something completely outside.
114
117
  f = func.bound_values(*bnds.extrema)
118
+
119
+ # If for some reason, there is no point left, we plot
120
+ # the original function.
121
+ if f.size < 2
122
+ f = func
123
+ end
124
+
115
125
  t.move_to_point(f.x.first, f.y.first)
116
126
  t.append_points_to_path(f.x[1..-1], f.y[1..-1])
117
127
  end
@@ -106,6 +106,9 @@ CTioga2::Log::init_logger
106
106
 
107
107
  require 'shellwords'
108
108
 
109
+ # Path name mangling
110
+ require 'pathname'
111
+
109
112
  # Maybe, maybe, maybe... We need tioga ?
110
113
  require 'Tioga/FigureMaker'
111
114
 
@@ -155,7 +158,7 @@ require 'ctioga2/postprocess'
155
158
  # displays of rate constants vs potentials)
156
159
  module CTioga2
157
160
 
158
- Version::register_svn_info('$Revision: 478 $', '$Date: 2013-09-01 11:24:02 +0200 (Sun, 01 Sep 2013) $')
161
+ Version::register_svn_info('$Revision: 508 $', '$Date: 2013-09-09 22:13:14 +0200 (Mon, 09 Sep 2013) $')
159
162
 
160
163
  # This class is the core of ctioga. It parses the command-line arguments,
161
164
  # reads all necessary files and plots graphs. Most of its functionality
@@ -342,55 +345,50 @@ module CTioga2
342
345
 
343
346
 
344
347
  t = create_figure_maker
345
- # If figname is clearly a path, we split it into directory/name
346
- # and set the output directory to directory.
347
- if File::basename(figname) != figname
348
- dir = File::dirname(figname)
349
- # If path is relative and output_directory is specified, we make
350
- # the path relative to output_dir
351
- if @output_directory && dir =~ /^[^\/~]/
352
- dir = File::join(@output_directory, dir)
353
- end
354
- t.save_dir = dir
355
- figname = File::basename(figname)
356
- elsif @output_directory
357
- t.save_dir = @output_directory
358
- end
359
348
 
360
- effective_fig_name = figname.gsub(/[.\s]/) do |x|
361
- "__#{x.ord}__"
349
+ path = Pathname.new(figname)
350
+ if @output_directory
351
+ out = Pathname.new(@output_directory)
352
+ path = out + path
362
353
  end
363
354
 
364
- if effective_fig_name != figname
365
- debug { "Mangled name to '#{effective_fig_name}'"}
366
- end
355
+ # We always cd into the target directory for creading the
356
+ Dir.chdir(path.dirname) do
357
+ fn = path.basename.to_s
367
358
 
368
- t.def_figure(effective_fig_name) do
369
- @latex_font.set_global_font(t)
370
- @root_object.draw_root_object(t)
371
- end
372
- t.make_preview_pdf(t.figure_index(effective_fig_name))
373
-
374
- # We look for latex errors
375
- if t.respond_to? :pdflatex_errors
376
- errs = t.pdflatex_errors
377
- if errs.size > 0
378
- error { "pdflatex returned with #{errs.size} error lines"}
379
- for l in errs
380
- warn { "pdflatex error: #{l.chomp}" }
359
+ efn = fn.gsub(/[.\s]/) do |x|
360
+ "__#{x.ord}__"
361
+ end
362
+
363
+ if efn != fn
364
+ debug { "Mangled name to '#{fn}'"}
365
+ end
366
+
367
+ t.def_figure(efn) do
368
+ @latex_font.set_global_font(t)
369
+ @root_object.draw_root_object(t)
370
+ end
371
+ t.make_preview_pdf(t.figure_index(efn))
372
+
373
+ # We look for latex errors
374
+ if t.respond_to? :pdflatex_errors
375
+ errs = t.pdflatex_errors
376
+ if errs.size > 0
377
+ error { "pdflatex returned with #{errs.size} error lines"}
378
+ for l in errs
379
+ warn { "pdflatex error: #{l.chomp}" }
380
+ end
381
381
  end
382
382
  end
383
- end
384
383
 
385
- # We first rename the PDF file if it was mangled.
386
- if effective_fig_name != figname
387
- Dir.chdir(t.save_dir || ".") do
388
- File::rename("#{effective_fig_name}.pdf", "#{figname}.pdf")
384
+ # We first rename the PDF file if it was mangled.
385
+ if efn != fn
386
+ File::rename("#{efn}.pdf", "#{fn}.pdf")
389
387
  end
388
+
390
389
  end
391
390
 
392
- file = t.save_dir ? File::join(t.save_dir, figname + ".pdf") :
393
- figname + ".pdf"
391
+ file = path.to_s + ".pdf"
394
392
 
395
393
  # Feed it
396
394
  @postprocess.process_file(file, last)
data/lib/ctioga2/utils.rb CHANGED
@@ -35,7 +35,7 @@ module CTioga2
35
35
  # arguments and have the Date and Revision svn:keyword:. Use this
36
36
  # way:
37
37
  #
38
- # Version::register_svn_info('$Revision: 496 $', '$Date: 2013-09-04 21:31:56 +0200 (Wed, 04 Sep 2013) $')
38
+ # Version::register_svn_info('$Revision: 508 $', '$Date: 2013-09-09 22:13:14 +0200 (Mon, 09 Sep 2013) $')
39
39
  #
40
40
  # To set the correct properties, the following command-line can be
41
41
  # used:
@@ -75,7 +75,7 @@ module CTioga2
75
75
  }
76
76
 
77
77
  # The position of the URL, used for getting the version
78
- SVN_URL = '$HeadURL: svn+ssh://rubyforge.org/var/svn/ctioga2/releases/ctioga2-0.6/lib/ctioga2/utils.rb $'
78
+ SVN_URL = '$HeadURL: svn+ssh://rubyforge.org/var/svn/ctioga2/releases/ctioga2-0.6.1/lib/ctioga2/utils.rb $'
79
79
 
80
80
  # The version of ctioga2
81
81
  CTIOGA_VERSION = if SVN_URL =~ /releases\/ctioga2-([^\/]+)/
@@ -84,7 +84,7 @@ module CTioga2
84
84
  "SVN version"
85
85
  end
86
86
 
87
- register_svn_info('$Revision: 496 $', '$Date: 2013-09-04 21:31:56 +0200 (Wed, 04 Sep 2013) $')
87
+ register_svn_info('$Revision: 508 $', '$Date: 2013-09-09 22:13:14 +0200 (Mon, 09 Sep 2013) $')
88
88
 
89
89
  end
90
90
 
@@ -225,6 +225,35 @@ module CTioga2
225
225
 
226
226
  return Math.log10(a.first).send(method)
227
227
  end
228
+
229
+
230
+ # Transcodes the given string from all encodings into the target
231
+ # encoding until an encoding is found in which the named file
232
+ # exists.
233
+ #
234
+ # Works around encoding problems on windows.
235
+ def self.transcode_until_found(file)
236
+ if File.exists? file
237
+ return file
238
+ end
239
+ begin # We wrap in a begin/rescue block for
240
+ # Ruby 1.8
241
+ for e in Encoding::constants
242
+ e = Encoding.const_get(e)
243
+ if e.is_a? Encoding
244
+ begin
245
+ ts = file.encode(Encoding::default_external, e)
246
+ if File.exists? ts
247
+ return ts
248
+ end
249
+ rescue
250
+ end
251
+ end
252
+ end
253
+ rescue
254
+ end
255
+ return file # But that will fail later on.
256
+ end
228
257
  end
229
258
 
230
259
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ctioga2
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.6'
4
+ version: 0.6.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-09-04 00:00:00.000000000 Z
12
+ date: 2013-09-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: tioga