Skip to content

Commit 3d0d537

Browse files
committed
Merge pull request #12 from yock/ruby-git
refactor: Replacing system() call for Git commands with ruby-git
2 parents f9acf39 + 70fc71d commit 3d0d537

File tree

15 files changed

+47
-71
lines changed

15 files changed

+47
-71
lines changed

.gitmodules

Whitespace-only changes.

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
source 'https://rubygems.org'
22

33
gem 'thor'
4+
gem 'git'
45

56
group :development, :test do
67
gem 'rspec', '~> 2.14'

Gemfile.lock

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ GEM
77
columnize (0.3.6)
88
debugger-linecache (1.2.0)
99
diff-lcs (1.2.5)
10+
git (1.2.6)
1011
rspec (2.14.1)
1112
rspec-core (~> 2.14.0)
1213
rspec-expectations (~> 2.14.0)
@@ -22,5 +23,6 @@ PLATFORMS
2223

2324
DEPENDENCIES
2425
byebug
26+
git
2527
rspec (~> 2.14)
2628
thor

forte.gemspec

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ $:.unshift File.expand_path("../lib", __FILE__)
22

33
Gem::Specification.new do |s|
44
s.name = 'forte'
5-
s.version = '0.0.2'
5+
s.description = 'Create an authorized_keys file for a shared shell account from a repository of public key files '
6+
s.homepage = 'https://github.com/yock/forte'
7+
s.version = '0.0.3'
68
s.summary = 'Create an authorized_keys file for a shared shell account from a repository of public key files'
79
s.platform = Gem::Platform::RUBY
810
s.authors = ['Michael Yockey', 'Ryan Cromwell']

forte.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
#!/usr/bin/env sh
2-
ruby -Ilib bin/forte
2+
ruby -Ilib bin/forte print https://github.com/yock/forte.git

lib/forte.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
require 'thor'
2-
require 'forte/git'
2+
require 'git'
3+
require 'fileutils'
34
require 'forte/authorized_keys'
45
require 'forte/base'
56
require 'forte/keyfile'
7+
require 'forte/repo_location'

lib/forte/base.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
class Base < Thor
22
desc "print", "Prints the public keys to STDOUT"
33
def print(uri)
4-
dir = Git.clone(uri)
5-
puts AuthorizedKeys.build(dir)
6-
Git.cleanup
4+
loc = RepoLocation.new(uri)
5+
repo = Git.clone(loc.uri, File.join(Dir.pwd, './.tmp'))
6+
puts AuthorizedKeys.build(repo.dir.path)
7+
FileUtils.rm_rf(repo.dir.path)
78
end
89
end

lib/forte/git.rb

Lines changed: 0 additions & 25 deletions
This file was deleted.

lib/forte/repo_location.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class RepoLocation
2+
attr_accessor :path
3+
4+
def initialize(path)
5+
@path = path
6+
end
7+
8+
def uri
9+
return path if path.start_with?('http')
10+
return path if Dir.exists?(File.join(path, '.git'))
11+
"https://github.com/#{path}.git"
12+
end
13+
14+
end

spec/base_spec.rb

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)