-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit b6e9e8c
Showing
11 changed files
with
231 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# http://editorconfig.org | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
language: node_js | ||
node_js: | ||
- "0.12" | ||
- "0.10" | ||
- "iojs" | ||
sudo: false | ||
cache: | ||
directories: | ||
- node_modules | ||
notifications: | ||
email: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
'use strict'; | ||
|
||
module.exports = function (grunt) { | ||
|
||
grunt.initConfig({ | ||
mochaTest: { | ||
test: { | ||
options: { | ||
reporter: 'spec', | ||
require: 'coffee-script' | ||
}, | ||
src: ['test/**/*.coffee'] | ||
} | ||
}, | ||
release: { | ||
options: { | ||
tagName: 'v<%= version %>', | ||
commitMessage: 'Prepared to release <%= version %>.' | ||
} | ||
}, | ||
watch: { | ||
files: ['Gruntfile.js', 'src/**/*.coffee', 'test/**/*.coffee'], | ||
tasks: ['test'] | ||
} | ||
}); | ||
|
||
// load all grunt tasks | ||
require('matchdep').filterDev(['grunt-*', '!grunt-cli']).forEach(grunt.loadNpmTasks); | ||
|
||
grunt.registerTask('test', ['mochaTest']); | ||
grunt.registerTask('test:watch', ['watch']); | ||
grunt.registerTask('default', ['test']); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# hubot-esv | ||
|
||
Simple ESV passage lookup based on api.esv.org. | ||
|
||
See [`src/esv.coffee`](src/esv.coffee) for full documentation. | ||
|
||
## Installation | ||
|
||
In hubot project repo, run: | ||
|
||
`npm install hubot-esv --save` | ||
|
||
Then add **hubot-esv** to your `external-scripts.json`: | ||
|
||
```json | ||
[ | ||
"hubot-esv" | ||
] | ||
``` | ||
|
||
## Sample Interaction | ||
|
||
``` | ||
user1>> hubot hello | ||
hubot>> hello! | ||
``` | ||
|
||
## NPM Module | ||
|
||
https://www.npmjs.com/package/hubot-esv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
fs = require 'fs' | ||
path = require 'path' | ||
|
||
module.exports = (robot, scripts) -> | ||
scriptsPath = path.resolve(__dirname, 'src') | ||
if fs.existsSync scriptsPath | ||
for script in fs.readdirSync(scriptsPath).sort() | ||
if scripts? and '*' not in scripts | ||
robot.loadFile(scriptsPath, script) if script in scripts | ||
else | ||
robot.loadFile(scriptsPath, script) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
{ | ||
"name": "hubot-esv", | ||
"description": "Simple ESV passage lookup based on api.esv.org", | ||
"version": "0.0.1", | ||
"author": "Scott A. Williams <[email protected]>", | ||
"license": "MIT", | ||
|
||
"keywords": "hubot, hubot-scripts, bible, esv", | ||
|
||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/hubot-scripts/hubot-esv.git" | ||
}, | ||
|
||
"bugs": { | ||
"url": "https://github.com/hubot-scripts/hubot-esv/issues" | ||
}, | ||
|
||
"dependencies": { | ||
}, | ||
|
||
"peerDependencies": { | ||
"hubot": "2.x" | ||
}, | ||
|
||
"devDependencies": { | ||
"hubot-test-helper": "^1.3.0", | ||
"chai": "^2.1.1", | ||
"coffee-script": "1.6.3", | ||
"grunt": "^0.4.5", | ||
"grunt-cli": "^0.1.13", | ||
"grunt-contrib-watch": "~0.6.1", | ||
"grunt-mocha-test": "~0.12.7", | ||
"grunt-release": "~0.11.0", | ||
"hubot": "2.x", | ||
"matchdep": "~0.3.0", | ||
"mocha": "^2.1.0", | ||
"sinon": "^1.13.0", | ||
"sinon-chai": "^2.7.0" | ||
}, | ||
|
||
"main": "index.coffee", | ||
|
||
"scripts": { | ||
"test": "grunt test" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/bash | ||
|
||
# Make sure everything is development forever | ||
export NODE_ENV=development | ||
|
||
# Load environment specific environment variables | ||
if [ -f .env ]; then | ||
source .env | ||
fi | ||
|
||
if [ -f .env.${NODE_ENV} ]; then | ||
source .env.${NODE_ENV} | ||
fi | ||
|
||
npm install | ||
|
||
# Make sure coffee and mocha are on the path | ||
export PATH="node_modules/.bin:$PATH" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/bash | ||
|
||
# bootstrap environment | ||
source script/bootstrap | ||
|
||
mocha --compilers coffee:coffee-script |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Description: | ||
# Simple ESV passage lookup based on esv-api.org | ||
# | ||
# Commands: | ||
# hubot esv <passage> | ||
# | ||
# Configuration: | ||
# HUBOT_ESV_API_KEY (Authorization token header value without "Token") | ||
# | ||
# Notes: | ||
# An API key from api.esv.org is required. | ||
# Obtain one from https://api.esv.org/account/create-application/ | ||
# See https://api.esv.org/docs/passage-text/#required-parameters for syntax | ||
# | ||
# Author: | ||
# Scott A. Williams <[email protected]> | ||
|
||
module.exports = (robot) -> | ||
robot.respond /esv\s+(.*)/i, (msg) -> | ||
if not msg.match[1] | ||
msg.send "Please provide a Bible passage for lookup" | ||
return | ||
else | ||
passage = msg.match[1] | ||
url = "https://api.esv.org/v3/passage/text/?q=" + passage + "&output-format=plain-text&include-footnotes=false&include-passage-horizontal-lines=false&include-heading-horizontal-lines=false&include-headings=false&include-subheadings=false&include-footnotes=false" | ||
robot.http(url) | ||
.header("Authorization","Token #{process.env.HUBOT_ESV_API_KEY}") | ||
.get() (err, res, body) -> | ||
if err | ||
msg.send "We have a problem: #{err}" | ||
return | ||
else | ||
data = JSON.parse body | ||
msg.send passage for passage in data.passages | ||
return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
Helper = require('hubot-test-helper') | ||
chai = require 'chai' | ||
|
||
expect = chai.expect | ||
|
||
helper = new Helper('../src/esv.coffee') | ||
|
||
describe 'esv', -> | ||
beforeEach -> | ||
@room = helper.createRoom() | ||
|
||
afterEach -> | ||
@room.destroy() | ||
|
||
it 'responds to hello', -> | ||
@room.user.say('alice', '@hubot hello').then => | ||
expect(@room.messages).to.eql [ | ||
['alice', '@hubot hello'] | ||
['hubot', '@alice hello!'] | ||
] | ||
|
||
it 'hears orly', -> | ||
@room.user.say('bob', 'just wanted to say orly').then => | ||
expect(@room.messages).to.eql [ | ||
['bob', 'just wanted to say orly'] | ||
['hubot', 'yarly'] | ||
] |