From 93645a279e68b5f23d13c340d96ede3f65aff635 Mon Sep 17 00:00:00 2001 From: Go MAEDA Date: Wed, 21 Aug 2024 00:46:15 +0000 Subject: Use anonymous block forwarding introduced in Ruby 3.1 (#38585). git-svn-id: https://svn.redmine.org/redmine/trunk@22973 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- lib/redmine/activity.rb | 2 +- lib/redmine/activity/fetcher.rb | 2 +- lib/redmine/export/csv.rb | 4 ++-- lib/redmine/field_format.rb | 2 +- lib/redmine/pagination.rb | 6 +++--- lib/redmine/plugin.rb | 8 ++++---- lib/redmine/scm/adapters/abstract_adapter.rb | 4 ++-- lib/redmine/scm/adapters/bazaar_adapter.rb | 8 ++++---- lib/redmine/scm/adapters/cvs_adapter.rb | 6 +++--- lib/redmine/scm/adapters/git_adapter.rb | 4 ++-- lib/redmine/scm/adapters/mercurial_adapter.rb | 4 ++-- lib/redmine/search.rb | 2 +- lib/redmine/syntax_highlighting.rb | 2 +- lib/redmine/views/builders/structure.rb | 2 +- lib/redmine/views/builders/xml.rb | 8 ++++---- 15 files changed, 32 insertions(+), 32 deletions(-) (limited to 'lib') diff --git a/lib/redmine/activity.rb b/lib/redmine/activity.rb index 0df7c6096..36663db6b 100644 --- a/lib/redmine/activity.rb +++ b/lib/redmine/activity.rb @@ -26,7 +26,7 @@ module Redmine @@providers = Hash.new {|h, k| h[k]=[]} class << self - def map(&block) + def map(&) yield self end diff --git a/lib/redmine/activity/fetcher.rb b/lib/redmine/activity/fetcher.rb index 4264c2e5d..5c031f069 100644 --- a/lib/redmine/activity/fetcher.rb +++ b/lib/redmine/activity/fetcher.rb @@ -60,7 +60,7 @@ module Redmine end # Yields to filter the activity scope - def scope_select(&block) + def scope_select(&) @scope = @scope.select {|t| yield t} end diff --git a/lib/redmine/export/csv.rb b/lib/redmine/export/csv.rb index 8e56b38f3..e0605a844 100644 --- a/lib/redmine/export/csv.rb +++ b/lib/redmine/export/csv.rb @@ -30,7 +30,7 @@ module Redmine include Redmine::I18n class << self - def generate(options = {}, &block) + def generate(options = {}, &) col_sep = (options[:field_separator].presence || l(:general_csv_separator)) encoding = Encoding.find(options[:encoding]) rescue Encoding.find(l(:general_csv_encoding)) @@ -41,7 +41,7 @@ module Redmine (+'').force_encoding(encoding) end - super(str, :col_sep => col_sep, :encoding => encoding, &block) + super(str, :col_sep => col_sep, :encoding => encoding, &) end end diff --git a/lib/redmine/field_format.rb b/lib/redmine/field_format.rb index 93a279758..e3ebc0398 100644 --- a/lib/redmine/field_format.rb +++ b/lib/redmine/field_format.rb @@ -187,7 +187,7 @@ module Redmine end end - def parse_keyword(custom_field, keyword, &block) + def parse_keyword(custom_field, keyword, &) separator = Regexp.escape "," keyword = keyword.dup.to_s diff --git a/lib/redmine/pagination.rb b/lib/redmine/pagination.rb index 4ee55165f..f980cbdbc 100644 --- a/lib/redmine/pagination.rb +++ b/lib/redmine/pagination.rb @@ -152,7 +152,7 @@ module Redmine # Yields the given block with the text and parameters # for each pagination link and returns a string that represents the links - def pagination_links_each(paginator, count=nil, options={}, &block) + def pagination_links_each(paginator, count=nil, options={}, &) options.assert_valid_keys :per_page_links per_page_links = options.delete(:per_page_links) @@ -205,7 +205,7 @@ module Redmine info = ''.html_safe info << content_tag('span', "(#{paginator.first_item}-#{paginator.last_item}/#{paginator.item_count})", :class => 'items') + ' ' - if per_page_links != false && links = per_page_links(paginator, &block) + if per_page_links != false && links = per_page_links(paginator, &) info << content_tag('span', links.to_s, :class => 'per-page') end html << content_tag('span', info) @@ -214,7 +214,7 @@ module Redmine end # Renders the "Per page" links. - def per_page_links(paginator, &block) + def per_page_links(paginator, &) values = per_page_options(paginator.per_page, paginator.item_count) if values.any? links = values.collect do |n| diff --git a/lib/redmine/plugin.rb b/lib/redmine/plugin.rb index f341d30e1..223b3927a 100644 --- a/lib/redmine/plugin.rb +++ b/lib/redmine/plugin.rb @@ -90,9 +90,9 @@ module Redmine # version '0.0.1' # requires_redmine version_or_higher: '3.0.0' # end - def self.register(id, &block) + def self.register(id, &) p = new(id) - p.instance_eval(&block) + p.instance_eval(&) # Set a default name if it was not provided during registration p.name(id.to_s.humanize) if p.name.nil? @@ -378,9 +378,9 @@ module Redmine # permission :view_contacts, { :contacts => [:list, :show] }, :public => true # permission :destroy_contacts, { :contacts => :destroy } # end - def project_module(name, &block) + def project_module(name, &) @project_module = name - self.instance_eval(&block) + self.instance_eval(&) @project_module = nil end diff --git a/lib/redmine/scm/adapters/abstract_adapter.rb b/lib/redmine/scm/adapters/abstract_adapter.rb index f28137ed5..15e719414 100644 --- a/lib/redmine/scm/adapters/abstract_adapter.rb +++ b/lib/redmine/scm/adapters/abstract_adapter.rb @@ -206,8 +206,8 @@ module Redmine self.class.logger end - def shellout(cmd, options = {}, &block) - self.class.shellout(cmd, options, &block) + def shellout(cmd, options = {}, &) + self.class.shellout(cmd, options, &) end # Path to the file where scm stderr output is logged diff --git a/lib/redmine/scm/adapters/bazaar_adapter.rb b/lib/redmine/scm/adapters/bazaar_adapter.rb index 559063c37..8b8cbb2bf 100644 --- a/lib/redmine/scm/adapters/bazaar_adapter.rb +++ b/lib/redmine/scm/adapters/bazaar_adapter.rb @@ -297,7 +297,7 @@ module Redmine @aro end - def scm_cmd(*args, &block) + def scm_cmd(*args, &) full_args = [] full_args += args full_args_locale = [] @@ -308,7 +308,7 @@ module Redmine shellout( self.class.sq_bin + ' ' + full_args_locale.map {|e| shell_quote e.to_s}.join(' '), - &block + & ) if $? && $?.exitstatus != 0 raise ScmCommandAborted, "bzr exited with non-zero status: #{$?.exitstatus}" @@ -318,7 +318,7 @@ module Redmine end private :scm_cmd - def scm_cmd_no_raise(*args, &block) + def scm_cmd_no_raise(*args, &) full_args = [] full_args += args full_args_locale = [] @@ -329,7 +329,7 @@ module Redmine shellout( self.class.sq_bin + ' ' + full_args_locale.map {|e| shell_quote e.to_s}.join(' '), - &block + & ) ret end diff --git a/lib/redmine/scm/adapters/cvs_adapter.rb b/lib/redmine/scm/adapters/cvs_adapter.rb index b8cc97001..07e882826 100644 --- a/lib/redmine/scm/adapters/cvs_adapter.rb +++ b/lib/redmine/scm/adapters/cvs_adapter.rb @@ -152,7 +152,7 @@ module Redmine # Returns all revisions found between identifier_from and identifier_to # in the repository. both identifier have to be dates or nil. # these method returns nothing but yield every result in block - def revisions(path=nil, identifier_from=nil, identifier_to=nil, options={}, &block) + def revisions(path=nil, identifier_from=nil, identifier_to=nil, options={}, &) path_with_project_utf8 = path_with_proj(path) path_with_project_locale = scm_iconv(@path_encoding, 'UTF-8', path_with_project_utf8) logger.debug " revisions path:" + @@ -381,7 +381,7 @@ module Redmine end end - def scm_cmd(*args, &block) + def scm_cmd(*args, &) full_args = ['-d', root_url] full_args += args full_args_locale = [] @@ -392,7 +392,7 @@ module Redmine shellout( self.class.sq_bin + ' ' + full_args_locale.map {|e| shell_quote e.to_s}.join(' '), - &block + & ) if $? && $?.exitstatus != 0 raise ScmCommandAborted, "cvs exited with non-zero status: #{$?.exitstatus}" diff --git a/lib/redmine/scm/adapters/git_adapter.rb b/lib/redmine/scm/adapters/git_adapter.rb index f946d2866..c7a5c6b66 100644 --- a/lib/redmine/scm/adapters/git_adapter.rb +++ b/lib/redmine/scm/adapters/git_adapter.rb @@ -440,7 +440,7 @@ module Redmine private - def git_cmd(args, options = {}, &block) + def git_cmd(args, options = {}, &) repo_path = root_url || url full_args = ['--git-dir', repo_path] if self.class.client_version_above?([1, 7, 2]) @@ -452,7 +452,7 @@ module Redmine shellout( self.class.sq_bin + ' ' + full_args.map {|e| shell_quote e.to_s}.join(' '), options, - &block + & ) if $? && $?.exitstatus != 0 raise ScmCommandAborted, "git exited with non-zero status: #{$?.exitstatus}" diff --git a/lib/redmine/scm/adapters/mercurial_adapter.rb b/lib/redmine/scm/adapters/mercurial_adapter.rb index c9a6dd22e..921c9fcc3 100644 --- a/lib/redmine/scm/adapters/mercurial_adapter.rb +++ b/lib/redmine/scm/adapters/mercurial_adapter.rb @@ -313,7 +313,7 @@ module Redmine private_constant :HG_EARLY_BOOL_ARG, :HG_EARLY_LIST_ARG # Runs 'hg' command with the given args - def hg(*args, &block) + def hg(*args, &) # as of hg 4.4.1, early parsing of bool options is not terminated at '--' if args.any? {|s| HG_EARLY_BOOL_ARG.match?(s)} raise HgCommandArgumentError, "malicious command argument detected" @@ -331,7 +331,7 @@ module Redmine ret = shellout( self.class.sq_bin + ' ' + full_args.map {|e| shell_quote e.to_s}.join(' '), - &block + & ) if $? && $?.exitstatus != 0 raise HgCommandAborted, "hg exited with non-zero status: #{$?.exitstatus}" diff --git a/lib/redmine/search.rb b/lib/redmine/search.rb index 088ad5785..3605d866f 100644 --- a/lib/redmine/search.rb +++ b/lib/redmine/search.rb @@ -23,7 +23,7 @@ module Redmine @@available_search_types = [] class << self - def map(&block) + def map(&) yield self end diff --git a/lib/redmine/syntax_highlighting.rb b/lib/redmine/syntax_highlighting.rb index 69688a45a..b5785f837 100644 --- a/lib/redmine/syntax_highlighting.rb +++ b/lib/redmine/syntax_highlighting.rb @@ -72,7 +72,7 @@ module Redmine @formatter = formatter end - def stream(tokens, &b) + def stream(tokens, &) token_lines(tokens) do |line| line.each do |tok, val| yield @formatter.span(tok, val) diff --git a/lib/redmine/views/builders/structure.rb b/lib/redmine/views/builders/structure.rb index ab1e3e411..ad40e5867 100644 --- a/lib/redmine/views/builders/structure.rb +++ b/lib/redmine/views/builders/structure.rb @@ -27,7 +27,7 @@ module Redmine @response = response end - def array(tag, options={}, &block) + def array(tag, options={}, &) @struct << [] yield(self) ret = @struct.pop diff --git a/lib/redmine/views/builders/xml.rb b/lib/redmine/views/builders/xml.rb index 7ead34d7d..6acc70a6e 100644 --- a/lib/redmine/views/builders/xml.rb +++ b/lib/redmine/views/builders/xml.rb @@ -33,16 +33,16 @@ module Redmine end # Overrides Builder::XmlBase#tag! to format timestamps in ISO 8601 - def tag!(sym, *args, &block) + def tag!(sym, *args, &) if args.size == 1 && args.first.is_a?(::Time) - tag! sym, args.first.xmlschema, &block + tag!(sym, args.first.xmlschema, &) else super end end - def array(name, options={}, &block) - __send__ name, (options || {}).merge(:type => 'array'), &block + def array(name, options={}, &) + __send__(name, (options || {}).merge(:type => 'array'), &) end end end -- cgit v1.2.3