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-899][WEBSITE-946][WEBSITE-950] Extract components to separate gems. #63

Conversation

katylouise
Copy link
Contributor

  • Extracted decorators to separate gem.
  • Extracted NTriple related code (NTripleResponseBuilder, NTripleResponse) to separate gem.
  • Created a BaseResponse.
  • Refactored tests.
  • Refactored documentation.

# @param [String] base_url the base url of our api. (expected: http://example.com - without the trailing slash).
# @param [Hash] headers the headers being sent in the request.
# @param [Parliament::Builder] builder the builder to use in order to build a response.
# @params [Module] decorators the decorator module to use in order to provide possible alias methods for any objects created by the builder.

Choose a reason for hiding this comment

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

Line is too long. [146/120]

#
# @raise [Parliament::ServerError] when the server responds with a 5xx status code.
# @raise [Parliament::ClientError] when the server responds with a 4xx status code.
# @raise [Parliament::NoContentResponseError] when the server responds with a 204 status code.
#
# @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.
# @return [Parliament::Response::BaseResponse] a Parliament::Response::BaseResponse object containing all of the data returned from the 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. [146/120]

#
# @param [String] base_url the base url of our api. (expected: http://example.com - without the trailing slash).
# @param [Hash] headers the headers being sent in the request.
def initialize(base_url: nil, headers: nil, builder: nil)
# @param [Parliament::Builder] builder the builder to use in order to build a response.
# @params [Module] decorators the decorator module to use in order to provide possible alias methods for any objects created by the builder.

Choose a reason for hiding this comment

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

Line is too long. [146/120]

@katylouise katylouise force-pushed the katylouise/website-899_split-out-ntriples branch from 5dda347 to b8a1951 Compare April 19, 2017 15:42
…arate gems.

* Extracted decorators to separate gem.
* Extracted NTriple related code (NTripleResponseBuilder, NTripleResponse) to separate gem.
* Created a BaseResponse.
* Refactored tests.
* Refactored documentation.
Copy link
Contributor

@mattrayner mattrayner left a comment

Choose a reason for hiding this comment

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

Hi @bex, I've added some comments/changes below

Gemfile Outdated
@@ -5,3 +5,6 @@ gemspec

# Include coveralls for CI coverage reports
gem 'coveralls', require: false

gem 'parliament-grom-decorators', path: '../parliament-grom-decorators'
Copy link
Contributor

Choose a reason for hiding this comment

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

If these are being used for testing we will need to either add them as development dependencies or look at how they are needed within the app.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is also breaking tests

@@ -1,12 +1,21 @@
module Parliament
module Builder
# API response builder, allowing the user to return the body of an HTTPResponse.
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be 'Base response builder'? It's not technically API specific

class BaseResponseBuilder
def initialize(response)
# Creates a new BaseReponseBuilder.
# @param [HTTPResponse] response an HTTP response containing n-triple data.
Copy link
Contributor

Choose a reason for hiding this comment

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

Does it need to contain ntriple data?

def initialize(response)
# Creates a new BaseReponseBuilder.
# @param [HTTPResponse] response an HTTP response containing n-triple data.
# @param [Module] decorators the decorator modules to provide alias methods to the resulting objects.
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be more like:

'A namespace which contains modules used to decorate the objects we receive'?

Copy link
Contributor

Choose a reason for hiding this comment

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

Infact, is this even needed? Our base response doesn't actually use the decorators?

Copy link
Contributor

Choose a reason for hiding this comment

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

Seeing the code below perhaps we need to mention why it's not used and that it is for API completeness?

@@ -1,78 +1,83 @@
module Parliament
module Request
# API request object, allowing the user to make a request to an API.
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this API specific?

@@ -61,10 +61,10 @@
end

context 'it accepts query parameters' do
Copy link
Contributor

Choose a reason for hiding this comment

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

What is this actually testing?

How does this test prove that what you're expecting to happen, actually happens? You don't appear to be checking that the params hash actually generates the URL you expect? Just that a connection to that URL could be made. Infact, this response isn't even checking that it's a 200?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have changed this test to check the request made contains the parameters expected in the url.

@@ -24,7 +25,7 @@
end

describe '#respond_to_missing?' do
subject { Parliament::Request::UrlRequest.new(base_url: 'http://test.com') }
subject { Parliament::Request::UrlRequest.new(base_url: 'http://test.com', decorators: Parliament::Grom::Decorator) }
Copy link
Contributor

Choose a reason for hiding this comment

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

Looking at this, parliament-grom-decorators should be aded as a development dependency?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have added parliament-grom-decorators as a dev dependency in the gemspec.

let(:response) { 'hello world' }
subject { Parliament::Response::BaseResponse.new(response) }

it 'has a response' do
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this the correct way to test what a method returns?

@@ -22,23 +22,23 @@

Copy link
Contributor

Choose a reason for hiding this comment

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

Should these utils be part of the Ntriple gem? It's directly related to that data and output?

@@ -8,6 +8,8 @@

$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
require 'parliament'
require 'parliament/grom/decorator'
Copy link
Contributor

Choose a reason for hiding this comment

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

These two should DEFINITELY be development dependencies

@mattrayner
Copy link
Contributor

On top of this, you're tests fail because of the relative paths used in Gemfile

# @param [Module] decorators the decorator module to use in order to provide possible alias methods for any objects created by the builder.
# @example Passing headers
#
# request = Parliament::Request::UrlRequest.new(base_url: 'http://example.com', headers: { 'Access-Token' => '12345678' })

Choose a reason for hiding this comment

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

Line is too long. [128/120]

# @param [String] base_url the base url of our api. (expected: http://example.com - without the trailing slash).
# @param [Hash] headers the headers being sent in the request.
# @param [Parliament::Builder] builder the builder to use in order to build a response.
# @param [Module] decorators the decorator module to use in order to provide possible alias methods for any objects created by the builder.

Choose a reason for hiding this comment

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

Line is too long. [145/120]

def initialize(response)
# Creates a new BaseReponseBuilder.
# @param [HTTPResponse] response an HTTP response.
# @param [Module] decorators a namespace which contains modules used to decorate the objects we receive. It is not used directly by the BaseResponseBuilder, but is there for API completeness.

Choose a reason for hiding this comment

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

Line is too long. [198/120]

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 3c9e889 on katylouise:katylouise/website-899_split-out-ntriples into fec78fd on ukparliament:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling f8a0ed8 on katylouise:katylouise/website-899_split-out-ntriples into fec78fd on ukparliament:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 513a0de on katylouise:katylouise/website-899_split-out-ntriples into fec78fd on ukparliament:master.

@mattrayner mattrayner merged commit 5a1aa34 into ukparliament:master Apr 24, 2017
@katylouise katylouise deleted the katylouise/website-899_split-out-ntriples branch June 9, 2017 09:47
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