github-auth 0.4.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CONTRIBUTING.md +13 -0
- data/README.md +25 -7
- data/Rakefile +2 -0
- data/github-auth.gemspec +1 -0
- data/lib/github/auth/keys_file.rb +1 -1
- data/lib/github/auth/version.rb +1 -1
- data/spec/unit/github/auth/keys_file_spec.rb +48 -31
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8ed96df336ef90a6312aace8d6c3e2aa33be4bbe
|
4
|
+
data.tar.gz: ed9ff502f8ff004a45d1026fb4061035932031a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 928de18477f4ab0ed074741d2045594733175fa803bd0240429555012f1ea8ef03884fae4545c6f4208a80960663c618999cb3168b29d5d86034821d4f9a0a30
|
7
|
+
data.tar.gz: cdcf7345687a26546cff7980bc625721b41db2f7b81af0ced07f5e133007eaa6d372990f4e60e234fcb8715cc45c58196ca743670755fcbedb88d21247f103cf
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Contributing
|
2
|
+
|
3
|
+
Want to contribute? Awesome! Thank you so much.
|
4
|
+
|
5
|
+
## How?
|
6
|
+
|
7
|
+
1. [Fork it](https://help.github.com/articles/fork-a-repo)
|
8
|
+
2. Create a feature branch (`git checkout -b my-new-feature`)
|
9
|
+
3. Commit changes, **with tests** (`git commit -am 'Add some feature'`)
|
10
|
+
4. Run the tests (`bundle exec rake`)
|
11
|
+
5. Push to the branch (`git push origin my-new-feature`)
|
12
|
+
6. Create new [Pull
|
13
|
+
Request](https://help.github.com/articles/using-pull-requests)
|
data/README.md
CHANGED
@@ -46,10 +46,33 @@ Removing 2 key(s) from '/Users/chris/.ssh/authorized_keys'
|
|
46
46
|
|
47
47
|
## Usage
|
48
48
|
|
49
|
+
### Command Line
|
50
|
+
|
51
|
+
`gh-auth` can be used from the command line after the gem has been installed.
|
52
|
+
|
49
53
|
```bash
|
50
54
|
usage: gh-auth [--version] [add|remove] <username>
|
51
55
|
```
|
52
56
|
|
57
|
+
### In You Project
|
58
|
+
|
59
|
+
Want to add/remove keys in your project, but not on the command line? That's ok
|
60
|
+
too.
|
61
|
+
|
62
|
+
```ruby
|
63
|
+
require 'github/auth'
|
64
|
+
|
65
|
+
# Add keys for GitHub user 'chrishunt'
|
66
|
+
Github::Auth::CLI.new(%w(
|
67
|
+
add chrishunt
|
68
|
+
)).execute
|
69
|
+
|
70
|
+
# Remove keys for GitHub user 'chrishunt'
|
71
|
+
Github::Auth::CLI.new(%w(
|
72
|
+
remove chrishunt
|
73
|
+
)).execute
|
74
|
+
```
|
75
|
+
|
53
76
|
## Installation
|
54
77
|
|
55
78
|
Install the `github-auth` gem:
|
@@ -176,10 +199,5 @@ If this isn't possible, then you can use a VPS provider like
|
|
176
199
|
[Linode](http://www.linode.com) to setup a pairing machine in the cloud.
|
177
200
|
|
178
201
|
## Contributing
|
179
|
-
|
180
|
-
|
181
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
182
|
-
3. Commit your changes, with tests (`git commit -am 'Add some feature'`)
|
183
|
-
4. Run the tests (`bundle exec rake spec`)
|
184
|
-
5. Push to the branch (`git push origin my-new-feature`)
|
185
|
-
6. Create new Pull Request
|
202
|
+
Please see the [Contributing
|
203
|
+
Document](https://github.com/chrishunt/github-auth/blob/master/CONTRIBUTING.md)
|
data/Rakefile
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'bundler/gem_tasks'
|
2
2
|
require 'rspec/core/rake_task'
|
3
3
|
require 'cane/rake_task'
|
4
|
+
require 'cane/hashcheck'
|
4
5
|
|
5
6
|
desc 'Run all tests'
|
6
7
|
RSpec::Core::RakeTask.new(:spec) do |task|
|
@@ -10,6 +11,7 @@ end
|
|
10
11
|
desc 'Check code quality'
|
11
12
|
Cane::RakeTask.new(:quality) do |task|
|
12
13
|
task.abc_max = 9
|
14
|
+
task.use Cane::HashCheck
|
13
15
|
end
|
14
16
|
|
15
17
|
task default: :spec
|
data/github-auth.gemspec
CHANGED
@@ -22,6 +22,7 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.add_development_dependency 'rake'
|
23
23
|
spec.add_development_dependency 'rspec'
|
24
24
|
spec.add_development_dependency 'cane'
|
25
|
+
spec.add_development_dependency 'cane-hashcheck'
|
25
26
|
spec.add_development_dependency 'coveralls'
|
26
27
|
spec.add_development_dependency 'sinatra'
|
27
28
|
spec.add_development_dependency 'thin'
|
@@ -50,7 +50,7 @@ module Github::Auth
|
|
50
50
|
|
51
51
|
def keys_file_content_without(keys)
|
52
52
|
keys_file_content.tap do |content|
|
53
|
-
Array(keys).each {
|
53
|
+
Array(keys).each {|k| content.gsub! /#{Regexp.escape k}( .*)?$\n?/, '' }
|
54
54
|
content.strip!
|
55
55
|
end
|
56
56
|
end
|
data/lib/github/auth/version.rb
CHANGED
@@ -5,7 +5,7 @@ require 'github/auth/keys_file'
|
|
5
5
|
describe Github::Auth::KeysFile do
|
6
6
|
subject { described_class.new path: path }
|
7
7
|
|
8
|
-
let(:keys) { %w(abc123 def456) }
|
8
|
+
let(:keys) { %w(abc123 def456 ghi789) }
|
9
9
|
let(:keys_file) { Tempfile.new 'authorized_keys' }
|
10
10
|
let(:path) { keys_file.path }
|
11
11
|
|
@@ -40,8 +40,10 @@ describe Github::Auth::KeysFile do
|
|
40
40
|
describe '#write!' do
|
41
41
|
it 'writes each key to the keys file' do
|
42
42
|
subject.write! keys
|
43
|
-
|
44
|
-
|
43
|
+
|
44
|
+
keys_file.read.tap do |keys_file_content|
|
45
|
+
keys.each { |key| expect(keys_file_content).to include key }
|
46
|
+
end
|
45
47
|
end
|
46
48
|
|
47
49
|
context 'with a single key' do
|
@@ -100,60 +102,75 @@ describe Github::Auth::KeysFile do
|
|
100
102
|
keys_file.rewind
|
101
103
|
end
|
102
104
|
|
103
|
-
|
104
|
-
let(:key) { keys[0] }
|
105
|
-
let(:other_key) { keys[1] }
|
106
|
-
|
105
|
+
shared_examples_for 'a successful key removal' do
|
107
106
|
it 'removes the key from the keys file' do
|
108
107
|
subject.delete! key
|
108
|
+
|
109
109
|
expect(keys_file.read).to_not include key
|
110
110
|
end
|
111
111
|
|
112
|
-
it 'does not remove the other
|
112
|
+
it 'does not remove the other keys from the keys file' do
|
113
113
|
subject.delete! key
|
114
|
-
|
114
|
+
|
115
|
+
keys_file.read.tap do |keys_file_content|
|
116
|
+
keys.reject { |other_key| other_key =~ /#{key}/ }.each do |key|
|
117
|
+
expect(keys_file_content).to include key
|
118
|
+
end
|
119
|
+
end
|
115
120
|
end
|
116
121
|
|
117
|
-
it 'does not leave blank
|
118
|
-
subject.delete!
|
119
|
-
blank_lines = keys_file.readlines.select { |line| line =~ /^$\n/ }
|
122
|
+
it 'does not leave a blank line' do
|
123
|
+
subject.delete! key
|
120
124
|
|
121
|
-
expect(
|
125
|
+
expect(
|
126
|
+
keys_file.readlines.select { |line| line =~ /^$\n/ }
|
127
|
+
).to be_empty
|
122
128
|
end
|
123
129
|
end
|
124
130
|
|
125
|
-
context 'when the
|
126
|
-
let(:key) {
|
131
|
+
context 'when the key is at the beginning of the keys file' do
|
132
|
+
let(:key) { keys.first }
|
127
133
|
|
128
|
-
|
129
|
-
|
130
|
-
keys_file.rewind
|
134
|
+
it_should_behave_like 'a successful key removal'
|
135
|
+
end
|
131
136
|
|
132
|
-
|
137
|
+
context 'when the key is in the middle of the keys file' do
|
138
|
+
let(:key) { keys[1] }
|
133
139
|
|
134
|
-
|
135
|
-
|
140
|
+
it_should_behave_like 'a successful key removal'
|
141
|
+
end
|
142
|
+
|
143
|
+
context 'when the key is at the end of the keys file' do
|
144
|
+
let(:key) { keys.last }
|
145
|
+
|
146
|
+
it_should_behave_like 'a successful key removal'
|
136
147
|
end
|
137
148
|
|
138
149
|
context 'when the key has a comment' do
|
139
|
-
let(:
|
150
|
+
let(:keys) {[ 'abc123', "#{key} #{comment}", 'ghi789' ]}
|
151
|
+
let(:key) { 'def456' }
|
140
152
|
let(:comment) { 'this is a comment' }
|
141
|
-
let(:keys) { ["#{key} #{comment}", 'def456'] }
|
142
|
-
let(:other_key) { keys[1] }
|
143
153
|
|
144
|
-
|
145
|
-
subject.delete! key
|
146
|
-
expect(keys_file.read).to_not include key
|
147
|
-
end
|
154
|
+
it_should_behave_like 'a successful key removal'
|
148
155
|
|
149
156
|
it 'removes the comment from the keys file' do
|
150
157
|
subject.delete! key
|
158
|
+
|
151
159
|
expect(keys_file.read).to_not include comment
|
152
160
|
end
|
161
|
+
end
|
153
162
|
|
154
|
-
|
155
|
-
|
156
|
-
|
163
|
+
context 'when the keys file does not have the key' do
|
164
|
+
let(:key) { 'not-in-the-keys-file' }
|
165
|
+
|
166
|
+
it 'does not modify the keys file' do
|
167
|
+
keys_file.read.tap do |original_keys_file_content|
|
168
|
+
keys_file.rewind
|
169
|
+
|
170
|
+
subject.delete! key
|
171
|
+
|
172
|
+
expect(keys_file.read).to eq original_keys_file_content
|
173
|
+
end
|
157
174
|
end
|
158
175
|
end
|
159
176
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: github-auth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Hunt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-05-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - '>='
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: cane-hashcheck
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: coveralls
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -132,6 +146,7 @@ extra_rdoc_files: []
|
|
132
146
|
files:
|
133
147
|
- .gitignore
|
134
148
|
- .travis.yml
|
149
|
+
- CONTRIBUTING.md
|
135
150
|
- Gemfile
|
136
151
|
- LICENSE.txt
|
137
152
|
- README.md
|