Module: IRuby::Jupyter

Defined in:
lib/iruby/jupyter.rb

Class Method Summary collapse

Class Method Details

.default_data_dirObject

User’s default kernelspec directory is described here:

https://docs.jupyter.org/en/latest/use/jupyter-directories.html


6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/iruby/jupyter.rb', line 6

def default_data_dir
  data_dir = ENV["JUPYTER_DATA_DIR"]
  return data_dir if data_dir

  case
  when windows?
    appdata = windows_user_appdata
    if !appdata.empty?
      File.join(appdata, 'jupyter')
    else
      jupyter_config_dir = ENV.fetch('JUPYTER_CONFIG_DIR', File.expand_path('~/.jupyter'))
      File.join(jupyter_config_dir, 'data')
    end
  when apple?
    File.expand_path('~/Library/Jupyter')
  else
    xdg_data_home = ENV.fetch('XDG_DATA_HOME', '')
    data_home = xdg_data_home[0] ? xdg_data_home : File.expand_path('~/.local/share')
    File.join(data_home, 'jupyter')
  end
end

.kernelspec_dir(data_dir = nil) ⇒ Object



28
29
30
31
# File 'lib/iruby/jupyter.rb', line 28

def kernelspec_dir(data_dir=nil)
  data_dir ||= default_data_dir
  File.join(data_dir, 'kernels')
end