capx 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: 54f9c832dd635a2ee78e58603f3317c8c556149d07fe5fec0b8742640ef8ba8b
4
- data.tar.gz: 1600766506adf2112eb75563e353c819302f1b9bd2be72b1b6d75a9a2b724d1b
2
+ SHA1:
3
+ metadata.gz: 9ee4adee93b41f95174e7c73e464686e47b3d126
4
+ data.tar.gz: '05905f870ec8126a43994c477e838d05b3972834'
5
5
  SHA512:
6
- metadata.gz: df1ed19bb23d76de632044abec6a8df7ae4937567ac05069b042c9068af277ab6ebfed99a2038df2e7f1f44c9f5908518628bd2da18a4af286056b4178c2ec77
7
- data.tar.gz: b846c3c660939616cd3890acab228e7042c03cf230f444f8a30bda1c78763b8a006c0e850f00cba76169af49f85c5e2f302171a551ead88eeb4a3b175bde40cb
6
+ metadata.gz: aefe35f43a1f85cd6dcb761e0baa2af40eb3d6c62bd9c66eed8bf0188f1634b8e5b2611a23d5cbe56cb1a60b4b77fd952a656f801746c0fb4fb77578cb9a70c3
7
+ data.tar.gz: 42269f15a5da4a313151b6bb0a8a1292e8c3e3f4ef7f69498931e84c9062f5d023be42991531b00b2ee977a98a2e809c20191f69493f36311eee5b4ec5341342
data/.gitignore CHANGED
@@ -1,50 +1,50 @@
1
- *.gem
2
- *.rbc
3
- /.config
4
- /coverage/
5
- /InstalledFiles
6
- /pkg/
7
- /spec/reports/
8
- /spec/examples.txt
9
- /test/tmp/
10
- /test/version_tmp/
11
- /tmp/
12
-
13
- # Used by dotenv library to load environment variables.
14
- # .env
15
-
16
- ## Specific to RubyMotion:
17
- .dat*
18
- .repl_history
19
- build/
20
- *.bridgesupport
21
- build-iPhoneOS/
22
- build-iPhoneSimulator/
23
-
24
- ## Specific to RubyMotion (use of CocoaPods):
25
- #
26
- # We recommend against adding the Pods directory to your .gitignore. However
27
- # you should judge for yourself, the pros and cons are mentioned at:
28
- # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
29
- #
30
- # vendor/Pods/
31
-
32
- ## Documentation cache and generated files:
33
- /.yardoc/
34
- /_yardoc/
35
- /doc/
36
- /rdoc/
37
-
38
- ## Environment normalization:
39
- /.bundle/
40
- /vendor/bundle
41
- /lib/bundler/man/
42
-
43
- # for a library or gem, you might want to ignore these files since the code is
44
- # intended to run in multiple environments; otherwise, check them in:
45
- # Gemfile.lock
46
- # .ruby-version
47
- # .ruby-gemset
48
-
49
- # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
50
- .rvmrc
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /spec/examples.txt
9
+ /test/tmp/
10
+ /test/version_tmp/
11
+ /tmp/
12
+
13
+ # Used by dotenv library to load environment variables.
14
+ # .env
15
+
16
+ ## Specific to RubyMotion:
17
+ .dat*
18
+ .repl_history
19
+ build/
20
+ *.bridgesupport
21
+ build-iPhoneOS/
22
+ build-iPhoneSimulator/
23
+
24
+ ## Specific to RubyMotion (use of CocoaPods):
25
+ #
26
+ # We recommend against adding the Pods directory to your .gitignore. However
27
+ # you should judge for yourself, the pros and cons are mentioned at:
28
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
29
+ #
30
+ # vendor/Pods/
31
+
32
+ ## Documentation cache and generated files:
33
+ /.yardoc/
34
+ /_yardoc/
35
+ /doc/
36
+ /rdoc/
37
+
38
+ ## Environment normalization:
39
+ /.bundle/
40
+ /vendor/bundle
41
+ /lib/bundler/man/
42
+
43
+ # for a library or gem, you might want to ignore these files since the code is
44
+ # intended to run in multiple environments; otherwise, check them in:
45
+ # Gemfile.lock
46
+ # .ruby-version
47
+ # .ruby-gemset
48
+
49
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
50
+ .rvmrc
data/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2018 Jan Kmet
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.
1
+ MIT License
2
+
3
+ Copyright (c) 2018 Jan Kmet
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 CHANGED
@@ -1,34 +1,35 @@
1
- # CapX
2
-
3
- Generates SSH commands using capistrano deploy configuration. \
4
- SSH username and host are parsed from capistrano deploy configuration. \
5
- \
6
- capistrano deploy configuration:
7
-
8
- server 'dev.example.com', user: 'deploy', roles: %w{web app db}, primary: true
9
- generated SSH command:
10
-
11
- $ ssh deploy@dev.example.com
12
-
13
- ## Installation
14
-
15
-
16
- $ gem install capx
17
-
18
-
19
- ## Usage
20
-
21
-
22
-
23
- This will add the following executable in your shell:
24
-
25
-
26
- capx [stage] [ssh|disk|info] [user]
27
-
28
-
29
- ### Examples:
30
-
31
- $ capx staging # show ssh command
32
- $ capx production ssh # execute ssh command
33
- $ capx production ssh root # execute ssh command with root user
34
- $ capx production disk # execute ssh 'df -H' command
1
+ # CapX
2
+
3
+ Generates SSH commands using capistrano deploy configuration. \
4
+ SSH username and host are parsed from capistrano deploy configuration. \
5
+ \
6
+ capistrano deploy configuration:
7
+
8
+ server 'dev.example.com', user: 'deploy', roles: %w{web app db}, primary: true
9
+ generated SSH command:
10
+
11
+ $ ssh deploy@dev.example.com
12
+
13
+ ## Installation
14
+
15
+
16
+ $ gem install capx
17
+
18
+
19
+ ## Usage
20
+
21
+
22
+
23
+ This will add the following executable in your shell:
24
+
25
+
26
+ capx [stage] [ssh|disk|info|redis] [user]
27
+
28
+
29
+ ### Examples:
30
+
31
+ $ capx staging # show ssh command
32
+ $ capx production ssh # execute ssh command
33
+ $ capx production ssh root # execute ssh command with root user
34
+ $ capx production disk # execute ssh 'df -H' command
35
+ $ capx production redis # execute ssh 'redis-cli INFO keyspace' command
data/bin/capx CHANGED
@@ -1,22 +1,22 @@
1
- #!/usr/bin/env ruby
2
- # encoding: utf-8
3
-
4
- $LOAD_PATH.unshift(File.dirname(File.realpath(__FILE__)) + '/../lib')
5
-
6
- require 'capx'
7
-
8
- def show_help
9
- puts 'params: <stage> <ssh|disk|info> <user>'
10
- puts 'example: capx staging ssh'
11
- end
12
-
13
- if ARGV[0]
14
- stage = ARGV[0]
15
- switch = ARGV[1]
16
- user = ARGV[2]
17
-
18
- runner = Capx::Runner.new(stage: stage, switch: switch, user: user)
19
- runner.run
20
- else
21
- show_help
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+ $LOAD_PATH.unshift(File.dirname(File.realpath(__FILE__)) + '/../lib')
5
+
6
+ require 'capx'
7
+
8
+ def show_help
9
+ puts 'params: <stage> <ssh|disk|info|redis> <user>'
10
+ puts 'example: capx staging ssh'
11
+ end
12
+
13
+ if ARGV[0]
14
+ stage = ARGV[0]
15
+ switch = ARGV[1]
16
+ user = ARGV[2]
17
+
18
+ runner = Capx::Runner.new(stage: stage, switch: switch, user: user)
19
+ runner.run
20
+ else
21
+ show_help
22
22
  end
