schema_dot_org 1.6.1 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 94b2d07e8efd22d98a9ad76181915fcd2bb91d6b3cf56028c125ff12854d3056
4
- data.tar.gz: b7625ad03b3dc4911b1f5b75db53e2187df6bfd8e74f184537dd9a1b3b631097
3
+ metadata.gz: ce7c69a80d31a953b0ee6b786fa61fdf28b639293471e14bf0b75d5b17ab1149
4
+ data.tar.gz: 502d77fdee47db37eb1de21fd27c432df94b787c21714fdbef0c0cfaab2a47d5
5
5
  SHA512:
6
- metadata.gz: 62860dcaa9d40e17ba4b495cb7e63e64cc46765166c1c5ba9a6d2777fcf93a76492ee3a1279cc95b1fe7e720422992e78f978b05a2b8a60f4258cd9d79396a16
7
- data.tar.gz: 4c0c209701314df1e8a07bf359da709d0285b76eb8e909dfa87c404a0c2efaeee27929c7ef766fc8af99e6ff993f86725d17a13bf09e753518485f113150fb8d
6
+ metadata.gz: df9fef20688ef16fcdcc2131c094d05755b59c913f92a537079a80f8a5d5830b31f49643f6c42304ea9f2dd6dc07f4ad3079f70cd0abff36b531e4a66de76e01
7
+ data.tar.gz: '03698279a36e56a0c114d8e6fa04b090876d076bce1a1d4e47fcb11ba366803e1fbf065a9879d1413a201096e7dcf71a25485c761cdd402c63333c0e949b5c5f'
@@ -1 +1 @@
1
- 2.7.1
1
+ 2.6.6
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
- source "https://rubygems.org"
1
+ source 'https://rubygems.org'
2
2
 
3
- git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
3
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
4
4
 
5
5
  # Specify your gem's dependencies in schema_dot_org.gemspec
6
6
  gemspec
@@ -1,8 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- schema_dot_org (1.6.1)
5
- validated_object (~> 2.0.2)
4
+ schema_dot_org (1.7.0)
5
+ sorbet-runtime (>= 0.5.5890)
6
+ validated_object (~> 2.1)
6
7
 
7
8
  GEM
8
9
  remote: https://rubygems.org/
@@ -19,7 +20,7 @@ GEM
19
20
  diff-lcs (1.4.4)
20
21
  i18n (1.8.5)
21
22
  concurrent-ruby (~> 1.0)
22
- minitest (5.14.1)
23
+ minitest (5.14.2)
23
24
  rake (13.0.1)
24
25
  rspec (3.9.0)
25
26
  rspec-core (~> 3.9.0)
@@ -34,11 +35,16 @@ GEM
34
35
  diff-lcs (>= 1.2.0, < 2.0)
35
36
  rspec-support (~> 3.9.0)
36
37
  rspec-support (3.9.3)
38
+ sorbet (0.5.5890)
39
+ sorbet-static (= 0.5.5890)
40
+ sorbet-runtime (0.5.5890)
41
+ sorbet-static (0.5.5890-universal-darwin-14)
37
42
  thread_safe (0.3.6)
38
43
  tzinfo (1.2.7)
39
44
  thread_safe (~> 0.1)
40
- validated_object (2.0.3)
45
+ validated_object (2.1.0)
41
46
  activemodel (>= 3.2.21)
47
+ sorbet-runtime (>= 0.5.5890)
42
48
  zeitwerk (2.4.0)
43
49
 
44
50
  PLATFORMS
@@ -49,6 +55,7 @@ DEPENDENCIES
49
55
  rake (>= 12.3.3)
50
56
  rspec (~> 3.0)
51
57
  schema_dot_org!
58
+ sorbet (>= 0.5.5890)
52
59
 
53
60
  BUNDLED WITH
54
61
  2.1.4
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
3
 
4
4
  RSpec::Core::RakeTask.new(:spec)
5
5
 
