trex 1.0.8 → 1.0.9

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.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/trex.rb +36 -16
  3. metadata +10 -14
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f439654d11b3e47c4c0e95532694ab1d99cb7979
4
+ data.tar.gz: fcf324be079039f7e2b8e692a1bcf5c2ae90b023
5
+ SHA512:
6
+ metadata.gz: 81130811e1175ad9d48f31d9c9760f0a1ad1fbbb52cda21e979e8c122654b172323076a36bc593f4d0e76bb474e7e5d40c51414e229e4d122cae20be150871b9
7
+ data.tar.gz: 0463e282529bf11b1cc916c85f9ea70c3219d9b80e942e23c58eab67ae174b032e79731a6bc0a2be0accfd3c61d98d60eb394da979bde90b8c968a923d87cb89
@@ -11,7 +11,7 @@
11
11
  # ./trex check # run afterthedeadline / latex checker on the document
12
12
  #
13
13
  # == Usage
14
- # trex [options] [view|compile|tex|clean|check]
14
+ # trex [options] [view|compile|tex|clean|check|count]
15
15
  # For help use: trex -h
16
16
  #
17
17
  # == Options
@@ -223,19 +223,40 @@ class TReX
223
223
  # ------------------------------------------------------------------------
224
224
  def count
225
225
  @options.quiet = true
226
+ self.count_wc
227
+ self.count_texcount
226
228
  self.compile
227
- puts 'Sources'.red + ":"
228
- self.print_wc_results `wc #{@options.source}`
229
- puts 'PDFtoText'.red + ":"
230
- #TODO create a tmp file instead of saving locally
231
- self.print_wc_results `pdftotext -enc UTF-8 -nopgbrk #{@options.output} - | wc`
232
- `rm -f #{@options.sourceBase}.txt`
233
- if self.has_command? 'texcount'
234
- puts 'texcount'.red + ":"
235
- puts `texcount -relaxed -sum #{@options.source}`
236
- end
229
+ self.count_pdf_info
230
+ self.count_pdf_to_text
231
+ end
232
+
233
+ def count_wc
234
+ puts "Source:".red + " #{@options.source}:"
235
+ self.print_wc_results `wc #{@options.source}`
236
+ end
237
+
238
+ def count_pdf_info
239
+ rutn unless self.has_command? 'pdfinfo'
240
+ puts 'PDFInfo'.red + ":"
241
+ puts `pdfinfo #{@options.output}`
242
+ end
243
+
244
+ def count_pdf_to_text
245
+ return unless self.has_command? 'pdftotext'
246
+ puts 'PDFtoText'.red + ":"
247
+ #TODO create a tmp file instead of saving locally
248
+ self.print_wc_results `pdftotext -enc UTF-8 -nopgbrk #{@options.output} - | wc`
249
+ `rm -f #{@options.sourceBase}.txt`
250
+
251
+ end
252
+
253
+ def count_texcount
254
+ return unless self.has_command? 'texcount'
255
+ puts 'texcount'.red + ":"
256
+ puts `texcount -relaxed -sum -inc -merge -col -sub=chapter #{@options.source} 2> /dev/null`
237
257
  end
238
258
 
259
+
239
260
  def print_wc_results(result)
240
261
  result = result.split()[0..2]
241
262
  max = result.map{|l| l.size}.max
@@ -300,7 +321,7 @@ class TReX
300
321
  return @opts unless @opts.nil?
301
322
 
302
323
  @opts = OptionParser.new do |opts|
303
- opts.banner = "#{executable_name} [options] [view|compile|tex|clean|spell]"
324
+ opts.banner = "#{executable_name} [options] [view|compile|tex|clean|spell|count]"
304
325
 
305
326
  opts.separator ''
306
327
  opts.separator 'Automate compilation of LaTeX documents, making the output human-readable.'
@@ -435,11 +456,9 @@ class TReX
435
456
  # /some/path in PATH, mode 040777 )
436
457
  @warn = $-v
437
458
  $-v = nil
438
- Open3.popen3(command+' --help') { |stdin, stdout, stderr|
439
- return stderr.read.length == 0
440
- }
459
+ result = system('type #{command} >/dev/null 2>&1')
441
460
  $-v = @warn
442
- return true
461
+ return result
443
462
  end
444
463
 
445
464
  # ---------------------------------------------------------------------
@@ -958,3 +977,4 @@ class TexError < TexWarning
958
977
  end
959
978
 
960
979
  # vim: set ts=4 sw=4 ts=4 :
980
+
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trex
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.8
5
- prerelease:
4
+ version: 1.0.9
6
5
  platform: ruby
7
6
  authors:
8
7
  - Camillo Bruni
@@ -11,22 +10,20 @@ authors:
11
10
  autorequire:
12
11
  bindir: bin
13
12
  cert_chain: []
14
- date: 2012-06-07 00:00:00.000000000 Z
13
+ date: 2014-01-28 00:00:00.000000000 Z
15
14
  dependencies:
16
15
  - !ruby/object:Gem::Dependency
17
16
  name: term-ansicolor
18
17
  requirement: !ruby/object:Gem::Requirement
19
- none: false
20
18
  requirements:
21
- - - ! '>='
19
+ - - ">="
22
20
  - !ruby/object:Gem::Version
23
21
  version: 1.0.7
24
22
  type: :runtime
25
23
  prerelease: false
26
24
  version_requirements: !ruby/object:Gem::Requirement
27
- none: false
28
25
  requirements:
29
- - - ! '>='
26
+ - - ">="
30
27
  - !ruby/object:Gem::Version
31
28
  version: 1.0.7
32
29
  description: trex is script simplifying the compilation of latex files by creating
@@ -38,30 +35,29 @@ executables:
38
35
  extensions: []
39
36
  extra_rdoc_files: []
40
37
  files:
41
- - lib/trex.rb
42
38
  - bin/trex
39
+ - lib/trex.rb
43
40
  homepage: https://github.com/dh83/trex
44
41
  licenses: []
42
+ metadata: {}
45
43
  post_install_message:
46
44
  rdoc_options: []
47
45
  require_paths:
48
46
  - lib
49
47
  required_ruby_version: !ruby/object:Gem::Requirement
50
- none: false
51
48
  requirements:
52
- - - ! '>='
49
+ - - ">="
53
50
  - !ruby/object:Gem::Version
54
51
  version: '0'
55
52
  required_rubygems_version: !ruby/object:Gem::Requirement
56
- none: false
57
53
  requirements:
58
- - - ! '>='
54
+ - - ">="
59
55
  - !ruby/object:Gem::Version
60
56
  version: '0'
61
57
  requirements: []
62
58
  rubyforge_project:
63
- rubygems_version: 1.8.23
59
+ rubygems_version: 2.2.0
64
60
  signing_key:
65
- specification_version: 3
61
+ specification_version: 4
66
62
  summary: Automate compilation of LaTeX documents, making the output human-readable.
67
63
  test_files: []