ruby-jss 1.2.3 → 1.2.4a1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. checksums.yaml +4 -4
  2. data/lib/jamf.rb +169 -0
  3. data/lib/jamf/api/abstract_classes/collection_resource.rb +422 -0
  4. data/lib/jamf/api/abstract_classes/generic_reference.rb +145 -0
  5. data/lib/jamf/api/abstract_classes/json_object.rb +1074 -0
  6. data/lib/jamf/api/abstract_classes/prestage.rb +219 -0
  7. data/lib/jamf/api/abstract_classes/prestage_skip_setup_items.rb +126 -0
  8. data/lib/jamf/api/abstract_classes/resource.rb +250 -0
  9. data/lib/jamf/api/abstract_classes/singleton_resource.rb +87 -0
  10. data/lib/jamf/api/attribute_classes/ip_address.rb +66 -0
  11. data/lib/jamf/api/attribute_classes/timestamp.rb +144 -0
  12. data/lib/jamf/api/connection.rb +734 -0
  13. data/lib/jamf/api/connection/api_error.rb +111 -0
  14. data/lib/jamf/api/connection/api_error_styleguide.rb +96 -0
  15. data/lib/jamf/api/connection/token.rb +220 -0
  16. data/lib/jamf/api/json_objects/account_prefs.rb +79 -0
  17. data/lib/jamf/api/json_objects/android_details.rb +139 -0
  18. data/lib/jamf/api/json_objects/appletv_details.rb +110 -0
  19. data/lib/jamf/api/json_objects/attachment.rb +68 -0
  20. data/lib/jamf/api/json_objects/cellular_network.rb +151 -0
  21. data/lib/jamf/api/json_objects/change_log_entry.rb +77 -0
  22. data/lib/jamf/api/json_objects/computer_prestage_skip_setup_items.rb +67 -0
  23. data/lib/jamf/api/json_objects/country.rb +51 -0
  24. data/lib/jamf/api/json_objects/extension_attribute_value.rb +128 -0
  25. data/lib/jamf/api/json_objects/installed_application.rb +59 -0
  26. data/lib/jamf/api/json_objects/installed_certificate.rb +53 -0
  27. data/lib/jamf/api/json_objects/installed_configuration_profile.rb +67 -0
  28. data/lib/jamf/api/json_objects/installed_ebook.rb +58 -0
  29. data/lib/jamf/api/json_objects/installed_provisioning_profile.rb +59 -0
  30. data/lib/jamf/api/json_objects/inventory_preload_extension_attribute.rb +52 -0
  31. data/lib/jamf/api/json_objects/ios_details.rb +244 -0
  32. data/lib/jamf/api/json_objects/location.rb +95 -0
  33. data/lib/jamf/api/json_objects/md_prestage_name.rb +57 -0
  34. data/lib/jamf/api/json_objects/md_prestage_names.rb +82 -0
  35. data/lib/jamf/api/json_objects/md_prestage_skip_setup_items.rb +165 -0
  36. data/lib/jamf/api/json_objects/mobile_device_details.rb +219 -0
  37. data/lib/jamf/api/json_objects/mobile_device_security.rb +101 -0
  38. data/lib/jamf/api/json_objects/prestage_assignment.rb +61 -0
  39. data/lib/jamf/api/json_objects/prestage_location.rb +104 -0
  40. data/lib/jamf/api/json_objects/prestage_purchasing_data.rb +132 -0
  41. data/lib/jamf/api/json_objects/prestage_scope.rb +54 -0
  42. data/lib/jamf/api/json_objects/prestage_sync_status.rb +63 -0
  43. data/lib/jamf/api/json_objects/purchasing_data.rb +125 -0
  44. data/lib/jamf/api/mixins/abstract.rb +58 -0
  45. data/lib/jamf/api/mixins/bulk_deletable.rb +39 -0
  46. data/lib/jamf/api/mixins/change_log.rb +136 -0
  47. data/lib/jamf/api/mixins/extendable.rb +75 -0
  48. data/lib/jamf/api/mixins/immutable.rb +39 -0
  49. data/lib/jamf/api/mixins/locatable.rb +124 -0
  50. data/lib/jamf/api/mixins/lockable.rb +48 -0
  51. data/lib/jamf/api/mixins/referable.rb +92 -0
  52. data/lib/jamf/api/mixins/searchable.rb +202 -0
  53. data/lib/jamf/api/mixins/uncreatable.rb +40 -0
  54. data/lib/jamf/api/mixins/undeletable.rb +40 -0
  55. data/lib/jamf/api/resources/collection_resources/account.rb +163 -0
  56. data/lib/jamf/api/resources/collection_resources/building.rb +114 -0
  57. data/lib/jamf/api/resources/collection_resources/category.rb +82 -0
  58. data/lib/jamf/api/resources/collection_resources/computer.rb +49 -0
  59. data/lib/jamf/api/resources/collection_resources/computer_prestage.rb +80 -0
  60. data/lib/jamf/api/resources/collection_resources/department.rb +79 -0
  61. data/lib/jamf/api/resources/collection_resources/extension_attribute.rb +45 -0
  62. data/lib/jamf/api/resources/collection_resources/inventory_preload_record.rb +274 -0
  63. data/lib/jamf/api/resources/collection_resources/md_prestage.rb +139 -0
  64. data/lib/jamf/api/resources/collection_resources/mobile_device.rb +315 -0
  65. data/lib/jamf/api/resources/collection_resources/script.rb +190 -0
  66. data/lib/jamf/api/resources/collection_resources/site.rb +77 -0
  67. data/lib/jamf/api/resources/singleton_resources/app_store_country_codes.rb +131 -0
  68. data/lib/jamf/api/resources/singleton_resources/authorization.rb +88 -0
  69. data/lib/jamf/api/resources/singleton_resources/client_checkin_settings.rb +139 -0
  70. data/lib/jamf/api/resources/singleton_resources/reenrollment_settings.rb +95 -0
  71. data/lib/jamf/client.rb +301 -0
  72. data/lib/jamf/client/jamf_binary.rb +132 -0
  73. data/lib/jamf/client/jamf_helper.rb +298 -0
  74. data/lib/jamf/client/management_action.rb +114 -0
  75. data/lib/jamf/compatibility.rb +88 -0
  76. data/lib/jamf/composer.rb +190 -0
  77. data/lib/jamf/configuration.rb +281 -0
  78. data/lib/jamf/exceptions.rb +107 -0
  79. data/lib/jamf/ruby_extensions.rb +36 -0
  80. data/lib/jamf/ruby_extensions/array.rb +35 -0
  81. data/lib/jamf/ruby_extensions/array/predicates.rb +46 -0
  82. data/lib/jamf/ruby_extensions/array/utils.rb +47 -0
  83. data/lib/jamf/ruby_extensions/filetest.rb +32 -0
  84. data/lib/jamf/ruby_extensions/filetest/predicates.rb +46 -0
  85. data/lib/jamf/ruby_extensions/hash.rb +33 -0
  86. data/lib/jamf/ruby_extensions/hash/backports.rb +92 -0
  87. data/lib/jamf/ruby_extensions/ipaddr.rb +37 -0
  88. data/lib/jamf/ruby_extensions/ipaddr/utils.rb +95 -0
  89. data/lib/jamf/ruby_extensions/object.rb +30 -0
  90. data/lib/jamf/ruby_extensions/object/predicates.rb +51 -0
  91. data/lib/jamf/ruby_extensions/pathname.rb +39 -0
  92. data/lib/jamf/ruby_extensions/pathname/predicates.rb +50 -0
  93. data/lib/jamf/ruby_extensions/pathname/utils.rb +75 -0
  94. data/lib/jamf/ruby_extensions/string.rb +35 -0
  95. data/lib/jamf/ruby_extensions/string/backports.rb +66 -0
  96. data/lib/jamf/ruby_extensions/string/conversions.rb +65 -0
  97. data/lib/jamf/ruby_extensions/string/predicates.rb +47 -0
  98. data/lib/jamf/utility.rb +423 -0
  99. data/lib/jamf/validate.rb +224 -0
  100. data/lib/jamf/version.rb +32 -0
  101. data/lib/jpapi.rb +26 -0
  102. data/lib/jss/version.rb +1 -1
  103. metadata +104 -4
