ruby-gr 0.0.26 → 0.64.0.0

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.
@@ -23,45 +23,66 @@ module GRCommons
23
23
  # - mingw-w64-gr
24
24
  module GRLib
25
25
  class << self
26
+ # Check if using RubyInstaller or not.
27
+ def ruby_installer?
28
+ Object.const_defined?(:RubyInstaller)
29
+ end
30
+
31
+ # Return the directory path from the GRDIR environment variable.
32
+ def get_grdir_from_env(lib_names)
33
+ return nil unless ENV['GRDIR']
34
+ return ENV['GRDIR'] if Dir.exist?(ENV['GRDIR'])
35
+
36
+ warn "#{lib_names} : Dir GRDIR=#{ENV['GRDIR']} not found." # return nil
37
+ end
38
+
26
39
  # Search the shared library.
27
40
  # @note This method does not detect the Operating System.
28
41
  #
29
42
  # @param lib_names [Array] The actual file name of the shared library.
30
43
  # @param pkg_name [String] The package name to be used when searching with pkg-configg
31
44
  def search(lib_names, pkg_name)
45
+ # FIXME: There may be a better way to do it...
32
46
  def lib_names.map_find(&block)
33
47
  lazy.map(&block).find { |path| path }
34
48
  end
49
+
50
+ # ENV['GRDIR']
51
+ # Verify that the directory exists.
52
+ grdir = get_grdir_from_env(lib_names)
53
+
35
54
  # Windows + RubyInstaller
36
- if Object.const_defined?(:RubyInstaller)
37
- dir = ENV['GRDIR'] || [
38
- RubyInstaller::Runtime.msys2_installation.msys_path,
39
- RubyInstaller::Runtime.msys2_installation.mingwarch
40
- ].join(File::ALT_SEPARATOR)
41
- lib_names.lazy.map do |lib_name|
42
- recursive_search(lib_name, dir)
43
- end.find { |i| i }.tap do |path|
44
- RubyInstaller::Runtime.add_dll_directory(File.dirname(path)) if path
45
- end
46
- # ENV['GRDIR'] (Linux, Mac, Windows)
47
- elsif ENV['GRDIR']
48
- # Search for XXX.dylib and then XXX.so on macOS
49
- lib_names.map_find do |lib_name|
50
- recursive_search(lib_name, ENV['GRDIR'])
51
- end || lib_names.map_find do |lib_name|
52
- pkg_config_search(lib_name, pkg_name)
53
- end
54
- else
55
- lib_names.map_find do |lib_name|
56
- pkg_config_search(lib_name, pkg_name)
55
+ if ruby_installer?
56
+ grdir ||= File.join(RubyInstaller::Runtime.msys2_installation.msys_path,
57
+ RubyInstaller::Runtime.msys2_installation.mingwarch)
58
+ end
59
+
60
+ # Search grdir
61
+ if grdir
62
+ lib_path = lib_names.map_find do |lib_name|
63
+ recursive_search(lib_name, grdir)
57
64
  end
58
65
  end
66
+
67
+ # Search with pkg-config
68
+ lib_path ||= lib_names.map_find do |lib_name|
69
+ pkg_config_search(lib_name, pkg_name)
70
+ end
71
+
72
+ # Windows + RubyInstaller
73
+ if ruby_installer?
74
+ RubyInstaller::Runtime.add_dll_directory(File.dirname(lib_path))
75
+ # FIXME: Where should I write this code?
76
+ ENV['GKS_FONTPATH'] ||= grdir
77
+ end
78
+
79
+ lib_path
59
80
  end
60
81
 
61
82
  # Recursive file search in directories
62
83
  # @param name [String] File to search for
63
84
  # @param base_dir [String] Directory to search
64
- # @retrun path [String, NilClass] Returns the first path found.
85
+ # @return path [String, NilClass] Returns the first path found.
65
86
  # If not found, nil is returned.
66
87
  def recursive_search(name, base_dir)
67
88
  Dir.chdir(base_dir) do
