From 83f390bd2a822ab14489799833d72f1e78f72c17 Mon Sep 17 00:00:00 2001 From: Kanezoh Date: Wed, 16 Jun 2021 23:35:14 +0900 Subject: [PATCH] delete unnnecessary namespace --- src/mechanize/form.cr | 20 ++++++++++---------- src/mechanize/form/check_box.cr | 2 +- src/mechanize/http/agent.cr | 4 ++-- src/mechanize/page.cr | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/mechanize/form.cr b/src/mechanize/form.cr index aebab19..1bfcd2f 100644 --- a/src/mechanize/form.cr +++ b/src/mechanize/form.cr @@ -2,8 +2,8 @@ require "./form/field" require "./form/check_box" class MechanizeCr::Form - getter fields : Array(MechanizeCr::FormContent::Field) - getter checkboxes : Array(MechanizeCr::FormContent::CheckBox) + getter fields : Array(FormContent::Field) + getter checkboxes : Array(FormContent::CheckBox) getter enctype : String getter method : String getter name : String @@ -12,8 +12,8 @@ class MechanizeCr::Form def initialize(node : Node | Myhtml::Node) @enctype = node.fetch("enctype", "application/x-www-form-urlencoded") @node = node - @fields = Array(MechanizeCr::FormContent::Field).new - @checkboxes = Array(MechanizeCr::FormContent::CheckBox).new + @fields = Array(FormContent::Field).new + @checkboxes = Array(FormContent::CheckBox).new @action = node.fetch("action", "") @method = node.fetch("method", "GET").upcase @name = node.fetch("name", "") @@ -49,21 +49,21 @@ class MechanizeCr::Form def field_with(criteria) f = fields_with(criteria) - raise MechanizeCr::ElementNotFoundError.new(:field, criteria) if f.nil? + raise ElementNotFoundError.new(:field, criteria) if f.nil? f.first end private def parse - @fields = Array(MechanizeCr::FormContent::Field).new - @checkboxes = Array(MechanizeCr::FormContent::CheckBox).new + @fields = Array(FormContent::Field).new + @checkboxes = Array(FormContent::CheckBox).new @node.css("input").not_nil!.each do |html_node| html_node = html_node.as(Myhtml::Node) type = (html_node["type"] || "text").downcase case type when "checkbox" - @checkboxes << MechanizeCr::FormContent::CheckBox.new(html_node, self) + @checkboxes << FormContent::CheckBox.new(html_node, self) else - @fields << MechanizeCr::FormContent::Field.new(html_node) + @fields << FormContent::Field.new(html_node) end end end @@ -77,7 +77,7 @@ class MechanizeCr::Form private def build_query query = [] of Array(String) - successful_controls = Array(MechanizeCr::FormContent::Field | MechanizeCr::FormContent::CheckBox).new + successful_controls = Array(FormContent::Field | FormContent::CheckBox).new fields.each do |elm| successful_controls << elm end diff --git a/src/mechanize/form/check_box.cr b/src/mechanize/form/check_box.cr index c9607d6..0cf336b 100644 --- a/src/mechanize/form/check_box.cr +++ b/src/mechanize/form/check_box.cr @@ -1,7 +1,7 @@ class MechanizeCr::FormContent::CheckBox < MechanizeCr::FormContent::Field property :checked, :form - def initialize(node : Node | Myhtml::Node, form : MechanizeCr::Form) + def initialize(node : Node | Myhtml::Node, form : Form) @checked = !!node["checked"] @form = form super(node) diff --git a/src/mechanize/http/agent.cr b/src/mechanize/http/agent.cr index 833c224..018302d 100644 --- a/src/mechanize/http/agent.cr +++ b/src/mechanize/http/agent.cr @@ -5,9 +5,9 @@ module MechanizeCr module HTTP class Agent property :request_headers, :context, :cookies - property history : Array(MechanizeCr::Page) + property history : Array(Page) def initialize(@context : Mechanize | Nil = nil) - @history = Array(MechanizeCr::Page).new + @history = Array(Page).new @request_headers = ::HTTP::Headers.new @context = context @cookies = Hash(String, ::HTTP::Cookies).new diff --git a/src/mechanize/page.cr b/src/mechanize/page.cr index 7ab77ba..d6cdb93 100644 --- a/src/mechanize/page.cr +++ b/src/mechanize/page.cr @@ -22,7 +22,7 @@ class MechanizeCr::Page < MechanizeCr::File def forms forms = css("form").map do |html_form| - form = MechanizeCr::Form.new(html_form) + form = Form.new(html_form) form.action ||= @uri.to_s form end.to_a