cosmetic changes

master
Anton Maminov 2022-11-04 15:19:48 +02:00
parent cc6f42b796
commit c783485d9a
7 changed files with 13 additions and 11 deletions

View File

@ -193,7 +193,6 @@ class Mechanize
# submitted with multiple buttons, pass each button to this method.
def add_button_to_query(button)
unless button.form_node == @node
message = ""
"#{button.inspect} does not belong to the same page as " \
"the form #{@name.inspect} in #{@page.try &.uri}"
message = "not a valid button"

View File

@ -23,10 +23,14 @@ class Mechanize::FormContent::SelectList < Mechanize::FormContent::MultiSelectLi
end
def value=(new_value)
values = new_value
@values = new_value
end
def query_value
value ? [[name, value.not_nil!]] : nil
if v = value
[[name, v]]
else
nil
end
end
end

View File

@ -30,7 +30,7 @@ class Mechanize
if size == 0
# TODO: raise error
end
page = @array.pop
@array.pop
end
end
end

View File

@ -318,7 +318,6 @@ class Mechanize
# extract valid cookies according to URI
private def valid_cookies(uri)
host = uri.host
valid_cookies = ::HTTP::Cookies.new
request_cookies.each do |cookie|
valid_cookies << cookie if cookie.valid_cookie?(uri)

View File

@ -127,7 +127,7 @@ class Mechanize
return nil unless value
return [name, value]
[name, value]
end
##

View File

@ -43,11 +43,11 @@ class Mechanize
# page.forms # => Array(Mechanize::Form)
# ```
def forms : Array(Form)
forms = css("form").map do |html_form|
css("form").map do |html_form|
form = Form.new(html_form, self)
form.action ||= @uri.to_s
form
end.to_a
end
end
# return all links(`Mechanize::PageContent::Link`) in the page.
@ -55,11 +55,11 @@ class Mechanize
# page.links # => Array(Mechanize::PageContent::Link)
# ```
def links : Array(PageContent::Link)
links = %w{a area}.map do |tag|
%w{a area}.flat_map do |tag|
css(tag).map do |node|
PageContent::Link.new(node, @mech, self)
end
end.flatten
end
end
elements_with "form"

View File

@ -5,7 +5,7 @@ class Mechanize
macro elements_with(singular, plural = "")
{% plural = "#{singular.id}s" if plural.empty? %}
# search {{ plural.id }} which match condition.
#
#
# Examples
# ```
# # if you specify String like "foo", it searches {{ singular.id }} which name is "foo".