<commit_before>/*
 *  transporter.js
 *
 *  <NAME>
 *  IOTDB.org
 *  2016-08-04
 *
 *  Copyright [2013-2016] [<NAME>]
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

"use strict";

const express = require('express');
const body_parser = require("body-parser");
const unirest = require('unirest');

const app = express();
app.use(body_parser.json());
app.listen(3000, function () {
  console.log('Example app listening on port 3000!');
});

// this is the source 
const iotdb = require("iotdb");
iotdb.use("homestar-wemo");

const iotdb_transporter = require("../../iotdb-transport-iotdb/transporter");
const iotdb_transport = iotdb_transporter.make({}, iotdb.connect("WeMoSocket"));

// this is the actual transporter
const express_transporter = require("../transporter")
const express_transport = express_transporter.make({
    prefix: "/",
}, app)

// the actual gets data from the source
express_transport.use(iotdb_transport)

/**
 *  The clever bit - when one is added, test the put
 */
express_transport
    .added()
    .subscribe(
        ad => {
            let count = 0;
            setInterval(() => {
                unirest
                    .put("http://127.0.0.1:3000/" + ad.id + "/ostate")
                    .type('json')
                    .json({
                        "on": count++ % 2,
                    })
                    .end((result) => {
                        if (result.error) {
                            console.log("HERE:A", result.error)
                        } else {
                            console.log("HERE:B", result.body)
                        }
                    });
            }, 1500);
        }
    );

<commit_msg>better messages<commit_after>/*
 *  transporter.js
 *
 *  <NAME>
 *  IOTDB.org
 *  2016-08-04
 *
 *  Copyright [2013-2016] [<NAME>]
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

"use strict";

const express = require('express');
const body_parser = require("body-parser");
const unirest = require('unirest');

const app = express();
app.use(body_parser.json());
app.listen(3000, function () {
  console.log('Example app listening on port 3000!');
});

// this is the source 
const iotdb = require("iotdb");
iotdb.use("homestar-wemo");

const iotdb_transporter = require("../../iotdb-transport-iotdb/transporter");
const iotdb_transport = iotdb_transporter.make({}, iotdb.connect("WeMoSocket"));

// this is the actual transporter
const express_transporter = require("../transporter")
const express_transport = express_transporter.make({
    prefix: "/",
}, app)

// the actual gets data from the source
express_transport.use(iotdb_transport)

/**
 *  The clever bit - when one is added, test the put using Unirest
 */
express_transport
    .added()
    .subscribe(
        ad => {
            let count = 0;
            setInterval(() => {
                unirest
                    .put("http://127.0.0.1:3000/" + ad.id + "/ostate")
                    .type('json')
                    .json({
                        "on": count++ % 2,
                    })
                    .end((result) => {
                        if (result.error) {
                            console.log("#", "unirest.put", _.error.message(result.error))
                        } else {
                            console.log("+", "unirest.put", result.body);
                        }
                    });
            }, 1500);
        }
    );


{'fraction_non_alphanumeric': 0.1292562724014337, 'fraction_numerical': 0.01971326164874552, 'mean_word_length': 2.079310344827586, 'pattern_counts': {'":': 2, '<': 7, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4580019', 'n_tokens_mistral': 1329, 'n_tokens_neox': 1244, 'n_words': 367}