ruby-jss 0.6.3
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of ruby-jss might be problematic. Click here for more details.
- checksums.yaml +7 -0
- data/.yardopts +7 -0
- data/CHANGES.md +112 -0
- data/LICENSE.txt +174 -0
- data/README.md +426 -0
- data/THANKS.md +6 -0
- data/bin/cgrouper +485 -0
- data/bin/subnet-update +400 -0
- data/lib/jss-api.rb +2 -0
- data/lib/jss.rb +190 -0
- data/lib/jss/api_connection.rb +410 -0
- data/lib/jss/api_object.rb +616 -0
- data/lib/jss/api_object/advanced_search.rb +389 -0
- data/lib/jss/api_object/advanced_search/advanced_computer_search.rb +95 -0
- data/lib/jss/api_object/advanced_search/advanced_mobile_device_search.rb +96 -0
- data/lib/jss/api_object/advanced_search/advanced_user_search.rb +95 -0
- data/lib/jss/api_object/building.rb +92 -0
- data/lib/jss/api_object/category.rb +147 -0
- data/lib/jss/api_object/computer.rb +852 -0
- data/lib/jss/api_object/creatable.rb +98 -0
- data/lib/jss/api_object/criteriable.rb +189 -0
- data/lib/jss/api_object/criteriable/criteria.rb +231 -0
- data/lib/jss/api_object/criteriable/criterion.rb +228 -0
- data/lib/jss/api_object/department.rb +93 -0
- data/lib/jss/api_object/distribution_point.rb +560 -0
- data/lib/jss/api_object/extendable.rb +221 -0
- data/lib/jss/api_object/extension_attribute.rb +466 -0
- data/lib/jss/api_object/extension_attribute/computer_extension_attribute.rb +362 -0
- data/lib/jss/api_object/extension_attribute/mobile_device_extension_attribute.rb +189 -0
- data/lib/jss/api_object/extension_attribute/user_extension_attribute.rb +117 -0
- data/lib/jss/api_object/group.rb +380 -0
- data/lib/jss/api_object/group/computer_group.rb +124 -0
- data/lib/jss/api_object/group/mobile_device_group.rb +139 -0
- data/lib/jss/api_object/group/user_group.rb +139 -0
- data/lib/jss/api_object/ldap_server.rb +535 -0
- data/lib/jss/api_object/locatable.rb +286 -0
- data/lib/jss/api_object/matchable.rb +97 -0
- data/lib/jss/api_object/mobile_device.rb +556 -0
- data/lib/jss/api_object/netboot_server.rb +148 -0
- data/lib/jss/api_object/network_segment.rb +414 -0
- data/lib/jss/api_object/osx_configuration_profile.rb +262 -0
- data/lib/jss/api_object/package.rb +839 -0
- data/lib/jss/api_object/peripheral.rb +335 -0
- data/lib/jss/api_object/peripheral_type.rb +295 -0
- data/lib/jss/api_object/policy.rb +898 -0
- data/lib/jss/api_object/purchasable.rb +316 -0
- data/lib/jss/api_object/removable_macaddr.rb +98 -0
- data/lib/jss/api_object/scopable.rb +136 -0
- data/lib/jss/api_object/scopable/scope.rb +621 -0
- data/lib/jss/api_object/script.rb +631 -0
- data/lib/jss/api_object/self_servable.rb +356 -0
- data/lib/jss/api_object/site.rb +93 -0
- data/lib/jss/api_object/software_update_server.rb +109 -0
- data/lib/jss/api_object/updatable.rb +117 -0
- data/lib/jss/api_object/uploadable.rb +138 -0
- data/lib/jss/api_object/user.rb +272 -0
- data/lib/jss/client.rb +504 -0
- data/lib/jss/compatibility.rb +66 -0
- data/lib/jss/composer.rb +185 -0
- data/lib/jss/configuration.rb +306 -0
- data/lib/jss/db_connection.rb +298 -0
- data/lib/jss/exceptions.rb +95 -0
- data/lib/jss/ruby_extensions.rb +35 -0
- data/lib/jss/ruby_extensions/filetest.rb +43 -0
- data/lib/jss/ruby_extensions/hash.rb +79 -0
- data/lib/jss/ruby_extensions/ipaddr.rb +91 -0
- data/lib/jss/ruby_extensions/pathname.rb +77 -0
- data/lib/jss/ruby_extensions/string.rb +59 -0
- data/lib/jss/ruby_extensions/time.rb +63 -0
- data/lib/jss/server.rb +108 -0
- data/lib/jss/utility.rb +478 -0
- data/lib/jss/version.rb +31 -0
- metadata +187 -0
@@ -0,0 +1,298 @@
|
|
1
|
+
### Copyright 2016 Pixar
|
2
|
+
###
|
3
|
+
### Licensed under the Apache License, Version 2.0 (the "Apache License")
|
4
|
+
### with the following modification; you may not use this file except in
|
5
|
+
### compliance with the Apache License and the following modification to it:
|
6
|
+
### Section 6. Trademarks. is deleted and replaced with:
|
7
|
+
###
|
8
|
+
### 6. Trademarks. This License does not grant permission to use the trade
|
9
|
+
### names, trademarks, service marks, or product names of the Licensor
|
10
|
+
### and its affiliates, except as required to comply with Section 4(c) of
|
11
|
+
### the License and to reproduce the content of the NOTICE file.
|
12
|
+
###
|
13
|
+
### You may obtain a copy of the Apache License at
|
14
|
+
###
|
15
|
+
### http://www.apache.org/licenses/LICENSE-2.0
|
16
|
+
###
|
17
|
+
### Unless required by applicable law or agreed to in writing, software
|
18
|
+
### distributed under the Apache License with the above modification is
|
19
|
+
### distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
20
|
+
### KIND, either express or implied. See the Apache License for the specific
|
21
|
+
### language governing permissions and limitations under the Apache License.
|
22
|
+
###
|
23
|
+
###
|
24
|
+
|
25
|
+
###
|
26
|
+
module JSS
|
27
|
+
|
28
|
+
|
29
|
+
|
30
|
+
#####################################
|
31
|
+
### Module Variables
|
32
|
+
#####################################
|
33
|
+
|
34
|
+
#####################################
|
35
|
+
### Classes
|
36
|
+
#####################################
|
37
|
+
|
38
|
+
###
|
39
|
+
### A mysql connection to the JSS database.
|
40
|
+
###
|
41
|
+
### This is a singleton class, only one can exist at a time, and it
|
42
|
+
### is created, but not connected, automatically when the module loads.
|
43
|
+
###
|
44
|
+
### Use it via the JSS::DB_CNX constant (for connection metadata)
|
45
|
+
### and the JSS::DB_CNX.db attribute (which contains the actual mysql
|
46
|
+
### query interface) for making queries
|
47
|
+
###
|
48
|
+
### Direct MySQL access is minimal and discouraged, since it
|
49
|
+
### bypasses the API, and can be very dangerous. However, it's necessary
|
50
|
+
### to overcome some limitations of the API or to access custom tables.
|
51
|
+
###
|
52
|
+
### While a database connction isn't required for most things,
|
53
|
+
### warnings will be sent to stderr when functionality is limited due to
|
54
|
+
### a lack of a database connection i.e. when JSS::DB_CNX.connected? == false
|
55
|
+
###
|
56
|
+
### To make a connection with credentials, just call the #connect method thus:
|
57
|
+
### JSS::DB_CNX.connect :server => 'server.company.com', :user => "user", :pw => "pw"
|
58
|
+
###
|
59
|
+
### Other options include:
|
60
|
+
### :db_name => which database to connect to, defaults to 'jamfsoftware'
|
61
|
+
### :port => tcp port for connection to server, defaults to the standard mysql port.
|
62
|
+
### :connect_timeout => seconds to wait before giving up on connection, defaults to 120
|
63
|
+
### :read_timeout => seconds to wait before giving up on recieving data, defaults to 120
|
64
|
+
### :write_timeout => seconds to wait before giving up on sending data, defaults to 120
|
65
|
+
### :timeout => sets all three timeouts to the same value, defaults to 120
|
66
|
+
###
|
67
|
+
### Calling JSS::DB_CNX.connect again will re-use any values not provided.
|
68
|
+
### but will create a new connection.
|
69
|
+
###
|
70
|
+
class DBConnection
|
71
|
+
|
72
|
+
include Singleton
|
73
|
+
|
74
|
+
#####################################
|
75
|
+
### Class Constants
|
76
|
+
#####################################
|
77
|
+
|
78
|
+
### The name of the JSS database on the mysql server
|
79
|
+
DEFAULT_DB_NAME = "jamfsoftware"
|
80
|
+
|
81
|
+
### give the connection a 120 second timeout, for really slow
|
82
|
+
### net connections (like... from airplanes)
|
83
|
+
DFT_TIMEOUT = 120
|
84
|
+
|
85
|
+
###
|
86
|
+
DFT_SOCKET = '/var/mysql/mysql.sock'
|
87
|
+
|
88
|
+
### the default MySQL port
|
89
|
+
DFT_PORT = 3306
|
90
|
+
|
91
|
+
### the strftime format for reading/writing dates in the db
|
92
|
+
SQL_DATE_FORMAT = "%Y-%m-%d %H:%M:%S"
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
attr_reader :server
|
97
|
+
attr_reader :port
|
98
|
+
attr_reader :socket
|
99
|
+
attr_reader :user
|
100
|
+
attr_reader :db_name
|
101
|
+
attr_reader :connect_timeout
|
102
|
+
attr_reader :read_timeout
|
103
|
+
attr_reader :write_timeout
|
104
|
+
attr_reader :connected
|
105
|
+
|
106
|
+
|
107
|
+
def initialize ()
|
108
|
+
require 'mysql'
|
109
|
+
@mysql = Mysql.init
|
110
|
+
@connected = false
|
111
|
+
end #init
|
112
|
+
|
113
|
+
###
|
114
|
+
### Connect to the JSS MySQL database.
|
115
|
+
###
|
116
|
+
### @param args[Hash] the keyed arguments for connection.
|
117
|
+
###
|
118
|
+
### @option args :server[String] Required, the hostname of the JSS API server
|
119
|
+
###
|
120
|
+
### @option args :port[Integer] the port number to connect with, defaults to the default Mysql TCP port
|
121
|
+
###
|
122
|
+
### @option args :socket[String,Pathname] when the server is 'localhost', the path to the connection socket.
|
123
|
+
###
|
124
|
+
### @option args :db_name[String] the name of the database to use, defaults to 'jamfsoftware'
|
125
|
+
###
|
126
|
+
### @option args :user[String] Required, the mysql user to connect as
|
127
|
+
###
|
128
|
+
### @option args :pw[String,Symbol] Required, the password for that user, or :prompt, or :stdin
|
129
|
+
### If :prompt, the user is promted on the commandline to enter the password for the :user.
|
130
|
+
### If :stdin#, the password is read from a line of std in represented by the digit at #,
|
131
|
+
### so :stdin3 reads the passwd from the third line of standard input. defaults to line 2,
|
132
|
+
### if no digit is supplied. see {JSS.stdin}
|
133
|
+
###
|
134
|
+
### @option args :connect_timeout[Integer] the number of seconds to wait for an initial response, defaults to 120
|
135
|
+
###
|
136
|
+
### @option args :read_timeout[Integer] the number of seconds before read-request times out, defaults to 120
|
137
|
+
###
|
138
|
+
### @option args :write_timeout[Integer] the number of seconds before write-request times out, defaults to 120
|
139
|
+
###
|
140
|
+
### @option args :timeout[Integer] used for any of the timeouts that aren't explicitly set.
|
141
|
+
###
|
142
|
+
### @return [true] the connection was successfully made.
|
143
|
+
###
|
144
|
+
def connect(args = {})
|
145
|
+
|
146
|
+
# server might come frome several places
|
147
|
+
# if not given in the args, use #hostname to figure out
|
148
|
+
# which
|
149
|
+
@server = args[:server] ? args[:server] : hostname
|
150
|
+
|
151
|
+
# settings from config if they aren't in the args
|
152
|
+
args[:port] ||= JSS::CONFIG.db_server_port
|
153
|
+
args[:socket] ||= JSS::CONFIG.db_server_socket
|
154
|
+
args[:db_name] ||= JSS::CONFIG.db_name
|
155
|
+
args[:user] ||= JSS::CONFIG.db_username
|
156
|
+
args[:connect_timeout] ||= JSS::CONFIG.db_connect_timeout
|
157
|
+
args[:read_timeout] ||= JSS::CONFIG.db_read_timeout
|
158
|
+
args[:write_timeout] ||= JSS::CONFIG.db_write_timeout
|
159
|
+
|
160
|
+
### if one timeout was given, use it for all three
|
161
|
+
args[:connect_timeout] ||= args[:timeout]
|
162
|
+
args[:read_timeout] ||= args[:timeout]
|
163
|
+
args[:write_timeout] ||= args[:timeout]
|
164
|
+
|
165
|
+
### if these weren't given, use the defaults
|
166
|
+
args[:connect_timeout] ||= DFT_TIMEOUT
|
167
|
+
args[:read_timeout] ||= DFT_TIMEOUT
|
168
|
+
args[:write_timeout] ||= DFT_TIMEOUT
|
169
|
+
args[:port] ||= Mysql::MYSQL_TCP_PORT
|
170
|
+
args[:socket] ||= DFT_SOCKET
|
171
|
+
args[:db_name] ||= DEFAULT_DB_NAME
|
172
|
+
|
173
|
+
begin
|
174
|
+
@mysql.close if connected?
|
175
|
+
rescue Mysql::ClientError::ServerGoneError
|
176
|
+
@connected = false
|
177
|
+
end
|
178
|
+
|
179
|
+
@port = args[:port]
|
180
|
+
@socket = args[:socket]
|
181
|
+
@mysql_name = args[:db_name]
|
182
|
+
@user = args[:user]
|
183
|
+
@connect_timeout = args[:connect_timeout]
|
184
|
+
@read_timeout = args[:read_timeout]
|
185
|
+
@write_timeout = args[:write_timeout]
|
186
|
+
|
187
|
+
# make sure we have a user, pw, server
|
188
|
+
raise JSS::MissingDataError, "No MySQL user specified, or listed in configuration." unless args[:user]
|
189
|
+
raise JSS::MissingDataError, "Missing :pw (or :prompt/:stdin) for user '#{@user}'" unless args[:pw]
|
190
|
+
raise JSS::MissingDataError, "No MySQL Server hostname specified, or listed in configuration." unless @server
|
191
|
+
|
192
|
+
@pw = if args[:pw] == :prompt
|
193
|
+
JSS.prompt_for_password "Enter the password for the MySQL user #{@user}@#{@server}:"
|
194
|
+
elsif args[:pw].is_a?(Symbol) and args[:pw].to_s.start_with?('stdin')
|
195
|
+
args[:pw].to_s =~ /^stdin(\d+)$/
|
196
|
+
line = $1
|
197
|
+
line ||= 2
|
198
|
+
JSS.stdin line
|
199
|
+
else
|
200
|
+
args[:pw]
|
201
|
+
end
|
202
|
+
|
203
|
+
@mysql = Mysql.init
|
204
|
+
|
205
|
+
@mysql.options Mysql::OPT_CONNECT_TIMEOUT, @connect_timeout
|
206
|
+
@mysql.options Mysql::OPT_READ_TIMEOUT, @read_timeout
|
207
|
+
@mysql.options Mysql::OPT_WRITE_TIMEOUT, @write_timeout
|
208
|
+
|
209
|
+
@mysql.connect @server, @user , @pw , @mysql_name, @port, @socket
|
210
|
+
|
211
|
+
@connected = true
|
212
|
+
end # reconnect
|
213
|
+
|
214
|
+
###
|
215
|
+
### @return [Mysql] The mysql database connection itself
|
216
|
+
###
|
217
|
+
def db
|
218
|
+
raise JSS::InvalidConnectionError, "No database connection. Please use JSS::DB_CNX.connect" unless JSS::DB_CNX.connected?
|
219
|
+
@mysql
|
220
|
+
end
|
221
|
+
|
222
|
+
###
|
223
|
+
### close the connection to the database
|
224
|
+
### it'll have to be re-connected before using again
|
225
|
+
###
|
226
|
+
def disconnect
|
227
|
+
@mysql.close if connected?
|
228
|
+
@server = nil
|
229
|
+
@port = nil
|
230
|
+
@socket = nil
|
231
|
+
@user = nil
|
232
|
+
@connection_timeout = DFT_TIMEOUT
|
233
|
+
@read_timeout = DFT_TIMEOUT
|
234
|
+
@write_timeout = DFT_TIMEOUT
|
235
|
+
@connected = false
|
236
|
+
nil
|
237
|
+
end # disconnect
|
238
|
+
|
239
|
+
### Test that a given hostname is a MySQL server
|
240
|
+
###
|
241
|
+
### @param server[String] The hostname to test
|
242
|
+
###
|
243
|
+
### @return [Boolean] does the server host a MySQL server?
|
244
|
+
###
|
245
|
+
def valid_server? (server, port = DFT_PORT)
|
246
|
+
mysql = Mysql.init
|
247
|
+
mysql.options Mysql::OPT_CONNECT_TIMEOUT, 5
|
248
|
+
|
249
|
+
begin
|
250
|
+
# this connection should get an access denied error if there is
|
251
|
+
# a mysql server there. I'm assuming no one will use this username
|
252
|
+
# and pw for anything real
|
253
|
+
mysql.connect server, "notArealUser", "definatelyNotA#{$$}password", "not_a_db", port
|
254
|
+
|
255
|
+
rescue Mysql::ServerError::AccessDeniedError
|
256
|
+
return true
|
257
|
+
rescue
|
258
|
+
return false
|
259
|
+
end
|
260
|
+
return false
|
261
|
+
end
|
262
|
+
|
263
|
+
### The server to which we are connected, or will
|
264
|
+
### try connecting to if none is specified with the
|
265
|
+
### call to #connect
|
266
|
+
###
|
267
|
+
### @return [String] the hostname of the server
|
268
|
+
###
|
269
|
+
def hostname
|
270
|
+
# return it if already set
|
271
|
+
return @server if @server
|
272
|
+
# otherwise, from the config
|
273
|
+
srvr = JSS::CONFIG.db_server_name
|
274
|
+
# otherwise, assume its on the JSS server to which this client talks
|
275
|
+
srvr ||= JSS::Client.jss_server
|
276
|
+
return srvr
|
277
|
+
end
|
278
|
+
|
279
|
+
|
280
|
+
#### Aliases
|
281
|
+
|
282
|
+
alias connected? connected
|
283
|
+
|
284
|
+
end # class DBConnection
|
285
|
+
|
286
|
+
### The single instance of the DBConnection
|
287
|
+
DB_CNX = DBConnection.instance
|
288
|
+
|
289
|
+
###
|
290
|
+
### @return [Mysql] The mysql database available through the DBConnection.instance
|
291
|
+
###
|
292
|
+
def self.db
|
293
|
+
DB_CNX.db
|
294
|
+
end
|
295
|
+
|
296
|
+
end # module
|
297
|
+
|
298
|
+
|
@@ -0,0 +1,95 @@
|
|
1
|
+
### Copyright 2016 Pixar
|
2
|
+
###
|
3
|
+
### Licensed under the Apache License, Version 2.0 (the "Apache License")
|
4
|
+
### with the following modification; you may not use this file except in
|
5
|
+
### compliance with the Apache License and the following modification to it:
|
6
|
+
### Section 6. Trademarks. is deleted and replaced with:
|
7
|
+
###
|
8
|
+
### 6. Trademarks. This License does not grant permission to use the trade
|
9
|
+
### names, trademarks, service marks, or product names of the Licensor
|
10
|
+
### and its affiliates, except as required to comply with Section 4(c) of
|
11
|
+
### the License and to reproduce the content of the NOTICE file.
|
12
|
+
###
|
13
|
+
### You may obtain a copy of the Apache License at
|
14
|
+
###
|
15
|
+
### http://www.apache.org/licenses/LICENSE-2.0
|
16
|
+
###
|
17
|
+
### Unless required by applicable law or agreed to in writing, software
|
18
|
+
### distributed under the Apache License with the above modification is
|
19
|
+
### distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
20
|
+
### KIND, either express or implied. See the Apache License for the specific
|
21
|
+
### language governing permissions and limitations under the Apache License.
|
22
|
+
###
|
23
|
+
###
|
24
|
+
|
25
|
+
###
|
26
|
+
module JSS
|
27
|
+
|
28
|
+
#####################################
|
29
|
+
### Exceptions
|
30
|
+
#####################################
|
31
|
+
|
32
|
+
###
|
33
|
+
### MissingDataError - raise this error when we
|
34
|
+
### are missing args, or other simliar stuff.
|
35
|
+
###
|
36
|
+
class MissingDataError < RuntimeError; end
|
37
|
+
|
38
|
+
###
|
39
|
+
### InvalidDataError - raise this error when
|
40
|
+
### a data item isn't what we expected.
|
41
|
+
###
|
42
|
+
class InvalidDataError < RuntimeError; end
|
43
|
+
|
44
|
+
###
|
45
|
+
### InvalidConnectionError - raise this error when we
|
46
|
+
### don't have a usable connection to a network service, or
|
47
|
+
### don't have proper authentication/authorization.
|
48
|
+
###
|
49
|
+
class InvalidConnectionError < RuntimeError; end
|
50
|
+
|
51
|
+
###
|
52
|
+
### NoSuchItemError - raise this error when
|
53
|
+
### a desired item doesn't exist.
|
54
|
+
###
|
55
|
+
class NoSuchItemError < RuntimeError; end
|
56
|
+
|
57
|
+
###
|
58
|
+
### AlreadyExistsError - raise this error when
|
59
|
+
### trying to create something that already exists.
|
60
|
+
###
|
61
|
+
class AlreadyExistsError < RuntimeError; end
|
62
|
+
|
63
|
+
###
|
64
|
+
### FileServiceError - raise this error when
|
65
|
+
### there's a problem accessing file service on a
|
66
|
+
### distribution point.
|
67
|
+
###
|
68
|
+
class FileServiceError < RuntimeError; end
|
69
|
+
|
70
|
+
###
|
71
|
+
### UnmanagedError - raise this when we
|
72
|
+
### try to do something managerial to
|
73
|
+
### an unmanaged object
|
74
|
+
###
|
75
|
+
class UnmanagedError < RuntimeError; end
|
76
|
+
|
77
|
+
###
|
78
|
+
### UnsupportedError - raise this when we
|
79
|
+
### try to do something not yet supported
|
80
|
+
###
|
81
|
+
class UnsupportedError < RuntimeError; end
|
82
|
+
|
83
|
+
###
|
84
|
+
### TimeoutError - raise this when we
|
85
|
+
### try to do and it times out
|
86
|
+
###
|
87
|
+
class TimeoutError < RuntimeError; end
|
88
|
+
|
89
|
+
###
|
90
|
+
### AuthenticationError - raise this when
|
91
|
+
### a name/pw are wrong
|
92
|
+
###
|
93
|
+
class AuthenticationError < RuntimeError; end
|
94
|
+
|
95
|
+
end # module JSS
|
@@ -0,0 +1,35 @@
|
|
1
|
+
### Copyright 2016 Pixar
|
2
|
+
###
|
3
|
+
### Licensed under the Apache License, Version 2.0 (the "Apache License")
|
4
|
+
### with the following modification; you may not use this file except in
|
5
|
+
### compliance with the Apache License and the following modification to it:
|
6
|
+
### Section 6. Trademarks. is deleted and replaced with:
|
7
|
+
###
|
8
|
+
### 6. Trademarks. This License does not grant permission to use the trade
|
9
|
+
### names, trademarks, service marks, or product names of the Licensor
|
10
|
+
### and its affiliates, except as required to comply with Section 4(c) of
|
11
|
+
### the License and to reproduce the content of the NOTICE file.
|
12
|
+
###
|
13
|
+
### You may obtain a copy of the Apache License at
|
14
|
+
###
|
15
|
+
### http://www.apache.org/licenses/LICENSE-2.0
|
16
|
+
###
|
17
|
+
### Unless required by applicable law or agreed to in writing, software
|
18
|
+
### distributed under the Apache License with the above modification is
|
19
|
+
### distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
20
|
+
### KIND, either express or implied. See the Apache License for the specific
|
21
|
+
### language governing permissions and limitations under the Apache License.
|
22
|
+
###
|
23
|
+
###
|
24
|
+
|
25
|
+
### All monkey-patched convenience methods are either prefixed with "jss_" or
|
26
|
+
### if they are type coercions, "to_jss_"
|
27
|
+
###
|
28
|
+
|
29
|
+
###
|
30
|
+
require "jss/ruby_extensions/filetest.rb"
|
31
|
+
require "jss/ruby_extensions/hash.rb"
|
32
|
+
require "jss/ruby_extensions/ipaddr.rb"
|
33
|
+
require "jss/ruby_extensions/pathname.rb"
|
34
|
+
require "jss/ruby_extensions/time.rb"
|
35
|
+
require "jss/ruby_extensions/string.rb"
|
@@ -0,0 +1,43 @@
|
|
1
|
+
### Copyright 2016 Pixar
|
2
|
+
###
|
3
|
+
### Licensed under the Apache License, Version 2.0 (the "Apache License")
|
4
|
+
### with the following modification; you may not use this file except in
|
5
|
+
### compliance with the Apache License and the following modification to it:
|
6
|
+
### Section 6. Trademarks. is deleted and replaced with:
|
7
|
+
###
|
8
|
+
### 6. Trademarks. This License does not grant permission to use the trade
|
9
|
+
### names, trademarks, service marks, or product names of the Licensor
|
10
|
+
### and its affiliates, except as required to comply with Section 4(c) of
|
11
|
+
### the License and to reproduce the content of the NOTICE file.
|
12
|
+
###
|
13
|
+
### You may obtain a copy of the Apache License at
|
14
|
+
###
|
15
|
+
### http://www.apache.org/licenses/LICENSE-2.0
|
16
|
+
###
|
17
|
+
### Unless required by applicable law or agreed to in writing, software
|
18
|
+
### distributed under the Apache License with the above modification is
|
19
|
+
### distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
20
|
+
### KIND, either express or implied. See the Apache License for the specific
|
21
|
+
### language governing permissions and limitations under the Apache License.
|
22
|
+
###
|
23
|
+
###
|
24
|
+
|
25
|
+
###
|
26
|
+
module FileTest
|
27
|
+
#############################################
|
28
|
+
### FileTest.file? returns true if
|
29
|
+
### the item is a symlink pointing to a regular file.
|
30
|
+
###
|
31
|
+
### This test, real_file?, returns true if the item is
|
32
|
+
### a regular file but NOT a symlink.
|
33
|
+
###
|
34
|
+
def FileTest.jss_real_file?(path)
|
35
|
+
FileTest.file?(path) and not FileTest.symlink?(path)
|
36
|
+
end # real_file?
|
37
|
+
end # module FileTest
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
|