nb_util 0.3.5 → 0.3.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: 73911ac5699fe50ad82be4a093af9ab0b07896edf4c0e6c8cc5460f26a53bf0a
4
- data.tar.gz: 0dcce44e514e0b8fd8129ce85944a5ad79102e2552e481e67427b2e0544d6415
3
+ metadata.gz: c481669cc7f54a88c0397da46a42150cb61b345dcdbc06d1a2a530b964249887
4
+ data.tar.gz: 63de0433b90627754c066286dfc7e8bb52a2b3b8584cbd82a5e7a71923649910
5
5
  SHA512:
6
- metadata.gz: 8465d24905fdc79e476c94515e9ce81249a07be10fcef1629a29bc1ab3b3c02b7f2f1793a3df233c71a5cae4964c344296ade6234d4fb487e6d60d5045c3be76
7
- data.tar.gz: 0dba5c2ce3abe994b3aa32b2bdaa720dfd782d2fd2fb725d8300288d611c327dbd4c1d258cf3296924460daa5bb8b433b3a6103c800e90965f85f3bc028f870a
6
+ metadata.gz: d9fe68971aeb2af907acf8474f8361618a7ece511ad0b145839bc58b99933df73fc9d6aecb8694b354e9c76784b861055899c280f429b65ad30a0a3400940231
7
+ data.tar.gz: a3a41d88b3979c2463cf40254c71988af2b91c0cc1e40e16dbf3b9f901e49c560b41d1bbb0e964b5c242688c7835ed9b131b778e59f7b1a9ca943592c54d340d
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- nb_util (0.3.4)
4
+ nb_util (0.3.7)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/lib/cli.rb CHANGED
@@ -36,10 +36,10 @@ module NbUtil
36
36
  desc "ipynb2tex [filename]", "convert ipynb to tex" # コマンドの使用例と、概要
37
37
  def ipynb2tex(argv0) # コマンドはメソッドとして定義する
38
38
  NbUtil.ipynb2tex(ARGV[1])
39
- NbUtil.revise_lines(ARGV[1])
40
- NbUtil.split_files(ARGV[1])
41
- NbUtil.replace_figs(ARGV[1])
42
- NbUtil.your_informations(ARGV[1])
39
+ # NbUtil.revise_lines(ARGV[1])
40
+ # NbUtil.split_files(ARGV[1])
41
+ # NbUtil.replace_figs(ARGV[1])
42
+ # NbUtil.your_informations(ARGV[1])
43
43
  end
44
44
  end
45
45
  end
@@ -11,21 +11,20 @@ module NbUtil
11
11
  def ipynb2tex(target)
12
12
  loop do
13
13
  your_informations(ARGV[1])
14
-
15
- puts ">上記の情報で実行する場合は「Y」、終了する場合は「N」を入力して下さい。"
14
+ print "Are you ok with it?: "
16
15
  input = STDIN.gets.to_s.chomp
17
16
  if input == 'Y' || input == 'y'
18
17
  location = Open3.capture3("gem environment gemdir")
19
18
  versions = Open3.capture3("gem list nb_util")
20
19
  latest_version = versions[0].split(",")
21
- p cp_lib_data_thesis_gem = File.join(location[0].chomp, "/gems/#{latest_version[0].chomp.gsub(' (','-').gsub(')','')}/lib/data/thesis")
22
- p cp_lib_data_pieces_gem = File.join(location[0].chomp, "/gems/#{latest_version[0].chomp.gsub(' (','-').gsub(')','')}/lib/data/pieces")
20
+ p cp_lib_data_thesis_gem = File.join(location[0].chomp, "/gems/#{latest_version[0].chomp.gsub(' (','-').gsub(')','')}/lib/data/thesis")
21
+ p cp_lib_data_pieces_gem = File.join(location[0].chomp, "/gems/#{latest_version[0].chomp.gsub(' (','-').gsub(')','')}/lib/data/pieces")
23
22
  cp_lib_data_thesis_bundle = File.join(Dir.pwd, '/lib/data/thesis')
24
23
  cp_lib_data_pieces_bundle = File.join(Dir.pwd, '/lib/data/pieces')
25
24
  re_fig = /(.+\.jpg)|(.+\.jpeg)|(.+\.png)/
26
25
 
27
26
  print "\e[32minputfile: \e[0m"
28
- target = ARGV[1]
27
+ target = File.expand_path(ARGV[1])
29
28
  print "\e[32m#{target}\n\e[0m"
30
29
  print "\e[32moutputfile: \e[0m"
31
30
  tex_src = target.sub('.ipynb', '.tex')
@@ -54,13 +53,14 @@ module NbUtil
54
53
 
55
54
  mk_xbb(target, re_fig)
56
55
 
