ruby-jss 1.2.10 → 1.5.2

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.

Files changed (119) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +208 -1
  3. data/lib/jamf.rb +18 -16
  4. data/lib/jamf/api/base_classes/collection_resource.rb +613 -0
  5. data/lib/jamf/api/{abstract_classes → base_classes}/json_object.rb +110 -102
  6. data/lib/jamf/api/{abstract_classes → base_classes}/prestage.rb +56 -31
  7. data/lib/jamf/api/{abstract_classes → base_classes}/resource.rb +10 -6
  8. data/lib/jamf/api/{abstract_classes → base_classes}/singleton_resource.rb +4 -3
  9. data/lib/jamf/api/connection.rb +20 -12
  10. data/lib/jamf/api/connection/api_error.rb +8 -8
  11. data/lib/jamf/api/connection/token.rb +36 -15
  12. data/lib/jamf/api/json_objects/device_enrollment_device.rb +14 -7
  13. data/lib/jamf/api/json_objects/{location.rb → device_enrollment_device_sync_state.rb} +27 -41
  14. data/lib/jamf/api/json_objects/device_enrollment_sync_status.rb +1 -1
  15. data/lib/jamf/api/json_objects/{attachment.rb → locale.rb} +14 -23
  16. data/lib/jamf/api/json_objects/md_prestage_name.rb +1 -1
  17. data/lib/jamf/api/json_objects/md_prestage_names.rb +2 -2
  18. data/lib/jamf/api/json_objects/md_prestage_skip_setup_items.rb +50 -1
  19. data/lib/jamf/api/json_objects/prestage_assignment.rb +2 -2
  20. data/lib/jamf/api/json_objects/prestage_location.rb +3 -3
  21. data/lib/jamf/api/json_objects/prestage_purchasing_data.rb +7 -7
  22. data/lib/jamf/api/json_objects/prestage_scope.rb +1 -1
  23. data/lib/jamf/api/{resources/collection_resources → json_objects}/time_zone.rb +9 -23
  24. data/lib/jamf/api/mixins/{abstract.rb → base_class.rb} +34 -16
  25. data/lib/jamf/api/mixins/bulk_deletable.rb +27 -6
  26. data/lib/jamf/api/mixins/change_log.rb +201 -51
  27. data/lib/jamf/api/{resources/collection_resources/extension_attribute.rb → mixins/filterable.rb} +20 -14
  28. data/lib/jamf/api/mixins/pageable.rb +208 -0
  29. data/lib/jamf/api/{json_objects/installed_application.rb → mixins/sortable.rb} +33 -33
  30. data/lib/jamf/api/resources/collection_resources/building.rb +16 -9
  31. data/lib/jamf/api/resources/collection_resources/category.rb +5 -4
  32. data/lib/jamf/api/resources/collection_resources/computer_prestage.rb +12 -5
  33. data/lib/jamf/api/resources/collection_resources/department.rb +1 -3
  34. data/lib/jamf/api/resources/collection_resources/device_enrollment.rb +13 -13
  35. data/lib/jamf/api/resources/collection_resources/inventory_preload_record.rb +11 -3
  36. data/lib/jamf/api/resources/collection_resources/mobile_device_prestage.rb +25 -23
  37. data/lib/jamf/api/resources/collection_resources/script.rb +61 -25
  38. data/lib/jamf/api/resources/singleton_resources/app_store_country_codes.rb +15 -5
  39. data/lib/jamf/api/resources/singleton_resources/locales.rb +155 -0
  40. data/lib/jamf/api/resources/singleton_resources/time_zones.rb +213 -0
  41. data/lib/jamf/configuration.rb +7 -9
  42. data/lib/jamf/ruby_extensions.rb +1 -0
  43. data/lib/jamf/ruby_extensions/array.rb +1 -1
  44. data/lib/jamf/ruby_extensions/array/utils.rb +3 -3
  45. data/lib/jamf/{api/resources/collection_resources/computer.rb → ruby_extensions/dig.rb} +22 -19
  46. data/lib/jamf/validate.rb +63 -24
  47. data/lib/jamf/version.rb +1 -1
  48. data/lib/jss.rb +4 -1
  49. data/lib/jss/api_connection.rb +111 -433
  50. data/lib/jss/api_object.rb +16 -13
  51. data/lib/jss/api_object/advanced_search.rb +27 -26
  52. data/lib/jss/api_object/app_store_country_codes.rb +298 -0
  53. data/lib/jss/api_object/categorizable.rb +1 -1
  54. data/lib/jss/api_object/computer.rb +13 -0
  55. data/lib/jss/api_object/configuration_profile.rb +60 -4
  56. data/lib/jss/api_object/directory_binding.rb +273 -0
  57. data/lib/jss/api_object/directory_binding_type.rb +96 -0
  58. data/lib/jss/api_object/directory_binding_type/active_directory.rb +539 -0
  59. data/lib/jss/api_object/directory_binding_type/admitmac.rb +594 -0
  60. data/lib/jss/api_object/directory_binding_type/centrify.rb +226 -0
  61. data/lib/jss/api_object/directory_binding_type/open_directory.rb +178 -0
  62. data/lib/jss/api_object/directory_binding_type/powerbroker_identity_services.rb +73 -0
  63. data/lib/jss/api_object/disk_encryption_configurations.rb +114 -0
  64. data/lib/jss/api_object/distribution_point.rb +97 -37
  65. data/lib/jss/api_object/dock_item.rb +143 -0
  66. data/lib/jss/api_object/ebook.rb +1 -2
  67. data/lib/jss/api_object/extendable.rb +1 -1
  68. data/lib/jss/api_object/extension_attribute.rb +4 -3
  69. data/lib/jss/api_object/group.rb +33 -2
  70. data/lib/jss/api_object/mac_application.rb +107 -8
  71. data/lib/jss/api_object/mobile_device_application.rb +12 -0
  72. data/lib/jss/api_object/network_segment.rb +195 -70
  73. data/lib/jss/api_object/package.rb +105 -40
  74. data/lib/jss/api_object/patch_source.rb +10 -9
  75. data/lib/jss/api_object/policy.rb +596 -32
  76. data/lib/jss/api_object/printer.rb +446 -0
  77. data/lib/jss/api_object/scopable.rb +10 -15
  78. data/lib/jss/api_object/scopable/scope.rb +371 -55
  79. data/lib/jss/api_object/self_servable.rb +17 -9
  80. data/lib/jss/api_object/uploadable.rb +1 -1
  81. data/lib/jss/api_object/user.rb +42 -1
  82. data/lib/jss/api_object/vpp_account.rb +209 -0
  83. data/lib/jss/api_object/vppable.rb +169 -13
  84. data/lib/jss/composer.rb +1 -1
  85. data/lib/jss/exceptions.rb +3 -0
  86. data/lib/jss/server.rb +15 -0
  87. data/lib/jss/utility.rb +143 -52
  88. data/lib/jss/validate.rb +53 -10
  89. data/lib/jss/version.rb +1 -1
  90. metadata +56 -61
  91. data/lib/jamf/api/abstract_classes/advanced_search.rb +0 -86
  92. data/lib/jamf/api/abstract_classes/collection_resource.rb +0 -433
  93. data/lib/jamf/api/abstract_classes/generic_reference.rb +0 -145
  94. data/lib/jamf/api/abstract_classes/prestage_skip_setup_items.rb +0 -126
  95. data/lib/jamf/api/json_objects/account_prefs.rb +0 -79
  96. data/lib/jamf/api/json_objects/android_details.rb +0 -139
  97. data/lib/jamf/api/json_objects/appletv_details.rb +0 -110
  98. data/lib/jamf/api/json_objects/cellular_network.rb +0 -151
  99. data/lib/jamf/api/json_objects/computer_prestage_skip_setup_items.rb +0 -67
  100. data/lib/jamf/api/json_objects/criterion.rb +0 -152
  101. data/lib/jamf/api/json_objects/extension_attribute_value.rb +0 -128
  102. data/lib/jamf/api/json_objects/installed_certificate.rb +0 -53
  103. data/lib/jamf/api/json_objects/installed_configuration_profile.rb +0 -67
  104. data/lib/jamf/api/json_objects/installed_ebook.rb +0 -58
  105. data/lib/jamf/api/json_objects/installed_provisioning_profile.rb +0 -59
  106. data/lib/jamf/api/json_objects/ios_details.rb +0 -244
  107. data/lib/jamf/api/json_objects/mobile_device_details.rb +0 -219
  108. data/lib/jamf/api/json_objects/mobile_device_security.rb +0 -101
  109. data/lib/jamf/api/json_objects/purchasing_data.rb +0 -125
  110. data/lib/jamf/api/mixins/locatable.rb +0 -124
  111. data/lib/jamf/api/mixins/referable.rb +0 -92
  112. data/lib/jamf/api/resources/collection_resources/account.rb +0 -163
  113. data/lib/jamf/api/resources/collection_resources/advanced_mobile_device_search.rb +0 -52
  114. data/lib/jamf/api/resources/collection_resources/advanced_user_search.rb +0 -52
  115. data/lib/jamf/api/resources/collection_resources/mobile_device.rb +0 -315
  116. data/lib/jamf/api/resources/collection_resources/site.rb +0 -77
  117. data/lib/jamf/api/resources/singleton_resources/authorization.rb +0 -88
  118. data/lib/jamf/api/resources/singleton_resources/client_checkin_settings.rb +0 -139
  119. data/lib/jamf/api/resources/singleton_resources/reenrollment_settings.rb +0 -95
