jupyter_on_rails 0.5.5 → 0.8.1

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: 769af5be4c72d1dce0739d209f0db7002fa8816f9bd471acd0bed6b3904d8669
4
- data.tar.gz: ad10d114debe205827a83f766363ef4221b4b15c2556593f70ac3000a6dcac52
3
+ metadata.gz: 9711a06562424b6dcf2542d0469e883c0b0e0bbd00466a0e924f3f9e5906d786
4
+ data.tar.gz: 95af53e3de6c917318e7fe46b395cbbb82acb06c19504403ae1597269c7827f8
5
5
  SHA512:
6
- metadata.gz: 1938f2c92fdd5f4c0465b06a16e71c2648e2fac680e6a0b6ccf6fed7cbd68d21b8f0d7731a177b577bb38b99e3fc7206f6794fd1fd1629c4532b25cecc9646b6
7
- data.tar.gz: c4fec94fd82d5a61776f2b707872718de2baf45165d0c5785037300aa21295417dd5f8d9a88f8b4b16d369c940300124b1036ec650cc9ce3fd3b961d4efb33a1
6
+ metadata.gz: fce6869b2b66ad33be239e6a80688023cf2491d4eb8a3779b8cd10f2bc2f0d84e36bbf2f82cdd5e3eca84de7dc40d07f67a741e95b1f87adad0d7f68e7f26be5
7
+ data.tar.gz: d5bad91c4e293a8e2b88f645735cbe1a22061cf23dab010c091561ff57008b2bc9376a3c0cc3e6e33a5b7b9271a58b8fc3c07fd8358acefa70e3d4c5563dd613
data/.rubocop.yml ADDED
@@ -0,0 +1,29 @@
1
+ Gemspec/RequiredRubyVersion:
2
+ Enabled: false
3
+
4
+ Metrics/LineLength:
5
+ Max: 160
6
+
7
+ Style/Documentation:
8
+ Enabled: false
9
+
10
+ Style/ClassAndModuleChildren:
11
+ Enabled: false
12
+
13
+ Metrics/AbcSize:
14
+ Max: 100
15
+
16
+ Metrics/MethodLength:
17
+ Max: 60
18
+
19
+ Metrics/PerceivedComplexity:
20
+ Max: 20
21
+
22
+ Metrics/CyclomaticComplexity:
23
+ Max: 20
24
+
25
+ Style/MultilineTernaryOperator:
26
+ Enabled: false
27
+
28
+ Lint/SuppressedException:
29
+ Enabled: false
data/Gemfile CHANGED
@@ -1,6 +1,8 @@
1
- source "https://rubygems.org"
1
+ # frozen_string_literal: true
2
2
 
3
- git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
3
+ source 'https://rubygems.org'
4
+
5
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
4
6
 
5
7
  # Specify your gem's dependencies in jupyter_on_rails.gemspec
6
8
  gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,144 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ jupyter_on_rails (0.8.1)
