chook 1.1.5 → 1.1.9

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 (52) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +6 -0
  3. data/LICENSE.txt +5 -3
  4. data/bin/chook-server +7 -25
  5. data/data/chook.conf.example +24 -0
  6. data/data/sample_handlers/RestAPIOperation-executable +6 -24
  7. data/data/sample_handlers/RestAPIOperation.rb +6 -24
  8. data/data/sample_handlers/SmartGroupComputerMembershipChange-executable +6 -23
  9. data/data/sample_handlers/SmartGroupComputerMembershipChange.rb +6 -24
  10. data/lib/chook/configuration.rb +14 -26
  11. data/lib/chook/event/handled_event/handlers.rb +3 -21
  12. data/lib/chook/event/handled_event.rb +7 -24
  13. data/lib/chook/event/handled_event_logger.rb +6 -24
  14. data/lib/chook/event/test_event.rb +21 -30
  15. data/lib/chook/event.rb +6 -25
  16. data/lib/chook/event_handling.rb +6 -24
  17. data/lib/chook/event_testing.rb +6 -24
  18. data/lib/chook/foundation.rb +6 -24
  19. data/lib/chook/handled_events.rb +6 -24
  20. data/lib/chook/handled_subjects.rb +6 -24
  21. data/lib/chook/procs.rb +19 -27
  22. data/lib/chook/server/auth.rb +19 -26
  23. data/lib/chook/server/log.rb +11 -25
  24. data/lib/chook/server/public/css/chook.css +10 -0
  25. data/lib/chook/server/routes/handle_by_name.rb +7 -25
  26. data/lib/chook/server/routes/handle_webhook_event.rb +7 -25
  27. data/lib/chook/server/routes/handlers.rb +6 -24
  28. data/lib/chook/server/routes/home.rb +7 -27
  29. data/lib/chook/server/routes/log.rb +6 -24
  30. data/lib/chook/server/routes/login_logout.rb +6 -25
  31. data/lib/chook/server/routes.rb +11 -29
  32. data/lib/chook/server/views/layout.haml +32 -7
  33. data/lib/chook/server.rb +8 -24
  34. data/lib/chook/subject/computer.rb +14 -32
  35. data/lib/chook/subject/dep_device.rb +13 -31
  36. data/lib/chook/subject/handled_subject.rb +6 -24
  37. data/lib/chook/subject/jss.rb +10 -28
  38. data/lib/chook/subject/mobile_device.rb +12 -30
  39. data/lib/chook/subject/patch_software_title_update.rb +6 -24
  40. data/lib/chook/subject/policy_finished.rb +6 -24
  41. data/lib/chook/subject/push.rb +8 -26
  42. data/lib/chook/subject/rest_api_operation.rb +11 -29
  43. data/lib/chook/subject/scep_challenge.rb +6 -24
  44. data/lib/chook/subject/smart_group.rb +7 -25
  45. data/lib/chook/subject/test_subject.rb +23 -39
  46. data/lib/chook/subject.rb +6 -24
  47. data/lib/chook/test_events.rb +6 -24
  48. data/lib/chook/test_subjects.rb +6 -24
  49. data/lib/chook/version.rb +8 -27
  50. data/lib/chook.rb +6 -24
  51. metadata +11 -12
  52. data/lib/chook/server/public/imgs/ChookLogoAlMcWhiggin.png +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ee82fa5d39fe0144efe36f7d89e9f70434b237f3f71685425cef401e3e77e3c0
4
- data.tar.gz: 26c3d95d95360ae4d2253cce58d8ae6eb7fcdf5d76241ba99622feceecf73e5b
3
+ metadata.gz: f1745b3a5b84635b47e1374c9922d40db13ff99074688be366db780624499944
4
+ data.tar.gz: 5eba3a3db3131dcef9e9e09b28823ef307b57a893932804ff80a0a6d144b2bc9
5
5
  SHA512:
6
- metadata.gz: e01538dfdeae7eab7a338d4ee979ab8d69c0e4d04b9dda69e8815c49c39d38a3943afc3b90df3c3ea96c4c9330e33f0996bec1bf2bffa49286ae1f799e9dcfe3
7
- data.tar.gz: dc949d58fe469d841803347a5841ee0d458f5510c634a52c1a2cd117db068638cb3b7b9300dd5ea90b91f4ec04b52cddf53aae610563374c1592d61911e3a479
6
+ metadata.gz: a6d42e754e7cabdb772f5ce7c53a2a886f5e0090b481b60ccb91c7212ecb9ddac3fe11e0699c383909c427921382b1370df36619a39e74d14d6c12acb6efee95
7
+ data.tar.gz: df3192ffd446740560a3ff3b5e44d44fcebb064c0bd5cde89652baa885afac5aa9210253f382cfda0e3c09cd922bea337d697babb2f07f541c3a1a9521e99401
data/CHANGES.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Chook Change Log
2
2
 
