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 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
@@ -1,15 +1,15 @@
1
1
  module Recipe
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
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
@@ -1,7 +1,7 @@
1
1
  module Recipe
2
- def self.bios
3
- if Os.windows?
4
- "systeminfo | findstr /B /C:\"BIOS Version\""
5
- end
6
- end
7
- end
2
+ def self.bios
3
+ if Os.windows?
4
+ "systeminfo | findstr /B /C:\"BIOS Version\""
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,17 @@
1
+ module Recipe
2
+ def self.eggs
3
+ "chicken-install -version"
4
+ end
5
+
6
+ def self.csi
7
+ "csi -version"
8
+ end
9
+
10
+ def self.csc
11
+ "csc -version"
12
+ end
13
+
14
+ def self.chicken
15
+ [eggs, csi]
16
+ end
17
+ end
@@ -1,7 +1,7 @@
1
1
  module Recipe
2
- def self.chocolatey
3
- if Os.windows?
4
- "chocolatey version"
5
- end
6
- end
2
+ def self.chocolatey
3
+ if Os.windows?
4
+ "chocolatey version"
5
+ end
6
+ end
7
7
  end
@@ -1,19 +1,19 @@
1
1
  module Recipe
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
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
@@ -0,0 +1,13 @@
1
+ module Recipe
2
+ def self.lein
3
+ "lein --version"
4
+ end
5
+
6
+ def self.clj
7
+ "clj -e '(println \"Clojure \" (clojure-version))'"
8
+ end
9
+
10
+ def self.clojure
11
+ [clj, lein]
12
+ end
13
+ end
@@ -1,14 +1,14 @@
1
1
  module Recipe
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
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
@@ -1,13 +1,13 @@
1
1
  module Recipe
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
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
@@ -1,19 +1,19 @@
1
1
  # Module name must be filename, minus .rb, in CamelCase.
2
2
  module Recipe
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
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
@@ -0,0 +1,7 @@
1
+ module Recipe
2
+ def self.ie
3
+ if Os.windows?
4
+ "reg query \"HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Internet Explorer\" /v Version"
5
+ end
6
+ end
7
+ end
@@ -1,19 +1,19 @@
1
1
  module Recipe
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
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
@@ -0,0 +1,5 @@
1
+ module Recipe
2
+ def self.java
3
+ "java -version"
4
+ end
5
+ end
@@ -1,7 +1,7 @@
1
1
  module Recipe
2
- def self.latex
3
- if Os.unix?
4
- "pdflatex --version"
5
- end
6
- end
7
- end
2
+ def self.latex
3
+ if Os.unix?
4
+ "pdflatex --version"
5
+ end
6
+ end
7
+ end
@@ -1,5 +1,5 @@
1
1
  module Recipe
2
- def self.ld
3
- "ld -v"
4
- end
5
- end
2
+ def self.ld
3
+ "ld -v"
4
+ end
5
+ end
@@ -1,5 +1,5 @@
1
1
  module Recipe
2
- def self.lua
3
- "lua -v"
4
- end
5
- end
2
+ def self.lua
3
+ "lua -v"
4
+ end
5
+ end
@@ -1,5 +1,5 @@
1
1
  module Recipe
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
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
@@ -1,13 +1,13 @@
1
1
  module Recipe
2
- def self.npm
3
- "npm --version"
4
- end
2
+ def self.npm
3
+ "npm --version"
4
+ end
5
5
 
6
- def self.js
7
- "node --version"
8
- end
6
+ def self.js
7
+ "node --version"
8
+ end
9
9
 
10
- def self.node
11
- [npm, js]
12
- end
13
- end
10
+ def self.node
11
+ [npm, js]
12
+ end
13
+ end
@@ -0,0 +1,5 @@
1
+ module Recipe
2
+ def self.ocaml
3
+ "ocaml -version"
4
+ end
5
+ end
@@ -1,14 +1,14 @@
1
1
  module Recipe
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
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
@@ -1,17 +1,17 @@
1
1
  module Recipe
2
- def self.ppm
3
- "ppm --version"
4
- end
2
+ def self.ppm
3
+ "ppm --version"
4
+ end
5
5
 
6
- def self.cpan
7
- "cpan --version"
8
- end
6
+ def self.cpan
7
+ "cpan --version"
8
+ end
9
9
 
10
- def self.pl
11
- "perl --version"
12
- end
10
+ def self.pl
11
+ "perl --version"
12
+ end
13
13
 
14
- def self.perl
15
- [ppm, cpan, pl]
16
- end
17
- end
14
+ def self.perl
15
+ [ppm, cpan, pl]
16
+ end
17
+ end
@@ -1,7 +1,7 @@
1
1
  module Recipe
2
- def self.powershell
3
- if Os.windows?
4
- "@powershell Get-Host"
5
- end
6
- end
2
+ def self.powershell
3
+ if Os.windows?
4
+ "@powershell Get-Host"
5
+ end
6
+ end
7
7
  end
@@ -1,11 +1,11 @@
1
1
  module Recipe
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
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
@@ -1,13 +1,19 @@
1
1
  module Recipe
2
- def self.rubygems
3
- "gem --version"
4
- end
2
+ module Package
3
+ def self.gem(package)
4
+ "gem list | grep #{package}"
5
+ end
6
+ end
5
7
 
6
- def self.rb
7
- "ruby --version"
8
- end
8
+ def self.rubygems
9
+ "gem --version"
10
+ end
9
11
 
10
- def self.ruby
11
- [rubygems, rb]
12
- end
13
- end
12
+ def self.rb
13
+ "ruby --version"
14
+ end
15
+
16
+ def self.ruby
17
+ [rubygems, rb]
18
+ end
19
+ end
@@ -0,0 +1,5 @@
1
+ module Recipe
2
+ def self.scala
3
+ "scalac -version"
4
+ end
5
+ end
@@ -1,9 +1,9 @@
1
1
  module Recipe
2
- def self.shell
3
- if Os.windows?
4
- "echo %cmdextversion%"
5
- elsif Os.unix?
6
- "sh --version"
7
- end
8
- end
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
@@ -0,0 +1,5 @@
1
+ module Recipe
2
+ def self.ssh
3
+ "ssh -V"
4
+ end
5
+ end
@@ -1,17 +1,17 @@
1
1
  module Recipe
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
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
@@ -1,7 +1,7 @@
1
1
  module Recipe
2
- def self.xcode
3
- if Os.mac?
4
- "xcodebuild -version"
5
- end
6
- end
7
- end
2
+ def self.xcode
3
+ if Os.mac?
4
+ "xcodebuild -version"
5
+ end
6
+ end
7
+ end
@@ -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.2"
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
- def self.raw
48
- # Config deprecated in Ruby 1.9
49
- RbConfig::CONFIG["host_os"]
50
- end
46
+ def self.raw
47
+ # Config deprecated in Ruby 1.9
48
+ RbConfig::CONFIG["host_os"]
49
+ end
51
50
 
52
- # A series of OS descriptions.
53
- # Not all of these are mutually exclusive.
51
+ # A series of OS descriptions.
52
+ # Not all of these are mutually exclusive.
54
53
 
55
- def self.windows?
56
- self.raw =~ /cygwin|mswin|mingw|bccwin|wince|emx/
57
- end
54
+ def self.windows?
55
+ self.raw =~ /cygwin|mswin|mingw|bccwin|wince|emx/
56
+ end
58
57
 
59
- def self.mingw?
60
- self.raw =~ /cygwin|mingw/
61
- end
58
+ def self.mingw?
59
+ self.raw =~ /cygwin|mingw/
60
+ end
62
61
 
63
- def self.mac?
64
- self.raw =~ /darwin/
65
- end
62
+ def self.mac?
63
+ self.raw =~ /darwin/
64
+ end
66
65
 
67
- def self.unix?
68
- not self.windows?
69
- end
66
+ def self.unix?
67
+ not self.windows?
68
+ end
70
69
 
71
- def self.haiku?
72
- self.raw =~ /haiku/
73
- end
70
+ def self.haiku?
71
+ self.raw =~ /haiku/
72
+ end
74
73
 
75
- def self.linux?
76
- self.unix? and not self.mac? and not self.haiku?
77
- end
74
+ def self.linux?
75
+ self.unix? and not self.mac? and not self.haiku?
76
+ end
78
77
 
79
- def self.x86_64?
80
- RbConfig::CONFIG["arch"] =~ /64/
81
- end
78
+ def self.x86_64?
79
+ RbConfig::CONFIG["arch"] =~ /64/
80
+ end
82
81
 
83
- def self.x86?
84
- !self.x86_64?
85
- end
82
+ def self.x86?
83
+ !self.x86_64?
84
+ end
86
85
  end
87
86
 
88
87
  module Recipe