@@ -0,0 +1,155 @@
1
+ # Copyright 2020 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
+ # Classes
30
+ #####################################
31
+
32
+ # A list of known timezones
33
+ class Locales < Jamf::SingletonResource
34
+
35
+ # Mix-Ins
36
+ #####################################
37
+
38
+ extend Jamf::Immutable
39
+
40
+ # Constants
41
+ #####################################
42
+
43
+ RSRC_VERSION = 'v1'.freeze
44
+
45
+ RSRC_PATH = 'locales'.freeze
46
+
47
+ OBJECT_MODEL = {
48
+
49
+ # @!attribute checkInFrequency
50
+ # @return [integer]
51
+ locales: {
52
+ class: Jamf::Locale,
53
+ multi: true,
54
+ read_only: true,
55
+ aliases: [:list]
56
+ }
57
+
58
+ }.freeze # end OBJECT_MODEL
59
+
60
+ parse_object_model
61
+
62
+ # TEMP? until this endpoint is brought up to standards
63
+ # the data from the API is a raw Array, but it should be a
64
+ # Hash containing an array.
65
+ def initialize(data, cnx: Jamf.cnx)
66
+ data = { locales: data }
67
+ super data, cnx: cnx
68
+ end
69
+
70
+ # Class Methods
71
+ #####################################
72
+
73
+ # @return [Array<Jamf::Locale>] all the locales available
74
+ #
75
+ def self.list(refresh = false, cnx: Jamf.cnx)
76
+ fetch(refresh, cnx: cnx).locales
77
+ end
78
+
79
+ # Class level wrapper for #descriptions
80
+ def self.descriptions(refresh = false, cnx: Jamf.cnx)
81
+ fetch(refresh, cnx: cnx).descriptions
82
+ end
83
+ # how to alias a class method
84
+ singleton_class.send(:alias_method, :names, :descriptions)
85
+
86
+ # Class level wrapper for #identifiers
87
+ def self.identifiers(refresh = false, cnx: Jamf.cnx)
88
+ fetch(refresh, cnx: cnx).identifiers
89
+ end
90
+ singleton_class.send(:alias_method, :ids, :identifiers)
91
+
92
+ # Class level wrapper for #ids_by_desc
93
+ def self.ids_by_desc(refresh = false, cnx: Jamf.cnx)
94
+ fetch(refresh, cnx: cnx).ids_by_desc
95
+ end
96
+
97
+ # Class level wrapper for #descs_by_id
98
+ def self.descs_by_id(refresh = false, cnx: Jamf.cnx)
99
+ fetch(refresh, cnx: cnx).descs_by_id
100
+ end
101
+
102
+ # Class level wrapper for #id_for_desc
103
+ def self.id_for_desc(desc, refresh = false, cnx: Jamf.cnx)
104
+ fetch(refresh, cnx: cnx).id_for_desc desc
105
+ end
106
+
107
+ # Class level wrapper for #desc_for_id
108
+ def self.desc_for_id(id, refresh = false, cnx: Jamf.cnx)
109
+ fetch(refresh, cnx: cnx).desc_for_id id
110
+ end
111
+
112
+ # Instance Methods
113
+ #####################################
114
+
115
+ # @return [Array<String>] the available descriptions
116
+ def descriptions
117
+ @descriptions ||= locales.map(&:description)
118
+ end
119
+ alias names descriptions
120
+
121
+ # @return [Array<String>] the available identifiers
122
+ def identifiers
123
+ @identifiers ||= locales.map(&:identifier)
124
+ end
125
+ alias ids identifiers
126
+
127
+ # @return [Hash] name => code
128
+ def ids_by_desc
129
+ @ids_by_desc ||= locales.map { |l| [l.description, l.identifier] }.to_h
130
+ end
131
+
132
+ # @return [Hash] code => name
133
+ def descs_by_id
134
+ @descs_by_id ||= locales.map { |l| [l.identifier, l.description] }.to_h
135
+ end
136
+
137
+ # return an identifier from its description, case-insensitive
138
+ # @param desc[String] the description of a locale
139
+ # @return [String]
140
+ def id_for_desc(desc)
141
+ desc = descriptions.select { |n| n.casecmp? desc }.first
142
+ ids_by_desc[desc]
143
+ end
144
+
145
+ # return a description from its identifier, case-insensitive
146
+ # @param name[String] the identifier of a local
147
+ # @return [String]
148
+ def desc_for_id(id)
149
+ id = identifiers.select { |n| n.casecmp? id }.first
150
+ descs_by_id[id]
151
+ end
152
+
153
+ end # class
154
+
155
+ end # module
@@ -0,0 +1,213 @@
1
+ # Copyright 2020 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
+ # Classes
30
+ #####################################
31
+
32
+ # A list of known timezones
33
+ class TimeZones < Jamf::SingletonResource
34
+
35
+ # Mix-Ins
36
+ #####################################
37
+
38
+ extend Jamf::Immutable
39
+
40
+ # Constants
41
+ #####################################
42
+
43
+ RSRC_VERSION = 'v1'.freeze
44
+
45
+ RSRC_PATH = 'time-zones'.freeze
46
+
47
+ OBJECT_MODEL = {
48
+
49
+ # @!attribute checkInFrequency
50
+ # @return [integer]
51
+ timeZones: {
52
+ class: Jamf::TimeZone,
53
+ multi: true,
54
+ read_only: true,
55
+ aliases: [:list]
56
+ }
57
+
58
+ }.freeze # end OBJECT_MODEL
59
+
60
+ parse_object_model
61
+
62
+ # TEMP? until this endpoint is brought up to standards
63
+ # the data from the API is a raw Array, but it should be a
64
+ # Hash containing an array.
65
+ def initialize(data, cnx: Jamf.cnx)
66
+ data = { timeZones: data }
67
+ super data, cnx: cnx
68
+ end
69
+
70
+
71
+
72
+ # Class Methods
73
+ #####################################
74
+
75
+ # @return [Array<Jamf::TimeZone>] all the zomes available
76
+ #
77
+ def self.list(refresh = false, cnx: Jamf.cnx)
78
+ fetch(refresh, cnx: cnx).timeZones
79
+ end
80
+
81
+ # Class level wrapper for #displayNames
82
+ def self.displayNames(refresh = false, cnx: Jamf.cnx)
83
+ fetch(refresh, cnx: cnx).displayNames
84
+ end
85
+ singleton_class.send(:alias_method, :names, :displayNames)
86
+
87
+ # Class level wrapper for #zoneIds
88
+ def self.zoneIds(refresh = false, cnx: Jamf.cnx)
89
+ fetch(refresh, cnx: cnx).zoneIds
90
+ end
91
+ singleton_class.send(:alias_method, :ids, :zoneIds)
92
+
93
+ # Class level wrapper for #regions
94
+ def self.regions(refresh = false, cnx: Jamf.cnx)
95
+ fetch(refresh, cnx: cnx).regions
96
+ end
97
+
98
+ # Class level wrapper for #ids_by_name
99
+ def self.ids_by_name(refresh = false, cnx: Jamf.cnx)
100
+ fetch(refresh, cnx: cnx).ids_by_name
101
+ end
102
+
103
+ # Class level wrapper for #names_by_id
104
+ def self.names_by_id(refresh = false, cnx: Jamf.cnx)
105
+ fetch(refresh, cnx: cnx).names_by_id
106
+ end
107
+
108
+ # Class level wrapper for #regions_by_id
109
+ def self.regions_by_id(refresh = false, cnx: Jamf.cnx)
110
+ fetch(refresh, cnx: cnx).regions_by_id
111
+ end
112
+
113
+ # Class level wrapper for #regions_by_name
114
+ def self.regions_by_name(refresh = false, cnx: Jamf.cnx)
115
+ fetch(refresh, cnx: cnx).regions_by_name
116
+ end
117
+
118
+ # Class level wrapper for #id_for_name
119
+ def self.id_for_name(name, refresh = false, cnx: Jamf.cnx)
120
+ fetch(refresh, cnx: cnx).id_for_name name
121
+ end
122
+
123
+ # Class level wrapper for #name_for_id
124
+ def self.name_for_id(id, refresh = false, cnx: Jamf.cnx)
125
+ fetch(refresh, cnx: cnx).name_for_id id
126
+ end
127
+
128
+ # Class level wrapper for #region_for_name
129
+ def self.region_for_name(name, refresh = false, cnx: Jamf.cnx)
130
+ fetch(refresh, cnx: cnx).region_for_name name
131
+ end
132
+
133
+ # Class level wrapper for #name_for_id
134
+ def self.region_for_id(id, refresh = false, cnx: Jamf.cnx)
135
+ fetch(refresh, cnx: cnx).region_for_id id
136
+ end
137
+
138
+
139
+ # Instance Methods
140
+ #####################################
141
+
142
+ # @return [Array<String>] the available zone names
143
+ def displayNames
144
+ @names ||= timeZones.map(&:displayName)
145
+ end
146
+ alias names displayNames
147
+
148
+ # @return [Array<String>] the available zone ids
149
+ def zoneIds
150
+ @ids ||= timeZones.map(&:zoneId)
151
+ end
152
+ alias ids zoneIds
153
+
154
+ # @return [Array<String>] the available zone regions
155
+ def regions
156
+ @regions ||= timeZones.map(&:region).uniq
157
+ end
158
+
159
+ # @return [Hash] name => id
160
+ def ids_by_name
161
+ @ids_by_name ||= timeZones.map { |tz| [tz.displayName, tz.zoneId] }.to_h
162
+ end
163
+
164
+ # @return [Hash] id => name
165
+ def names_by_id
166
+ @names_by_id ||= timeZones.map { |tz| [tz.zoneId, tz.displayName] }.to_h
167
+ end
168
+
169
+ # @return [Hash] id => region
170
+ def regions_by_id
171
+ @regions_by_id ||= timeZones.map { |tz| [tz.zoneId, tz.region] }.to_h
172
+ end
173
+
174
+ # @return [Hash] name => region
175
+ def regions_by_name
176
+ @regions_by_name ||= timeZones.map { |tz| [tz.displayName, tz.region] }.to_h
177
+ end
178
+
179
+ # return a zone id from its name, case-insensitive
180
+ # @param name[String] the name of a zone
181
+ # @return [String]
182
+ def id_for_name(name)
183
+ name = names.select { |n| n.casecmp? name }.first
184
+ ids_by_name[name]
185
+ end
186
+
187
+ # return a zone name from its id, case-insensitive
188
+ # @param name[String] the name of a zone
189
+ # @return [String]
190
+ def name_for_id(id)
191
+ id = ids.select { |n| n.casecmp? id }.first
192
+ names_by_id[id]
193
+ end
194
+
195
+ # return a zone name from its id, case-insensitive
196
+ # @param name[String] the name of a zone
197
+ # @return [String]
198
+ def region_for_name(name)
199
+ name = names.select { |n| n.casecmp? name }.first
200
+ regions_by_name[name]
201
+ end
202
+
203
+ # return a zones from its id, case-insensitive
204
+ # @param name[String] the name of a zone
205
+ # @return [String]
206
+ def region_for_id(id)
207
+ id = ids.select { |n| n.casecmp? id }.first
208
+ regions_by_id[id]
209
+ end
210
+
211
+ end # class
212
+
213
+ end # module
@@ -103,8 +103,8 @@ module Jamf
103
103
  # The Pathname to the machine-wide preferences