5
+ daru
6
+ iruby
7
+ railties
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ actionpack (6.1.3.2)
13
+ actionview (= 6.1.3.2)
14
+ activesupport (= 6.1.3.2)
15
+ rack (~> 2.0, >= 2.0.9)
16
+ rack-test (>= 0.6.3)
17
+ rails-dom-testing (~> 2.0)
18
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
19
+ actionview (6.1.3.2)
20
+ activesupport (= 6.1.3.2)
21
+ builder (~> 3.1)
22
+ erubi (~> 1.4)
23
+ rails-dom-testing (~> 2.0)
24
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
25
+ activesupport (6.1.3.2)
26
+ concurrent-ruby (~> 1.0, >= 1.0.2)
27
+ i18n (>= 1.6, < 2)
28
+ minitest (>= 5.1)
29
+ tzinfo (~> 2.0)
30
+ zeitwerk (~> 2.3)
31
+ addressable (2.7.0)
32
+ public_suffix (>= 2.0.2, < 5.0)
33
+ ast (2.4.1)
34
+ backports (3.21.0)
35
+ bond (0.5.1)
36
+ builder (3.2.4)
37
+ bump (0.9.0)
38
+ concurrent-ruby (1.1.8)
39
+ crass (1.0.6)
40
+ daru (0.3)
41
+ packable (~> 1.3.13)
42
+ data_uri (0.1.0)
43
+ erubi (1.10.0)
44
+ faraday (1.0.1)
45
+ multipart-post (>= 1.2, < 3)
46
+ faraday-http-cache (2.2.0)
47
+ faraday (>= 0.8)
48
+ ffi (1.15.0)
49
+ ffi-rzmq (2.0.7)
50
+ ffi-rzmq-core (>= 1.0.7)
51
+ ffi-rzmq-core (1.0.7)
52
+ ffi
53
+ github_changelog_generator (1.15.2)
54
+ activesupport
55
+ faraday-http-cache
56
+ multi_json
57
+ octokit (~> 4.6)
58
+ rainbow (>= 2.2.1)
59
+ rake (>= 10.0)
60
+ retriable (~> 3.0)
61
+ i18n (1.8.10)
62
+ concurrent-ruby (~> 1.0)
63
+ iruby (0.5.0)
64
+ bond (~> 0.5)
65
+ data_uri (~> 0.1)
66
+ ffi-rzmq
67
+ mime-types (>= 3.3.1)
68
+ multi_json (~> 1.11)
69
+ loofah (2.9.1)
70
+ crass (~> 1.0.2)
71
+ nokogiri (>= 1.5.9)
72
+ method_source (1.0.0)
73
+ mime-types (3.3.1)
74
+ mime-types-data (~> 3.2015)
75
+ mime-types-data (3.2021.0225)
76
+ mini_portile2 (2.5.1)
77
+ minitest (5.14.4)
78
+ multi_json (1.14.1)
79
+ multipart-post (2.1.1)
80
+ nokogiri (1.11.3)
81
+ mini_portile2 (~> 2.5.0)
82
+ racc (~> 1.4)
83
+ octokit (4.18.0)
84
+ faraday (>= 0.9)
85
+ sawyer (~> 0.8.0, >= 0.5.3)
86
+ packable (1.3.14)
87
+ backports
88
+ parallel (1.20.1)
89
+ parser (3.0.0.0)
90
+ ast (~> 2.4.1)
91
+ public_suffix (4.0.5)
92
+ racc (1.5.2)
93
+ rack (2.2.3)
94
+ rack-test (1.1.0)
95
+ rack (>= 1.0, < 3)
96
+ rails-dom-testing (2.0.3)
97
+ activesupport (>= 4.2.0)
98
+ nokogiri (>= 1.6)
99
+ rails-html-sanitizer (1.3.0)
100
+ loofah (~> 2.3)
101
+ railties (6.1.3.2)
102
+ actionpack (= 6.1.3.2)
103
+ activesupport (= 6.1.3.2)
104
+ method_source
105
+ rake (>= 0.8.7)
106
+ thor (~> 1.0)
107
+ rainbow (3.0.0)
108
+ rake (13.0.1)
109
+ regexp_parser (2.0.3)
110
+ retriable (3.1.2)
111
+ rexml (3.2.5)
112
+ rubocop (1.8.0)
113
+ parallel (~> 1.10)
114
+ parser (>= 3.0.0.0)
115
+ rainbow (>= 2.2.2, < 4.0)
116
+ regexp_parser (>= 1.8, < 3.0)
117
+ rexml
118
+ rubocop-ast (>= 1.2.0, < 2.0)
119
+ ruby-progressbar (~> 1.7)
120
+ unicode-display_width (>= 1.4.0, < 3.0)
121
+ rubocop-ast (1.4.0)
122
+ parser (>= 2.7.1.5)
123
+ ruby-progressbar (1.11.0)
124
+ sawyer (0.8.2)
125
+ addressable (>= 2.3.5)
126
+ faraday (> 0.8, < 2.0)
127
+ thor (1.1.0)
128
+ tzinfo (2.0.4)
129
+ concurrent-ruby (~> 1.0)
130
+ unicode-display_width (2.0.0)
131
+ zeitwerk (2.4.2)
132
+
133
+ PLATFORMS
134
+ ruby
135
+
136
+ DEPENDENCIES
137
+ bump
138
+ github_changelog_generator
139
+ jupyter_on_rails!
140
+ rake
141
+ rubocop
142
+
143
+ BUNDLED WITH
144
+ 2.1.4
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Yuki Inoue
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md CHANGED
@@ -14,7 +14,10 @@ managing the jupyter configuration installed in user global area (the iruby kern
14
14
 
15
15
  With this gem, these awkwardness is to solved by following instruments:
16
16
  * `rake jupyter:notebook` Railtie command which invokes jupyter at your project root, and
17
- * The rails kernel dynamically defined by the rake task which automatically loads your Rails application.
17
+ * This rake task automatically creates two `iruby` kernels to load your application in Jupyter:
18
+ * one for normal operation
19
+ * one for sandbox mode in which everything you do is wrapped in a database transaction that is rolled back when the
20
+ kernel exits (equivalent to `rails console --sandbox`)
18
21
 
19
22
 
20
23
  ## Prerequisites
@@ -58,10 +61,11 @@ rake jupyter:notebook
58
61
  Eventually, you'll have jupyter opened, and the kernel being available.
59
62
 
60
63
 
61
- ### ApplicationRecord#to_df
64
+ ### ApplicationRecord.to_df/#to_df
62
65
 
63
66
  ```ruby
64
67
  User.to_df # => Daru::DataFrame is returned
68
+ user.to_df # => Daru::DataFrame for single record
65
69
  ```
66
70
 
67
71
  ### Daru::DataFrame#write_model
data/Rakefile CHANGED
@@ -1,2 +1,4 @@
1
- require "bundler/gem_tasks"
2
- task :default => :spec
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ task default: :spec
data/bin/console CHANGED
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
- require "bundler/setup"
4
- require "jupyter_on_rails"
4
+ require 'bundler/setup'
5
+ require 'jupyter_on_rails'
5
6
 
6
7
  # You can add fixtures and/or initialization code here to make experimenting
7
8
  # with your gem easier. You can also use a different console, if you like.
@@ -10,5 +11,5 @@ require "jupyter_on_rails"
10
11
  # require "pry"
11
12
  # Pry.start
12
13
 
13
- require "irb"
14
+ require 'irb'
14
15
  IRB.start(__FILE__)
@@ -1,45 +1,47 @@
1
+ # frozen_string_literal: true
1
2
 
2
- lib = File.expand_path("../lib", __FILE__)
3
+ lib = File.expand_path('lib', __dir__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require "jupyter_on_rails/version"
5
+ require 'jupyter_on_rails/version'
5
6
 
6
7
  Gem::Specification.new do |spec|
7
- spec.name = "jupyter_on_rails"
8
+ spec.name = 'jupyter_on_rails'
8
9
  spec.version = JupyterOnRails::VERSION
9
- spec.authors = ["Yuki INOUE"]
10
- spec.email = ["inoueyuworks@gmail.com"]
10
+ spec.authors = ['Yuki INOUE']
11
+ spec.email = ['inoueyuworks@gmail.com']
11
12
 
12
- spec.summary = %q{Integrate jupyter into rails}
13
- spec.description = %q{Utilities for integrating jupyter and rails.}
14
- spec.homepage = "https://github.com/Yuki-Inoue/jupyter_on_rails"
13
+ spec.summary = 'Integrate jupyter into rails'
14
+ spec.description = 'Utilities for integrating jupyter and rails.'
15
+ spec.homepage = 'https://github.com/Yuki-Inoue/jupyter_on_rails'
15
16
 
16
17
  # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
17
18
  # to allow pushing to a single host or delete this section to allow pushing to any host.
18
19
  if spec.respond_to?(:metadata)
19
- spec.metadata["allowed_push_host"] = 'https://rubygems.org'
20
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
20
21
 
21
- spec.metadata["homepage_uri"] = spec.homepage
22
- spec.metadata["source_code_uri"] = "https://github.com/Yuki-Inoue/jupyter_on_rails"
22
+ spec.metadata['homepage_uri'] = spec.homepage
23
+ spec.metadata['source_code_uri'] = 'https://github.com/Yuki-Inoue/jupyter_on_rails'
23
24
  # spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
24
25
  else
25
- raise "RubyGems 2.0 or newer is required to protect against " \
26
- "public gem pushes."
26
+ raise 'RubyGems 2.0 or newer is required to protect against ' \
27
+ 'public gem pushes.'
27
28
  end
28
29
 
29
30
  # Specify which files should be added to the gem when it is released.
30
31
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
31
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
32
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
32
33
  `git ls-files -z`.split("\x0")
33
- .reject { |f| f.match(%r{^(test|spec|features)/}) }
34
- .reject { |f| f.match(/\.png$/) }
34
+ .reject { |f| f.match(%r{^(test|spec|features|\.github)/}) }
35
+ .reject { |f| f.match(/(\.gitignore|\.png)$/) }
35
36
  end
36
- spec.bindir = "exe"
37
+ spec.bindir = 'exe'
37
38
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
38
- spec.require_paths = ["lib"]
39
+ spec.require_paths = ['lib']
39
40
 
40
- spec.add_development_dependency "rake"
41
- spec.add_development_dependency 'github_changelog_generator'
42
41
  spec.add_development_dependency 'bump'
42
+ spec.add_development_dependency 'github_changelog_generator'
43
+ spec.add_development_dependency 'rake'
44
+ spec.add_development_dependency 'rubocop'
43
45
 
44
46
  spec.add_dependency 'iruby'
45
47
  spec.add_dependency 'railties'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'jupyter_on_rails/version'
2
4
 
3
5
  module JupyterOnRails
@@ -1,14 +1,5 @@
1
- root = ENV.fetch('RAILS_ROOT')
1
+ # frozen_string_literal: true
2
2
 
3
- boot_file = File.expand_path('config/boot.rb', root)
4
- require boot_file
3
+ require 'jupyter_on_rails/kernel'
5
4
 
6
- require_relative 'iruby_kernel_extention'
7
- JupyterOnRails::IRubyKernelExtention.root = root
8
-
9
- require 'iruby'
10
- module IRuby
11
- class Kernel
12
- prepend JupyterOnRails::IRubyKernelExtention
13
- end
14
- end
5
+ JupyterOnRails::Kernel.new.boot
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'jupyter_on_rails/kernel'
4
+
5
+ JupyterOnRails::Kernel.new(sandbox: true).boot
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'active_support/concern'
2
4
 
3
5
  module JupyterOnRails
@@ -5,6 +7,17 @@ module JupyterOnRails
5
7
  module ActiveRecordExt
6
8
  extend ::ActiveSupport::Concern
7
9
 
10
+ # Rails 4.0 support
11
+ unless respond_to?(:class_methods)
12
+ def self.class_methods(&class_methods_module_definition)
13
+ mod = const_defined?(:ClassMethods, false) ?
14
+ const_get(:ClassMethods) :
15
+ const_set(:ClassMethods, Module.new)
16
+
17
+ mod.module_eval(&class_methods_module_definition)
18
+ end
19
+ end
20
+
8
21
  class_methods do
9
22
  def to_df
10
23
  relation = all
@@ -34,6 +47,10 @@ module JupyterOnRails
34
47
  ::Daru::DataFrame.new(datas)
35
48
  end
36
49
  end
50
+
51
+ def to_df
52
+ ::Daru::DataFrame.new([attributes])
53
+ end
37
54
  end
38
55
  end
39
56
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module JupyterOnRails
2
4
  module Daru
3
5
  module DataFrameExt
@@ -1,17 +1,45 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module JupyterOnRails
2
4
  module IRubyKernelExtention
3
5
  class << self
4
- attr_accessor :root
6
+ attr_accessor :root, :sandbox
5
7
  end
6
8
 
7
9
  def run
10
+ # Load Daru extensions
11
+ begin
12
+ require 'daru'
13
+ require 'active_record'
14
+ rescue LoadError
15
+ else
16
+ require 'jupyter_on_rails/daru/active_record_ext'
17
+ require 'jupyter_on_rails/daru/data_frame_ext'
18
+
19
+ ::ActiveRecord::Base.instance_eval do
20
+ include ::JupyterOnRails::Daru::ActiveRecordExt
21
+ end
22
+ ::Daru::DataFrame.instance_eval do
23
+ include ::JupyterOnRails::Daru::DataFrameExt
24
+ end
25
+ end
26
+
8
27
  original = Dir.pwd
9
28
  root = IRubyKernelExtention.root
10
29
  Dir.chdir root
11
- app_file = File.expand_path('config/application.rb', root)
30
+ app_file = File.expand_path('config/environment.rb', root)
12
31
  require app_file
13
32
  Rails.application.require_environment!
14
33
  Dir.chdir original
34
+
35
+ if IRubyKernelExtention.sandbox
36
+ ActiveRecord::Base.connection.begin_transaction(joinable: false)
37
+
38
+ at_exit do
39
+ ActiveRecord::Base.connection.rollback_transaction
40
+ end
41
+ end
42
+
15
43
  super
16
44
  end
17
45
  end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ module JupyterOnRails
4
+ class Kernel
5
+ def initialize(sandbox: false)
6
+ @root = ENV.fetch('RAILS_ROOT')
7
+ @sandbox = sandbox
8
+ end
9
+
10
+ def boot
11
+ boot_rails
12
+ load_extensions
13
+ end
14
+
15
+ private
16
+
17
+ def boot_rails
18
+ boot_file = File.expand_path('config/boot.rb', @root)
19
+ require boot_file
20
+ end
21
+
22
+ def load_extensions
23
+ require_relative 'iruby_kernel_extention'
24
+ JupyterOnRails::IRubyKernelExtention.root = @root
25
+ JupyterOnRails::IRubyKernelExtention.sandbox = @sandbox
26
+
27
+ require 'iruby'
28
+ IRuby::Kernel.instance_eval { prepend JupyterOnRails::IRubyKernelExtention }
29
+ IRuby::Display::Registry.instance_eval do
30
+ match do |obj|
31
+ obj.is_a?(ActiveRecord::Relation) ||
32
+ obj.is_a?(::Class) && obj < ActiveRecord::Base && !obj.abstract_class
33
+ end
34
+ priority 100
35
+ format 'text/html' do |obj|
36
+ n = 10
37
+ puts "finding top #{n}"
38
+ obj.limit(n).to_df.to_html
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'daru/active_record_ext'
2
4
  require_relative 'daru/data_frame_ext'
3
5
 
@@ -6,21 +8,5 @@ module JupyterOnRails
6
8
  rake_tasks do
7
9
  load 'jupyter_on_rails/railtie/jupyter.rake'
8
10
  end
9
-
10
- config.before_configuration do
11
- begin
12
- require 'daru'
13
- rescue LoadError
14
- end
15
-
16
- if defined?(::Daru) && defined?(::ActiveRecord)
17
- class ::ActiveRecord::Base
18
- include ::JupyterOnRails::Daru::ActiveRecordExt
19
- end
20
- class ::Daru::DataFrame
21
- include ::JupyterOnRails::Daru::DataFrameExt
22
- end
23
- end
24
- end
25
11
  end
26
12
  end
@@ -1,30 +1,52 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'shellwords'
2
4
  require 'json'
5
+ require 'ostruct'
3
6
 
7
+ # rubocop:disable Metrics/BlockLength
4
8
  namespace :jupyter do
5
9
  desc 'start jupyter notebook'
6
- task :notebook do
10
+ task notebook: :install_kernels do
11
+ ipython_dir = ENV['IPYTHONDIR'] || Rails.root / '.ipython'
12
+
13
+ env = { 'JUPYTER_DATA_DIR' => ipython_dir.to_s }
14
+ commands = %w[jupyter notebook]
15
+ commands = %w[pipenv run] + commands if (Rails.root / 'Pipfile').exist?
16
+ Process.exec(env, *commands)
17
+ end
18
+
19
+ desc 'Install the kernel'
20
+ task :install_kernels do
7
21
  root = Rails.root
8
22
  ipython_dir = ENV['JUPYTER_DATA_DIR'] || ENV['IPYTHONDIR'] || root / '.ipython'
9
23
  ipython_dir = File.absolute_path(ipython_dir.to_s)
24
+ application_module =
25
+ if Rails::VERSION::MAJOR >= 6
26
+ Rails.application.class.module_parent
27
+ else
28
+ Rails.application.class.parent
29
+ end
10
30
 
11
31
  sh "JUPYTER_DATA_DIR=#{Shellwords.shellescape(ipython_dir.to_s)} bundle exec iruby register --force"
12
32
 
13
- sh "rm -rf #{Shellwords.shellescape(ipython_dir.to_s)}/kernels/rails"
14
- sh "cp -r #{Shellwords.shellescape(ipython_dir.to_s)}/kernels/ruby #{Shellwords.shellescape(ipython_dir.to_s)}/kernels/rails"
33
+ [
34
+ OpenStruct.new(kernel_name: 'rails', boot_file: '../boot.rb', name_ext: ''),
35
+ OpenStruct.new(kernel_name: 'rails-sandbox', boot_file: '../boot_sandbox.rb', name_ext: ', sandbox')
36
+ ].each do |cfg|
37
+ sh "rm -rf #{Shellwords.shellescape(ipython_dir.to_s)}/kernels/#{cfg.kernel_name}"
15
38
 
16
- kernel_file = File.expand_path('kernels/rails/kernel.json', ipython_dir.to_s)
17
- kernel_h = JSON.parse(File.read(kernel_file))
18
- kernel_h['argv'] << File.expand_path('../boot.rb', __dir__)
19
- kernel_h['display_name'] = "#{Rails.application.class.parent} (rails #{Rails.version})"
20
- kernel_h['env'] ||= {}
21
- kernel_h['env']['RAILS_ROOT'] = root.to_s
39
+ sh "cp -r #{Shellwords.shellescape(ipython_dir.to_s)}/kernels/ruby #{Shellwords.shellescape(ipython_dir.to_s)}/kernels/#{cfg.kernel_name}"
22
40
 
23
- File.write(kernel_file, JSON.dump(kernel_h))
41
+ kernel_file = File.expand_path("kernels/#{cfg.kernel_name}/kernel.json", ipython_dir.to_s)
42
+ kernel_h = JSON.parse(File.read(kernel_file))
43
+ kernel_h['argv'] << File.expand_path(cfg.boot_file, __dir__)
44
+ kernel_h['display_name'] = "#{application_module} (rails #{Rails.version}#{cfg.name_ext})"
45
+ kernel_h['env'] ||= {}
46
+ kernel_h['env']['RAILS_ROOT'] = root.to_s
24
47
 
25
- env = { 'JUPYTER_DATA_DIR' => ipython_dir.to_s }
26
- commands = %w[jupyter notebook]
27
- commands = %w[pipenv run] + commands if (root / 'Pipfile').exist?
28
- Process.exec(env, *commands)
48
+ File.write(kernel_file, JSON.dump(kernel_h))
49
+ end
29
50
  end
30
51
  end
52
+ # rubocop:enable Metrics/BlockLength
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module JupyterOnRails
2
- VERSION = '0.5.5'
4
+ VERSION = '0.8.1'
3
5
  end
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jupyter_on_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.5
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuki INOUE
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-12-28 00:00:00.000000000 Z
11
+ date: 2021-05-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rake
14
+ name: bump
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
@@ -39,7 +39,21 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: bump
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
59
  - - ">="
@@ -101,10 +115,11 @@ executables: []
101
115
  extensions: []
102
116
  extra_rdoc_files: []
103
117
  files:
104
- - ".github/FUNDING.yml"
105
- - ".gitignore"
118
+ - ".rubocop.yml"
106
119
  - CHANGELOG.md
107
120
  - Gemfile
121
+ - Gemfile.lock
122
+ - LICENSE
108
123
  - README.md
109
124
  - Rakefile
110
125
  - bin/console
@@ -112,9 +127,11 @@ files:
112
127
  - jupyter_on_rails.gemspec
113
128
  - lib/jupyter_on_rails.rb
114
129
  - lib/jupyter_on_rails/boot.rb
130
+ - lib/jupyter_on_rails/boot_sandbox.rb
115
131
  - lib/jupyter_on_rails/daru/active_record_ext.rb
116
132
  - lib/jupyter_on_rails/daru/data_frame_ext.rb
117
133
  - lib/jupyter_on_rails/iruby_kernel_extention.rb
134
+ - lib/jupyter_on_rails/kernel.rb
118
135
  - lib/jupyter_on_rails/railtie.rb
119
136
  - lib/jupyter_on_rails/railtie/jupyter.rake
120
137
  - lib/jupyter_on_rails/version.rb
@@ -139,7 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
139
156
  - !ruby/object:Gem::Version
140
157
  version: '0'
141
158
  requirements: []
142
- rubygems_version: 3.0.3
159
+ rubygems_version: 3.1.4
143
160
  signing_key:
144
161
  specification_version: 4
145
162
  summary: Integrate jupyter into rails
data/.github/FUNDING.yml DELETED
@@ -1,2 +0,0 @@
1
-
2
- issuehunt: yuki-inoue
data/.gitignore DELETED
@@ -1,10 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /_yardoc/
4
- /coverage/
5
- /doc/
6
- /pkg/
7
- /spec/reports/
8
- /tmp/
9
- /Gemfile.lock
10
- /vendor