dnkey 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6df844c5af54d67654bd8ddb0ba1b42598355e93
4
+ data.tar.gz: 54cfe463a54ce2623ea450d00bffcd55a01e6e5c
5
+ SHA512:
6
+ metadata.gz: f29b127a575f799c52dd1c693930ea50f08baa2af7e5c914947e2de1ab1866381e19ac97486d1fd9b8339bde6fda152e9a5f6f071f3963717f29eab927c2c80e
7
+ data.tar.gz: c28570934d2967f87938f3548fae392c7f9e2160f1962764bb97112067500a00a254f310f1816cf993cb41eddb2c9148b0f17d2dedd7302b14aa180cf646283f
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.1
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in dnkey.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 parasquid
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,70 @@
1
+ # Dnkey
2
+
3
+ Put your Ruby code in the file `lib/dnkey`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'dnkey'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install dnkey
20
+
21
+ ## Usage
22
+
23
+ ### Generic API usage
24
+
25
+ ```Dnkey::API.get('mark.neuroware.io', :key => :btc, :nameservers => ['8.8.8.8'])```
26
+
27
+ ### Domain Specifc Language
28
+
29
+ We have a number of baked-in classes to help out in the more common use cases (like getting a bitcoin key).
30
+
31
+ For example, if you'd like to get the bitcoin key from the domain ```mark.neuroware.io``` you can call:
32
+
33
+ ```Dnkey::Bitcoin.get('mark.neuroware.io) # => ["1M4VYf837vbKc9mJxqGdM2w1xPmZNDXdGa", "33aaehx6p4QrTHMvQUZy3dTEevXr4Wprap"]```
34
+
35
+ We have built-in support for the following dnkeys:
36
+
37
+ * Bitcoin (:btc)
38
+ * Litecoin (:lite)
39
+ * Dogecoin (:doge)
40
+ * Dashcoin (:dash)
41
+ * Email (:email)
42
+
43
+ We'll be adding more dnkey-specific classes later on, PRs are welcome!
44
+
45
+ You can also get all dnkeys from the domain using:
46
+
47
+ Dnkey::API.get_all('mark.neuroware.io')
48
+ #=> {
49
+ :btc => ["1M4VYf837vbKc9mJxqGdM2w1xPmZNDXdGa", "13aaehx6p4QrTHMvQUZy3dTEevXr4Wprap"],
50
+ :email => ["mark@neuroware.io"],
51
+ :ltc => ["LMUN5ZPQCym1sz2XxbunhWsfwJc5nKfANN"],
52
+ :doge => ["DNvyxwdSTuzhXmHye6PbGvGWk5EEEZvXpF"],
53
+ :dash => ["XeRsLXWVjdnc92AC16zh2segmAbyBZ5Qkt"]
54
+ }
55
+
56
+ It will return a hash with the dnkey as the key and the value as an array of the values.
57
+
58
+ ## Development
59
+
60
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
61
+
62
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
63
+
64
+ ## Contributing
65
+
66
+ 1. Fork it ( https://github.com/Neuroware-IO/dnkey/fork )
67
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
68
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
69
+ 4. Push to the branch (`git push origin my-new-feature`)
70
+ 5. Create a new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "dnkey"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'dnkey/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "dnkey"
8
+ spec.version = Dnkey::VERSION
9
+ spec.authors = ["parasquid"]
10
+ spec.email = ["tristan.gomez@gmail.com"]
11
+
12
+ spec.summary = %q{DNKey library for Ruby}
13
+ spec.description = %q{DNKs (Doman Name Keys) provide a standardized way in which to broadcast public keys via DNS TXT records. This is especially useful for Bitcoin and other cryptographic addresses, where instead of having to remember over thirty seemingly random characters.}
14
+ spec.homepage = "https://github.com/Neuroware-IO/dnkey-ruby"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_dependency 'dnsruby'
23
+ spec.add_development_dependency "bundler", "~> 1.9"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ spec.add_development_dependency "pry"
26
+ end
@@ -0,0 +1,73 @@
1
+ require "dnkey/version"
2
+ require 'dnsruby'
3
+ require 'pry'
4
+ include Dnsruby
5
+
6
+ module Dnkey
7
+ def self.default_options
8
+ {:nameservers => ['8.8.8.8']}
9
+ end
10
+
11
+ class API
12
+ def self.get(domain, options=Dnkey::default_options)
13
+ keys = get_txt_entries(domain, options).answer.find_all do |answer|
14
+ value = answer.strings.first
15
+ value.include? "dnkey-#{options[:key].to_s}"
16
+ end
17
+ keys.map.each {|key| key.rdata.first.split('=').last.strip}
18
+ end
19
+
20
+ def self.get_all(domain, options=Dnkey::default_options)
21
+ keys = get_txt_entries(domain, options).answer.find_all do |answer|
22
+ value = answer.strings.first
23
+ value.include? "dnkey-"
24
+ end
25
+ result = {}
26
+ keys.each do |key|
27
+ entry = key.rdata.first.split('=')
28
+ result[entry.first.gsub('dnkey-','').to_sym] ||= []
29
+ result[entry.first.gsub('dnkey-','').to_sym] << entry.last.strip
30
+ end
31
+ result
32
+ end
33
+
34
+ private
35
+
36
+ def self.get_txt_entries(domain, options)
37
+ res = Dnsruby::Resolver.new(nameservers: options[:nameservers])
38
+ ret = res.query(domain, Types.TXT)
39
+ end
40
+ end
41
+
42
+ # TODO: refactor out the duplication
43
+ class Bitcoin
44
+ def self.get(domain, options={})
45
+ API.get(domain, {:key => :btc}.merge(options).merge(Dnkey::default_options))
46
+ end
47
+ end
48
+
49
+ class Litecoin
50
+ def self.get(domain, options={})
51
+ API.get(domain, {:key => :lite}.merge(options).merge(Dnkey::default_options))
52
+ end
53
+ end
54
+
55
+ class Dogecoin
56
+ def self.get(domain, options={})
57
+ API.get(domain, {:key => :doge}.merge(options).merge(Dnkey::default_options))
58
+ end
59
+ end
60
+
61
+ class Dashcoin
62
+ def self.get(domain, options={})
63
+ API.get(domain, {:key => :dash}.merge(options).merge(Dnkey::default_options))
64
+ end
65
+ end
66
+
67
+ class Email
68
+ def self.get(domain, options={})
69
+ API.get(domain, {:key => :email}.merge(options).merge(Dnkey::default_options))
70
+ end
71
+ end
72
+
73
+ end
@@ -0,0 +1,3 @@
1
+ module Dnkey
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,116 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dnkey
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - parasquid
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-04-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: dnsruby
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.9'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.9'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: DNKs (Doman Name Keys) provide a standardized way in which to broadcast
70
+ public keys via DNS TXT records. This is especially useful for Bitcoin and other
71
+ cryptographic addresses, where instead of having to remember over thirty seemingly
72
+ random characters.
73
+ email:
74
+ - tristan.gomez@gmail.com
75
+ executables: []
76
+ extensions: []
77
+ extra_rdoc_files: []
78
+ files:
79
+ - ".gitignore"
80
+ - ".rspec"
81
+ - ".travis.yml"
82
+ - CODE_OF_CONDUCT.md
83
+ - Gemfile
84
+ - LICENSE.txt
85
+ - README.md
86
+ - Rakefile
87
+ - bin/console
88
+ - bin/setup
89
+ - dnkey.gemspec
90
+ - lib/dnkey.rb
91
+ - lib/dnkey/version.rb
92
+ homepage: https://github.com/Neuroware-IO/dnkey-ruby
93
+ licenses:
94
+ - MIT
95
+ metadata: {}
96
+ post_install_message:
97
+ rdoc_options: []
98
+ require_paths:
99
+ - lib
100
+ required_ruby_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ required_rubygems_version: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ requirements: []
111
+ rubyforge_project:
112
+ rubygems_version: 2.4.6
113
+ signing_key:
114
+ specification_version: 4
115
+ summary: DNKey library for Ruby
116
+ test_files: []