6
- task :default => :spec
6
+ task default: :spec
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "bundler/setup"
4
- require "schema_dot_org"
3
+ require 'bundler/setup'
4
+ require 'schema_dot_org'
5
5
 
6
6
  # You can add fixtures and/or initialization code here to make experimenting
7
7
  # with your gem easier. You can also use a different console, if you like.
@@ -10,5 +10,5 @@ require "schema_dot_org"
10
10
  # require "pry"
11
11
  # Pry.start
12
12
 
13
- require "irb"
13
+ require 'irb'
14
14
  IRB.start(__FILE__)
@@ -1,3 +1,4 @@
1
+ # typed: ignore
1
2
  # frozen_string_literal: true
2
3
 
3
4
  require 'json'
@@ -8,9 +9,8 @@ module SchemaDotOrg
8
9
  # Base class for schema types. Refactors out common code.
9
10
  #
10
11
  class SchemaType < ValidatedObject::Base
11
- ROOT_ATTR = { "@context" => "http://schema.org" }.freeze
12
- UNQUALIFIED_CLASS_NAME_REGEX = /([^:]+)$/
13
-
12
+ ROOT_ATTR = { '@context' => 'http://schema.org' }.freeze
13
+ UNQUALIFIED_CLASS_NAME_REGEX = /([^:]+)$/.freeze
14
14
 
15
15
  def to_s
16
16
  json_string = to_json_ld(pretty: (!rails_production? && !ENV['SCHEMA_DOT_ORG_MINIFIED_JSON']))
@@ -23,12 +23,10 @@ module SchemaDotOrg
23
23
  end
24
24
  end
25
25
 
26
-
27
26
  def to_json_ld(pretty: false)
28
27
  "<script type=\"application/ld+json\">\n" + to_json(pretty: pretty, as_root: true) + "\n</script>"
29
28
  end
30
29
 
31
-
32
30
  def to_json(pretty: false, as_root: false)
33
31
  structure = as_root ? ROOT_ATTR.merge(to_json_struct) : to_json_struct
34
32
 
@@ -39,26 +37,22 @@ module SchemaDotOrg
39
37
  end
40
38
  end
41
39
 
42
-
43
40
  # Use the class name to create the "@type" attribute.
44
41
  # @return a hash structure representing json.
45
42
  def to_json_struct
46
- { "@type" => un_namespaced_classname }.merge(_to_json_struct.compact)
43
+ { '@type' => un_namespaced_classname }.merge(_to_json_struct.compact)
47
44
  end
48
45
 
49
-
50
46
  def _to_json_struct
51
- raise "For subclasses to implement"
47
+ raise 'For subclasses to implement'
52
48
  end
53
49
 
54
-
55
50
  # @return the classname without the module namespace.
56
51
  def un_namespaced_classname
57
52
  self.class.name =~ UNQUALIFIED_CLASS_NAME_REGEX
58
53
  Regexp.last_match(1)
59
54
  end
60
55
 
61
-
62
56
  private
63
57
 
64
58
  def rails_production?
@@ -1,3 +1,4 @@
1
+ # typed: ignore
1
2
  # frozen_string_literal: true
2
3
 
3
4
  require 'date'
@@ -5,7 +6,6 @@ require 'schema_dot_org'
5
6
  require 'schema_dot_org/person'
6
7
  require 'schema_dot_org/place'
7
8
 
8
-
9
9
  module SchemaDotOrg
10
10
  class Organization < SchemaType
11
11
  attr_accessor :email,
@@ -28,14 +28,14 @@ module SchemaDotOrg
28
28
 
29
29
  def _to_json_struct
30
30
  {
31
- "name" => name,
32
- "email" => email,
33
- "url" => url,
34
- "logo" => logo,
35
- "founder" => founder.to_json_struct,
36
- "foundingDate" => founding_date.to_s,
37
- "foundingLocation" => founding_location.to_json_struct,
38
- "sameAs" => same_as
31
+ 'name' => name,
32
+ 'email' => email,
33
+ 'url' => url,
34
+ 'logo' => logo,
35
+ 'founder' => founder.to_json_struct,
36
+ 'foundingDate' => founding_date.to_s,
37
+ 'foundingLocation' => founding_location.to_json_struct,
38
+ 'sameAs' => same_as
39
39
  }
