-
-
Notifications
You must be signed in to change notification settings - Fork 392
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
133 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,53 @@ | ||
# frozen_string_literal: true | ||
|
||
module Rectify | ||
class Presenter | ||
def method_missing(method_name, ...) | ||
if view_context.respond_to?(method_name) | ||
view_context.send(method_name, ...) | ||
else | ||
super | ||
if defined?(Rectify) && RUBY_VERSION >= "3.0.0" | ||
unless Rectify::VERSION == "0.13.0" | ||
msg = %( | ||
Rectify v 0.13.0 library has some methods overridden in #{__FILE__} to support Ruby 3 upgrade. | ||
At the time when this message has been written there are no changes in gem repo that may fix this. | ||
You have installed version: #{Rectify::VERSION}. Please check whether the upgrades are addressing or not those issues. | ||
) | ||
raise msg | ||
end | ||
|
||
module Rectify | ||
class Presenter | ||
def method_missing(method_name, ...) | ||
if view_context.respond_to?(method_name) | ||
view_context.send(method_name, ...) | ||
else | ||
super | ||
end | ||
end | ||
end | ||
|
||
def respond_to_missing?(method_name, include_private = false) | ||
view_context.respond_to?(method_name, include_private) | ||
def respond_to_missing?(method_name, include_private = false) | ||
view_context.respond_to?(method_name, include_private) | ||
end | ||
end | ||
end | ||
|
||
class Command | ||
def self.call(*args, **kwargs, &block) | ||
event_recorder = EventRecorder.new | ||
class Command | ||
def self.call(*args, **kwargs, &block) | ||
event_recorder = EventRecorder.new | ||
|
||
command = new(*args, **kwargs) | ||
command.subscribe(event_recorder) | ||
command.evaluate(&block) if block_given? | ||
command.call | ||
command = new(*args, **kwargs) | ||
command.subscribe(event_recorder) | ||
command.evaluate(&block) if block_given? | ||
command.call | ||
|
||
event_recorder.events | ||
end | ||
event_recorder.events | ||
end | ||
|
||
def method_missing(method_name, ...) | ||
if @caller.respond_to?(method_name, true) | ||
@caller.send(method_name, ...) | ||
else | ||
super | ||
def method_missing(method_name, ...) | ||
if @caller.respond_to?(method_name, true) | ||
@caller.send(method_name, ...) | ||
else | ||
super | ||
end | ||
end | ||
end | ||
|
||
def respond_to_missing?(method_name, include_private = false) | ||
@caller.respond_to?(method_name, include_private) | ||
def respond_to_missing?(method_name, include_private = false) | ||
@caller.respond_to?(method_name, include_private) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# frozen_string_literal: true | ||
|
||
# The ruby 3 requires splat on the query_params. The GraphLient gem fixes this in version 0.5.0, yet the | ||
# decidim-bulletin-board is using 0.4.0 | ||
if defined?(Graphlient) && RUBY_VERSION >= "3.0.0" | ||
unless Graphlient::VERSION == "0.4.0" | ||
msg = %( | ||
Graphlient library has some methods overridden in #{__FILE__} to support Ruby 3 upgrade. | ||
It is known that 0.5.0 version is already fixing the issue. | ||
You have installed version: #{Graphlient::VERSION} | ||
) | ||
raise msg | ||
end | ||
|
||
# rubocop:disable Layout/EmptyLineAfterGuardClause | ||
module Graphlient | ||
class Client | ||
def execute(query, variables = nil) | ||
query_params = {} | ||
query_params[:context] = @options if @options | ||
query_params[:variables] = variables if variables | ||
query = client.parse(query) if query.is_a?(String) | ||
rc = client.query(query, **query_params) | ||
raise Graphlient::Errors::GraphQLError, rc if rc.errors.any? | ||
# see https://github.com/github/graphql-client/pull/132 | ||
# see https://github.com/exAspArk/graphql-errors/issues/2 | ||
raise Graphlient::Errors::ExecutionError, rc if errors_in_result?(rc) | ||
rc | ||
rescue GraphQL::Client::Error => e | ||
raise Graphlient::Errors::ClientError, e.message | ||
end | ||
end | ||
end | ||
# rubocop:enable Layout/EmptyLineAfterGuardClause | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,67 @@ | ||
# frozen_string_literal: true | ||
# | ||
|
||
# https://github.com/gdelugre/origami/issues/80 | ||
module Origami | ||
class Date < LiteralString | ||
def self.parse(str) #:nodoc: | ||
raise InvalidDateError, "Not a valid Date string" unless str =~ REGEXP_TOKEN | ||
|
||
date = | ||
{ | ||
year: $~['year'].to_i | ||
} | ||
|
||
date[:month] = $~['month'].to_i if $~['month'] | ||
date[:day] = $~['day'].to_i if $~['day'] | ||
date[:hour] = $~['hour'].to_i if $~['hour'] | ||
date[:min] = $~['min'].to_i if $~['min'] | ||
date[:sec] = $~['sec'].to_i if $~['sec'] | ||
|
||
if %w[+ -].include?($~['ut']) | ||
utc_offset = $~['ut_hour_off'].to_i * 3600 + $~['ut_min_off'].to_i * 60 | ||
utc_offset = -utc_offset if $~['ut'] == '-' | ||
|
||
date[:utc_offset] = utc_offset | ||
end | ||
|
||
Origami::Date.new(**date) | ||
end | ||
# The ruby 3 requires splat on the query_params. The GraphLient gem fixes this in version 0.5.0, yet the | ||
# decidim-bulletin-board is using 0.4.0 | ||
|
||
if defined?(Origami) && RUBY_VERSION >= "3.0.0" | ||
unless Origami::VERSION == "2.1.0" | ||
msg = %( | ||
Origami v 2.1.0 library has some methods overridden in #{__FILE__} to support Ruby 3 upgrade. | ||
There are no recent changes on the gem's repo, so a fix is not forseen at the time when this message has been written | ||
You have installed version: #{Origami::VERSION}. Please check whether the upgrades are addressing or not those issues. | ||
) | ||
raise msg | ||
end | ||
# rubocop:disable Style/SpecialGlobalVars | ||
# rubocop:disable Style/StringLiterals | ||
# rubocop:disable Style/PercentLiteralDelimiters | ||
module Origami | ||
class Date < LiteralString | ||
def self.parse(str) #:nodoc: | ||
raise InvalidDateError, "Not a valid Date string" unless str =~ REGEXP_TOKEN | ||
|
||
date = | ||
{ | ||
year: $~['year'].to_i | ||
} | ||
|
||
date[:month] = $~['month'].to_i if $~['month'] | ||
date[:day] = $~['day'].to_i if $~['day'] | ||
date[:hour] = $~['hour'].to_i if $~['hour'] | ||
date[:min] = $~['min'].to_i if $~['min'] | ||
date[:sec] = $~['sec'].to_i if $~['sec'] | ||
|
||
def self.now | ||
now = Time.now.utc | ||
if %w[+ -].include?($~['ut']) | ||
utc_offset = $~['ut_hour_off'].to_i * 3600 + $~['ut_min_off'].to_i * 60 | ||
utc_offset = -utc_offset if $~['ut'] == '-' | ||
|
||
date = | ||
{ | ||
year: now.strftime("%Y").to_i, | ||
month: now.strftime("%m").to_i, | ||
day: now.strftime("%d").to_i, | ||
hour: now.strftime("%H").to_i, | ||
min: now.strftime("%M").to_i, | ||
sec: now.strftime("%S").to_i, | ||
utc_offset: now.utc_offset | ||
} | ||
date[:utc_offset] = utc_offset | ||
end | ||
|
||
Origami::Date.new(**date) | ||
Origami::Date.new(**date) | ||
end | ||
|
||
def self.now | ||
now = Time.now.utc | ||
|
||
date = | ||
{ | ||
year: now.strftime("%Y").to_i, | ||
month: now.strftime("%m").to_i, | ||
day: now.strftime("%d").to_i, | ||
hour: now.strftime("%H").to_i, | ||
min: now.strftime("%M").to_i, | ||
sec: now.strftime("%S").to_i, | ||
utc_offset: now.utc_offset | ||
} | ||
|
||
Origami::Date.new(**date) | ||
end | ||
end | ||
end | ||
# rubocop:enable Style/StringLiterals | ||
# rubocop:enable Style/SpecialGlobalVars | ||
# rubocop:enable Style/PercentLiteralDelimiters | ||
end |