shell_gongeek 0.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 57af02866865fc0f2b1bb125441a6c1e514770b8
4
+ data.tar.gz: 5dbf9f5ed7b0a078de6cd862a02a4d0fbf929f77
5
+ SHA512:
6
+ metadata.gz: e40abd7f625dde54027f740adb2a66ec52c82ae165880c74b642eea2b1c345e675d176312b2c4ba605ed6f00120ff7ce65b13695a06737d3d0524d4b824bd4ff
7
+ data.tar.gz: 7b083326b3c68ce4899f9705d24835bb7b1cff92a4748f5d5a610bd6206f98f0374395bbeb2d52e386b7f907abf5513f0bff36a5551f692fbb5dc294f4eeb8c0
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ .idea
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in shell_gongeek.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,44 @@
1
+ ## ShellGongeek
2
+
3
+ 简化方便操作一些常用linux命令的ruby脚本
4
+
5
+ 目前支持:
6
+
7
+ 1. sr pk 3000 (删除占用3000端口的所有程序)
8
+ 2. sr pl 3000 (等价于 lsof -i:3000)
9
+
10
+ 后续考虑以自己实用出发添加相应命令
11
+
12
+ ## Installation
13
+
14
+ Add this line to your application's Gemfile:
15
+
16
+ ```ruby
17
+ gem 'shell_gongeek'
18
+ ```
19
+
20
+ And then execute:
21
+
22
+ $ bundle
23
+
24
+ Or install it yourself as:
25
+
26
+ $ gem install shell_gongeek
27
+
28
+ ## Usage
29
+
30
+ 目前支持:
31
+
32
+ 1. sr pk 3000 (删除占用3000端口的所有程序)
33
+ 2. sr pl 3000 (等价于 lsof -i:3000)
34
+
35
+ ## Development
36
+
37
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
38
+
39
+ 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).
40
+
41
+ ## Contributing
42
+
43
+ Bug reports and pull requests are welcome on GitHub at https://github.com/gongeek/shell_gongeek.
44
+
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "shell_gongeek"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
data/bin/sr ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require "shell_gongeek"
3
+ ShellGongeek.run
@@ -0,0 +1,3 @@
1
+ module ShellGongeek
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,37 @@
1
+ require "shell_gongeek/version"
2
+
3
+ module ShellGongeek
4
+ def self.run
5
+ # Your code goes here...
6
+ command=ARGV[0]
7
+ params=ARGV.slice(1, ARGV.length)
8
+
9
+ #杀死占用某个端口的所有程序
10
+ #例如 sr pk 3000
11
+ if command=='pk'
12
+ p_info=`lsof -i:#{params[0]}`
13
+ if p_info.length==0
14
+ puts "#{params[0]}端口没有程序"
15
+ end
16
+ pids=[]
17
+ lines=p_info.split("\n")
18
+ lines.delete_at(0)
19
+ lines.each { |line| pids.push line.split(/[\W]+/)[1] }
20
+ puts pids.join(' ')
21
+ if pids.length>0
22
+ if system "kill #{pids.join(' ')}"
23
+ puts "成功杀死占用#{params[0]}的程序"
24
+ end
25
+ end
26
+ end
27
+
28
+ if command=='pl'
29
+ if params[0]
30
+ exec "lsof -i:#{params[0]}"
31
+ else
32
+ puts '请输入端口号'
33
+ end
34
+
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,31 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'shell_gongeek/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "shell_gongeek"
8
+ spec.version = ShellGongeek::VERSION
9
+ spec.authors = ["宫卫"]
10
+ spec.email = ["gongwei.gw@alibaba-inc.com"]
11
+
12
+ spec.summary = %q{gongeek的命令行工具.}
13
+ spec.description = %q{gongeek的命令行工具..}
14
+ spec.homepage = "http://gongwei.xyz"
15
+
16
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
17
+ # delete this section to allow pushing this gem to any host.
18
+ # if spec.respond_to?(:metadata)
19
+ # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
20
+ # else
21
+ # raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
22
+ # end
23
+
24
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
25
+ # spec.bindir = "exe"
26
+ spec.executables = ['sr']
27
+ spec.require_paths = ["lib"]
28
+
29
+ spec.add_development_dependency "bundler", "~> 1.10"
30
+ spec.add_development_dependency "rake", "~> 10.0"
31
+ end
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: shell_gongeek
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - 宫卫
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-06-17 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.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: gongeek的命令行工具..
42
+ email:
43
+ - gongwei.gw@alibaba-inc.com
44
+ executables:
45
+ - sr
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - ".gitignore"
50
+ - Gemfile
51
+ - README.md
52
+ - Rakefile
53
+ - bin/console
54
+ - bin/setup
55
+ - bin/sr
56
+ - lib/shell_gongeek.rb
57
+ - lib/shell_gongeek/version.rb
58
+ - shell_gongeek.gemspec
59
+ homepage: http://gongwei.xyz
60
+ licenses: []
61
+ metadata: {}
62
+ post_install_message:
63
+ rdoc_options: []
64
+ require_paths:
65
+ - lib
66
+ required_ruby_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ requirements: []
77
+ rubyforge_project:
78
+ rubygems_version: 2.5.1
79
+ signing_key:
80
+ specification_version: 4
81
+ summary: gongeek的命令行工具.
82
+ test_files: []