Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions datastar.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ Gem::Specification.new do |spec|

spec.summary = 'Ruby SDK for Datastar. Rack-compatible.'
spec.homepage = 'https://github.com/starfederation/datastar-ruby#readme'
spec.required_ruby_version = '>= 3.0.0'
spec.required_ruby_version = '>= 3.3.0'

spec.metadata['homepage_uri'] = spec.homepage
spec.metadata['source_code_uri'] = 'https://github.com/starfederation/datastar-ruby'
spec.metadata['rubygems_mfa_required'] = 'true'

# Specify which files should be added to the gem when it is released.
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
Expand All @@ -29,9 +30,9 @@ Gem::Specification.new do |spec|
spec.require_paths = ['lib']

# Uncomment to register a new dependency of your gem
spec.add_dependency 'rack', '>= 3.2'
spec.add_dependency 'json'
spec.add_dependency 'logger'
spec.add_dependency 'rack', '>= 3.2'

spec.add_development_dependency 'phlex'
# For more information and examples about making a new gem, check out our
Expand Down
20 changes: 10 additions & 10 deletions lib/datastar/server_sent_event_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,28 @@
module Datastar
module ElementPatchMode
# Morphs the element into the existing element.
OUTER = 'outer'
OUTER = :outer

# Replaces the inner HTML of the existing element.
INNER = 'inner'
INNER = :inner

# Removes the existing element.
REMOVE = 'remove'
REMOVE = :remove

# Replaces the existing element with the new element.
REPLACE = 'replace'
REPLACE = :replace

# Prepends the element inside to the existing element.
PREPEND = 'prepend'
PREPEND = :prepend

# Appends the element inside the existing element.
APPEND = 'append'
APPEND = :append

# Inserts the element before the existing element.
BEFORE = 'before'
BEFORE = :before

# Inserts the element after the existing element.
AFTER = 'after'
AFTER = :after
end

class ServerSentEventGenerator
Expand Down Expand Up @@ -98,7 +98,7 @@ def patch_elements(elements, options = BLANK_OPTIONS)

def remove_elements(selector, options = BLANK_OPTIONS)
patch_elements(
nil,
nil,
options.merge(
MODE_DATALINE_LITERAL => ElementPatchMode::REMOVE,
selector:
Expand Down Expand Up @@ -178,7 +178,7 @@ def build_options(options, buffer)
default_value = OPTION_DEFAULTS[sse_key]
buffer << "#{sse_key}: #{v}\n" unless v == default_value
elsif v.is_a?(Hash)
v.each do |kk, vv|
v.each do |kk, vv|
buffer << "data: #{k} #{kk} #{vv}\n"
end
elsif v.is_a?(Array)
Expand Down