github-ssh-keys-for 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/Gemfile +8 -0
- data/LICENSE.txt +22 -0
- data/README.md +15 -0
- data/Rakefile +2 -0
- data/bin/github_ssh_keys_for +18 -0
- data/github-ssh-keys-for.gemspec +23 -0
- data/lib/github_ssh_keys_for/get_keys.rb +34 -0
- data/lib/github_ssh_keys_for/print_keys.rb +15 -0
- data/lib/github_ssh_keys_for/version.rb +3 -0
- data/spec/github_ssh_keys_for/get_keys_spec.rb +42 -0
- data/spec/github_ssh_keys_for/print_keys_spec.rb +10 -0
- metadata +88 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 4dc57cfc9066ffa09f9deeb876d4f468d788e63d
|
|
4
|
+
data.tar.gz: da8e593127eb9ebad24eeb18eb5d7176968a6688
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: ebd930a1a874df900c191270439da2ab963b3940c24ed6d9d50f5065c642355c0b382e4b0381e380f5d7ce893f4cdcb52b1f8e79a1cd6a7e0a7f9a36ea9069cc
|
|
7
|
+
data.tar.gz: 25870f55b10f325c9d48c734e1d91e38dc4b094bb706532256c50e2c497674a7a2290a49f3cafc88de89be65cbfac1ebf7f92a603ba02a1377b85822551b27fa
|
data/.gitignore
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
*.gem
|
|
2
|
+
*.rbc
|
|
3
|
+
.bundle
|
|
4
|
+
.config
|
|
5
|
+
.yardoc
|
|
6
|
+
Gemfile.lock
|
|
7
|
+
InstalledFiles
|
|
8
|
+
_yardoc
|
|
9
|
+
coverage
|
|
10
|
+
doc/
|
|
11
|
+
lib/bundler/man
|
|
12
|
+
pkg
|
|
13
|
+
rdoc
|
|
14
|
+
spec/reports
|
|
15
|
+
test/tmp
|
|
16
|
+
test/version_tmp
|
|
17
|
+
tmp
|
|
18
|
+
*.bundle
|
|
19
|
+
*.so
|
|
20
|
+
*.o
|
|
21
|
+
*.a
|
|
22
|
+
mkmf.log
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright (c) 2014 Sandro Padin
|
|
2
|
+
|
|
3
|
+
MIT License
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
data/Rakefile
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#! /usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require_relative '../lib/github_ssh_keys_for/get_keys'
|
|
4
|
+
require_relative '../lib/github_ssh_keys_for/print_keys'
|
|
5
|
+
|
|
6
|
+
def get_keys(username)
|
|
7
|
+
GithubSshKeysFor::GetKeys.new(username).execute
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def print_keys(keys)
|
|
11
|
+
GithubSshKeysFor::PrintKeys.new(keys).execute
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
username = ARGV[0]
|
|
15
|
+
keys = get_keys(username)
|
|
16
|
+
|
|
17
|
+
puts "# Github public keys for '#{username}'"
|
|
18
|
+
print_keys keys
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'github_ssh_keys_for/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "github-ssh-keys-for"
|
|
8
|
+
spec.version = GithubSshKeysFor::VERSION
|
|
9
|
+
spec.authors = ["Sandro Padin"]
|
|
10
|
+
spec.email = ["sandropadin@gmail.com"]
|
|
11
|
+
spec.summary = %q{Find and print the SSH keys for any Github user.}
|
|
12
|
+
spec.description = %q{Find and print the SSH keys for any Github user.}
|
|
13
|
+
spec.homepage = "https://github.com/spadin/github-ssh-keys-for"
|
|
14
|
+
spec.license = "MIT"
|
|
15
|
+
|
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
|
19
|
+
spec.require_paths = ["lib"]
|
|
20
|
+
|
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
|
22
|
+
spec.add_development_dependency "rake"
|
|
23
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
require 'open-uri'
|
|
2
|
+
require 'json'
|
|
3
|
+
|
|
4
|
+
module GithubSshKeysFor
|
|
5
|
+
class GetKeys
|
|
6
|
+
def initialize(username)
|
|
7
|
+
@username = username
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def execute
|
|
11
|
+
response = open_json_uri(uri)
|
|
12
|
+
response.map do |item|
|
|
13
|
+
item["key"]
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
private
|
|
18
|
+
|
|
19
|
+
attr_reader :username
|
|
20
|
+
|
|
21
|
+
def uri
|
|
22
|
+
"https://api.github.com/users/#{username}/keys"
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def open_uri(uri)
|
|
26
|
+
OpenURI::open_uri(uri).read
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def open_json_uri(uri)
|
|
30
|
+
response = open_uri(uri)
|
|
31
|
+
JSON.parse(response)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
require 'github_ssh_keys_for/get_keys'
|
|
2
|
+
|
|
3
|
+
module GithubSshKeysFor
|
|
4
|
+
describe GetKeys do
|
|
5
|
+
context 'opening a network connection' do
|
|
6
|
+
it 'attempts to get the file at https://api.github.com/users/spadin/keys' do
|
|
7
|
+
expect_any_instance_of(described_class).to receive(:open_uri).and_return("{}")
|
|
8
|
+
described_class.new("spadin").execute
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
context 'network connections mocked' do
|
|
13
|
+
let(:key_1) { "ssh-rsa key-1"}
|
|
14
|
+
let(:key_2) { "ssh-rsa key-2"}
|
|
15
|
+
let(:key_3) { "ssh-rsa key-3"}
|
|
16
|
+
let(:json) {[
|
|
17
|
+
{
|
|
18
|
+
"id" => 00001,
|
|
19
|
+
"key" => key_1
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"id" => 00002,
|
|
23
|
+
"key" => key_2
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"id" => 00003,
|
|
27
|
+
"key" => key_3
|
|
28
|
+
}
|
|
29
|
+
]}
|
|
30
|
+
|
|
31
|
+
it 'returns an array with the ssh keys only' do
|
|
32
|
+
allow_any_instance_of(described_class)
|
|
33
|
+
.to receive(:open_json_uri).and_return(json)
|
|
34
|
+
|
|
35
|
+
execute = described_class.new("spadin").execute
|
|
36
|
+
|
|
37
|
+
expect(execute).to include(key_1, key_2, key_3)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
require 'github_ssh_keys_for/print_keys'
|
|
2
|
+
|
|
3
|
+
module GithubSshKeysFor
|
|
4
|
+
describe PrintKeys do
|
|
5
|
+
it 'prints the items in the array one line a time' do
|
|
6
|
+
keys = ['ssh_key key_1', 'ssh_key key_2']
|
|
7
|
+
expect { described_class.new(keys).execute }.to output("ssh_key key_1\nssh_key key_2\n").to_stdout
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: github-ssh-keys-for
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Sandro Padin
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2014-07-15 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: bundler
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - ~>
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '1.6'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - ~>
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.6'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rake
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - '>='
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - '>='
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '0'
|
|
41
|
+
description: Find and print the SSH keys for any Github user.
|
|
42
|
+
email:
|
|
43
|
+
- sandropadin@gmail.com
|
|
44
|
+
executables:
|
|
45
|
+
- github_ssh_keys_for
|
|
46
|
+
extensions: []
|
|
47
|
+
extra_rdoc_files: []
|
|
48
|
+
files:
|
|
49
|
+
- .gitignore
|
|
50
|
+
- Gemfile
|
|
51
|
+
- LICENSE.txt
|
|
52
|
+
- README.md
|
|
53
|
+
- Rakefile
|
|
54
|
+
- bin/github_ssh_keys_for
|
|
55
|
+
- github-ssh-keys-for.gemspec
|
|
56
|
+
- lib/github_ssh_keys_for/get_keys.rb
|
|
57
|
+
- lib/github_ssh_keys_for/print_keys.rb
|
|
58
|
+
- lib/github_ssh_keys_for/version.rb
|
|
59
|
+
- spec/github_ssh_keys_for/get_keys_spec.rb
|
|
60
|
+
- spec/github_ssh_keys_for/print_keys_spec.rb
|
|
61
|
+
homepage: https://github.com/spadin/github-ssh-keys-for
|
|
62
|
+
licenses:
|
|
63
|
+
- MIT
|
|
64
|
+
metadata: {}
|
|
65
|
+
post_install_message:
|
|
66
|
+
rdoc_options: []
|
|
67
|
+
require_paths:
|
|
68
|
+
- lib
|
|
69
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
70
|
+
requirements:
|
|
71
|
+
- - '>='
|
|
72
|
+
- !ruby/object:Gem::Version
|
|
73
|
+
version: '0'
|
|
74
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
75
|
+
requirements:
|
|
76
|
+
- - '>='
|
|
77
|
+
- !ruby/object:Gem::Version
|
|
78
|
+
version: '0'
|
|
79
|
+
requirements: []
|
|
80
|
+
rubyforge_project:
|
|
81
|
+
rubygems_version: 2.0.14
|
|
82
|
+
signing_key:
|
|
83
|
+
specification_version: 4
|
|
84
|
+
summary: Find and print the SSH keys for any Github user.
|
|
85
|
+
test_files:
|
|
86
|
+
- spec/github_ssh_keys_for/get_keys_spec.rb
|
|
87
|
+
- spec/github_ssh_keys_for/print_keys_spec.rb
|
|
88
|
+
has_rdoc:
|