fit_parser 0.0.2 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/Gemfile.lock +1 -1
- data/lib/fit_parser/file/definitions.rb +657 -657
- data/lib/fit_parser/version.rb +1 -1
- data/spec/file/data_spec.rb +11 -11
- data/spec/file/definition_spec.rb +1 -1
- data/spec/file/definitions_spec.rb +7 -7
- data/spec/file/header_spec.rb +1 -1
- data/spec/file/record_header_spec.rb +1 -1
- data/spec/file/record_spec.rb +5 -5
- data/spec/file/type_spec.rb +6 -6
- data/spec/file/types_spec.rb +3 -3
- data/spec/file_spec.rb +3 -3
- data/spec/{fit_spec.rb → fit_parser_spec.rb} +2 -2
- data/spec/spec_helper.rb +1 -1
- metadata +6 -6
data/lib/fit_parser/version.rb
CHANGED
data/spec/file/data_spec.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe FitParser::File::Data do
|
4
4
|
describe ".generate" do
|
5
5
|
context 'standard definition' do
|
6
6
|
let(:definition) do
|
7
|
-
|
7
|
+
FitParser::File::Definition.read example_file('record/message/definition')
|
8
8
|
end
|
9
9
|
|
10
10
|
subject { described_class.generate(definition) }
|
@@ -15,21 +15,21 @@ describe Fit::File::Data do
|
|
15
15
|
|
16
16
|
context 'definition with multiple time the same field' do
|
17
17
|
before :all do
|
18
|
-
@fields =
|
19
|
-
@dyn_fields =
|
18
|
+
@fields = FitParser::File::Definitions.class_variable_get :@@fields
|
19
|
+
@dyn_fields = FitParser::File::Definitions.class_variable_get :@@dyn_fields
|
20
20
|
# force a fake definition for scaling of arrays
|
21
|
-
|
21
|
+
FitParser::File::Definitions.add_field 2, 2, "field_array", :type => 6, :scale => 10, :offset => 0
|
22
22
|
end
|
23
23
|
|
24
24
|
after :all do
|
25
|
-
|
26
|
-
|
25
|
+
FitParser::File::Definitions.class_variable_set :@@fields, @fields
|
26
|
+
FitParser::File::Definitions.class_variable_set :@@dyn_fields, @dyn_fields
|
27
27
|
end
|
28
28
|
|
29
29
|
before :each do
|
30
30
|
def_file = example_file('record/message/definition_field_array.fit')
|
31
31
|
data_file = example_file('record/message/data_field_array.fit')
|
32
|
-
definition = described_class.generate(
|
32
|
+
definition = described_class.generate(FitParser::File::Definition.read def_file)
|
33
33
|
@result = definition.read( data_file )
|
34
34
|
end
|
35
35
|
|
@@ -61,7 +61,7 @@ describe Fit::File::Data do
|
|
61
61
|
before :each do
|
62
62
|
def_file = example_file('record/message/definition_dynamic_fields.fit')
|
63
63
|
data_file = example_file('record/message/data_dynamic_fields.fit')
|
64
|
-
definition = described_class.generate(
|
64
|
+
definition = described_class.generate(FitParser::File::Definition.read def_file)
|
65
65
|
@result = definition.read( data_file )
|
66
66
|
end
|
67
67
|
|
@@ -75,7 +75,7 @@ describe Fit::File::Data do
|
|
75
75
|
before :each do
|
76
76
|
def_file = example_file('record/message/definition_dynamic_fields.fit')
|
77
77
|
data_file = example_file('record/message/data_dynamic_fields.fit')
|
78
|
-
definition = described_class.generate(
|
78
|
+
definition = described_class.generate(FitParser::File::Definition.read def_file)
|
79
79
|
@result = definition.read( data_file )
|
80
80
|
end
|
81
81
|
|
@@ -88,7 +88,7 @@ describe Fit::File::Data do
|
|
88
88
|
context 'definition with bit field types' do
|
89
89
|
before :each do
|
90
90
|
def_file = example_file('record/message/definition_file_capabilities.fit')
|
91
|
-
@definition = described_class.generate(
|
91
|
+
@definition = described_class.generate(FitParser::File::Definition.read def_file)
|
92
92
|
end
|
93
93
|
|
94
94
|
context 'when only 1 bit set' do
|
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
# we use undefined numbers for field otherwise we interfere
|
4
4
|
# with already defined fields in definitions.rb and test are
|
5
5
|
# not really independant of the code
|
6
|
-
describe
|
6
|
+
describe FitParser::File::Definitions do
|
7
7
|
describe ".add_field" do
|
8
8
|
before :all do
|
9
9
|
@fields = described_class.class_variable_get :@@fields
|
@@ -11,14 +11,14 @@ describe Fit::File::Definitions do
|
|
11
11
|
end
|
12
12
|
|
13
13
|
after :all do
|
14
|
-
|
15
|
-
|
14
|
+
FitParser::File::Definitions.class_variable_set(:@@fields, @fields)
|
15
|
+
FitParser::File::Definitions.class_variable_set(:@@dyn_fields, @dyn_fields)
|
16
16
|
end
|
17
17
|
|
18
18
|
context "without additional options" do
|
19
19
|
before :each do
|
20
|
-
|
21
|
-
|
20
|
+
FitParser::File::Definitions.class_variable_set(:@@fields, Hash.new { |h,k| h[k]={} })
|
21
|
+
FitParser::File::Definitions.class_variable_set(:@@dyn_fields, Hash.new { |h,k| h[k]={} })
|
22
22
|
described_class.add_field(999, 999, 'rspec_test')
|
23
23
|
end
|
24
24
|
|
@@ -34,8 +34,8 @@ describe Fit::File::Definitions do
|
|
34
34
|
|
35
35
|
context "with additional options" do
|
36
36
|
before :each do
|
37
|
-
|
38
|
-
|
37
|
+
FitParser::File::Definitions.class_variable_set(:@@fields, Hash.new { |h,k| h[k]={} })
|
38
|
+
FitParser::File::Definitions.class_variable_set(:@@dyn_fields, Hash.new { |h,k| h[k]={} })
|
39
39
|
|
40
40
|
described_class.add_field(999, 999, 'rspec_test', :scale => 100, :units => 'm')
|
41
41
|
described_class.add_field(999, 999, 'rspec_test_dyn', :type => 4, :scale => 10, :offset => 10, :ref_field_name => nil, :ref_field_values => nil)
|
data/spec/file/header_spec.rb
CHANGED
data/spec/file/record_spec.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe FitParser::File::Record do
|
4
4
|
before do
|
5
5
|
described_class.clear_definitions!
|
6
6
|
described_class.read(example_file('record/definition_record_2.fit'))
|
@@ -12,8 +12,8 @@ describe Fit::File::Record do
|
|
12
12
|
context "given a sample definition record" do
|
13
13
|
let(:file) { example_file('record/definition_record') }
|
14
14
|
|
15
|
-
it { expect(subject.header).to be_a
|
16
|
-
it { expect(subject.content).to be_a
|
15
|
+
it { expect(subject.header).to be_a FitParser::File::RecordHeader }
|
16
|
+
it { expect(subject.content).to be_a FitParser::File::Definition }
|
17
17
|
|
18
18
|
end
|
19
19
|
|
@@ -27,7 +27,7 @@ describe Fit::File::Record do
|
|
27
27
|
|
28
28
|
let(:file) { example_file('record/data_record_2.fit') }
|
29
29
|
|
30
|
-
its(:header) { should be_a(
|
30
|
+
its(:header) { should be_a(FitParser::File::RecordHeader) }
|
31
31
|
it { expect(subject.content.raw_version).to be == 250 }
|
32
32
|
it { expect(subject.content.raw_part_number).to be == '123-A1234-00' }
|
33
33
|
end
|
@@ -36,7 +36,7 @@ describe Fit::File::Record do
|
|
36
36
|
|
37
37
|
let(:file) { example_file('record/data_record_2bis.fit') }
|
38
38
|
|
39
|
-
its(:header) { should be_a(
|
39
|
+
its(:header) { should be_a(FitParser::File::RecordHeader) }
|
40
40
|
it { expect(subject.content.raw_version).to be == 251 }
|
41
41
|
it { expect(subject.content.version).to be == 2.51 }
|
42
42
|
it { expect(subject.content.raw_part_number).to be == '123-A1234' }
|
data/spec/file/type_spec.rb
CHANGED
@@ -1,20 +1,20 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe FitParser::File::Type do
|
4
4
|
before :all do
|
5
|
-
@types =
|
6
|
-
|
7
|
-
|
5
|
+
@types = FitParser::File::Types.class_variable_get :@@types
|
6
|
+
FitParser::File::Types.add_type(:int_type, :sint8)
|
7
|
+
FitParser::File::Types.add_type(:int_type_with_val, :uint8, :values => {1 => 'one', 2 => 'two', 3 => 'three'})
|
8
8
|
end
|
9
9
|
|
10
10
|
after :all do
|
11
|
-
|
11
|
+
FitParser::File::Types.class_variable_set(:@@types, @types)
|
12
12
|
end
|
13
13
|
|
14
14
|
describe '.get_type' do
|
15
15
|
context 'when valid name' do
|
16
16
|
it 'returns a type' do
|
17
|
-
expect(described_class.get_type(:int_type)).to be_a
|
17
|
+
expect(described_class.get_type(:int_type)).to be_a FitParser::File::Type
|
18
18
|
end
|
19
19
|
|
20
20
|
it 'returns always the same instance' do
|
data/spec/file/types_spec.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe FitParser::File::Types do
|
4
4
|
before :all do
|
5
5
|
@types = described_class.class_variable_get :@@types
|
6
6
|
end
|
7
7
|
|
8
8
|
after :all do
|
9
|
-
|
9
|
+
FitParser::File::Types.class_variable_set(:@@types, @types)
|
10
10
|
end
|
11
11
|
|
12
12
|
describe '.add_type' do
|
13
13
|
before :each do
|
14
|
-
|
14
|
+
FitParser::File::Types.class_variable_set(:@@types, Hash.new { |h,k| h[k]={} })
|
15
15
|
end
|
16
16
|
|
17
17
|
context 'for enum type' do
|
data/spec/file_spec.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe FitParser::File do
|
4
4
|
let(:file) { described_class.read( example_file('file/full_file_with_wrong_crc.fit') ) }
|
5
5
|
|
6
6
|
it 'should have a header' do
|
7
|
-
expect(file.header).to be_a
|
7
|
+
expect(file.header).to be_a FitParser::File::Header
|
8
8
|
end
|
9
9
|
|
10
10
|
it 'should have records' do
|
11
11
|
expect(file.records).to be_a Array
|
12
|
-
expect(file.records[0]).to be_a
|
12
|
+
expect(file.records[0]).to be_a FitParser::File::Record
|
13
13
|
end
|
14
14
|
|
15
15
|
it 'should have a CRC' do
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fit_parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dima Mescheryakov
|
@@ -28,16 +28,16 @@ dependencies:
|
|
28
28
|
name: activesupport
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -185,7 +185,7 @@ files:
|
|
185
185
|
- spec/file/type_spec.rb
|
186
186
|
- spec/file/types_spec.rb
|
187
187
|
- spec/file_spec.rb
|
188
|
-
- spec/
|
188
|
+
- spec/fit_parser_spec.rb
|
189
189
|
- spec/spec_helper.rb
|
190
190
|
- spec/support/examples/file/full_file_with_wrong_crc.fit
|
191
191
|
- spec/support/examples/file/header
|