3
+ ## v 1.1.9 2025-10-20
4
+ - Use the 'TOMORROW OPEN SOURCE TECHNOLOGY LICENSE 1.0' (TOST) License
5
+ - The terms are unchanged, but it now has an offical name.
6
+
7
+ ## v 1.1.6 - 1.1.8 Internal Releases only.
8
+
3
9
  ## v 1.1.5 2020-12-11
4
10
 
5
11
  - Add support for handling DeviceAddedToDEP webhook events
data/LICENSE.txt CHANGED
@@ -1,8 +1,8 @@
1
+ TOMORROW OPEN SOURCE TECHNOLOGY LICENSE 1.0
1
2
 
2
- Modified Apache 2.0 License
3
+ The Tomorrow Open Source Technology License 1.0 differs from the original Apache License 2.0 in the following manner. The scope of the trademark grant in section 6 is different.
3
4
 
4
-
5
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
6
 
7
7
  1. Definitions.
8
8
 
@@ -172,3 +172,5 @@
172
172
  defend, and hold each Contributor harmless for any liability
173
173
  incurred by, or claims asserted against, such Contributor by reason
174
174
  of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
data/bin/chook-server CHANGED
@@ -1,31 +1,13 @@
1
- #!/usr/bin/ruby
1
+ #!/usr/bin/env ruby
2
2
 
3
3
  Process.setproctitle('chook')
4
4
 
5
- ### Copyright 2017 Pixar
6
-
7
- ###
8
- ### Licensed under the Apache License, Version 2.0 (the "Apache License")
9
- ### with the following modification; you may not use this file except in
10
- ### compliance with the Apache License and the following modification to it:
11
- ### Section 6. Trademarks. is deleted and replaced with:
12
- ###
13
- ### 6. Trademarks. This License does not grant permission to use the trade
14
- ### names, trademarks, service marks, or product names of the Licensor
15
- ### and its affiliates, except as required to comply with Section 4(c) of
16
- ### the License and to reproduce the content of the NOTICE file.
17
- ###
18
- ### You may obtain a copy of the Apache License at
19
- ###
20
- ### http://www.apache.org/licenses/LICENSE-2.0
21
- ###
22
- ### Unless required by applicable law or agreed to in writing, software
23
- ### distributed under the Apache License with the above modification is
24
- ### distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
25
- ### KIND, either express or implied. See the Apache License for the specific
26
- ### language governing permissions and limitations under the Apache License.
27
- ###
28
- ###
5
+ # Copyright 2025 Pixar
6
+ #
7
+ # Licensed under the terms set forth in the LICENSE.txt file available at
8
+ # at the root of this project.
9
+ #
10
+ #
29
11
 
30
12
  require 'getoptlong'
31
13
 
@@ -122,6 +122,19 @@ webhooks_user_pw:
122
122
  #
123
123
  admin_user:
124
124
 
125
+ #################
126
+ # When admin_users is set to 'use_jamf', it allows anyone who can log in to
127
+ # jamf pro to access the chook web UI.
128
+ #
129
+ # To limit that to a list of specific usernames, put those usernames into this
130
+ # value, comma-separated
131
+ #
132
+ # example:
133
+ # jamf_admins: admin1,admin2,admin3
134
+ # Default: none
135
+ #
136
+ jamf_admins:
137
+
125
138
  #################
126
139
  # When admin page authentication is enabled by setting admin_user, this
127
140
  # tells chook how to learn the password for that user:
@@ -181,3 +194,14 @@ jamf_use_ssl:
181
194
  # Default: none, but /etc/ruby-jss.conf will be honored
182
195
  #
183
196
  jamf_verify_cert:
197
+
198
+ #################
199
+ # Environment Variables to set before starting the server.
200
+ # The value is a comma-separated list of VAR=value pairs.
201
+ # NOTE: do not quote the values.
202
+ # Example:
203
+ # env: FOO=bar,BAZ=this is a value,BANG=42
204
+ #
205
+ # Default: none
206
+ #
207
+ env:
@@ -1,29 +1,11 @@
1
1
  #!/bin/bash