57
- if File.exist?(cp_lib_data_pieces_bundle)
56
+ if Dir.exist?(cp_lib_data_pieces_bundle.to_s)
58
57
  FileUtils.cp_r(cp_lib_data_pieces_bundle, target_parent)
59
58
  FileUtils.cp_r(cp_lib_data_thesis_bundle, target_parent)
60
59
  else
61
60
  FileUtils.cp_r(cp_lib_data_pieces_gem, target_parent)
62
61
  FileUtils.cp_r(cp_lib_data_thesis_gem, target_parent)
63
62
  end
63
+
64
64
  =begin
65
65
  if (Open3.capture3("bundle exec exe/nb_util ipynb2tex #{target}")) then
66
66
  FileUtils.cp_r(cp_lib_data_pieces_bundle, target_parent)
@@ -77,10 +77,9 @@ module NbUtil
77
77
  exit
78
78
  break
79
79
  elsif input == 'N' || input == 'n'
80
- p '作業を中断します'
80
+ target_parent = File.dirname(target)
81
+ FileUtils.rm_r(File.join(target_parent.to_s, '/informations.tex'))
81
82
  break
82
- else
83
- p "「Y」又は「N」を入力して下さい"
84
83
  end
85
84
  end
86
85
  end
@@ -149,13 +148,11 @@ module NbUtil
149
148
  caption = lines[i + 1]
150
149
  label_name = file_name.to_s.gsub('figs', '').gsub('.png', '').gsub('/', '')
151
150
  wrap_figs = <<"EOS"
152
- \\begin{wrapfigure}{r}{#{size}mm}
153
151
  \\begin{center}
154
- \\includegraphics[bb= 0 0 1024 768, width=#{size}mm]{../../#{file_name}}
155
- #{caption}
156
- \\label{fig:#{label_name}}
152
+ \\includegraphics[width=#{size}mm]{../../#{file_name}}
157
153
  \\end{center}
158
- \\end{wrapfigure}
154
+ #{caption}
155
+ \\label{fig:#{label}}
159
156
  EOS
160
157
  # \\vspace{#{top}\\baselineskip}
161
158
  # \\vspace{#{bottom}\\baselineskip}
@@ -187,11 +184,11 @@ EOS
187
184
  def your_informations(target)
188
185
  info = Array.new(3)
189
186
 
190
- print "卒論の題目: "
187
+ print "thesis title: "
191
188
  info[0] = STDIN.gets.to_s.chomp
192
- print "学籍番号(7桁): "
189
+ print "student number(eight-digit): "
193
190
  info[1] = STDIN.gets.to_s.chomp
194
- print "あなたの名前: "
191
+ print "your name: "
195
192
  info[2] = STDIN.gets.to_s.chomp
196
193
 
197
194
  target_parent = File.dirname(target)
@@ -211,17 +208,23 @@ EOS
211
208
  end
212
209
 
213
210
  def mk_latex_and_mv_to_latex(target, target_parent)
214
- mk_latex = File.join(File.dirname(target),'/mk_latex')
215
211
  mk_latex = FileUtils.mkdir_p(File.join(File.dirname(target),'/mk_latex'))
216
- FileUtils.rm_r(mk_latex[0])
212
+ if Dir.exist?(File.join(mk_latex[0].to_s, '/pieces'))
213
+ d = Date.today
214
+ old_file = File.join(File.dirname(target),"/old/#{d.year}#{d.month}#{d.day}")
215
+ FileUtils.mkdir_p(old_file)
216
+ FileUtils.cp_r(mk_latex[0], old_file)
217
+ FileUtils.rm_r(mk_latex[0])
218
+ end
217
219
  mk_latex = FileUtils.mkdir_p(File.join(File.dirname(target),'/mk_latex'))
220
+
218
221
  #p split_files = FileUtils.mkdir_p(File.join(File.dirname(target),'/mk_latex/split_files'))
219
222
  split_files = File.join(target_parent, '/split_files')
220
223
  pieces = File.join(target_parent, '/pieces')
221
224
  thesis = File.join(target_parent, '/thesis')
222
225
  latex = File.join(target_parent, '/latex')
223
226
 
224
- FileUtils.mv(split_files, mk_latex[0]+'/split_files')
227
+ FileUtils.mv(split_files, File.join(mk_latex[0], "/split_files"))
225
228
  FileUtils.mv(pieces, mk_latex[0])
226
229
  FileUtils.mv(thesis, mk_latex[0])
227
230
  FileUtils.mv(latex, mk_latex[0])
@@ -1,3 +1,3 @@
1
1
  module NbUtil
2
- VERSION = "0.3.5"
2
+ VERSION = "0.3.8"
3
3
  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.3.5
4
+ version: 0.3.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: 2017-12-18 00:00:00.000000000 Z
11
+ date: 2017-12-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler