specs 0.19 → 0.20

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4dc8fbd20c9643c2b14cc197206902202f3960f8
4
- data.tar.gz: e2e9d12b0723079cb32a3db43bc80d5bbbd51993
3
+ metadata.gz: 108f0346813810751bc678547295cef5d746de69
4
+ data.tar.gz: fb0540346c63920763af7f363c535288e06598ed
5
5
  SHA512:
6
- metadata.gz: f0e1c9c089361b1cf962edc5c3b07cfe9c13c1da7f1e8ac29604a15839f22e461ac39a04bf27e4ebaeeb012cbd9c012745324c99c4c7fd2ff9e8832dcc195024
7
- data.tar.gz: 30b0b545cf2852c285f4b6eabe85a9760594283607166d75cc50ced13b1c3f68d38f39bb7b49273d0a7d46d72b135ea8f6b0182827677edf28db0b4487b74b56
6
+ metadata.gz: 98c054f85195eb660291294399f24e2da4d7afb9fd5717d6fbd7b02918cb632925132c7fd0c59ef5e87ebcb1c5d7f0d00faa1539474ca49b3ebcf97617385704
7
+ data.tar.gz: 7f40300e49dbcfa0eba415c23768d62095df8589f0a8ca70858f2180ea889d4d390eeee2ef2b0736f539121fa8b6f274ebb641ad70304cd232601b398fe492e2
data/bin/specs CHANGED
@@ -1,9 +1,3 @@
1
1
  #!/usr/bin/env ruby
2
- require 'rubygems'
3
2
  require 'specs'
4
-
5
- begin
6
- main
7
- rescue Interrupt
8
- nil
9
- end
3
+ Specs::main
@@ -0,0 +1,5 @@
1
+ module Recipe
2
+ def self.memcached
3
+ 'echo version | nc localhost 11211'
4
+ end
5
+ end
@@ -0,0 +1,52 @@
1
+ require_relative 'specs'
2
+
3
+ require 'docopt'
4
+
5
+ USAGE = <<DOCOPT
6
+ Usage:
7
+ specs [-v | -h] [<aspect>]...
8
+
9
+ Arguments:
10
+ <aspect> Software stack to query [default: os hardware].
11
+
12
+ Options:
13
+ -v --version Print version info.
14
+ -h --help Print usage info.
15
+ DOCOPT
16
+
17
+ module Specs
18
+ def self.main
19
+ check_ruby_version
20
+
21
+ begin
22
+ options = Docopt::docopt(USAGE, version: Specs::VERSION)
23
+
24
+ aspects = options['<aspect>']
25
+
26
+ # Work around https://github.com/docopt/docopt/issues/274
27
+ if aspects == []
28
+ aspects = ['os', 'hardware']
29
+ end
30
+
31
+ # Print specs' own version, and filter out redundant requests
32
+ aspects = ['specs'] + (aspects - ['specs'])
33
+
34
+ aspects.each do |aspect|
35
+ # What does the aspect module say to run
36
+ # in order to retrieve the aspect information?
37
+ cmds = command(aspect)
38
+
39
+ if !cmds || cmds.instance_of?(String)
40
+ run(cmds, aspect)
41
+ # Module returns an array of command strings.
42
+ elsif cmds.instance_of?(Array)
43
+ cmds.each { |cmd| run(cmd, aspect) }
44
+ end
45
+ end
46
+ rescue Docopt::Exit => e
47
+ puts e.message
48
+ end
49
+ rescue Interrupt
50
+ nil
51
+ end
52
+ end
@@ -1,4 +1,3 @@
1
- #!/usr/bin/env ruby
2
1
  #
3
2
  # Author:: Andrew Pennebaker
4
3
  #
@@ -8,16 +7,6 @@
8
7
  #
9
8
  # specs - Get system specs easily
10
9
  #
11
- # == Usage
12
- #
13
- # specs [aspects]
14
- #
15
- # Example:
16
- #
17
- # specs ruby os hardware
18
- #
19
- # By default, aspects are os and hardware.
20
- #
21
10
  # If an aspect is not installed, its output may be omitted.
22
11
  #
23
12
  # --help, -h:
@@ -26,18 +15,14 @@
26
15
  # --version, -v:
