ruby-jss 2.0.0b3 → 2.0.0b5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +1 -0
- data/README-2.0.0.md +68 -57
- data/README.md +227 -172
- data/lib/jamf/api/classic/api_objects/distribution_point.rb +12 -50
- data/lib/jamf/api/classic/api_objects/patch_title.rb +14 -9
- data/lib/jamf/api/classic/base_classes/api_object.rb +68 -9
- data/lib/jamf/api/classic/base_classes/patch_source.rb +10 -5
- data/lib/jamf/api/connection.rb +1 -1
- data/lib/jamf/api/jamf_pro/mixins/collection_resource.rb +8 -12
- data/lib/jamf/version.rb +1 -1
- data/lib/jamf/zeitwerk_config.rb +217 -0
- data/lib/jamf.rb +7 -39
- metadata +4 -4
- data/lib/zeitwerk_config.rb +0 -168
@@ -0,0 +1,217 @@
|
|
1
|
+
# Copyright 2022 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
|
+
# Gems
|
25
|
+
######
|
26
|
+
|
27
|
+
require 'zeitwerk'
|
28
|
+
|
29
|
+
# Jamf's Zeitwerk Config and processes
|
30
|
+
module JamfZeitwerkConfig
|
31
|
+
|
32
|
+
# touch this file to make zeitwerk and mixins send text to stderr as things load
|
33
|
+
# or get mixed in
|
34
|
+
VERBOSE_LOADING_FILE = Pathname.new('/tmp/ruby-jss-verbose-loading')
|
35
|
+
|
36
|
+
# Or, set this ENV var to also make zeitverk and mixins send text to stderr
|
37
|
+
VERBOSE_LOADING_ENV = 'RUBY_JSS_VERBOSE_LOADING'
|
38
|
+
|
39
|
+
# touch this file to make zeitwek eager-load everything when the gem is required.
|
40
|
+
EAGER_LOAD_FILE = Pathname.new('/tmp/ruby-jss-zeitwerk-eager-load')
|
41
|
+
|
42
|
+
# Only look at the filesystem once.
|
43
|
+
def self.verbose_loading?
|
44
|
+
return @verbose_loading unless @verbose_loading.nil?
|
45
|
+
|
46
|
+
@verbose_loading = VERBOSE_LOADING_FILE.file?
|
47
|
+
@verbose_loading ||= ENV.include? VERBOSE_LOADING_ENV
|
48
|
+
@verbose_loading
|
49
|
+
end
|
50
|
+
|
51
|
+
# rubocop: disable Style/StderrPuts
|
52
|
+
def self.load_msg(msg)
|
53
|
+
$stderr.puts msg if verbose_loading?
|
54
|
+
end
|
55
|
+
# rubocop: enable Style/StderrPuts
|
56
|
+
|
57
|
+
# The loader object for Xolo
|
58
|
+
def self.loader
|
59
|
+
@loader
|
60
|
+
end
|
61
|
+
|
62
|
+
# Configure the Zeitwerk loader, See https://github.com/fxn/zeitwerk
|
63
|
+
def self.setup_zeitwerk_loader(zloader)
|
64
|
+
@loader = zloader
|
65
|
+
|
66
|
+
# Ignore this file (more ignores below)
|
67
|
+
loader.ignore __FILE__
|
68
|
+
|
69
|
+
##### Collaped Paths
|
70
|
+
|
71
|
+
# these paths all define classes & modules directly below 'Jamf'
|
72
|
+
# If we didn't collapse them, then e.g.
|
73
|
+
# /jamf/api/base_classes/classic/group.rb
|
74
|
+
# would be expected to define
|
75
|
+
# Jamf::Api::BaseClasses::Classic::Group
|
76
|
+
# rather than what we want:
|
77
|
+
# Jamf::Group
|
78
|
+
###################################################
|
79
|
+
|
80
|
+
loader.collapse("#{__dir__}/api")
|
81
|
+
|
82
|
+
loader.collapse("#{__dir__}/api/classic")
|
83
|
+
loader.collapse("#{__dir__}/api/classic/api_objects")
|
84
|
+
loader.collapse("#{__dir__}/api/classic/base_classes")
|
85
|
+
|
86
|
+
loader.collapse("#{__dir__}/api/jamf_pro")
|
87
|
+
loader.collapse("#{__dir__}/api/jamf_pro/api_objects")
|
88
|
+
loader.collapse("#{__dir__}/api/jamf_pro/mixins")
|
89
|
+
loader.collapse("#{__dir__}/api/jamf_pro/base_classes")
|
90
|
+
loader.collapse("#{__dir__}/api/jamf_pro/other_classes")
|
91
|
+
|
92
|
+
loader.collapse("#{__dir__}/deprecations")
|
93
|
+
|
94
|
+
##### Inflected Paths
|
95
|
+
|
96
|
+
# filenames => Constants, which don't adhere to zeitwerk's parsing standards.
|
97
|
+
#
|
98
|
+
# Mostly because the a filename like 'oapi_object' would be
|
99
|
+
# loaded by zeitwerk expecting it to define 'OapiObject', but it really
|
100
|
+
# defines 'OAPIObject'
|
101
|
+
###############################################
|
102
|
+
|
103
|
+
# Connections
|
104
|
+
loader.inflector.inflect 'classic_api' => 'ClassicAPI'
|
105
|
+
loader.inflector.inflect 'jamf_pro_api' => 'JamfProAPI'
|
106
|
+
loader.inflector.inflect 'jamf_pro_api_error' => 'JamfProAPIError'
|
107
|
+
|
108
|
+
# API objects, resources, and mixins
|
109
|
+
loader.inflector.inflect 'oapi_schemas' => 'OAPISchemas'
|
110
|
+
loader.inflector.inflect 'oapi_object' => 'OAPIObject'
|
111
|
+
loader.inflector.inflect 'oapi_validate' => 'OAPIValidate'
|
112
|
+
|
113
|
+
loader.inflector.inflect 'jpapi_resource' => 'JPAPIResource'
|
114
|
+
|
115
|
+
loader.inflector.inflect 'api_object' => 'APIObject'
|
116
|
+
loader.inflector.inflect 'xml_workaround' => 'XMLWorkaround'
|
117
|
+
loader.inflector.inflect 'json_object' => 'JSONObject'
|
118
|
+
loader.inflector.inflect 'vppable' => 'VPPable'
|
119
|
+
loader.inflector.inflect 'osx_configuration_profile' => 'OSXConfigurationProfile'
|
120
|
+
loader.inflector.inflect 'jp_extendable' => 'JPExtendable'
|
121
|
+
loader.inflector.inflect 'mdm' => 'MDM'
|
122
|
+
loader.inflector.inflect 'ibeacon' => 'IBeacon'
|
123
|
+
loader.inflector.inflect 'powerbroker_identity_services' => 'PowerBroker'
|
124
|
+
loader.inflector.inflect 'admitmac' => 'ADmitMac'
|
125
|
+
loader.inflector.inflect 'ip_address' => 'IPAddress'
|
126
|
+
loader.inflector.inflect 'netboot_server' => 'NetBootServer'
|
127
|
+
loader.inflector.inflect 'vpp_account' => 'VPPAccount'
|
128
|
+
loader.inflector.inflect 'removable_macaddr' => 'RemovableMacAddress'
|
129
|
+
loader.inflector.inflect 'md_prestage_name' => 'MobileDevicePrestageName'
|
130
|
+
loader.inflector.inflect 'md_prestage_names' => 'MobileDevicePrestageNames'
|
131
|
+
loader.inflector.inflect 'md_prestage_skip_setup_items' => 'MobileDevicePrestageSkipSetupItems'
|
132
|
+
loader.inflector.inflect 'macos_managed_updates' => 'MacOSManagedUpdates'
|
133
|
+
|
134
|
+
# deprecations, separated so they load only when used.
|
135
|
+
# When its time to get rid of them, delete the files from the
|
136
|
+
# 'deprecations' directory, and the matching line here.
|
137
|
+
loader.inflector.inflect('deprecated_api_constant' => 'API')
|
138
|
+
loader.inflector.inflect('deprecated_config_constant' => 'CONFIG')
|
139
|
+
loader.inflector.inflect('deprecated_api_connection_class' => 'APIConnection')
|
140
|
+
|
141
|
+
##### Ingored Paths
|
142
|
+
|
143
|
+
# These should be ignored, some will be required directly
|
144
|
+
#####################################
|
145
|
+
|
146
|
+
loader.ignore "#{__dir__}/db_connection.rb"
|
147
|
+
loader.ignore "#{__dir__}/ruby_extensions.rb"
|
148
|
+
loader.ignore "#{__dir__}/ruby_extensions"
|
149
|
+
loader.ignore "#{__dir__}/exceptions.rb"
|
150
|
+
|
151
|
+
lib_dir = Pathname.new(__dir__).parent.to_s
|
152
|
+
loader.ignore "#{lib_dir}/ruby-jss.rb"
|
153
|
+
loader.ignore "#{lib_dir}/jss.rb"
|
154
|
+
loader.ignore "#{lib_dir}/jss-api.rb"
|
155
|
+
|
156
|
+
##### Callbacks
|
157
|
+
|
158
|
+
# callback for when a specific file/constant loads
|
159
|
+
# duplicate and uncomment this if desired to react to
|
160
|
+
# specific things loading
|
161
|
+
#####################################
|
162
|
+
# loader.on_load('Jamf::SomeClass') do |klass, abspath|
|
163
|
+
# Jamf.load_msg "I just loaded #{klass} from #{abspath}"
|
164
|
+
# end
|
165
|
+
|
166
|
+
# callback for when anything loads
|
167
|
+
# - const_path is like "Jamf::SomeClass" or "Jamf::SomeClass::SOME_CONST_ARRY"
|
168
|
+
# - value is the value that constant contains after loading,
|
169
|
+
# e.g. the class Jamf::SomeClass for 'Jamf::SomeClass' or
|
170
|
+
# an Array for the constant "Jamf::SomeClass::SOME_CONST_ARRY"
|
171
|
+
# - abspath is the full path to the file where the constant was loaded from.
|
172
|
+
#####################################
|
173
|
+
loader.on_load do |const_path, value, abspath|
|
174
|
+
load_msg "Zeitwerk just loaded #{value.class} '#{const_path}' from:\n #{abspath}"
|
175
|
+
|
176
|
+
# Parse OAPI_PROPERTIES into getters and setters for subclasses of
|
177
|
+
# OAPIObject in the JPAPI.
|
178
|
+
#
|
179
|
+
# The class we just loaded must have this method and constant
|
180
|
+
# and the method must not have run already for the class or any superclass.
|
181
|
+
# This prevents running parse_oapi_properties again in subclasses that
|
182
|
+
# don't need to do that
|
183
|
+
if value.respond_to?(:oapi_properties_parsed?) && \
|
184
|
+
defined?(value::OAPI_PROPERTIES) && \
|
185
|
+
!value.oapi_properties_parsed?
|
186
|
+
|
187
|
+
parsed = value.parse_oapi_properties
|
188
|
+
load_msg "Parsed OAPI_PROPERTIES for #{value}" if parsed
|
189
|
+
end
|
190
|
+
|
191
|
+
# Generate the identifier list methods (.all_*) for subclasses of APIObject
|
192
|
+
# in the Classic API
|
193
|
+
if value.is_a?(Class) && value.superclass == Jamf::APIObject
|
194
|
+
|
195
|
+
done = value.define_identifier_list_methods
|
196
|
+
load_msg "Defined identifier list methods for #{value}" if done
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
loader.setup
|
201
|
+
end # setup_zeitwerk_loader
|
202
|
+
|
203
|
+
# For testing the Zeitwrk Loader.
|
204
|
+
# Normally we want autoloading on demand,
|
205
|
+
# eager loading loads everything so we can see it
|
206
|
+
#
|
207
|
+
# To make this happen touch the file defined in EAGER_LOAD_FILE
|
208
|
+
def self.eager_load_for_testing
|
209
|
+
return unless EAGER_LOAD_FILE.file?
|
210
|
+
|
211
|
+
loader.eager_load(force: true)
|
212
|
+
warn :loaded
|
213
|
+
# rescue Zeitwerk::NameError => e
|
214
|
+
# warn e.message
|
215
|
+
end
|
216
|
+
|
217
|
+
end # module JamfZeitwerkConfig
|
data/lib/jamf.rb
CHANGED
@@ -54,49 +54,20 @@ require 'jamf/exceptions'
|
|
54
54
|
require 'jamf/db_connection'
|
55
55
|
|
56
56
|
# Configure the Zeitwerk loader, See https://github.com/fxn/zeitwerk
|
57
|
-
require '
|
58
|
-
require 'zeitwerk_config'
|
59
|
-
|
60
|
-
# touch this file to make zeitwerk and mixins send text to stderr as things load
|
61
|
-
# or get mixed in
|
62
|
-
JAMF_VERBOSE_LOADING_FILE = Pathname.new('/tmp/ruby-jss-verbose-loading')
|
63
|
-
|
64
|
-
# Or, set this ENV var to also make zeitverk and mixins send text to stderr
|
65
|
-
JAMF_VERBOSE_LOADING_ENV = 'RUBY_JSS_VERBOSE_LOADING'.freeze
|
66
|
-
|
67
|
-
# touch this file to make zeitwek eager-load everything when the gem is required.
|
68
|
-
JAMF_ZEITWERK_EAGER_LOAD_FILE = Pathname.new('/tmp/ruby-jss-zeitwerk-eager-load')
|
57
|
+
require 'jamf/zeitwerk_config'
|
69
58
|
|
70
59
|
# the `Zeitwerk::Loader.for_gem` creates the loader object, and must
|
71
60
|
# happen in this file, so we pass it into a method defined in
|
72
61
|
# zeitwerk_config
|
73
|
-
setup_zeitwerk_loader Zeitwerk::Loader.for_gem
|
62
|
+
JamfZeitwerkConfig.setup_zeitwerk_loader Zeitwerk::Loader.for_gem
|
74
63
|
|
75
64
|
# Jamf, A Ruby module for interacting with the JAMF Pro Server via both of its REST APIs
|
76
65
|
module Jamf
|
77
66
|
|
78
|
-
|
79
|
-
return if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new(MINIMUM_RUBY_VERSION)
|
80
|
-
|
81
|
-
raise "Can't use ruby-jss #{Jamf::VERSION}, ruby itself must be version #{MINIMUM_RUBY_VERSION} or greater, this is ruby #{RUBY_VERSION}."
|
82
|
-
end
|
83
|
-
|
84
|
-
# Only look at the filesystem once.
|
85
|
-
def self.verbose_loading?
|
86
|
-
return @verbose_loading unless @verbose_loading.nil?
|
87
|
-
|
88
|
-
@verbose_loading = JAMF_VERBOSE_LOADING_FILE.file?
|
89
|
-
@verbose_loading ||= ENV.include? JAMF_VERBOSE_LOADING_ENV
|
90
|
-
@verbose_loading
|
91
|
-
end
|
92
|
-
|
93
|
-
# rubocop: disable Style/StderrPuts
|
67
|
+
# Use the load_msg method defined for Zeitwerk
|
94
68
|
def self.load_msg(msg)
|
95
|
-
|
96
|
-
|
97
|
-
$stderr.puts msg
|
98
|
-
end
|
99
|
-
# rubocop: enable Style/StderrPuts
|
69
|
+
JamfZeitwerkConfig.load_msg msg
|
70
|
+
end
|
100
71
|
|
101
72
|
# the single instance of our configuration object
|
102
73
|
def self.config
|
@@ -113,11 +84,8 @@ module Jamf
|
|
113
84
|
|
114
85
|
end # module Jamf
|
115
86
|
|
116
|
-
# make sure we can run
|
117
|
-
Jamf.validate_ruby_version
|
118
|
-
|
119
87
|
# JSS module is now a synonym for Jamf module
|
120
88
|
JSS = Jamf
|
121
89
|
|
122
|
-
# testing zeitwerk loading
|
123
|
-
eager_load_for_testing
|
90
|
+
# testing zeitwerk loading, the the desired file is present
|
91
|
+
JamfZeitwerkConfig.eager_load_for_testing
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-jss
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.0b5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Lasell
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2022-
|
13
|
+
date: 2022-09-06 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: CFPropertyList
|
@@ -149,7 +149,7 @@ description: |
|
|
149
149
|
'Jamf Pro' API. Jamf Pro objects are implemented as classes and can interact
|
150
150
|
with each other. Authentication tokens, data transfer using JSON or XML and other
|
151
151
|
details are handled automatically under the hood to allow simpler, intuitive
|
152
|
-
automation of Jamf-related
|
152
|
+
automation of Jamf-related tasks.
|
153
153
|
email: ruby-jss@pixar.com
|
154
154
|
executables:
|
155
155
|
- cgrouper
|
@@ -775,10 +775,10 @@ files:
|
|
775
775
|
- lib/jamf/utility.rb
|
776
776
|
- lib/jamf/validate.rb
|
777
777
|
- lib/jamf/version.rb
|
778
|
+
- lib/jamf/zeitwerk_config.rb
|
778
779
|
- lib/jss-api.rb
|
779
780
|
- lib/jss.rb
|
780
781
|
- lib/ruby-jss.rb
|
781
|
-
- lib/zeitwerk_config.rb
|
782
782
|
- test/README-TEST.md
|
783
783
|
- test/bin/runtests
|
784
784
|
- test/lib/jamf_test.rb
|
data/lib/zeitwerk_config.rb
DELETED
@@ -1,168 +0,0 @@
|
|
1
|
-
# Copyright 2022 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
|
-
# Configure the Zeitwerk loader, See https://github.com/fxn/zeitwerk
|
25
|
-
def setup_zeitwerk_loader(loader)
|
26
|
-
@loader = loader
|
27
|
-
|
28
|
-
# Ignore this file (more ignores below)
|
29
|
-
loader.ignore __FILE__
|
30
|
-
|
31
|
-
# these paths all define classes & modules directly below 'Jamf'
|
32
|
-
# If we didn't collapse them, then e.g.
|
33
|
-
# /jamf/api/base_classes/classic/group.rb
|
34
|
-
# would be expected to define
|
35
|
-
# Jamf::Api::BaseClasses::Classic::Group
|
36
|
-
# rather than what we want:
|
37
|
-
# Jamf::Group
|
38
|
-
###################################################
|
39
|
-
|
40
|
-
loader.collapse("#{__dir__}/jamf/api")
|
41
|
-
|
42
|
-
loader.collapse("#{__dir__}/jamf/api/classic")
|
43
|
-
loader.collapse("#{__dir__}/jamf/api/classic/api_objects")
|
44
|
-
loader.collapse("#{__dir__}/jamf/api/classic/base_classes")
|
45
|
-
|
46
|
-
loader.collapse("#{__dir__}/jamf/api/jamf_pro")
|
47
|
-
loader.collapse("#{__dir__}/jamf/api/jamf_pro/api_objects")
|
48
|
-
loader.collapse("#{__dir__}/jamf/api/jamf_pro/mixins")
|
49
|
-
loader.collapse("#{__dir__}/jamf/api/jamf_pro/base_classes")
|
50
|
-
loader.collapse("#{__dir__}/jamf/api/jamf_pro/other_classes")
|
51
|
-
|
52
|
-
loader.collapse("#{__dir__}/jamf/deprecations")
|
53
|
-
|
54
|
-
# filenames => Constants, which don't adhere to zeitwerk's parsing standards.
|
55
|
-
#
|
56
|
-
# Mostly because the a filename like 'oapi_object' would be
|
57
|
-
# loaded by zeitwerk expecting it to define 'OapiObject', but it really
|
58
|
-
# defines 'OAPIObject'
|
59
|
-
###############################################
|
60
|
-
|
61
|
-
# Connections
|
62
|
-
loader.inflector.inflect 'classic_api' => 'ClassicAPI'
|
63
|
-
loader.inflector.inflect 'jamf_pro_api' => 'JamfProAPI'
|
64
|
-
loader.inflector.inflect 'jamf_pro_api_error' => 'JamfProAPIError'
|
65
|
-
|
66
|
-
# API objects, resources, and mixins
|
67
|
-
loader.inflector.inflect 'oapi_schemas' => 'OAPISchemas'
|
68
|
-
loader.inflector.inflect 'oapi_object' => 'OAPIObject'
|
69
|
-
loader.inflector.inflect 'oapi_validate' => 'OAPIValidate'
|
70
|
-
|
71
|
-
loader.inflector.inflect 'jpapi_resource' => 'JPAPIResource'
|
72
|
-
|
73
|
-
loader.inflector.inflect 'api_object' => 'APIObject'
|
74
|
-
loader.inflector.inflect 'xml_workaround' => 'XMLWorkaround'
|
75
|
-
loader.inflector.inflect 'json_object' => 'JSONObject'
|
76
|
-
loader.inflector.inflect 'vppable' => 'VPPable'
|
77
|
-
loader.inflector.inflect 'osx_configuration_profile' => 'OSXConfigurationProfile'
|
78
|
-
loader.inflector.inflect 'jp_extendable' => 'JPExtendable'
|
79
|
-
loader.inflector.inflect 'mdm' => 'MDM'
|
80
|
-
loader.inflector.inflect 'ibeacon' => 'IBeacon'
|
81
|
-
loader.inflector.inflect 'powerbroker_identity_services' => 'PowerBroker'
|
82
|
-
loader.inflector.inflect 'admitmac' => 'ADmitMac'
|
83
|
-
loader.inflector.inflect 'ip_address' => 'IPAddress'
|
84
|
-
loader.inflector.inflect 'netboot_server' => 'NetBootServer'
|
85
|
-
loader.inflector.inflect 'vpp_account' => 'VPPAccount'
|
86
|
-
loader.inflector.inflect 'removable_macaddr' => 'RemovableMacAddress'
|
87
|
-
loader.inflector.inflect 'md_prestage_name' => 'MobileDevicePrestageName'
|
88
|
-
loader.inflector.inflect 'md_prestage_names' => 'MobileDevicePrestageNames'
|
89
|
-
loader.inflector.inflect 'md_prestage_skip_setup_items' => 'MobileDevicePrestageSkipSetupItems'
|
90
|
-
loader.inflector.inflect 'macos_managed_updates' => 'MacOSManagedUpdates'
|
91
|
-
|
92
|
-
# deprecations, separated so they load only when used.
|
93
|
-
# When its time to get rid of them, delete the files from the
|
94
|
-
# 'deprecations' directory, and the matching line here.
|
95
|
-
loader.inflector.inflect('deprecated_api_constant' => 'API')
|
96
|
-
loader.inflector.inflect('deprecated_config_constant' => 'CONFIG')
|
97
|
-
loader.inflector.inflect('deprecated_api_connection_class' => 'APIConnection')
|
98
|
-
|
99
|
-
# These should be ignored, some will be required directly
|
100
|
-
#####################################
|
101
|
-
|
102
|
-
loader.ignore "#{__dir__}/jamf/db_connection.rb"
|
103
|
-
loader.ignore "#{__dir__}/jamf/ruby_extensions.rb"
|
104
|
-
loader.ignore "#{__dir__}/jamf/ruby_extensions"
|
105
|
-
loader.ignore "#{__dir__}/jamf/exceptions.rb"
|
106
|
-
loader.ignore "#{__dir__}/jss-api.rb"
|
107
|
-
loader.ignore "#{__dir__}/jss.rb"
|
108
|
-
loader.ignore "#{__dir__}/ruby-jss.rb"
|
109
|
-
|
110
|
-
# callback for when a specific file/constant loads
|
111
|
-
# duplicate and uncomment this if desired to react to
|
112
|
-
# specific things loading
|
113
|
-
#####################################
|
114
|
-
# loader.on_load('Jamf::SomeClass') do |klass, abspath|
|
115
|
-
# Jamf.load_msg "I just loaded #{klass} from #{abspath}"
|
116
|
-
# end
|
117
|
-
|
118
|
-
# callback for when anything loads
|
119
|
-
# - const_path is like "Jamf::SomeClass" or "Jamf::SomeClass::SOME_CONST_ARRY"
|
120
|
-
# - value is the value that constant contains after loading,
|
121
|
-
# e.g. the class Jamf::SomeClass for 'Jamf::SomeClass' or
|
122
|
-
# an Array for the constant "Jamf::SomeClass::SOME_CONST_ARRY"
|
123
|
-
# - abspath is the full path to the file where the constant was loaded from.
|
124
|
-
#####################################
|
125
|
-
loader.on_load do |const_path, value, abspath|
|
126
|
-
Jamf.load_msg "Zeitwerk just loaded #{value.class} '#{const_path}' from:\n #{abspath}"
|
127
|
-
|
128
|
-
# Parse OAPI_PROPERTIES into getters and setters for subclasses of
|
129
|
-
# OAPIObject in the JPAPI.
|
130
|
-
#
|
131
|
-
# The class we just loaded must have this method and constant
|
132
|
-
# and the method must not have run already for the class or any superclass.
|
133
|
-
# This prevents running parse_oapi_properties again in subclasses that
|
134
|
-
# don't need to do that
|
135
|
-
if value.respond_to?(:oapi_properties_parsed?) && \
|
136
|
-
defined?(value::OAPI_PROPERTIES) && \
|
137
|
-
!value.oapi_properties_parsed?
|
138
|
-
|
139
|
-
parsed = value.parse_oapi_properties
|
140
|
-
Jamf.load_msg "Parsed OAPI_PROPERTIES for #{value}" if parsed
|
141
|
-
end
|
142
|
-
|
143
|
-
# Generate the identifier list methods (.all_*) for subclasses of APIObject
|
144
|
-
# in the Classic API
|
145
|
-
if value.is_a?(Class) && value.superclass == Jamf::APIObject
|
146
|
-
|
147
|
-
done = value.define_identifier_list_methods
|
148
|
-
Jamf.load_msg "Defined identifier list methods for #{value}" if done
|
149
|
-
end
|
150
|
-
end
|
151
|
-
|
152
|
-
loader.setup
|
153
|
-
end # setup_zeitwerk_loader
|
154
|
-
|
155
|
-
# For testing the Zeitwrk Loader.
|
156
|
-
# Normally we want autoloading on demand,
|
157
|
-
# eager loading loads everything so we can see it
|
158
|
-
#
|
159
|
-
# To make this happen touch the file defined in JAMF_ZEITWERK_EAGER_LOAD_FILE
|
160
|
-
# in jamf.rb
|
161
|
-
def eager_load_for_testing
|
162
|
-
return unless JAMF_ZEITWERK_EAGER_LOAD_FILE.file?
|
163
|
-
|
164
|
-
@loader.eager_load(force: true)
|
165
|
-
warn :loaded
|
166
|
-
# rescue Zeitwerk::NameError => e
|
167
|
-
# warn e.message
|
168
|
-
end
|