Skip to content

Commit

Permalink
Run rubocop -A
Browse files Browse the repository at this point in the history
  • Loading branch information
mokuzon committed Dec 17, 2024
1 parent 8963415 commit 14ab0e2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
3 changes: 2 additions & 1 deletion lib/line/bot/v2/reserved_words.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ module Bot
module V2
# CodeGen add _ prefix to reserved words
# see: https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractRubyCodegen.java
RESERVED_WORDS = %i[__FILE__ and def end in or self unless __LINE__ begin defined? ensure module redo super until BEGIN break do false next rescue then when END case else for nil retry true while alias class elsif if not return undef yield]
RESERVED_WORDS = %i[__FILE__ and def end in or self unless __LINE__ begin defined? ensure module redo super until BEGIN break do false next rescue then when END case else for nil retry true
while alias class elsif if not return undef yield]
end
end
end
14 changes: 9 additions & 5 deletions lib/line/bot/v2/webhook_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,25 @@ def parse(body, signature)
data = JSON.parse(body, symbolize_names: true)
data = Line::Bot::V2::Utils.deep_underscore(data)

data[:events].map { |event|
data[:events].map do |event|
event_class_name = determine_class_name(:events, event)
event_class = Object.const_get(event_class_name) rescue nil
event_class = begin
Object.const_get(event_class_name)
rescue StandardError
nil
end

# If there is no specific webhook class, leave the value as is
event_instance = event_class ? create_instance(event_class, event) : event

deep_hash_to_ostruct(event_instance)
}
end
end

private

def verify_signature(body:, signature:)
hash = OpenSSL::HMAC::digest(OpenSSL::Digest.new('SHA256'), @channel_secret, body)
hash = OpenSSL::HMAC.digest(OpenSSL::Digest.new('SHA256'), @channel_secret, body)
signature == Base64.strict_encode64(hash.to_s)
end

Expand Down Expand Up @@ -127,7 +131,7 @@ def determine_class_name(key, value)
end

def pascalize(str)
str.to_s.gsub(/(?:^|_)([a-z])/) { $1.upcase }
str.to_s.gsub(/(?:^|_)([a-z])/) { ::Regexp.last_match(1).upcase }
end

def singularize(str)
Expand Down
1 change: 0 additions & 1 deletion spec/line/bot/v2/webhook_parser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1720,4 +1720,3 @@
end
end
end

0 comments on commit 14ab0e2

Please sign in to comment.