2
2
 
3
- ### Copyright 2017 Pixar
4
-
5
- ###
6
- ### Licensed under the Apache License, Version 2.0 (the "Apache License")
7
- ### with the following modification; you may not use this file except in
8
- ### compliance with the Apache License and the following modification to it:
9
- ### Section 6. Trademarks. is deleted and replaced with:
10
- ###
11
- ### 6. Trademarks. This License does not grant permission to use the trade
12
- ### names, trademarks, service marks, or product names of the Licensor
13
- ### and its affiliates, except as required to comply with Section 4(c) of
14
- ### the License and to reproduce the content of the NOTICE file.
15
- ###
16
- ### You may obtain a copy of the Apache License at
17
- ###
18
- ### http://www.apache.org/licenses/LICENSE-2.0
19
- ###
20
- ### Unless required by applicable law or agreed to in writing, software
21
- ### distributed under the Apache License with the above modification is
22
- ### distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
23
- ### KIND, either express or implied. See the Apache License for the specific
24
- ### language governing permissions and limitations under the Apache License.
25
- ###
26
- ###
3
+ # Copyright 2025 Pixar
4
+ #
5
+ # Licensed under the terms set forth in the LICENSE.txt file available at
6
+ # at the root of this project.
7
+ #
8
+ #
27
9
 
28
10
  # NOTE: Native bash doesn't have any easy way to parse JSON.
29
11
  # Instead, you should really use a tool like 'jq' https://stedolan.github.io/jq/.
@@ -1,27 +1,9 @@
1
- ### Copyright 2017 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
- ###
1
+ # Copyright 2025 Pixar
2
+ #
3
+ # Licensed under the terms set forth in the LICENSE.txt file available at
4
+ # at the root of this project.
5
+ #
6
+ #
25
7
 
26
8
  # this module is just a namespace so we don't conflict with other handlers
27
9
  module APIOpHandler
@@ -1,27 +1,10 @@
1
1
  #!/bin/bash
2
- ### Copyright 2017 Pixar
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
- ###
2
+ # Copyright 2025 Pixar
3
+ #
4
+ # Licensed under the terms set forth in the LICENSE.txt file available at
5
+ # at the root of this project.
6
+ #
7
+ #
25
8
 
26
9
  # NOTE: Native bash doesn't have any easy way to parse JSON.
27
10
  # Instead, you should really use a tool like 'jq' https://stedolan.github.io/jq/.
@@ -1,27 +1,9 @@
1
- ### Copyright 2017 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
- ###
1
+ # Copyright 2025 Pixar
2
+ #
3
+ # Licensed under the terms set forth in the LICENSE.txt file available at
4
+ # at the root of this project.
5
+ #
6
+ #
25
7
 
26
8
  Chook.event_handler do |event|
27
9
  event.logger.debug "Computer Smart Group Changed: #{event.subject.name}"
@@ -1,27 +1,9 @@
1
- ### Copyright 2017 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
- ###
1
+ # Copyright 2025 Pixar
2
+ #
3
+ # Licensed under the terms set forth in the LICENSE.txt file available at
4
+ # at the root of this project.
5
+ #
6
+ #
25
7
 
26
8
  require 'singleton'
27
9
 
@@ -51,17 +33,19 @@ module Chook
51
33
  ssl_private_key_path: Chook::Procs::STRING_TO_PATHNAME,
52
34
  log_file: Chook::Procs::STRING_TO_PATHNAME,
53
35
  log_level: Chook::Procs::STRING_TO_LOG_LEVEL,
54
- log_max_megs: :to_i,
36
+ log_max_megs: :to_i,
55
37
  logs_to_keep: :to_i,
56
38
  webhooks_user: nil,
57
39
  webhooks_user_pw: nil,
58
40
  admin_user: nil,
59
41
  admin_pw: nil,
60
42
  admin_session_expires: :to_i,
43
+ jamf_admins: Chook::Procs::COMMA_STRING_TO_ARRAY,
61
44
  jamf_server: nil,
62
45
  jamf_port: :to_i,
63
46
  jamf_use_ssl: Chook::Procs::STRING_TO_BOOLEAN,
64
- jamf_verify_cert: Chook::Procs::STRING_TO_BOOLEAN
47
+ jamf_verify_cert: Chook::Procs::STRING_TO_BOOLEAN,
48
+ env: Chook::Procs::ENV_FROM_CONFIG
65
49
  }.freeze
