chronicle-core 0.2.2 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rspec.yml +1 -1
  3. data/.gitignore +3 -1
  4. data/.rubocop-plugin.yml +4 -0
  5. data/.rubocop.yml +16 -2
  6. data/Gemfile +2 -2
  7. data/Guardfile +3 -3
  8. data/LICENSE.txt +1 -1
  9. data/README.md +87 -2
  10. data/Rakefile +63 -1
  11. data/bin/console +6 -6
  12. data/chronicle-core.gemspec +32 -26
  13. data/lib/chronicle/core/version.rb +1 -3
  14. data/lib/chronicle/core.rb +1 -3
  15. data/lib/chronicle/models/base.rb +96 -0
  16. data/lib/chronicle/models/builder.rb +35 -0
  17. data/lib/chronicle/models/generation.rb +89 -0
  18. data/lib/chronicle/models/model_factory.rb +65 -0
  19. data/lib/chronicle/models.rb +17 -0
  20. data/lib/chronicle/schema/rdf_parsing/graph_transformer.rb +122 -0
  21. data/lib/chronicle/schema/rdf_parsing/rdf_serializer.rb +138 -0
  22. data/lib/chronicle/schema/rdf_parsing/schemaorg.rb +47 -0
  23. data/lib/chronicle/schema/rdf_parsing/ttl_graph_builder.rb +142 -0
  24. data/lib/chronicle/schema/rdf_parsing.rb +11 -0
  25. data/lib/chronicle/schema/schema_graph.rb +145 -0
  26. data/lib/chronicle/schema/schema_property.rb +81 -0
  27. data/lib/chronicle/schema/schema_type.rb +110 -0
  28. data/lib/chronicle/schema/types.rb +9 -0
  29. data/lib/chronicle/schema/validation/base_contract.rb +22 -0
  30. data/lib/chronicle/schema/validation/contract_factory.rb +133 -0
  31. data/lib/chronicle/schema/validation/edge_validator.rb +53 -0
  32. data/lib/chronicle/schema/validation/generation.rb +29 -0
  33. data/lib/chronicle/schema/validation/validator.rb +23 -0
  34. data/lib/chronicle/schema/validation.rb +41 -0
  35. data/lib/chronicle/schema.rb +9 -2
  36. data/lib/chronicle/serialization/hash_serializer.rb +5 -11
  37. data/lib/chronicle/serialization/jsonapi_serializer.rb +41 -26
  38. data/lib/chronicle/serialization/jsonld_serializer.rb +38 -0
  39. data/lib/chronicle/serialization/record.rb +90 -0
  40. data/lib/chronicle/serialization/serializer.rb +31 -18
  41. data/lib/chronicle/serialization.rb +6 -4
  42. data/lib/chronicle/utils/hash_utils.rb +19 -16
  43. data/schema/chronicle_schema_v1.json +1283 -0
  44. data/schema/chronicle_schema_v1.rb +183 -0
  45. data/schema/chronicle_schema_v1.ttl +720 -0
  46. metadata +107 -15
  47. data/lib/chronicle/schema/activity.rb +0 -5
  48. data/lib/chronicle/schema/base.rb +0 -79
  49. data/lib/chronicle/schema/entity.rb +0 -5
  50. data/lib/chronicle/schema/raw.rb +0 -9
  51. data/lib/chronicle/schema/validator.rb +0 -55