@@ -5,10 +5,11 @@
5
5
  # It should not be loaded when gr_commons/gr_commons is loaded.
6
6
 
7
7
  require 'logger'
8
- require 'rainbow'
9
- require 'awesome_print'
8
+ require 'pp'
10
9
 
11
10
  module GRCommons
11
+ # Convenience class methods
12
+
12
13
  class << self
13
14
  # Create a new GRLogger
14
15
  # @param out [String]
@@ -16,30 +17,35 @@ module GRCommons
16
17
  # @example
17
18
  # require 'gr_commons/gr_logger'
18
19
  # GRCommons.gr_log("log.txt")
20
+
19
21
  def gr_log(out = $stderr)
20
22
  GRCommons::GRLogger.new(out)
21
23
  end
22
24
 
23
25
  # Return the last created GRLogger
24
26
  # @return [GRLogger]
27
+
25
28
  def gr_logger
26
29
  GRCommons::GRLogger.logger
27
30
  end
28
31
  end
29
32
 
30
- # Outputs function calls to GR Framework to a log file.
31
- # Mainly used for debugging.
32
- # @note This module is for those who want to see low-level function calls in GR.
33
+ # If GR.rb call native functions of the GR framework,
34
+ # it will be recorded in the log file.
35
+ #
36
+ # @note Mainly used by developers for debugging.
33
37
  #
34
38
  # = How it works 
35
- # prepend a module named Inspector to the singular class
36
- # of the FFI module. It will inspects the GR function call of the FFI module
39
+ # It prepend a module named Inspector to the singular class of the FFI module.
40
+ # It will inspects the GR function call of the FFI module
37
41
  #
38
42
  # @example
39
43
  # require 'gr_commons/gr_logger'
40
- # GRCommons.gr_log("log.txt")
44
+ # GRCommons::GRLogger.new("log.txt")
45
+
41
46
  class GRLogger < Logger
42
47
  # Return the last created GRLogger
48
+
43
49
  def self.logger
44
50
  @@logger ||= GRCommons::GRLogger.new
45
51
  end
@@ -51,13 +57,15 @@ module GRCommons
51
57
  end
52
58
  end
53
59
 
60
+ # GR
61
+
54
62
  if Object.const_defined?(:GR)
55
63
  module GR
56
64
  module FFI
57
65
  module Inspector
58
66
  GR::FFI.ffi_methods.each do |s|
59
67
  define_method(s) do |*args|
60
- GRCommons.gr_logger.info "GR::FFI.#{s}\n" + args.ai + "\n"
68
+ GRCommons.gr_logger.info "GR::FFI.#{s}\n#{args.pretty_inspect}\n"
61
69
  super(*args)
62
70
  end
63
71
  end
@@ -69,13 +77,15 @@ if Object.const_defined?(:GR)
69
77
  end
70
78
  end
71
79
 
80
+ # GR3
81
+
72
82
  if Object.const_defined?(:GR3)
73
83
  module GR3
74
84
  module FFI
75
85
  module Inspector
76
86
  GR3::FFI.ffi_methods.each do |s|
77
87
  define_method(s) do |*args|
78
- GRCommons.gr_logger.info "GR3::FFI.#{s}\n" + args.ai + "\n"
88
+ GRCommons.gr_logger.info "GR3::FFI.#{s}\n#{args.pretty_inspect}\n"
79
89
  super(*args)
80
90
  end
81
91
  end
@@ -87,13 +97,15 @@ if Object.const_defined?(:GR3)
87
97
  end
88
98
  end
89
99
 
100
+ # GRM
101
+
90
102
  if Object.const_defined?(:GRM)
91
103
  module GRM
92
104
  module FFI
93
105
  module Inspector
94
106
  GRM::FFI.ffi_methods.each do |s|
95
107
  define_method(s) do |*args|
96
- GRCommons.gr_logger.info "GRM::FFI.#{s}\n" + args.ai + "\n"
108
+ GRCommons.gr_logger.info "GRM::FFI.#{s}\n#{args.pretty_inspect}\n"
97
109
  super(*args)
98
110
  end
