jupyter_on_rails 0.12.0 → 0.13.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 27f2fd3fc91d19c53934a71316291e7cf5611e5a7f111f9c3aaa8b473a907e0d
4
- data.tar.gz: ad3df102931dda73da46bd5feabf66a00fee9d8bf545dca737b6c4fbb45e4317
3
+ metadata.gz: 825a6e5e99d4d99d2efc6a11878e1491fcca63fcb551c1d1ad1c209fbada3d41
4
+ data.tar.gz: e2dd4b956fb8fe643c9bdaaba7bf5676d69fa45c6dc2618fb5ee54801089db26
5
5
  SHA512:
6
- metadata.gz: 5bc320a0c1b2b6b580d3ff90834aee380d117605e8df4325de238014ba51176670bc2e32422a0b64e0c5bff098b46ef2c1558413acd76226d939d76b94ab1693
7
- data.tar.gz: db968e93f18f3a806f329e9aa5503001d415cb83f95bd34bae48d7066ba59bc1e0f97221d0cdef9b6c17d081db8d04bf3d760c24ae070e3960ad251eee6b142a
6
+ metadata.gz: 47a6707a1a8763e9452d0f7482647fe5cbb2092bb0730a8a16bbea397e6c211a5803c3cacf5668f556f1ba931739144beb50780a5b87b24d82e9e919cf5fc4f1
7
+ data.tar.gz: e621139221f8ac2c8dd50e711ac0f745928e3a43662ceb515184fef21994c4b191fd5fef5461541e4ff7016943fe79af74bd45b050a129bb5b8c43685f71dba9
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- jupyter_on_rails (0.12.0)
4
+ jupyter_on_rails (0.13.0)
5
5
  daru
6
6
  iruby
7
7
  railties
@@ -1,8 +1,26 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JupyterOnRails
4
- module Initializer
5
- def self.run(root:, sandbox:)
4
+ class Initializer
5
+ def self.run(**opts)
6
+ new(**opts).run
7
+ end
8
+
9
+ def initialize(root:, sandbox:)
10
+ @root = root
11
+ @sandbox = sandbox
12
+ end
13
+
14
+ attr_reader :root, :sandbox
15
+
16
+ def run
17
+ setup_daru
18
+ load_rails_environment
19
+ setup_console_methods
20
+ setup_sandbox_transaction if sandbox
21
+ end
22
+
23
+ def setup_daru
6
24
  require 'active_support/lazy_load_hooks'
7
25
 
8
26
  ActiveSupport.on_load(:active_record) do
@@ -33,16 +51,25 @@ module JupyterOnRails
33
51
  end
34
52
  end
35
53
  end
54
+ end
36
55
 
37
- original = Dir.pwd
38
- Dir.chdir root
56
+ def load_rails_environment
39
57
  app_file = File.expand_path('config/environment.rb', root)
40
- require app_file
41
- Rails.application.require_environment!
42
- Dir.chdir original
58
+ Dir.chdir(root) do
59
+ require app_file
60
+ end
61
+ end
43
62
 
44
- return unless sandbox
63
+ def setup_console_methods
64
+ require 'rails/console/app'
65
+ IRuby::Kernel
66
+ .instance
67
+ .instance_variable_get(:@backend)
68
+ .instance_variable_get(:@main)
69
+ .extend(Rails::ConsoleMethods)
70
+ end
45
71
 
72
+ def setup_sandbox_transaction
46
73
  ActiveRecord::Base.connection.begin_transaction(joinable: false)
47
74
  at_exit do
48
75
  ActiveRecord::Base.connection.rollback_transaction
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JupyterOnRails
4
- VERSION = '0.12.0'
4
+ VERSION = '0.13.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jupyter_on_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.0
4
+ version: 0.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuki INOUE