@@ -0,0 +1,37 @@
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/ipaddr/utils'
27
+
28
+
29
+ ############################################
30
+ ### A few augmentations to IPAddr handling.
31
+ ###
32
+ class IPAddr
33
+
34
+ include JamfRubyExtensions::IPAddr::Utils
35
+
36
+
37
+ end # Class IPAddr
@@ -0,0 +1,95 @@
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 IPAddr
27
+
28
+ module Utils
29
+
30
+ ### Convert starting and ending IPv4 IP addresses (either Strings or IPAddrs)
31
+ ### into a single masked IPv4 IPAddr
32
+ ###
33
+ ### @param starting[Strings, IPAddr] the starting IP address
34
+ ###
35
+ ### @param ending[Strings, IPAddr] the ending IP address
36
+ ###
37
+ ### @return [IPAddr] the IP address range represented as a masked IPv4 address
38
+ ###
39
+ ### @example
40
+ ### IPAddr.j_masked_v4addr '10.0.0.0', '10.0.0.255' # => #<IPAddr: IPv4:10.0.0.0/255.255.255.0>
41
+ ###
42
+ def self.j_masked_v4addr(starting,ending)
43
+ IPAddr.new "#{starting}/#{self.j_cidr_from_ends(starting,ending)}"
44
+ end #self.j_masked_v4addr(starting,ending)
45
+
46
+ ### Given starting and ending IPv4 IP addresses (either Strings or IPAddrs)
47
+ ### return the CIDR notation routing prefix mask
48
+ ###
49
+ ### @param starting[Strings, IPAddr] the starting IP address
50
+ ###
51
+ ### @param ending[Strings, IPAddr] the ending IP address
52
+ ###
53
+ ### @return [FixNum] the CIDR notation routing prefix mask
54
+ ###
55
+ ### @example
56
+ ### IPAddr.j_cidr_from_ends '10.0.0.0', '10.0.0.255' # => 24
57
+ ###
58
+ def self.j_cidr_from_ends(starting,ending)
59
+
60
+ starting = IPAddr.new(starting) unless starting.kind_of? IPAddr
61
+ ending = IPAddr.new(ending) unless ending.kind_of? IPAddr
62
+
63
+ ### how many possible addresses in the range?
64
+ num_addrs = ending.to_i - starting.to_i + 1
65
+
66
+ ### convert the number of possible addresses to
67
+ ### binary then subtract the number of bits from
68
+ ### the full length of an IPv4 addr
69
+ ### (32 bits) and that gives the CIDR prefix
70
+ return 32 - num_addrs.to_s(2).length + 1
71
+
72
+ end #self.get_cidr(starting,ending)
73
+
74
+ ### Convert a starting address (either String or IPAddr) and a
75
+ ### CIDR notation routing prefix mask into the IPv4 address
76
+ ### of at the end of the range of addresses.
77
+ ###
78
+ ### @param starting[Strings, IPAddr] the starting IP address
79
+ ###
80
+ ### @param cidr[FixNum] the CIDR mask
81
+ ###
82
+ ### @return [IPAddr] the ending IP address of the range.
83
+ ###
84
+ ### @example
85
+ ### IPAddr.j_ending_address '10.0.0.0', 24 # => #<IPAddr: IPv4:10.0.0.255>
86
+ ###
87
+ def self.j_ending_address(starting, cidr)
88
+ IPAddr.new( "#{starting}/#{cidr}").to_range.max
89
+ end # ending_address
90
+
91
+ end # module
92
+
93
+ end # module
94
+
95
+ end # module
@@ -0,0 +1,30 @@
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
+ require 'jamf/ruby_extensions/object/predicates'
24
+
25
+ # include the modules loaded above
26
+ class Object
27
+
28
+ include JamfRubyExtensions::Object::Predicates
29
+
30
+ end
@@ -0,0 +1,51 @@
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 Object
29
+
30
+ module Predicates
31
+
32
+ # is an object an explict true or false?
33
+ #
34
+ # TODO: globally replace
35
+ # `JSS::TRUE_FALSE.include? xxx`
36
+ # with
37
+ # `xxx.j_boolean?`
38
+ #
39
+ #
40
+ # @return [Boolean]
41
+ #
42
+ def j_boolean?
43
+ [true, false].include? self
44
+ end
45
+ alias j_bool? j_boolean?
46
+
47
+ end # module
48
+
49
+ end # module
50
+
51
+ end # module
@@ -0,0 +1,39 @@
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
+ ############################################
27
+ # Some handy additions to the Pathname class.
28
+ # Why aren't they there already?
29
+
30
+ require 'jamf/ruby_extensions/pathname/utils'
31
+ require 'jamf/ruby_extensions/pathname/predicates'
32
+
33
+ # include the modules loaded above
34
+ class Pathname
35
+
36
+ include JamfRubyExtensions::Pathname::Predicates
37
+ include JamfRubyExtensions::Pathname::Utils
38
+
39
+ end
@@ -0,0 +1,50 @@
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 Pathname
29
+
30
+ module Predicates
31
+
32
+ # Is this a real file rather than a symlink?
33
+ # @see FileTest.real_file
34
+ def j_real_file?
35
+ FileTest.real_file? self
36
+ end # real_file?
37
+
38
+ # does a path include another?
39
+ # i.e. is 'other' a descendant of self ?
40
+ def j_include?(other)
41
+ eps = expand_path.to_s
42
+ oeps = other.expand_path.to_s
43
+ oeps != eps && oeps.start_with?(eps)
44
+ end
45
+
46
+ end # module
47
+
48
+ end # module
49
+
50
+ end # module
@@ -0,0 +1,75 @@
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 Pathname
27
+
28
+ module Utils
29
+
30
+ # Copy a path to a destination
31
+ # @see FileUtils.cp
32
+ def j_cp(dest, options = {})
33
+ FileUtils.cp @path, dest.to_s, options
34
+ end # cp
35
+
36
+ # Recursively copy this path to a destination
37
+ # @see FileUtils.cp_r
38
+ def j_cp_r(dest, options = {})
39
+ FileUtils.cp_r @path, dest.to_s, options
40
+ end # cp
41
+
42
+ # Write some string content to a file.
43
+ #
44
+ # Simpler than always using an open('w') block
45
+ # *CAUTION* this overwrites files!
46
+ #
47
+ def j_save(content)
48
+ self.open('w') { |f| f.write content.to_s }
49
+ end
50
+
51
+ # Append some string content to a file.
52
+ #
53
+ # Simpler than always using an open('a') block
54
+ #
55
+ def j_append(content)
56
+ self.open('a') { |f| f.write content.to_s }
57
+ end
58
+
59
+ # Touching can sometimes be good
60
+ #
61
+ # @see FileUtils.touch
62
+ def j_touch
63
+ FileUtils.touch @path
64
+ end
65
+
66
+ # Pathname should use FileUtils.chown, not File.chown
67
+ def j_chown(usr, grp)
68
+ FileUtils.chown usr, grp, @path
69
+ end
70
+
71
+ end # module
72
+
73
+ end # module
74
+
75
+ end # module
@@ -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
+ require 'jamf/ruby_extensions/string/conversions'
25
+ require 'jamf/ruby_extensions/string/predicates'
26
+ require 'jamf/ruby_extensions/string/backports'
27
+
28
+ # include the modules loaded above
29
+ class String
30
+
31
+ include JamfRubyExtensions::String::Predicates
32
+ include JamfRubyExtensions::String::Conversions
33
+ include JamfRubyExtensions::String::BackPorts
34
+
35
+ end
@@ -0,0 +1,66 @@
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 String
27
+
28
+ module BackPorts
29
+
30
+ # Ruby 2.5 + has these handy delete_* methods
31
+ unless Jamf::BLANK.respond_to? :delete_prefix
32
+
33
+ def delete_prefix(pfx)
34
+ sub /\A#{pfx}/, Jamf::BLANK
35
+ end
36
+
37
+ def delete_prefix!(pfx)
38
+ sub! /\A#{pfx}/, Jamf::BLANK
39
+ end
40
+
41
+ def delete_suffix(sfx)
42
+ sub /#{sfx}\z/, Jamf::BLANK
43
+ end
44
+
45
+ def delete_suffix!(sfx)
46
+ sub! /#{sfx}\z/, Jamf::BLANK
47
+ end
48
+
49
+ end # unless
50
+
51
+ # String#casecmp? - its in Ruby 2.4+
52
+ unless Jamf::BLANK.respond_to? :casecmp?
53
+
54
+ def casecmp?(other)
55
+ return nil unless other.is_a? String
56
+
57
+ casecmp(other).zero?
58
+ end
59
+
60
+ end # unless
61
+
62
+ end # module
63
+
64
+ end # module
65
+
66
+ end # module