arosa 0.1.0 → 0.1.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 810cb0bb6cbdd8aa9d5a2a465d99275e4830189fd432110f73984c4840bb3b6c
4
- data.tar.gz: 8c3bd9ece1d575d04151c7d383c000d757050f1784d513335ff0fdc568c2ebe1
3
+ metadata.gz: 35f28ac507aed0a001301603188128a173c4136f70e17073bc5616ce09a9ae06
4
+ data.tar.gz: 558a643ba9b5791a52b0261923cc4e36bbb9938d8e5af4267069a80b462e6afb
5
5
  SHA512:
6
- metadata.gz: 24b4b2ef43dfdc9d01f79bf2d7119998f22372a3e80ce9aa9c348f1346db12916f231dcb2657c6266dc5a985db6a132440818d70bffc68e455c87540c71084a5
7
- data.tar.gz: 9fcb61eb463aab857ad40b6123447ef3cd5908f76266546fa9dcc62123b3b266abfb4801b15a5f5af2dfa5dc2a6d4626f06b64f6013a5ead8128955b11650586
6
+ metadata.gz: 7fece26c0f93ff317797ce437a922b4ce071f620ca45a78d6a3d871fadb4857cf3eb54e95a5df38ff2690858c9fa247e94374be7e96e3d38cc6bd734546388aa
7
+ data.tar.gz: 48e224a93526e8f8076873956d5d8a3b76fbc949fe3b2b901ae4e8d008f3b7663dea751a9586a8aed96ea909402113e5fc79fdab21656eb3581e39d54b7e6ef0
@@ -0,0 +1,29 @@
1
+ name: Push Gem
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - v*
7
+
8
+ permissions:
9
+ contents: read
10
+
11
+ jobs:
12
+ push:
13
+ if: github.repository == 'samuenti/arosa'
14
+ runs-on: ubuntu-latest
15
+
16
+ permissions:
17
+ contents: write
18
+ id-token: write
19
+
20
+ steps:
21
+ - uses: actions/checkout@v4
22
+
23
+ - name: Set up Ruby
24
+ uses: ruby/setup-ruby@v1
25
+ with:
26
+ bundler-cache: true
27
+ ruby-version: ruby
28
+
29
+ - uses: rubygems/release-gem@v1
data/README.md CHANGED
@@ -1,7 +1,11 @@
1
1
  # Arosa
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/arosa.svg)](https://badge.fury.io/rb/arosa) ![Gem Total Downloads](https://img.shields.io/gem/dt/arosa?style=flat&link=https%3A%2F%2Frubygems.org%2Fgems%2Farosa) ![GitHub License](https://img.shields.io/github/license/samuenti/arosa)
4
+
3
5
  Generate [schema.org](https://schema.org) structured data as JSON-LD. Drop it into your pages and let search engines understand your content.
4
6
 
7
+ Arosa works anywhere in your Ruby code. Build the schema, then output it in your view.
8
+
5
9
  ## Installation
6
10
 
7
11
  ```ruby
@@ -10,71 +14,6 @@ gem 'arosa'
10
14
 
11
15
  Then `bundle install`.
12
16
 
13
- ## Usage
14
-
15
- Arosa works anywhere in your Ruby code. Build the schema, then output it in your view.
16
-
17
- Here's an example of an Organization schema:
18
-
19
- ```ruby
20
- @org = Arosa::Schemas::Organization.new(
21
- name: "Acme Corp",
22
- url: "https://acme.com",
23
- logo: "https://acme.com/logo.png",
24
- email: "hello@acme.com",
25
- founding_date: Date.new(2020, 1, 1),
26
- address: Arosa::Schemas::PostalAddress.new(
27
- street_address: "123 Main St",
28
- address_locality: "Zug",
29
- address_country: "CH",
30
- postal_code: "6300"
31
- )
32
- )
33
- ```
34
-
35
- In your view:
36
-
37
- ```erb
38
- <%= @org %>
39
- ```
40
-
41
- Which will output:
42
-
43
- ```html
44
- <script type="application/ld+json">
45
- {
46
- "@context": "https://schema.org",
47
- "@type": "Organization",
48
- "name": "Acme Corp",
49
- "url": "https://acme.com",
50
- "logo": "https://acme.com/logo.png",
51
- "email": "hello@acme.com",
52
- "foundingDate": "2020-01-01",
53
- "address": {
54
- "@type": "PostalAddress",
55
- "streetAddress": "123 Main St",
56
- "addressLocality": "Zug",
57
- "addressCountry": "CH",
58
- "postalCode": "6300"
59
- }
60
- }
61
- </script>
62
- ```
63
-
64
- ## Validation
65
-
66
- Wrong types and unknown properties raise errors immediately:
67
-
68
- ```ruby
69
- Arosa::Schemas::Organization.new(name: 123)
70
- # => ArgumentError: name must be a String, got Integer
71
-
72
- Arosa::Schemas::Organization.new(made_up: "value")
73
- # => NoMethodError: undefined method `made_up='
74
- ```
75
-
76
- No silent failures. If it builds, the markup is valid.
77
-
78
17
  ## Supported Types
79
18
 
80
19
  | Type | Schema.org |
@@ -84,6 +23,7 @@ No silent failures. If it builds, the markup is valid.
84
23
  | [ContactPoint](#contactpoint) | [schema.org/ContactPoint](https://schema.org/ContactPoint) |
85
24
  | [BreadcrumbList](#breadcrumblist) | [schema.org/BreadcrumbList](https://schema.org/BreadcrumbList) |
86
25
  | [ListItem](#listitem) | [schema.org/ListItem](https://schema.org/ListItem) |
26
+ | [Language](#language) | [schema.org/Language](https://schema.org/Language) |
87
27
 
88
28
  More types coming.
89
29
 
@@ -115,7 +55,7 @@ More types coming.
115
55
  | same_as | Array of String |
116
56
 
117
57
  ```ruby
118
- Arosa::Schemas::Organization.new(
58
+ @organisation = Arosa::Schemas::Organization.new(
119
59
  name: "Acme Corp",
120
60
  url: "https://acme.com",
121
61
  logo: "https://acme.com/logo.png",
@@ -139,6 +79,44 @@ Arosa::Schemas::Organization.new(
139
79
  )
140
80
  ```
141
81
 
82
+ In your view:
83
+
84
+ ```erb
85
+ <%= @organisation %>
86
+ ```
87
+
88
+ Output:
89
+
90
+ ```html
91
+ <script type="application/ld+json">
92
+ {
93
+ "@context": "https://schema.org",
94
+ "@type": "Organization",
95
+ "name": "Acme Corp",
96
+ "url": "https://acme.com",
97
+ "logo": "https://acme.com/logo.png",
98
+ "email": "hello@acme.com",
99
+ "foundingDate": "2020-01-01",
100
+ "sameAs": ["https://linkedin.com/company/acme", "https://en.wikipedia.org/wiki/Acme"],
101
+ "address": {
102
+ "@type": "PostalAddress",
103
+ "streetAddress": "123 Main St",
104
+ "addressLocality": "Zug",
105
+ "addressCountry": "CH",
106
+ "postalCode": "6300"
107
+ },
108
+ "contactPoint": {
109
+ "@type": "ContactPoint",
110
+ "contactType": "customer service",
111
+ "telephone": "+1-800-555-1234",
112
+ "email": "support@acme.com"
113
+ }
114
+ }
115
+ </script>
116
+ ```
117
+
118
+ The same pattern applies to all schema types.
119
+
142
120
  ### PostalAddress
143
121
 
144
122
  | Property | Type |
@@ -166,12 +144,24 @@ Arosa::Schemas::PostalAddress.new(
166
144
  | contact_type | String |
167
145
  | telephone | String |
168
146
  | email | String |
147
+ | available_language | Array of String or [Language](#language) |
169
148
 
170
149
  ```ruby
150
+ # Simple: just language codes
171
151
  Arosa::Schemas::ContactPoint.new(
172
152
  contact_type: "customer service",
173
153
  telephone: "+1-800-555-1234",
174
- email: "support@example.com"
154
+ available_language: ["en", "es"]
155
+ )
156
+
157
+ # Detailed: full Language objects
158
+ Arosa::Schemas::ContactPoint.new(
159
+ contact_type: "customer service",
160
+ telephone: "+1-800-555-1234",
161
+ available_language: [
162
+ Arosa::Schemas::Language.new(name: "English", alternate_name: "en"),
163
+ Arosa::Schemas::Language.new(name: "Spanish", alternate_name: "es")
164
+ ]
175
165
  )
176
166
  ```
177
167
 
@@ -209,6 +199,34 @@ Arosa::Schemas::ListItem.new(
209
199
 
210
200
  Note: `item` is optional on the last breadcrumb (the current page).
211
201
 
202
+ ### Language
203
+
204
+ | Property | Type |
205
+ |----------|------|
206
+ | name | String |
207
+ | alternate_name | String |
208
+
209
+ ```ruby
210
+ Arosa::Schemas::Language.new(
211
+ name: "Spanish",
212
+ alternate_name: "es"
213
+ )
214
+ ```
215
+
216
+ ## Validation
217
+
218
+ Wrong types and unknown properties raise errors immediately:
219
+
220
+ ```ruby
221
+ Arosa::Schemas::Organization.new(name: 123)
222
+ # => ArgumentError: name must be a String, got Integer
223
+
224
+ Arosa::Schemas::Organization.new(made_up: "value")
225
+ # => NoMethodError: undefined method `made_up='
226
+ ```
227
+
228
+ No silent failures. If it builds, the markup is valid.
229
+
212
230
  ## License
213
231
 
214
232
  MIT
data/lib/arosa/schema.rb CHANGED
@@ -64,7 +64,7 @@ module Arosa
64
64
  end
65
65
 
66
66
  def to_html
67
- html = %(<script type="application/ld+json">#{to_json}</script>)
67
+ html = %(<script type="application/ld+json" data-turbo-temporary>#{to_json}</script>)
68
68
  html.respond_to?(:html_safe) ? html.html_safe : html
69
69
  end
70
70
 
@@ -77,8 +77,8 @@ module Arosa
77
77
  inner = type.first
78
78
  return if value.is_a?(inner)
79
79
  return if value.is_a?(Array) && value.all? { |v| v.is_a?(inner) }
80
- else
81
- return if value.is_a?(type)
80
+ elsif value.is_a?(type)
81
+ return
82
82
  end
83
83
 
84
84
  raise ArgumentError, "#{name} must be a #{type}, got #{value.class}"
@@ -11,6 +11,7 @@ module Arosa
11
11
  property :contact_type, type: String
12
12
  property :telephone, type: String
13
13
  property :email, type: String
14
+ property :available_language, type: Array
14
15
  end
15
16
  end
16
17
  end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Arosa
4
+ module Schemas
5
+ # Schema.org Language type
6
+ #
7
+ # https://schema.org/Language
8
+ class Language < Schema
9
+ schema_type "Language"
10
+
11
+ property :name, type: String
12
+ property :alternate_name, type: String
13
+ end
14
+ end
15
+ end
data/lib/arosa/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Arosa
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
data/lib/arosa.rb CHANGED
@@ -7,6 +7,7 @@ require_relative "arosa/schema"
7
7
 
8
8
  # Schemas
9
9
  require_relative "arosa/schemas/postal_address"
10
+ require_relative "arosa/schemas/language"
10
11
  require_relative "arosa/schemas/contact_point"
11
12
  require_relative "arosa/schemas/organization"
12
13
  require_relative "arosa/schemas/list_item"
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arosa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuenti
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2026-01-03 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies: []
13
12
  description: A Ruby gem for generating schema.org structured data for rich results.
14
13
  email:
@@ -17,6 +16,7 @@ executables: []
17
16
  extensions: []
18
17
  extra_rdoc_files: []
19
18
  files:
19
+ - ".github/workflows/push_gem.yml"
20
20
  - LICENSE.txt
21
21
  - README.md
22
22
  - Rakefile
@@ -24,6 +24,7 @@ files:
24
24
  - lib/arosa/schema.rb
25
25
  - lib/arosa/schemas/breadcrumb_list.rb
26
26
  - lib/arosa/schemas/contact_point.rb
27
+ - lib/arosa/schemas/language.rb
27
28
  - lib/arosa/schemas/list_item.rb
28
29
  - lib/arosa/schemas/organization.rb
29
30
  - lib/arosa/schemas/postal_address.rb
@@ -36,7 +37,6 @@ metadata:
36
37
  homepage_uri: https://github.com/samuenti/arosa
37
38
  source_code_uri: https://github.com/samuenti/arosa
38
39
  rubygems_mfa_required: 'true'
39
- post_install_message:
40
40
  rdoc_options: []
41
41
  require_paths:
42
42
  - lib
@@ -51,8 +51,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
51
51
  - !ruby/object:Gem::Version
52
52
  version: '0'
53
53
  requirements: []
54
- rubygems_version: 3.4.19
55
- signing_key:
54
+ rubygems_version: 4.0.3
56
55
  specification_version: 4
57
56
  summary: Generate schema.org structured data as JSON-LD
58
57
  test_files: []