ruby-jss 1.2.3 → 1.2.4a1
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 +4 -4
- data/lib/jamf.rb +169 -0
- data/lib/jamf/api/abstract_classes/collection_resource.rb +422 -0
- data/lib/jamf/api/abstract_classes/generic_reference.rb +145 -0
- data/lib/jamf/api/abstract_classes/json_object.rb +1074 -0
- data/lib/jamf/api/abstract_classes/prestage.rb +219 -0
- data/lib/jamf/api/abstract_classes/prestage_skip_setup_items.rb +126 -0
- data/lib/jamf/api/abstract_classes/resource.rb +250 -0
- data/lib/jamf/api/abstract_classes/singleton_resource.rb +87 -0
- data/lib/jamf/api/attribute_classes/ip_address.rb +66 -0
- data/lib/jamf/api/attribute_classes/timestamp.rb +144 -0
- data/lib/jamf/api/connection.rb +734 -0
- data/lib/jamf/api/connection/api_error.rb +111 -0
- data/lib/jamf/api/connection/api_error_styleguide.rb +96 -0
- data/lib/jamf/api/connection/token.rb +220 -0
- data/lib/jamf/api/json_objects/account_prefs.rb +79 -0
- data/lib/jamf/api/json_objects/android_details.rb +139 -0
- data/lib/jamf/api/json_objects/appletv_details.rb +110 -0
- data/lib/jamf/api/json_objects/attachment.rb +68 -0
- data/lib/jamf/api/json_objects/cellular_network.rb +151 -0
- data/lib/jamf/api/json_objects/change_log_entry.rb +77 -0
- data/lib/jamf/api/json_objects/computer_prestage_skip_setup_items.rb +67 -0
- data/lib/jamf/api/json_objects/country.rb +51 -0
- data/lib/jamf/api/json_objects/extension_attribute_value.rb +128 -0
- data/lib/jamf/api/json_objects/installed_application.rb +59 -0
- data/lib/jamf/api/json_objects/installed_certificate.rb +53 -0
- data/lib/jamf/api/json_objects/installed_configuration_profile.rb +67 -0
- data/lib/jamf/api/json_objects/installed_ebook.rb +58 -0
- data/lib/jamf/api/json_objects/installed_provisioning_profile.rb +59 -0
- data/lib/jamf/api/json_objects/inventory_preload_extension_attribute.rb +52 -0
- data/lib/jamf/api/json_objects/ios_details.rb +244 -0
- data/lib/jamf/api/json_objects/location.rb +95 -0
- data/lib/jamf/api/json_objects/md_prestage_name.rb +57 -0
- data/lib/jamf/api/json_objects/md_prestage_names.rb +82 -0
- data/lib/jamf/api/json_objects/md_prestage_skip_setup_items.rb +165 -0
- data/lib/jamf/api/json_objects/mobile_device_details.rb +219 -0
- data/lib/jamf/api/json_objects/mobile_device_security.rb +101 -0
- data/lib/jamf/api/json_objects/prestage_assignment.rb +61 -0
- data/lib/jamf/api/json_objects/prestage_location.rb +104 -0
- data/lib/jamf/api/json_objects/prestage_purchasing_data.rb +132 -0
- data/lib/jamf/api/json_objects/prestage_scope.rb +54 -0
- data/lib/jamf/api/json_objects/prestage_sync_status.rb +63 -0
- data/lib/jamf/api/json_objects/purchasing_data.rb +125 -0
- data/lib/jamf/api/mixins/abstract.rb +58 -0
- data/lib/jamf/api/mixins/bulk_deletable.rb +39 -0
- data/lib/jamf/api/mixins/change_log.rb +136 -0
- data/lib/jamf/api/mixins/extendable.rb +75 -0
- data/lib/jamf/api/mixins/immutable.rb +39 -0
- data/lib/jamf/api/mixins/locatable.rb +124 -0
- data/lib/jamf/api/mixins/lockable.rb +48 -0
- data/lib/jamf/api/mixins/referable.rb +92 -0
- data/lib/jamf/api/mixins/searchable.rb +202 -0
- data/lib/jamf/api/mixins/uncreatable.rb +40 -0
- data/lib/jamf/api/mixins/undeletable.rb +40 -0
- data/lib/jamf/api/resources/collection_resources/account.rb +163 -0
- data/lib/jamf/api/resources/collection_resources/building.rb +114 -0
- data/lib/jamf/api/resources/collection_resources/category.rb +82 -0
- data/lib/jamf/api/resources/collection_resources/computer.rb +49 -0
- data/lib/jamf/api/resources/collection_resources/computer_prestage.rb +80 -0
- data/lib/jamf/api/resources/collection_resources/department.rb +79 -0
- data/lib/jamf/api/resources/collection_resources/extension_attribute.rb +45 -0
- data/lib/jamf/api/resources/collection_resources/inventory_preload_record.rb +274 -0
- data/lib/jamf/api/resources/collection_resources/md_prestage.rb +139 -0
- data/lib/jamf/api/resources/collection_resources/mobile_device.rb +315 -0
- data/lib/jamf/api/resources/collection_resources/script.rb +190 -0
- data/lib/jamf/api/resources/collection_resources/site.rb +77 -0
- data/lib/jamf/api/resources/singleton_resources/app_store_country_codes.rb +131 -0
- data/lib/jamf/api/resources/singleton_resources/authorization.rb +88 -0
- data/lib/jamf/api/resources/singleton_resources/client_checkin_settings.rb +139 -0
- data/lib/jamf/api/resources/singleton_resources/reenrollment_settings.rb +95 -0
- data/lib/jamf/client.rb +301 -0
- data/lib/jamf/client/jamf_binary.rb +132 -0
- data/lib/jamf/client/jamf_helper.rb +298 -0
- data/lib/jamf/client/management_action.rb +114 -0
- data/lib/jamf/compatibility.rb +88 -0
- data/lib/jamf/composer.rb +190 -0
- data/lib/jamf/configuration.rb +281 -0
- data/lib/jamf/exceptions.rb +107 -0
- data/lib/jamf/ruby_extensions.rb +36 -0
- data/lib/jamf/ruby_extensions/array.rb +35 -0
- data/lib/jamf/ruby_extensions/array/predicates.rb +46 -0
- data/lib/jamf/ruby_extensions/array/utils.rb +47 -0
- data/lib/jamf/ruby_extensions/filetest.rb +32 -0
- data/lib/jamf/ruby_extensions/filetest/predicates.rb +46 -0
- data/lib/jamf/ruby_extensions/hash.rb +33 -0
- data/lib/jamf/ruby_extensions/hash/backports.rb +92 -0
- data/lib/jamf/ruby_extensions/ipaddr.rb +37 -0
- data/lib/jamf/ruby_extensions/ipaddr/utils.rb +95 -0
- data/lib/jamf/ruby_extensions/object.rb +30 -0
- data/lib/jamf/ruby_extensions/object/predicates.rb +51 -0
- data/lib/jamf/ruby_extensions/pathname.rb +39 -0
- data/lib/jamf/ruby_extensions/pathname/predicates.rb +50 -0
- data/lib/jamf/ruby_extensions/pathname/utils.rb +75 -0
- data/lib/jamf/ruby_extensions/string.rb +35 -0
- data/lib/jamf/ruby_extensions/string/backports.rb +66 -0
- data/lib/jamf/ruby_extensions/string/conversions.rb +65 -0
- data/lib/jamf/ruby_extensions/string/predicates.rb +47 -0
- data/lib/jamf/utility.rb +423 -0
- data/lib/jamf/validate.rb +224 -0
- data/lib/jamf/version.rb +32 -0
- data/lib/jpapi.rb +26 -0
- data/lib/jss/version.rb +1 -1
- metadata +104 -4
@@ -0,0 +1,107 @@
|
|
1
|
+
# Copyright 2019 Pixar
|
2
|
+
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "Apache License")
|
5
|
+
# with the following modification; you may not use this file except in
|
6
|
+
# compliance with the Apache License and the following modification to it:
|
7
|
+
# Section 6. Trademarks. is deleted and replaced with:
|
8
|
+
#
|
9
|
+
# 6. Trademarks. This License does not grant permission to use the trade
|
10
|
+
# names, trademarks, service marks, or product names of the Licensor
|
11
|
+
# and its affiliates, except as required to comply with Section 4(c) of
|
12
|
+
# the License and to reproduce the content of the NOTICE file.
|
13
|
+
#
|
14
|
+
# You may obtain a copy of the Apache License at
|
15
|
+
#
|
16
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
17
|
+
#
|
18
|
+
# Unless required by applicable law or agreed to in writing, software
|
19
|
+
# distributed under the Apache License with the above modification is
|
20
|
+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
21
|
+
# KIND, either express or implied. See the Apache License for the specific
|
22
|
+
# language governing permissions and limitations under the Apache License.
|
23
|
+
#
|
24
|
+
#
|
25
|
+
|
26
|
+
# The Module
|
27
|
+
module Jamf
|
28
|
+
|
29
|
+
# Exceptions
|
30
|
+
#####################################
|
31
|
+
|
32
|
+
# MissingDataError - raise this error when we
|
33
|
+
# are missing args, or other simliar stuff.
|
34
|
+
#
|
35
|
+
class MissingDataError < RuntimeError; end
|
36
|
+
|
37
|
+
# InvalidDataError - raise this error when
|
38
|
+
# a data item isn't what we expected.
|
39
|
+
#
|
40
|
+
class InvalidDataError < RuntimeError; end
|
41
|
+
|
42
|
+
# InvalidConnectionError - raise this error when we
|
43
|
+
# don't have a usable connection to a network service, or
|
44
|
+
# don't have proper authentication/authorization.
|
45
|
+
#
|
46
|
+
class InvalidConnectionError < RuntimeError; end
|
47
|
+
|
48
|
+
# NoSuchItemError - raise this error when
|
49
|
+
# a desired item doesn't exist.
|
50
|
+
#
|
51
|
+
class NoSuchItemError < RuntimeError; end
|
52
|
+
|
53
|
+
# AlreadyExistsError - raise this error when
|
54
|
+
# trying to create something that already exists.
|
55
|
+
#
|
56
|
+
class AlreadyExistsError < RuntimeError; end
|
57
|
+
|
58
|
+
# FileServiceError - raise this error when
|
59
|
+
# there's a problem accessing file service on a
|
60
|
+
# distribution point.
|
61
|
+
#
|
62
|
+
class FileServiceError < RuntimeError; end
|
63
|
+
|
64
|
+
# UnmanagedError - raise this when we
|
65
|
+
# try to do something managerial to
|
66
|
+
# an unmanaged object
|
67
|
+
#
|
68
|
+
class UnmanagedError < RuntimeError; end
|
69
|
+
|
70
|
+
# UnsupportedError - raise this when we
|
71
|
+
# try to do something not yet supported
|
72
|
+
#
|
73
|
+
class UnsupportedError < RuntimeError; end
|
74
|
+
|
75
|
+
# TimeoutError - raise this when we
|
76
|
+
# try to do something and it times out
|
77
|
+
#
|
78
|
+
class TimeoutError < RuntimeError; end
|
79
|
+
|
80
|
+
# AuthenticationError - raise this when
|
81
|
+
# a name/pw are wrong
|
82
|
+
#
|
83
|
+
class AuthenticationError < RuntimeError; end
|
84
|
+
|
85
|
+
# ConflictError - raise this when
|
86
|
+
# attempts to PUT or PUSH to the API
|
87
|
+
# result in a 409 Conflict http error.
|
88
|
+
# See {Jamf::APIConnection#raise_conflict_error}
|
89
|
+
#
|
90
|
+
class ConflictError < RuntimeError; end
|
91
|
+
|
92
|
+
# BadRequestError - raise this when
|
93
|
+
# attempts to PUT or PUSH or DELETE to the API
|
94
|
+
# result in a 400 Bad Request http error.
|
95
|
+
# See {Jamf::APIConnection.raise_bad_request_error}
|
96
|
+
#
|
97
|
+
class BadRequestError < RuntimeError; end
|
98
|
+
|
99
|
+
# APIRequestError - raise this when
|
100
|
+
# attempts API actions generate an error not dealt with
|
101
|
+
# by ConflictError or BadRequestError
|
102
|
+
# result in a 400 Bad Request http error.
|
103
|
+
# See {Jamf::APIConnection.raise_api_error}
|
104
|
+
#
|
105
|
+
class APIRequestError < RuntimeError; end
|
106
|
+
|
107
|
+
end # module JAMF
|
@@ -0,0 +1,36 @@
|
|
1
|
+
### Copyright 2019 Pixar
|
2
|
+
|
3
|
+
###
|
4
|
+
### Licensed under the Apache License, Version 2.0 (the "Apache License")
|
5
|
+
### with the following modification; you may not use this file except in
|
6
|
+
### compliance with the Apache License and the following modification to it:
|
7
|
+
### Section 6. Trademarks. is deleted and replaced with:
|
8
|
+
###
|
9
|
+
### 6. Trademarks. This License does not grant permission to use the trade
|
10
|
+
### names, trademarks, service marks, or product names of the Licensor
|
11
|
+
### and its affiliates, except as required to comply with Section 4(c) of
|
12
|
+
### the License and to reproduce the content of the NOTICE file.
|
13
|
+
###
|
14
|
+
### You may obtain a copy of the Apache License at
|
15
|
+
###
|
16
|
+
### http://www.apache.org/licenses/LICENSE-2.0
|
17
|
+
###
|
18
|
+
### Unless required by applicable law or agreed to in writing, software
|
19
|
+
### distributed under the Apache License with the above modification is
|
20
|
+
### distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
21
|
+
### KIND, either express or implied. See the Apache License for the specific
|
22
|
+
### language governing permissions and limitations under the Apache License.
|
23
|
+
###
|
24
|
+
###
|
25
|
+
|
26
|
+
### All monkey-patched convenience methods are either prefixed with "jss_" or
|
27
|
+
### if they are type coercions, "to_jss_"
|
28
|
+
###
|
29
|
+
|
30
|
+
require 'jamf/ruby_extensions/filetest.rb'
|
31
|
+
require 'jamf/ruby_extensions/hash.rb'
|
32
|
+
require 'jamf/ruby_extensions/ipaddr.rb'
|
33
|
+
require 'jamf/ruby_extensions/object.rb'
|
34
|
+
require 'jamf/ruby_extensions/pathname.rb'
|
35
|
+
require 'jamf/ruby_extensions/string.rb'
|
36
|
+
require 'jamf/ruby_extensions/array.rb'
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# Copyright 2019 Pixar
|
2
|
+
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "Apache License")
|
5
|
+
# with the following modification; you may not use this file except in
|
6
|
+
# compliance with the Apache License and the following modification to it:
|
7
|
+
# Section 6. Trademarks. is deleted and replaced with:
|
8
|
+
#
|
9
|
+
# 6. Trademarks. This License does not grant permission to use the trade
|
10
|
+
# names, trademarks, service marks, or product names of the Licensor
|
11
|
+
# and its affiliates, except as required to comply with Section 4(c) of
|
12
|
+
# the License and to reproduce the content of the NOTICE file.
|
13
|
+
#
|
14
|
+
# You may obtain a copy of the Apache License at
|
15
|
+
#
|
16
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
17
|
+
#
|
18
|
+
# Unless required by applicable law or agreed to in writing, software
|
19
|
+
# distributed under the Apache License with the above modification is
|
20
|
+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
21
|
+
# KIND, either express or implied. See the Apache License for the specific
|
22
|
+
# language governing permissions and limitations under the Apache License.
|
23
|
+
#
|
24
|
+
#
|
25
|
+
|
26
|
+
require 'jamf/ruby_extensions/array/predicates'
|
27
|
+
require 'jamf/ruby_extensions/array/utils'
|
28
|
+
|
29
|
+
#
|
30
|
+
class Array
|
31
|
+
|
32
|
+
include JamfRubyExtensions::Array::Predicates
|
33
|
+
include JamfRubyExtensions::Array::Utils
|
34
|
+
|
35
|
+
end # class
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# Copyright 2019 Pixar
|
2
|
+
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "Apache License")
|
5
|
+
# with the following modification; you may not use this file except in
|
6
|
+
# compliance with the Apache License and the following modification to it:
|
7
|
+
# Section 6. Trademarks. is deleted and replaced with:
|
8
|
+
#
|
9
|
+
# 6. Trademarks. This License does not grant permission to use the trade
|
10
|
+
# names, trademarks, service marks, or product names of the Licensor
|
11
|
+
# and its affiliates, except as required to comply with Section 4(c) of
|
12
|
+
# the License and to reproduce the content of the NOTICE file.
|
13
|
+
#
|
14
|
+
# You may obtain a copy of the Apache License at
|
15
|
+
#
|
16
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
17
|
+
#
|
18
|
+
# Unless required by applicable law or agreed to in writing, software
|
19
|
+
# distributed under the Apache License with the above modification is
|
20
|
+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
21
|
+
# KIND, either express or implied. See the Apache License for the specific
|
22
|
+
# language governing permissions and limitations under the Apache License.
|
23
|
+
#
|
24
|
+
#
|
25
|
+
|
26
|
+
module JamfRubyExtensions
|
27
|
+
|
28
|
+
module Array
|
29
|
+
|
30
|
+
module Predicates
|
31
|
+
|
32
|
+
# A case-insensitive version of #include? for Arrays of Strings.
|
33
|
+
#
|
34
|
+
# @param somestring [String] the String to search for
|
35
|
+
#
|
36
|
+
# @return [Boolean] Does the Array contain the String, ignoring case?
|
37
|
+
#
|
38
|
+
def j_ci_include_string?(somestring)
|
39
|
+
any? { |s| s.to_s.casecmp? somestring }
|
40
|
+
end
|
41
|
+
|
42
|
+
end # module
|
43
|
+
|
44
|
+
end # module
|
45
|
+
|
46
|
+
end # module
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# Copyright 2019 Pixar
|
2
|
+
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "Apache License")
|
5
|
+
# with the following modification; you may not use this file except in
|
6
|
+
# compliance with the Apache License and the following modification to it:
|
7
|
+
# Section 6. Trademarks. is deleted and replaced with:
|
8
|
+
#
|
9
|
+
# 6. Trademarks. This License does not grant permission to use the trade
|
10
|
+
# names, trademarks, service marks, or product names of the Licensor
|
11
|
+
# and its affiliates, except as required to comply with Section 4(c) of
|
12
|
+
# the License and to reproduce the content of the NOTICE file.
|
13
|
+
#
|
14
|
+
# You may obtain a copy of the Apache License at
|
15
|
+
#
|
16
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
17
|
+
#
|
18
|
+
# Unless required by applicable law or agreed to in writing, software
|
19
|
+
# distributed under the Apache License with the above modification is
|
20
|
+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
21
|
+
# KIND, either express or implied. See the Apache License for the specific
|
22
|
+
# language governing permissions and limitations under the Apache License.
|
23
|
+
|
24
|
+
module JamfRubyExtensions
|
25
|
+
|
26
|
+
module Array
|
27
|
+
|
28
|
+
module Utils
|
29
|
+
|
30
|
+
# Fetch a string from an Array of Strings case-insensitively,
|
31
|
+
# e.g. my_array.j_ci_fetch_string('ThRashEer') will return 'thrasher'
|
32
|
+
# or nil if no match
|
33
|
+
#
|
34
|
+
# @param somestring [String] the String to search for
|
35
|
+
#
|
36
|
+
# @return [String, nil] The matching string as it exists in the Array, nil if it doesn't exist
|
37
|
+
#
|
38
|
+
def j_ci_fetch_string(somestring)
|
39
|
+
idx = index { |s| s.to_s.casecmp? somestring }
|
40
|
+
idx ? self[idx] : nil
|
41
|
+
end
|
42
|
+
|
43
|
+
end # module
|
44
|
+
|
45
|
+
end # module
|
46
|
+
|
47
|
+
end # module
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# Copyright 2019 Pixar
|
2
|
+
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "Apache License")
|
5
|
+
# with the following modification; you may not use this file except in
|
6
|
+
# compliance with the Apache License and the following modification to it:
|
7
|
+
# Section 6. Trademarks. is deleted and replaced with:
|
8
|
+
#
|
9
|
+
# 6. Trademarks. This License does not grant permission to use the trade
|
10
|
+
# names, trademarks, service marks, or product names of the Licensor
|
11
|
+
# and its affiliates, except as required to comply with Section 4(c) of
|
12
|
+
# the License and to reproduce the content of the NOTICE file.
|
13
|
+
#
|
14
|
+
# You may obtain a copy of the Apache License at
|
15
|
+
#
|
16
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
17
|
+
#
|
18
|
+
# Unless required by applicable law or agreed to in writing, software
|
19
|
+
# distributed under the Apache License with the above modification is
|
20
|
+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
21
|
+
# KIND, either express or implied. See the Apache License for the specific
|
22
|
+
# language governing permissions and limitations under the Apache License.
|
23
|
+
#
|
24
|
+
#
|
25
|
+
|
26
|
+
require 'jamf/ruby_extensions/filetest/predicates'
|
27
|
+
|
28
|
+
module FileTest
|
29
|
+
|
30
|
+
extend JamfRubyExtensions::FileTest::Predicates
|
31
|
+
|
32
|
+
end # module FileTest
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# Copyright 2019 Pixar
|
2
|
+
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "Apache License")
|
5
|
+
# with the following modification; you may not use this file except in
|
6
|
+
# compliance with the Apache License and the following modification to it:
|
7
|
+
# Section 6. Trademarks. is deleted and replaced with:
|
8
|
+
#
|
9
|
+
# 6. Trademarks. This License does not grant permission to use the trade
|
10
|
+
# names, trademarks, service marks, or product names of the Licensor
|
11
|
+
# and its affiliates, except as required to comply with Section 4(c) of
|
12
|
+
# the License and to reproduce the content of the NOTICE file.
|
13
|
+
#
|
14
|
+
# You may obtain a copy of the Apache License at
|
15
|
+
#
|
16
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
17
|
+
#
|
18
|
+
# Unless required by applicable law or agreed to in writing, software
|
19
|
+
# distributed under the Apache License with the above modification is
|
20
|
+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
21
|
+
# KIND, either express or implied. See the Apache License for the specific
|
22
|
+
# language governing permissions and limitations under the Apache License.
|
23
|
+
#
|
24
|
+
#
|
25
|
+
|
26
|
+
module JamfRubyExtensions
|
27
|
+
|
28
|
+
module FileTest
|
29
|
+
|
30
|
+
module Predicates
|
31
|
+
|
32
|
+
# FileTest.file? returns true if
|
33
|
+
# the item is a symlink pointing to a regular file.
|
34
|
+
#
|
35
|
+
# This test, real_file?, returns true if the item is
|
36
|
+
# a regular file but NOT a symlink.
|
37
|
+
#
|
38
|
+
def j_real_file?(path)
|
39
|
+
FileTest.file?(path) && !FileTest.symlink?(path)
|
40
|
+
end # real_file?
|
41
|
+
|
42
|
+
end # module
|
43
|
+
|
44
|
+
end # module
|
45
|
+
|
46
|
+
end # module
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# Copyright 2019 Pixar
|
2
|
+
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "Apache License")
|
5
|
+
# with the following modification; you may not use this file except in
|
6
|
+
# compliance with the Apache License and the following modification to it:
|
7
|
+
# Section 6. Trademarks. is deleted and replaced with:
|
8
|
+
#
|
9
|
+
# 6. Trademarks. This License does not grant permission to use the trade
|
10
|
+
# names, trademarks, service marks, or product names of the Licensor
|
11
|
+
# and its affiliates, except as required to comply with Section 4(c) of
|
12
|
+
# the License and to reproduce the content of the NOTICE file.
|
13
|
+
#
|
14
|
+
# You may obtain a copy of the Apache License at
|
15
|
+
#
|
16
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
17
|
+
#
|
18
|
+
# Unless required by applicable law or agreed to in writing, software
|
19
|
+
# distributed under the Apache License with the above modification is
|
20
|
+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
21
|
+
# KIND, either express or implied. See the Apache License for the specific
|
22
|
+
# language governing permissions and limitations under the Apache License.
|
23
|
+
#
|
24
|
+
#
|
25
|
+
|
26
|
+
require 'jamf/ruby_extensions/hash/backports'
|
27
|
+
|
28
|
+
# include the modules loaded above
|
29
|
+
class Hash
|
30
|
+
|
31
|
+
include JamfRubyExtensions::Hash::BackPorts
|
32
|
+
|
33
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
# Copyright 2019 Pixar
|
2
|
+
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "Apache License")
|
5
|
+
# with the following modification; you may not use this file except in
|
6
|
+
# compliance with the Apache License and the following modification to it:
|
7
|
+
# Section 6. Trademarks. is deleted and replaced with:
|
8
|
+
#
|
9
|
+
# 6. Trademarks. This License does not grant permission to use the trade
|
10
|
+
# names, trademarks, service marks, or product names of the Licensor
|
11
|
+
# and its affiliates, except as required to comply with Section 4(c) of
|
12
|
+
# the License and to reproduce the content of the NOTICE file.
|
13
|
+
#
|
14
|
+
# You may obtain a copy of the Apache License at
|
15
|
+
#
|
16
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
17
|
+
#
|
18
|
+
# Unless required by applicable law or agreed to in writing, software
|
19
|
+
# distributed under the Apache License with the above modification is
|
20
|
+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
21
|
+
# KIND, either express or implied. See the Apache License for the specific
|
22
|
+
# language governing permissions and limitations under the Apache License.
|
23
|
+
#
|
24
|
+
#
|
25
|
+
# Copyright 2019 Pixar
|
26
|
+
|
27
|
+
#
|
28
|
+
# Licensed under the Apache License, Version 2.0 (the "Apache License")
|
29
|
+
# with the following modification; you may not use this file except in
|
30
|
+
# compliance with the Apache License and the following modification to it:
|
31
|
+
# Section 6. Trademarks. is deleted and replaced with:
|
32
|
+
#
|
33
|
+
# 6. Trademarks. This License does not grant permission to use the trade
|
34
|
+
# names, trademarks, service marks, or product names of the Licensor
|
35
|
+
# and its affiliates, except as required to comply with Section 4(c) of
|
36
|
+
# the License and to reproduce the content of the NOTICE file.
|
37
|
+
#
|
38
|
+
# You may obtain a copy of the Apache License at
|
39
|
+
#
|
40
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
41
|
+
#
|
42
|
+
# Unless required by applicable law or agreed to in writing, software
|
43
|
+
# distributed under the Apache License with the above modification is
|
44
|
+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
45
|
+
# KIND, either express or implied. See the Apache License for the specific
|
46
|
+
# language governing permissions and limitations under the Apache License.
|
47
|
+
|
48
|
+
module JamfRubyExtensions
|
49
|
+
|
50
|
+
module Hash
|
51
|
+
|
52
|
+
module BackPorts
|
53
|
+
|
54
|
+
empty_hash = {}
|
55
|
+
|
56
|
+
# Ruby 2.5 + has transform_keys
|
57
|
+
unless empty_hash.respond_to? :transform_keys
|
58
|
+
def transform_keys(&block)
|
59
|
+
nh = {}
|
60
|
+
each do |k, v|
|
61
|
+
nk = yield k
|
62
|
+
nh[nk] = v
|
63
|
+
end
|
64
|
+
nh
|
65
|
+
end
|
66
|
+
|
67
|
+
def transform_keys!(&block)
|
68
|
+
replace transform_keys(&block)
|
69
|
+
end
|
70
|
+
end # unless
|
71
|
+
|
72
|
+
# Ruby 2.4 + has transform_values
|
73
|
+
unless empty_hash.respond_to? :transform_values
|
74
|
+
def transform_values(&block)
|
75
|
+
nh = {}
|
76
|
+
each do |k, v|
|
77
|
+
nv = yield v
|
78
|
+
nh[k] = nv
|
79
|
+
end
|
80
|
+
nh
|
81
|
+
end
|
82
|
+
|
83
|
+
def transform_values!(&block)
|
84
|
+
replace transform_values(&block)
|
85
|
+
end
|
86
|
+
end # unless
|
87
|
+
|
88
|
+
end # module
|
89
|
+
|
90
|
+
end # module
|
91
|
+
|
92
|
+
end # module
|