104
104
  GLOBAL_CONF_FILE = Pathname.new "/etc/#{CONF_FILENAME}"
105
105
 
106
- # The Pathname to the user-specific preferences plist
107
- USER_CONF_FILE = ENV['HOME'] ? Pathname.new("~/.#{CONF_FILENAME}").expand_path : nil
106
+ # The Pathname to the user-specific preferences plist if there is one
107
+ USER_CONF_FILE = Pathname.new("#{ENV['HOME']}/.#{CONF_FILENAME}")
108
108
 
109
109
  # The attribute keys we maintain, and the type they should be stored as
110
110
  CONF_KEYS = {
@@ -134,7 +134,6 @@ module Jamf
134
134
  # Constructor
135
135
  #####################################
136
136
 
137
-
138
137
  # Initialize!
139
138
  #
140
139
  def initialize
@@ -145,7 +144,6 @@ module Jamf
145
144
  # Public Instance Methods
146
145
  #####################################
147
146
 
148
-
149
147
  # Clear all values
150
148
  #
151
149
  # @return [void]
@@ -159,7 +157,7 @@ module Jamf
159
157
  # @return [void]
160
158
  #
161
159
  def read_global
162
- read GLOBAL_CONF_FILE if GLOBAL_CONF_FILE&.file? && GLOBAL_CONF_FILE.readable?
160
+ read GLOBAL_CONF_FILE if GLOBAL_CONF_FILE.file? && GLOBAL_CONF_FILE.readable?
163
161
  end
164
162
 
165
163
  # (Re)read the user prefs, if it exists.
@@ -167,7 +165,7 @@ module Jamf
167
165
  # @return [void]
168
166
  #
169
167
  def read_user
170
- read USER_CONF_FILE if USER_CONF_FILE&.file? && USER_CONF_FILE.readable?
168
+ read USER_CONF_FILE if USER_CONF_FILE.file? && USER_CONF_FILE.readable?
171
169
  end
172
170
 
173
171
  # Clear the settings and reload the prefs files, or another file if provided
@@ -196,9 +194,9 @@ module Jamf
196
194
  def save(file)
197
195
  path =
198
196
  case file
199
- when :global then GLOBAL_CONF_FILE
200
- when :user then USER_CONF_FILE
201
- else Pathname.new(file)
197
+ when :global then GLOBAL_CONF_FILE
198
+ when :user then USER_CONF_FILE
199
+ else Pathname.new(file)
202
200
  end
203
201
 
204
202
  raise Jamf::MissingDataError, "No HOME environment variable, can't write to user conf file." if path.nil?
@@ -34,3 +34,4 @@ require 'jamf/ruby_extensions/object.rb'
34
34
  require 'jamf/ruby_extensions/pathname.rb'
35
35
  require 'jamf/ruby_extensions/string.rb'
36
36
  require 'jamf/ruby_extensions/array.rb'
37
+ require 'jamf/ruby_extensions/dig.rb'
@@ -26,7 +26,7 @@
26
26
  require 'jamf/ruby_extensions/array/predicates'
27
27
  require 'jamf/ruby_extensions/array/utils'
28
28
 
29
- #
29
+ # an array
30
30
  class Array
31
31
 
32
32
  include JamfRubyExtensions::Array::Predicates
@@ -25,6 +25,7 @@ module JamfRubyExtensions
25
25
 
26
26
  module Array
27
27
 
28
+ # Useful monkey patches for Array
28
29
  module Utils
29
30
 
30
31
  # Fetch a string from an Array case-insensitively,
@@ -40,8 +41,7 @@ module JamfRubyExtensions
40
41
  # nil if it doesn't exist
41
42
  #
42
43
  def j_ci_fetch(somestring)
43
- # select { |s| s&.casecmp? somestring }.first
44
- each { |s| return s if s&.casecmp?(somestring) }
44
+ each { |s| return s if s.respond_to?(:casecmp?) && s.casecmp?(somestring) }
45
45
  nil
46
46
  end
47
47
 
@@ -52,7 +52,7 @@ module JamfRubyExtensions
52
52
  # @return [Boolean]
53
53
  #
54
54
  def j_ci_include?(somestring)
55
- any? { |s| s&.casecmp? somestring }
55
+ any? { |s| s.respond_to?(:casecmp?) && s.casecmp?(somestring) }
56
56
  end
57
57
 
58
58
  end # module