nb_util 0.4.7 → 0.4.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 328951c7c1dc5885dd1b6b7f83be2802aee2c0cd1c655ad083c0a6db4d31767f
4
- data.tar.gz: 1ec2b8a8d782227377ede403e76499a00f0f1afd71301bd4b0471e0409cf4bb3
3
+ metadata.gz: 92eec37d4cc03123b3f8e76f953041a5ce035bdadd4d612dd3b5d8c8b4608da4
4
+ data.tar.gz: c43039b7b4dc1a6978cb6cc00930b4f9a8dbd8dafd616eb57f9be37ec10babf9
5
5
  SHA512:
6
- metadata.gz: 2a16e7b13024e581a107da8abfb84217ec2742ce50768a9a2738fc1809acb99a68597e4bb6e248892e11e7db28f895a875fb2f5d732f4e067360aef6108d68ea
7
- data.tar.gz: c7a809a211dc8358602866123b0da9885a99b23baaeab6be4e5ac04c80801194247ecd0f672b42d70aba31d4b82aee8e8d2c45aa408d0ae373dea473b73e54ff
6
+ metadata.gz: c827fa8512622ba9ffe0488ecfe603749f8dc0c033a12e71abbefb52bd7874a400016ddd5fd21eca0b96d50bea62c66047165b5e7174f83ea84abb28621411d4
7
+ data.tar.gz: 3c809decb9c9cac0852f69b77d2e629d609019d9debb788aa039ffea795a5956e3f724c98595688294eafdafb9b981c894cd5e7a41cb76407bdb94156f4de8a1
Binary file
@@ -4,15 +4,21 @@
4
4
  \input{../thesis_pieces/usepackage}% pieces
5
5
  \input{../thesis_pieces/form00_style}% pieces
6
6
  \input{../thesis_pieces/tightlist_setting}% pieces
7
- %参考文献の設定===========================================================
7
+ %参考文献の設定============================================================
8
8
  \renewcommand{\bibname}{参考文献}
9
9
 
10
- %表紙======================================================================
10
+ %表紙=====================================================================
11
11
  \input{../split_files/informations/informations}
12
12
 
13
- %目次======================================================================
13
+ %目次=====================================================================
14
14
  \tableofcontents
15
15
 
16
+ % 表目次の表示==============================================================
17
+ \listoftables
18
+
19
+ % 図目次の表示==============================================================
20
+ \listoffigures
21
+
16
22
  %本文======================================================================
17
23
  \input{./.splits_location.tex}
18
24
 
@@ -69,6 +69,7 @@ module NbUtil
69
69
 
70
70
  mk_latex_and_mv_to_latex(target, target_parent, "thesis")
71
71
  Open3.capture3("open #{target_parent}")
72
+ # p File.join(target_parent,"mk_latex/thesis")
72
73
  Open3.capture3("open #{target_parent}/mk_latex/thesis/thesis.tex/")
73
74
 
74
75
  exit
@@ -81,63 +82,70 @@ module NbUtil
81
82
  end
82
83
  end
83
84
 
84
- def ipynb2tex_handout(target)
85
- loop do
86
- your_informations(ARGV[1], "handout")
87
- print "Are you ok with it?: "
88
- input = STDIN.gets.to_s.chomp
89
- if input == 'Y' || input == 'y'
90
- location = Open3.capture3("gem environment gemdir")
91
- versions = Open3.capture3("gem list nb_util")
92
- latest_version = versions[0].split(",")
93
- cp_lib_data_handout_gem = File.join(location[0].chomp, "/gems/#{latest_version[0].chomp.gsub(' (','-').gsub(')','')}/lib/data/handout")
94
- cp_lib_data_handout_pieces_gem = File.join(location[0].chomp, "/gems/#{latest_version[0].chomp.gsub(' (','-').gsub(')','')}/lib/data/handout_pieces")
95
- cp_lib_data_handout_bundle = File.join(Dir.pwd, '/lib/data/handout')
96
- cp_lib_data_handout_pieces_bundle = File.join(Dir.pwd, '/lib/data/handout_pieces')
97
- re_fig = /(.+\.jpg)|(.+\.jpeg)|(.+\.png)/
85
+ def ipynb2tex_handout(target)
86
+ loop do
87
+ target_parent = File.dirname(target)
88
+ exist_info = File.join(target_parent, 'mk_latex/split_files/informations/informations.tex')
89
+ if File.exist?(exist_info)
90
+ FileUtils.mkdir_p(target_parent + '/split_files/informations')
91
+ FileUtils.cp(exist_info, target_parent)
92
+ else
93
+ your_informations(ARGV[1], "handout")
94
+ end
95
+ print "Are you ok with it?: "
96
+ input = STDIN.gets.to_s.chomp
97
+ if input == 'Y' || input == 'y'
98
+ location = Open3.capture3("gem environment gemdir")
99
+ versions = Open3.capture3("gem list nb_util")
100
+ latest_version = versions[0].split(",")
101
+ cp_lib_data_handout_gem = File.join(location[0].chomp, "/gems/#{latest_version[0].chomp.gsub(' (','-').gsub(')','')}/lib/data/handout")
102
+ cp_lib_data_handout_pieces_gem = File.join(location[0].chomp, "/gems/#{latest_version[0].chomp.gsub(' (','-').gsub(')','')}/lib/data/handout_pieces")
103
+ cp_lib_data_handout_bundle = File.join(Dir.pwd, '/lib/data/handout')
104
+ cp_lib_data_handout_pieces_bundle = File.join(Dir.pwd, '/lib/data/handout_pieces')
105
+ re_fig = /(.+\.jpg)|(.+\.jpeg)|(.+\.png)/
98
106
 