@@ -1,26 +1,26 @@
1
- # coding: utf-8
2
-
3
- $LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
4
- require 'capx/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = 'capx'
8
- spec.version = Capx::VERSION
9
- spec.platform = Gem::Platform::RUBY
10
- spec.required_ruby_version = '>= 2.2.0'
11
- spec.authors = ['Jan Kmet']
12
- spec.email = ['jan.kmet@gmail.com']
13
- spec.summary = 'Generates SSH command using capistrano deploy configuration.'
14
- spec.description = <<-EOF
15
- Generates SSH command using capistrano deploy configuration..
16
- SSH username and host are parsed from capistrano deploy configuration
17
- EOF
18
- spec.homepage = 'https://github.com/jankmet/capx'
19
-
20
- spec.files = `git ls-files`.split($RS)
21
- spec.executables = ['capx']
22
- spec.test_files = spec.files.grep(/^spec\//)
23
- spec.require_paths = ['lib']
24
- spec.licenses = ['MIT']
25
- end
26
-
1
+ # coding: utf-8
2
+
3
+ $LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
4
+ require 'capx/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'capx'
8
+ spec.version = Capx::VERSION
9
+ spec.platform = Gem::Platform::RUBY
10
+ spec.required_ruby_version = '>= 2.2.0'
11
+ spec.authors = ['Jan Kmet']
12
+ spec.email = ['jan.kmet@gmail.com']
13
+ spec.summary = 'Generates SSH command using capistrano deploy configuration.'
14
+ spec.description = <<-EOF
15
+ Generates SSH command using capistrano deploy configuration..
16
+ SSH username and host are parsed from capistrano deploy configuration
17
+ EOF
18
+ spec.homepage = 'https://github.com/jankmet/capx'
19
+
20
+ spec.files = `git ls-files`.split($RS)
21
+ spec.executables = ['capx']
22
+ spec.test_files = spec.files.grep(/^spec\//)
23
+ spec.require_paths = ['lib']
24
+ spec.licenses = ['MIT']
25
+ end
26
+
@@ -1,6 +1,6 @@
1
- require 'capx/version'
2
- require 'capx/runner'
3
-
4
- # main module for capx
5
- module Capx
6
- end
1
+ require 'capx/version'
2
+ require 'capx/runner'
3
+
4
+ # main module for capx
5
+ module Capx
6
+ end
@@ -1,52 +1,58 @@
1
- module Capx
2
- class Runner
3
- PATTERN = /server:?\s+[\'\"]([\w\-\.]+)[\'\"],\s+user:?\s+[\'\"]([\w\-\.]+)[\'\"]/
4
-
5
- def initialize(options)
6
- @stage = options[:stage]
7
- @switch = options[:switch]
8
- @user = options[:user]
9
- @server = nil
10
- end
11
-
12
- def run
13
- file = "config/deploy/#{@stage}.rb"
14
- if File.exist?(file)
15
- File.open(file).each do |line|
16
- if match = PATTERN.match(line)
17
- @server = match.captures[0]
18
- @user = match.captures[1] if @user.nil?
19
- end
20
- end
21
-
22
- if @server.nil? || @user.nil?
23
- puts "capistrano server/user not found"
24
- else
25
- if @switch == 'ssh'
26
- # call ssh
27
- cmd = "ssh #{@user}@#{@server}"
28
- execute_cmd(cmd)
29
- elsif @switch == 'disk'
30
- # call remote df -H
31
- cmd = "ssh #{@user}@#{@server} 'df -H'"
32
- execute_cmd(cmd)
33
- elsif @switch == 'info'
34
- cmd = "ssh #{@user}@#{@server} 'cat /etc/*-release'"
35
- execute_cmd(cmd)
36
- else
37
- puts "#{@user}@#{@server}"
38
- end
39
- end
40
- else
41
- puts "File #{file} not found"
42
- end
43
- end
44
-
45
- private
46
-
47
- def execute_cmd(cmd)
48
- puts "executing #{cmd}"
49
- exec(cmd)
50
- end
51
- end
52
- end
1
+ module Capx
2
+ class Runner
3
+ PATTERN = /server:?\s+[\'\"]([\w\-\.]+)[\'\"],\s+user:?\s+[\'\"]([\w\-\.]+)[\'\"]/
4
+
5
+ def initialize(options)
6
+ @stage = options[:stage]
7
+ @switch = options[:switch]
8
+ @user = options[:user]
9
+ @server = nil
10
+ end
11
+
12
+ def run
13
+ file = "config/deploy/#{@stage}.rb"
14
+ if File.exist?(file)
15
+ File.open(file).each do |line|
16
+ if match = PATTERN.match(line)
17
+ @server = match.captures[0]
18
+ @user = match.captures[1] if @user.nil?
19
+ end
20
+ end
21
+
22
+ if @server.nil? || @user.nil?
23
+ puts 'capistrano server/user not found'
24
+ else
25
+ ssh_cmd = "ssh #{@user}@#{@server}"
26
+ if @switch == 'ssh'
27
+ # call ssh
28
+ cmd = ssh_cmd
29
+ execute_cmd(cmd)
30
+ elsif @switch == 'disk'
31
+ # call remote df -H
32
+ cmd = "#{ssh_cmd} 'df -H'"
33
+ execute_cmd(cmd)
34
+ elsif @switch == 'info'
35
+ # call remote cat /etc/*-release
36
+ cmd = "#{ssh_cmd} 'cat /etc/*-release'"
37
+ execute_cmd(cmd)
38
+ elsif @switch == 'redis'
39
+ # call remote redis-cli INFO keyspace
40
+ cmd = "#{ssh_cmd} 'redis-cli INFO keyspace'"
41
+ execute_cmd(cmd)
42
+ else
43
+ puts "#{@user}@#{@server}"
44
+ end
45
+ end
46
+ else
47
+ puts "File #{file} not found"
48
+ end
49
+ end
50
+
51
+ private
52
+
53
+ def execute_cmd(cmd)
54
+ puts "executing #{cmd}"
55
+ exec(cmd)
56
+ end
57
+ end
58
+ end
@@ -1,5 +1,5 @@
1
- # main module for capx
2
- module Capx
3
- VERSION = '0.0.3'
4
- end
1
+ # main module for capx
2
+ module Capx
3
+ VERSION = '0.0.4'
4
+ end
5
5
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capx
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Kmet
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-12 00:00:00.000000000 Z
11
+ date: 2018-08-19 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |2
14
14
  Generates SSH command using capistrano deploy configuration..
@@ -48,7 +48,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
48
48
  version: '0'
49
49
  requirements: []
50
50
  rubyforge_project:
51
- rubygems_version: 2.7.3
51
+ rubygems_version: 2.6.13
52
52
  signing_key:
53
53
  specification_version: 4
54
54
  summary: Generates SSH command using capistrano deploy configuration.