poet 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/MIT-LICENSE +19 -0
- data/README +9 -0
- data/Rakefile +1 -0
- data/bin/poet +62 -0
- data/lib/poet.rb +1 -0
- data/lib/poet/version.rb +3 -0
- data/poet.gemspec +24 -0
- metadata +76 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/MIT-LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2009 André Wendt
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
data/README
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
Lost in a long list of host stanzas in your ssh_config?
|
2
|
+
|
3
|
+
Fear not -- divide them up into several smaller files under $HOME/.ssh/config.d/ and run 'ssh-confgen' to concatenate them into a single ssh_config.
|
4
|
+
|
5
|
+
'ssh-confgen' does not overwrite your existing ssh_config. If you want to play with it, move your existing config out of the way.
|
6
|
+
|
7
|
+
Stanzas under $HOME/.ssh/config.d/ with an extension of .disabled are ignored by ssh-confgen. Every now and then, when you do need it, run 'ssh-confgen --with CONFIG' to explicitly include CONFIG.disabled in your generated ssh_config. You can even include several by running several '--with' options or using '--with CONFIG1,CONFIG2'.
|
8
|
+
|
9
|
+
If you only want an ssh_config from certain files, use '--only CONFIG' or '--only CONFIG1,CONFIG2'.
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/poet
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'optparse'
|
4
|
+
|
5
|
+
CONF_DIR = File.expand_path('~/.ssh/config.d')
|
6
|
+
SSH_CONFIG = File.expand_path('~/.ssh/config')
|
7
|
+
MAGIC_LINE = "# Generated by #{File.basename(__FILE__)}"
|
8
|
+
|
9
|
+
options = {:verbose => false, :with => [], :only => []}
|
10
|
+
|
11
|
+
optparse = OptionParser.new do|opts|
|
12
|
+
opts.on('-h', '--help', 'Display this screen') do
|
13
|
+
puts opts
|
14
|
+
exit
|
15
|
+
end
|
16
|
+
opts.on('-v', '--verbose', 'Be verbose') do |file|
|
17
|
+
options[:verbose] = true
|
18
|
+
end
|
19
|
+
opts.on('-w', '--with CONFIG', 'Include an otherwise disabled config file') do |file|
|
20
|
+
options[:with] += file.split(',')
|
21
|
+
options[:with].each{|file| puts "Including #{file} even if disabled..."}
|
22
|
+
end
|
23
|
+
opts.on('-o', '--only CONFIG', 'Use only given config files') do |file|
|
24
|
+
options[:only] += file.split(',')
|
25
|
+
options[:only].each{|file| puts "Using only #{file}..."}
|
26
|
+
end
|
27
|
+
end
|
28
|
+
optparse.parse!
|
29
|
+
|
30
|
+
if !File.directory?(CONF_DIR)
|
31
|
+
puts "#{CONF_DIR} does not exist or is not a directory"
|
32
|
+
Process.exit!(1)
|
33
|
+
end
|
34
|
+
|
35
|
+
if File.exists?(SSH_CONFIG) && File.new(SSH_CONFIG).gets == "#{MAGIC_LINE}\n"
|
36
|
+
puts "Found generated ssh_config under #{SSH_CONFIG}. Overwriting..."
|
37
|
+
elsif File.exists?(SSH_CONFIG)
|
38
|
+
puts "Found hand-crafted ssh_config under #{SSH_CONFIG}. Please move it out of the way."
|
39
|
+
Process.exit!(2)
|
40
|
+
end
|
41
|
+
|
42
|
+
File.open(SSH_CONFIG, 'w') do |ssh_config|
|
43
|
+
ssh_config.puts(MAGIC_LINE)
|
44
|
+
ssh_config.puts("# DO NOT EDIT THIS FILE")
|
45
|
+
ssh_config.puts("# Create or modify files under #{CONF_DIR}/ instead")
|
46
|
+
end
|
47
|
+
|
48
|
+
if options[:only].empty?
|
49
|
+
files = Dir["#{CONF_DIR}/**"].reject do |file|
|
50
|
+
file =~ /\.disabled$/ && !options[:with].include?("#{File.basename(file, '.disabled')}")
|
51
|
+
end
|
52
|
+
else
|
53
|
+
files = Dir["#{CONF_DIR}/**"].select do |file|
|
54
|
+
options[:only].include?(File.basename(file, '.disabled'))
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
files.sort.each do |file|
|
59
|
+
puts "Concatenating #{file}" if options[:verbose]
|
60
|
+
%x(/bin/cat #{file} >> #{SSH_CONFIG})
|
61
|
+
%x(echo >> #{SSH_CONFIG})
|
62
|
+
end
|
data/lib/poet.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "poet/version"
|
data/lib/poet/version.rb
ADDED
data/poet.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "poet/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "poet"
|
7
|
+
s.version = Poet::VERSION
|
8
|
+
s.authors = ["André Wendt"]
|
9
|
+
s.email = [%w(awendt freeshell.org).join('@')]
|
10
|
+
s.homepage = "https://github.com/awendt/poet"
|
11
|
+
s.summary = %q{Poet concatenates stanzas}
|
12
|
+
s.description = %q{Split your longish ~/.ssh/config into files in ~/.ssh/config.d/ and let poet join them for you.}
|
13
|
+
|
14
|
+
s.rubyforge_project = "poet"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
# specify any dependencies here; for example:
|
22
|
+
# s.add_development_dependency "rspec"
|
23
|
+
# s.add_runtime_dependency "rest-client"
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: poet
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- "Andr\xC3\xA9 Wendt"
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2012-03-29 00:00:00 +02:00
|
19
|
+
default_executable:
|
20
|
+
dependencies: []
|
21
|
+
|
22
|
+
description: Split your longish ~/.ssh/config into files in ~/.ssh/config.d/ and let poet join them for you.
|
23
|
+
email:
|
24
|
+
- awendt@freeshell.org
|
25
|
+
executables:
|
26
|
+
- poet
|
27
|
+
extensions: []
|
28
|
+
|
29
|
+
extra_rdoc_files: []
|
30
|
+
|
31
|
+
files:
|
32
|
+
- .gitignore
|
33
|
+
- Gemfile
|
34
|
+
- MIT-LICENSE
|
35
|
+
- README
|
36
|
+
- Rakefile
|
37
|
+
- bin/poet
|
38
|
+
- lib/poet.rb
|
39
|
+
- lib/poet/version.rb
|
40
|
+
- poet.gemspec
|
41
|
+
has_rdoc: true
|
42
|
+
homepage: https://github.com/awendt/poet
|
43
|
+
licenses: []
|
44
|
+
|
45
|
+
post_install_message:
|
46
|
+
rdoc_options: []
|
47
|
+
|
48
|
+
require_paths:
|
49
|
+
- lib
|
50
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
hash: 3
|
56
|
+
segments:
|
57
|
+
- 0
|
58
|
+
version: "0"
|
59
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
|
+
none: false
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
hash: 3
|
65
|
+
segments:
|
66
|
+
- 0
|
67
|
+
version: "0"
|
68
|
+
requirements: []
|
69
|
+
|
70
|
+
rubyforge_project: poet
|
71
|
+
rubygems_version: 1.6.2
|
72
|
+
signing_key:
|
73
|
+
specification_version: 3
|
74
|
+
summary: Poet concatenates stanzas
|
75
|
+
test_files: []
|
76
|
+
|