dumper 0.0.1

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.
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Kenn Ejima
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,19 @@
1
+ # Dumper
2
+
3
+ Utility that checks the status of a database.
4
+
5
+ ## Installation
6
+
7
+ $ gem install dumper
8
+
9
+ ## Usage
10
+
11
+ TODO: Write usage instructions here
12
+
13
+ ## Contributing
14
+
15
+ 1. Fork it
16
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
17
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
18
+ 4. Push to the branch (`git push origin my-new-feature`)
19
+ 5. Create new Pull Request
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # Abort beautifully with ctrl+c.
4
+ Signal.trap(:INT) { abort "\nAborting." }
5
+
6
+ # Load the main lib and invoke CLI.
7
+ require 'dumper'
8
+ Dumper::Cli.start
@@ -0,0 +1,20 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/dumper/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Kenn Ejima"]
6
+ gem.email = ["kenn.ejima@gmail.com"]
7
+ gem.description = %q{Utility that checks the status of a database}
8
+ gem.summary = %q{Utility that checks the status of a database}
9
+ gem.homepage = ""
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "dumper"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Dumper::VERSION
17
+
18
+ gem.add_runtime_dependency "thor"
19
+ gem.add_runtime_dependency "rainbow"
20
+ end
@@ -0,0 +1,29 @@
1
+ require 'dumper/version'
2
+ require 'thor'
3
+ require 'rainbow'
4
+ require 'socket'
5
+
6
+ module Dumper
7
+ autoload :Cli, 'dumper/cli'
8
+ end
9
+
10
+ require 'ipaddr'
11
+ class IPAddr
12
+ PrivateRanges = [
13
+ IPAddr.new("10.0.0.0/8"),
14
+ IPAddr.new("172.16.0.0/12"),
15
+ IPAddr.new("192.168.0.0/16")
16
+ ]
17
+
18
+ def private?
19
+ return false unless self.ipv4?
20
+ PrivateRanges.each do |ipr|
21
+ return true if ipr.include?(self)
22
+ end
23
+ return false
24
+ end
25
+
26
+ def public?
27
+ !private?
28
+ end
29
+ end
@@ -0,0 +1,49 @@
1
+ module Dumper
2
+ class Cli < Thor
3
+ include Thor::Actions
4
+
5
+ desc 'doctor', 'Check configurations'
6
+ def doctor
7
+ check_ip
8
+ check_cnf
9
+ end
10
+
11
+ no_tasks do
12
+ def check_ip
13
+ puts 'Checking IP address...'
14
+ ip = IPSocket.getaddress(Socket.gethostname)
15
+ ip_str = "#{ip} ... "
16
+ if IPAddr.new(ip).private?
17
+ ip_str << 'private'.color(:red)
18
+ else
19
+ ip_str << 'public'.color(:green)
20
+ end
21
+ puts ip_str
22
+ end
23
+
24
+ def check_cnf
25
+ puts 'Checking my.cnf...'
26
+ bound = nil
27
+ ['/etc/my.cnf', '/etc/mysql/my.cnf', '/usr/etc/my.cnf', '~/.my.cnf'].each do |name|
28
+ fullpath = File.expand_path(name)
29
+ next unless File.exist?(fullpath)
30
+ File.readlines(fullpath).each do |line|
31
+ if line =~ /^bind-address/
32
+ bound = line.split('=').strip
33
+ break
34
+ end
35
+ end
36
+ end
37
+ if bound
38
+ if bound == '127.0.0.1'
39
+ puts 'There is bind-address = 127.0.0.1 ... ' << 'fail'.color(:red)
40
+ elsif IPAddr.new(bound).private?
41
+ puts "There is bind-address = #{bound} ... " << 'fail'.color(:red)
42
+ end
43
+ else
44
+ puts 'No bind-address defined in my.cnf ... ' << 'ok'.color(:green)
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,3 @@
1
+ module Dumper
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,89 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dumper
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Kenn Ejima
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-04-28 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: thor
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rainbow
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ description: Utility that checks the status of a database
47
+ email:
48
+ - kenn.ejima@gmail.com
49
+ executables:
50
+ - dumper
51
+ extensions: []
52
+ extra_rdoc_files: []
53
+ files:
54
+ - .gitignore
55
+ - Gemfile
56
+ - LICENSE
57
+ - README.md
58
+ - Rakefile
59
+ - bin/dumper
60
+ - dumper.gemspec
61
+ - lib/dumper.rb
62
+ - lib/dumper/cli.rb
63
+ - lib/dumper/version.rb
64
+ homepage: ''
65
+ licenses: []
66
+ post_install_message:
67
+ rdoc_options: []
68
+ require_paths:
69
+ - lib
70
+ required_ruby_version: !ruby/object:Gem::Requirement
71
+ none: false
72
+ requirements:
73
+ - - ! '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ none: false
78
+ requirements:
79
+ - - ! '>='
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ requirements: []
83
+ rubyforge_project:
84
+ rubygems_version: 1.8.19
85
+ signing_key:
86
+ specification_version: 3
87
+ summary: Utility that checks the status of a database
88
+ test_files: []
89
+ has_rdoc: