puzzly_api_plugin 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.circleci/config.yml +43 -0
- data/.gitignore +16 -0
- data/.rspec +3 -0
- data/.rubocop.yml +11 -0
- data/Gemfile +8 -0
- data/LICENSE.txt +21 -0
- data/Linux Mint Ruby Setup.md +1 -0
- data/README.md +17 -0
- data/Rakefile +8 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/lib/puzzly_api_plugin/collection/apis.rb +20 -0
- data/lib/puzzly_api_plugin/collection/caches.rb +20 -0
- data/lib/puzzly_api_plugin/collection/collection.rb +24 -0
- data/lib/puzzly_api_plugin/collection/contexts.rb +12 -0
- data/lib/puzzly_api_plugin/collection/modules.rb +16 -0
- data/lib/puzzly_api_plugin/collection/queries.rb +20 -0
- data/lib/puzzly_api_plugin/collection/schemas.rb +16 -0
- data/lib/puzzly_api_plugin/collection/tables.rb +20 -0
- data/lib/puzzly_api_plugin/collection/topics.rb +24 -0
- data/lib/puzzly_api_plugin/fields.rb +82 -0
- data/lib/puzzly_api_plugin/generator.rb +62 -0
- data/lib/puzzly_api_plugin/identity.rb +15 -0
- data/lib/puzzly_api_plugin/jsonable.rb +15 -0
- data/lib/puzzly_api_plugin/metadata/api.rb +33 -0
- data/lib/puzzly_api_plugin/metadata/cache.rb +33 -0
- data/lib/puzzly_api_plugin/metadata/context.rb +21 -0
- data/lib/puzzly_api_plugin/metadata/metadata.rb +27 -0
- data/lib/puzzly_api_plugin/metadata/module.rb +27 -0
- data/lib/puzzly_api_plugin/metadata/query.rb +33 -0
- data/lib/puzzly_api_plugin/metadata/schema.rb +33 -0
- data/lib/puzzly_api_plugin/metadata/table.rb +33 -0
- data/lib/puzzly_api_plugin/metadata/topic.rb +33 -0
- data/lib/puzzly_api_plugin/page.rb +19 -0
- data/lib/puzzly_api_plugin/version.rb +5 -0
- data/lib/puzzly_api_plugin/view/api.rb +19 -0
- data/lib/puzzly_api_plugin/view/apis.rb +23 -0
- data/lib/puzzly_api_plugin/view/cache.rb +19 -0
- data/lib/puzzly_api_plugin/view/caches.rb +23 -0
- data/lib/puzzly_api_plugin/view/context.rb +36 -0
- data/lib/puzzly_api_plugin/view/contexts.rb +23 -0
- data/lib/puzzly_api_plugin/view/dashboard.rb +32 -0
- data/lib/puzzly_api_plugin/view/module.rb +34 -0
- data/lib/puzzly_api_plugin/view/modules.rb +23 -0
- data/lib/puzzly_api_plugin/view/queries.rb +23 -0
- data/lib/puzzly_api_plugin/view/query.rb +19 -0
- data/lib/puzzly_api_plugin/view/renderable.rb +57 -0
- data/lib/puzzly_api_plugin/view/schema.rb +23 -0
- data/lib/puzzly_api_plugin/view/schemas.rb +23 -0
- data/lib/puzzly_api_plugin/view/table.rb +19 -0
- data/lib/puzzly_api_plugin/view/tables.rb +23 -0
- data/lib/puzzly_api_plugin/view/topic.rb +23 -0
- data/lib/puzzly_api_plugin/view/topics.rb +23 -0
- data/lib/puzzly_api_plugin.rb +55 -0
- data/puzzly_api_plugin.gemspec +36 -0
- data/script/bootstrap +3 -0
- data/script/ci-build +7 -0
- data/script/ci-release +15 -0
- data/script/fmt +10 -0
- data/script/test +4 -0
- metadata +201 -0
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PuzzlyApiPlugin
|
4
|
+
class Query < Metadata
|
5
|
+
def self.create(document)
|
6
|
+
Query.new(document,
|
7
|
+
document.data[YAMLFields::MODULE_ID],
|
8
|
+
document.data[YAMLFields::QUERY_ID],
|
9
|
+
document.data[YAMLFields::QUERY_NAME],
|
10
|
+
document.data[YAMLFields::QUERY_DESCRIPTION],
|
11
|
+
document.data[YAMLFields::QUERY_SPECIFICATION])
|
12
|
+
end
|
13
|
+
|
14
|
+
def initialize(document, module_id, id, name, description, specification)
|
15
|
+
super(document, id, name)
|
16
|
+
self[MetadataFields::MODULE_ID] = module_id
|
17
|
+
self[MetadataFields::DESCRIPTION] = description
|
18
|
+
self[MetadataFields::SPECIFICATION] = specification
|
19
|
+
end
|
20
|
+
|
21
|
+
def module_id
|
22
|
+
self[MetadataFields::MODULE_ID]
|
23
|
+
end
|
24
|
+
|
25
|
+
def description
|
26
|
+
self[MetadataFields::DESCRIPTION]
|
27
|
+
end
|
28
|
+
|
29
|
+
def specification
|
30
|
+
self[MetadataFields::SPECIFICATION]
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PuzzlyApiPlugin
|
4
|
+
class Schema < Metadata
|
5
|
+
def self.create(document)
|
6
|
+
Schema.new(document,
|
7
|
+
document.data[YAMLFields::CONTEXT_ID],
|
8
|
+
document.data[YAMLFields::SCHEMA_ID],
|
9
|
+
document.data[YAMLFields::SCHEMA_NAME],
|
10
|
+
document.data[YAMLFields::SCHEMA_DESCRIPTION],
|
11
|
+
document.data[YAMLFields::SCHEMA_SPECIFICATION])
|
12
|
+
end
|
13
|
+
|
14
|
+
def initialize(document, context_id, id, name, description, specification)
|
15
|
+
super(document, id, name)
|
16
|
+
self[MetadataFields::CONTEXT_ID] = context_id
|
17
|
+
self[MetadataFields::DESCRIPTION] = description
|
18
|
+
self[MetadataFields::SPECIFICATION] = specification
|
19
|
+
end
|
20
|
+
|
21
|
+
def context_id
|
22
|
+
self[MetadataFields::CONTEXT_ID]
|
23
|
+
end
|
24
|
+
|
25
|
+
def description
|
26
|
+
self[MetadataFields::DESCRIPTION]
|
27
|
+
end
|
28
|
+
|
29
|
+
def specification
|
30
|
+
self[MetadataFields::SPECIFICATION]
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PuzzlyApiPlugin
|
4
|
+
class Table < Metadata
|
5
|
+
def self.create(document)
|
6
|
+
Table.new(document,
|
7
|
+
document.data[YAMLFields::MODULE_ID],
|
8
|
+
document.data[YAMLFields::TABLE_ID],
|
9
|
+
document.data[YAMLFields::TABLE_NAME],
|
10
|
+
document.data[YAMLFields::TABLE_DESCRIPTION],
|
11
|
+
document.data[YAMLFields::TABLE_SPECIFICATION])
|
12
|
+
end
|
13
|
+
|
14
|
+
def initialize(document, module_id, id, name, description, specification)
|
15
|
+
super(document, id, name)
|
16
|
+
self[MetadataFields::MODULE_ID] = module_id
|
17
|
+
self[MetadataFields::DESCRIPTION] = description
|
18
|
+
self[MetadataFields::SPECIFICATION] = specification
|
19
|
+
end
|
20
|
+
|
21
|
+
def module_id
|
22
|
+
self[MetadataFields::MODULE_ID]
|
23
|
+
end
|
24
|
+
|
25
|
+
def description
|
26
|
+
self[MetadataFields::DESCRIPTION]
|
27
|
+
end
|
28
|
+
|
29
|
+
def specification
|
30
|
+
self[MetadataFields::SPECIFICATION]
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PuzzlyApiPlugin
|
4
|
+
class Topic < Metadata
|
5
|
+
def self.create(document)
|
6
|
+
Topic.new(document,
|
7
|
+
document.data[YAMLFields::MODULE_ID],
|
8
|
+
document.data[YAMLFields::SCHEMA_ID],
|
9
|
+
document.data[YAMLFields::TOPIC_ID],
|
10
|
+
document.data[YAMLFields::TOPIC_NAME],
|
11
|
+
document.data[YAMLFields::TOPIC_DESCRIPTION])
|
12
|
+
end
|
13
|
+
|
14
|
+
def initialize(document, module_id, schema_id, id, name, description)
|
15
|
+
super(document, id, name)
|
16
|
+
self[MetadataFields::MODULE_ID] = module_id
|
17
|
+
self[MetadataFields::SCHEMA_ID] = schema_id
|
18
|
+
self[MetadataFields::DESCRIPTION] = description
|
19
|
+
end
|
20
|
+
|
21
|
+
def module_id
|
22
|
+
self[MetadataFields::MODULE_ID]
|
23
|
+
end
|
24
|
+
|
25
|
+
def schema_id
|
26
|
+
self[MetadataFields::SCHEMA_ID]
|
27
|
+
end
|
28
|
+
|
29
|
+
def description
|
30
|
+
self[MetadataFields::DESCRIPTION]
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class JSONPage < Jekyll::Page
|
4
|
+
def initialize(site, base, dir, name, content)
|
5
|
+
@site = site
|
6
|
+
@base = base
|
7
|
+
@dir = dir
|
8
|
+
@name = name
|
9
|
+
|
10
|
+
self.data = {}
|
11
|
+
self.content = content
|
12
|
+
|
13
|
+
process(@name)
|
14
|
+
end
|
15
|
+
|
16
|
+
def render_with_liquid?
|
17
|
+
false
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PuzzlyApiPlugin
|
4
|
+
class ApiView < Renderable
|
5
|
+
def self.create(api)
|
6
|
+
mod = ModulesCollection.instance.get_by_id api.module_id
|
7
|
+
|
8
|
+
ApiView.new(mod.to_identity,
|
9
|
+
api)
|
10
|
+
end
|
11
|
+
|
12
|
+
def initialize(mod, api)
|
13
|
+
api.copy_to_hash self
|
14
|
+
self.delete MetadataFields::MODULE_ID
|
15
|
+
|
16
|
+
self[MetadataFields::MODULE] = mod
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PuzzlyApiPlugin
|
4
|
+
|
5
|
+
class ApisView < Renderable
|
6
|
+
API_ENDPOINT = 'apis/home'
|
7
|
+
|
8
|
+
def self.create
|
9
|
+
apis = []
|
10
|
+
|
11
|
+
ApisCollection.instance.each do |id, api|
|
12
|
+
apis.push ApiView.create(api)
|
13
|
+
end
|
14
|
+
|
15
|
+
ApisView.new(apis)
|
16
|
+
end
|
17
|
+
|
18
|
+
def initialize(apis)
|
19
|
+
super(API_ENDPOINT)
|
20
|
+
self.apis apis
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PuzzlyApiPlugin
|
4
|
+
class CacheView < Renderable
|
5
|
+
def self.create(cache)
|
6
|
+
mod = ModulesCollection.instance.get_by_id cache.module_id
|
7
|
+
|
8
|
+
CacheView.new(mod.to_identity,
|
9
|
+
cache)
|
10
|
+
end
|
11
|
+
|
12
|
+
def initialize(mod, cache)
|
13
|
+
cache.copy_to_hash self
|
14
|
+
self.delete MetadataFields::MODULE_ID
|
15
|
+
|
16
|
+
self[MetadataFields::MODULE] = mod
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PuzzlyApiPlugin
|
4
|
+
|
5
|
+
class CachesView < Renderable
|
6
|
+
API_ENDPOINT = 'caches/home'
|
7
|
+
|
8
|
+
def self.create
|
9
|
+
caches = []
|
10
|
+
|
11
|
+
CachesCollection.instance.each do |id, cache|
|
12
|
+
caches.push CacheView.create(cache)
|
13
|
+
end
|
14
|
+
|
15
|
+
CachesView.new(caches)
|
16
|
+
end
|
17
|
+
|
18
|
+
def initialize(caches)
|
19
|
+
super(API_ENDPOINT)
|
20
|
+
self.caches caches
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PuzzlyApiPlugin
|
4
|
+
class ContextView < Renderable
|
5
|
+
def self.create(context)
|
6
|
+
modules = ModulesCollection.instance.get_by_context context
|
7
|
+
schemas = SchemasCollection.instance.get_by_context context
|
8
|
+
|
9
|
+
apis = ApisCollection.instance.get_by_modules modules
|
10
|
+
caches = CachesCollection.instance.get_by_modules modules
|
11
|
+
queries = QueriesCollection.instance.get_by_modules modules
|
12
|
+
tables = TablesCollection.instance.get_by_modules modules
|
13
|
+
topics = TopicsCollection.instance.get_by_modules modules
|
14
|
+
|
15
|
+
ContextView.new(context,
|
16
|
+
modules.map { |_id, mod| mod.to_identity },
|
17
|
+
schemas.map { |_id, schema| schema.to_identity },
|
18
|
+
apis.map { |_id, api| api.to_identity },
|
19
|
+
caches.map { |_id, cache| cache.to_identity },
|
20
|
+
queries.map { |_id, query| query.to_identity },
|
21
|
+
tables.map { |_id, table| table.to_identity },
|
22
|
+
topics.map { |_id, topic| topic.to_identity })
|
23
|
+
end
|
24
|
+
|
25
|
+
def initialize(context, modules, schemas, apis, caches, queries, tables, topics)
|
26
|
+
context.copy_to_hash self
|
27
|
+
self.modules modules
|
28
|
+
self.schemas schemas
|
29
|
+
self.apis apis
|
30
|
+
self.caches caches
|
31
|
+
self.queries queries
|
32
|
+
self.tables tables
|
33
|
+
self.topics topics
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PuzzlyApiPlugin
|
4
|
+
|
5
|
+
class ContextsView < Renderable
|
6
|
+
API_ENDPOINT = 'contexts/home'
|
7
|
+
|
8
|
+
def self.create
|
9
|
+
contexts = []
|
10
|
+
|
11
|
+
ContextsCollection.instance.each do |id, context|
|
12
|
+
contexts.push ContextView.create(context)
|
13
|
+
end
|
14
|
+
|
15
|
+
ContextsView.new(contexts)
|
16
|
+
end
|
17
|
+
|
18
|
+
def initialize(contexts)
|
19
|
+
super(API_ENDPOINT)
|
20
|
+
self.contexts contexts
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PuzzlyApiPlugin
|
4
|
+
class HomeDashboardView < Renderable
|
5
|
+
API_ENDPOINT = 'dashboards/home'
|
6
|
+
|
7
|
+
def self.create
|
8
|
+
HomeDashboardView.new(ApisCollection.instance.identities,
|
9
|
+
CachesCollection.instance.identities,
|
10
|
+
ContextsCollection.instance.identities,
|
11
|
+
ModulesCollection.instance.identities,
|
12
|
+
QueriesCollection.instance.identities,
|
13
|
+
SchemasCollection.instance.identities,
|
14
|
+
TablesCollection.instance.identities,
|
15
|
+
TopicsCollection.instance.identities)
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def initialize(apis, caches, contexts, modules, queries, schemas, tables, topics)
|
21
|
+
super(API_ENDPOINT)
|
22
|
+
self.apis apis
|
23
|
+
self.caches caches
|
24
|
+
self.contexts contexts
|
25
|
+
self.modules modules
|
26
|
+
self.queries queries
|
27
|
+
self.schemas schemas
|
28
|
+
self.tables tables
|
29
|
+
self.topics topics
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PuzzlyApiPlugin
|
4
|
+
class ModuleView < Renderable
|
5
|
+
def self.create(mod)
|
6
|
+
context = ContextsCollection.instance.get_by_id mod.context_id
|
7
|
+
apis = ApisCollection.instance.get_by_module mod
|
8
|
+
caches = CachesCollection.instance.get_by_module mod
|
9
|
+
queries = QueriesCollection.instance.get_by_module mod
|
10
|
+
tables = TablesCollection.instance.get_by_module mod
|
11
|
+
topics = TopicsCollection.instance.get_by_module mod
|
12
|
+
|
13
|
+
ModuleView.new(context.to_identity,
|
14
|
+
mod,
|
15
|
+
apis.map { |_id, api| api.to_identity },
|
16
|
+
caches.map { |_id, cache| cache.to_identity },
|
17
|
+
queries.map { |_id, query| query.to_identity },
|
18
|
+
tables.map { |_id, table| table.to_identity },
|
19
|
+
topics.map { |_id, topic| topic.to_identity })
|
20
|
+
end
|
21
|
+
|
22
|
+
def initialize(context, mod, apis, caches, queries, tables, topics)
|
23
|
+
mod.copy_to_hash self
|
24
|
+
self.delete MetadataFields::CONTEXT_ID
|
25
|
+
|
26
|
+
self[MetadataFields::CONTEXT] = context
|
27
|
+
self.apis apis
|
28
|
+
self.caches caches
|
29
|
+
self.queries queries
|
30
|
+
self.tables tables
|
31
|
+
self.topics topics
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PuzzlyApiPlugin
|
4
|
+
|
5
|
+
class ModulesView < Renderable
|
6
|
+
API_ENDPOINT = 'modules/home'
|
7
|
+
|
8
|
+
def self.create
|
9
|
+
modules = []
|
10
|
+
|
11
|
+
ModulesCollection.instance.each do |id, mod|
|
12
|
+
modules.push ModuleView.create(mod)
|
13
|
+
end
|
14
|
+
|
15
|
+
ModulesView.new(modules)
|
16
|
+
end
|
17
|
+
|
18
|
+
def initialize(modules)
|
19
|
+
super(API_ENDPOINT)
|
20
|
+
self.modules modules
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PuzzlyApiPlugin
|
4
|
+
|
5
|
+
class QueriesView < Renderable
|
6
|
+
API_ENDPOINT = 'queries/home'
|
7
|
+
|
8
|
+
def self.create
|
9
|
+
queries = []
|
10
|
+
|
11
|
+
QueriesCollection.instance.each do |id, query|
|
12
|
+
queries.push QueryView.create(query)
|
13
|
+
end
|
14
|
+
|
15
|
+
QueriesView.new(queries)
|
16
|
+
end
|
17
|
+
|
18
|
+
def initialize(queries)
|
19
|
+
super(API_ENDPOINT)
|
20
|
+
self.queries queries
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PuzzlyApiPlugin
|
4
|
+
class QueryView < Renderable
|
5
|
+
def self.create(query)
|
6
|
+
mod = ModulesCollection.instance.get_by_id query.module_id
|
7
|
+
|
8
|
+
QueryView.new(mod.to_identity,
|
9
|
+
query)
|
10
|
+
end
|
11
|
+
|
12
|
+
def initialize(mod, query)
|
13
|
+
query.copy_to_hash self
|
14
|
+
self.delete MetadataFields::MODULE_ID
|
15
|
+
|
16
|
+
self[MetadataFields::MODULE] = mod
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PuzzlyApiPlugin
|
4
|
+
class Renderable < JSONable
|
5
|
+
def initialize(path)
|
6
|
+
self['path'] = path
|
7
|
+
end
|
8
|
+
|
9
|
+
def render
|
10
|
+
to_json
|
11
|
+
end
|
12
|
+
|
13
|
+
def path
|
14
|
+
self[MetadataFields::PATH]
|
15
|
+
end
|
16
|
+
|
17
|
+
def contexts contexts
|
18
|
+
self[MetadataFields::CONTEXTS] = contexts
|
19
|
+
self[MetadataFields::NUMBER_OF_CONTEXTS] = contexts.size
|
20
|
+
end
|
21
|
+
|
22
|
+
def modules modules
|
23
|
+
self[MetadataFields::MODULES] = modules
|
24
|
+
self[MetadataFields::NUMBER_OF_MODULES] = modules.size
|
25
|
+
end
|
26
|
+
|
27
|
+
def schemas schemas
|
28
|
+
self[MetadataFields::SCHEMAS] = schemas
|
29
|
+
self[MetadataFields::NUMBER_OF_SCHEMAS] = schemas.size
|
30
|
+
end
|
31
|
+
|
32
|
+
def apis apis
|
33
|
+
self[MetadataFields::APIS] = apis
|
34
|
+
self[MetadataFields::NUMBER_OF_APIS] = apis.size
|
35
|
+
end
|
36
|
+
|
37
|
+
def caches caches
|
38
|
+
self[MetadataFields::CACHES] = caches
|
39
|
+
self[MetadataFields::NUMBER_OF_CACHES] = caches.size
|
40
|
+
end
|
41
|
+
|
42
|
+
def queries queries
|
43
|
+
self[MetadataFields::QUERIES] = queries
|
44
|
+
self[MetadataFields::NUMBER_OF_QUERIES] = queries.size
|
45
|
+
end
|
46
|
+
|
47
|
+
def tables tables
|
48
|
+
self[MetadataFields::TABLES] = tables
|
49
|
+
self[MetadataFields::NUMBER_OF_TABLES] = tables.size
|
50
|
+
end
|
51
|
+
|
52
|
+
def topics topics
|
53
|
+
self[MetadataFields::TOPICS] = topics
|
54
|
+
self[MetadataFields::NUMBER_OF_TOPICS] = topics.size
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PuzzlyApiPlugin
|
4
|
+
class SchemaView < Renderable
|
5
|
+
def self.create(schema)
|
6
|
+
context = ContextsCollection.instance.get_by_id schema.context_id
|
7
|
+
|
8
|
+
topics = TopicsCollection.instance.get_by_schema schema
|
9
|
+
|
10
|
+
SchemaView.new( context.to_identity,
|
11
|
+
schema,
|
12
|
+
topics)
|
13
|
+
end
|
14
|
+
|
15
|
+
def initialize(context, schema, topics)
|
16
|
+
schema.copy_to_hash self
|
17
|
+
self.delete MetadataFields::CONTEXT_ID
|
18
|
+
|
19
|
+
self[MetadataFields::CONTEXT] = context
|
20
|
+
self.topics topics
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PuzzlyApiPlugin
|
4
|
+
|
5
|
+
class SchemasView < Renderable
|
6
|
+
API_ENDPOINT = 'schemas/home'
|
7
|
+
|
8
|
+
def self.create
|
9
|
+
schemas = []
|
10
|
+
|
11
|
+
SchemasCollection.instance.each do |id, mod|
|
12
|
+
schemas.push SchemaView.create(mod)
|
13
|
+
end
|
14
|
+
|
15
|
+
SchemasView.new(schemas)
|
16
|
+
end
|
17
|
+
|
18
|
+
def initialize(schemas)
|
19
|
+
super(API_ENDPOINT)
|
20
|
+
self.schemas schemas
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PuzzlyApiPlugin
|
4
|
+
class TableView < Renderable
|
5
|
+
def self.create(table)
|
6
|
+
mod = ModulesCollection.instance.get_by_id table.module_id
|
7
|
+
|
8
|
+
TableView.new(mod.to_identity,
|
9
|
+
table)
|
10
|
+
end
|
11
|
+
|
12
|
+
def initialize(mod, table)
|
13
|
+
table.copy_to_hash self
|
14
|
+
self.delete MetadataFields::MODULE_ID
|
15
|
+
|
16
|
+
self[MetadataFields::MODULE] = mod
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PuzzlyApiPlugin
|
4
|
+
|
5
|
+
class TablesView < Renderable
|
6
|
+
API_ENDPOINT = 'tables/home'
|
7
|
+
|
8
|
+
def self.create
|
9
|
+
tables = []
|
10
|
+
|
11
|
+
TablesCollection.instance.each do |id, table|
|
12
|
+
tables.push TableView.create(table)
|
13
|
+
end
|
14
|
+
|
15
|
+
TablesView.new(tables)
|
16
|
+
end
|
17
|
+
|
18
|
+
def initialize(tables)
|
19
|
+
super(API_ENDPOINT)
|
20
|
+
self.tables tables
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PuzzlyApiPlugin
|
4
|
+
class TopicView < Renderable
|
5
|
+
def self.create(topic)
|
6
|
+
mod = ModulesCollection.instance.get_by_id topic.module_id
|
7
|
+
schema = SchemasCollection.instance.get_by_id topic.schema_id
|
8
|
+
|
9
|
+
TopicView.new(mod.to_identity,
|
10
|
+
schema.to_identity,
|
11
|
+
topic)
|
12
|
+
end
|
13
|
+
|
14
|
+
def initialize(mod, schema, topic)
|
15
|
+
topic.copy_to_hash self
|
16
|
+
self.delete MetadataFields::MODULE_ID
|
17
|
+
self.delete MetadataFields::SCHEMA_ID
|
18
|
+
|
19
|
+
self[MetadataFields::MODULE] = mod
|
20
|
+
self[MetadataFields::SCHEMA] = schema
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PuzzlyApiPlugin
|
4
|
+
|
5
|
+
class TopicsView < Renderable
|
6
|
+
API_ENDPOINT = 'topics/home'
|
7
|
+
|
8
|
+
def self.create
|
9
|
+
topics = []
|
10
|
+
|
11
|
+
TopicsCollection.instance.each do |id, topic|
|
12
|
+
topics.push TopicView.create(topic)
|
13
|
+
end
|
14
|
+
|
15
|
+
TopicsView.new(topics)
|
16
|
+
end
|
17
|
+
|
18
|
+
def initialize(topics)
|
19
|
+
super(API_ENDPOINT)
|
20
|
+
self.topics topics
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|