sshster 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/.rspec +3 -0
- data/.rubocop.yml +12 -0
- data/.travis.yml +7 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +65 -0
- data/LICENSE.txt +21 -0
- data/README.md +43 -0
- data/Rakefile +6 -0
- data/bin/sshster +6 -0
- data/lib/sshster/actions/base.rb +38 -0
- data/lib/sshster/actions/compose.rb +87 -0
- data/lib/sshster/actions/help.rb +19 -0
- data/lib/sshster/actions/init.rb +42 -0
- data/lib/sshster/app.rb +46 -0
- data/lib/sshster/argv_parser.rb +36 -0
- data/lib/sshster/config.rb +44 -0
- data/lib/sshster/version.rb +3 -0
- data/lib/sshster.rb +15 -0
- data/sshster.gemspec +30 -0
- metadata +149 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c1fad7d301df4b6de92f730ae4b825594ba55c05d48cffcf8a769cc80b7f1dd0
|
4
|
+
data.tar.gz: 4cc12eda71b55f249740e1fcc9565bfd7267652f08ee5e5410d06161754e9063
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 781b5853fa368b6b9df34ddd956fde3cf4d264384095e624215267c86d240ba3f0213a15582299bc6c2b1b30494b2c5ece812ead2b77d3cf704135669d0d5681
|
7
|
+
data.tar.gz: 34fa3ff5e3989befd4881e37fb941bc250b33913740a9d609eb65ea78fe1d75c13a71219e4e7f6973c2d72700dfbe438d258fdc2df058b695009dbfc1e496589
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
Style/StringLiterals:
|
2
|
+
EnforcedStyle: single_quotes
|
3
|
+
Metrics/LineLength:
|
4
|
+
Max: 120
|
5
|
+
Metrics/BlockLength:
|
6
|
+
Enabled: false
|
7
|
+
Style/TrailingCommaInHashLiteral:
|
8
|
+
Enabled: false
|
9
|
+
Style/Documentation:
|
10
|
+
Enabled: false
|
11
|
+
Style/ModuleFunction:
|
12
|
+
Enabled: false
|
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at vanyazin@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
sshster (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
ast (2.4.0)
|
10
|
+
coderay (1.1.2)
|
11
|
+
coolline (0.5.0)
|
12
|
+
unicode_utils (~> 1.4)
|
13
|
+
diff-lcs (1.3)
|
14
|
+
jaro_winkler (1.5.2)
|
15
|
+
method_source (0.9.2)
|
16
|
+
parallel (1.17.0)
|
17
|
+
parser (2.6.2.1)
|
18
|
+
ast (~> 2.4.0)
|
19
|
+
pry (0.12.2)
|
20
|
+
coderay (~> 1.1.0)
|
21
|
+
method_source (~> 0.9.0)
|
22
|
+
pry-coolline (0.2.5)
|
23
|
+
coolline (~> 0.5)
|
24
|
+
psych (3.1.0)
|
25
|
+
rainbow (3.0.0)
|
26
|
+
rake (10.5.0)
|
27
|
+
rspec (3.8.0)
|
28
|
+
rspec-core (~> 3.8.0)
|
29
|
+
rspec-expectations (~> 3.8.0)
|
30
|
+
rspec-mocks (~> 3.8.0)
|
31
|
+
rspec-core (3.8.0)
|
32
|
+
rspec-support (~> 3.8.0)
|
33
|
+
rspec-expectations (3.8.3)
|
34
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
35
|
+
rspec-support (~> 3.8.0)
|
36
|
+
rspec-mocks (3.8.0)
|
37
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
38
|
+
rspec-support (~> 3.8.0)
|
39
|
+
rspec-support (3.8.0)
|
40
|
+
rubocop (0.67.2)
|
41
|
+
jaro_winkler (~> 1.5.1)
|
42
|
+
parallel (~> 1.10)
|
43
|
+
parser (>= 2.5, != 2.5.1.1)
|
44
|
+
psych (>= 3.1.0)
|
45
|
+
rainbow (>= 2.2.2, < 4.0)
|
46
|
+
ruby-progressbar (~> 1.7)
|
47
|
+
unicode-display_width (>= 1.4.0, < 1.6)
|
48
|
+
ruby-progressbar (1.10.0)
|
49
|
+
unicode-display_width (1.5.0)
|
50
|
+
unicode_utils (1.4.0)
|
51
|
+
|
52
|
+
PLATFORMS
|
53
|
+
ruby
|
54
|
+
|
55
|
+
DEPENDENCIES
|
56
|
+
bundler (~> 1.17)
|
57
|
+
pry
|
58
|
+
pry-coolline
|
59
|
+
rake (~> 10.0)
|
60
|
+
rspec (~> 3.0)
|
61
|
+
rubocop
|
62
|
+
sshster!
|
63
|
+
|
64
|
+
BUNDLED WITH
|
65
|
+
1.17.3
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 Ivan Zinovyev
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# Sshster
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/sshster`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'sshster'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install sshster
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/sshster. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
40
|
+
|
41
|
+
## Code of Conduct
|
42
|
+
|
43
|
+
Everyone interacting in the Sshster project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/sshster/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/sshster
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
require 'fileutils'
|
3
|
+
|
4
|
+
module Sshster
|
5
|
+
module Actions
|
6
|
+
class Base
|
7
|
+
attr_accessor :config
|
8
|
+
|
9
|
+
def initialize(config)
|
10
|
+
@config = config
|
11
|
+
end
|
12
|
+
|
13
|
+
def run; end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def config_path
|
18
|
+
@config_path ||= root_path.join('config')
|
19
|
+
end
|
20
|
+
|
21
|
+
def origin_config_path
|
22
|
+
@origin_config_path ||= root_path.join('config.orig')
|
23
|
+
end
|
24
|
+
|
25
|
+
def projects_path
|
26
|
+
@projects_path ||= root_path.join('sshster')
|
27
|
+
end
|
28
|
+
|
29
|
+
def sshster_config_path
|
30
|
+
@sshster_config_path ||= root_path.join('sshster.yml')
|
31
|
+
end
|
32
|
+
|
33
|
+
def root_path
|
34
|
+
@root_path ||= Pathname.new(config['ssh_config'])
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
module Sshster
|
2
|
+
module Actions
|
3
|
+
class Compose < Base
|
4
|
+
def run
|
5
|
+
@host_names = []
|
6
|
+
@projects = []
|
7
|
+
compile_projects
|
8
|
+
File.write(config_path, File.read(origin_config_path))
|
9
|
+
open(config_path, 'a') do |f|
|
10
|
+
f << "\n\n # === GENERATED === # \n\n"
|
11
|
+
@projects.map do |project|
|
12
|
+
compile_project(project, f)
|
13
|
+
f << "\n\n"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def compile_project(project, f)
|
21
|
+
options = project[:options]
|
22
|
+
screen_session = options['screen_session']
|
23
|
+
f << "Host #{project[:name]}\n"
|
24
|
+
f << " ForwardAgent yes\n" if options['forward_agent']
|
25
|
+
f << " HostName #{project[:hostname]}\n"
|
26
|
+
f << " User #{options['user']}\n"
|
27
|
+
f << " RequestTTY yes\n" if options['request_tty']
|
28
|
+
f << " RemoteCommand ssh-agent ; ssh-add ; screen -SRR #{screen_session} &>/dev/null || bash --login\n" if screen_session
|
29
|
+
end
|
30
|
+
|
31
|
+
def parse_projects_data(projects_data, groups = [])
|
32
|
+
if projects_data.is_a?(Hash)
|
33
|
+
projects_data.each do |group, project|
|
34
|
+
new_groups = groups.dup
|
35
|
+
parse_projects_data(project, new_groups << group)
|
36
|
+
end
|
37
|
+
elsif projects_data.is_a?(Array)
|
38
|
+
projects_data.map do |project|
|
39
|
+
name = project.find { |_k, v| v.nil? }&.first
|
40
|
+
options = project.select { |k, v| !v.nil? }.to_h
|
41
|
+
@projects << prepare_project(name, groups, options)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def prepare_project(name, groups, options)
|
47
|
+
{ name: build_project_name(name, groups),
|
48
|
+
hostname: name,
|
49
|
+
options: build_project_options(options) }
|
50
|
+
end
|
51
|
+
|
52
|
+
def build_project_options(options)
|
53
|
+
config.merge(options)
|
54
|
+
end
|
55
|
+
|
56
|
+
def build_project_name(name, groups)
|
57
|
+
return name if groups.empty?
|
58
|
+
name = groups.join('.')
|
59
|
+
names_count = @host_names.select { |host| host == name }.count + 1
|
60
|
+
@host_names << name
|
61
|
+
"#{name}#{names_count}"
|
62
|
+
end
|
63
|
+
|
64
|
+
def compile_projects(groups = [])
|
65
|
+
projects do |projects_data|
|
66
|
+
parse_projects_data(projects_data, groups = [])
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def projects
|
71
|
+
projects_paths.each do |project_path|
|
72
|
+
data = parse_project(project_path)
|
73
|
+
hosts = data['hosts']
|
74
|
+
yield(hosts) if hosts
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def parse_project(file_path)
|
79
|
+
YAML.safe_load(File.read(file_path))
|
80
|
+
end
|
81
|
+
|
82
|
+
def projects_paths
|
83
|
+
Dir[projects_path.join('*.yml')]
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# rubocop:disable all
|
2
|
+
module Sshster
|
3
|
+
module Actions
|
4
|
+
class Help
|
5
|
+
def run
|
6
|
+
puts <<~HELP
|
7
|
+
sshster [-h] [-c] <command>
|
8
|
+
|
9
|
+
Commands:
|
10
|
+
|
11
|
+
init Initialize sshster configuration files inside of yours ~/.ssh dir
|
12
|
+
compose Compile your projects to ~/.ssh/config file
|
13
|
+
help Show this help
|
14
|
+
HELP
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
# rubocop:enable all
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module Sshster
|
2
|
+
module Actions
|
3
|
+
class Init < Base
|
4
|
+
def run
|
5
|
+
create_root_dir
|
6
|
+
backup_config
|
7
|
+
create_sshster_yml
|
8
|
+
create_projects_dir
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def create_root_dir
|
14
|
+
return if root_path.exist?
|
15
|
+
|
16
|
+
FileUtils.mkdir_p(root_path)
|
17
|
+
end
|
18
|
+
|
19
|
+
def create_projects_dir
|
20
|
+
return if projects_path.exist?
|
21
|
+
|
22
|
+
FileUtils.mkdir(projects_path)
|
23
|
+
end
|
24
|
+
|
25
|
+
def create_sshster_yml
|
26
|
+
return if sshster_config_path.exist?
|
27
|
+
|
28
|
+
FileUtils.touch(sshster_config_path)
|
29
|
+
end
|
30
|
+
|
31
|
+
def backup_config
|
32
|
+
return if origin_config_path.exist?
|
33
|
+
|
34
|
+
if config_path.exist?
|
35
|
+
FileUtils.mv(config_path, origin_config_path)
|
36
|
+
else
|
37
|
+
FileUtils.touch(origin_config_path)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/lib/sshster/app.rb
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
require File.expand_path('actions/base', __dir__)
|
2
|
+
require File.expand_path('actions/init', __dir__)
|
3
|
+
require File.expand_path('actions/compose', __dir__)
|
4
|
+
require File.expand_path('actions/help', __dir__)
|
5
|
+
|
6
|
+
module Sshster
|
7
|
+
class App
|
8
|
+
attr_accessor :options
|
9
|
+
|
10
|
+
def initialize(options)
|
11
|
+
@options = options
|
12
|
+
end
|
13
|
+
|
14
|
+
def run
|
15
|
+
case command
|
16
|
+
when :init then action_init
|
17
|
+
when :compose then action_compose
|
18
|
+
when :help then action_help
|
19
|
+
else action_help
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def action_init
|
24
|
+
Actions::Init.new(config).run
|
25
|
+
end
|
26
|
+
|
27
|
+
def action_compose
|
28
|
+
action_init
|
29
|
+
Actions::Compose.new(config).run
|
30
|
+
end
|
31
|
+
|
32
|
+
def action_help
|
33
|
+
Actions::Help.new.run
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def config
|
39
|
+
@config ||= Config.new(options.config).merge
|
40
|
+
end
|
41
|
+
|
42
|
+
def command
|
43
|
+
@command ||= @options.command
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Sshster
|
2
|
+
class ArgvParser
|
3
|
+
attr_reader :config, :command, :help
|
4
|
+
|
5
|
+
def initialize(argv)
|
6
|
+
@argv = argv
|
7
|
+
end
|
8
|
+
|
9
|
+
def parse
|
10
|
+
options = parse_argv(@argv)
|
11
|
+
@config = options['-c']
|
12
|
+
@help = options['-h']
|
13
|
+
@command = detect_command(options)
|
14
|
+
self
|
15
|
+
end
|
16
|
+
|
17
|
+
def valid?
|
18
|
+
!@command.nil? && valid_commands.include?(@command)
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def valid_commands
|
24
|
+
%i[init compose help]
|
25
|
+
end
|
26
|
+
|
27
|
+
def detect_command(options)
|
28
|
+
command = options.find { |_k, v| v.nil? }
|
29
|
+
command[0].to_sym if command
|
30
|
+
end
|
31
|
+
|
32
|
+
def parse_argv(argv)
|
33
|
+
Hash[argv.join(' ').scan(/(-?[^=\s]+)(?: ([^-]{1}[\S]+))?/)]
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Sshster
|
2
|
+
class Config
|
3
|
+
attr_accessor :options, :config_path
|
4
|
+
|
5
|
+
def initialize(config_path = nil)
|
6
|
+
@config_path = config_path || default_file_path
|
7
|
+
@options = default_options
|
8
|
+
end
|
9
|
+
|
10
|
+
def merge
|
11
|
+
merge_config(config_path)
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def parse_config(config_path)
|
17
|
+
YAML.safe_load(File.read(config_path))
|
18
|
+
end
|
19
|
+
|
20
|
+
def merge_config(config_path)
|
21
|
+
return @options unless File.exist?(config_path)
|
22
|
+
|
23
|
+
@options.merge!(parse_config(config_path))
|
24
|
+
end
|
25
|
+
|
26
|
+
def default_options
|
27
|
+
{
|
28
|
+
'forward_agent' => true,
|
29
|
+
'user' => 'deploy',
|
30
|
+
'request_tty' => true,
|
31
|
+
'screen_session' => 'deploy',
|
32
|
+
'ssh_config' => default_ssh_config_path,
|
33
|
+
}
|
34
|
+
end
|
35
|
+
|
36
|
+
def default_file_path
|
37
|
+
ENV['HOME'] + '/.ssh/sshster.yml'
|
38
|
+
end
|
39
|
+
|
40
|
+
def default_ssh_config_path
|
41
|
+
ENV['HOME'] + '/.ssh'
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/lib/sshster.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require 'sshster/version'
|
3
|
+
require 'sshster/argv_parser'
|
4
|
+
require 'sshster/config'
|
5
|
+
require 'sshster/app'
|
6
|
+
|
7
|
+
module Sshster
|
8
|
+
extend self
|
9
|
+
class Error < StandardError; end
|
10
|
+
|
11
|
+
def run(argv)
|
12
|
+
options = ArgvParser.new(argv).parse
|
13
|
+
App.new(options).run
|
14
|
+
end
|
15
|
+
end
|
data/sshster.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
lib = File.expand_path('lib', __dir__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'sshster/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'sshster'
|
7
|
+
spec.version = Sshster::VERSION
|
8
|
+
spec.authors = ['Ivan Zinovyev']
|
9
|
+
spec.email = ['ivan@zinovyev.net']
|
10
|
+
|
11
|
+
spec.summary = 'Manage your ssh connections with ease'
|
12
|
+
spec.description = 'Ssh configuration manager'
|
13
|
+
spec.homepage = 'https://github.com/zinovyev/sshster'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
17
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
end
|
19
|
+
|
20
|
+
spec.bindir = 'bin'
|
21
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
22
|
+
spec.require_paths = ['lib']
|
23
|
+
|
24
|
+
spec.add_development_dependency 'bundler', '~> 1.17'
|
25
|
+
spec.add_development_dependency 'pry'
|
26
|
+
spec.add_development_dependency 'pry-coolline'
|
27
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
28
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
29
|
+
spec.add_development_dependency 'rubocop'
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,149 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sshster
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ivan Zinovyev
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-04-23 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.17'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.17'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: pry
|
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
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: pry-coolline
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rubocop
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: Ssh configuration manager
|
98
|
+
email:
|
99
|
+
- ivan@zinovyev.net
|
100
|
+
executables:
|
101
|
+
- sshster
|
102
|
+
extensions: []
|
103
|
+
extra_rdoc_files: []
|
104
|
+
files:
|
105
|
+
- ".gitignore"
|
106
|
+
- ".rspec"
|
107
|
+
- ".rubocop.yml"
|
108
|
+
- ".travis.yml"
|
109
|
+
- CODE_OF_CONDUCT.md
|
110
|
+
- Gemfile
|
111
|
+
- Gemfile.lock
|
112
|
+
- LICENSE.txt
|
113
|
+
- README.md
|
114
|
+
- Rakefile
|
115
|
+
- bin/sshster
|
116
|
+
- lib/sshster.rb
|
117
|
+
- lib/sshster/actions/base.rb
|
118
|
+
- lib/sshster/actions/compose.rb
|
119
|
+
- lib/sshster/actions/help.rb
|
120
|
+
- lib/sshster/actions/init.rb
|
121
|
+
- lib/sshster/app.rb
|
122
|
+
- lib/sshster/argv_parser.rb
|
123
|
+
- lib/sshster/config.rb
|
124
|
+
- lib/sshster/version.rb
|
125
|
+
- sshster.gemspec
|
126
|
+
homepage: https://github.com/zinovyev/sshster
|
127
|
+
licenses:
|
128
|
+
- MIT
|
129
|
+
metadata: {}
|
130
|
+
post_install_message:
|
131
|
+
rdoc_options: []
|
132
|
+
require_paths:
|
133
|
+
- lib
|
134
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
140
|
+
requirements:
|
141
|
+
- - ">="
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
version: '0'
|
144
|
+
requirements: []
|
145
|
+
rubygems_version: 3.0.3
|
146
|
+
signing_key:
|
147
|
+
specification_version: 4
|
148
|
+
summary: Manage your ssh connections with ease
|
149
|
+
test_files: []
|