Skip to content

Commit 52dda06

Browse files
committed
Updated docs
1 parent a114325 commit 52dda06

1 file changed

Lines changed: 118 additions & 82 deletions

File tree

README.md

Lines changed: 118 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Bible.js
33

44
The Bible as a NPM module.
55

6-
## Installation
6+
# Installation
77
```sh
88
$ npm install bible.js
99
```
@@ -15,101 +15,137 @@ $ sudo npm install bible -g
1515

1616
For more information and documentation click [here](https://github.com/BibleJS/BibleApp).
1717

18-
## Methods
18+
# Methods
1919

20-
### Constructor: `new Bible (options)`
21-
Creates a new `Bible` instance.
20+
## `new Bible(options)`
21+
Creates a new `Bible` instance
2222

23-
#### Arguments
23+
### Params
24+
* **Object** *options* An object containing the following fields:
2425

25-
- `@options` object containing:
26-
- `language`: the language (currently the supported languages are Romanian (`"RO"`) and English (`"EN"`)
26+
- `language`: the langauge of the Bible instance
2727

28-
#### Example
28+
## `myBible.get(reference, callback)`
29+
This function gets a verse/chapter etc providing the `reference`
2930

30-
```js
31-
var Bible = new (require ("bible.js"))({
32-
language: "EN"
33-
})
34-
```
35-
36-
### `Bible.get (reference, callback)`
37-
This function gets the verses/chapter represented by `@reference` argument. The `@callback` function is called with an error and an array of verses (objects).
38-
39-
#### Arguments
40-
- `@reference`: a string in the following formats:
41-
e.g. Genesis 1:1 - returns one verse
42-
or Genesis 1:1,2 - returns two verses (1 and 2)
43-
or Genesis 1:1-10 - returns the verses 1 - 10
44-
or Genesis 1 - returns the whole chapter
31+
### Params:
32+
* **String** *reference* The verse reference. It can be in the following formats:
4533

46-
- `@callback`: the callback function
34+
- Genesis 1:1 - returns one verse
35+
- Genesis 1:1,2 - returns two verses (1 and 2)
36+
- Genesis 1:1-10 - returns the verses 1 - 10
37+
- Genesis 1 - returns the whole chapter
4738

48-
#### Example
39+
* **Function** *callback* The callback function
4940

50-
```js
51-
Bible.get("Psalm 1:1-6", function (err, data) {
52-
/* do something */
53-
});
54-
```
41+
### Return:
42+
* **Bible** The Bible instance (self)
5543

56-
### `Bible.search (query, callback)`
57-
The method receives a string or a regular expression in the first argument (`@query`). The verses that match the query are fetched.
58-
**NOTE**: right now only searching in json files is implemented.
59-
60-
#### Arguments
61-
- `@query`: string or regular expression
62-
- `@callback`: the callback function
63-
64-
#### Example
65-
66-
```js
67-
Bible.search(/david/i, function (err, verses) {
68-
/* do something with the verses that contain "david" */
69-
});
70-
```
44+
## `search(query, callback)`
45+
This function gets the verses that match to the regular expression
46+
provided.
7147

72-
## Example
73-
```js
74-
// dependencies
75-
var Bible = new (require ("bible.js"))({
76-
language: "EN"
77-
})
48+
### Params:
49+
* **String|RegExp** *query* The string/regular expression that matches the searched verses.
50+
* **Function** *callback* The callback function
7851

79-
// the Bible reference
80-
, reference = "Psalm 1:1-6"
81-
;
52+
### Return:
53+
* **Bible** The Bible instance (self)
8254

83-
// output
84-
console.log(reference);
85-
console.log("-------------");
55+
## `init(config, callback)`
56+
Inits BibleJS module by downloading versions set in configuration
57+
This method should be called when the application is started.
8658

87-
// get verse
88-
Bible.get(reference, function (err, data) {
59+
### Params:
60+
* **Object** *config* BibleJS configuration object. It must contain `versions` field as noted in documentation.
61+
* **Function** *callback* The callback function
8962

90-
// we've get the verses
91-
if (data && data.length) {
63+
### Return:
64+
* **Bible** Bible constructor
9265

93-
// each verse
94-
for (var i in data) {
9566

96-
// output
97-
console.log(data[i].verse + " | " + data[i].text);
67+
# Example
68+
```js
69+
// Dependencies
70+
var Bible = require("../index");
71+
72+
// Init Bible
73+
Bible.init({
74+
versions: {
75+
en: {
76+
source: "https://github.com/BibleJS/bible-english"
77+
, version: "master"
78+
, language: "en"
79+
},
80+
ro: {
81+
source: "https://github.com/BibleJS/bible-romanian"
82+
, version: "master"
83+
, language: "ro"
9884
}
99-
100-
// output
101-
console.log("-------------\n");
10285
}
86+
}, function (err) {
87+
if (err) { throw err; }
88+
89+
// Create Bible instances
90+
var enBible = new Bible({ language: "en" })
91+
, roBible = new Bible({ language: "ro" })
92+
, references = {
93+
en: "Psalm 1:1-6"
94+
, ro: "Psalmi 1:1-6"
95+
}
96+
, responseHandler = function (lang) {
97+
return function (err, data) {
98+
if (err) { throw err; }
99+
100+
// Output
101+
if (lang) {
102+
console.log(references[lang]);
103+
}
104+
console.log("-------------");
105+
106+
if (data && data.length) {
107+
108+
// each verse
109+
for (var i in data) {
110+
console.log(data[i].verse + " | " + data[i].text);
111+
}
112+
113+
console.log("-------------\n");
114+
}
115+
}
116+
}
117+
;
118+
119+
// Get verses
120+
enBible.get(references.en, responseHandler("en"));
121+
roBible.get(references.ro, responseHandler("ro"));
122+
123+
// Search
124+
roBible.search("/meroza/gi", responseHandler());
103125
});
104126
```
105127

106-
### Testing
128+
## Testing
107129

108130
```sh
109131
$ npm test
110132

111-
> bible.js@0.1.1 test /home/.../bible.js
112-
> node test/english
133+
> bible.js@1.0.0 test /home/ionicabizau/Documents/BibleApp/node_modules/bible.js
134+
> node test/index
135+
136+
Psalmi 1:1-6
137+
-------------
138+
1 | Ferice de omul care nu se duce la sfatul celor răi, nu se opreşte pe calea celor păcătoşi şi nu se aşază pe scaunul celor batjocoritori!
139+
2 | Ci îşi găseşte plăcerea în Legea Domnului, şi zi şi noapte cugetă la Legea Lui!
140+
3 | El este ca un pom sădit lângă un izvor de apă, care îşi dă rodul la vremea lui şi ale cărui frunze nu se veştejesc: tot ce începe, duce la bun sfârşit.
141+
4 | Nu tot aşa este cu cei răi: ci ei sunt ca pleava pe care o spulberă vântul.
142+
5 | De aceea cei răi nu pot ţine capul sus în ziua judecăţii, nici păcătoşii în adunarea celor neprihăniţi.
143+
6 | Căci Domnul cunoaşte calea celor neprihăniţi, dar calea păcătoşilor duce la pieire.
144+
-------------
145+
146+
-------------
147+
23 | Blestemaţi pe Meroza, a zis Îngerul Domnului, blestemaţi, blestemaţi pe locuitorii lui; căci n-au venit în ajutorul Domnului, în ajutorul Domnului, printre oamenii viteji.
148+
-------------
113149

114150
Psalm 1:1-6
115151
-------------
@@ -122,37 +158,37 @@ Psalm 1:1-6
122158
-------------
123159
```
124160

125-
## Changelog
161+
# Changelog
126162

127-
### `1.0.0`
163+
## `1.0.0`
128164
- First stable release with a lot of improvements
129165
- Support custom language submodules (everyone can build one) via `git` and `npm`
130166

131-
### `v0.1.7`
167+
## `v0.1.7`
132168
- Added `search` method
133169
- Removed `mongodb` as dependency
134170

135-
### `v0.1.6`
171+
## `v0.1.6`
136172
- Updated GitHub urls and email address
137173

138-
### `v0.1.5`
174+
## `v0.1.5`
139175
- Convert to uppercase the language field
140176

141-
### `v0.1.4`
177+
## `v0.1.4`
142178
- Get all verses from a chapter (bug when language is RO).
143179

144-
### `v0.1.3`
180+
## `v0.1.3`
145181
- Removed `_books` field.
146182
- Use the new version of [Bible Data](https://github.com/BibleJS/Versions)
147183

148-
### `v0.1.2`
184+
## `v0.1.2`
149185
- added English support using providers
150186

151-
### `v0.1.1`
187+
## `v0.1.1`
152188
- use Bible data v0.1.1
153189

154-
### `v0.1.0`
190+
## `v0.1.0`
155191
- initial release
156192

157-
## License
193+
# License
158194
See LICENSE file.

0 commit comments

Comments
 (0)