ssh-bookmarks 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2990e3790d81b0ab359301bb719a25d15d81b5da
4
+ data.tar.gz: 736793cae10b17700fa601ab5da2889df4c71fb9
5
+ SHA512:
6
+ metadata.gz: 219dee7f9d8842f1b19d07485da94dd4159cb976065bbe74617ec392f12f1ef088250b83256240565052089a5ec934bfcca2c437bff93ce8cce585698626d0a6
7
+ data.tar.gz: 2e2ebdc7336827aa8f66ff874a934d857b085288cab2a518703e2a9b4c36965f78fc7a14070d24a9cc4596546f5bc7fd15c49ed1cb37e340d96916626176d237
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/.travis.yml ADDED
@@ -0,0 +1,18 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.2p95
4
+ - 1.8.7
5
+ - jruby-19mode
6
+ - 1.9.2
7
+ - 1.9.3
8
+ - 2.0.0
9
+ - 2.1.0
10
+ env:
11
+ - CI=true
12
+ gemfile:
13
+ - Gemfile
14
+ branches:
15
+ only:
16
+ - master
17
+
18
+
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ssh_bookmarks.gemspec
4
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,37 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ guard 'spring', rspec_cli: '--color' do
5
+ watch(%r{^spec/.+_spec\.rb$})
6
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
7
+ watch('spec/spec_helper.rb') { 'spec' }
8
+ watch(%r{.+\.rb$})
9
+ watch(%r{^features/.+\.feature$})
10
+ watch(%r{^features/support/.+$}) { 'features' }
11
+ watch(%r{^features/.+\/step_definitions/(.+)_steps\.rb$}) do |m|
12
+ Dir[File.join("**/#{m[1]}.feature")][0] || 'features'
13
+ end
14
+ end
15
+
16
+ guard :rspec, cmd: 'rspec' do
17
+ watch(%r{^spec/.+_spec\.rb$})
18
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
19
+ watch('spec/spec_helper.rb') { 'spec' }
20
+ end
21
+
22
+ guard :cucumber do
23
+ watch(%r{^features/.+\.feature$})
24
+ watch(%r{^features/support/.+$}) { 'features' }
25
+ watch(%r{^features/.+\/step_definitions/(.+)_steps\.rb$}) do |m|
26
+ Dir[File.join("**/#{m[1]}.feature")][0] || 'features'
27
+ end
28
+ end
29
+
30
+ guard :rubocop do
31
+ watch(%r{.+\.rb$})
32
+ watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
33
+ end
34
+
35
+ guard :reek do
36
+ watch(%r{.+\.rb$})
37
+ end
data/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 Andrey Antipov
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 all
13
+ 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 THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,39 @@
1
+
2
+ A dead simple cli ssh server list.
3
+
4
+ ## ssh-bookmarks <sub>0.1</sub>
5
+
6
+
7
+ ## Installation
8
+
9
+ $ gem install ssh-bookmarks
10
+
11
+ ## Usage
12
+
13
+ $ ssh-bookmarks
14
+
15
+
16
+ ## Configure
17
+
18
+ $ man ssh_config
19
+
20
+
21
+ ---
22
+
23
+ ![Server selection](https://raw.githubusercontent.com/AndreyAntipov/ssh-bookmarks-shell/media/screenshoot.png "Server selection")
24
+
25
+ ---
26
+
27
+ ## License
28
+
29
+ The MIT License (MIT)
30
+
31
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions in [LICENSE.md](https://github.com/AndreyAntipov/ssh-bookmarks-shell/blob/master/LICENSE.md)
32
+
33
+ ## Contributing
34
+
35
+ 1. Fork it ( https://github.com/[my-github-username]/ssh_bookmarks/fork )
36
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
37
+ 3. Commit your changes (`git commit -am ‘Add some feature’`)
38
+ 4. Push to the branch (`git push origin my-new-feature`)
39
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
data/bin/ssh-bookmarks ADDED
@@ -0,0 +1,108 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: UTF-8
3
+
4
+ # dead simple ssh connection manager
5
+ class Application
6
+ require 'highline/import'
7
+
8
+ # Core methods
9
+ class Foundation
10
+ # SSH methods
11
+ module SSH
12
+ def self.connect(server)
13
+ exec "ssh #{server}"
14
+ end
15
+ end
16
+
17
+ # preparation and setting the configuration file
18
+ class Config
19
+ PATH = "#{ENV['HOME']}/.ssh/config"
20
+ OPTIONS = %w(hidden)
21
+
22
+ # prepare config
23
+ def initialize
24
+ # load ssh config
25
+ new = File.readlines(PATH).map(&:split)
26
+ @data = construct new
27
+ rescue => err
28
+ abort "Error: config is invalid.\nReason: #{err}"
29
+ end
30
+
31
+ def construct(raw)
32
+ container = []
33
+ raw.each_with_index do |block, index|
34
+ next if block.empty? || comment?(block)
35
+ if block[0] == 'Host'
36
+ container << {}
37
+ container.last.merge!(options: options(raw, index))
38
+ end
39
+ container.last.merge!(block[0].downcase.to_sym => block[1]) if defined? container
40
+ end
41
+ container
42
+ end
43
+
44
+ # parse inline options passed in comments of specific block
45
+ def options(raw, index)
46
+ @prev_index = 0 unless defined? @prev_index
47
+ options = {}
48
+ index = index-1
49
+ # catch options between range
50
+ raw[@prev_index..index].each do |opt|
51
+ if comment?(opt) && option?(opt)
52
+ options.merge!(opt[1].downcase.to_sym => true)
53
+ end
54
+ end
55
+ @prev_index = index
56
+ options
57
+ end
58
+
59
+ def option?(block)
60
+ OPTIONS.include?(block[1])
61
+ end
62
+
63
+ # block is comment?
64
+ def comment?(block)
65
+ true if block[0] == '#'
66
+ end
67
+
68
+ # determine if config exist
69
+ def exist?
70
+ # ssh configuration file
71
+ if File.exist?(PATH)
72
+ return true
73
+ else
74
+ abort "Error: no configuration file is found.\nExpected path: #{path}"
75
+ end
76
+ end
77
+
78
+ attr_reader :data
79
+ private :exist?, :comment?, :option?, :construct, :options
80
+ end
81
+ end
82
+
83
+ # CLI interface for SSH manager
84
+ class Interface < Foundation
85
+ def initialize
86
+ config = Config.new
87
+ show_menu config.data, 'host'
88
+
89
+ # ignore errors when use ctrl-c or ctrl-d
90
+ rescue SystemExit, Interrupt, EOFError
91
+ puts "\nexiting..."
92
+ end
93
+
94
+ def show_menu(list, title)
95
+ t = title.to_sym
96
+ proposal = 'Please choose the server which you would like to connect?'
97
+ choose do |menu|
98
+ menu.prompt = proposal
99
+ list.each do |item|
100
+ unless item[:options][:hidden]
101
+ menu.choice(item[t]) { SSH.connect item[t] }
102
+ end
103
+ end
104
+ end
105
+ end
106
+ end
107
+ Interface.new
108
+ end
@@ -0,0 +1,3 @@
1
+ module SshBookmarks
2
+ VERSION = "0.0.2"
3
+ end
@@ -0,0 +1,5 @@
1
+ require "ssh_bookmarks/version"
2
+
3
+ module SshBookmarks
4
+ # Your code goes here...
5
+ end
@@ -0,0 +1,54 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'ssh-bookmarks/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "ssh-bookmarks"
8
+ spec.version = SshBookmarks::VERSION
9
+ spec.authors = ["Andrey Antipov"]
10
+ spec.email = ["andrey@antipov.me"]
11
+ spec.summary = %q{A dead simple cli ssh server list.}
12
+ #spec.description = %q{TODO: Write a longer description. Optional.}
13
+ spec.homepage = "https://github.com/AndreyAntipov/ssh-bookmarks"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ # cli interface dependency
22
+ spec.add_runtime_dependency "highline"
23
+
24
+ # dependencies
25
+ spec.add_development_dependency "bundler", "~> 1.7"
26
+ spec.add_development_dependency "rake", "~> 10.0"
27
+
28
+ # docs
29
+ spec.add_development_dependency "yard"
30
+ spec.add_development_dependency "inch"
31
+
32
+ # preloader
33
+ spec.add_development_dependency "spring"
34
+
35
+ # irb
36
+ spec.add_development_dependency "pry"
37
+ spec.add_development_dependency "hirb"
38
+
39
+ # tests
40
+ spec.add_development_dependency "simplecov"
41
+ spec.add_development_dependency "rubocop"
42
+ spec.add_development_dependency "cucumber"
43
+ spec.add_development_dependency "rspec"
44
+ spec.add_development_dependency "rspec-expectations"
45
+ spec.add_development_dependency "fuubar"
46
+
47
+ # automation
48
+ spec.add_development_dependency "guard"
49
+ spec.add_development_dependency "guard-rubocop"
50
+ spec.add_development_dependency "guard-cucumber"
51
+ spec.add_development_dependency "guard-spring"
52
+ spec.add_development_dependency "guard-bundler"
53
+
54
+ end
data/test/.keep ADDED
File without changes
File without changes
data/test/rspec/.keep ADDED
File without changes
File without changes
metadata ADDED
@@ -0,0 +1,331 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ssh-bookmarks
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Andrey Antipov
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-09-29 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: highline
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.7'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.7'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: yard
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: inch
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'
83
+ - !ruby/object:Gem::Dependency
84
+ name: spring
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
+ - !ruby/object:Gem::Dependency
98
+ name: pry
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: hirb
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: simplecov
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: rubocop
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: cucumber
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: rspec
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
181
+ - !ruby/object:Gem::Dependency
182
+ name: rspec-expectations
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - ">="
186
+ - !ruby/object:Gem::Version
187
+ version: '0'
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - ">="
193
+ - !ruby/object:Gem::Version
194
+ version: '0'
195
+ - !ruby/object:Gem::Dependency
196
+ name: fuubar
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - ">="
200
+ - !ruby/object:Gem::Version
201
+ version: '0'
202
+ type: :development
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - ">="
207
+ - !ruby/object:Gem::Version
208
+ version: '0'
209
+ - !ruby/object:Gem::Dependency
210
+ name: guard
211
+ requirement: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - ">="
214
+ - !ruby/object:Gem::Version
215
+ version: '0'
216
+ type: :development
217
+ prerelease: false
218
+ version_requirements: !ruby/object:Gem::Requirement
219
+ requirements:
220
+ - - ">="
221
+ - !ruby/object:Gem::Version
222
+ version: '0'
223
+ - !ruby/object:Gem::Dependency
224
+ name: guard-rubocop
225
+ requirement: !ruby/object:Gem::Requirement
226
+ requirements:
227
+ - - ">="
228
+ - !ruby/object:Gem::Version
229
+ version: '0'
230
+ type: :development
231
+ prerelease: false
232
+ version_requirements: !ruby/object:Gem::Requirement
233
+ requirements:
234
+ - - ">="
235
+ - !ruby/object:Gem::Version
236
+ version: '0'
237
+ - !ruby/object:Gem::Dependency
238
+ name: guard-cucumber
239
+ requirement: !ruby/object:Gem::Requirement
240
+ requirements:
241
+ - - ">="
242
+ - !ruby/object:Gem::Version
243
+ version: '0'
244
+ type: :development
245
+ prerelease: false
246
+ version_requirements: !ruby/object:Gem::Requirement
247
+ requirements:
248
+ - - ">="
249
+ - !ruby/object:Gem::Version
250
+ version: '0'
251
+ - !ruby/object:Gem::Dependency
252
+ name: guard-spring
253
+ requirement: !ruby/object:Gem::Requirement
254
+ requirements:
255
+ - - ">="
256
+ - !ruby/object:Gem::Version
257
+ version: '0'
258
+ type: :development
259
+ prerelease: false
260
+ version_requirements: !ruby/object:Gem::Requirement
261
+ requirements:
262
+ - - ">="
263
+ - !ruby/object:Gem::Version
264
+ version: '0'
265
+ - !ruby/object:Gem::Dependency
266
+ name: guard-bundler
267
+ requirement: !ruby/object:Gem::Requirement
268
+ requirements:
269
+ - - ">="
270
+ - !ruby/object:Gem::Version
271
+ version: '0'
272
+ type: :development
273
+ prerelease: false
274
+ version_requirements: !ruby/object:Gem::Requirement
275
+ requirements:
276
+ - - ">="
277
+ - !ruby/object:Gem::Version
278
+ version: '0'
279
+ description:
280
+ email:
281
+ - andrey@antipov.me
282
+ executables:
283
+ - ssh-bookmarks
284
+ extensions: []
285
+ extra_rdoc_files: []
286
+ files:
287
+ - ".gitignore"
288
+ - ".travis.yml"
289
+ - Gemfile
290
+ - Guardfile
291
+ - LICENSE.md
292
+ - README.md
293
+ - Rakefile
294
+ - bin/ssh-bookmarks
295
+ - lib/ssh-bookmarks.rb
296
+ - lib/ssh-bookmarks/version.rb
297
+ - ssh-bookmarks.gemspec
298
+ - test/.keep
299
+ - test/features/.keep
300
+ - test/rspec/.keep
301
+ - test/test_ssh-bookmarks.rb
302
+ homepage: https://github.com/AndreyAntipov/ssh-bookmarks
303
+ licenses:
304
+ - MIT
305
+ metadata: {}
306
+ post_install_message:
307
+ rdoc_options: []
308
+ require_paths:
309
+ - lib
310
+ required_ruby_version: !ruby/object:Gem::Requirement
311
+ requirements:
312
+ - - ">="
313
+ - !ruby/object:Gem::Version
314
+ version: '0'
315
+ required_rubygems_version: !ruby/object:Gem::Requirement
316
+ requirements:
317
+ - - ">="
318
+ - !ruby/object:Gem::Version
319
+ version: '0'
320
+ requirements: []
321
+ rubyforge_project:
322
+ rubygems_version: 2.2.2
323
+ signing_key:
324
+ specification_version: 4
325
+ summary: A dead simple cli ssh server list.
326
+ test_files:
327
+ - test/.keep
328
+ - test/features/.keep
329
+ - test/rspec/.keep
330
+ - test/test_ssh-bookmarks.rb
331
+ has_rdoc: