1 | <!DOCTYPE html>
|
2 | <html lang="en">
|
3 | <head>
|
4 | <meta charset="utf-8">
|
5 | <title>JSDoc: Index</title>
|
6 |
|
7 | <script src="scripts/prettify/prettify.js"> </script>
|
8 | <script src="scripts/prettify/lang-css.js"> </script>
|
9 | |
10 |
|
11 |
|
12 | <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
|
13 | <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
|
14 | </head>
|
15 |
|
16 | <body>
|
17 |
|
18 | <div id="main">
|
19 |
|
20 | <h1 class="page-title">Index</h1>
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 | <h3> </h3>
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 | <section>
|
44 | <article><h1 id="node-goldwasher-schedule">node-goldwasher-schedule</h1>
|
45 | <p><a href="https://www.npmjs.org/package/goldwasher-schedule"><img src="http://img.shields.io/npm/v/goldwasher-schedule.svg" alt="npm version"></a>
|
46 | <a href="https://travis-ci.org/alexlangberg/node-goldwasher-schedule"><img src="http://img.shields.io/travis/alexlangberg/node-goldwasher-schedule.svg" alt="Build Status"></a>
|
47 | <a href="https://coveralls.io/r/alexlangberg/node-goldwasher-schedule?branch=master"><img src="http://img.shields.io/coveralls/alexlangberg/node-goldwasher-schedule.svg" alt="Coverage Status"></a>
|
48 | <a href="https://codeclimate.com/github/alexlangberg/node-goldwasher-schedule"><img src="http://img.shields.io/codeclimate/github/alexlangberg/node-goldwasher-schedule.svg" alt="Code Climate"></a></p>
|
49 | <p><a href="https://david-dm.org/alexlangberg/node-goldwasher-schedule"><img src="https://david-dm.org/alexlangberg/node-goldwasher-schedule.svg" alt="Dependency Status"></a>
|
50 | <a href="https://david-dm.org/alexlangberg/node-goldwasher-schedule#info=devDependencies"><img src="https://david-dm.org/alexlangberg/node-goldwasher-schedule/dev-status.svg" alt="devDependency Status"></a>
|
51 | <a href="https://david-dm.org/alexlangberg/node-goldwasher-schedule#info=peerDependencies"><img src="https://david-dm.org/alexlangberg/node-goldwasher-schedule/peer-status.svg" alt="peerDependency Status"></a></p>
|
52 | <p>Plugin for <a href="https://www.npmjs.org/package/goldwasher">goldwasher</a>, using <a href="https://www.npmjs.org/package/node-schedule">node-schedule</a> to schedule <a href="https://www.npmjs.org/package/goldwasher-needle">goldwasher-needle</a> requests at time intervals. Requires <a href="https://www.npmjs.org/package/goldwasher">goldwasher</a> to work.</p>
|
53 | <h2 id="installation">Installation</h2>
|
54 | <pre><code>npm install goldwasher-schedule
|
55 | </code></pre><h2 id="usage">Usage</h2>
|
56 | <pre><code class="lang-javascript">var goldwasher = require('goldwasher-schedule');
|
57 | var gs = goldwasher(targets, options);
|
58 | gs.on('result', function(results) {
|
59 | console.log(results);
|
60 | });
|
61 | gs.start();
|
62 | gs.stop();
|
63 | </code></pre>
|
64 | <h2 id="parameters">Parameters</h2>
|
65 | <h3 id="targets">Targets</h3>
|
66 | <p>The first parameter required by the setup function is an array of targets. An example:</p>
|
67 | <pre><code class="lang-javascript">[
|
68 | {
|
69 | url: 'https://github.com',
|
70 | rule: { second: [15, 35, 55] },
|
71 | goldwasher: {
|
72 | selector: 'h1'
|
73 | }
|
74 | }
|
75 | ]
|
76 | </code></pre>
|
77 | <p><code>url</code> is the only required parameter.
|
78 | <code>rule</code> is the schedule rule for <a href="https://www.npmjs.org/package/node-schedule">node-schedule</a>. In this case, 3 times a minute when second equals any of the three values (defaults to <code>second: 1</code>, e.g. once a minute).
|
79 | <code>goldwasher</code> is an object of custom <a href="https://www.npmjs.org/package/goldwasher">goldwasher</a> options for this target.</p>
|
80 | <p>Additionally, all other options used by <a href="https://www.npmjs.org/package/goldwasher-needle">goldwasher-needle</a> can be passed along, such as <code>needle</code>, <code>goldwasherNeedle</code> and <code>retry</code>. Have a look at their respective doc pages for <a href="https://www.npmjs.org/package/goldwasher">goldwasher</a>, <a href="https://www.npmjs.org/package/needle">needle</a> and <a href="https://www.npmjs.org/package/retry">retry</a> for options available.</p>
|
81 | <p>If no other options than <code>url</code> are set in the target, the defaults provided by the options parameter, explained below, will be used.</p>
|
82 | <h3 id="options">Options</h3>
|
83 | <p>Options can be optionally passed in as the second parameter. It can contain the default values for targets. For instance:</p>
|
84 | <pre><code class="lang-javascript">var options = {
|
85 | rule: { second: 10 },
|
86 | goldwasher: {
|
87 | selector: 'h1'
|
88 | },
|
89 | needle: {
|
90 | follow_max: 20
|
91 | },
|
92 | retry: {
|
93 | retries: 3
|
94 | }
|
95 | }
|
96 | </code></pre>
|
97 | <p>These options will be applied to all targets that do not explicitly define them themselves. Note that if no rule is provided, it defaults to <code>second: 1</code>, e.g. once a minute.</p>
|
98 | <h3 id="events">events</h3>
|
99 | <p>This module is an event emitter, that will emit events on start, stop, run, end and results. The results event will emit:</p>
|
100 | <ol>
|
101 | <li><code>results</code> - the results from goldwasher.</li>
|
102 | <li><code>options</code> - the options (and target) the results have been collected with.</li>
|
103 | <li><code>response</code> - the response from goldwasher-needle.</li>
|
104 | <li><code>body</code> - the raw body from goldwasher-needle.</li>
|
105 | </ol>
|
106 | <h2 id="example">Example</h2>
|
107 | <pre><code class="lang-javascript">var gs = require('goldwasher-schedule');
|
108 |
|
109 | // declare google.com a target
|
110 | var targets = [
|
111 | {
|
112 | url: 'https://google.com'
|
113 | }
|
114 | ];
|
115 |
|
116 | // set up the schedule
|
117 | gs(targets).start();
|
118 |
|
119 | // receive the results
|
120 | gs.on('result', function(results) {
|
121 | console.log(results);
|
122 | });
|
123 | </code></pre>
|
124 | <h2 id="advanced-example">Advanced example</h2>
|
125 | <pre><code class="lang-javascript">var goldwasher = require('goldwasher-schedule');
|
126 |
|
127 | // first will use default options below, second has custom options
|
128 | var targets = [
|
129 | {
|
130 | url: 'https://google.com'
|
131 | },
|
132 | {
|
133 | url: 'https://github.com',
|
134 | rule: { second: [15, 35, 55] },
|
135 | goldwasher: {
|
136 | selector: 'h1'
|
137 | }
|
138 | }
|
139 | ];
|
140 |
|
141 | // default options
|
142 | var options = {
|
143 | rule: { second: [1, 10, 20, 30, 40, 50] }
|
144 | };
|
145 |
|
146 | // set up the schedule
|
147 | var gs = goldwasher(targets, options);
|
148 |
|
149 | // receive the results
|
150 | gs.on('result', function(results) {
|
151 | console.log(results);
|
152 | });
|
153 |
|
154 | // start the schedule
|
155 | gs.start();
|
156 |
|
157 | // stop the schedule after 60 seconds
|
158 | setTimeout(function() {
|
159 | gs.stop();
|
160 | }, 60000);
|
161 | </code></pre>
|
162 | </article>
|
163 | </section>
|
164 |
|
165 |
|
166 |
|
167 |
|
168 |
|
169 |
|
170 | </div>
|
171 |
|
172 | <nav>
|
173 | <h2><a href="index.html">Index</a></h2>
|
174 | </nav>
|
175 |
|
176 | <br clear="both">
|
177 |
|
178 | <footer>
|
179 | Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha5</a> on Sat Oct 03 2015 20:03:58 GMT+0200 (CEST)
|
180 | </footer>
|
181 |
|
182 | <script> prettyPrint(); </script>
|
183 | <script src="scripts/linenumber.js"> </script>
|
184 | </body>
|
185 | </html> |
\ | No newline at end of file |