99
- print "\e[32minputfile: \e[0m"
100
- target = File.expand_path(ARGV[1])
101
- print "\e[32m#{target}\n\e[0m"
102
- print "\e[32moutputfile: \e[0m"
103
- tex_src = target.sub('.ipynb', '.tex')
104
- print "\e[32m#{tex_src}\n\e[0m"
105
- target_parent = File.dirname(target)
106
- target_basename = File.basename(tex_src)
107
- Open3.capture3("jupyter nbconvert --to latex #{target}")
108
- lines = File.readlines(tex_src)
109
- lines.each_with_index do |line, i|
110
- line.sub!("\documentclass[11pt]{article}",
111
- "\documentclass[11pt,dvipdfmx]{jsarticle}")
112
- print "\e[32m#{line}\n\e[0m" if line =~ re_fig #redにする"\e[31m\e[0m"
113
- line.sub!(line, '%' + line) if line.include?('.svg')
114
- end
115
- File.open(tex_src, 'w') { |file| file.print lines.join }
107
+ print "\e[32minputfile: \e[0m"
108
+ target = File.expand_path(ARGV[1])
109
+ print "\e[32m#{target}\n\e[0m"
110
+ print "\e[32moutputfile: \e[0m"
111
+ tex_src = target.sub('.ipynb', '.tex')
112
+ print "\e[32m#{tex_src}\n\e[0m"
113
+ target_parent = File.dirname(target)
114
+ target_basename = File.basename(tex_src)
115
+ Open3.capture3("jupyter nbconvert --to latex #{target}")
116
+ lines = File.readlines(tex_src)
117
+ lines.each_with_index do |line, i|
118
+ line.sub!("\documentclass[11pt]{article}",
119
+ "\documentclass[11pt,dvipdfmx]{jsarticle}")
120
+ print "\e[32m#{line}\n\e[0m" if line =~ re_fig #redにする"\e[31m\e[0m"
121
+ line.sub!(line, '%' + line) if line.include?('.svg')
122
+ end
123
+ File.open(tex_src, 'w') { |file| file.print lines.join }
116
124
 
117
- FileUtils.mkdir_p(target_parent + '/latex')
118
- FileUtils.mv(tex_src, target_parent + '/latex')
119
- replace_figs(File.join(target_parent + '/latex', target_basename), "handout")
120
- revise_lines(File.join(target_parent + '/latex', target_basename))
121
- split_files(File.join(target_parent + '/latex', target_basename), target, "handout")
122
- FileUtils.mv(target_parent + '/tmp.tex', target_parent + '/split_files/tmp')
123
- FileUtils.mv(target_parent + '/informations.tex', target_parent + '/split_files/informations')
124
- mk_thesis_location(target, "handout")
125
- FileUtils.mv(target_parent + '/.splits_location.tex', target_parent + '/handout')
125
+ FileUtils.mkdir_p(target_parent + '/latex')
126
+ FileUtils.mv(tex_src, target_parent + '/latex')
127
+ replace_figs(File.join(target_parent + '/latex', target_basename), "handout")
128
+ revise_lines(File.join(target_parent + '/latex', target_basename))
129
+ split_files(File.join(target_parent + '/latex', target_basename), target, "handout")
130
+ FileUtils.mv(target_parent + '/tmp.tex', target_parent + '/split_files/tmp')
131
+ FileUtils.mv(target_parent + '/informations.tex', target_parent + '/split_files/informations')
132
+ mk_thesis_location(target, "handout")
133
+ FileUtils.mv(target_parent + '/.splits_location.tex', target_parent + '/handout')
126
134
 
127
- mk_xbb(target, re_fig)
128
- if Dir.exist?(cp_lib_data_handout_pieces_bundle.to_s) && Dir.exist?(cp_lib_data_handout_bundle.to_s)
129
- FileUtils.cp_r(cp_lib_data_handout_pieces_bundle, target_parent)
130
- FileUtils.cp_r(cp_lib_data_handout_bundle, target_parent)
131
- else
132
- FileUtils.cp_r(cp_lib_data_handout_pieces_gem, target_parent)
133
- FileUtils.cp_r(cp_lib_data_handout_gem, target_parent)
134
- end
135
+ mk_xbb(target, re_fig)
136
+ if Dir.exist?(cp_lib_data_handout_pieces_bundle.to_s) && Dir.exist?(cp_lib_data_handout_bundle.to_s)
137
+ FileUtils.cp_r(cp_lib_data_handout_pieces_bundle, target_parent)
138
+ FileUtils.cp_r(cp_lib_data_handout_bundle, target_parent)
139
+ else
140
+ FileUtils.cp_r(cp_lib_data_handout_pieces_gem, target_parent)
141
+ FileUtils.cp_r(cp_lib_data_handout_gem, target_parent)
142
+ end
135
143
 
