fit_js 0.94.6 → 0.94.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2cbab4a9ee8033bb7a5ef15efd8bd17228f9e1d9eb335388c843ebfc395fb641
4
- data.tar.gz: 752c88200bd84bbe44bdd91688eb2fd8928e503dbd292ee87d6e93f3e75e496b
3
+ metadata.gz: b2b71ad79d02fde4e8bee8d7f11a2615dce2e72d41e2629696f0bdd290f68b22
4
+ data.tar.gz: 18c95d304bde02b68bd26126853629ba09ac99d6e30e616af72c6cc23081c27b
5
5
  SHA512:
6
- metadata.gz: ea97014a9365ef75a304a3728d11c74f4bb62a3bdd0d11696c6ab0225597aacd515dd07572343684b6e285eb342bf5f4299e6c820d3733f6926759db98dbcb9a
7
- data.tar.gz: 41f877bde6339f13ab64d554e65e0d7a45933513c37fcf0bfa121353c0da09c696ecc53848ac1d7f75710b4d15d4ae18776accf1cb5fc0248a9bc130804b99f4
6
+ metadata.gz: c849d463d6f3fbe169e17ab7f6a32f609c2322031a5e2b8eb8e853d86ca2c2112976b4361ed2a7247255406878ca4d8be955efa88e278436905613ddaa1a306b
7
+ data.tar.gz: e400ae98147f3fed44414e3ed72e1846a7a426f67db1b2537b54412dafa220fe31165784318528692953afc4f3e736bf3f95adc2b2e120948b95c23b8e979bb2
data/.DS_Store ADDED
Binary file
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2023-01-19
4
+
5
+ - Initial release
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at axeouse@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1 @@
1
+ gem "fit_js", path: "../fitjs"
data/Gemfile.lock ADDED
@@ -0,0 +1,16 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ fit_js (0.94.2)
5
+
6
+ GEM
7
+ specs:
8
+
9
+ PLATFORMS
10
+ x86_64-darwin-21
11
+
12
+ DEPENDENCIES
13
+ fit_js!
14
+
15
+ BUNDLED WITH
16
+ 2.3.16
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023 Justin Dunn
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,37 @@
1
+ # FitJs
2
+
3
+ Welcome to fitjs gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/fit_js`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Install the gem and add to the application's Gemfile by executing:
10
+
11
+ $ bundle add fit_js
12
+
13
+ If bundler is not being used to manage dependencies, install the gem by executing:
14
+
15
+ $ gem install fit_js
16
+
17
+ ## Usage
18
+
19
+ TODO: Write usage instructions here
20
+
21
+ ## Development
22
+
23
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
24
+
25
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
26
+
27
+ ## Contributing
28
+
29
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/fit_js. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/fit_js/blob/main/CODE_OF_CONDUCT.md).
30
+
31
+ ## License
32
+
33
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
34
+
35
+ ## Code of Conduct
36
+
37
+ Everyone interacting in the FitJs project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/fit_js/blob/main/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ task default: %i[]
data/app/.DS_Store ADDED
Binary file
Binary file
@@ -0,0 +1,48 @@
1
+ /////////////////////////////////////////////////////////////////////////////////////////////
2
+ // Copyright 2022 Garmin International, Inc.
3
+ // Licensed under the Flexible and Interoperable Data Transfer (FIT) Protocol License; you
4
+ // may not use this file except in compliance with the Flexible and Interoperable Data
5
+ // Transfer (FIT) Protocol License.
6
+ /////////////////////////////////////////////////////////////////////////////////////////////
7
+ // ****WARNING**** This file is auto-generated! Do NOT edit this file.
8
+ // Profile Version = 21.94Release
9
+ // Tag = production/akw/21.94.00-0-g0f668193
10
+ /////////////////////////////////////////////////////////////////////////////////////////////
11
+
12
+
13
+ class AccumulatedField {
14
+ #accumulatedValue = 0;
15
+ #lastValue = 0;
16
+
17
+ constructor(value) {
18
+ this.#accumulatedValue = value;
19
+ this.#lastValue = value;
20
+ }
21
+
22
+ accumulate(value, bits) {
23
+ const mask = (1 << bits) - 1;
24
+
25
+ this.#accumulatedValue += (value - this.#lastValue) & mask;
26
+ this.#lastValue = value;
27
+
28
+ return this.#accumulatedValue;
29
+ }
30
+ }
31
+
32
+ class Accumulator {
33
+ #messages = {};
34
+
35
+ add(mesgNum, fieldNum, value) {
36
+ if (this.#messages[mesgNum] == null) {
37
+ this.#messages[mesgNum] = {};
38
+ }
39
+
40
+ this.#messages[mesgNum][fieldNum] = new AccumulatedField(value);
41
+ }
42
+
43
+ accumulate(mesgNum, fieldNum, value, bits) {
44
+ return this.#messages[mesgNum]?.[fieldNum]?.accumulate(value, bits) ?? value;
45
+ }
46
+ }
47
+
48
+ export default Accumulator;
@@ -0,0 +1,85 @@
1
+ /////////////////////////////////////////////////////////////////////////////////////////////
2
+ // Copyright 2022 Garmin International, Inc.
3
+ // Licensed under the Flexible and Interoperable Data Transfer (FIT) Protocol License; you
4
+ // may not use this file except in compliance with the Flexible and Interoperable Data
5
+ // Transfer (FIT) Protocol License.
6
+ /////////////////////////////////////////////////////////////////////////////////////////////
7
+ // ****WARNING**** This file is auto-generated! Do NOT edit this file.
8
+ // Profile Version = 21.94Release
9
+ // Tag = production/akw/21.94.00-0-g0f668193
10
+ /////////////////////////////////////////////////////////////////////////////////////////////
11
+
12
+
13
+ import FIT from "./fit.js";
14
+
15
+ class BitStream {
16
+ #array = null;
17
+ #currentArrayPosition = 0;
18
+ #bitPerPosition = 0;
19
+ #currentByte = 0;
20
+ #currentBit = 0;
21
+ #bitsAvailable = 0;
22
+
23
+ constructor(data, baseType = FIT.BaseType.UINT8) {
24
+ this.#array = Array.isArray(data) ? data : [data];
25
+ const baseTypeSize = FIT.BaseTypeDefinitions[baseType].size;
26
+ this.#bitPerPosition = baseTypeSize * 8;
27
+ this.reset();
28
+ }
29
+
30
+ get bitsAvailable() {
31
+ return this.#bitsAvailable;
32
+ }
33
+
34
+ get hasBitsAvailable() {
35
+ return this.#bitsAvailable > 0;
36
+ }
37
+
38
+ reset() {
39
+ this.#currentArrayPosition = 0;
40
+ this.#bitsAvailable = this.#bitPerPosition * this.#array.length;
41
+ this.#nextByte();
42
+ }
43
+
44
+ readBit() {
45
+ if (!this.hasBitsAvailable) {
46
+ this.#throwError();
47
+ }
48
+
49
+ if (this.#currentBit >= this.#bitPerPosition) {
50
+ this.#nextByte();
51
+ }
52
+
53
+ const bit = this.#currentByte & 0x01;
54
+ this.#currentByte = this.#currentByte >> 1;
55
+ this.#currentBit++;
56
+ this.#bitsAvailable--;
57
+
58
+ return bit;
59
+ }
60
+
61
+ readBits(nBitsToRead) {
62
+ let value = 0n;
63
+
64
+ for (let i = 0n; i < nBitsToRead; i++) {
65
+ value |= BigInt(this.readBit()) << i;
66
+ }
67
+
68
+ return Number(value);
69
+ }
70
+
71
+ #nextByte() {
72
+ if (this.#currentArrayPosition >= this.#array.length) {
73
+ this.#throwError();
74
+ }
75
+
76
+ this.#currentByte = this.#array[this.#currentArrayPosition++];
77
+ this.#currentBit = 0;
78
+ }
79
+
80
+ #throwError(error = "") {
81
+ throw Error("FIT Runtime Error no bits available.");
82
+ }
83
+ }
84
+
85
+ export default BitStream;
@@ -0,0 +1,56 @@
1
+ /////////////////////////////////////////////////////////////////////////////////////////////
2
+ // Copyright 2022 Garmin International, Inc.
3
+ // Licensed under the Flexible and Interoperable Data Transfer (FIT) Protocol License; you
4
+ // may not use this file except in compliance with the Flexible and Interoperable Data
5
+ // Transfer (FIT) Protocol License.
6
+ /////////////////////////////////////////////////////////////////////////////////////////////
7
+ // ****WARNING**** This file is auto-generated! Do NOT edit this file.
8
+ // Profile Version = 21.94Release
9
+ // Tag = production/akw/21.94.00-0-g0f668193
10
+ /////////////////////////////////////////////////////////////////////////////////////////////
11
+
12
+
13
+ const crcTable = [
14
+ 0x0000, 0xCC01, 0xD801, 0x1400, 0xF001, 0x3C00, 0x2800, 0xE401,
15
+ 0xA001, 0x6C00, 0x7800, 0xB401, 0x5000, 0x9C01, 0x8801, 0x4400
16
+ ]
17
+
18
+ class CrcCalculator {
19
+ #crc = 0;
20
+
21
+ constructor() {
22
+ }
23
+
24
+ get crc() {
25
+ return this.#crc;
26
+ }
27
+
28
+ #updateCRC(value) {
29
+ // compute checksum of lower four bits of byte
30
+ let tmp = crcTable[this.#crc & 0xF];
31
+ this.#crc = (this.#crc >> 4) & 0x0FFF;
32
+ this.#crc = this.#crc ^ tmp ^ crcTable[value & 0xF];
33
+
34
+ // compute checksum of upper four bits of byte
35
+ tmp = crcTable[this.#crc & 0xF];
36
+ this.#crc = (this.#crc >> 4) & 0x0FFF;
37
+ this.#crc = this.#crc ^ tmp ^ crcTable[(value >> 4) & 0xF];
38
+
39
+ return this.#crc;
40
+ }
41
+
42
+ addBytes(buf, start, end) {
43
+ for (let i = start; i < end; i++) {
44
+ this.#crc = this.#updateCRC(buf[i]);
45
+ }
46
+
47
+ return this.#crc;
48
+ }
49
+
50
+ static calculateCRC(buf, start, end) {
51
+ const crcCalculator = new CrcCalculator();
52
+ return crcCalculator.addBytes(buf, start, end);
53
+ }
54
+ }
55
+
56
+ export default CrcCalculator;