ruby-gr 0.0.3 → 0.0.4

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.
data/lib/gr3/ffi.rb CHANGED
@@ -3,6 +3,7 @@
3
3
  require 'ffi'
4
4
 
5
5
  module GR3
6
+ # FFI Wrapper module for GR
6
7
  module FFI
7
8
  extend ::FFI::Library
8
9
 
data/lib/gr_commons.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # Module with common code for GR, GR3
3
4
  module GRCommons
4
5
  end
5
6
 
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GRCommons
4
+ # This module modifies the behavior of the attach_function method.
4
5
  module AttachFunction
5
6
  # Remember added method name
6
7
  def attach_function(name, *args)
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GRCommons
4
+ # This module adds methods to the GRBase and GR3Base modules.
4
5
  module DefineMethods
5
6
  private
6
7
 
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GRCommons
4
+ # This module provides functionality common to GR and GR3.
4
5
  module GRCommonUtils
5
6
  private
6
7
 
@@ -3,19 +3,26 @@
3
3
  module GRCommons
4
4
  # Jupyter Notebook and Jpyter Lab.
5
5
  module JupyterSupport
6
- if defined? IRuby
6
+ if defined?(IRuby) && IRuby.respond_to?(:display)
7
7
  def self.extended(_obj)
8
- require 'tempfile'
8
+ require 'tmpdir'
9
9
  ENV['GKSwstype'] = 'svg'
10
10
  # May be extended to both GR3 and GR
11
- ENV['GKS_FILEPATH'] = Tempfile.open(['plot', '.svg']).path
11
+ ENV['GKS_FILEPATH'] = Dir::Tmpname.create('plot-') {}
12
12
  end
13
13
 
14
14
  def show
15
15
  emergencyclosegks
16
16
  sleep 0.5
17
- svg = File.read(ENV['GKS_FILEPATH'])
18
- IRuby.display(svg, mime: 'image/svg+xml')
17
+ case ENV['GKSwstype']
18
+ when 'svg'
19
+ data = File.read(ENV['GKS_FILEPATH'] + '.svg')
20
+ IRuby.display(data, mime: 'image/svg+xml')
21
+ when 'mov', 'mp4', 'webm'
22
+ require 'base64'
23
+ data = File.binread(ENV['GKS_FILEPATH'] + '.' + ENV['GKSwstype'])
24
+ IRuby.display("<video controls autoplay type=\"video/mp4\" src=\"data:video/mp4;base64,#{Base64.encode64(data)}\">", mime: 'text/html')
25
+ end
19
26
  nil
20
27
  end
21
28
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GRCommons
4
- VERSION = '0.0.3'
4
+ VERSION = '0.0.4'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-gr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - kojix2
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-30 00:00:00.000000000 Z
11
+ date: 2019-11-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi