jupyter_on_rails 0.5.3 → 0.5.4

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: 21a8ae6b4a482e324dbb5cee23c4239bf9ec489b3fe6a6bf31e2f7ebccc8f612
4
- data.tar.gz: e72c9b01472338ac1e948201d1dcce66f30fe57921660becb126219d83c7ba54
3
+ metadata.gz: 64441927cfbebeb5966f657eb12f91da456f0153bea937d63224d20c0e0ea8d9
4
+ data.tar.gz: 4c291ffecffbe3b1da1edead4c67bac115ebd8f43c197069fcb36f59ad7cd228
5
5
  SHA512:
6
- metadata.gz: cfb93042494c2f9f4a831d95059afaa1ab49dac9be49d93055debe7c70c1a9ecad0d0877fe61c98a183e1af1f5ff96abb703fba5765ee8963d745c71c770e584
7
- data.tar.gz: '040793452a6e5b6c40b2c69bc5335cde56e8a51ae90d996e20dd817807857406e78f8aa38272049d422f732af6c0d81db83b85ac4f1f8cbb10f6b624b70e548c'
6
+ metadata.gz: cb81e52c12d99a68a99808f5c21958bed0cfc75668a8c5ba12815d28306432b3b643ed56d98c9acd9276ff56e7eb6b77209a2d0310349e6944c4ff51455e3126
7
+ data.tar.gz: 808ce025b1c66bcf6c967ff6bd6d8d24aaf61d2781d0360d1963cdfb3b73b2d406bb931988d2e40f8b5572b24b4c8f44318806f6c7e3a4809ea27940952cf053
@@ -0,0 +1,2 @@
1
+
2
+ issuehunt: yuki-inoue
data/README.md CHANGED
@@ -67,7 +67,8 @@ User.to_df # => Daru::DataFrame is returned
67
67
  ### Daru::DataFrame#write_model
68
68
 
69
69
  For each row, call `to_h` and pass it to `model.new`.
70
- And then, imports them using `model.import`.
70
+ And then, imports them using `model.insert_all` on Rails >= 6, or `model.import` (requires adding
71
+ `activerecord-import` to your `Gemfile`).
71
72
 
72
73
  ```ruby
73
74
  df.write_model(User)
@@ -37,14 +37,12 @@ Gem::Specification.new do |spec|
37
37
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
38
38
  spec.require_paths = ["lib"]
39
39
 
40
- spec.add_development_dependency "bundler", "~> 1.17"
41
- spec.add_development_dependency "rake", "~> 10.0"
40
+ spec.add_development_dependency "rake"
42
41
  spec.add_development_dependency 'github_changelog_generator'
43
42
  spec.add_development_dependency 'bump'
44
43
 
45
44
  spec.add_dependency 'iruby'
46
45
  spec.add_dependency 'railties'
47
46
 
48
- spec.add_dependency 'activerecord-import'
49
47
  spec.add_dependency 'daru'
50
48
  end
@@ -2,10 +2,28 @@ module JupyterOnRails
2
2
  module Daru
3
3
  module DataFrameExt
4
4
  def write_model(model)
5
- require 'activerecord-import'
5
+ if ActiveRecord.version >= Gem::Version.new('6.0.0.beta1')
6
+ write_model_rails(model)
7
+ else
8
+ write_model_activerecord_import(model)
9
+ end
10
+ end
11
+
12
+ private
13
+
14
+ def write_model_activerecord_import(model)
15
+ begin
16
+ require 'activerecord-import'
17
+ rescue LoadError
18
+ raise 'write_model requires either Rails >= 6 or the activerecord-import gem'
19
+ end
20
+
21
+ records = map_rows(&:to_h).map(&model.method(:new))
22
+ model.import(records)
23
+ end
6
24
 
7
- objs = map_rows(&:to_h).map(&model.method(:new))
8
- model.import(objs)
25
+ def write_model_rails(model)
26
+ model.insert_all(map_rows(&:to_h))
9
27
  end
10
28
  end
11
29
  end
@@ -1,3 +1,3 @@
1
1
  module JupyterOnRails
2
- VERSION = '0.5.3'
2
+ VERSION = '0.5.4'
3
3
  end
metadata CHANGED
@@ -1,43 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jupyter_on_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.5.4
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-04-21 00:00:00.000000000 Z
11
+ date: 2019-09-18 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: bundler
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '1.17'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '1.17'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: rake
29
15
  requirement: !ruby/object:Gem::Requirement
30
16
  requirements:
31
- - - "~>"
17
+ - - ">="
32
18
  - !ruby/object:Gem::Version
33
- version: '10.0'
19
+ version: '0'
34
20
  type: :development
35
21
  prerelease: false
36
22
  version_requirements: !ruby/object:Gem::Requirement
37
23
  requirements:
38
- - - "~>"
24
+ - - ">="
39
25
  - !ruby/object:Gem::Version
40
- version: '10.0'
26
+ version: '0'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: github_changelog_generator
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -94,20 +80,6 @@ dependencies:
94
80
  - - ">="
95
81
  - !ruby/object:Gem::Version
96
82
  version: '0'
97
- - !ruby/object:Gem::Dependency
98
- name: activerecord-import
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- version: '0'
104
- type: :runtime
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- version: '0'
111
83
  - !ruby/object:Gem::Dependency
112
84
  name: daru
113
85
  requirement: !ruby/object:Gem::Requirement
@@ -129,6 +101,7 @@ executables: []
129
101
  extensions: []
130
102
  extra_rdoc_files: []
131
103
  files:
104
+ - ".github/FUNDING.yml"
132
105
  - ".gitignore"
133
106
  - CHANGELOG.md
134
107
  - Gemfile