<commit_before>/*
 Provides a set of services to build objects in a format that can
 be directly uploaded to Tidepool servers.

 Generally, call 'setDefaults' with the common fields you want to set default
 values for, then call a series of 'make' functions to build the base object,
 and then chain that to a series of 'with_' calls to set the fields. If you
 need to add a value that's not in the standard set of values for a given
 type, use the 'set' function.

 When complete, call the 'done' function, which removes the placeholders
 for optional fields and checks to make sure that required fields were
 supplied. The 'done' function returns the completed object.

 It looks like this:

 var cbg = builder.makeCBG()
 .with_value(data.glucose)
 .with_time(data.displayUtc)
 .with_deviceTime(data.displayTime)
 .set("trend", data.trendText)
 .done();

 */

/*
 * == BSD2 LICENSE ==
 * Copyright (c) 2014, Tidepool Project
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the associated License, which is identical to the BSD 2-Clause
 * License as published by the Open Source Initiative at opensource.org.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the License for more details.
 *
 * You should have received a copy of the License along with this program; if
 * not, you can obtain one from Tidepool Project at tidepool.org.
 * == BSD2 LICENSE ==
 */

'use strict';

var _ = require('lodash');
var util = require('util');

module.exports = function () {
  var REQUIRED = '**REQUIRED**';
  var OPTIONAL = '**OPTIONAL**';

  var deviceInfo = {
    time: REQUIRED,
    deviceTime: OPTIONAL,
    timezoneOffset: OPTIONAL
  };
  function setDefaults(info) {
    deviceInfo = _.assign({}, deviceInfo, _.pick(info, 'deviceId', 'source', 'timezoneOffset', 'units'));
  }

  function _createObject() {
    return {
      // use set to specify extra values that aren't in the template for
      // the data type
      set: function set(k, v) {
        if (v == null && this[k]) {
          delete this[k];
        } else {
          this[k] = v;
        }<commit_msg>Make timezoneOffset required again<commit_after>/*
 Provides a set of services to build objects in a format that can
 be directly uploaded to Tidepool servers.

 Generally, call 'setDefaults' with the common fields you want to set default
 values for, then call a series of 'make' functions to build the base object,
 and then chain that to a series of 'with_' calls to set the fields. If you
 need to add a value that's not in the standard set of values for a given
 type, use the 'set' function.

 When complete, call the 'done' function, which removes the placeholders
 for optional fields and checks to make sure that required fields were
 supplied. The 'done' function returns the completed object.

 It looks like this:

 var cbg = builder.makeCBG()
 .with_value(data.glucose)
 .with_time(data.displayUtc)
 .with_deviceTime(data.displayTime)
 .set("trend", data.trendText)
 .done();

 */

/*
 * == BSD2 LICENSE ==
 * Copyright (c) 2014, Tidepool Project
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the associated License, which is identical to the BSD 2-Clause
 * License as published by the Open Source Initiative at opensource.org.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the License for more details.
 *
 * You should have received a copy of the License along with this program; if
 * not, you can obtain one from Tidepool Project at tidepool.org.
 * == BSD2 LICENSE ==
 */

'use strict';

var _ = require('lodash');
var util = require('util');

module.exports = function () {
  var REQUIRED = '**REQUIRED**';
  var OPTIONAL = '**OPTIONAL**';

  var deviceInfo = {
    time: REQUIRED,
    deviceTime: OPTIONAL,
    timezoneOffset: REQUIRED
  };
  function setDefaults(info) {
    deviceInfo = _.assign({}, deviceInfo, _.pick(info, 'deviceId', 'source', 'timezoneOffset', 'units'));
  }

  function _createObject() {
    return {
      // use set to specify extra values that aren't in the template for
      // the data type
      set: function set(k, v) {
        if (v == null && this[k]) {
          delete this[k];
        } else {
          this[k] = v;
        }
{'fraction_non_alphanumeric': 0.0912881281544876, 'fraction_numerical': 0.0030721966205837174, 'mean_word_length': 3.4081237911025144, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, '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': '878185', 'n_tokens_mistral': 1303, 'n_tokens_neox': 1256, 'n_words': 591}