openalias 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 39ac221aa45bd2163ce9c22a8317021344c4d687
4
- data.tar.gz: 9fe23da73dcf88520f0e3f5b232220fb729237ad
3
+ metadata.gz: df775d877c6bf968cd9e75a33f25bad59dfcbc23
4
+ data.tar.gz: 5cd92574a8cf2d7e1bfcf19afcfa94847be10f54
5
5
  SHA512:
6
- metadata.gz: b729f48f77fc5037d4aed7d41ceed7f987cb508b4ca4d2db54c98a13088421e26c39f2f485093837149dfb91e56707d50e3e4dcfd7c9f9cfe2c0d5e931352ec7
7
- data.tar.gz: 4ddf3d8e96adbd9969ba880d93e9b266feede39f1c00113ac33dbb377ae537424b66e933488d5929ff9344ed0c7aa8d35a40163b5f1d888000c421459630f5e1
6
+ metadata.gz: 97b481b4bb24193f79c556877f6388c1de0c555560479f49dfd027cc13dd71473ff4c4a1061348888711a1ef046d8f15417cab3a98072550f25c34174cba3777
7
+ data.tar.gz: 8dee671ce1e80dcbc4e9c8345efd2298afb6b63fbaa34f10f2c1922adf8735683c5ee474f4c35d153caca9118e26196d30b05631ba6ba5b5f1504522c6d2f0ab
data/README.md CHANGED
@@ -15,6 +15,8 @@ At some point it would probably be awesome to rewrite the whole thing in pure ru
15
15
 
16
16
  ## Installation
17
17
 
18
+ (You need `rustc` installed to build the native rust extension)
19
+
18
20
  Add this line to your application's Gemfile:
19
21
 
20
22
  ```ruby
@@ -28,12 +30,15 @@ Or install it yourself as:
28
30
  ## Usage
29
31
 
30
32
  ```ruby
31
- Openalias.addresses('btc@michaelbumann.com')
33
+ Openalias.addresses('btc@michaelbumann.com') # or Openalias.lookup('btc@michaelbumann.com')
32
34
  => [#<Openalias::CryptoAddress cryptocurrency="btc", address="3MGfEx4iaVEAy8nD4rWdocgrPo8aCR4Zfa", recipient_name="bumi">]
33
35
 
34
36
  Openalias.addresses('donate.getmonero.org')
35
37
  => [#<Openalias::CryptoAddress cryptocurrency="xmr", address="44AFFq5kSiGBoZ4NMDwYtN18obc8AemS33DBLWs3H7otXft3XjrpDtQGv7SqSsaBYBb98uNbr2VBBEt7f2wfn3RVGQBEP3A", recipient_name="Monero Development", tx_description="Donation to Monero Core Team">, #<Openalias::CryptoAddress cryptocurrency="btc", address="1KTexdemPdxSBcG55heUuTjDRYqbC5ZL8H", recipient_name="Monero Development", tx_description="Donation to Monero Core Team">]
36
38
 
39
+ Openalias.addresses('donate.getmonero.org').find(&:xmr?)
40
+ => #<Openalias::CryptoAddress cryptocurrency="xmr", address="44AFFq5kSiGBoZ4NMDwYtN18obc8AemS33DBLWs3H7otXft3XjrpDtQGv7SqSsaBYBb98uNbr2VBBEt7f2wfn3RVGQBEP3A", recipient_name="Monero Development", tx_description="Donation to Monero Core Team">
41
+
37
42
  Openalias.addresses('donate.getmonero.org')[0].recipient_name
38
43
  => "Monero Development"
39
44
 
@@ -2,12 +2,24 @@ require 'thermite/fiddle'
2
2
  require 'ostruct'
3
3
 
4
4
  class Openalias
5
- VERSION = "0.1.0"
6
- class CryptoAddress < OpenStruct; end
5
+ VERSION = "0.2.0"
6
+ class CryptoAddress < OpenStruct;
7
+
8
+ def method_missing(method_name, *args, &block)
9
+ if symbol = method_name[/(.*)\?\z/, 1]
10
+ self.cryptocurrency.to_s.downcase === symbol.to_s.downcase
11
+ else
12
+ super
13
+ end
14
+ end
15
+ end
7
16
 
8
17
  toplevel_dir = File.dirname(File.dirname(__FILE__))
9
18
  Thermite::Fiddle.load_module('init_openalias_rust',
10
19
  cargo_project_path: toplevel_dir,
11
20
  ruby_project_path: toplevel_dir)
12
21
 
22
+ def self.lookup(address)
23
+ self.addresses(address)
24
+ end
13
25
  end
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "openalias"
7
- spec.version = "0.1.0"
7
+ spec.version = "0.2.0"
8
8
  spec.authors = ["bumi"]
9
9
  spec.email = ["hello@michaelbumann.com"]
10
10
 
data/src/lib.rs CHANGED
@@ -8,7 +8,7 @@ class!(Openalias);
8
8
 
9
9
  methods!(
10
10
  Openalias,
11
- itself,
11
+ _itself,
12
12
 
13
13
  fn addresses(address: RString) -> Array {
14
14
  let mut cryptoaddresses = Array::new();
@@ -45,8 +45,7 @@ methods!(
45
45
  }
46
46
  return cryptoaddresses;
47
47
  }
48
- Err(cas) => {
49
- println!("{}", cas);
48
+ Err(_cas) => {
50
49
  return cryptoaddresses;
51
50
  }
52
51
  }
@@ -56,7 +55,6 @@ methods!(
56
55
  #[no_mangle]
57
56
  pub extern fn init_openalias_rust() {
58
57
  Class::from_existing("Openalias").define(|itself| {
59
- //Class::new("OpenaliasRust", None).define(|itself| {
60
58
  itself.def_self("addresses", addresses);
61
59
  });
62
60
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openalias
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - bumi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-11-01 00:00:00.000000000 Z
11
+ date: 2018-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler