httpsnippet
Advanced tools
Comparing version 1.0.0-beta.2 to 1.0.0-beta.3
{ | ||
"version": "1.0.0-beta.2", | ||
"version": "1.0.0-beta.3", | ||
"name": "httpsnippet", | ||
@@ -4,0 +4,0 @@ "description": "HTTP Request snippet generator for *most* languages", |
@@ -90,8 +90,9 @@ 'use strict'; | ||
} | ||
// find the first possibel target | ||
var firstTarget = Object.keys(family).pop(); | ||
// find the first default target | ||
var defaultTarget = family._familyInfo().default; | ||
// shorthand | ||
if (!target || typeof target === 'object') { | ||
target = firstTarget; | ||
target = defaultTarget; | ||
} | ||
@@ -103,3 +104,3 @@ | ||
if (typeof family[target] !== 'function') { | ||
target = firstTarget; | ||
target = defaultTarget; | ||
} | ||
@@ -124,10 +125,59 @@ | ||
module.exports._familyInfo = function (family) { | ||
if (targets[family] && targets[family]._familyInfo) { | ||
return targets[family]._familyInfo(); | ||
} | ||
return false; | ||
}; | ||
module.exports.info = function (family, target) { | ||
var result = HTTPSnippet.prototype._matchTarget.call(null, family, target); | ||
if (!targets[family]) { | ||
return false; | ||
} | ||
if (result) { | ||
return result.info(); | ||
if (typeof targets[family] === 'function') { | ||
return targets[family].info(); | ||
} | ||
return false; | ||
// get all info for all family members | ||
if (!target && typeof targets[family] === 'object') { | ||
var results = { | ||
family: family | ||
}; | ||
results.members = Object.keys(targets[family]) | ||
.filter(function (key) { | ||
return key !== '_familyInfo'; | ||
}) | ||
.map(function (target) { | ||
var info = targets[family][target].info(); | ||
delete info.family; | ||
return info; | ||
}); | ||
return results; | ||
} | ||
if (typeof targets[family] === 'object' && typeof targets[family][target] === 'function') { | ||
return targets[family][target].info(); | ||
} | ||
}; | ||
module.exports.extname = function (family, target) { | ||
if (!targets[family]) { | ||
return ''; | ||
} | ||
if (typeof targets[family] === 'function') { | ||
return targets[family].info().extname; | ||
} | ||
// get all info for all family members | ||
if (!target && typeof targets[family] === 'object') { | ||
return targets[family]._familyInfo().extname; | ||
} | ||
}; |
@@ -48,7 +48,7 @@ 'use strict'; | ||
key: 'curl', | ||
ext: '.sh', | ||
title: 'cURL', | ||
link: 'http://curl.haxx.se/', | ||
description: 'curl is a command line tool and library for transferring data with URL syntax' | ||
description: 'curl is a command line tool and library for transferring data with URL syntax', | ||
extname: '.sh' | ||
}; | ||
}; |
@@ -111,7 +111,7 @@ 'use strict'; | ||
key: 'httpie', | ||
ext: '.sh', | ||
title: 'HTTPie', | ||
link: 'http://httpie.org/', | ||
description: 'a CLI, cURL-like tool for humans' | ||
description: 'a CLI, cURL-like tool for humans', | ||
extname: '.sh' | ||
}; | ||
}; |
'use strict'; | ||
module.exports = require('requireindex')(__dirname); | ||
module.exports._familyInfo = function () { | ||
return { | ||
key: 'node', | ||
title: 'Node.JS', | ||
extname: '.js', | ||
default: 'native' | ||
}; | ||
}; |
@@ -70,4 +70,3 @@ 'use strict'; | ||
key: 'native', | ||
ext: '.js', | ||
title: 'Node.JS', | ||
title: 'HTTP', | ||
link: 'http://nodejs.org/api/http.html#http_http_request_options_callback', | ||
@@ -74,0 +73,0 @@ description: 'Node.js native HTTP interface' |
@@ -109,4 +109,3 @@ 'use strict'; | ||
key: 'curl', | ||
ext: '.php', | ||
title: 'PHP', | ||
title: 'cURL', | ||
link: 'http://php.net/manual/en/book.curl.php', | ||
@@ -113,0 +112,0 @@ description: 'PHP with libcurl' |
'use strict'; | ||
module.exports = require('requireindex')(__dirname); | ||
module.exports._familyInfo = function () { | ||
return { | ||
key: 'php', | ||
title: 'PHP', | ||
extname: '.php', | ||
default: 'curl' | ||
}; | ||
}; |
@@ -51,7 +51,7 @@ 'use strict'; | ||
key: 'wget', | ||
ext: '.sh', | ||
title: 'Wget', | ||
link: 'https://www.gnu.org/software/wget/', | ||
description: 'a free software package for retrieving files using HTTP, HTTPS' | ||
description: 'a free software package for retrieving files using HTTP, HTTPS', | ||
extname: '.sh' | ||
}; | ||
}; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
35441
17
546