89
- def self.command_not_found
90
- # Windows but not MinGW
91
- if Os.windows? and !Os.mingw?
92
- "not recognized as an internal or external command"
93
- # MinGW or other Unix variant.
94
- else
95
- "command not found"
96
- end
97
- end
98
-
99
- def self.os
100
- if Os.windows?
101
- "systeminfo | findstr /B /C:\"OS Name\" /C:\"OS Version\""
102
- elsif Os.mac?
103
- "system_profiler SPSoftwareDataType | grep 'System Version'"
104
- elsif Os.linux?
105
- "lsb_release -a"
106
- # Unix
107
- else
108
- "uname -a"
109
- end
110
- end
111
-
112
- def self.arch
113
- "ruby -rrbconfig -e 'puts RbConfig::CONFIG[\"arch\"]'"
114
- end
115
-
116
- def self.specs
117
- SPECS_VERSION_STRING
118
- end
119
-
120
- def self.ruby_v
121
- RUBY_VERSION
122
- end
123
-
124
- def self.ruby1_8?
125
- RUBY_VERSION =~ /^1\.8/
126
- end
127
-
128
- def self.ruby1_9?
129
- RUBY_VERSION =~ /^1\.9/
130
- end
131
-
132
- def self.rubygems
133
- "gem --version"
134
- end
135
-
136
- def self.rb
137
- "ruby --version"
138
- end
139
-
140
- def self.ruby
141
- [rubygems, rb]
142
- end
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
- # Custom aspect?
156
- if !BUILTINS.include?(aspect)
157
- require_path = "#{RECIPE_DIR}#{SEP}#{aspect}.rb"
158
-
159
- # Attempt to load custom aspect recipe.
160
- if File.exist?(require_path)
161
- require require_path
162
- end
163
- end
164
-
165
- # Ruby methods can't use hypens (-),
166
- # So translate to underscores (_)
167
- # When looking up known aspects.
168
- method = aspect.gsub("-", "_").to_sym
169
-
170
- # Known aspect.
171
- if Recipe.methods.include?(method)
172
- Recipe.send(method)
173
- # Unknown aspect.
174
- # Default to --version flag.
175
- else
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
- # Newline to visually separate multiple aspect commands.
184
- puts ""
185
-
186
- if cmd.nil?
187
- puts "#{aspect} aspect not implemented for this system"
188
-
189
- elsif cmd == SPECS_VERSION_STRING
190
- puts "specs --version"
191
- puts SPECS_VERSION_STRING
192
- else
193
- puts cmd
194
-
195
- output = `#{cmd} 2>&1`
196
-
197
- if output.include?(Recipe.command_not_found)
198
- puts "#{cmd.split.first} not found"
199
- else
200
- puts output
201
- end
202
- end
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
- system "more specs.rb"
207
- exit
210
+ system "more specs.rb"
211
+ exit
208
212
  end
209
213
 
210
214
  def print_specs_own_version
211
- puts SPECS_VERSION_STRING
212
- puts SPECS_HOME_PAGE
215
+ puts SPECS_VERSION_STRING
216
+ puts SPECS_HOME_PAGE
213
217
  end
214
218
 
215
219
  def check_ruby_version
216
- if RUBY_VERSION =~ /^1\.8/
217
- puts "Requires Ruby 1.9+"
218
- puts "http://www.ruby-lang.org/"
219
- exit
220
- end
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
- check_ruby_version
225
-
226
- opts = GetoptLong.new(
227
- ["--help", "-h", GetoptLong::NO_ARGUMENT],
228
- ["--version", "-v", GetoptLong::NO_ARGUMENT]
229
- )
230
-
231
- begin
232
- opts.each { |option, value|
233
- case option
234
- when "--help"
235
- usage
236
- when "--version"
237
- print_specs_own_version
238
- end
239
- }
240
- rescue GetoptLong::InvalidOption
241
- usage
242
- end
243
-
244
- # Default aspects
245
- aspects = ["specs", "os", "hardware"]
246
- if !ARGV.empty?
247
- aspects = ARGV
248
- end
249
-
250
- aspects = aspects - ["specs"]
251
- puts "Specs:\n\n"
252
- print_specs_own_version
253
-
254
- aspects.each { |aspect|
255
- # What does the aspect module say to run
256
- # in order to retrieve the aspect information?
257
- cmds = command(aspect)
258
-
259
- if cmds.nil? or cmds.instance_of?(String)
260
- run(cmds, aspect)
261
- # Module returns an array of command strings.
262
- elsif cmds.instance_of?(Array)
263
- cmds.each { |cmd| run(cmd, aspect) }
264
- end
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.2'
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-02-15 00:00:00.000000000 Z
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.24
73
+ rubygems_version: 1.8.23
66
74
  signing_key:
67
75
  specification_version: 3
68
76
  summary: Software version information at your fingertips