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

Allow for Nexpose::Connection.new to consume URI objects #38

Merged
merged 2 commits into from
Sep 6, 2013
Merged

Allow for Nexpose::Connection.new to consume URI objects #38

merged 2 commits into from
Sep 6, 2013

Conversation

erran
Copy link
Contributor

@erran erran commented Sep 5, 2013

No description provided.

@host = ip
@port = port
@username = user
@password = pass
@silo_id = silo_id
@session_id = nil
@url = "https://#{@host}:#{@port}/api/API_VERSION/xml"
@url = File.join("https://#{@host}:#{@port}", '/api/API_VERSION/xml')
Copy link
Contributor

Choose a reason for hiding this comment

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

File.join ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's a habit you pick up from using Chef too much. 😄 I've seen it in other libraries like Octokit.rb too. It can also be used to join uri components (URI.join does the same and adds validation on some components). I'll revert this line, since it doesn't change anything until the suggestion in my comment is addressed. I think I'll remove the comment, address your suggestions, and create a new issue.

@mdaines-r7
Copy link
Contributor

Do you have some example usages?

My inclination would be to have a function that generates the Connection. Something like

def self.from_uri(uri)
  # parse out and create new Connection
end

@erran
Copy link
Contributor Author

erran commented Sep 6, 2013

Yeah, that sounds good. I mostly wanted a way to parse it out. Having a from_uri method gets it done as well. When I picked the gem back up after not interacting with it for a while my first attempt to create a Nexpose::Connection object failed due to me not specified the params separately using: Nexpose::Connection.new('https://nexpose.local:3780')

@erran
Copy link
Contributor Author

erran commented Sep 6, 2013

nx_uri = URI.parse('https://nexpose.local:3780')
Nexpose::Connection.new('nexpose', 3780, 'nxadmin', 'password', nil)
Nexpose::Connection.from_uri(nx_uri, 'nxadmin', 'password', nil)
Nexpose::Connection.from_uri('https://nexpose.local:3780', 'nxadmin', 'password', nil)

@erran
Copy link
Contributor Author

erran commented Sep 6, 2013

That should be it for this PR. As for the rest, I guess it won't apply until we update the actual Nexpose API.

On an unrelated note check out this file I've been using to add extensions to this gem: Nexpose::Console.

mdaines-r7 added a commit that referenced this pull request Sep 6, 2013
Allow for Nexpose::Connection.new to consume URI objects
@mdaines-r7 mdaines-r7 merged commit 584d03b into rapid7:master Sep 6, 2013
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.

2 participants