jupyter_on_rails 0.3.4 → 0.4.0

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: 6500d132489c7b40c8502a6d4d95f0cd4e314bccb33b26d3693206a27046c988
4
- data.tar.gz: 6d928c989159b0bddd3dc2df4489e190863217bc8fe5e6c2d9baeb3446678852
3
+ metadata.gz: 8e6369cfa99c15261de10721130c486f17eb74b2cb1314ee12d9dcbd3cc05e56
4
+ data.tar.gz: 0fb2755e9c07b722653afa7f21bb22e0ea2696bcb6c5a4cc2ead1aa8979dc45b
5
5
  SHA512:
6
- metadata.gz: 271038f2cf2635d8fad00f9ed23edee77a6a0743201f7fe590a1c834492cb6e87d04681c92ae53f1824f4133d41b37729fdd8d3a47d2e9f82e6a08b35a9b1b04
7
- data.tar.gz: 2488dff0517374702c01e6ebf36d5a8c8a170741aef8a9948a2632edc666d7e2443c609b0ccfd1ccef037b44ff42d3879368cd1b6b0db1210afbd156eb0d4a41
6
+ metadata.gz: 810b4806aeddac18ef4daca0af9d73686bfbc31bcdc39dd5c41ace0fa0ffb746828d5c366c142e52274a10aa68f3c4352766b809a2afddc042ac3bf1b59fac7f
7
+ data.tar.gz: d79f7edbcfb58449b58b7922d5adc22758d90648bd985e77ddae581e18d5e9da74bc27d7d216cf8067f8a8f3960ea1b9dc2c9c935b9f165c0b346504e481ef65
data/README.md CHANGED
@@ -64,6 +64,15 @@ Eventually, you'll have jupyter opened, and the kernel being available.
64
64
  User.to_df # => Daru::DataFrame is returned
65
65
  ```
66
66
 
67
+ ### Daru::DataFrame#write_model
68
+
69
+ For each row, call `to_h` and pass it to `model.new`.
70
+ And then, imports them using `model.import`.
71
+
72
+ ```ruby
73
+ df.write_model(User)
74
+ ```
75
+
67
76
  ## Development
68
77
 
69
78
  This is a railtie gem, so you'd probably want to do something like:
@@ -38,6 +38,8 @@ Gem::Specification.new do |spec|
38
38
  spec.add_development_dependency "bundler", "~> 1.17"
39
39
  spec.add_development_dependency "rake", "~> 10.0"
40
40
 
41
- spec.add_dependency 'railties'
42
41
  spec.add_dependency 'iruby'
42
+ spec.add_dependency 'railties'
43
+
44
+ spec.add_dependency 'activerecord-import'
43
45
  end
@@ -0,0 +1,12 @@
1
+ module JupyterOnRails
2
+ module Daru
3
+ module DataFrameExt
4
+ def write_model(model)
5
+ require 'activerecord-import'
6
+
7
+ objs = map_rows(&:to_h).map(&model.method(:new))
8
+ model.import(objs)
9
+ end
10
+ end
11
+ end
12
+ end
@@ -1,4 +1,5 @@
1
1
  require_relative 'daru/active_record_ext'
2
+ require_relative 'daru/data_frame_ext'
2
3
 
3
4
  module JupyterOnRails
4
5
  class Railtie < ::Rails::Railtie
@@ -11,6 +12,9 @@ module JupyterOnRails
11
12
  class ::ActiveRecord::Base
12
13
  include ::JupyterOnRails::Daru::ActiveRecordExt
13
14
  end
15
+ class ::Daru::DataFrame
16
+ include ::JupyterOnRails::Daru::DataFrameExt
17
+ end
14
18
  end
15
19
  end
16
20
  end
@@ -1,3 +1,3 @@
1
1
  module JupyterOnRails
2
- VERSION = '0.3.4'
2
+ VERSION = '0.4.0'
3
3
  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.3.4
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuki INOUE
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: iruby
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: railties
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -53,7 +67,7 @@ dependencies:
53
67
  - !ruby/object:Gem::Version
54
68
  version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
- name: iruby
70
+ name: activerecord-import
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
73
  - - ">="
@@ -84,6 +98,7 @@ files:
84
98
  - lib/jupyter_on_rails.rb
85
99
  - lib/jupyter_on_rails/boot.rb
86
100
  - lib/jupyter_on_rails/daru/active_record_ext.rb
101
+ - lib/jupyter_on_rails/daru/data_frame_ext.rb
87
102
  - lib/jupyter_on_rails/iruby_kernel_extention.rb
88
103
  - lib/jupyter_on_rails/railtie.rb
89
104
  - lib/jupyter_on_rails/railtie/jupyter.rake