Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/diaspora/diaspora.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorBenjamin Neff <benjamin@coding4coffee.ch>2022-07-23 04:55:00 +0300
committerBenjamin Neff <benjamin@coding4coffee.ch>2022-07-23 17:59:37 +0300
commit49ba740b45c57e4ec745736c84226dc55b18d10b (patch)
tree23613ce55d04dbdf7ff23c1006fd0335893f79e8 /lib
parente984fa7d91a287bc0882cc3db2f451158035243b (diff)
Add NodeInfo 2.1
Diffstat (limited to 'lib')
-rw-r--r--lib/node_info.rb31
1 files changed, 26 insertions, 5 deletions
diff --git a/lib/node_info.rb b/lib/node_info.rb
index f2118af26..6237daeca 100644
--- a/lib/node_info.rb
+++ b/lib/node_info.rb
@@ -4,13 +4,13 @@ require "pathname"
require "json-schema"
module NodeInfo
- VERSIONS = %w(1.0 2.0).freeze
- SCHEMAS = {}
+ VERSIONS = %w[1.0 2.0 2.1].freeze
+ SCHEMAS = {} # rubocop:disable Style/MutableConstant
private_constant :VERSIONS, :SCHEMAS
- # rubocop:disable Metrics/BlockLength
Document = Struct.new(:version, :software, :protocols, :services, :open_registrations, :usage, :metadata) do
- Software = Struct.new(:name, :version) do
+ # rubocop:disable Lint/ConstantDefinitionInBlock
+ Software = Struct.new(:name, :version, :repository, :homepage) do
def initialize(name=nil, version=nil)
super(name, version)
end
@@ -21,6 +21,13 @@ module NodeInfo
"version" => version
}
end
+
+ def version_21_hash
+ version_10_hash.merge(
+ "repository" => repository,
+ "homepage" => homepage
+ )
+ end
end
Protocols = Struct.new(:protocols) do
@@ -80,6 +87,7 @@ module NodeInfo
}
end
end
+ # rubocop:enable Lint/ConstantDefinitionInBlock
def self.build
new.tap do |doc|
@@ -98,6 +106,8 @@ module NodeInfo
version_10_hash
when "2.0"
version_20_hash
+ when "2.1"
+ version_21_hash
end
end
@@ -144,6 +154,18 @@ module NodeInfo
)
end
+ def version_21_hash
+ deep_compact(
+ "version" => "2.1",
+ "software" => software.version_21_hash,
+ "protocols" => protocols.version_20_array,
+ "services" => services.version_10_hash,
+ "openRegistrations" => open_registrations,
+ "usage" => usage.version_10_hash,
+ "metadata" => metadata
+ )
+ end
+
def deep_compact(hash)
hash.tap do |hash|
hash.reject! {|_, value|
@@ -153,7 +175,6 @@ module NodeInfo
end
end
end
- # rubocop:enable Metrics/BlockLength
def self.schema(version)
SCHEMAS[version] ||= JSON.parse(