99
111
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GRCommons
4
- VERSION = '0.0.26'
4
+ VERSION = '0.64.0.0'
5
5
  end
data/lib/grm/ffi.rb CHANGED
@@ -70,8 +70,5 @@ module GRM
70
70
  try_extern 'int grm_merge_named(const grm_args_t *args, const char *identificator)'
71
71
  try_extern 'int grm_plot(const grm_args_t *args)'
72
72
  try_extern 'int grm_switch(unsigned int id)'
73
-
74
- # https://github.com/sciapp/gr/blob/master/lib/grm/util.h
75
- try_extern 'FILE *grm_get_stdout(void)'
76
73
  end
77
74
  end
data/lib/grm.rb CHANGED
@@ -27,7 +27,7 @@ module GRM
27
27
 
28
28
  # Platforms | path
29
29
  # Windows | bin/libGRM.dll
30
- # MacOSX | lib/libGRM.dylib (v0.53.0 .so)
30
+ # MacOSX | lib/libGRM.dylib ( <= v0.53.0 .so)
31
31
  # Ubuntu | lib/libGRM.so
32
32
  platform = RbConfig::CONFIG['host_os']
33
33
  lib_names, pkg_name = \
@@ -35,10 +35,14 @@ module GRM
35
35
  when /mswin|msys|mingw|cygwin|bccwin|wince|emc/
36
36
  [['libGRM.dll'], 'grm']
37
37
  when /darwin|mac os/
38
+ ENV['GKSwstype'] ||= 'gksqt'
38
39
  [['libGRM.dylib', 'libGRM.so'], 'grm']
39
40
  else
40
41
  [['libGRM.so'], 'grm']
41
42
  end
43
+
44
+ # On Windows + RubyInstaller,
45
+ # the environment variable GKS_FONTPATH will be set.
42
46
  lib_path = GRCommons::GRLib.search(lib_names, pkg_name)
43
47
 
44
48
  raise NotFoundError, "#{lib_names} not found" if lib_path.nil?
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-gr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.26
4
+ version: 0.64.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - kojix2
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-04-05 00:00:00.000000000 Z
11
+ date: 2022-03-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: histogram
14
+ name: fiddle
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
@@ -25,7 +25,7 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: numo-narray
28
+ name: histogram
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
@@ -39,7 +39,7 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: pkg-config
42
+ name: numo-narray
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
@@ -53,83 +53,13 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: bundler
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: pry
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '0'
83
- - !ruby/object:Gem::Dependency
84
- name: rake
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: 12.3.3
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: 12.3.3
97
- - !ruby/object:Gem::Dependency
98
- name: rubocop
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- version: '0'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- version: '0'
111
- - !ruby/object:Gem::Dependency
112
- name: simplecov
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - ">="
116
- - !ruby/object:Gem::Version
117
- version: '0'
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - ">="
123
- - !ruby/object:Gem::Version
124
- version: '0'
125
- - !ruby/object:Gem::Dependency
126
- name: test-unit
56
+ name: pkg-config
127
57
  requirement: !ruby/object:Gem::Requirement
128
58
  requirements:
129
59
  - - ">="
130
60
  - !ruby/object:Gem::Version
131
61
  version: '0'
132
- type: :development
62
+ type: :runtime
133
63
  prerelease: false
134
64
  version_requirements: !ruby/object:Gem::Requirement
135
65
  requirements:
@@ -147,7 +77,6 @@ files:
147
77
  - lib/gr.rb
148
78
  - lib/gr/ffi.rb
149
79
  - lib/gr/grbase.rb
150
- - lib/gr/plot.rb
151
80
  - lib/gr/version.rb
152
81
  - lib/gr3.rb
153
82
  - lib/gr3/ffi.rb
@@ -186,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
186
115
  - !ruby/object:Gem::Version
187
116
  version: '0'
188
117
  requirements: []
189
- rubygems_version: 3.2.3
118
+ rubygems_version: 3.3.7
190
119
  signing_key:
191
120
  specification_version: 4
192
121
  summary: GR for Ruby