Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update sanctuary-scripts to version 1.5.0 #5

Merged
merged 1 commit into from
May 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,19 @@
"extends": ["./node_modules/sanctuary-style/eslint-es3.json"],
"env": {
"node": true
}
},
"overrides": [
{
"files": ["*.md"],
"plugins": ["markdown"],
"env": {"es6": true},
"globals": {"checkPermission": false, "findRoles": false},
"rules": {
"strict": ["off"],
"no-extra-semi": ["off"],
"semi-style": ["off"],
"semi": ["off"]
}
}
]
}
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
[![Dependencies](https://david-dm.org/Avaq/permissionary.svg)](https://david-dm.org/Avaq/permissionary)
[![Build Status](https://travis-ci.org/Avaq/permissionary.svg?branch=master)](https://travis-ci.org/Avaq/permissionary)
[![Code Coverage](https://codecov.io/gh/Avaq/permissionary/branch/master/graph/badge.svg)](https://codecov.io/gh/Avaq/permissionary)
[![Greenkeeper badge](https://badges.greenkeeper.io/Avaq/permissionary.svg)](https://greenkeeper.io/)

Tiny and framework-agnostic role-based permission management using
a model of *composition* over inheritance.
Expand Down Expand Up @@ -40,7 +41,7 @@ assign both roles to that user.

## API

<h4 name="checkPermission"><code><a href="https://github.com/Avaq/permissionary/blob/v0.1.0/index.js#L49">checkPermission :: StrMap (Array String) -⁠> Array String -⁠> String -⁠> Boolean</a></code></h4>
#### <a name="checkPermission" href="https://github.com/Avaq/permissionary/blob/v0.0.0/index.js#L50">`checkPermission :: StrMap (Array String) -⁠> Array String -⁠> String -⁠> Boolean`</a>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happened to the version number? 😱

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh darn it.. I committed the README I was generating locally to identify the issue. I should be more careful and less hurried. I will push a fix to master as if running sanctuary-release. >.<

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I'll just release a patch for consistency.


A [curried][5] function that takes three arguments and returns a Boolean:

Expand Down Expand Up @@ -85,7 +86,7 @@ canAlice('users.create');
true
```

<h4 name="findRoles"><code><a href="https://github.com/Avaq/permissionary/blob/v0.1.0/index.js#L112">findRoles :: StrMap (Array String) -⁠> String -⁠> Array String</a></code></h4>
#### <a name="findRoles" href="https://github.com/Avaq/permissionary/blob/v0.0.0/index.js#L113">`findRoles :: StrMap (Array String) -⁠> String -⁠> Array String`</a>

A [curried][5] function that takes two arguments and returns an Array
of role names:
Expand Down
19 changes: 10 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
//.
//. ## Usage
//.
//. <!-- eslint-disable no-unused-vars -->
//. ```js
//. var {checkPermission, findRoles} = require('permissionary');
//. ```
Expand Down Expand Up @@ -69,26 +70,26 @@ var hasProp = Object.prototype.hasOwnProperty;
//. > var createVerifier = checkPermission({
//. . 'content-reader': ['content.read', 'images.read'],
//. . 'content-writer': ['content.write', 'images.upload'],
//. . 'superadmin': ['*']
//. . });
//. . 'superadmin': ['*']
//. . })
//.
//. // Let's say our user Bob is a content-reader, and also a content-writer.
//. > var canBob = createVerifier(['content-reader', 'content-writer']);
//. > var canBob = createVerifier(['content-reader', 'content-writer'])
//.
//. // And Alice is an administrator.
//. > var canAlice = createVerifier(['superadmin']);
//. > var canAlice = createVerifier(['superadmin'])
//.
//. // Bob has this permission through his content-reader role.
//. > canBob('content.read');
//. > canBob('content.read')
//. true
//.
//. // Bob does not have this permission.
//. > canBob('users.create');
//. > canBob('users.create')
//. false
//.
//. // Alice, however, does. She has all permissions (even the ones
//. // we haven't thought of yet).
//. canAlice('users.create');
//. canAlice('users.create')
//. true
//. ```
function checkPermission(grants, roles, permission) {
Expand Down Expand Up @@ -126,8 +127,8 @@ function checkPermission(grants, roles, permission) {
//. > var getRequiredRoles = findRoles({
//. . 'content-reader': ['content.read', 'images.read'],
//. . 'content-writer': ['content.write', 'images.upload'],
//. . 'superadmin': ['*']
//. . });
//. . 'superadmin': ['*']
//. . })
//.
//. > getRequiredRoles('content.read')
//. ['content-reader', 'superadmin']
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@
},
"devDependencies": {
"codecov": "^3.0.0",
"sanctuary-scripts": "^1.0.1"
"sanctuary-scripts": "^1.5.0"
}
}