gmt 0.1.1 → 0.1.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9c457c3b27d88eb6ecebfe6b4099964280c56034
4
- data.tar.gz: 46117cbd3d877e969dc3c5b0ac81fffbb119c3b6
3
+ metadata.gz: 116cb71a63ceee278a6cd534b47283c5d90a49d2
4
+ data.tar.gz: 793f1e3ec6e3f1fbfdf1278fbf373bdb4627a67a
5
5
  SHA512:
6
- metadata.gz: 9db2d2eb4e8c28b4437030383e11f7a117b4a0405a17afe0fc631829479ec7ba6580d2e3b292b020ba39589e4b8f123e47f0b6a10ce53fcadd9e0de4b0c4fa7e
7
- data.tar.gz: b1139fd50414084518919b2504fec7a39a3d0b0f39a07d0da43434f888c581e1e16a3aaffeb9dbe37577e0b38b6e2e439c05f6165706ce2782c1870818c36071
6
+ metadata.gz: 3ddc705150d74f92d57f92424a5ab70b323f1be9fd58f8b637b8b3d5935f596081ca531d40e795015d1e474803bc59ed30efe8459667bc8d6c78877f5c22a1fc
7
+ data.tar.gz: d1c2536387dfc8f7a76624cc6d3b1f041922a0de3e412815acdb6ae2af795b17494e0a51b60e0db005a7a8afc9cfba4727d24d7942f94e07b6ecc9a1eec2790a
@@ -23,17 +23,33 @@ LIB_DIRS = [
23
23
  dir_config('gmt', HEADER_DIRS, LIB_DIRS)
24
24
 
25
25
  abort 'missing gmt.h' unless find_header('gmt.h')
26
+ abort 'missing gmt_version.h' unless find_header('gmt_version.h')
26
27
 
27
- SYM =
28
+ FUNCS =
28
29
  [
29
30
  'GMT_Create_Session',
30
31
  'GMT_Destroy_Session',
31
32
  ]
32
33
 
33
- abort "libgmt is missing" unless find_library('gmt', SYM.first)
34
+ abort "libgmt is missing" unless find_library('gmt', FUNCS.first)
34
35
 
35
- SYM.each do |func|
36
+ FUNCS.each do |func|
36
37
  abort "missing #{func}()" unless have_func(func)
37
38
  end
38
39
 
40
+ MACROS =
41
+ [
42
+ 'GMT_MAJOR_VERSION',
43
+ 'GMT_MINOR_VERSION',
44
+ 'GMT_RELEASE_VERSION'
45
+ ]
46
+
47
+ MACROS.each do |macro|
48
+ abort "missing #{macro}" unless have_macro(macro, 'gmt_version.h')
49
+ end
50
+
51
+ # remove a C90 specific warning
52
+
53
+ CONFIG['warnflags'].slice!(/ -Wdeclaration-after-statement/)
54
+
39
55
  create_makefile 'gmt/gmt'
@@ -1,8 +1,13 @@
1
1
  #include <ruby.h>
2
2
  #include <gmt.h>
3
+ #include <gmt_version.h>
3
4
 
4
5
  #include "option.h"
5
6
 
7
+ #define API_VER(major, minor, release) (10000 * major + 100 * minor + release)
8
+ #define GMT_API_VER API_VER(GMT_MAJOR_VERSION, GMT_MINOR_VERSION, GMT_RELEASE_VERSION)
9
+ #define API_AT_LEAST(major, minor, release) (GMT_API_VER >= API_VER(major, minor, release))
10
+
6
11
  typedef struct
7
12
  {
8
13
  void *session;
@@ -139,6 +144,14 @@ GMT_FUN(pswiggle)
139
144
  GMT_FUN(psxy)
140
145
  GMT_FUN(psxyz)
141
146
 
147
+ #if API_AT_LEAST(5, 3, 0)
148
+ GMT_FUN(pssolar)
149
+ #endif
150
+
151
+ #if API_AT_LEAST(5, 4, 0)
152
+ GMT_FUN(psternary)
153
+ #endif
154
+
142
155
  /* Gridding of Data Tables */
143
156
 
144
157
  GMT_FUN(greenspline)
@@ -261,6 +274,14 @@ void Init_gmt(void)
261
274
  RB_DPM(psxy);
262
275
  RB_DPM(psxyz);
263
276
 
277
+ #if API_AT_LEAST(5, 3, 0)
278
+ RB_DPM(pssolar);
279
+ #endif
280
+
281
+ #if API_AT_LEAST(5, 4, 0)
282
+ RB_DPM(psternary);
283
+ #endif
284
+
264
285
  /* Gridding of Data Tables */
265
286
 
266
287
  RB_DPM(greenspline);
@@ -340,6 +361,12 @@ void Init_gmt(void)
340
361
  RB_DPM(gmt2kml);
341
362
  RB_DPM(kml2gmt);
342
363
  RB_DPM(psconvert);
364
+
365
+ /* version constants */
366
+
367
+ rb_define_const(cGMT, "VERSION_MAJOR", INT2NUM(GMT_MAJOR_VERSION));
368
+ rb_define_const(cGMT, "VERSION_MINOR", INT2NUM(GMT_MINOR_VERSION));
369
+ rb_define_const(cGMT, "VERSION_RELEASE", INT2NUM(GMT_RELEASE_VERSION));
343
370
  }
344
371
 
345
372
  #undef RB_DPM
@@ -39,7 +39,7 @@ extern gmt_option_t* ruby_array_to_gmt_options(VALUE opts, void *session)
39
39
 
40
40
  gmt_option_t *gmt_opts = NULL;
41
41
 
42
- for (size_t i = 0 ; i < RARRAY_LEN(opts) ; i++)
42
+ for (size_t i = 0 ; i < (size_t)RARRAY_LEN(opts) ; i++)
43
43
  {
44
44
  VALUE opt = RARRAY_PTR(opts)[i];
45
45
 
@@ -81,7 +81,7 @@ extern gmt_option_t* append_inputs_to_gmt_options(VALUE files,
81
81
  if (TYPE(files) != T_ARRAY)
82
82
  rb_raise(rb_eArgError, "inputs should be an array");
83
83
 
84
- for (size_t i = 0 ; i < RARRAY_LEN(files) ; i++)
84
+ for (size_t i = 0 ; i < (size_t)RARRAY_LEN(files) ; i++)
85
85
  {
86
86
  VALUE file = RARRAY_PTR(files)[i];
87
87
 
data/lib/gmt.rb CHANGED
@@ -47,7 +47,7 @@
47
47
  #
48
48
  # Each GMT function is available as instance method, and each has the same
49
49
  # signatures: several _arguments_, typically input files, followed by a
50
- # single options hash. The options has corresponds to the command-line
50
+ # single options hash. The options hash corresponds to the command-line
51
51
  # options of the GMT program; hence the shell command
52
52
  #
53
53
  # gmt makecpt -Cgebco depths.txt -i2 -Z -E24 > my_depths.cpt
@@ -91,8 +91,41 @@ class GMT
91
91
 
92
92
  class << self
93
93
 
94
+ # @param [Integer] major The major version
95
+ # @param [Integer] minor The minor version
96
+ # @param [Integer] release The release version
97
+ # @return [Boolean] +true+ if the current API version is at least as requested
98
+ #
99
+ # @example If the current API version if 5.3.2, then
100
+ # GMT.version_at_least?(5) #=> true
101
+ # GMT.version_at_least?(5, 3, 1) #=> true
102
+ # GMT.version_at_least?(5, 3, 3) #=> false
103
+ def version_at_least?(major, minor=0, release=0)
104
+ if VERSION_MAJOR > major then
105
+ true
106
+ elsif VERSION_MAJOR < major then
107
+ false
108
+ else
109
+ version_at_least_minor?(minor, release)
110
+ end
111
+ end
112
+
94
113
  private
95
114
 
115
+ def version_at_least_minor?(minor, release)
116
+ if VERSION_MINOR > minor then
117
+ true
118
+ elsif VERSION_MINOR < minor then
119
+ false
120
+ else
121
+ version_at_least_release?(release)
122
+ end
123
+ end
124
+
125
+ def version_at_least_release?(release)
126
+ VERSION_RELEASE >= release
127
+ end
128
+
96
129
  # @macro [attach] wrapper_ps
97
130
  #
98
131
  # A PostScript function (accepts +:file+ and +:position+ options).
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gmt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - J.J. Green
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-22 00:00:00.000000000 Z
11
+ date: 2017-08-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0.9'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubygems-tasks
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '2.4'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '2.4'
69
83
  description: |
70
84
  A Ruby extension for the Generic Mapping Tools (GMT5)
71
85
  cartographic toolset.