40
40
  end
41
41
  end
@@ -1,18 +1,17 @@
1
+ # typed: ignore
1
2
  # frozen_string_literal: true
2
3
 
3
4
  require 'schema_dot_org'
4
5
 
5
-
6
6
  module SchemaDotOrg
7
7
  # Model the Schema.org `Person`. See http://schema.org/Person
8
8
  class Person < SchemaType
9
9
  attr_accessor :name
10
10
  validates :name, type: String, presence: true
11
11
 
12
-
13
12
  def _to_json_struct
14
13
  {
15
- 'name' => self.name
14
+ 'name' => name
16
15
  }
17
16
  end
18
17
  end
@@ -1,8 +1,8 @@
1
+ # typed: ignore
1
2
  # frozen_string_literal: true
2
3
 
3
4
  require 'schema_dot_org'
4
5
 
5
-
6
6
  module SchemaDotOrg
7
7
  # Model the Schema.org `Thing > Place`. See http://schema.org/Place
8
8
  class Place < SchemaType
@@ -11,7 +11,7 @@ module SchemaDotOrg
11
11
 
12
12
  def _to_json_struct
13
13
  {
14
- 'address' => self.address
14
+ 'address' => address
15
15
  }
16
16
  end
17
17
  end
@@ -1,8 +1,8 @@
1
+ # typed: ignore
1
2
  # frozen_string_literal: true
2
3
 
3
4
  require 'schema_dot_org'
4
5
 
5
-
6
6
  module SchemaDotOrg
7
7
  # Model the Schema.org `Thing > SearchAction`. See http://schema.org/SearchAction
8
8
  class SearchAction < SchemaType
@@ -12,8 +12,8 @@ module SchemaDotOrg
12
12
 
13
13
  def _to_json_struct
14
14
  {
15
- 'target' => self.target,
16
- 'query_input' => self.query_input
15
+ 'target' => target,
16
+ 'query_input' => query_input
17
17
  }
18
18
  end
19
19
  end
@@ -1,9 +1,9 @@
1
+ # typed: ignore
1
2
  # frozen_string_literal: true
2
3
 
3
4
  require 'schema_dot_org'
4
5
  require 'schema_dot_org/search_action'
5
6
 
6
-
7
7
  module SchemaDotOrg
8
8
  # Model the Schema.org `Thing > CreativeWork > WebSite`.
9
9
  # @See http://schema.org/WebSite
@@ -15,9 +15,9 @@ module SchemaDotOrg
15
15
 
16
16
  def _to_json_struct
17
17
  {
18
- 'name' => self.name,
19
- 'url' => self.url,
20
- 'potentialAction' => self.potential_action&.to_json_struct
18
+ 'name' => name,
19
+ 'url' => url,
20
+ 'potentialAction' => potential_action&.to_json_struct
21
21
  }
22
22
  end
23
23
  end
@@ -1,14 +1,19 @@
1
+ # frozen_string_literal: true
2
+
1
3
  lib = File.expand_path('lib', __dir__)
4
+
2
5
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
6
 
4
7
  Gem::Specification.new do |spec|
8
+ spec.required_ruby_version = '>= 2.6'
5
9
  spec.name = 'schema_dot_org'
6
- spec.version = '1.6.1'
10
+ spec.version = '1.7.0'
7
11
  spec.authors = ['Robb Shecter']
8
12
  spec.email = ['robb@public.law']
9
13
 
10
14
  spec.summary = 'JSON-LD generator for Schema.org vocabulary'
