texzip 0.1.5 → 0.1.6

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/History.txt CHANGED
@@ -1,3 +1,7 @@
1
+ == 0.1.6 / 2012-10-25
2
+ * add .png extension for images
3
+ * add -p parameter for storing images without nested subdirectories
4
+
1
5
  == 0.1.5 / 2011-06-22
2
6
  * compatibility with bibtex-parser >= 1.3.6
3
7
  * require ffi-libarchive only if necessary
data/Rakefile CHANGED
@@ -8,15 +8,14 @@ end
8
8
  #task :default => 'test:run'
9
9
  #task 'gem:release' => 'test:run'
10
10
 
11
- files = `darcs show files`.split("\n").
12
- select{|f| File.file?(f)}.
13
- map{|f| f.gsub(/^\.\//, '')} - %w(.boring .bnsignore)
11
+ files = `hg locate`.split("\n") - %w(.hgignore .hgtags)
14
12
 
15
13
  Bones {
16
14
  name 'texzip'
17
15
  authors 'Frank Fischer'
18
16
  email 'frank.fischer@mathematik.tu-chemnitz.de'
19
- url 'http://darcsden.com/lyro/texzip'
17
+ url 'http://bitbucket.org/lyro/texzip'
18
+ ignore_file '.hgignore'
20
19
  depend_on 'bibtex-ruby', ['>= 1.3.6', '< 2.0']
21
20
  depend_on 'trollop', '~> 1.16'
22
21
  depend_on 'ffi-libarchive', '>= 0.1.3', '< 2.0'
data/bin/texzip CHANGED
@@ -21,9 +21,10 @@ EOS
21
21
  opt :bib, "Output BibTeX file", :default => "bibliography.bib"
22
22
  opt :output, "Output directory where the modified files should saved", :type => String
23
23
  opt :images, "Subdirectory where the images should be stored", :default => "img"
24
+ opt "plain-images", "Images should be stored without further subdirectories"
24
25
  opt :archive, "Archive to be created", :type => String
25
26
  opt :force, "Force overwriting of files", :default => false
26
- version "#{File.basename(__FILE__)} #{TeXzip::VERSION} (c) 2011 Frank Fischer"
27
+ version "#{File.basename(__FILE__)} #{TeXzip::VERSION} (c) 2011,2012 Frank Fischer"
27
28
  end
28
29
 
29
30
  if ARGV.empty?
@@ -40,7 +41,9 @@ end
40
41
 
41
42
  begin
42
43
  texproject = TeXzip::Project.new ARGV.shift
43
- texproject.modify_files(opts[:output] || Dir.getwd, opts[:images], opts[:bib])
44
+ texproject.modify_files(opts[:output] || Dir.getwd,
45
+ opts[:images], opts["plain-images"],
46
+ opts[:bib])
44
47
 
45
48
  texproject.overwrite_all = opts[:force]
46
49
 
@@ -9,7 +9,7 @@ class TeXzip::Error < Exception; end
9
9
  class TeXzip::Project < HighLine
10
10
 
11
11
  PACKAGE_EXTENSIONS = %w(.sty .cls)
12
- IMAGE_EXTENSIONS = %w(.jpg .pdf .eps .pstex)
12
+ IMAGE_EXTENSIONS = %w(.png .jpg .pdf .eps .pstex)
13
13
  TEXIMAGE_EXTENSIONS = %w(.pspdftex .pdf_t .pstex_t)
14
14
 
15
15
  class Quit < Exception; end
@@ -21,18 +21,28 @@ class TeXzip::Project < HighLine
21
21
  @root_dir = Pathname.new(root_dir).expand_path
22
22
  @file = Pathname.new(file)
23
23
  @file = @root_dir.join(file).expand_path.relative_path_from(@root_dir)
24
+ @out_file = @file
24
25
  end
25
26
 
26
27
  def set_output_directory dir
27
28
  @out_dir = Pathname.new(dir).expand_path
28
29
  end
29
30
 
31
+ def set_plain_output_directory dir
32
+ set_output_directory dir
33
+ @out_file = @file.basename
34
+ end
35
+
30
36
  def file
31
37
  @file
32
38
  end
33
39
 
40
+ def out_file= file
41
+ @out_file = Pathname.new(file)
42
+ end
43
+
34
44
  def output_path
35
- @out_dir.join(@file).expand_path
45
+ @out_dir.join(@out_file).expand_path
36
46
  end
37
47
 
38
48
  def path
@@ -285,15 +295,22 @@ class TeXzip::Project < HighLine
285
295
  end
286
296
  end
287
297
 
288
- def modify_files outdir, image_dir, bibtex_file
298
+ def modify_files outdir, image_dir, plain_img, bibtex_file
289
299
  @output_directory = Pathname.new(outdir).expand_path
290
300
  @output_image_directory = @output_directory.join(Pathname.new(image_dir)).expand_path
291
301
  @output_bibtex = @output_directory.join(Pathname.new(bibtex_file)).expand_path
292
302
  @modified_files = {}
293
303
 
304
+ plain_img_files = Hash.new{|h,k| h[k] = []}
305
+
294
306
  @tex_files.each_key do |file|
295
307
  if TEXIMAGE_EXTENSIONS.include? file.extname
296
- file.set_output_directory @output_image_directory
308
+ if plain_img
309
+ file.set_plain_output_directory @output_image_directory
310
+ plain_img_files[file.file.to_s] << file
311
+ else
312
+ file.set_output_directory @output_image_directory
313
+ end
297
314
  else
298
315
  file.set_output_directory @output_directory
299
316
  end
@@ -303,9 +320,32 @@ class TeXzip::Project < HighLine
303
320
  end
304
321
 
305
322
  @image_files.each do |file|
306
- file.set_output_directory @output_image_directory
323
+ if plain_img
324
+ file.set_plain_output_directory @output_image_directory
325
+ plain_img_files[file.file.to_s] << file
326
+ else
327
+ file.set_output_directory @output_image_directory
328
+ end
307
329
  end
308
330
 
331
+ # maybe rename some files
332
+ plain_img_files.each_pair do |fname, files|
333
+ ext = File.extname(fname)
334
+ next if files.size <= 1
335
+ cnt = 2
336
+ files.each do |file|
337
+ loop do
338
+ new_fname = fname.basename.sub_ext("#{cnt}#{ext}")
339
+ if plain_img_files.include?(new_fname.to_s)
340
+ cnt += 1
341
+ else
342
+ file.out_file = new_fname
343
+ break
344
+ end
345
+ end
346
+ end
347
+ end
348
+
309
349
  filter_bibtex
310
350
  end
311
351
 
data/version.txt CHANGED
@@ -1 +1 @@
1
- 0.1.5
1
+ 0.1.6
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: texzip
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.5
5
+ version: 0.1.6
6
6
  platform: ruby
7
7
  authors:
8
8
  - Frank Fischer
@@ -10,11 +10,10 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-06-22 00:00:00 Z
13
+ date: 2012-10-25 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bibtex-ruby
17
- prerelease: false
18
17
  requirement: &id001 !ruby/object:Gem::Requirement
19
18
  none: false
20
19
  requirements:
@@ -25,10 +24,10 @@ dependencies:
25
24
  - !ruby/object:Gem::Version
26
25
  version: "2.0"
27
26
  type: :runtime
27
+ prerelease: false
28
28
  version_requirements: *id001
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: trollop
31
- prerelease: false
32
31
  requirement: &id002 !ruby/object:Gem::Requirement
33
32
  none: false
34
33
  requirements:
@@ -36,10 +35,10 @@ dependencies:
36
35
  - !ruby/object:Gem::Version
37
36
  version: "1.16"
38
37
  type: :runtime
38
+ prerelease: false
39
39
  version_requirements: *id002
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: ffi-libarchive
42
- prerelease: false
43
42
  requirement: &id003 !ruby/object:Gem::Requirement
44
43
  none: false
45
44
  requirements:
@@ -47,10 +46,10 @@ dependencies:
47
46
  - !ruby/object:Gem::Version
48
47
  version: 0.1.3
49
48
  type: :runtime
49
+ prerelease: false
50
50
  version_requirements: *id003
51
51
  - !ruby/object:Gem::Dependency
52
52
  name: ffi-inliner
53
- prerelease: false
54
53
  requirement: &id004 !ruby/object:Gem::Requirement
55
54
  none: false
56
55
  requirements:
@@ -58,10 +57,10 @@ dependencies:
58
57
  - !ruby/object:Gem::Version
59
58
  version: 0.2.4
60
59
  type: :runtime
60
+ prerelease: false
61
61
  version_requirements: *id004
62
62
  - !ruby/object:Gem::Dependency
63
63
  name: highline
64
- prerelease: false
65
64
  requirement: &id005 !ruby/object:Gem::Requirement
66
65
  none: false
67
66
  requirements:
@@ -69,17 +68,18 @@ dependencies:
69
68
  - !ruby/object:Gem::Version
70
69
  version: "1.0"
71
70
  type: :runtime
71
+ prerelease: false
72
72
  version_requirements: *id005
73
73
  - !ruby/object:Gem::Dependency
74
74
  name: bones
75
- prerelease: false
76
75
  requirement: &id006 !ruby/object:Gem::Requirement
77
76
  none: false
78
77
  requirements:
79
78
  - - ">="
80
79
  - !ruby/object:Gem::Version
81
- version: 3.7.0
80
+ version: 3.8.0
82
81
  type: :development
82
+ prerelease: false
83
83
  version_requirements: *id006
84
84
  description: |-
85
85
  A small tool to collect images and BibTeX references from tex-files
@@ -96,25 +96,25 @@ files:
96
96
  - History.txt
97
97
  - README.md
98
98
  - Rakefile
99
- - version.txt
100
99
  - bin/texzip
101
100
  - lib/texzip.rb
102
101
  - lib/texzip/Project.rb
103
- - spec/spec_helper.rb
104
- - spec/texzip_spec.rb
105
102
  - spec/dummy/bib1.bib
106
103
  - spec/dummy/bib2.bib
107
104
  - spec/dummy/chapter1.tex
108
105
  - spec/dummy/chapter2.tex
109
- - spec/dummy/chapter4.tex
110
- - spec/dummy/root-file.tex
111
- - spec/dummy/root-file2.tex
112
- - spec/dummy/root-file3.tex
113
106
  - spec/dummy/chapter3/chapter3-bad.tex
114
107
  - spec/dummy/chapter3/chapter3.1.tex
115
108
  - spec/dummy/chapter3/chapter3.2.tex
116
109
  - spec/dummy/chapter3/chapter3.tex
117
- homepage: http://darcsden.com/lyro/texzip
110
+ - spec/dummy/chapter4.tex
111
+ - spec/dummy/root-file.tex
112
+ - spec/dummy/root-file2.tex
113
+ - spec/dummy/root-file3.tex
114
+ - spec/spec_helper.rb
115
+ - spec/texzip_spec.rb
116
+ - version.txt
117
+ homepage: http://bitbucket.org/lyro/texzip
118
118
  licenses: []
119
119
 
120
120
  post_install_message:
@@ -138,7 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
138
138
  requirements: []
139
139
 
140
140
  rubyforge_project: texzip
141
- rubygems_version: 1.7.2
141
+ rubygems_version: 1.8.24
142
142
  signing_key:
143
143
  specification_version: 3
144
144
  summary: A small tool to collect images and BibTeX references from tex-files and repack them in a new directory with a new clean BibTeX file.