icharger-log 0.0.1

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.
data/spec/file_spec.rb ADDED
@@ -0,0 +1,63 @@
1
+ require 'spec_helper'
2
+
3
+ describe ICharger::Log::File do
4
+
5
+ context 'data file LiPo[Storage_952_CH1].txt' do
6
+
7
+ before(:all) { @file = ICharger::Log::File.new(data_file('LiPo[Storage_952_CH1].txt')) }
8
+
9
+ subject { @file }
10
+
11
+ it { should have(447).rows }
12
+
13
+ its(:channel) { should eql(1) }
14
+
15
+ its(:duration) { should be_within(0.1).of(44.6) }
16
+
17
+ end
18
+
19
+ context 'data file LiPo[Storage_953_CH2].txt' do
20
+
21
+ before(:all) { @file = ICharger::Log::File.new(data_file('LiPo[Storage_953_CH2].txt')) }
22
+
23
+ subject { @file }
24
+
25
+ it { should have(629).rows }
26
+
27
+ its(:channel) { should eql(2) }
28
+
29
+ its(:duration) { should be_within(0.1).of(62.8) }
30
+
31
+ end
32
+
33
+ describe '#icharger?' do
34
+
35
+ it 'should be false for invalid or missing files' do
36
+ files = invalid_data_files
37
+ files.should have(2).files
38
+
39
+ files.each do |f|
40
+ expect(ICharger::Log::File.icharger?(f)).to be_false
41
+ end
42
+ end
43
+
44
+ it 'should be true for valid files' do
45
+ files = data_files
46
+ files.should have(2).files
47
+
48
+ files.each do |f|
49
+ expect(ICharger::Log::File.icharger?(f)).to be_true
50
+ end
51
+ end
52
+
53
+ it 'should return a file object' do
54
+ expect(ICharger::Log::File.icharger?(data_files[0])).to be_a(ICharger::Log::File)
55
+ end
56
+
57
+ it 'should return nil when invalid' do
58
+ expect(ICharger::Log::File.icharger?(invalid_data_files[0])).to be_nil
59
+ end
60
+
61
+ end
62
+
63
+ end
data/spec/row_spec.rb ADDED
@@ -0,0 +1,91 @@
1
+ require 'spec_helper'
2
+
3
+ describe ICharger::Log::Row do
4
+
5
+ subject { ICharger::Log::Row.new(data) }
6
+
7
+ context 'channel 1, 6 cells' do
8
+
9
+ let(:data) { '$1;1;18000;1;0;-53;23746;22752;1;380;0;3795;3793;3798;3795;3793;3789;0;0;0;0;50' }
10
+
11
+ its(:channel) { should eql(1) }
12
+
13
+ its(:current) { should be_within(0.01).of(-0.53) }
14
+
15
+ its(:cell_count) { should eql(6) }
16
+
17
+ it 'should have known cell voltages' do
18
+ expect(subject.cell(0)).to be_within(0.01).of(3.79)
19
+ expect(subject.cell(1)).to be_within(0.01).of(3.79)
20
+ expect(subject.cell(2)).to be_within(0.01).of(3.79)
21
+ expect(subject.cell(3)).to be_within(0.01).of(3.79)
22
+ expect(subject.cell(4)).to be_within(0.01).of(3.79)
23
+ expect(subject.cell(5)).to be_within(0.01).of(3.79)
24
+ end
25
+
26
+ end
27
+
28
+ context 'channel 2, 6 cells' do
29
+
30
+ let(:data) { '$2;1;9000;1;0;41;23840;22853;0;380;0;3810;3807;3813;3811;3806;3812;0;0;0;0;40' }
31
+
32
+ its(:channel) { should eql(2) }
33
+
34
+ its(:current) { should be_within(0.01).of(0.41) }
35
+
36
+ its(:cell_count) { should eql(6) }
37
+
38
+ it 'should have known cell voltages' do
39
+ expect(subject.cell(0)).to be_within(0.01).of(3.81)
40
+ expect(subject.cell(1)).to be_within(0.01).of(3.80)
41
+ expect(subject.cell(2)).to be_within(0.01).of(3.81)
42
+ expect(subject.cell(3)).to be_within(0.01).of(3.81)
43
+ expect(subject.cell(4)).to be_within(0.01).of(3.80)
44
+ expect(subject.cell(5)).to be_within(0.01).of(3.81)
45
+ end
46
+
47
+ end
48
+
49
+ context 'channel 1, 10 cells' do
50
+
51
+ let(:data) { '$1;1;106000;1;0;397;23840;22853;0;380;0;3810;3807;3813;3811;3806;3812;3811;3814;3809;3812;40' }
52
+
53
+ its(:channel) { should eql(1) }
54
+
55
+ its(:current) { should be_within(0.1).of(3.97) }
56
+
57
+ its(:cell_count) { should eql(10) }
58
+
59
+ it 'should have known cell voltages' do
60
+ expect(subject.cell(0)).to be_within(0.01).of(3.81)
61
+ expect(subject.cell(1)).to be_within(0.01).of(3.80)
62
+ expect(subject.cell(2)).to be_within(0.01).of(3.81)
63
+ expect(subject.cell(3)).to be_within(0.01).of(3.81)
64
+ expect(subject.cell(4)).to be_within(0.01).of(3.80)
65
+ expect(subject.cell(5)).to be_within(0.01).of(3.81)
66
+ expect(subject.cell(6)).to be_within(0.01).of(3.81)
67
+ expect(subject.cell(7)).to be_within(0.01).of(3.81)
68
+ expect(subject.cell(8)).to be_within(0.01).of(3.80)
69
+ expect(subject.cell(9)).to be_within(0.01).of(3.81)
70
+ end
71
+
72
+ end
73
+
74
+ context 'channel 2, 2 cells' do
75
+
76
+ let(:data) { '$2;1;87000;1;0;402;23840;22853;0;380;0;3810;3807;0;0;0;0;0;0;0;0;40' }
77
+
78
+ its(:channel) { should eql(2) }
79
+
80
+ its(:current) { should be_within(0.1).of(4.02) }
81
+
82
+ its(:cell_count) { should eql(2) }
83
+
84
+ it 'should have known cell voltages' do
85
+ expect(subject.cell(0)).to be_within(0.01).of(3.81)
86
+ expect(subject.cell(1)).to be_within(0.01).of(3.81)
87
+ end
88
+
89
+ end
90
+
91
+ end
@@ -0,0 +1,38 @@
1
+ require 'simplecov'
2
+ require 'simplecov-gem-adapter'
3
+ require 'simplecov-rcov'
4
+ SimpleCov.formatter = SimpleCov::Formatter::RcovFormatter
5
+ SimpleCov.start 'gem' if ENV['COVERAGE']
6
+
7
+ require 'awesome_print'
8
+ require 'pathname'
9
+ require 'icharger/log'
10
+
11
+ RSpec.configure do |config|
12
+ config.treat_symbols_as_metadata_keys_with_true_values = true
13
+ config.run_all_when_everything_filtered = true
14
+ config.filter_run :focus
15
+
16
+ # Run specs in random order to surface order dependencies. If you find an
17
+ # order dependency and want to debug it, you can fix the order by providing
18
+ # the seed, which is printed after each run.
19
+ # --seed 1234
20
+ config.order = 'random'
21
+ end
22
+
23
+ # root from spec/data
24
+ def data_file(name)
25
+ File.expand_path("#{File.dirname(__FILE__)}/data/#{name}")
26
+ end
27
+
28
+ def data_files
29
+ dir = "#{File.dirname(__FILE__)}/data/#{dir}"
30
+ Dir.glob("#{dir}/*").select { |e| File.file? e }
31
+ end
32
+
33
+ def invalid_data_files
34
+ dir = "#{File.dirname(__FILE__)}/data/invalid"
35
+ invalid = Dir.glob("#{dir}/**/*").select { |e| File.file? e }
36
+ invalid << __FILE__
37
+ invalid << 'NOFILE.TLM'
38
+ end
metadata ADDED
@@ -0,0 +1,177 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: icharger-log
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Nick Veys
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-10-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: awesome_print
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: ci_reporter
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '='
46
+ - !ruby/object:Gem::Version
47
+ version: 1.8.4
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '='
53
+ - !ruby/object:Gem::Version
54
+ version: 1.8.4
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: '2.13'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: '2.13'
83
+ - !ruby/object:Gem::Dependency
84
+ name: simplecov
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: simplecov-gem-adapter
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: simplecov-rcov
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ description: Read and interpret iCharger log files.
126
+ email:
127
+ - nick@codelever.com
128
+ executables: []
129
+ extensions: []
130
+ extra_rdoc_files: []
131
+ files:
132
+ - .gitignore
133
+ - .travis.yml
134
+ - Gemfile
135
+ - LICENSE.txt
136
+ - README.md
137
+ - Rakefile
138
+ - icharger-log.gemspec
139
+ - lib/icharger/log.rb
140
+ - lib/icharger/log/file.rb
141
+ - lib/icharger/log/row.rb
142
+ - lib/icharger/log/version.rb
143
+ - spec/data/LiPo[Storage_952_CH1].txt
144
+ - spec/data/LiPo[Storage_953_CH2].txt
145
+ - spec/file_spec.rb
146
+ - spec/row_spec.rb
147
+ - spec/spec_helper.rb
148
+ homepage: http://github.com/code-lever/icharger-log
149
+ licenses:
150
+ - MIT
151
+ metadata: {}
152
+ post_install_message:
153
+ rdoc_options: []
154
+ require_paths:
155
+ - lib
156
+ required_ruby_version: !ruby/object:Gem::Requirement
157
+ requirements:
158
+ - - '>='
159
+ - !ruby/object:Gem::Version
160
+ version: '0'
161
+ required_rubygems_version: !ruby/object:Gem::Requirement
162
+ requirements:
163
+ - - '>='
164
+ - !ruby/object:Gem::Version
165
+ version: '0'
166
+ requirements: []
167
+ rubyforge_project:
168
+ rubygems_version: 2.0.3
169
+ signing_key:
170
+ specification_version: 4
171
+ summary: iCharger log file reader
172
+ test_files:
173
+ - spec/data/LiPo[Storage_952_CH1].txt
174
+ - spec/data/LiPo[Storage_953_CH2].txt
175
+ - spec/file_spec.rb
176
+ - spec/row_spec.rb
177
+ - spec/spec_helper.rb