ghkeys 1.0 → 2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -9
- data/Gemfile.lock +49 -0
- data/README.md +3 -1
- data/ghkeys.gemspec +1 -0
- data/lib/ghkeys.rb +12 -8
- data/lib/ghkeys/exceptions.rb +4 -0
- data/lib/ghkeys/ssh_key.rb +39 -0
- data/lib/ghkeys/version.rb +1 -1
- metadata +18 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b96a1df80d832753a10798c758f2718117c2c74
|
4
|
+
data.tar.gz: 4534718ba71425d75f3da84ffe86033f56abf34d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 205fd042fcde45ad2c131eea6e669f30c7b8f1b7bd76d8fd9b711bd75ccf5a3e3c4a5b8d751c576bed6c59fea4300748b1201dddf5d89c95c137cf9d9bdfca38
|
7
|
+
data.tar.gz: 7760232838783003009e1aa9f3a46dc8970ab4a9f38c6e63c89214d45e68797ee1a33ce730f75474383d9600dad8fd976deae05daa5f48e57aa837d80b299cf1
|
data/.gitignore
CHANGED
data/Gemfile.lock
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
ghkeys (1.0)
|
5
|
+
httparty (~> 0.13.7)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
coderay (1.1.1)
|
11
|
+
diff-lcs (1.2.5)
|
12
|
+
httparty (0.13.7)
|
13
|
+
json (~> 1.8)
|
14
|
+
multi_xml (>= 0.5.2)
|
15
|
+
json (1.8.3)
|
16
|
+
method_source (0.8.2)
|
17
|
+
multi_xml (0.5.5)
|
18
|
+
pry (0.10.3)
|
19
|
+
coderay (~> 1.1.0)
|
20
|
+
method_source (~> 0.8.1)
|
21
|
+
slop (~> 3.4)
|
22
|
+
rake (10.5.0)
|
23
|
+
rspec (3.4.0)
|
24
|
+
rspec-core (~> 3.4.0)
|
25
|
+
rspec-expectations (~> 3.4.0)
|
26
|
+
rspec-mocks (~> 3.4.0)
|
27
|
+
rspec-core (3.4.4)
|
28
|
+
rspec-support (~> 3.4.0)
|
29
|
+
rspec-expectations (3.4.0)
|
30
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
31
|
+
rspec-support (~> 3.4.0)
|
32
|
+
rspec-mocks (3.4.1)
|
33
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
34
|
+
rspec-support (~> 3.4.0)
|
35
|
+
rspec-support (3.4.1)
|
36
|
+
slop (3.6.0)
|
37
|
+
|
38
|
+
PLATFORMS
|
39
|
+
ruby
|
40
|
+
|
41
|
+
DEPENDENCIES
|
42
|
+
bundler (~> 1.12)
|
43
|
+
ghkeys!
|
44
|
+
pry
|
45
|
+
rake (~> 10.0)
|
46
|
+
rspec (~> 3.0)
|
47
|
+
|
48
|
+
BUNDLED WITH
|
49
|
+
1.12.5
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# GHKeys - GitHub Keys
|
2
2
|
|
3
3
|
GitHub Keys gem allows you to fetch users keys in the simplest way. It uses web scraping because of GH API limits.
|
4
4
|
|
@@ -27,6 +27,8 @@ GHKeys('axvm')
|
|
27
27
|
=> #array of strings
|
28
28
|
```
|
29
29
|
|
30
|
+
Each key will be wrapped into SSHKey class. It gives you ability to calculate md5\sha1\sha256 fingerprints. If key is corrupted or invalid, `IncorrectOrCorruptedKey` exception will be raised.
|
31
|
+
|
30
32
|
## Contributing
|
31
33
|
|
32
34
|
Bug reports and pull requests are welcome on GitHub at https://github.com/axvm/ghkeys.
|
data/ghkeys.gemspec
CHANGED
data/lib/ghkeys.rb
CHANGED
@@ -1,28 +1,32 @@
|
|
1
1
|
require "ghkeys/version"
|
2
|
+
require 'ghkeys/exceptions'
|
3
|
+
require "ghkeys/ssh_key"
|
4
|
+
require "sshkey"
|
2
5
|
require "httparty"
|
3
|
-
require 'pry'
|
4
6
|
|
5
7
|
module GHKeys
|
6
8
|
extend self
|
7
9
|
|
8
10
|
def fetch(username)
|
9
11
|
response = HTTParty.get("https://github.com/#{username}.keys")
|
10
|
-
raise UserNotFound
|
12
|
+
raise UserNotFound if response.code == 404
|
11
13
|
|
12
14
|
response.split("\n")
|
13
15
|
end
|
14
16
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
@user = user
|
19
|
-
super(msg)
|
17
|
+
def parse(keys)
|
18
|
+
keys.inject [] do |a, k|
|
19
|
+
a << SSHKey.new(k)
|
20
20
|
end
|
21
21
|
end
|
22
|
+
|
23
|
+
def by_username(username)
|
24
|
+
parse(fetch(username))
|
25
|
+
end
|
22
26
|
end
|
23
27
|
|
24
28
|
module Kernel
|
25
29
|
def GHKeys(username)
|
26
|
-
|
30
|
+
by_username(username)
|
27
31
|
end
|
28
32
|
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module GHKeys
|
2
|
+
class SSHKey
|
3
|
+
attr_accessor :key
|
4
|
+
|
5
|
+
def initialize(base64_key)
|
6
|
+
@key = base64_key
|
7
|
+
|
8
|
+
raise IncorrectOrCorruptedKey unless valid?
|
9
|
+
end
|
10
|
+
|
11
|
+
def valid?
|
12
|
+
::SSHKey.valid_ssh_public_key? @key
|
13
|
+
end
|
14
|
+
|
15
|
+
def bits
|
16
|
+
::SSHKey.ssh_public_key_bits @key
|
17
|
+
end
|
18
|
+
|
19
|
+
def md5_fingerprint
|
20
|
+
::SSHKey.fingerprint @key
|
21
|
+
end
|
22
|
+
|
23
|
+
def sha1_fingerprint
|
24
|
+
::SSHKey.sha1_fingerprint @key
|
25
|
+
end
|
26
|
+
|
27
|
+
def sha256_fingerprint
|
28
|
+
::SSHKey.sha256_fingerprint @key
|
29
|
+
end
|
30
|
+
|
31
|
+
def to_s
|
32
|
+
@key
|
33
|
+
end
|
34
|
+
|
35
|
+
def inspect
|
36
|
+
to_s
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/lib/ghkeys/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ghkeys
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '
|
4
|
+
version: '2.0'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- axvm
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: 0.13.7
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: sshkey
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 1.8.0
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 1.8.0
|
83
97
|
description: Simple gem might be useful when you need to fetch users public keys
|
84
98
|
email:
|
85
99
|
- axvmindaweb@gmail.com
|
@@ -91,12 +105,15 @@ files:
|
|
91
105
|
- ".rspec"
|
92
106
|
- ".travis.yml"
|
93
107
|
- Gemfile
|
108
|
+
- Gemfile.lock
|
94
109
|
- README.md
|
95
110
|
- Rakefile
|
96
111
|
- bin/console
|
97
112
|
- bin/setup
|
98
113
|
- ghkeys.gemspec
|
99
114
|
- lib/ghkeys.rb
|
115
|
+
- lib/ghkeys/exceptions.rb
|
116
|
+
- lib/ghkeys/ssh_key.rb
|
100
117
|
- lib/ghkeys/version.rb
|
101
118
|
homepage: https://github.com/axvm/ghkeys
|
102
119
|
licenses: []
|