136
- mk_latex_and_mv_to_latex(target, target_parent, "handout")
137
- Open3.capture3("open #{target_parent}")
138
- Open3.capture3("open #{target_parent}/mk_latex/handout/handout.tex/")
144
+ mk_latex_and_mv_to_latex(target, target_parent, "handout")
145
+ Open3.capture3("open #{target_parent}")
146
+ Open3.capture3("open #{target_parent}/mk_latex/handout/handout.tex/")
139
147
 
140
- exit
148
+ exit
141
149
  break
142
150
  elsif input == 'N' || input == 'n'
143
151
  target_parent = File.dirname(target)
@@ -210,7 +218,7 @@ module NbUtil
210
218
  chapter_size = chapter.size
211
219
  p chapter
212
220
  for num in 0..chapter_size-1 do
213
- splitters = [ ["\\section{#{chapter[num]}}", target_parent + "/chapter#{num}.tex", FileUtils.mkdir_p(target_parent + "/split_files/chapter#{num}")],
221
+ splitters = [ ["\\section{#{chapter[num]}}", target_parent + "/chapter#{num+1}.tex", FileUtils.mkdir_p(target_parent + "/split_files/chapter#{num+1}")],
214
222
  ["\\begin{Verbatim}", target_parent + '/tmp.tex', FileUtils.mkdir_p(target_parent + '/split_files/tmp')]]
215
223
  cont = File.read(target)
216
224
  splitters.reverse.each do |splitter|
@@ -230,14 +238,14 @@ module NbUtil
230
238
  end
231
239
  end
232
240
  end
233
- FileUtils.mv(target_parent + "/chapter#{num}.tex", target_parent + "/split_files/chapter#{num}")
241
+ FileUtils.mv(target_parent + "/chapter#{num+1}.tex", target_parent + "/split_files/chapter#{num+1}")
234
242
  end
235
243
  end
236
244
 
237
245
  if thesis_or_handout == "handout"
238
246
  section_size = chapter.size
239
247
  for num in 0..section_size-1 do
240
- splitters = [ ["\\section{#{chapter[num]}}", target_parent + "/chapter#{num}.tex", FileUtils.mkdir_p(target_parent + "/split_files/chapter#{num}")],
248
+ splitters = [ ["\\section{#{chapter[num]}}", target_parent + "/chapter#{num+1}.tex", FileUtils.mkdir_p(target_parent + "/split_files/chapter#{num+1}")],
241
249
  ["\\begin{Verbatim}", target_parent + '/tmp.tex', FileUtils.mkdir_p(target_parent + '/split_files/tmp')]]
242
250
  cont = File.read(target)
243
251
  splitters.reverse.each do |splitter|
@@ -253,7 +261,7 @@ module NbUtil
253
261
  end
254
262
  end
255
263
  end
256
- FileUtils.mv(target_parent + "/chapter#{num}.tex", target_parent + "/split_files/chapter#{num}")
264
+ FileUtils.mv(target_parent + "/chapter#{num+1}.tex", target_parent + "/split_files/chapter#{num+1}")
257
265
  end
258
266
  end
259
267
  end
@@ -420,7 +428,7 @@ EOS
420
428
  end
421
429
  File.open(target_parent + '/.splits_location.tex', "w") do |f|
422
430
  for num in 0..chapter_size-1 do
423
- f.print("\\input{../split_files/chapter#{num}/chapter#{num}}\n")
431
+ f.print("\\input{../split_files/chapter#{num+1}/chapter#{num+1}}\n")
424
432
  end
425
433
  end
426
434
  end
@@ -1,3 +1,3 @@
1
1
  module NbUtil
2
- VERSION = "0.4.7"
2
+ VERSION = "0.4.8"
3
3
  end
@@ -33,5 +33,5 @@ Gem::Specification.new do |spec|
33
33
  spec.add_development_dependency "bundler", "~> 1.16"
34
34
  spec.add_development_dependency "rake", "~> 10.0"
35
35
  spec.add_development_dependency "rspec", "~> 3.0"
36
- spec.add_development_dependency "thor"
36
+ spec.add_dependency "thor"
37
37
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nb_util
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.7
4
+ version: 0.4.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masatoshi Kowaki
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-01-12 00:00:00.000000000 Z
11
+ date: 2018-01-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -59,7 +59,7 @@ dependencies:
59
59
  - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
- type: :development
62
+ type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements: