specs 0.2 → 0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE.md +22 -22
- data/bin/specs +0 -0
- data/lib/aspects/as.rb +14 -14
- data/lib/aspects/bios.rb +6 -6
- data/lib/aspects/chicken.rb +17 -0
- data/lib/aspects/chocolatey.rb +5 -5
- data/lib/aspects/chrome.rb +18 -18
- data/lib/aspects/clojure.rb +13 -0
- data/lib/aspects/cpu.rb +13 -13
- data/lib/aspects/firefox.rb +12 -12
- data/lib/aspects/hardware.rb +16 -16
- data/lib/aspects/haskell.rb +21 -0
- data/lib/aspects/ie.rb +7 -0
- data/lib/aspects/inkscape.rb +18 -18
- data/lib/aspects/java.rb +5 -0
- data/lib/aspects/latex.rb +6 -6
- data/lib/aspects/ld.rb +4 -4
- data/lib/aspects/lua.rb +4 -4
- data/lib/aspects/net.rb +4 -4
- data/lib/aspects/node.rb +10 -10
- data/lib/aspects/ocaml.rb +5 -0
- data/lib/aspects/opera.rb +13 -13
- data/lib/aspects/perl.rb +13 -13
- data/lib/aspects/powershell.rb +5 -5
- data/lib/aspects/ram.rb +10 -10
- data/lib/aspects/ruby.rb +16 -10
- data/lib/aspects/scala.rb +5 -0
- data/lib/aspects/shell.rb +8 -8
- data/lib/aspects/ssh.rb +5 -0
- data/lib/aspects/virtualbox.rb +16 -16
- data/lib/aspects/xcode.rb +6 -6
- data/lib/specs.rb +185 -181
- metadata +11 -3
data/LICENSE.md
CHANGED
@@ -1,23 +1,23 @@
|
|
1
|
-
# FreeBSD License
|
2
|
-
|
3
|
-
# Copyright 2012 Andrew Pennebaker. All rights reserved.
|
4
|
-
|
5
|
-
Redistribution and use in source and binary forms, with or without modification,
|
6
|
-
are permitted provided that the following conditions are met:
|
7
|
-
|
8
|
-
1. Redistributions of source code must retain the above copyright notice, this
|
9
|
-
list of conditions and the following disclaimer.
|
10
|
-
2. Redistributions in binary form must reproduce the above copyright notice,
|
11
|
-
this list of conditions and the following disclaimer in the documentation and/or
|
12
|
-
other materials provided with the distribution.
|
13
|
-
|
14
|
-
THIS SOFTWARE IS PROVIDED BY THE AUTHORS "AS IS" AND ANY EXPRESS OR IMPLIED
|
15
|
-
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
16
|
-
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
17
|
-
SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
18
|
-
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
19
|
-
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
20
|
-
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
21
|
-
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
22
|
-
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
1
|
+
# FreeBSD License
|
2
|
+
|
3
|
+
# Copyright 2012 Andrew Pennebaker. All rights reserved.
|
4
|
+
|
5
|
+
Redistribution and use in source and binary forms, with or without modification,
|
6
|
+
are permitted provided that the following conditions are met:
|
7
|
+
|
8
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
9
|
+
list of conditions and the following disclaimer.
|
10
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
11
|
+
this list of conditions and the following disclaimer in the documentation and/or
|
12
|
+
other materials provided with the distribution.
|
13
|
+
|
14
|
+
THIS SOFTWARE IS PROVIDED BY THE AUTHORS "AS IS" AND ANY EXPRESS OR IMPLIED
|
15
|
+
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
16
|
+
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
17
|
+
SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
18
|
+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
19
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
20
|
+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
21
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
22
|
+
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
23
23
|
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/bin/specs
CHANGED
File without changes
|
data/lib/aspects/as.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
module Recipe
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
end
|
2
|
+
def self.as
|
3
|
+
# Windows
|
4
|
+
if Os.windows?
|
5
|
+
"as -version"
|
6
|
+
# Assume OS is a Unix variant.
|
7
|
+
# as hangs by default, waiting for stdin to end;
|
8
|
+
# Send EOF via /dev/null.
|
9
|
+
#
|
10
|
+
# Don't create spurious a.out file.
|
11
|
+
else
|
12
|
+
"as -o /dev/null -version < /dev/null"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/aspects/bios.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Recipe
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
end
|
2
|
+
def self.bios
|
3
|
+
if Os.windows?
|
4
|
+
"systeminfo | findstr /B /C:\"BIOS Version\""
|
5
|
+
end
|
6
|
+
end
|
7
|
+
end
|
data/lib/aspects/chocolatey.rb
CHANGED
data/lib/aspects/chrome.rb
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
module Recipe
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
end
|
2
|
+
def self.chrome
|
3
|
+
# Assumes Chrome installed in default directory.
|
4
|
+
if Os.mac?
|
5
|
+
"/Applications/Google\\ Chrome.app/Contents/MacOS/Google\\ Chrome --version 2>&1 | grep -v Unsure" # Redirect stderr to stdout
|
6
|
+
elsif Os.windows?
|
7
|
+
if Os.x86_64?
|
8
|
+
"%UserProfile%\\AppData\\Local\\Google\\Chrome\\Application\\chrome --version"
|
9
|
+
else
|
10
|
+
"\"C:\\Program Files\\Google\\Chrome\\Application\\chrome\" --version"
|
11
|
+
end
|
12
|
+
# Assumes
|
13
|
+
# * binary is google-chrome.
|
14
|
+
# * binary is in PATH.
|
15
|
+
else
|
16
|
+
"google-chrome --version"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/aspects/cpu.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
module Recipe
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
end
|
2
|
+
def self.cpu
|
3
|
+
if Os.windows?
|
4
|
+
"wmic cpu get NumberOfCores, NumberOfLogicalProcessors"
|
5
|
+
elsif Os.mac?
|
6
|
+
[
|
7
|
+
"system_profiler | grep Cores: ",
|
8
|
+
"system_profiler | grep Processors:"
|
9
|
+
]
|
10
|
+
else
|
11
|
+
"cat /proc/cpuinfo | grep processor | wc -l"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/lib/aspects/firefox.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
module Recipe
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
end
|
2
|
+
def self.firefox
|
3
|
+
# Assumes Firefox is installed in the default directory.
|
4
|
+
if Os.windows?
|
5
|
+
"C:\\Program Files (x86)\\Mozilla Firefox\\firefox --version"
|
6
|
+
elsif Os.mac?
|
7
|
+
"/Applications/Firefox.app/Contents/MacOS/firefox --version"
|
8
|
+
# Assumes firefox in PATH.
|
9
|
+
else
|
10
|
+
"firefox --version"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lib/aspects/hardware.rb
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
# Module name must be filename, minus .rb, in CamelCase.
|
2
2
|
module Recipe
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
3
|
+
# ModuleName.command returns the appropriate command line instruction for returning the relevant specifications.
|
4
|
+
# OS-contextual instructions can be modulated by querying the Os module (see the root specs Ruby code).
|
5
|
+
def self.hardware
|
6
|
+
# Use environment variable.
|
7
|
+
if Os.windows?
|
8
|
+
"systeminfo | findstr /B /C:\"System Manufacturer\" /C:\"System Model\""
|
9
|
+
# Produces a noticeable delay.
|
10
|
+
elsif Os.mac?
|
11
|
+
"system_profiler | grep 'Model Identifier'"
|
12
|
+
# Assume:
|
13
|
+
# * OS is a Unix variant.
|
14
|
+
# * dmidecode is installed.
|
15
|
+
else
|
16
|
+
"sudo dmidecode -t system | grep Manufacturer|Product"
|
17
|
+
end
|
18
|
+
end
|
19
19
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Recipe
|
2
|
+
def self.cabal
|
3
|
+
"cabal --version"
|
4
|
+
end
|
5
|
+
|
6
|
+
def self.ghc
|
7
|
+
"ghc --version"
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.haskellplatform
|
11
|
+
"ghc-pkg field haskell-platform version"
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.haskell
|
15
|
+
[
|
16
|
+
cabal,
|
17
|
+
ghc,
|
18
|
+
haskellplatform
|
19
|
+
]
|
20
|
+
end
|
21
|
+
end
|
data/lib/aspects/ie.rb
ADDED
data/lib/aspects/inkscape.rb
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
module Recipe
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
end
|
2
|
+
def self.inkscape
|
3
|
+
# Assumes Inkscape is installed in default directory.
|
4
|
+
if Os.windows?
|
5
|
+
if Os.x86_64?
|
6
|
+
"C:\\Program Files (x86)\\Inkscape\\inkscape --version"
|
7
|
+
elsif Os.x86?
|
8
|
+
"\"C:\\Program Files\\Inkscape\\inkscape\" --version"
|
9
|
+
end
|
10
|
+
elsif Os.mac?
|
11
|
+
"/Applications/Inkscape.app/Contents/Resources/bin/inkscape --version"
|
12
|
+
# Assumes:
|
13
|
+
# * OS is a Unix variant.
|
14
|
+
# * inkscape is in PATH.
|
15
|
+
else
|
16
|
+
"inkscape --version"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/aspects/java.rb
ADDED
data/lib/aspects/latex.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Recipe
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
end
|
2
|
+
def self.latex
|
3
|
+
if Os.unix?
|
4
|
+
"pdflatex --version"
|
5
|
+
end
|
6
|
+
end
|
7
|
+
end
|
data/lib/aspects/ld.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
module Recipe
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
end
|
2
|
+
def self.ld
|
3
|
+
"ld -v"
|
4
|
+
end
|
5
|
+
end
|
data/lib/aspects/lua.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
module Recipe
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
end
|
2
|
+
def self.lua
|
3
|
+
"lua -v"
|
4
|
+
end
|
5
|
+
end
|
data/lib/aspects/net.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
module Recipe
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
end
|
2
|
+
def self.net
|
3
|
+
"ruby -e \"require 'net/http'; puts Net::HTTP.new('icanhazip.com').request(Net::HTTP::Get.new('/', {'User-Agent'=>'curl'})).body\""
|
4
|
+
end
|
5
|
+
end
|
data/lib/aspects/node.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
module Recipe
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
def self.npm
|
3
|
+
"npm --version"
|
4
|
+
end
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
def self.js
|
7
|
+
"node --version"
|
8
|
+
end
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
end
|
10
|
+
def self.node
|
11
|
+
[npm, js]
|
12
|
+
end
|
13
|
+
end
|
data/lib/aspects/opera.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
module Recipe
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
end
|
2
|
+
def self.opera
|
3
|
+
# Assumes opera in PATH.
|
4
|
+
if Os.unix? and not Os.mac?
|
5
|
+
"opera -version"
|
6
|
+
# Opera for Mac/Windows does not support the -version command line option.
|
7
|
+
# # Assumes Opera is installed in the default directory.
|
8
|
+
# elsif Os.mac?
|
9
|
+
# "/Applications/Opera.app/Contents/MacOS/Opera -version"
|
10
|
+
# elsif Os.windows?
|
11
|
+
# "C:\\Program Files (x86)\\Opera\\opera -version"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/lib/aspects/perl.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
module Recipe
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
def self.ppm
|
3
|
+
"ppm --version"
|
4
|
+
end
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
def self.cpan
|
7
|
+
"cpan --version"
|
8
|
+
end
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
def self.pl
|
11
|
+
"perl --version"
|
12
|
+
end
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
end
|
14
|
+
def self.perl
|
15
|
+
[ppm, cpan, pl]
|
16
|
+
end
|
17
|
+
end
|
data/lib/aspects/powershell.rb
CHANGED
data/lib/aspects/ram.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
module Recipe
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
end
|
2
|
+
def self.ram
|
3
|
+
if Os.windows?
|
4
|
+
"systeminfo | findstr /C:\"Total Physical Memory\""
|
5
|
+
elsif Os.mac?
|
6
|
+
"system_profiler | grep 'Memory:'"
|
7
|
+
else
|
8
|
+
"grep MemTotal /proc/meminfo"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
data/lib/aspects/ruby.rb
CHANGED
@@ -1,13 +1,19 @@
|
|
1
1
|
module Recipe
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
module Package
|
3
|
+
def self.gem(package)
|
4
|
+
"gem list | grep #{package}"
|
5
|
+
end
|
6
|
+
end
|
5
7
|
|
6
|
-
|
7
|
-
|
8
|
-
|
8
|
+
def self.rubygems
|
9
|
+
"gem --version"
|
10
|
+
end
|
9
11
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
12
|
+
def self.rb
|
13
|
+
"ruby --version"
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.ruby
|
17
|
+
[rubygems, rb]
|
18
|
+
end
|
19
|
+
end
|
data/lib/aspects/shell.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
module Recipe
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
end
|
2
|
+
def self.shell
|
3
|
+
if Os.windows?
|
4
|
+
"echo %cmdextversion%"
|
5
|
+
elsif Os.unix?
|
6
|
+
"sh --version"
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
data/lib/aspects/ssh.rb
ADDED
data/lib/aspects/virtualbox.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
module Recipe
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
end
|
2
|
+
def self.virtualbox
|
3
|
+
# Assumes Firefox is installed in the default directory.
|
4
|
+
if Os.windows?
|
5
|
+
if Os.x86?
|
6
|
+
"\"C:\\Program Files\\Oracle\\VirtualBox\\VBoxManage\" --version"
|
7
|
+
elsif Os.x86_64?
|
8
|
+
"C:\\Program Files (x86)\\Oracle\\VirtualBox\\VBoxManage --version"
|
9
|
+
end
|
10
|
+
elsif Os.mac?
|
11
|
+
"/Applications/Firefox.app/Contents/MacOS/firefox --version"
|
12
|
+
# Assumes firefox in PATH.
|
13
|
+
else
|
14
|
+
"firefox --version"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/aspects/xcode.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Recipe
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
end
|
2
|
+
def self.xcode
|
3
|
+
if Os.mac?
|
4
|
+
"xcodebuild -version"
|
5
|
+
end
|
6
|
+
end
|
7
|
+
end
|
data/lib/specs.rb
CHANGED
@@ -27,10 +27,9 @@
|
|
27
27
|
# print specs' own version
|
28
28
|
|
29
29
|
require "getoptlong"
|
30
|
-
|
31
30
|
require "pathname"
|
32
31
|
|
33
|
-
SPECS_VERSION = "0.
|
32
|
+
SPECS_VERSION = "0.3"
|
34
33
|
SPECS_VERSION_STRING = "specs #{SPECS_VERSION}"
|
35
34
|
SPECS_HOME_PAGE = "https://github.com/mcandre/specs#readme"
|
36
35
|
|
@@ -44,102 +43,105 @@ SPECS_DIR = Pathname.new(File.dirname(__FILE__))
|
|
44
43
|
# "firefox --version" in Unix
|
45
44
|
#
|
46
45
|
module Os
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
46
|
+
def self.raw
|
47
|
+
# Config deprecated in Ruby 1.9
|
48
|
+
RbConfig::CONFIG["host_os"]
|
49
|
+
end
|
51
50
|
|
52
|
-
|
53
|
-
|
51
|
+
# A series of OS descriptions.
|
52
|
+
# Not all of these are mutually exclusive.
|
54
53
|
|
55
|
-
|
56
|
-
|
57
|
-
|
54
|
+
def self.windows?
|
55
|
+
self.raw =~ /cygwin|mswin|mingw|bccwin|wince|emx/
|
56
|
+
end
|
58
57
|
|
59
|
-
|
60
|
-
|
61
|
-
|
58
|
+
def self.mingw?
|
59
|
+
self.raw =~ /cygwin|mingw/
|
60
|
+
end
|
62
61
|
|
63
|
-
|
64
|
-
|
65
|
-
|
62
|
+
def self.mac?
|
63
|
+
self.raw =~ /darwin/
|
64
|
+
end
|
66
65
|
|
67
|
-
|
68
|
-
|
69
|
-
|
66
|
+
def self.unix?
|
67
|
+
not self.windows?
|
68
|
+
end
|
70
69
|
|
71
|
-
|
72
|
-
|
73
|
-
|
70
|
+
def self.haiku?
|
71
|
+
self.raw =~ /haiku/
|
72
|
+
end
|
74
73
|
|
75
|
-
|
76
|
-
|
77
|
-
|
74
|
+
def self.linux?
|
75
|
+
self.unix? and not self.mac? and not self.haiku?
|
76
|
+
end
|
78
77
|
|
79
|
-
|
80
|
-
|
81
|
-
|
78
|
+
def self.x86_64?
|
79
|
+
RbConfig::CONFIG["arch"] =~ /64/
|
80
|
+
end
|
82
81
|
|
83
|
-
|
84
|
-
|
85
|
-
|
82
|
+
def self.x86?
|
83
|
+
!self.x86_64?
|
84
|
+
end
|
86
85
|
end
|
87
86
|
|
88
87
|
module Recipe
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
88
|
+
module Package
|
89
|
+
end
|
90
|
+
|
91
|
+
def self.command_not_found
|
92
|
+
# Windows but not MinGW
|
93
|
+
if Os.windows? and !Os.mingw?
|
94
|
+
"not recognized as an internal or external command"
|
95
|
+
# MinGW or other Unix variant.
|
96
|
+
else
|
97
|
+
"command not found"
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
def self.os
|
102
|
+
if Os.windows?
|
103
|
+
"systeminfo | findstr /B /C:\"OS Name\" /C:\"OS Version\""
|
104
|
+
elsif Os.mac?
|
105
|
+
"system_profiler SPSoftwareDataType | grep 'System Version'"
|
106
|
+
elsif Os.linux?
|
107
|
+
"lsb_release -a"
|
108
|
+
# Unix
|
109
|
+
else
|
110
|
+
"uname -a"
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
def self.arch
|
115
|
+
"ruby -rrbconfig -e 'puts RbConfig::CONFIG[\"arch\"]'"
|
116
|
+
end
|
117
|
+
|
118
|
+
def self.specs
|
119
|
+
SPECS_VERSION_STRING
|
120
|
+
end
|
121
|
+
|
122
|
+
def self.ruby_v
|
123
|
+
RUBY_VERSION
|
124
|
+
end
|
125
|
+
|
126
|
+
def self.ruby1_8?
|
127
|
+
RUBY_VERSION =~ /^1\.8/
|
128
|
+
end
|
129
|
+
|
130
|
+
def self.ruby1_9?
|
131
|
+
RUBY_VERSION =~ /^1\.9/
|
132
|
+
end
|
133
|
+
|
134
|
+
def self.rubygems
|
135
|
+
"gem --version"
|
136
|
+
end
|
137
|
+
|
138
|
+
def self.rb
|
139
|
+
"ruby --version"
|
140
|
+
end
|
141
|
+
|
142
|
+
def self.ruby
|
143
|
+
[rubygems, rb]
|
144
|
+
end
|
143
145
|
end
|
144
146
|
|
145
147
|
BUILTINS = ["specs", "os", "arch", "ruby"]
|
@@ -149,118 +151,120 @@ SEP = File::SEPARATOR
|
|
149
151
|
# .../specs/aspects
|
150
152
|
RECIPE_DIR = [SPECS_DIR, "aspects"].join(SEP)
|
151
153
|
|
154
|
+
Dir[File.join(RECIPE_DIR, '**', '*.rb')].each do |file|
|
155
|
+
require File.expand_path(file)
|
156
|
+
end
|
157
|
+
|
152
158
|
# For a given spec, return the command line instruction(s)
|
153
159
|
# that will get the spec's version information.
|
154
160
|
def command(aspect)
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
"#{aspect} --version"
|
177
|
-
end
|
161
|
+
# Ruby methods can't use hypens (-),
|
162
|
+
# So translate to underscores (_)
|
163
|
+
# When looking up known aspects.
|
164
|
+
method = aspect.gsub("-", "_").to_sym
|
165
|
+
|
166
|
+
# Package?
|
167
|
+
if aspect.include?(":")
|
168
|
+
package_manager, package = aspect.split(":")
|
169
|
+
package_manager = package_manager.to_sym
|
170
|
+
|
171
|
+
if Recipe::Package.methods.include?(package_manager)
|
172
|
+
Recipe::Package.send(package_manager, package)
|
173
|
+
end
|
174
|
+
# Known aspect?
|
175
|
+
elsif Recipe.methods.include?(method)
|
176
|
+
Recipe.send(method)
|
177
|
+
# Unknown aspect.
|
178
|
+
# Default to --version flag.
|
179
|
+
else
|
180
|
+
"#{aspect} --version"
|
181
|
+
end
|
178
182
|
end
|
179
183
|
|
180
184
|
# Print a command line instruction and its output,
|
181
185
|
# Emulating a user manually entering the instruction.
|
182
186
|
def run(cmd, aspect)
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
187
|
+
# Newline to visually separate multiple aspect commands.
|
188
|
+
puts ""
|
189
|
+
|
190
|
+
if cmd.nil?
|
191
|
+
puts "#{aspect} aspect not implemented for this system"
|
192
|
+
|
193
|
+
elsif cmd == SPECS_VERSION_STRING
|
194
|
+
puts "specs --version"
|
195
|
+
puts SPECS_VERSION_STRING
|
196
|
+
else
|
197
|
+
puts cmd
|
198
|
+
|
199
|
+
output = `#{cmd} 2>&1`
|
200
|
+
|
201
|
+
if output.include?(Recipe.command_not_found)
|
202
|
+
puts "#{cmd.split.first} not found"
|
203
|
+
else
|
204
|
+
puts output
|
205
|
+
end
|
206
|
+
end
|
203
207
|
end
|
204
208
|
|
205
209
|
def usage
|
206
|
-
|
207
|
-
|
210
|
+
system "more specs.rb"
|
211
|
+
exit
|
208
212
|
end
|
209
213
|
|
210
214
|
def print_specs_own_version
|
211
|
-
|
212
|
-
|
215
|
+
puts SPECS_VERSION_STRING
|
216
|
+
puts SPECS_HOME_PAGE
|
213
217
|
end
|
214
218
|
|
215
219
|
def check_ruby_version
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
220
|
+
if RUBY_VERSION =~ /^1\.8/
|
221
|
+
puts "Requires Ruby 1.9+"
|
222
|
+
puts "http://www.ruby-lang.org/"
|
223
|
+
exit
|
224
|
+
end
|
221
225
|
end
|
222
226
|
|
223
227
|
def main
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
end
|
228
|
+
check_ruby_version
|
229
|
+
|
230
|
+
opts = GetoptLong.new(
|
231
|
+
["--help", "-h", GetoptLong::NO_ARGUMENT],
|
232
|
+
["--version", "-v", GetoptLong::NO_ARGUMENT]
|
233
|
+
)
|
234
|
+
|
235
|
+
begin
|
236
|
+
opts.each { |option, value|
|
237
|
+
case option
|
238
|
+
when "--help"
|
239
|
+
usage
|
240
|
+
when "--version"
|
241
|
+
print_specs_own_version
|
242
|
+
end
|
243
|
+
}
|
244
|
+
rescue GetoptLong::InvalidOption
|
245
|
+
usage
|
246
|
+
end
|
247
|
+
|
248
|
+
# Default aspects
|
249
|
+
aspects = ["specs", "os", "hardware"]
|
250
|
+
if !ARGV.empty?
|
251
|
+
aspects = ARGV
|
252
|
+
end
|
253
|
+
|
254
|
+
aspects = aspects - ["specs"]
|
255
|
+
puts "Specs:\n\n"
|
256
|
+
print_specs_own_version
|
257
|
+
|
258
|
+
aspects.each { |aspect|
|
259
|
+
# What does the aspect module say to run
|
260
|
+
# in order to retrieve the aspect information?
|
261
|
+
cmds = command(aspect)
|
262
|
+
|
263
|
+
if cmds.nil? or cmds.instance_of?(String)
|
264
|
+
run(cmds, aspect)
|
265
|
+
# Module returns an array of command strings.
|
266
|
+
elsif cmds.instance_of?(Array)
|
267
|
+
cmds.each { |cmd| run(cmd, aspect) }
|
268
|
+
end
|
269
|
+
}
|
270
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: specs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.3'
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-03-23 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: See README.md for example usage
|
15
15
|
email: andrew.pennebaker@gmail.com
|
@@ -21,23 +21,31 @@ files:
|
|
21
21
|
- lib/specs.rb
|
22
22
|
- lib/aspects/as.rb
|
23
23
|
- lib/aspects/bios.rb
|
24
|
+
- lib/aspects/chicken.rb
|
24
25
|
- lib/aspects/chocolatey.rb
|
25
26
|
- lib/aspects/chrome.rb
|
27
|
+
- lib/aspects/clojure.rb
|
26
28
|
- lib/aspects/cpu.rb
|
27
29
|
- lib/aspects/firefox.rb
|
28
30
|
- lib/aspects/hardware.rb
|
31
|
+
- lib/aspects/haskell.rb
|
32
|
+
- lib/aspects/ie.rb
|
29
33
|
- lib/aspects/inkscape.rb
|
34
|
+
- lib/aspects/java.rb
|
30
35
|
- lib/aspects/latex.rb
|
31
36
|
- lib/aspects/ld.rb
|
32
37
|
- lib/aspects/lua.rb
|
33
38
|
- lib/aspects/net.rb
|
34
39
|
- lib/aspects/node.rb
|
40
|
+
- lib/aspects/ocaml.rb
|
35
41
|
- lib/aspects/opera.rb
|
36
42
|
- lib/aspects/perl.rb
|
37
43
|
- lib/aspects/powershell.rb
|
38
44
|
- lib/aspects/ram.rb
|
39
45
|
- lib/aspects/ruby.rb
|
46
|
+
- lib/aspects/scala.rb
|
40
47
|
- lib/aspects/shell.rb
|
48
|
+
- lib/aspects/ssh.rb
|
41
49
|
- lib/aspects/virtualbox.rb
|
42
50
|
- lib/aspects/xcode.rb
|
43
51
|
- LICENSE.md
|
@@ -62,7 +70,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
62
70
|
version: '0'
|
63
71
|
requirements: []
|
64
72
|
rubyforge_project:
|
65
|
-
rubygems_version: 1.8.
|
73
|
+
rubygems_version: 1.8.23
|
66
74
|
signing_key:
|
67
75
|
specification_version: 3
|
68
76
|
summary: Software version information at your fingertips
|