Skip to content

Drop Ruby 1.8 support and clean up#66

Open
HashNotAdam wants to merge 22 commits into
fog:masterfrom
HashNotAdam:fix/cop
Open

Drop Ruby 1.8 support and clean up#66
HashNotAdam wants to merge 22 commits into
fog:masterfrom
HashNotAdam:fix/cop

Conversation

@HashNotAdam
Copy link
Copy Markdown
Contributor

  • Remove Ruby 1.8 Travis CI tests
  • Remove json gem (only needed for Ruby 1.8)
  • Fix style guide violations
  • Reduce duplication
  • Reduce complexity

TODO

Fog::Compute::XenServer::Models::ClassMethods.define_methods has a note about how it could be better designed if not for Ruby 1.8.7 but I couldn't see a test that could explain the use case. Hopefully someone else can help with this.

storage_repository_class.require_before_save.must_equal([ :name, :type ])
end
end No newline at end of file

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

:type => :type,
:uuid => :uuid,
:virtual_allocation => :virtual_allocation,
:pbds => :PBDs,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Use the new Ruby 1.9 hash syntax.

:tags => :tags,
:type => :type,
:uuid => :uuid,
:virtual_allocation => :virtual_allocation,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Use the new Ruby 1.9 hash syntax.
Line is too long. [89/80]

:sm_config => :sm_config,
:tags => :tags,
:type => :type,
:uuid => :uuid,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Use the new Ruby 1.9 hash syntax.

:shared => :shared,
:sm_config => :sm_config,
:tags => :tags,
:type => :type,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Use the new Ruby 1.9 hash syntax.

:description => :description,
:introduced_by => :introduced_by,
:local_cache_enabled => :local_cache_enabled,
:name => :name,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Use the new Ruby 1.9 hash syntax.

:current_operations => :current_operations,
:description => :description,
:introduced_by => :introduced_by,
:local_cache_enabled => :local_cache_enabled,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Use the new Ruby 1.9 hash syntax.
Line is too long. [91/80]

:content_type => :content_type,
:current_operations => :current_operations,
:description => :description,
:introduced_by => :introduced_by,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Use the new Ruby 1.9 hash syntax.

:blobs => :blobs,
:content_type => :content_type,
:current_operations => :current_operations,
:description => :description,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Use the new Ruby 1.9 hash syntax.

:allowed_operations => :allowed_operations,
:blobs => :blobs,
:content_type => :content_type,
:current_operations => :current_operations,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Use the new Ruby 1.9 hash syntax.
Line is too long. [89/80]

storage_repository_class.require_before_save.must_equal([ :name, :type ])
end
end No newline at end of file

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

:type => :type,
:uuid => :uuid,
:virtual_allocation => :virtual_allocation,
:pbds => :PBDs,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Use the new Ruby 1.9 hash syntax.

:tags => :tags,
:type => :type,
:uuid => :uuid,
:virtual_allocation => :virtual_allocation,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Use the new Ruby 1.9 hash syntax.
Line is too long. [89/80]

:sm_config => :sm_config,
:tags => :tags,
:type => :type,
:uuid => :uuid,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Use the new Ruby 1.9 hash syntax.

:shared => :shared,
:sm_config => :sm_config,
:tags => :tags,
:type => :type,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Use the new Ruby 1.9 hash syntax.

:description => :description,
:introduced_by => :introduced_by,
:local_cache_enabled => :local_cache_enabled,
:name => :name,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Use the new Ruby 1.9 hash syntax.

:current_operations => :current_operations,
:description => :description,
:introduced_by => :introduced_by,
:local_cache_enabled => :local_cache_enabled,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Use the new Ruby 1.9 hash syntax.
Line is too long. [91/80]

:content_type => :content_type,
:current_operations => :current_operations,
:description => :description,
:introduced_by => :introduced_by,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Use the new Ruby 1.9 hash syntax.

:blobs => :blobs,
:content_type => :content_type,
:current_operations => :current_operations,
:description => :description,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Use the new Ruby 1.9 hash syntax.

:allowed_operations => :allowed_operations,
:blobs => :blobs,
:content_type => :content_type,
:current_operations => :current_operations,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Use the new Ruby 1.9 hash syntax.
Line is too long. [89/80]

