Skip to content

Commit

Permalink
Updated steep and fixed empty array typings
Browse files Browse the repository at this point in the history
  • Loading branch information
kpumuk committed Dec 15, 2024
1 parent 48a785a commit 0e36667
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ source "https://rubygems.org"
gemspec

# Ruby typings
gem "steep", "~> 1.7.1", platform: :mri_32
gem "steep", "~> 1.9.1", platform: :mri_33
6 changes: 3 additions & 3 deletions lib/meta_tags/renderer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def initialize(meta_tags)
#
# @param [ActionView::Base] view Rails view object.
def render(view)
tags = []
tags = [] #: Array[Tag]

Check failure on line 21 in lib/meta_tags/renderer.rb

View workflow job for this annotation

GitHub Actions / StandardRB - Ruby 3.3 on Rails 7.1

Layout/LeadingCommentSpace: Missing space after `#`.

render_charset(tags)
render_title(tags)
Expand All @@ -35,8 +35,8 @@ def render(view)
render_hashes(tags)
render_custom(tags)

tags.tap(&:compact!).map! { |tag| tag.render(view) }
view.safe_join tags, MetaTags.config.minify_output ? "" : "\n"
rendered_tags = tags.tap(&:compact!).map { |tag| tag.render(view) }
view.safe_join rendered_tags, MetaTags.config.minify_output ? "" : "\n"
end

protected
Expand Down
4 changes: 2 additions & 2 deletions lib/meta_tags/text_normalizer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def truncate_array(string_array, limit = nil, separator = "")
return string_array if limit.nil? || limit <= 0

length = 0
result = []
result = [] #: Array[String]

Check failure on line 162 in lib/meta_tags/text_normalizer.rb

View workflow job for this annotation

GitHub Actions / StandardRB - Ruby 3.3 on Rails 7.1

Layout/LeadingCommentSpace: Missing space after `#`.

string_array.each do |string|
limit_left = calculate_limit_left(limit, length, result, separator)
Expand Down Expand Up @@ -192,7 +192,7 @@ def truncate_title(site_title, title, separator)
site_title, title, separator, global_limit
)

title = (title_limited_length > 0) ? truncate_array(title, title_limited_length, separator) : []
title = (title_limited_length > 0) ? truncate_array(title, title_limited_length, separator) : [] #: Array[String]

Check failure on line 195 in lib/meta_tags/text_normalizer.rb

View workflow job for this annotation

GitHub Actions / StandardRB - Ruby 3.3 on Rails 7.1

Layout/LeadingCommentSpace: Missing space after `#`.
site_title = (site_title_limited_length > 0) ? truncate(site_title, site_title_limited_length) : nil
end

Expand Down
6 changes: 3 additions & 3 deletions sig/lib/_internal/rails.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ module ActiveSupport
end

interface _ActionControllerBase
def render: (*untyped args) { () -> untyped } -> untyped
def render: (*untyped args) ?{ () -> untyped } -> untyped
end

interface _ActionViewBase
def tag: (String name, ?Hash[String | Symbol, untyped] options, ?bool open) -> void
def tag: (String name, ?Hash[String | Symbol, untyped] options, ?bool open) -> String

def content_tag: (String name, String content, ?Hash[String | Symbol, untyped] options, ?bool open) -> void
def content_tag: (String name, String content, ?Hash[String | Symbol, untyped] options, ?bool open) -> String

def safe_join: (Array[String], String) -> String

Expand Down
2 changes: 1 addition & 1 deletion sig/lib/meta_tags/content_tag.rbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module MetaTags
class ContentTag < Tag
def render: (_ActionViewBase view) -> untyped
def render: (_ActionViewBase view) -> String
end
end
2 changes: 1 addition & 1 deletion sig/lib/meta_tags/controller_helper.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module MetaTags
@page_description: String?
@page_keywords: String? | Array[String]

def render: (*untyped args) { () -> untyped } -> untyped
def render: (*untyped args) ?{ () -> untyped } -> untyped

def set_meta_tags: (ViewHelper::meta_tags | (_MetaTagish & Object) meta_tags) -> void

Expand Down
2 changes: 1 addition & 1 deletion sig/lib/meta_tags/tag.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module MetaTags

def initialize: (String | Symbol name, ?Hash[String | Symbol, untyped] attributes) -> void

def render: (_ActionViewBase view) -> void
def render: (_ActionViewBase view) -> String

def prepare_attributes: (Hash[String | Symbol, untyped] attributes) -> Hash[String | Symbol, untyped]
end
Expand Down
4 changes: 0 additions & 4 deletions spec/controller_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@
end
end

before do
skip("Does not work properly with RBS") if ENV["RBS_TEST_TARGET"]
end

describe "module" do
it "is mixed into ActionController::Base" do
expect(ActionController::Base.included_modules).to include(described_class)
Expand Down

0 comments on commit 0e36667

Please sign in to comment.