1
0
mirror of https://github.com/bumi/openalias-ruby synced 2024-10-03 10:29:46 +00:00

Add Openalias.lookup as alias to Openalias.addresses

The rust implementation uses #addresses but I find #lookup a bit more
intuitive and descriptive.
This commit is contained in:
bumi 2018-11-03 18:36:50 +01:00
parent 867cb68df6
commit cd337c42b1
3 changed files with 9 additions and 2 deletions

View File

@ -30,7 +30,7 @@ Or install it yourself as:
## Usage
```ruby
Openalias.addresses('btc@michaelbumann.com')
Openalias.addresses('btc@michaelbumann.com') # or Openalias.lookup('btc@michaelbumann.com')
=> [#<Openalias::CryptoAddress cryptocurrency="btc", address="3MGfEx4iaVEAy8nD4rWdocgrPo8aCR4Zfa", recipient_name="bumi">]
Openalias.addresses('donate.getmonero.org')

View File

@ -19,4 +19,7 @@ class Openalias
cargo_project_path: toplevel_dir,
ruby_project_path: toplevel_dir)
def self.lookup(address)
self.addresses(address)
end
end

View File

@ -5,11 +5,15 @@ RSpec.describe Openalias do
expect(Openalias::VERSION).not_to be nil
end
it "provides #lookup as an alias for #addresses" do
expect(Openalias).to respond_to(:lookup)
end
it "provides ? methods to check for the currency" do
expect(Openalias.addresses('donate.getmonero.org').find { |c| c.cryptocurrency.downcase == 'xmr' }.xmr?).to eql(true)
expect(Openalias.addresses('donate.getmonero.org').find { |c| c.cryptocurrency.downcase == 'xmr' }.btc?).to eql(false)
expect(Openalias.addresses('donate.getmonero.org').find(&:xmr?).xmr?).to eql(true)
expect(Openalias.addresses('donate.getmonero.org').find(&:xmr?).xmr).to eql(true)
expect(Openalias.addresses('donate.getmonero.org').find(&:xmr?).btc?).to eql(false)
end
it "provides accessors for the data" do