27
16
  # print specs' own version
28
17
 
29
- require 'getoptlong'
30
18
  require 'pathname'
31
19
  require 'system_with_aliases'
32
20
  require 'contracts'
33
21
  include Contracts
34
22
 
35
23
  require_relative 'version'
36
- SPECS_VERSION_STRING = "specs #{Specs::VERSION}"
37
-
38
- SPECS_HOME_PAGE = 'https://github.com/mcandre/specs#readme'
39
24
 
40
- SPECS_DIR = Pathname.new(File.dirname(__FILE__))
25
+ require_relative 'cli'
41
26
 
42
27
  # Get the basic operating system name reliably, even in JRuby
43
28
  # Useful for OS-contextual command line instructions.
@@ -160,11 +145,6 @@ module Recipe
160
145
  "ruby -rrbconfig -e \"puts RbConfig::CONFIG['arch']\""
161
146
  end
162
147
 
163
- Contract nil => String
164
- def self.specs
165
- SPECS_VERSION_STRING
166
- end
167
-
168
148
  Contract nil => String
169
149
  def self.ruby_v
170
150
  RUBY_VERSION
@@ -201,104 +181,78 @@ module Recipe
201
181
  end
202
182
  end
203
183
 
204
- BUILTINS = %w(specs os arch ruby)
205
-
206
- SEP = File::SEPARATOR
184
+ module Specs
185
+ include Contracts::Modules
207
186
 
208
- # .../specs/aspects
209
- RECIPE_DIR = [SPECS_DIR, 'aspects'].join(SEP)
187
+ SPECS_DIR = Pathname.new(File.dirname(__FILE__))
210
188
 
211
- Dir[File.join(RECIPE_DIR, '**', '*.rb')].each do |file|
212
- require File.expand_path(file)
213
- end
189
+ BUILTINS = %w(specs os arch ruby)
214
190
 
215
- # For a given spec, return the command line instruction(s)
216
- # that will get the spec's version information.
217
- Contract String => Any
218
- def self.command(aspect)
219
- # Ruby methods can't use hyphens (-),
220
- # So translate to underscores (_)
221
- # When looking up known aspects.
222
- method = aspect.gsub('-', '_').to_sym
223
-
224
- # Package?
225
- if aspect.include?(':')
226
- package_manager, package = aspect.split(':')
227
- package_manager = package_manager.to_sym
228
-
229
- if Recipe::Package.methods.include?(package_manager)
230
- Recipe::Package.send(package_manager, package)
231
- end
232
- # Known aspect?
233
- elsif Recipe.methods.include?(method)
234
- Recipe.send(method)
235
- # Unknown aspect.
236
- # Default to --version flag.
237
- else
238
- "#{aspect} --version"
239
- end
240
- end
191
+ SEP = File::SEPARATOR
241
192
 
242
- # Print a command line instruction and its output,
243
- # Emulating a user manually entering the instruction.
244
- def self.run(cmd, aspect)
245
- # Newline to visually separate multiple aspect commands.
246
- puts ''
193
+ # .../specs/aspects
194
+ RECIPE_DIR = [SPECS_DIR, 'aspects'].join(SEP)
247
195
 
248
- if !cmd
249
- puts "#{aspect} aspect not implemented for this system"
250
- elsif cmd == SPECS_VERSION_STRING
251
- puts 'specs --version'
252
- puts SPECS_VERSION_STRING
253
- else
254
- puts cmd
255
-
256
- output = SystemWithAliases::execute(cmd)
196
+ Dir[File.join(RECIPE_DIR, '**', '*.rb')].each do |file|
197
+ require File.expand_path(file)
198
+ end
257
199
 
258
- if output.include?(Recipe.command_not_found)
259
- puts "#{cmd.split.first} not found"
200
+ # For a given spec, return the command line instruction(s)
201
+ # that will get the spec's version information.
202
+ Contract String => Any
203
+ def self.command(aspect)
204
+ # Ruby methods can't use hyphens (-),
205
+ # So translate to underscores (_)
206
+ # When looking up known aspects.
207
+ method = aspect.gsub('-', '_').to_sym
208
+
209
+ # Package?
210
+ if aspect.include?(':')
211
+ package_manager, package = aspect.split(':')
212
+ package_manager = package_manager.to_sym
213
+
214
+ if Recipe::Package.methods.include?(package_manager)
215
+ Recipe::Package.send(package_manager, package)
216
+ end
217
+ # Known aspect?
218
+ elsif Recipe.methods.include?(method)
219
+ Recipe.send(method)
220
+ # Unknown aspect.
221
+ # Default to --version flag.
260
222
  else