@@ -0,0 +1,183 @@
1
+ version 1
2
+ set_base_graph 'schema.org', '26.0'
3
+
4
+ pick_type :Thing do
5
+ pick_type :Action do
6
+ apply_property :endTime
7
+ apply_property :startTime
8
+ apply_property :agent, required: true
9
+ apply_property :instrument
10
+ apply_property :object
11
+ apply_property :result
12
+
13
+ pick_type :AssessAction do
14
+ pick_type :ReactAction do
15
+ pick_type :LikeAction
16
+ end
17
+ end
18
+
19
+ pick_type :ConsumeAction do
20
+ pick_type :ListenAction
21
+ pick_type :ReadAction
22
+ pick_type :UseAction
23
+ pick_type :ViewAction
24
+ pick_type :WatchAction
25
+ end
26
+
27
+ pick_type :InteractAction do
28
+ pick_type :CommunicateAction do
29
+ pick_type :CheckInAction
30
+ end
31
+ end
32
+
33
+ pick_type :UpdateAction do
34
+ pick_type :AddAction do
35
+ pick_type :InsertAction
36
+ end
37
+ end
38
+ end
39
+
40
+ pick_type :Event do
41
+ apply_property :location, many: true
42
+ apply_property :startDate
43
+ apply_property :endDate
44
+ end
45
+
46
+ pick_type :CreativeWork do
47
+ pick_type :Book do
48
+ apply_property :numberOfPages
49
+ end
50
+
51
+ pick_type :CreativeWorkSeries do
52
+ pick_type :PodcastSeries do
53
+ apply_property :webFeed
54
+ end
55
+ end
56
+
57
+ pick_type :Episode do
58
+ pick_type :PodcastEpisode
59
+
60
+ apply_property :partOfSeason
61
+ apply_property :partOfSeries
62
+ apply_property :duration
63
+ apply_property :episodeNumber
64
+ end
65
+
66
+ pick_type :MediaObject do
67
+ pick_type :AudioObject
68
+ pick_type :ImageObject
69
+ pick_type :VideoObject
70
+
71
+ apply_property :duration
72
+ apply_property :width
73
+ apply_property :height
74
+ end
75
+
76
+ pick_type :MusicPlaylist do
77
+ pick_type :MusicAlbum do
78
+ apply_property :byArtist, many: true
79
+ end
80
+ end
81
+
82
+ pick_type :MusicRecording do
83
+ apply_property :inAlbum, many: true
84
+ apply_property :byArtist, many: true
85
+ apply_property :duration
86
+ end
87
+
88
+ pick_type :Message do
89
+ apply_property :recipient, many: true
90
+ apply_property :sender
91
+ end
92
+
93
+ apply_property :about, many: true
94
+ apply_property :aggregateRating
95
+ apply_property :author, many: true
96
+ apply_property :contributor, many: true
97
+ apply_property :contentLocation, many: true
98
+ apply_property :creator, many: true
99
+ apply_property :inLanguage, many: true
100
+ apply_property :isPartOf, many: true
101
+ apply_property :keywords, many: true
102
+ apply_property :mentions, many: true
103
+ apply_property :producer, many: true
104
+ apply_property :publisher, many: true
105
+ apply_property :text
106
+ end
107
+
108
+ pick_type :Intangible do
109
+ pick_type :Quantity do
110
+ pick_type :Duration
111
+ pick_type :Distance
112
+ pick_type :Energy
113
+ pick_type :Mass
114
+ end
115
+
116
+ pick_type :StructuredValue do
117
+ pick_type :ContactPoint do
118
+ pick_type :PostalAddress do
119
+ apply_property :addressCountry
120
+ apply_property :addressLocality
121
+ apply_property :addressRegion
122
+ apply_property :postOfficeBoxNumber
123
+ apply_property :postalCode
124
+ apply_property :streetAddress
125
+ end
126
+ end
127
+ pick_type :QuantitativeValue do
128
+ apply_property :value
129
+ end
130
+ end
131
+ end
132
+
133
+ pick_type :Organization
134
+
135
+ pick_type :Person do
136
+ apply_property :address
137
+ end
138
+ pick_type :Organization do
139
+ apply_property :location, many: true
140
+ pick_type :PerformingGroup do
141
+ pick_type :MusicGroup do
142
+ apply_property :album, many: true
143
+ end
144
+ end
145
+ end
146
+
147
+ pick_type :Place do
148
+ pick_type :AdministrativeArea do
149
+ pick_all_subtypes
150
+ end
151
+
152
+ apply_property :address
153
+ apply_property :latitude
154
+ apply_property :longitude
155
+ end
156
+
157
+ apply_property :alternateName
158
+ apply_property :description
159
+ apply_property :identifier
160
+ apply_property :image
161
+ apply_property :name
162
+ apply_property :subjectOf, many: true
163
+ apply_property :url
164
+
165
+ # TODO: Make these subproperties of identifier, alternateName
166
+ add_property :source
167
+ add_property :slug
168
+ add_property :sourceId
169
+ add_property :sourceNamespace
170
+ end
171
+
172
+ pick_type :DataType do
173
+ pick_type :Number do
174
+ pick_type :Integer
175
+ pick_type :Float
176
+ end
177
+ pick_type :Boolean
178
+ pick_type :Text do
179
+ pick_type :URL
180
+ end
181
+ pick_type :Date
182
+ pick_type :DateTime
183
+ end