Implement os/windows.parseWmicDiskDriveGet()

This commit is contained in:
Juan Cruz Viotti 2014-12-09 12:46:02 -04:00
parent 9dbf3a21cf
commit 75ce68c789
34 changed files with 322 additions and 35 deletions

View File

@ -259,11 +259,24 @@
</li>
</ul>
</ul>
<ul>
<li class='letter'>w</li>
<ul>
<li>
<a href='file/lib/resin/os/windows/windows.coffee.html'>
windows.coffee
</a>
<small>
(lib&#47;resin&#47;os&#47;windows)
</small>
</li>
</ul>
</ul>
</div>
</div>
</div>
<div id='footer'>
December 09, 14 09:05:26 by
December 09, 14 12:47:37 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo
</a>

View File

@ -87,7 +87,7 @@
</div>
</div>
<div id='footer'>
December 09, 14 09:05:26 by
December 09, 14 12:47:37 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo
</a>

View File

@ -83,7 +83,7 @@ Error: Invalid configuration file: /opt/resin.conf
</div>
</div>
<div id='footer'>
December 09, 14 09:05:26 by
December 09, 14 12:47:37 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo
</a>

View File

@ -70,7 +70,7 @@ Error: Invalid credentials
</div>
</div>
<div id='footer'>
December 09, 14 09:05:26 by
December 09, 14 12:47:37 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo
</a>

View File

@ -70,7 +70,7 @@ Error: Invalid key
</div>
</div>
<div id='footer'>
December 09, 14 09:05:26 by
December 09, 14 12:47:37 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo
</a>

View File

@ -83,7 +83,7 @@ Error: Invalid path: /tmp
</div>
</div>
<div id='footer'>
December 09, 14 09:05:26 by
December 09, 14 12:47:37 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo
</a>

View File

@ -83,7 +83,7 @@ Error: You don&#39;t have any applications
</div>
</div>
<div id='footer'>
December 09, 14 09:05:26 by
December 09, 14 12:47:37 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo
</a>

View File

@ -83,7 +83,7 @@ Error: Couldn&#39;t find application
</div>
</div>
<div id='footer'>
December 09, 14 09:05:26 by
December 09, 14 12:47:37 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo
</a>

View File

@ -392,7 +392,7 @@
</div>
</div>
<div id='footer'>
December 09, 14 09:05:26 by
December 09, 14 12:47:37 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo
</a>

View File

@ -119,7 +119,7 @@ console.log(contents.remoteUrl)
</div>
</div>
<div id='footer'>
December 09, 14 09:05:26 by
December 09, 14 12:47:37 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo
</a>

View File

@ -169,7 +169,7 @@
</div>
</div>
<div id='footer'>
December 09, 14 09:05:26 by
December 09, 14 12:47:37 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo
</a>

View File

@ -37,7 +37,7 @@
</table>
</div>
<div id='footer'>
December 09, 14 09:05:26 by
December 09, 14 12:47:37 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo
</a>

View File

@ -186,7 +186,7 @@ console.log(devices)
</div>
</div>
<div id='footer'>
December 09, 14 09:05:26 by
December 09, 14 12:47:37 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo
</a>

View File

@ -94,7 +94,7 @@ resin.errors.handle(error, shouldExit)
</div>
</div>
<div id='footer'>
December 09, 14 09:05:26 by
December 09, 14 12:47:37 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo
</a>

View File

@ -105,7 +105,7 @@ console.log(object.dataPrefix) # /opt/resin
</div>
</div>
<div id='footer'>
December 09, 14 09:05:26 by
December 09, 14 12:47:37 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo
</a>

View File

@ -57,7 +57,7 @@
</dl>
</div>
<div id='footer'>
December 09, 14 09:05:26 by
December 09, 14 12:47:37 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo
</a>

View File

@ -348,7 +348,7 @@
</div>
</div>
<div id='footer'>
December 09, 14 09:05:26 by
December 09, 14 12:47:37 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo
</a>

View File

@ -47,7 +47,7 @@
</table>
</div>
<div id='footer'>
December 09, 14 09:05:26 by
December 09, 14 12:47:37 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo
</a>

View File

@ -326,7 +326,7 @@
</div>
</div>
<div id='footer'>
December 09, 14 09:05:26 by
December 09, 14 12:47:37 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo
</a>

View File

@ -316,7 +316,7 @@
</div>
</div>
<div id='footer'>
December 09, 14 09:05:26 by
December 09, 14 12:47:37 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo
</a>

View File

@ -154,7 +154,7 @@
</div>
</div>
<div id='footer'>
December 09, 14 09:05:26 by
December 09, 14 12:47:37 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo
</a>

View File

@ -52,7 +52,7 @@
</dl>
</div>
<div id='footer'>
December 09, 14 09:05:26 by
December 09, 14 12:47:37 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo
</a>

View File

@ -156,7 +156,7 @@ console.log(result)
</div>
</div>
<div id='footer'>
December 09, 14 09:05:26 by
December 09, 14 12:47:37 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo
</a>

View File

@ -0,0 +1,178 @@
<!DOCTYPE html>
<html>
<head>
<meta charset='UTF-8'>
<title>CoffeeScript API Documentation</title>
<script src='../../../../../javascript/application.js'></script>
<script src='../../../../../javascript/search.js'></script>
<link rel='stylesheet' href='../../../../../stylesheets/application.css' type='text/css'>
</head>
<body>
<div id='base' data-path='../../../../../'></div>
<div id='header'>
<div id='menu'>
<a href='../../../../../alphabetical_index.html' title='Index'>
Index
</a>
&raquo;
<span class='title'>lib</span>
&raquo;
<span class='title'>resin</span>
&raquo;
<span class='title'>os</span>
&raquo;
<span class='title'>windows</span>
&raquo;
<span class='title'>windows.coffee</span>
</div>
</div>
<div id='content'>
<h1>
File:
windows.coffee
</h1>
<table class='box'>
<tr>
<td>Defined in:</td>
<td>lib&#47;resin&#47;os&#47;windows</td>
</tr>
</table>
<h2>Method Summary</h2>
<ul class='summary'>
<li>
<span class='signature'>
<a href='#parseWmicDiskDriveGet-'>
~
(Object)
<b>parseWmicDiskDriveGet</b><span>(output)</span>
</a>
</span>
<span class='note private title'>Private</span>
<span class='desc'>
Parse wmic diskdrive get output <pre><code>result = resin.os.windows.parseWmicDiskDriveGet(output)
for item in result console.log(&quot;#{item.id} - #{item.caption}&quot;)
</code></pre>
</span>
</li>
</ul>
<h2>Method Details</h2>
<div class='methods'>
<div class='method_details'>
<p class='signature' id='parseWmicDiskDriveGet-'>
~
(Object)
<b>parseWmicDiskDriveGet</b><span>(output)</span>
<span class='note private'>Private</span>
<br>
</p>
<div class='docstring'>
<div class='note'>
<strong>Note:</strong>
This only parses output from <code>wmic diskdrive get DeviceID, Caption</code>
</div>
<p>Parse wmic diskdrive get output</p><pre><code>result = resin.os.windows.parseWmicDiskDriveGet(output)
for item in result console.log(&quot;#{item.id} - #{item.caption}&quot;)
</code></pre>
</div>
<div class='tags'>
<h3>Parameters:</h3>
<ul class='param'>
<li>
<span class='name'>output</span>
<span class='type'>
(
<tt>String</tt>
)
</span>
&mdash;
<span class='desc'>wmic diskdrive get DeviceID, Caption output </span>
</li>
</ul>
<h3>Returns:</h3>
<ul class='return'>
<li>
<span class='type'></span>
(
<tt>Object</tt>
)
&mdash;
<span class='desc'>parsed result containing id and caption </span>
</li>
</ul>
</div>
</div>
</div>
</div>
<div id='footer'>
December 09, 14 12:47:37 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo
</a>
2.0.9
&#10034;
Press H to see the keyboard shortcuts
&#10034;
<a href='http://twitter.com/netzpirat' target='_parent'>@netzpirat</a>
&#10034;
<a href='http://twitter.com/_inossidabile' target='_parent'>@_inossidabile</a>
</div>
<iframe id='search_frame'></iframe>
<div id='fuzzySearch'>
<input type='text'>
<ol></ol>
</div>
<div id='help'>
<p>
Quickly fuzzy find classes, mixins, methods, file:
</p>
<ul>
<li>
<span>T</span>
Open fuzzy finder dialog
</li>
</ul>
<p>
Control the navigation frame:
</p>
<ul>
<li>
<span>L</span>
Toggle list view
</li>
<li>
<span>C</span>
Show class list
</li>
<li>
<span>I</span>
Show mixin list
</li>
<li>
<span>F</span>
Show file list
</li>
<li>
<span>M</span>
Show method list
</li>
<li>
<span>E</span>
Show extras list
</li>
</ul>
<p>
You can focus and blur the search input:
</p>
<ul>
<li>
<span>S</span>
Focus search input
</li>
<li>
<span>Esc</span>
Blur search input
</li>
</ul>
</div>
</body>
</html>

View File

@ -227,7 +227,7 @@ resin.server.request { method: &#39;GET&#39; url: &#39;/download&#39; p
</div>
</div>
<div id='footer'>
December 09, 14 09:05:26 by
December 09, 14 12:47:37 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo
</a>

View File

@ -77,7 +77,7 @@
</dl>
</div>
<div id='footer'>
December 09, 14 09:05:26 by
December 09, 14 12:47:37 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo
</a>

View File

@ -235,7 +235,7 @@
</div>
</div>
<div id='footer'>
December 09, 14 09:05:26 by
December 09, 14 12:47:37 by
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
Codo
</a>

View File

@ -228,6 +228,22 @@
lib&#47;resin&#47;os
</small>
</li>
<li>
<span>
windows
</span>
</li>
<ul>
<li>
<a href='file/lib/resin/os/windows/windows.coffee.html' target='main'>
windows.coffee
</a>
<small class='namespace'>
lib&#47;resin&#47;os&#47;windows
</small>
</li>
</ul>
</ul>
<li>

File diff suppressed because one or more lines are too long

View File

@ -330,6 +330,14 @@
(lib&#47;resin&#47;auth&#47;auth.coffee)
</small>
</li>
<li>
<a href='file/lib/resin/os/windows/windows.coffee.html#parseWmicDiskDriveGet-' target='main' title='parseWmicDiskDriveGet'>
~parseWmicDiskDriveGet
</a>
<small>
(lib&#47;resin&#47;os&#47;windows&#47;windows.coffee)
</small>
</li>
<li>
<a href='file/lib/resin/helpers/helpers.coffee.html#prefixObjectValuesWithPath-' target='main' title='prefixObjectValuesWithPath'>
~prefixObjectValuesWithPath
@ -338,14 +346,6 @@
(lib&#47;resin&#47;helpers&#47;helpers.coffee)
</small>
</li>
<li>
<a href='file/lib/resin/models/environment-variables.coffee.html#remove-' target='main' title='remove'>
~remove
</a>
<small>
(lib&#47;resin&#47;models&#47;environment-variables.coffee)
</small>
</li>
<li>
<a href='file/lib/resin/models/application.coffee.html#remove-' target='main' title='remove'>
~remove
@ -354,6 +354,14 @@
(lib&#47;resin&#47;models&#47;application.coffee)
</small>
</li>
<li>
<a href='file/lib/resin/models/environment-variables.coffee.html#remove-' target='main' title='remove'>
~remove
</a>
<small>
(lib&#47;resin&#47;models&#47;environment-variables.coffee)
</small>
</li>
<li>
<a href='file/lib/resin/models/device.coffee.html#remove-' target='main' title='remove'>
~remove

View File

@ -1,3 +1,5 @@
exports.windows = require('./windows/windows')
# Generate os cache name
#
# It generates an unique name for a certain instance of the os

View File

@ -1,4 +1,5 @@
_ = require('lodash')
sinon = require('sinon')
chai = require('chai')
chai.use(require('chai-string'))
expect = chai.expect

View File

@ -0,0 +1,44 @@
_ = require('lodash')
_.str = require('underscore.string')
# @nodoc
trimString = (string) ->
return string.trim()
# @nodoc
unwords = (array) ->
return _.str.join(' ', array...)
# @nodoc
parseWmicDiskDrive = (item) ->
result = _.str.clean(item)
result = _.str.words(result)
caption = _.initial(result)
caption = unwords(caption)
id = _.last(result)
return { caption, id }
# Parse wmic diskdrive get output
#
# @private
#
# @param {String} output wmic diskdrive get DeviceID, Caption output
#
# @return {Object} parsed result containing id and caption
#
# @note This only parses output from `wmic diskdrive get DeviceID, Caption`
#
# @example Parse wmic output
# result = resin.os.windows.parseWmicDiskDriveGet(output)
# for item in result
# console.log("#{item.id} - #{item.caption}")
#
exports.parseWmicDiskDriveGet = (output) ->
output = _.str.lines(output)
output = _.map(output, trimString)
output = _.reject(output, _.isEmpty)
output = _.tail(output)
return _.map(output, parseWmicDiskDrive)

View File

@ -0,0 +1,25 @@
fs = require('fs')
chai = require('chai')
expect = chai.expect
windows = require('./windows')
describe 'OS Windows:', ->
describe '#parseWmicDiskDriveGet()', ->
beforeEach ->
@wmicOutput = [
'Caption DeviceID \r\r'
'WDC WD10JPVX-75JC3T0 \\\\.\\PHYSICALDRIVE0 \r\r'
'Generic STORAGE DEVICE USB Device \\\\.\\PHYSICALDRIVE1 \r\r'
'\r\r'
''
].join('\n')
it 'should parse the output', ->
result = windows.parseWmicDiskDriveGet(@wmicOutput)
expect(result).to.deep.equal [
{ caption: 'WDC WD10JPVX-75JC3T0', id: '\\\\.\\PHYSICALDRIVE0' }
{ caption: 'Generic STORAGE DEVICE USB Device', id: '\\\\.\\PHYSICALDRIVE1' }
]