11
- spec.description = 'Creates well-formed website metadata with strongly typed Ruby.'
15
+ spec.description = 'Creates well-formed website metadata with ' \
16
+ 'strongly typed Ruby.'
12
17
  spec.homepage = 'https://github.com/public-law/schema-dot-org'
13
18
  spec.license = 'MIT'
14
19
 
@@ -19,9 +24,12 @@ Gem::Specification.new do |spec|
19
24
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
25
  spec.require_paths = ['lib']
21
26
 
22
- spec.add_dependency 'validated_object', '~> 2.0.2'
27
+ spec.add_dependency 'validated_object', '~> 2.1'
23
28
 
24
29
  spec.add_development_dependency 'bundler', '~> 2'
25
30
  spec.add_development_dependency 'rake', '>= 12.3.3'
26
31
  spec.add_development_dependency 'rspec', '~> 3.0'
32
+ spec.add_development_dependency 'sorbet', '>= 0.5.5890'
33
+
34
+ spec.add_runtime_dependency 'sorbet-runtime', '>= 0.5.5890'
27
35
  end
@@ -0,0 +1,2 @@
1
+ --dir
2
+ .
@@ -0,0 +1,262 @@
1
+ # This file is autogenerated. Do not edit it by hand. Regenerate it with:
2
+ # srb rbi gems
3
+
4
+ # typed: ignore
5
+ #
6
+ # If you would like to make changes to this file, great! Please create the gem's shim here:
7
+ #
8
+ # https://github.com/sorbet/sorbet-typed/new/master?filename=lib/activemodel/all/activemodel.rbi
9
+ #
10
+ # activemodel-6.0.3.2
11
+
12
+ module ActiveModel
13
+ def self.eager_load!; end
14
+ def self.gem_version; end
15
+ def self.version; end
16
+ extend ActiveSupport::Autoload
17
+ end
18
+ module ActiveModel::VERSION
19
+ end
20
+ module ActiveModel::Serializers
21
+ extend ActiveSupport::Autoload
22
+ end
23
+ module ActiveModel::Validations
24
+ def errors; end
25
+ def initialize_dup(other); end
26
+ def invalid?(context = nil); end
27
+ def raise_validation_error; end
28
+ def read_attribute_for_validation(*arg0); end
29
+ def run_validations!; end
30
+ def valid?(context = nil); end
31
+ def validate!(context = nil); end
32
+ def validate(context = nil); end
33
+ def validates_with(*args, &block); end
34
+ extend ActiveSupport::Concern
35
+ end
36
+ module ActiveModel::Validations::ClassMethods
37
+ def _parse_validates_options(options); end
38
+ def _validates_default_keys; end
39
+ def attribute_method?(attribute); end
40
+ def clear_validators!; end
41
+ def inherited(base); end
42
+ def validate(*args, &block); end
43
+ def validates!(*attributes); end
44
+ def validates(*attributes); end
45
+ def validates_each(*attr_names, &block); end
46
+ def validates_with(*args, &block); end
47
+ def validators; end
48
+ def validators_on(*attributes); end
49
+ end
50
+ module ActiveModel::Validations::Clusivity
51
+ def check_validity!; end
52
+ def delimiter; end
53
+ def include?(record, value); end
54
+ def inclusion_method(enumerable); end
55
+ end
56
+ class ActiveModel::Validator
57
+ def initialize(options = nil); end
58
+ def kind; end
59
+ def options; end
60
+ def self.kind; end
61
+ def validate(record); end
62
+ end
63
+ class ActiveModel::EachValidator < ActiveModel::Validator
64
+ def attributes; end
65
+ def check_validity!; end
66
+ def initialize(options); end
67
+ def validate(record); end
68
+ def validate_each(record, attribute, value); end
69
+ end
70
+ class ActiveModel::BlockValidator < ActiveModel::EachValidator
71
+ def initialize(options, &block); end
72
+ def validate_each(record, attribute, value); end
73
+ end
74
+ class ActiveModel::Validations::InclusionValidator < ActiveModel::EachValidator
75
+ def validate_each(record, attribute, value); end
76
+ include ActiveModel::Validations::Clusivity
77
+ end
78
+ module ActiveModel::Validations::HelperMethods
79
+ def _merge_attributes(attr_names); end
80
+ def validates_absence_of(*attr_names); end
81
+ def validates_acceptance_of(*attr_names); end
82
+ def validates_confirmation_of(*attr_names); end
83
+ def validates_exclusion_of(*attr_names); end
84
+ def validates_format_of(*attr_names); end
85
+ def validates_inclusion_of(*attr_names); end
86
+ def validates_length_of(*attr_names); end
87
+ def validates_numericality_of(*attr_names); end
88
+ def validates_presence_of(*attr_names); end
89
+ def validates_size_of(*attr_names); end
90
+ end
91
+ class ActiveModel::Validations::AbsenceValidator < ActiveModel::EachValidator
92
+ def validate_each(record, attr_name, value); end
93
+ end
94
+ class ActiveModel::Validations::NumericalityValidator < ActiveModel::EachValidator
95
+ def allow_only_integer?(record); end
96
+ def check_validity!; end
97
+ def filtered_options(value); end
98
+ def is_hexadecimal_literal?(raw_value); end
99
+ def is_integer?(raw_value); end
100
+ def is_number?(raw_value); end
101
+ def parse_as_number(raw_value); end
102
+ def record_attribute_changed_in_place?(record, attr_name); end
103
+ def validate_each(record, attr_name, value); end
104
+ end
105
+ module ActiveModel::Validations::Callbacks
106
+ def run_validations!; end
107
+ extend ActiveSupport::Concern
108
+ end
109
+ module ActiveModel::Validations::Callbacks::ClassMethods
110
+ def after_validation(*args, &block); end
111
+ def before_validation(*args, &block); end
112
+ end
113
+ class ActiveModel::Validations::ExclusionValidator < ActiveModel::EachValidator
114
+ def validate_each(record, attribute, value); end
115
+ include ActiveModel::Validations::Clusivity
116
+ end
117
+ class ActiveModel::Validations::ConfirmationValidator < ActiveModel::EachValidator
118
+ def confirmation_value_equal?(record, attribute, value, confirmed); end
119
+ def initialize(options); end
120
+ def setup!(klass); end
121
+ def validate_each(record, attribute, value); end
122
+ end
123
+ class ActiveModel::Validations::FormatValidator < ActiveModel::EachValidator
124
+ def check_options_validity(name); end
125
+ def check_validity!; end
126
+ def option_call(record, name); end
127
+ def record_error(record, attribute, name, value); end
128
+ def regexp_using_multiline_anchors?(regexp); end
129
+ def validate_each(record, attribute, value); end
130
+ end
131
+ class ActiveModel::Validations::PresenceValidator < ActiveModel::EachValidator
132
+ def validate_each(record, attr_name, value); end
133
+ end
134
+ class ActiveModel::Validations::LengthValidator < ActiveModel::EachValidator
135
+ def check_validity!; end
136
+ def initialize(options); end
137
+ def skip_nil_check?(key); end
138
+ def validate_each(record, attribute, value); end
139
+ end
140
+ class ActiveModel::Validations::AcceptanceValidator < ActiveModel::EachValidator
141
+ def acceptable_option?(value); end
142
+ def initialize(options); end
143
+ def setup!(klass); end
144
+ def validate_each(record, attribute, value); end
145
+ end
146
+ class ActiveModel::Validations::AcceptanceValidator::LazilyDefineAttributes < Module
147
+ def ==(other); end
148
+ def attributes; end
149
+ def define_on(klass); end
150
+ def included(klass); end
151
+ def initialize(attributes); end
152
+ def matches?(method_name); end
153
+ end
154
+ class ActiveModel::Validations::WithValidator < ActiveModel::EachValidator
155
+ def validate_each(record, attr, val); end
156
+ end
157
+ class ActiveModel::ValidationError < StandardError
158
+ def initialize(model); end
159
+ def model; end
160
+ end
161
+ class ActiveModel::Name
162
+ def !~(**, &&); end
163
+ def <=>(**, &&); end
164
+ def ==(arg); end
165
+ def ===(arg); end
166
+ def =~(**, &&); end
167
+ def _singularize(string); end
168
+ def as_json(**, &&); end
169
+ def cache_key; end
170
+ def collection; end
171
+ def element; end
172
+ def eql?(**, &&); end
173
+ def human(options = nil); end
174
+ def i18n_key; end
175
+ def initialize(klass, namespace = nil, name = nil); end
176
+ def match?(**, &&); end
177
+ def name; end
178
+ def param_key; end
179
+ def plural; end
180
+ def route_key; end
181
+ def singular; end
182
+ def singular_route_key; end
183
+ def to_s(**, &&); end
184
+ def to_str(**, &&); end
185
+ include Comparable
186
+ end
187
+ module ActiveModel::Naming
188
+ def model_name; end
189
+ def self.extended(base); end
190
+ def self.model_name_from_record_or_class(record_or_class); end
191
+ def self.param_key(record_or_class); end
192
+ def self.plural(record_or_class); end
193
+ def self.route_key(record_or_class); end
194
+ def self.singular(record_or_class); end
195
+ def self.singular_route_key(record_or_class); end
196
+ def self.uncountable?(record_or_class); end
197
+ end
198
+ module ActiveModel::Callbacks
199
+ def _define_after_model_callback(klass, callback); end
200
+ def _define_around_model_callback(klass, callback); end
201
+ def _define_before_model_callback(klass, callback); end
202
+ def define_model_callbacks(*callbacks); end
203
+ def self.extended(base); end
204
+ end
205
+ module ActiveModel::Translation
206
+ def human_attribute_name(attribute, options = nil); end
207
+ def i18n_scope; end
208
+ def lookup_ancestors; end
209
+ include ActiveModel::Naming
210
+ end
211
+ class ActiveModel::Errors
212
+ def [](attribute); end
213
+ def add(attribute, message = nil, options = nil); end
214
+ def added?(attribute, message = nil, options = nil); end
215
+ def apply_default_array(hash); end
216
+ def as_json(options = nil); end
217
+ def blank?; end
218
+ def clear; end
219
+ def copy!(other); end
220
+ def count; end
221
+ def delete(key); end
222
+ def details; end
223
+ def each; end
224
+ def empty?; end
225
+ def full_message(attribute, message); end
226
+ def full_messages; end
227
+ def full_messages_for(attribute); end
228
+ def generate_message(attribute, type = nil, options = nil); end
229
+ def has_key?(attribute); end
230
+ def include?(attribute); end
231
+ def init_with(coder); end
232
+ def initialize(base); end
233
+ def initialize_dup(other); end
234
+ def key?(attribute); end
235
+ def keys; end
236
+ def marshal_dump; end
237
+ def marshal_load(array); end
238
+ def merge!(other); end
239
+ def messages; end
240
+ def normalize_detail(message, options); end
241
+ def normalize_message(attribute, message, options); end
242
+ def of_kind?(attribute, message = nil); end
243
+ def self.i18n_customize_full_message; end
244
+ def self.i18n_customize_full_message=(arg0); end
245
+ def size; end
246
+ def slice!(*keys); end
247
+ def to_a; end
248
+ def to_hash(full_messages = nil); end
249
+ def to_xml(options = nil); end
250
+ def values; end
251
+ def without_default_proc(hash); end
252
+ include Enumerable
253
+ end
254
+ class ActiveModel::StrictValidationFailed < StandardError
255
+ end
256
+ class ActiveModel::RangeError < RangeError
257
+ end
258
+ class ActiveModel::UnknownAttributeError < NoMethodError
259
+ def attribute; end
260
+ def initialize(record, attribute); end
261
+ def record; end
262
+ end