Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WEBSITE-877] Refactor requests #60

Conversation

katylouise
Copy link
Contributor

  • Created separate requests for general urls and opensearch.
  • Created separate builders for opensearch and ntriples.
  • Created base builder and base request.

self || super
end

# This class always responds to method calls, even those missing. Therefore, respond_to_missing? always returns true.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is too long. [123/120]

@@ -0,0 +1,60 @@
module Parliament
module Request
class UrlRequest < Parliament::Request::BaseRequest

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing top-level class documentation comment.

@query_url
end

def setup_query_url(search_params)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Method has too many lines. [12/10]

end
end

def query_url

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use attr_reader to define trivial reader methods.

return if url.nil?

request = Parliament::Request::BaseRequest.new(base_url: url,
headers: { 'Accept' => 'application/opensearchdescription+xml' })

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Align the elements of a hash literal if they span more than one line.
Line is too long. [122/120]


module Parliament
module Request
class OpenSearchRequest < Parliament::Request::BaseRequest

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing top-level class documentation comment.

# @param [Hash] params (optional) additional URI encoded form values to be added to the URI.
#
# @return [Parliament::Response] a Parliament::Response object containing all of the nodes returned from the URL.
def get(params: nil)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assignment Branch Condition size for get is too high. [18.14/15]
Method has too many lines. [11/10]

#
# An interesting note for #initialize is that setting base_url on the class, or using the environment variable
# PARLIAMENT_BASE_URL means you don't need to pass in a base_url. You can pass one anyway to override the
# environment variable or class parameter. Similarly, headers can be set by either settings the headers on the class, or passing headers in.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is too long. [147/120]

@@ -0,0 +1,136 @@
module Parliament
module Request
class BaseRequest

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing top-level class documentation comment.


module Parliament
module Builder
class OpenSearchResponseBuilder < Parliament::Builder::BaseResponseBuilder

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing top-level class documentation comment.

@katylouise katylouise force-pushed the katylouise/website-899_refactor-request branch from 46a1a15 to 386ff3e Compare April 7, 2017 11:45
@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 386ff3e on katylouise:katylouise/website-899_refactor-request into 8d93001 on ukparliament:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 386ff3e on katylouise:katylouise/website-899_refactor-request into 8d93001 on ukparliament:master.

}.freeze

def initialize(base_url: nil, headers: nil, builder: nil)
@base_url = Parliament::Request::OpenSearchRequest.get_description(base_url) || self.class.base_url
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we include an ENV lookup like 'OPENSEARCH_DESCRIPTION_URL'?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

@@ -0,0 +1,73 @@
module Parliament
module Request
class OpenSearchRequest < Parliament::Request::BaseRequest

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing top-level class documentation comment.

headers: { 'Accept' => 'application/opensearchdescription+xml' })
xml_response = request.get

xml_root = REXML::Document.new(xml_response.body).root
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to check - is this still needed with our gem usage? Or should we use our gem too?

}.freeze

def initialize(base_url: nil, headers: nil, builder: nil)
@base_url = Parliament::Request::OpenSearchRequest.get_description(base_url) || self.class.base_url || ENV['OPENSEARCH_DESCRIPTION_URL']

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is too long. [144/120]

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 1bb3aec on katylouise:katylouise/website-899_refactor-request into 8d93001 on ukparliament:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 1bb3aec on katylouise:katylouise/website-899_refactor-request into 8d93001 on ukparliament:master.

@mattrayner mattrayner merged commit 656e5a5 into ukparliament:master Apr 7, 2017
@katylouise katylouise deleted the katylouise/website-899_refactor-request branch June 9, 2017 09:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants