Make code compatible with Ruby 2.7
Not including specs etc.
This commit is contained in:
parent
e2b650fb84
commit
596529d9eb
@ -80,7 +80,7 @@ module Nostr
|
|||||||
# @return [Subscription] The subscription object
|
# @return [Subscription] The subscription object
|
||||||
#
|
#
|
||||||
def subscribe(subscription_id: SecureRandom.hex, filter: Filter.new)
|
def subscribe(subscription_id: SecureRandom.hex, filter: Filter.new)
|
||||||
subscriptions[subscription_id] = Subscription.new(id: subscription_id, filter:)
|
subscriptions[subscription_id] = Subscription.new(id: subscription_id, filter: filter)
|
||||||
parent_to_child_channel.push([ClientMessageType::REQ, subscription_id, filter.to_h].to_json)
|
parent_to_child_channel.push([ClientMessageType::REQ, subscription_id, filter.to_h].to_json)
|
||||||
subscriptions[subscription_id]
|
subscriptions[subscription_id]
|
||||||
end
|
end
|
||||||
|
@ -150,7 +150,9 @@ module Nostr
|
|||||||
#
|
#
|
||||||
# @return [Array<String>] The event's updated list of tags
|
# @return [Array<String>] The event's updated list of tags
|
||||||
#
|
#
|
||||||
def add_event_reference(event_id) = tags.push(['e', event_id])
|
def add_event_reference(event_id)
|
||||||
|
tags.push(['e', event_id])
|
||||||
|
end
|
||||||
|
|
||||||
# Adds a reference to a pubkey as a 'p' tag
|
# Adds a reference to a pubkey as a 'p' tag
|
||||||
#
|
#
|
||||||
@ -164,7 +166,9 @@ module Nostr
|
|||||||
#
|
#
|
||||||
# @return [Array<String>] The event's updated list of tags
|
# @return [Array<String>] The event's updated list of tags
|
||||||
#
|
#
|
||||||
def add_pubkey_reference(pubkey) = tags.push(['p', pubkey])
|
def add_pubkey_reference(pubkey)
|
||||||
|
tags.push(['p', pubkey])
|
||||||
|
end
|
||||||
|
|
||||||
# Signs an event with the user's private key
|
# Signs an event with the user's private key
|
||||||
#
|
#
|
||||||
@ -213,13 +217,13 @@ module Nostr
|
|||||||
#
|
#
|
||||||
def to_h
|
def to_h
|
||||||
{
|
{
|
||||||
id:,
|
id: id,
|
||||||
pubkey:,
|
pubkey: pubkey,
|
||||||
created_at:,
|
created_at: created_at,
|
||||||
kind:,
|
kind: kind,
|
||||||
tags:,
|
tags: tags,
|
||||||
content:,
|
content: content,
|
||||||
sig:
|
sig: sig
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -145,14 +145,14 @@ module Nostr
|
|||||||
#
|
#
|
||||||
def to_h
|
def to_h
|
||||||
{
|
{
|
||||||
ids:,
|
ids: ids,
|
||||||
authors:,
|
authors: authors,
|
||||||
kinds:,
|
kinds: kinds,
|
||||||
'#e': e,
|
'#e': e,
|
||||||
'#p': p,
|
'#p': p,
|
||||||
since:,
|
since: since,
|
||||||
until: self.until,
|
until: self.until,
|
||||||
limit:
|
limit: limit
|
||||||
}.compact
|
}.compact
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ module Nostr
|
|||||||
private_key = generate_private_key
|
private_key = generate_private_key
|
||||||
public_key = extract_public_key(private_key)
|
public_key = extract_public_key(private_key)
|
||||||
|
|
||||||
KeyPair.new(private_key:, public_key:)
|
KeyPair.new(private_key: private_key, public_key: public_key)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Generates a private key
|
# Generates a private key
|
||||||
|
@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
|
|||||||
spec.description = 'Client and relay implementation of the Nostr protocol.'
|
spec.description = 'Client and relay implementation of the Nostr protocol.'
|
||||||
spec.homepage = 'https://github.com/wilsonsilva/nostr'
|
spec.homepage = 'https://github.com/wilsonsilva/nostr'
|
||||||
spec.license = 'MIT'
|
spec.license = 'MIT'
|
||||||
spec.required_ruby_version = '>= 3.2.0'
|
spec.required_ruby_version = '>= 2.7.2'
|
||||||
spec.metadata['rubygems_mfa_required'] = 'true'
|
spec.metadata['rubygems_mfa_required'] = 'true'
|
||||||
|
|
||||||
spec.metadata['homepage_uri'] = spec.homepage
|
spec.metadata['homepage_uri'] = spec.homepage
|
||||||
|
Loading…
x
Reference in New Issue
Block a user