gmt 0.1.4 → 0.1.5
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 +5 -5
- data/lib/gmt.rb +41 -29
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 84cd995c50a9a918aadf655f83b8be85f297f391f456cd4fe1833db79367bfb0
|
4
|
+
data.tar.gz: 7f88fb3453566749affca18d1ec2afe0242e5ff2b50edfd34795572213a798da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c4d22fae62200c0976471c93f5b9dadbfafe7368b14e6ef5b344d0f77267d74c28e6db459e20b4740991792ed3545267870767e9048a33802736844253b0d0ec
|
7
|
+
data.tar.gz: 2f59eea2cead5e5383ebf5ffcb828a4d1e6c3f5913b44682dfcd6c52a118f24d3f111da1af9ebf9eff5c7b36f5ed74f25ce7e11e4c1adf945a4e3a6487c466a2
|
data/lib/gmt.rb
CHANGED
@@ -56,7 +56,7 @@
|
|
56
56
|
#
|
57
57
|
# gmt = GMT.new
|
58
58
|
# gmt.makecpt('depths.txt',
|
59
|
-
# :
|
59
|
+
# C: 'gebco', i: 2, Z: nil, E: 24, :> => 'my_depths.cpt')
|
60
60
|
#
|
61
61
|
# Note that
|
62
62
|
# - the argument(s) (the input file <code>'depths.txt'</code>) preceed(s)
|
@@ -67,6 +67,15 @@
|
|
67
67
|
# - the output redirection is _also_ treated as hash option, with key
|
68
68
|
# <code>:></code> and value which is the output file.
|
69
69
|
#
|
70
|
+
# The options without argument can also be specifed by a symbol
|
71
|
+
# _argument_, but recall that arguments must proceed the options hash,
|
72
|
+
# so the above would be
|
73
|
+
#
|
74
|
+
# gmt.makecpt('depths.txt',
|
75
|
+
# :Z, C: 'gebco', i: 2, E: 24, :> => 'my_depths.cpt')
|
76
|
+
#
|
77
|
+
# using this format.
|
78
|
+
#
|
70
79
|
# == PostScript functions
|
71
80
|
#
|
72
81
|
# When creating complex PostScript plots one needs to make several calls to
|
@@ -82,10 +91,10 @@
|
|
82
91
|
# So one might write
|
83
92
|
#
|
84
93
|
# gmt = GMT.new
|
85
|
-
# gmt.psbasemap( …, :
|
86
|
-
# gmt.pstext( …, :
|
87
|
-
# gmt.psxy( …, :
|
88
|
-
# gmt.pslogo( …, :
|
94
|
+
# gmt.psbasemap( …, file: 'map.ps', position: :first)
|
95
|
+
# gmt.pstext( …, file: 'map.ps', position: :middle)
|
96
|
+
# gmt.psxy( …, file: 'map.ps', position: :middle)
|
97
|
+
# gmt.pslogo( …, file: 'map.ps', position: :last)
|
89
98
|
#
|
90
99
|
class GMT
|
91
100
|
|
@@ -135,11 +144,11 @@ class GMT
|
|
135
144
|
# @return [Boolean] +true+ on success
|
136
145
|
# @see http://gmt.soest.hawaii.edu/doc/latest/$1.html
|
137
146
|
def wrapper_ps(method)
|
138
|
-
define_method(method) do |*args, **
|
139
|
-
|
140
|
-
coerce_postscript_options!(
|
141
|
-
coerce_append_option!(
|
142
|
-
self.send(api_function(method), *args, options_as_pairs(
|
147
|
+
define_method(method) do |*args, **opts|
|
148
|
+
args, opts = nilargify(args, opts)
|
149
|
+
coerce_postscript_options!(opts)
|
150
|
+
coerce_append_option!(opts)
|
151
|
+
self.send(api_function(method), *args, options_as_pairs(opts))
|
143
152
|
end
|
144
153
|
end
|
145
154
|
|
@@ -150,10 +159,10 @@ class GMT
|
|
150
159
|
# @return [Boolean] +true+ on success
|
151
160
|
# @see http://gmt.soest.hawaii.edu/doc/latest/$1.html
|
152
161
|
def wrapper_other(method)
|
153
|
-
define_method(method) do |*args, **
|
154
|
-
|
155
|
-
coerce_append_option!(
|
156
|
-
self.send(api_function(method), *args, options_as_pairs(
|
162
|
+
define_method(method) do |*args, **opts|
|
163
|
+
args, opts = nilargify(args, opts)
|
164
|
+
coerce_append_option!(opts)
|
165
|
+
self.send(api_function(method), *args, options_as_pairs(opts))
|
157
166
|
end
|
158
167
|
end
|
159
168
|
|
@@ -176,10 +185,13 @@ class GMT
|
|
176
185
|
[method.to_s, 'c'].join('_').to_sym
|
177
186
|
end
|
178
187
|
|
179
|
-
# convert arguments to
|
188
|
+
# convert symbol arguments to nil-valued options, so
|
189
|
+
# nilargify(['a', :b], {c: 'd'}) -> [['a'], {b: nil, c: 'd'}]
|
180
190
|
|
181
|
-
def
|
182
|
-
|
191
|
+
def nilargify(args, opts)
|
192
|
+
syms, strs = args.partition { |x| x.is_a? Symbol }
|
193
|
+
syms.each { |sym| opts[sym] = nil }
|
194
|
+
[strs, opts]
|
183
195
|
end
|
184
196
|
|
185
197
|
# for GMT modules which produce PostScript, convert the
|
@@ -187,11 +199,11 @@ class GMT
|
|
187
199
|
# equivalent of the -K, -O options, and the creation of
|
188
200
|
# or appending to the PostScript output file
|
189
201
|
|
190
|
-
def coerce_postscript_options!(
|
191
|
-
file =
|
192
|
-
position =
|
202
|
+
def coerce_postscript_options!(opts)
|
203
|
+
file = opts.delete(:file)
|
204
|
+
position = opts.delete(:position)
|
193
205
|
if file && position then
|
194
|
-
|
206
|
+
file_opts =
|
195
207
|
case position
|
196
208
|
when :first, 'first'
|
197
209
|
{ :K => nil, :> => file }
|
@@ -202,28 +214,28 @@ class GMT
|
|
202
214
|
else
|
203
215
|
raise ArgumentError, 'position should be :first, :middle or :last'
|
204
216
|
end
|
205
|
-
|
217
|
+
opts.merge!(file_opts)
|
206
218
|
end
|
207
219
|
end
|
208
220
|
|
209
221
|
# handle the :>> option
|
210
222
|
|
211
|
-
def coerce_append_option!(
|
212
|
-
if file =
|
213
|
-
|
223
|
+
def coerce_append_option!(opts)
|
224
|
+
if file = opts.delete(:>>) then
|
225
|
+
opts[:>] = '>' + file
|
214
226
|
end
|
215
227
|
end
|
216
228
|
|
217
229
|
# convert non-nil argument to string
|
218
230
|
|
219
|
-
def string_unless_nil(
|
220
|
-
|
231
|
+
def string_unless_nil(arg)
|
232
|
+
arg.to_s unless arg.nil?
|
221
233
|
end
|
222
234
|
|
223
235
|
# convert the options hash to an array of pairs
|
224
236
|
|
225
|
-
def options_as_pairs(
|
226
|
-
|
237
|
+
def options_as_pairs(opts)
|
238
|
+
opts.each_with_object(Array.new) do |(key, values), result|
|
227
239
|
if values.respond_to? :each then
|
228
240
|
values.each do |value|
|
229
241
|
result << [key, string_unless_nil(value)]
|
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.
|
4
|
+
version: 0.1.5
|
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: 2018-
|
11
|
+
date: 2018-08-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: 0.2.4
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rake-compiler
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '1'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '1'
|
83
97
|
description: |
|
84
98
|
A Ruby extension for the Generic Mapping Tools (GMT5)
|
85
99
|
cartographic toolset.
|
@@ -118,7 +132,7 @@ requirements:
|
|
118
132
|
- GMT5 installation (test)
|
119
133
|
- ghostscript (test)
|
120
134
|
rubyforge_project:
|
121
|
-
rubygems_version: 2.
|
135
|
+
rubygems_version: 2.7.6
|
122
136
|
signing_key:
|
123
137
|
specification_version: 4
|
124
138
|
summary: Generic Mapping Tools (GMT)
|