66
50
 
67
51
  # Class Variables
@@ -102,6 +86,7 @@ module Chook
102
86
  #
103
87
  def read_global
104
88
  return false unless DEFAULT_CONF_FILE.file? && DEFAULT_CONF_FILE.readable?
89
+
105
90
  read DEFAULT_CONF_FILE
106
91
  end
107
92
 
@@ -114,6 +99,7 @@ module Chook
114
99
  def reload(file = DEFAULT_CONF_FILE)
115
100
  file = Pathname.new file
116
101
  return false unless file.file? && file.readable?
102
+
117
103
  clear_all
118
104
  read file
119
105
  end
@@ -184,8 +170,10 @@ module Chook
184
170
  line.strip =~ /^(\w+?):\s*(\S.*)$/
185
171
  key = Regexp.last_match(1)
186
172
  next unless key
173
+
187
174
  attr = key.to_sym
188
175
  next unless available_conf_keys.include? attr
176
+
189
177
  setter = "#{key}=".to_sym
190
178
  value = Regexp.last_match(2).strip
191
179
 
@@ -1,24 +1,7 @@
1
- # Copyright 2017 Pixar
1
+ # Copyright 2025 Pixar
2
2
  #
3
- # Licensed under the Apache License, Version 2.0 (the "Apache License")
4
- # with the following modification; you may not use this file except in
5
- # compliance with the Apache License and the following modification to it:
6
- # Section 6. Trademarks. is deleted and replaced with:
7
- #
8
- # 6. Trademarks. This License does not grant permission to use the trade
9
- # names, trademarks, service marks, or product names of the Licensor
10
- # and its affiliates, except as required to comply with Section 4(c) of
11
- # the License and to reproduce the content of the NOTICE file.
12
- #
13
- # You may obtain a copy of the Apache License at
14
- #
15
- # http://www.apache.org/licenses/LICENSE-2.0
16
- #
17
- # Unless required by applicable law or agreed to in writing, software
18
- # distributed under the Apache License with the above modification is
19
- # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
20
- # KIND, either express or implied. See the Apache License for the specific
21
- # language governing permissions and limitations under the Apache License.
3
+ # Licensed under the terms set forth in the LICENSE.txt file available at
4
+ # at the root of this project.
22
5
  #
23
6
  #
24
7
 
@@ -260,7 +243,6 @@ module Chook
260
243
  Chook.logger.info "Loading internal general handler file '#{handler_file.basename}' for #{event_name} events"
261
244
  load_internal_handler handler_file
262
245
  handlers[event_name] << @loaded_handler if @loaded_handler
263
-
264
246
  end # self.load_general_handler(handler_file)
265
247
 
266
248
  # Load a named event handler from a file.
@@ -1,27 +1,9 @@
1
- ### Copyright 2017 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
- ###
1
+ # Copyright 2025 Pixar
2
+ #
3
+ # Licensed under the terms set forth in the LICENSE.txt file available at
4
+ # at the root of this project.
5
+ #
6
+ #
25
7
 
26
8
  require 'chook/event/handled_event/handlers'
27
9
 
@@ -96,6 +78,7 @@ module Chook
96
78
  #
97
79
  def self.parse_event(raw_event_json)
98
80
  return nil if raw_event_json.to_s.empty?
81
+
99
82
  event_json = JSON.parse(raw_event_json, symbolize_names: true)
100
83
  event_name = event_json[:webhook][:webhookEvent]
101
84
  Chook::HandledEvents.const_get(event_name).new raw_event_json
@@ -1,27 +1,9 @@
1
- ### Copyright 2017 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
- ###
1
+ # Copyright 2025 Pixar
2
+ #
3
+ # Licensed under the terms set forth in the LICENSE.txt file available at
4
+ # at the root of this project.
5
+ #
6
+ #
25
7
 
26
8
  module Chook
27
9
 
@@ -1,27 +1,9 @@
1
- ### Copyright 2017 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
- ###
1
+ # Copyright 2025 Pixar
2
+ #
3
+ # Licensed under the terms set forth in the LICENSE.txt file available at
4
+ # at the root of this project.
5
+ #
6
+ #
25
7
 
26
8
  module Chook
27
9
 
@@ -37,7 +19,7 @@ module Chook
37
19
  #
38
20
  class TestEvent < Chook::Event
39
21
 
