red-amber-view 0.0.0 → 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -0
- data/exe/arrow_table_view.rb +3 -5
- data/lib/red_amber/view/version.rb +1 -1
- data/lib/red_amber/view.rb +38 -10
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a906d4762fac64e4671e16728430d97f709001fce8429521d6d4e4d7fb92bbd7
|
4
|
+
data.tar.gz: 650d56a3a69a61a49bd9b21597734ac819df1e4e7fde91b07bcbd898cd7acc9b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d029ceb987981f0df229915706daacec55151a2366318bbba8866fed1c772e0abaf917db55296a6e38a308563d2bd241dff9f94505ba7e8afbd51b2699ef817a
|
7
|
+
data.tar.gz: e184c90a5b65880b0d3294e9ab8afbda61c442143eb07e468b8be4348ac042bd4ce4ac55f91c23e8d0a9aa7cb646a0f5c1ad3655d9b0739c5d5c240b8cbf041b
|
data/README.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# RedAmber View
|
2
2
|
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/red-amber-view.svg)](https://badge.fury.io/rb/red-amber-view)
|
4
|
+
[![test](https://github.com/kojix2/red-amber-view/actions/workflows/ci.yml/badge.svg)](https://github.com/kojix2/red-amber-view/actions/workflows/ci.yml)
|
5
|
+
[![Gitter Chat](https://badges.gitter.im/red-data-tools/en.svg)](https://gitter.im/red-data-tools/en)
|
6
|
+
|
3
7
|
R's `View()` for [RedAmber](https://github.com/heronshoes/red_amber).
|
4
8
|
|
5
9
|
## Installation
|
data/exe/arrow_table_view.rb
CHANGED
@@ -3,13 +3,13 @@
|
|
3
3
|
require 'libui'
|
4
4
|
require 'arrow'
|
5
5
|
|
6
|
-
WINDOW_TITLE =
|
6
|
+
WINDOW_TITLE = ARGV[1]
|
7
7
|
WINDOW_WIDTH = 600
|
8
8
|
WINDOW_HEIGHT = 400
|
9
9
|
|
10
10
|
ARROW_PATH = ARGV[0]
|
11
|
-
|
12
|
-
|
11
|
+
arrow_table = Arrow::Table.load(ARROW_PATH)
|
12
|
+
File.unlink(ARROW_PATH)
|
13
13
|
|
14
14
|
LibUI.init
|
15
15
|
|
@@ -18,7 +18,6 @@ main_window = LibUI.new_window(WINDOW_TITLE, WINDOW_WIDTH, WINDOW_HEIGHT, 1)
|
|
18
18
|
hbox = LibUI.new_horizontal_box
|
19
19
|
LibUI.window_set_child(main_window, hbox)
|
20
20
|
|
21
|
-
arrow_table = Arrow::Table.load(ARROW_PATH)
|
22
21
|
ncol = arrow_table.n_columns
|
23
22
|
nrow = arrow_table.n_rows
|
24
23
|
|
@@ -59,7 +58,6 @@ LibUI.box_append(hbox, table, 1)
|
|
59
58
|
LibUI.control_show(main_window)
|
60
59
|
|
61
60
|
LibUI.window_on_closing(main_window) do
|
62
|
-
rm_arrow_file.call
|
63
61
|
LibUI.control_destroy(main_window)
|
64
62
|
LibUI.free_table_model(model)
|
65
63
|
LibUI.quit
|
data/lib/red_amber/view.rb
CHANGED
@@ -7,17 +7,45 @@ module RedAmber
|
|
7
7
|
module View
|
8
8
|
DataFrame.include(self)
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
10
|
+
# Invokes a spreadsheet-style data viewer
|
11
|
+
# @param [String] title A title for a viewer window.
|
12
|
+
# @return [Integer] The pid of the child process.
|
13
|
+
|
14
|
+
def view(title = 'RedAmber View')
|
15
|
+
arrow_path = nil
|
16
|
+
|
17
|
+
# Linux
|
18
|
+
if Dir.exist?('/dev/shm')
|
19
|
+
require 'securerandom'
|
20
|
+
loop do
|
21
|
+
arrow_path = "/dev/shm/red-amber-view-#{SecureRandom.hex(8)}.arrow"
|
22
|
+
break unless File.exist? arrow_path
|
23
|
+
end
|
24
|
+
begin
|
25
|
+
save_succeeded = to_arrow.save(arrow_path)
|
26
|
+
rescue StandardError => e
|
27
|
+
warn e.message
|
28
|
+
end
|
16
29
|
end
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
30
|
+
|
31
|
+
# When /dev/shm is not available
|
32
|
+
unless save_succeeded
|
33
|
+
require 'tempfile'
|
34
|
+
# The tempfile will be removed by the spawned process.
|
35
|
+
tf = Tempfile.create(['red-amber-view', '.arrow'])
|
36
|
+
arrow_path = tf.path
|
37
|
+
save_succeeded = to_arrow.save(arrow_path)
|
38
|
+
end
|
39
|
+
|
40
|
+
raise 'Failed to save arrow file' unless save_succeeded
|
41
|
+
|
42
|
+
spawn(RbConfig.ruby, arrow_table_viewer, arrow_path, title)
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def arrow_table_viewer
|
48
|
+
File.expand_path('../../exe/arrow_table_view.rb', __dir__)
|
21
49
|
end
|
22
50
|
end
|
23
51
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: red-amber-view
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kojix2
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-07-
|
11
|
+
date: 2022-07-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: libui
|