envcheck 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 Scott Tadman
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,8 @@
1
+ = envcheck
2
+
3
+ Ruby Server Environment Checking Tool
4
+
5
+ == Copyright
6
+
7
+ Copyright (c) 2012 Scott Tadman, The Working Group Inc.
8
+ See LICENSE.txt for further details.
@@ -0,0 +1,26 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'rake'
5
+ require 'jeweler'
6
+
7
+ Jeweler::Tasks.new do |gem|
8
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
9
+ gem.name = "envcheck"
10
+ gem.homepage = "http://github.com/tadman/envcheck"
11
+ gem.license = "MIT"
12
+ gem.summary = %Q{Ruby Server Environment Checking Tool}
13
+ gem.description = %Q{Provides a simple way to test that your environment is configured correctly.}
14
+ gem.email = "scott@twg.ca"
15
+ gem.authors = [ "Scott Tadman" ]
16
+ end
17
+
18
+ Jeweler::RubygemsDotOrgTasks.new
19
+
20
+ require 'rake/testtask'
21
+
22
+ Rake::TestTask.new(:test) do |test|
23
+ test.libs << 'lib' << 'test'
24
+ test.pattern = 'test/**/test_*.rb'
25
+ test.verbose = true
26
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'optparse'
4
+
5
+ # == Library Path ===========================================================
6
+
7
+ SCRIPT_PATH = begin
8
+ script_path = __FILE__
9
+
10
+ count = 0
11
+
12
+ while (File.lstat(script_path).symlink?)
13
+ script_path = File.readlink(script_path)
14
+
15
+ count += 1
16
+ break if (count > 100)
17
+ end
18
+
19
+ script_path
20
+ end
21
+
22
+ $LOAD_PATH << File.expand_path(File.join('..', 'lib'), File.dirname(SCRIPT_PATH))
23
+
24
+ require 'envcheck'
25
+
26
+ # == Main ==================================================================
27
+
28
+ begin
29
+ puts Envcheck.report
30
+ end
@@ -0,0 +1,48 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "envcheck"
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Scott Tadman"]
12
+ s.date = "2012-04-30"
13
+ s.description = "Provides a simple way to test that your environment is configured correctly."
14
+ s.email = "scott@twg.ca"
15
+ s.executables = ["envcheck"]
16
+ s.extra_rdoc_files = [
17
+ "LICENSE.txt",
18
+ "README.rdoc"
19
+ ]
20
+ s.files = [
21
+ ".document",
22
+ "LICENSE.txt",
23
+ "README.rdoc",
24
+ "Rakefile",
25
+ "VERSION",
26
+ "bin/envcheck",
27
+ "envcheck-0.1.0.gem",
28
+ "envcheck.gemspec",
29
+ "lib/envcheck.rb",
30
+ "test/helper.rb",
31
+ "test/test_envcheck.rb"
32
+ ]
33
+ s.homepage = "http://github.com/tadman/envcheck"
34
+ s.licenses = ["MIT"]
35
+ s.require_paths = ["lib"]
36
+ s.rubygems_version = "1.8.21"
37
+ s.summary = "Ruby Server Environment Checking Tool"
38
+
39
+ if s.respond_to? :specification_version then
40
+ s.specification_version = 3
41
+
42
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
43
+ else
44
+ end
45
+ else
46
+ end
47
+ end
48
+
@@ -0,0 +1,84 @@
1
+ class Envcheck
2
+ # == Constants ============================================================
3
+
4
+ COMMANDS = {
5
+ :ruby => {
6
+ :version => /^ruby (\S+)/
7
+ },
8
+ :rubygems => {
9
+ :bin => 'gem',
10
+ :version => /(\S+)/
11
+ },
12
+ :bundler => {
13
+ :bin => 'bundle',
14
+ :version => /^Bundler version (.*)/
15
+ },
16
+ :passenger => {
17
+ :version => /^Phusion Passenger version (\S+)/
18
+ },
19
+ :ImageMagick => {
20
+ :bin => 'convert',
21
+ :version => /^Version: ImageMagick (\S+)/
22
+ },
23
+ :mysql => {
24
+ :version => /Ver\s+\S+\s+Distrib\s+(\S+),/
25
+ }
26
+ }.freeze
27
+
28
+ # == Class Methods ========================================================
29
+
30
+ def self.report
31
+ self.new.report
32
+ end
33
+
34
+ # == Instance Methods =====================================================
35
+
36
+ def initialize(options = nil)
37
+ @options = options
38
+ end
39
+
40
+ def path
41
+ @path ||= ENV['PATH'].split(/\:/).select do |path|
42
+ path and path.match(/\S/)
43
+ end
44
+ end
45
+
46
+ def find_in_path(file)
47
+ return unless (file)
48
+
49
+ file = file.to_s
50
+
51
+ self.path.each do |path|
52
+ test_path = File.expand_path(file, path)
53
+ if (File.exist?(test_path))
54
+ return test_path
55
+ end
56
+ end
57
+
58
+ nil
59
+ end
60
+
61
+ def report
62
+ summary = ''
63
+
64
+ COMMANDS.each do |command, config|
65
+ summary << "#{command}\n"
66
+
67
+ if (bin_found = self.find_in_path(config[:bin] || command))
68
+ summary << " #{bin_found}\n"
69
+
70
+ version_string = `#{bin_found} #{config[:version_flag] || '--version'}`
71
+
72
+ if (match = (config[:version] and version_string.match(config[:version])))
73
+ summary << " Version #{match[1]}\n"
74
+ else
75
+ summary << version_string.split(/\n/).collect { |s| " #{s}\n" }.join('')
76
+ end
77
+ else
78
+ summary << " NOT FOUND\n"
79
+ end
80
+ end
81
+
82
+ summary
83
+ end
84
+ end
@@ -0,0 +1,18 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'test/unit'
11
+ require 'shoulda'
12
+
13
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
14
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
15
+ require 'envcheck'
16
+
17
+ class Test::Unit::TestCase
18
+ end
@@ -0,0 +1,7 @@
1
+ require 'helper'
2
+
3
+ class TestEnvcheck < Test::Unit::TestCase
4
+ should "probably rename this file and start testing for real" do
5
+ flunk "hey buddy, you should probably rename this file and start testing for real"
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,59 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: envcheck
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Scott Tadman
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-04-30 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: Provides a simple way to test that your environment is configured correctly.
15
+ email: scott@twg.ca
16
+ executables:
17
+ - envcheck
18
+ extensions: []
19
+ extra_rdoc_files:
20
+ - LICENSE.txt
21
+ - README.rdoc
22
+ files:
23
+ - .document
24
+ - LICENSE.txt
25
+ - README.rdoc
26
+ - Rakefile
27
+ - VERSION
28
+ - bin/envcheck
29
+ - envcheck-0.1.0.gem
30
+ - envcheck.gemspec
31
+ - lib/envcheck.rb
32
+ - test/helper.rb
33
+ - test/test_envcheck.rb
34
+ homepage: http://github.com/tadman/envcheck
35
+ licenses:
36
+ - MIT
37
+ post_install_message:
38
+ rdoc_options: []
39
+ require_paths:
40
+ - lib
41
+ required_ruby_version: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ required_rubygems_version: !ruby/object:Gem::Requirement
48
+ none: false
49
+ requirements:
50
+ - - ! '>='
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ requirements: []
54
+ rubyforge_project:
55
+ rubygems_version: 1.8.21
56
+ signing_key:
57
+ specification_version: 3
58
+ summary: Ruby Server Environment Checking Tool
59
+ test_files: []