261
- puts output
223
+ "#{aspect} --version"
262
224
  end
263
225
  end
264
- end
265
-
266
- def self.check_ruby_version
267
- if Recipe.ruby1_8?
268
- puts 'Requires Ruby 1.9 or higher.'
269
- puts 'http://www.ruby-lang.org/'
270
- exit
271
- end
272
- end
273
-
274
- def self.usage
275
- puts "Specs:\n\n#{SPECS_VERSION_STRING}\n#{SPECS_HOME_PAGE}"
276
226
 
277
- exit if ARGV.include?('--version')
278
- end
279
-
280
- def main
281
- check_ruby_version
282
-
283
- usage
284
-
285
- # Default aspects
286
- aspects = %w(os) # hardware)
227
+ # Print a command line instruction and its output,
228
+ # Emulating a user manually entering the instruction.
229
+ def self.run(cmd, aspect)
230
+ if !cmd
231
+ puts "#{aspect} aspect not implemented for this system"
232
+ elsif cmd == 'specs'
233
+ puts 'specs --version'
234
+ puts Specs::Version
235
+ else
236
+ puts cmd
287
237
 
288
- aspects = ARGV unless ARGV.empty?
238
+ output = SystemWithAliases::execute(cmd)
289
239
 
290
- aspects -= ['specs', '-v', 'version', '-version', '--version']
240
+ if output.include?(Recipe.command_not_found)
241
+ puts "#{cmd.split.first} not found"
242
+ else
243
+ puts output
244
+ end
291
245
 
292
- aspects.each do |aspect|
293
- # What does the aspect module say to run
294
- # in order to retrieve the aspect information?
295
- cmds = command(aspect)
246
+ # Vertically separate multiple aspects
247
+ puts ''
248
+ end
249
+ end
296
250
 
297
- if !cmds || cmds.instance_of?(String)
298
- run(cmds, aspect)
299
- # Module returns an array of command strings.
300
- elsif cmds.instance_of?(Array)
301
- cmds.each { |cmd| run(cmd, aspect) }
251
+ def self.check_ruby_version
252
+ if Recipe.ruby1_8?
253
+ puts 'Requires Ruby 1.9 or higher.'
254
+ puts 'http://www.ruby-lang.org/'
255
+ exit
302
256
  end
303
257
  end
304
258
  end
@@ -2,5 +2,5 @@
2
2
  # Specs
3
3
  #
4
4
  module Specs
5
- VERSION = '0.19'
5
+ VERSION = '0.20'
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: specs
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.19'
4
+ version: '0.20'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Pennebaker
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-03-23 00:00:00.000000000 Z
11
+ date: 2015-05-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rb-system-with-aliases
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ~>
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: docopt
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '0.5'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '0.5'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: contracts
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -317,6 +331,7 @@ files:
317
331
  - lib/aspects/ld.rb
318
332
  - lib/aspects/links.rb
319
333
  - lib/aspects/lua.rb
334
+ - lib/aspects/memcached.rb
320
335
  - lib/aspects/net.rb
321
336
  - lib/aspects/node.rb
322
337
  - lib/aspects/npm.rb
@@ -345,6 +360,7 @@ files:
345
360
  - lib/aspects/thunderbolt.rb
346
361
  - lib/aspects/virtualbox.rb
347
362
  - lib/aspects/xcode.rb
363
+ - lib/cli.rb
348
364
  - lib/specs.rb
349
365
  - lib/version.rb
350
366
  homepage: https://github.com/mcandre/specs
@@ -367,7 +383,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
367
383
  version: '0'
368
384
  requirements: []
369
385
  rubyforge_project:
370
- rubygems_version: 2.4.5
386
+ rubygems_version: 2.4.6
371
387
  signing_key:
372
388
  specification_version: 4
373
389
  summary: Software version information at your fingertips