-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add HostPool connection metadata support (#2)
* Add support for arbitrary metadata to be attached to each Remotus::HostPool upon initialization. This is useful when defining additional authentication stores that may need more information than the hostname to gather appropriate credentials.
- Loading branch information
Showing
10 changed files
with
168 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# frozen_string_literal: true | ||
|
||
module Remotus | ||
# Core Ruby extensions | ||
module CoreExt | ||
# String extension module | ||
module String | ||
unless method_defined?(:to_method_name) | ||
# | ||
# Converts a string into a safe method name that can be used for instance variables | ||
# | ||
# @return [Symbol] Method name | ||
# | ||
def to_method_name | ||
gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2') | ||
.gsub(/([a-z])([A-Z])/, '\1_\2') | ||
.tr(" ", "_") | ||
.gsub(/(?:[^_a-zA-Z0-9]|^\d+)/, "") | ||
.downcase | ||
.to_sym | ||
end | ||
end | ||
end | ||
end | ||
end | ||
|
||
String.include(Remotus::CoreExt::String) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,5 +2,5 @@ | |
|
||
module Remotus | ||
# Remotus gem version | ||
VERSION = "0.1.0" | ||
VERSION = "0.2.0" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# frozen_string_literal: true | ||
|
||
RSpec.describe Remotus::CoreExt::String do | ||
let(:data) do | ||
{ | ||
"TestThisThing" => :test_this_thing, | ||
"123Invalid_start" => :invalid_start, | ||
" many spaces" => :___many____spaces, | ||
"OSThing" => :os_thing, | ||
"!@#$%^&*&()-=invalid_starting_characters" => :invalid_starting_characters, | ||
"Invalid!@#$%^&*()-=_Interior_chars" => :invalid_interior_chars | ||
} | ||
end | ||
|
||
describe "#to_method_name" do | ||
it "converts the string to a safe method name that can be used for instance variables" do | ||
data.each do |str, out| | ||
expect(str.to_method_name).to eq(out) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters