Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
shinnn committed Sep 25, 2015
0 parents commit 99d2f9a
Show file tree
Hide file tree
Showing 11 changed files with 261 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
@@ -0,0 +1,12 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false
1 change: 1 addition & 0 deletions .gitattributes
@@ -0,0 +1 @@
* text=auto
2 changes: 2 additions & 0 deletions .gitignore
@@ -0,0 +1,2 @@
coverage
node_modules
12 changes: 12 additions & 0 deletions .travis.yml
@@ -0,0 +1,12 @@
git:
depth: 1
branches:
except: /^v\d/
language: node_js
node_js: stable
after_script:
- npm install istanbul-coveralls
- npm run-script coverage
- node node_modules/.bin/istanbul-coveralls
notifications:
email: false
24 changes: 24 additions & 0 deletions LICENSE
@@ -0,0 +1,24 @@
This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.

In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

For more information, please refer to <http://unlicense.org/>
66 changes: 66 additions & 0 deletions README.md
@@ -0,0 +1,66 @@
# outdated-pod-regex

[![NPM version](https://img.shields.io/npm/v/outdated-pod-regex.svg)](https://www.npmjs.com/package/outdated-pod-regex)
[![Build Status](https://travis-ci.org/shinnn/outdated-pod-regex.svg?branch=master)](https://travis-ci.org/shinnn/outdated-pod-regex)
[![Coverage Status](https://img.shields.io/coveralls/shinnn/outdated-pod-regex.svg)](https://coveralls.io/r/shinnn/outdated-pod-regex)
[![devDependency Status](https://david-dm.org/shinnn/outdated-pod-regex/dev-status.svg)](https://david-dm.org/shinnn/outdated-pod-regex#info=devDependencies)

Create a [regular expression](http://www.ecma-international.org/ecma-262/5.1/#sec-15.10) object that matches the outdated [Pod](https://cocoapods.org/) list generated with [`pod outdated`](https://guides.cocoapods.org/terminal/commands.html#pod_outdated) command

```javascript
const stdout = `
- CrittercismSDK 5.3.0 -> 5.3.0 (latest version 5.4.0)
- GCDWebServer 3.2.5 -> 3.2.7 (latest version 3.2.7)
`;

stdout.match(outdatedPodRegex());
//=> ['- CrittercismSDK 5.3.0 -> 5.3.0 (latest version 5.4.0)', '- GCDWebServer 3.2.5 -> 3.2.7 (latest version 3.2.7)']
```

## Installation

### package managers

#### [npm](https://www.npmjs.com/)

```
npm install outdated-pod-regex
```

#### [bower](http://bower.io/)

```
bower install outdated-pod-regex
```

### Standalone

[Download the script file directly.](https://raw.githubusercontent.com/shinnn/outdated-pod-regex/master/browser.js)

## API

### outdatedPodRegex()

Return: [`RegExp`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp) instance with `g` and `m` flags

```javascript
const stdout = `
- CrittercismSDK 5.3.0 -> 5.3.0 (latest version 5.4.0)
- GCDWebServer 3.2.5 -> 3.2.7 (latest version 3.2.7)
`;

const regex = outdatedPodRegex();

regex.exec(stdout);
//=> ['- CrittercismSDK 5.3.0 -> 5.3.0 (latest version 5.4.0)', 'CrittercismSDK', '5.3.0', '5.3.0', '5.4.0']

regex.exec(stdout);
//=> ['- GCDWebServer 3.2.5 -> 3.2.7 (latest version 3.2.7)', 'GCDWebServer', '3.2.5', '3.2.7', '3.2.7']

regex.exec(stdout);
//=> null
```

## License

[The Unlicense](./LICENSE)
33 changes: 33 additions & 0 deletions bower.json
@@ -0,0 +1,33 @@
{
"name": "outdated-pod-regex",
"version": "1.0.0",
"description": "Create a regex that matches the Pod list generated with `pod outdated`",
"keywords": [
"cocoapods",
"pod",
"pods",
"outdated",
"list",
"regex",
"regexp",
"match",
"detect"
],
"main": "browser.js",
"moduleType": "globals",
"homepage": "https://github.com/shinnn/outdated-pod-regex",
"repository": {
"type": "git",
"url": "git://github.com/shinnn/outdated-pod-regex.git"
},
"authors": [
"Shinnosuke Watanabe (https://github.com/shinnn)"
],
"license": "Unlicense",
"ignore": [
"**/.*",
"*.js",
"*.json",
"node_modules"
]
}
5 changes: 5 additions & 0 deletions browser.js
@@ -0,0 +1,5 @@
window.outdatedPodRegex = function outdatedPodRegex() {
'use strict';
// https://github.com/CocoaPods/Core/blob/0.39.0/lib/cocoapods-core/specification/linter.rb#L187-L202
return /^- ([^\.\s\/][^\s\/]*) (\(unused\)|\d[\d.]+) -> (\(unused\)|\d[\d.]+) \(latest version (.+)\)$/gm;
};
5 changes: 5 additions & 0 deletions index.js
@@ -0,0 +1,5 @@
module.exports = function outdatedPodRegex() {
'use strict';
// https://github.com/CocoaPods/Core/blob/0.39.0/lib/cocoapods-core/specification/linter.rb#L187-L202
return /^- ([^\.\s\/][^\s\/]*) (\(unused\)|\d[\d.]+) -> (\(unused\)|\d[\d.]+) \(latest version (.+)\)$/gm;
};
36 changes: 36 additions & 0 deletions package.json
@@ -0,0 +1,36 @@
{
"name": "outdated-pod-regex",
"version": "1.0.0",
"description": "Create a regex that matches the Pod list generated with `pod outdated`",
"repository": "shinnn/outdated-pod-regex",
"author": "Shinnosuke Watanabe (https://github.com/shinnn)",
"scripts": {
"pretest": "eslint --config @shinnn/node --env browser browser.js index.js test.js",
"test": "node --strong_mode --throw-deprecation --track-heap-objects test.js | tap-spec",
"coverage": "node --strong_mode node_modules/.bin/istanbul cover test.js"
},
"license": "Unlicense",
"files": [
"index.js"
],
"keywords": [
"cocoapods",
"pod",
"pods",
"outdated",
"list",
"regex",
"regexp",
"match",
"detect",
"client-side",
"browser"
],
"devDependencies": {
"@shinnn/eslint-config-node": "^1.0.1",
"eslint": "^1.7.3",
"istanbul": "^0.4.0",
"tap-spec": "^4.1.0",
"tape": "^4.2.2"
}
}
65 changes: 65 additions & 0 deletions test.js
@@ -0,0 +1,65 @@
'use strong';

const test = require('tape');

const fixture = `
Updating spec repo \`master\`
Updating spec repo \`outdated-pod-regex\`
Analyzing dependencies
The following pod updates are available:
- Foo 4.12.1 -> 4.12.1 (latest version 4.15.0)
- bax+qux 2.8.3 -> (unused) (latest version 2.9.0)
`;

function runTest(description, outdatedPodRegex) {
test(description, t => {
t.plan(7);

t.equal(outdatedPodRegex.name, 'outdatedPodRegex', 'should have a function name.');

const regex = outdatedPodRegex();

t.deepEqual(
Array.from(regex.exec(fixture)),
['- Foo 4.12.1 -> 4.12.1 (latest version 4.15.0)', 'Foo', '4.12.1', '4.12.1', '4.15.0'],
'should return a regex that detects outdated Pods from `pod outdated`.'
);

t.deepEqual(
Array.from(regex.exec(fixture)),
['- bax+qux 2.8.3 -> (unused) (latest version 2.9.0)', 'bax+qux', '2.8.3', '(unused)', '2.9.0'],
'should return a regex with "g" and "m" flags.'
);

t.strictEqual(
outdatedPodRegex().exec('- .foo 2.8.3 -> 4.12.1 (latest version 2.9.0)'),
null,
'should return a regex that doesn\'t match the line with a dot-first pod name.'
);

t.strictEqual(
outdatedPodRegex().exec('- f/oo 2.8.3 -> 4.12.1 (latest version 2.9.0)'),
null,
'should return a regex that doesn\'t match the line with a pod name including `/`.'
);

t.strictEqual(
outdatedPodRegex().exec('- f oo 2.8.3 -> 4.12.1 (latest version 2.9.0)'),
null,
'should return a regex that doesn\'t match the line with a pod name including white spaces.'
);

t.strictEqual(
outdatedPodRegex().exec('- foo 2. 8.3 -> 4.12.1 (latest version 2.9.0)'),
null,
'should return a regex that doesn\'t match the line with an invalid version number.'
);
});
}

runTest('require(\'outdated-pod-regex\')', require('.'));

global.window = {};
require(`./${require('./bower.json').main}`);

runTest('window.outdatedPodRegex', global.window.outdatedPodRegex);

0 comments on commit 99d2f9a

Please sign in to comment.