40
- EVENT_ATTRIBUTES = %w(webhook_id webhook_name subject).freeze
22
+ EVENT_ATTRIBUTES = %w[webhook_id webhook_name subject].freeze
41
23
 
42
24
  # For each event type in Chook::Event::EVENTS.keys
43
25
  # generate a TestEvent class for it, set its SUBJECT_CLASS constant
@@ -48,21 +30,26 @@ module Chook
48
30
  def self.generate_classes
49
31
  Chook::Event::EVENTS.each do |classname, subject|
50
32
  next if Chook::TestEvents.const_defined? classname
33
+
51
34
  # make the new TestEvent subclass
52
35
  new_class = Class.new(Chook::TestEvent) do
53
36
  # Setters & Getters
54
37
  EVENT_ATTRIBUTES.each do |attribute|
55
38
  # Getter
56
39
  attr_reader attribute
40
+
57
41
  # Setter
58
42
  if attribute == 'subject'
59
43
  define_method("#{attribute}=") do |new_val|
60
- raise "Invalid TestSubject: Chook::TestEvents::#{classname} requires a Chook::TestSubjects::#{EVENTS[classname]}" unless Chook::Validators.send(:valid_test_subject, classname, new_val)
61
- instance_variable_set(('@' + attribute.to_s), new_val)
44
+ raise "Invalid TestSubject: Chook::TestEvents::#{classname} requires a Chook::TestSubjects::#{EVENTS[classname]}" unless Chook::Validators.send(
45
+ :valid_test_subject, classname, new_val
46
+ )
47
+
48
+ instance_variable_set('@' + attribute.to_s, new_val)
62
49
  end # end define_method
63
50
  else
64
51
  define_method("#{attribute}=") do |new_val|
65
- instance_variable_set(('@' + attribute.to_s), new_val)
52
+ instance_variable_set('@' + attribute.to_s, new_val)
66
53
  end # end define_method
67
54
  end
68
55
  end # end EVENT_ATTRIBUTES.each do |attribute|
@@ -90,6 +77,7 @@ module Chook
90
77
  raw_hash_form['webhook'.to_sym] = { 'webhookEvent'.to_sym => self.class.to_s.split('::')[-1] }
91
78
  EVENT_ATTRIBUTES.each do |json_attribute|
92
79
  next if json_attribute.include? 'json'
80
+
93
81
  if json_attribute == 'subject'
94
82
  raw_hash_form['event'.to_sym] = instance_variable_get('@' + json_attribute).json_hash
95
83
  else
@@ -111,8 +99,10 @@ module Chook
111
99
  #
112
100
  def fire(server_url)
113
101
  raise 'Please provide a destination server URL' unless server_url
102
+
114
103
  uri = URI.parse(server_url)
115
104
  raise 'Please provide a valid destination server URL' if uri.host.nil?
105
+
116
106
  data = json_hash.to_json # This is the structural equivalent of the Chook::Event @raw_json form
117
107
  http_connection = Net::HTTP.new uri.host, uri.port
118
108
  http_connection.post(uri, data)
@@ -128,10 +118,11 @@ module Chook
128
118
  if event_data
129
119
  event_data.each do |key, value|
130
120
  next unless EVENT_ATTRIBUTES.include? key
131
- instance_variable_set(('@' + key.to_s), value)
121
+
122
+ instance_variable_set('@' + key.to_s, value)
132
123
  end # event_data.each
133
124
  else
134
- EVENT_ATTRIBUTES.each { |attribute| instance_variable_set(('@' + attribute.to_s), nil) }
125
+ EVENT_ATTRIBUTES.each { |attribute| instance_variable_set('@' + attribute.to_s, nil) }
135
126
  end # end if event_data
136
127
  end # end init
137
128
 
data/lib/chook/event.rb CHANGED
@@ -1,29 +1,10 @@
1
- ### Copyright 2017 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
-
1
+ # Copyright 2025 Pixar
2
+ #
3
+ # Licensed under the terms set forth in the LICENSE.txt file available at
4
+ # at the root of this project.
26
5
  #
6
+ #
7
+
27
8
  module Chook
28
9
 
29
10
  # This is the MetaClass for all Event objects, both handled and test.
@@ -1,27 +1,9 @@
1
- ### Copyright 2017 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
- ###
1
+ # Copyright 2025 Pixar
2
+ #
3
+ # Licensed under the terms set forth in the LICENSE.txt file available at
4
+ # at the root of this project.
5
+ #
6
+ #
25
7
  # foundation
26
8
  require 'chook/foundation'
27
9