vigiles 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/generators/vigiles/initializer_generator.rb +1 -1
- data/lib/generators/vigiles/install_generator.rb +1 -1
- data/lib/generators/vigiles/migration_generator.rb +2 -1
- data/lib/vigiles/archive/response.rb +1 -1
- data/lib/vigiles/constants.rb +161 -1
- data/lib/vigiles/options.rb +1 -0
- data/lib/vigiles/types.rb +6 -0
- data/lib/vigiles/utilities/http.rb +60 -0
- data/lib/vigiles/utilities/json.rb +3 -2
- data/lib/vigiles/version.rb +1 -1
- data/lib/vigiles.rb +15 -3
- metadata +5 -4
- /data/lib/generators/{templates → vigiles/templates}/archive_conversation_migration.rb.erb +0 -0
- /data/lib/generators/{templates → vigiles/templates}/initializer.rb +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5cad76457ae57c5b08da94044394a063e57f5d1e5ea5a8b9cea412876dce12bf
|
4
|
+
data.tar.gz: 6eb84b1766ef2e737652fc63e28924756b8d26d74b676d9f716f1db8e0744c8f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 23a0e61a11a529603eebc7e197961762b493c940a2b33cb510f0f81e419b2379a9a3e207eb236be1a1aae44009cf75f95aec401dc1b3ee95cefad6b678809505
|
7
|
+
data.tar.gz: 697eb918976d40ea0189d9b1de700caeae6931e28f41a6627d055c7c3d6eed4df44cf541d705f2ecb66931549c8af5825cf0177e9835eb2f2a7d2705dcf000b5
|
@@ -3,6 +3,7 @@
|
|
3
3
|
|
4
4
|
require "rails/generators"
|
5
5
|
require "rails/generators/active_record"
|
6
|
+
require "active_record"
|
6
7
|
|
7
8
|
module Vigiles
|
8
9
|
module Generators
|
@@ -12,7 +13,7 @@ module Vigiles
|
|
12
13
|
|
13
14
|
include ::Rails::Generators::Migration
|
14
15
|
|
15
|
-
source_root File.expand_path("
|
16
|
+
source_root File.expand_path("templates", __dir__)
|
16
17
|
|
17
18
|
def install
|
18
19
|
migration_template(
|
data/lib/vigiles/constants.rb
CHANGED
@@ -8,7 +8,167 @@ module Vigiles
|
|
8
8
|
%w[
|
9
9
|
application/json
|
10
10
|
]
|
11
|
-
).freeze,
|
11
|
+
).freeze,
|
12
|
+
T::Set[String]
|
13
|
+
)
|
14
|
+
|
15
|
+
ALL_IANA_CONTENT_TYPES = T.let(
|
16
|
+
{
|
17
|
+
Types::ContentType::ApplicationJson => Set.new(
|
18
|
+
%w[
|
19
|
+
application/3gppHal+json
|
20
|
+
application/3gppHalForms+json
|
21
|
+
application/ace+json
|
22
|
+
application/activity+json
|
23
|
+
application/aif+json
|
24
|
+
application/alto-cdni+json
|
25
|
+
application/alto-cdnifilter+json
|
26
|
+
application/alto-costmap+json
|
27
|
+
application/alto-costmapfilter+json
|
28
|
+
application/alto-directory+json
|
29
|
+
application/alto-endpointprop+json
|
30
|
+
application/alto-endpointpropparams+json
|
31
|
+
application/alto-endpointcost+json
|
32
|
+
application/alto-endpointcostparams+json
|
33
|
+
application/alto-error+json
|
34
|
+
application/alto-networkmapfilter+json
|
35
|
+
application/alto-networkmap+json
|
36
|
+
application/alto-propmap+json
|
37
|
+
application/alto-propmapparams+json
|
38
|
+
application/alto-tips+json
|
39
|
+
application/alto-tipsparams+json
|
40
|
+
application/alto-updatestreamcontrol+json
|
41
|
+
application/alto-updatestreamparams+json
|
42
|
+
application/atsc-rdt+json
|
43
|
+
application/calendar+json
|
44
|
+
application/captive+json
|
45
|
+
application/city+json
|
46
|
+
application/coap-group+json
|
47
|
+
application/csvm+json
|
48
|
+
application/cwl+json
|
49
|
+
application/dicom+json
|
50
|
+
application/dns+json
|
51
|
+
application/elm+json
|
52
|
+
application/EmergencyCallData.LegacyESN+json
|
53
|
+
application/expect-ct-report+json
|
54
|
+
application/fhir+json
|
55
|
+
application/geo+json
|
56
|
+
application/geo+json-seq
|
57
|
+
application/geoxacml+json
|
58
|
+
application/jf2feed+json
|
59
|
+
application/jose+json
|
60
|
+
application/jrd+json
|
61
|
+
application/jscalendar+json
|
62
|
+
application/jscontact+json
|
63
|
+
application/json
|
64
|
+
application/json-patch+json
|
65
|
+
application/json-seq
|
66
|
+
application/jsonpath
|
67
|
+
application/jwk+json
|
68
|
+
application/jwk-set+json
|
69
|
+
application/ld+json
|
70
|
+
application/linkset+json
|
71
|
+
application/manifest+json
|
72
|
+
application/merge-patch+json
|
73
|
+
application/mud+json
|
74
|
+
application/ppsp-tracker+json
|
75
|
+
application/problem+json
|
76
|
+
application/prs.implied-object+json
|
77
|
+
application/prs.implied-object+json-seq
|
78
|
+
application/pvd+json
|
79
|
+
application/rdap+json
|
80
|
+
application/reputon+json
|
81
|
+
application/sarif-external-properties+json
|
82
|
+
application/sarif+json
|
83
|
+
application/scim+json
|
84
|
+
application/senml-etch+json
|
85
|
+
application/senml+json
|
86
|
+
application/sensml+json
|
87
|
+
application/spdx+json
|
88
|
+
application/stix+json
|
89
|
+
application/taxii+json
|
90
|
+
application/td+json
|
91
|
+
application/tlsrpt+json
|
92
|
+
application/tm+json
|
93
|
+
application/vcard+json
|
94
|
+
application/vnd.acm.addressxfer+json
|
95
|
+
application/vnd.acm.chatbot+json
|
96
|
+
application/vnd.amadeus+json
|
97
|
+
application/vnd.apache.thrift.json
|
98
|
+
application/vnd.api+json
|
99
|
+
application/vnd.aplextor.warrp+json
|
100
|
+
application/vnd.apothekende.reservation+json
|
101
|
+
application/vnd.artisan+json
|
102
|
+
application/vnd.avalon+json
|
103
|
+
application/vnd.bbf.usp.msg+json
|
104
|
+
application/vnd.bekitzur-stech+json
|
105
|
+
application/vnd.byu.uapi+json
|
106
|
+
application/vnd.capasystems-pg+json
|
107
|
+
application/vnd.cncf.helm.config.v1+json
|
108
|
+
application/vnd.collection.doc+json
|
109
|
+
application/vnd.collection+json
|
110
|
+
application/vnd.collection.next+json
|
111
|
+
application/vnd.coreos.ignition+json
|
112
|
+
application/vnd.cryptii.pipe+json
|
113
|
+
application/vnd.cyclonedx+json
|
114
|
+
application/vnd.datapackage+json
|
115
|
+
application/vnd.dataresource+json
|
116
|
+
application/vnd.document+json
|
117
|
+
application/vnd.drive+json
|
118
|
+
application/vnd.eclipse.ditto+json
|
119
|
+
application/vnd.eu.kasparian.car+json
|
120
|
+
application/vnd.futoin+json
|
121
|
+
application/vnd.gentics.grd+json
|
122
|
+
application/vnd.geo+json
|
123
|
+
application/vnd.gnu.taler.exchange+json
|
124
|
+
application/vnd.gnu.taler.merchant+json
|
125
|
+
application/vnd.hal+json
|
126
|
+
application/vnd.hc+json
|
127
|
+
application/vnd.heroku+json
|
128
|
+
application/vnd.hyper-item+json
|
129
|
+
application/vnd.hyper+json
|
130
|
+
application/vnd.hyperdrive+json
|
131
|
+
application/vnd.ims.lis.v2.result+json
|
132
|
+
application/vnd.ims.lti.v2.toolconsumerprofile+json
|
133
|
+
application/vnd.ims.lti.v2.toolproxy.id+json
|
134
|
+
application/vnd.ims.lti.v2.toolproxy+json
|
135
|
+
application/vnd.ims.lti.v2.toolsettings+json
|
136
|
+
application/vnd.ims.lti.v2.toolsettings.simple+json
|
137
|
+
application/vnd.ipld.dag-json
|
138
|
+
application/vnd.las.las+json
|
139
|
+
application/vnd.leap+json
|
140
|
+
application/vnd.mason+json
|
141
|
+
application/vnd.micro+json
|
142
|
+
application/vnd.miele+json
|
143
|
+
application/vnd.nacamar.ybrid+json
|
144
|
+
application/vnd.nato.bindingdataobject+json
|
145
|
+
application/vnd.nearst.inv+json
|
146
|
+
application/vnd.oai.workflows+json
|
147
|
+
application/vnd.oci.image.manifest.v1+json
|
148
|
+
application/vnd.oftn.l10n+json
|
149
|
+
application/vnd.oma.lwm2m+json
|
150
|
+
application/vnd.oracle.resource+json
|
151
|
+
application/vnd.pagerduty+json
|
152
|
+
application/vnd.restful+json
|
153
|
+
application/vnd.seis+json
|
154
|
+
application/vnd.shootproof+json
|
155
|
+
application/vnd.shopkick+json
|
156
|
+
application/vnd.siren+json
|
157
|
+
application/vnd.syft+json
|
158
|
+
application/vnd.tableschema+json
|
159
|
+
application/vnd.think-cell.ppttc+json
|
160
|
+
application/vnd.vel+json
|
161
|
+
application/vnd.veritone.aion+json
|
162
|
+
application/vnd.xacml+json
|
163
|
+
application/voucher-cms+json
|
164
|
+
application/webpush-options+json
|
165
|
+
application/yang-data+json
|
166
|
+
application/yang-patch+json
|
167
|
+
application/yang-sid+json
|
168
|
+
].map(&:downcase)
|
169
|
+
).freeze
|
170
|
+
}.freeze,
|
171
|
+
T::Hash[Types::ContentType, T::Set[String]]
|
12
172
|
)
|
13
173
|
|
14
174
|
DEFAULT_CONTENT_TYPE_RECORDERS = T.let(
|
data/lib/vigiles/options.rb
CHANGED
data/lib/vigiles/types.rb
CHANGED
@@ -0,0 +1,60 @@
|
|
1
|
+
# typed: strict
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module Vigiles
|
5
|
+
module Utilities
|
6
|
+
module HTTP
|
7
|
+
extend T::Sig
|
8
|
+
|
9
|
+
WellKnownHttpHeader = Vigiles::Types::WellKnownHttpHeader
|
10
|
+
ContentType = Vigiles::Types::ContentType
|
11
|
+
|
12
|
+
# if http headers could be stemmed, this is what the
|
13
|
+
# method below would have done. at the moment, it works
|
14
|
+
# for only a few headers, and tries to clean up excesses
|
15
|
+
# that are not necessarily part of the value.
|
16
|
+
#
|
17
|
+
# since it raises, do not call unless you have explicitly
|
18
|
+
# handled the header. thanks!
|
19
|
+
sig { params(header: String, value: String).returns(String) }
|
20
|
+
def self.sanitize_header_value(header:, value:)
|
21
|
+
# don't attempt to sanitize values for relatively unknown
|
22
|
+
# headers. for example, custom headers (those with the x
|
23
|
+
# prefix). obviously if the value is blank then no sanitization
|
24
|
+
# is necessary.
|
25
|
+
return value if value.blank? || !well_known?(header)
|
26
|
+
|
27
|
+
case header.downcase
|
28
|
+
when "content-type" then sanitize_content_type(value.strip)
|
29
|
+
else raise ArgumentError, header
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
sig { params(header_value: String).returns(String) }
|
34
|
+
private_class_method def self.sanitize_content_type(header_value)
|
35
|
+
downcased_v = header_value.downcase
|
36
|
+
return ContentType::ApplicationJson.serialize if json?(downcased_v)
|
37
|
+
|
38
|
+
raise
|
39
|
+
end
|
40
|
+
|
41
|
+
sig { params(header: String).returns(T::Boolean) }
|
42
|
+
private_class_method def self.well_known?(header)
|
43
|
+
WellKnownHttpHeader.deserialize(header.downcase)
|
44
|
+
true
|
45
|
+
rescue StandardError
|
46
|
+
false
|
47
|
+
end
|
48
|
+
|
49
|
+
sig { params(header_value: String).returns(T::Boolean) }
|
50
|
+
private_class_method def self.json?(header_value)
|
51
|
+
return false if header_value.blank?
|
52
|
+
|
53
|
+
application_json = T.must(header_value.split(/;/).first)
|
54
|
+
T.must(
|
55
|
+
Constants::ALL_IANA_CONTENT_TYPES[ContentType::ApplicationJson]
|
56
|
+
).include?(application_json)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -8,11 +8,12 @@ module Vigiles
|
|
8
8
|
module JSON
|
9
9
|
extend T::Sig
|
10
10
|
|
11
|
-
sig { params(text: String).returns(T.
|
11
|
+
sig { params(text: String).returns(T.untyped) }
|
12
12
|
def self.parse_benignly(text)
|
13
13
|
::JSON.parse(text)
|
14
14
|
rescue StandardError
|
15
|
-
text
|
15
|
+
return text unless block_given?
|
16
|
+
yield text
|
16
17
|
end
|
17
18
|
end
|
18
19
|
end
|
data/lib/vigiles/version.rb
CHANGED
data/lib/vigiles.rb
CHANGED
@@ -1,13 +1,18 @@
|
|
1
1
|
# typed: strict
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
require "zeitwerk"
|
5
4
|
require "sorbet-runtime"
|
6
5
|
require "action_dispatch"
|
6
|
+
require "zeitwerk"
|
7
|
+
|
7
8
|
require_relative "core_ext"
|
8
9
|
|
9
10
|
loader = Zeitwerk::Loader.for_gem(warn_on_extra_files: false)
|
10
|
-
loader.inflector.inflect(
|
11
|
+
loader.inflector.inflect(
|
12
|
+
"json" => "JSON",
|
13
|
+
"http" => "HTTP",
|
14
|
+
"uri" => "URI"
|
15
|
+
)
|
11
16
|
loader.ignore("#{__dir__}/generators")
|
12
17
|
loader.ignore("#{__dir__}/core_ext.rb")
|
13
18
|
loader.ignore("#{__dir__}/core_ext")
|
@@ -49,7 +54,14 @@ module Vigiles
|
|
49
54
|
|
50
55
|
sig { params(request: ActionDispatch::Request).returns(T::Boolean) }
|
51
56
|
private_class_method def self.content_type_match?(request)
|
52
|
-
|
57
|
+
return false if (content_type = request.content_type).nil?
|
58
|
+
|
59
|
+
spec.request_content_types.include?(
|
60
|
+
Utilities::HTTP.sanitize_header_value(
|
61
|
+
header: "content-type",
|
62
|
+
value: content_type
|
63
|
+
)
|
64
|
+
)
|
53
65
|
end
|
54
66
|
|
55
67
|
sig { params(req: ActionDispatch::Request).returns(T::Boolean) }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vigiles
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yaw Boakye
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-06-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sorbet-runtime
|
@@ -208,11 +208,11 @@ files:
|
|
208
208
|
- lib/core_ext.rb
|
209
209
|
- lib/core_ext/action_dispatch/request.rb
|
210
210
|
- lib/core_ext/object.rb
|
211
|
-
- lib/generators/templates/archive_conversation_migration.rb.erb
|
212
|
-
- lib/generators/templates/initializer.rb
|
213
211
|
- lib/generators/vigiles/initializer_generator.rb
|
214
212
|
- lib/generators/vigiles/install_generator.rb
|
215
213
|
- lib/generators/vigiles/migration_generator.rb
|
214
|
+
- lib/generators/vigiles/templates/archive_conversation_migration.rb.erb
|
215
|
+
- lib/generators/vigiles/templates/initializer.rb
|
216
216
|
- lib/vigiles.rb
|
217
217
|
- lib/vigiles/archive.rb
|
218
218
|
- lib/vigiles/archive/conversation.rb
|
@@ -229,6 +229,7 @@ files:
|
|
229
229
|
- lib/vigiles/options.rb
|
230
230
|
- lib/vigiles/spec.rb
|
231
231
|
- lib/vigiles/types.rb
|
232
|
+
- lib/vigiles/utilities/http.rb
|
232
233
|
- lib/vigiles/utilities/json.rb
|
233
234
|
- lib/vigiles/utilities/uri.rb
|
234
235
|
- lib/vigiles/version.rb
|
File without changes
|
File without changes
|