jupyter_on_rails 0.12.0 → 0.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/jupyter_on_rails/initializer.rb +35 -8
- data/lib/jupyter_on_rails/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 825a6e5e99d4d99d2efc6a11878e1491fcca63fcb551c1d1ad1c209fbada3d41
|
4
|
+
data.tar.gz: e2dd4b956fb8fe643c9bdaaba7bf5676d69fa45c6dc2618fb5ee54801089db26
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 47a6707a1a8763e9452d0f7482647fe5cbb2092bb0730a8a16bbea397e6c211a5803c3cacf5668f556f1ba931739144beb50780a5b87b24d82e9e919cf5fc4f1
|
7
|
+
data.tar.gz: e621139221f8ac2c8dd50e711ac0f745928e3a43662ceb515184fef21994c4b191fd5fef5461541e4ff7016943fe79af74bd45b050a129bb5b8c43685f71dba9
|
data/Gemfile.lock
CHANGED
@@ -1,8 +1,26 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module JupyterOnRails
|
4
|
-
|
5
|
-
def self.run(
|
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
|
-
|
38
|
-
Dir.chdir root
|
56
|
+
def load_rails_environment
|
39
57
|
app_file = File.expand_path('config/environment.rb', root)
|
40
|
-
|
41
|
-
|
42
|
-
|
58
|
+
Dir.chdir(root) do
|
59
|
+
require app_file
|
60
|
+
end
|
61
|
+
end
|
43
62
|
|
44
|
-
|
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
|