w3c_api 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 +4 -4
- data/LICENSE.md +1 -1
- data/README.adoc +845 -436
- data/lib/w3c_api/cli.rb +20 -20
- data/lib/w3c_api/client.rb +66 -195
- data/lib/w3c_api/commands/affiliation.rb +33 -33
- data/lib/w3c_api/commands/ecosystem.rb +47 -47
- data/lib/w3c_api/commands/group.rb +68 -68
- data/lib/w3c_api/commands/output_formatter.rb +11 -11
- data/lib/w3c_api/commands/participation.rb +20 -22
- data/lib/w3c_api/commands/series.rb +26 -26
- data/lib/w3c_api/commands/specification.rb +77 -52
- data/lib/w3c_api/commands/translation.rb +18 -18
- data/lib/w3c_api/commands/user.rb +60 -60
- data/lib/w3c_api/hal.rb +164 -0
- data/lib/w3c_api/models/account.rb +44 -0
- data/lib/w3c_api/models/affiliation.rb +54 -65
- data/lib/w3c_api/models/affiliation_index.rb +11 -0
- data/lib/w3c_api/models/call_for_translation.rb +15 -39
- data/lib/w3c_api/models/chair_index.rb +11 -0
- data/lib/w3c_api/models/charter.rb +48 -89
- data/lib/w3c_api/models/charter_index.rb +11 -0
- data/lib/w3c_api/models/connected_account.rb +21 -30
- data/lib/w3c_api/models/ecosystem.rb +20 -42
- data/lib/w3c_api/models/{ecosystems.rb → ecosystem_index.rb} +4 -10
- data/lib/w3c_api/models/evangelist_index.rb +11 -0
- data/lib/w3c_api/models/extension.rb +5 -7
- data/lib/w3c_api/models/group.rb +63 -142
- data/lib/w3c_api/models/group_index.rb +12 -0
- data/lib/w3c_api/models/join_emails.rb +5 -7
- data/lib/w3c_api/models/participant_index.rb +11 -0
- data/lib/w3c_api/models/participation.rb +31 -90
- data/lib/w3c_api/models/participation_index.rb +11 -0
- data/lib/w3c_api/models/photo.rb +26 -0
- data/lib/w3c_api/models/serie.rb +21 -51
- data/lib/w3c_api/models/{series.rb → serie_index.rb} +22 -13
- data/lib/w3c_api/models/spec_version.rb +69 -83
- data/lib/w3c_api/models/spec_version_index.rb +13 -0
- data/lib/w3c_api/models/spec_version_ref.rb +11 -13
- data/lib/w3c_api/models/specification.rb +54 -66
- data/lib/w3c_api/models/specification_index.rb +10 -0
- data/lib/w3c_api/models/team_contact_index.rb +11 -0
- data/lib/w3c_api/models/testimonial.rb +17 -0
- data/lib/w3c_api/models/translation.rb +33 -72
- data/lib/w3c_api/models/{translations.rb → translation_index.rb} +4 -12
- data/lib/w3c_api/models/user.rb +95 -165
- data/lib/w3c_api/models/user_index.rb +11 -0
- data/lib/w3c_api/models.rb +35 -12
- data/lib/w3c_api/version.rb +1 -1
- data/lib/w3c_api.rb +3 -2
- metadata +35 -19
- data/lib/w3c_api/models/affiliations.rb +0 -33
- data/lib/w3c_api/models/base.rb +0 -39
- data/lib/w3c_api/models/call_for_translation_ref.rb +0 -15
- data/lib/w3c_api/models/charters.rb +0 -17
- data/lib/w3c_api/models/collection_base.rb +0 -79
- data/lib/w3c_api/models/delegate_enumerable.rb +0 -54
- data/lib/w3c_api/models/groups.rb +0 -38
- data/lib/w3c_api/models/link.rb +0 -17
- data/lib/w3c_api/models/participations.rb +0 -17
- data/lib/w3c_api/models/series_collection.rb +0 -17
- data/lib/w3c_api/models/spec_versions.rb +0 -17
- data/lib/w3c_api/models/specifications.rb +0 -17
- data/lib/w3c_api/models/users.rb +0 -44
data/lib/w3c_api/models/serie.rb
CHANGED
@@ -1,11 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
require_relative 'link'
|
5
|
-
|
3
|
+
# https://api.w3.org/specification-series/css-backgrounds
|
6
4
|
# {
|
7
5
|
# "shortname": "css-backgrounds",
|
8
|
-
# "name": "CSS Backgrounds and Borders
|
6
|
+
# "name": "CSS Backgrounds and Borders",
|
9
7
|
# "_links": {
|
10
8
|
# "self": {
|
11
9
|
# "href": "https://api.w3.org/specification-series/css-backgrounds"
|
@@ -18,7 +16,7 @@ require_relative 'link'
|
|
18
16
|
# }
|
19
17
|
# }
|
20
18
|
# }
|
21
|
-
|
19
|
+
|
22
20
|
# {
|
23
21
|
# "shortname": "2dcontext",
|
24
22
|
# "name": "HTML Canvas 2D Context",
|
@@ -36,53 +34,25 @@ require_relative 'link'
|
|
36
34
|
# }
|
37
35
|
|
38
36
|
module W3cApi
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
client.series_specifications(shortname)
|
58
|
-
end
|
59
|
-
|
60
|
-
# Get current specification in this series
|
61
|
-
def current_specification(client = nil)
|
62
|
-
return nil unless client && _links&.current_specification
|
63
|
-
|
64
|
-
href = _links.current_specification.href
|
65
|
-
shortname = href.split('/').last
|
66
|
-
client.specification(shortname)
|
67
|
-
end
|
68
|
-
|
69
|
-
def self.from_response(response)
|
70
|
-
transformed_response = transform_keys(response)
|
71
|
-
|
72
|
-
series = new
|
73
|
-
transformed_response.each do |key, value|
|
74
|
-
case key
|
75
|
-
when :_links
|
76
|
-
links = value.each_with_object({}) do |(link_name, link_data), acc|
|
77
|
-
acc[link_name] = Link.new(href: link_data[:href], title: link_data[:title])
|
78
|
-
end
|
79
|
-
series._links = SerieLinks.new(links)
|
80
|
-
else
|
81
|
-
series.send("#{key}=", value) if series.respond_to?("#{key}=")
|
82
|
-
end
|
83
|
-
end
|
84
|
-
series
|
37
|
+
module Models
|
38
|
+
class Serie < Lutaml::Hal::Resource
|
39
|
+
attribute :shortname, :string
|
40
|
+
attribute :name, :string
|
41
|
+
attribute :href, :string
|
42
|
+
attribute :title, :string
|
43
|
+
|
44
|
+
hal_link :self, key: 'self', realize_class: 'Serie'
|
45
|
+
hal_link :specifications, key: 'specifications', realize_class: 'SpecificationIndex'
|
46
|
+
hal_link :current_specification, key: 'current-specification', realize_class: 'SpecVersion'
|
47
|
+
|
48
|
+
key_value do
|
49
|
+
%i[
|
50
|
+
shortname
|
51
|
+
name
|
52
|
+
].each do |key|
|
53
|
+
map key.to_s.tr('_', '-'), to: key
|
85
54
|
end
|
86
55
|
end
|
87
56
|
end
|
57
|
+
end
|
88
58
|
end
|
@@ -1,14 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'lutaml/model'
|
4
3
|
require_relative 'serie'
|
5
|
-
require_relative 'delegate_enumerable'
|
6
|
-
require_relative 'collection_base'
|
7
4
|
|
5
|
+
# https://api.w3.org/specification-series
|
8
6
|
# {
|
9
7
|
# "page": 1,
|
10
|
-
# "limit":
|
11
|
-
# "pages":
|
8
|
+
# "limit": 100,
|
9
|
+
# "pages": 15,
|
12
10
|
# "total": 1426,
|
13
11
|
# "_links": {
|
14
12
|
# "specification-series": [
|
@@ -28,14 +26,25 @@ require_relative 'collection_base'
|
|
28
26
|
# "href": "https://api.w3.org/specification-series/accessibility-metrics-report",
|
29
27
|
# "title": "accessibility-metrics-report"
|
30
28
|
# },
|
31
|
-
|
29
|
+
# ],
|
30
|
+
# "self": {
|
31
|
+
# "href": "https://api.w3.org/specification-series?page=1&items=100"
|
32
|
+
# },
|
33
|
+
# "first": {
|
34
|
+
# "href": "https://api.w3.org/specification-series?page=1&items=100"
|
35
|
+
# },
|
36
|
+
# "last": {
|
37
|
+
# "href": "https://api.w3.org/specification-series?page=15&items=100"
|
38
|
+
# },
|
39
|
+
# "next": {
|
40
|
+
# "href": "https://api.w3.org/specification-series?page=2&items=100"
|
41
|
+
# }
|
42
|
+
# }
|
43
|
+
# }
|
32
44
|
module W3cApi
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
delegate_enumerable :series
|
38
|
-
collection_instance_class Serie, :series
|
39
|
-
end
|
45
|
+
module Models
|
46
|
+
class SerieIndex < Lutaml::Hal::Page
|
47
|
+
hal_link :series, key: 'specification-series', realize_class: 'Serie', collection: true
|
40
48
|
end
|
49
|
+
end
|
41
50
|
end
|
@@ -1,96 +1,82 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
require_relative 'link'
|
5
|
-
|
6
|
-
# Example spec version response format:
|
3
|
+
# https://api.w3.org/specifications/html5/versions/20180327
|
7
4
|
# {
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
#
|
5
|
+
# "status": "Retired",
|
6
|
+
# "rec-track": true,
|
7
|
+
# "uri": "https://www.w3.org/TR/2018/SPSD-html5-20180327/",
|
8
|
+
# "date": "2018-03-27",
|
9
|
+
# "informative": false,
|
10
|
+
# "title": "HTML5",
|
11
|
+
# "shortlink": "https://www.w3.org/TR/html5/",
|
12
|
+
# "_links": {
|
13
|
+
# "self": {
|
14
|
+
# "href": "https://api.w3.org/specifications/html5/versions/20180327"
|
15
|
+
# },
|
16
|
+
# "editors": {
|
17
|
+
# "href": "https://api.w3.org/specifications/html5/versions/20180327/editors"
|
18
|
+
# },
|
19
|
+
# "deliverers": {
|
20
|
+
# "href": "https://api.w3.org/specifications/html5/versions/20180327/deliverers"
|
21
|
+
# },
|
22
|
+
# "specification": {
|
23
|
+
# "href": "https://api.w3.org/specifications/html5"
|
24
|
+
# },
|
25
|
+
# "predecessor-version": {
|
26
|
+
# "href": "https://api.w3.org/specifications/html5/versions/20180327/predecessors"
|
27
|
+
# }
|
22
28
|
# }
|
23
|
-
# }
|
24
29
|
# }
|
25
30
|
|
26
31
|
module W3cApi
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
attribute :href, :string
|
46
|
-
attribute :shortlink, :string, pattern: %r{https://www\.w3\.org/.*}
|
47
|
-
attribute :translation, :string
|
48
|
-
attribute :errata, :string
|
49
|
-
attribute :process_rules, :string
|
50
|
-
attribute :_links, SpecVersionLinks
|
51
|
-
|
52
|
-
# Return the specification this version belongs to
|
53
|
-
def specification(client = nil)
|
54
|
-
return nil unless client && _links&.specification
|
55
|
-
|
56
|
-
spec_href = _links.specification.href
|
57
|
-
spec_shortname = spec_href.split('/').last
|
58
|
-
|
59
|
-
client.specification(spec_shortname)
|
60
|
-
end
|
61
|
-
|
62
|
-
# Check if this spec version is a Recommendation
|
63
|
-
def recommendation?
|
64
|
-
status == 'REC'
|
65
|
-
end
|
66
|
-
|
67
|
-
# Check if this spec version is a Working Draft
|
68
|
-
def working_draft?
|
69
|
-
status == 'WD'
|
70
|
-
end
|
71
|
-
|
72
|
-
# Check if this spec version is a Candidate Recommendation
|
73
|
-
def candidate_recommendation?
|
74
|
-
status == 'CR'
|
75
|
-
end
|
32
|
+
module Models
|
33
|
+
class SpecVersion < Lutaml::Hal::Resource
|
34
|
+
attribute :status, :string
|
35
|
+
attribute :rec_track, :boolean
|
36
|
+
attribute :editor_draft, :string
|
37
|
+
attribute :uri, :string
|
38
|
+
attribute :date, :date_time
|
39
|
+
attribute :last_call_feedback_due, :date_time
|
40
|
+
attribute :pr_reviews_date, :date_time
|
41
|
+
attribute :implementation_feedback_due, :date_time
|
42
|
+
attribute :per_reviews_due, :date_time
|
43
|
+
attribute :informative, :boolean
|
44
|
+
attribute :title, :string
|
45
|
+
attribute :href, :string
|
46
|
+
attribute :shortlink, :string
|
47
|
+
attribute :translation, :string
|
48
|
+
attribute :errata, :string
|
49
|
+
attribute :process_rules, :string
|
76
50
|
|
77
|
-
|
78
|
-
|
51
|
+
hal_link :self, key: 'self', realize_class: 'SpecVersion'
|
52
|
+
hal_link :editors, key: 'editors', realize_class: 'UserIndex'
|
53
|
+
hal_link :deliverers, key: 'deliverers', realize_class: 'UserIndex'
|
54
|
+
hal_link :specification, key: 'specification', realize_class: 'Specification'
|
55
|
+
hal_link :predecessor_version, key: 'predecessor-version', realize_class: 'SpecVersionIndex'
|
56
|
+
hal_link :successor_version, key: 'successor-version', realize_class: 'SpecVersionIndex'
|
79
57
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
58
|
+
key_value do
|
59
|
+
%i[
|
60
|
+
status
|
61
|
+
rec_track
|
62
|
+
editor_draft
|
63
|
+
uri
|
64
|
+
date
|
65
|
+
last_call_feedback_due
|
66
|
+
pr_reviews_date
|
67
|
+
implementation_feedback_due
|
68
|
+
per_reviews_due
|
69
|
+
informative
|
70
|
+
title
|
71
|
+
href
|
72
|
+
shortlink
|
73
|
+
translation
|
74
|
+
errata
|
75
|
+
process_rules
|
76
|
+
].each do |key|
|
77
|
+
map key.to_s.tr('_', '-'), to: key
|
93
78
|
end
|
94
79
|
end
|
95
80
|
end
|
81
|
+
end
|
96
82
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'spec_version'
|
4
|
+
|
5
|
+
module W3cApi
|
6
|
+
module Models
|
7
|
+
class SpecVersionIndex < Lutaml::Hal::Page
|
8
|
+
hal_link :spec_versions, key: 'version-history', realize_class: 'SpecVersion', collection: true
|
9
|
+
hal_link :predecessor_version, key: 'predecessor-version', realize_class: 'SpecVersionIndex', collection: true
|
10
|
+
hal_link :successor_version, key: 'successor-version', realize_class: 'SpecVersionIndex', collection: true
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -1,18 +1,16 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'lutaml/model'
|
4
|
-
|
5
3
|
module W3cApi
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
end
|
4
|
+
module Models
|
5
|
+
class SpecVersionRef < Lutaml::Model::Serializable
|
6
|
+
attribute :status, :string
|
7
|
+
attribute :rec_track, :boolean
|
8
|
+
attribute :editor_draft, :string
|
9
|
+
attribute :uri, :string
|
10
|
+
attribute :date, :string
|
11
|
+
attribute :title, :string
|
12
|
+
attribute :shortlink, :string
|
13
|
+
attribute :process_rules, :string
|
17
14
|
end
|
15
|
+
end
|
18
16
|
end
|
@@ -1,79 +1,67 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
require_relative 'link'
|
5
|
-
|
3
|
+
# https://api.w3.org/specifications/html5
|
6
4
|
# {
|
7
|
-
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
#
|
22
|
-
#
|
23
|
-
#
|
24
|
-
#
|
25
|
-
#
|
26
|
-
#
|
27
|
-
#
|
28
|
-
#
|
5
|
+
# "shortlink": "https://www.w3.org/TR/html5/",
|
6
|
+
# "description": "<p>This specification defines the 5th major revision of the core language of the World Wide Web: the Hypertext Markup Language (HTML). In this version, new features are introduced to help Web application authors, new elements are introduced based on research into prevailing authoring practices, and special attention has been given to defining clear conformance criteria for user agents in an effort to improve interoperability.</p>",
|
7
|
+
# "title": "HTML5",
|
8
|
+
# "shortname": "html5",
|
9
|
+
# "series-version": "5",
|
10
|
+
# "_links": {
|
11
|
+
# "self": {
|
12
|
+
# "href": "https://api.w3.org/specifications/html5"
|
13
|
+
# },
|
14
|
+
# "version-history": {
|
15
|
+
# "href": "https://api.w3.org/specifications/html5/versions"
|
16
|
+
# },
|
17
|
+
# "first-version": {
|
18
|
+
# "href": "https://api.w3.org/specifications/html5/versions/20080122",
|
19
|
+
# "title": "Working Draft"
|
20
|
+
# },
|
21
|
+
# "latest-version": {
|
22
|
+
# "href": "https://api.w3.org/specifications/html5/versions/20180327",
|
23
|
+
# "title": "Retired"
|
24
|
+
# },
|
25
|
+
# "supersedes": {
|
26
|
+
# "href": "https://api.w3.org/specifications/html5/supersedes"
|
27
|
+
# },
|
28
|
+
# "series": {
|
29
|
+
# "href": "https://api.w3.org/specification-series/html"
|
30
|
+
# }
|
29
31
|
# }
|
30
|
-
# }
|
31
32
|
# }
|
32
33
|
|
33
34
|
module W3cApi
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
class Specification < Base
|
44
|
-
attribute :shortlink, :string
|
45
|
-
attribute :description, :string
|
46
|
-
attribute :title, :string
|
47
|
-
attribute :href, :string
|
48
|
-
attribute :shortname, :string
|
49
|
-
attribute :editor_draft, :string
|
50
|
-
attribute :series_version, :string
|
51
|
-
attribute :_links, SpecificationLinks
|
52
|
-
|
53
|
-
# Return versions of this specification
|
54
|
-
def versions(client = nil)
|
55
|
-
return nil unless client && shortname
|
56
|
-
|
57
|
-
client.specification_versions(shortname)
|
58
|
-
end
|
35
|
+
module Models
|
36
|
+
class Specification < Lutaml::Hal::Resource
|
37
|
+
attribute :shortlink, :string
|
38
|
+
attribute :description, :string
|
39
|
+
attribute :title, :string
|
40
|
+
attribute :href, :string
|
41
|
+
attribute :shortname, :string
|
42
|
+
attribute :editor_draft, :string
|
43
|
+
attribute :series_version, :string
|
59
44
|
|
60
|
-
|
61
|
-
|
45
|
+
hal_link :self, key: 'self', realize_class: 'Specification'
|
46
|
+
hal_link :version_history, key: 'version-history', realize_class: 'SpecVersionIndex'
|
47
|
+
hal_link :first_version, key: 'first-version', realize_class: 'SpecVersion'
|
48
|
+
hal_link :latest_version, key: 'latest-version', realize_class: 'SpecVersion'
|
49
|
+
hal_link :supersedes, key: 'supersedes', realize_class: 'SpecificationIndex', collection: true
|
50
|
+
hal_link :series, key: 'series', realize_class: 'Serie'
|
62
51
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
end
|
75
|
-
spec
|
52
|
+
key_value do
|
53
|
+
%i[
|
54
|
+
shortlink
|
55
|
+
description
|
56
|
+
title
|
57
|
+
href
|
58
|
+
shortname
|
59
|
+
editor_draft
|
60
|
+
series_version
|
61
|
+
].each do |key|
|
62
|
+
map key.to_s.tr('_', '-'), to: key
|
76
63
|
end
|
77
64
|
end
|
78
65
|
end
|
66
|
+
end
|
79
67
|
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module W3cApi
|
4
|
+
module Models
|
5
|
+
# SpecificationIndex class that models `/specifications`
|
6
|
+
class SpecificationIndex < Lutaml::Hal::Page
|
7
|
+
hal_link :specifications, key: 'specifications', realize_class: 'Specification', collection: true
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'lutaml/hal'
|
2
|
+
|
3
|
+
# "testimonials": {
|
4
|
+
# "en": "Google's mission is to organize the world’s information and make it universally accessible and useful."
|
5
|
+
# },
|
6
|
+
|
7
|
+
module W3cApi
|
8
|
+
module Models
|
9
|
+
class Testimonial < Lutaml::Hal::Resource
|
10
|
+
attribute :en, :string
|
11
|
+
|
12
|
+
key_value do
|
13
|
+
map 'en', to: :en
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -1,8 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative '
|
4
|
-
require_relative 'call_for_translation_ref'
|
5
|
-
require_relative 'link'
|
3
|
+
require_relative 'call_for_translation'
|
6
4
|
require_relative 'user'
|
7
5
|
|
8
6
|
# {
|
@@ -85,78 +83,41 @@ require_relative 'user'
|
|
85
83
|
# }
|
86
84
|
|
87
85
|
module W3cApi
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
attribute :call_for_translation, CallForTranslationRef
|
103
|
-
attribute :comments, :string
|
104
|
-
attribute :states, :string, collection: true
|
105
|
-
attribute :translators, User, collection: true
|
106
|
-
attribute :_links, TranslationLinks
|
107
|
-
|
108
|
-
# Parse date strings to Date objects
|
109
|
-
def published_date
|
110
|
-
Date.parse(published) if published
|
111
|
-
rescue Date::Error
|
112
|
-
nil
|
113
|
-
end
|
114
|
-
|
115
|
-
def updated_date
|
116
|
-
Date.parse(updated) if updated
|
117
|
-
rescue Date::Error
|
118
|
-
nil
|
119
|
-
end
|
120
|
-
|
121
|
-
# Get the call for translation as a CallForTranslation object
|
122
|
-
def call_for_translation_object
|
123
|
-
return nil unless call_for_translation
|
124
|
-
|
125
|
-
Models::CallForTranslation.new(call_for_translation)
|
126
|
-
end
|
127
|
-
|
128
|
-
# Get the specification version associated with this translation
|
129
|
-
def specification_version(client = nil)
|
130
|
-
return nil unless call_for_translation&.spec_version
|
131
|
-
|
132
|
-
call_for_translation.spec_version
|
133
|
-
end
|
86
|
+
module Models
|
87
|
+
class Translation < Lutaml::Hal::Resource
|
88
|
+
attribute :uri, :string
|
89
|
+
attribute :title, :string
|
90
|
+
attribute :href, :string
|
91
|
+
attribute :language, :string
|
92
|
+
attribute :published, :date_time
|
93
|
+
attribute :updated, :date_time
|
94
|
+
attribute :authorized, :boolean
|
95
|
+
attribute :lto_name, :string
|
96
|
+
attribute :call_for_translation, CallForTranslation
|
97
|
+
attribute :comments, :string
|
98
|
+
attribute :states, :string, collection: true
|
99
|
+
attribute :translators, User, collection: true
|
134
100
|
|
135
|
-
|
136
|
-
transformed_response = transform_keys(response)
|
101
|
+
hal_link :self, key: 'self', realize_class: 'Translation'
|
137
102
|
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
else
|
155
|
-
translation.send("#{key}=", value) if translation.respond_to?("#{key}=")
|
156
|
-
end
|
157
|
-
end
|
158
|
-
translation
|
103
|
+
key_value do
|
104
|
+
%i[
|
105
|
+
uri
|
106
|
+
title
|
107
|
+
href
|
108
|
+
language
|
109
|
+
published
|
110
|
+
updated
|
111
|
+
authorized
|
112
|
+
lto_name
|
113
|
+
call_for_translation
|
114
|
+
comments
|
115
|
+
states
|
116
|
+
translators
|
117
|
+
].each do |key|
|
118
|
+
map key.to_s.tr('_', '-'), to: key
|
159
119
|
end
|
160
120
|
end
|
161
121
|
end
|
122
|
+
end
|
162
123
|
end
|