@coveralls
Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.07%) to 94.005% when pulling 54a3323 on HashNotAdam:fix/cop into 2a0ba15 on fog:master.

@coveralls
Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.07%) to 94.012% when pulling afdcf9d on HashNotAdam:fix/cop into 2a0ba15 on fog:master.

@coveralls
Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.07%) to 94.012% when pulling afdcf9d on HashNotAdam:fix/cop into 2a0ba15 on fog:master.


private

def load_data(keep_type = nil, delete_templates = false)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Since this method is for servers collection only maybe you want to rename it to load_servers?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fair call; I'll trust you.
To be really honest, I only have a simple understanding of what this whole gem does — saw some warnings and thought I could apply some standard code practices 😆
I'll do a little more (hopefully over the next day) and will review this again.

@collection_name = collection_name
end

def define_methods(methods)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

❤️ 💙 💚 💛 💜

end

super
end
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Great refactoring. =)

HOST_METHODS = [
:emergency_ha_disable, :list_methods, :local_management_reconfigure,
:management_disable, :management_reconfigure, :shutdown_agent
].freeze
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Loved this. =)

raise RequestFailed.new(
%(#{method}: #{response["ErrorDescription"]})
)
end
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Great Great Great Great Great Great Great Great refactoring. =)

pif_class::PIF_METHODS.each do |method|
methods.include?(method).must_equal(true)
end
end
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You know when the code is good when the test can be as simple as that. Great refactoring including tests. =)

@plribeiro3000
Copy link
Copy Markdown
Member

@HashNotAdam Thats a great PR. I'm really excited to merge it in.

Could you just fix @houndci-bot comments and the one i made regarding the name of the method before i push this forward please?

@HashNotAdam
Copy link
Copy Markdown
Contributor Author

NP @plribeiro3000

In reviewing your comments, I've found a bug in load_data which tells me there is no test for the original code so I'll look at that too.

@coveralls
Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.1%) to 93.951% when pulling b903c05 on HashNotAdam:fix/cop into 2a0ba15 on fog:master.

@HashNotAdam
Copy link
Copy Markdown
Contributor Author

@plribeiro3000, when attempting to add a test for the above-mentioned bug, I encountered a few issues.

Firstly, Fog::Compute::XenServer::Real deals with making server connections. I can see there are a few VCR cassettes that exist that were configured for connecting to a local server, however, I was unable to see any documentation regarding how one might start a server for testing. Without a test server, mock, or cassette, I can't be completely certain that there aren't more bugs.

The second issue is related to the first in that I found there is a huge amount of duplication in this class, however, given the lack of tests, I can't safely refactor. As an example, the method I created from existing code (request_get_all_records) is nearly identical to get_records. Also, most of the request files just make a call to @connection.request using the parser Fog::Parsers::XenServer::Base.new.

If you can provide assistance regarding how I could get a suitable test environment or equivalent, I'd be happy to continue refactoring. If not, I'll just clean up what I've already submitted and leave it there.

@plribeiro3000
Copy link
Copy Markdown
Member

@HashNotAdam Sadly there isn't a documentation regarding testing because even the tests were never finished. Those VCR tests were made using a real XenServer installation on a physical server.

Feel free to let this change off for now so we can merge what you already have and later (another PR) we can tackle this. What do you think?

@HashNotAdam
Copy link
Copy Markdown
Contributor Author

Thanks @plribeiro3000, that sounds good; I'm far too nervous about playing with code I have no way of testing.
If anyone comes up with a way to produce a test environment in the future, I'd be happy jump back in.

@plribeiro3000
Copy link
Copy Markdown
Member

@HashNotAdam Can you confirm nothing broke with those changes?

@HashNotAdam
Copy link
Copy Markdown
Contributor Author

@plribeiro3000 no, as mentioned above, I know of at least one bug so I need to do a clean up and then I'll let you know when I believe it is good.

TBH, even then, if there are no tests, there is no way to be 100% certain.

@plribeiro3000
Copy link
Copy Markdown
Member

@HashNotAdam Thats ok to not work. hehehhe
We can do a release candidate to be sure. =)

Let me know when we can move forward with this.

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.

4 participants