Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions lib/fit4ruby/BDFieldNameTranslator.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env ruby -w
# encoding: UTF-8
#
# = FitDataRecord.rb -- Fit4Ruby - FIT file processing library for Ruby
# = BDFieldNameTranslator.rb -- Fit4Ruby - FIT file processing library for Ruby
#
# Copyright (c) 2020 by Chris Schlaeger <cs@taskjuggler.org>
#
Expand All @@ -23,11 +23,7 @@ module BDFieldNameTranslator
}

def to_bd_field_name(name)
if (bd_name = BD_DICT[name])
return bd_name
end

name
BD_DICT.fetch(name, name)
end

end
Expand Down
34 changes: 34 additions & 0 deletions spec/BDFieldNameTranslator_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env ruby -w
# encoding: UTF-8
#
# = BDFieldNameTranslator_spec.rb -- Fit4Ruby - FIT file processing library for Ruby
#
# Copyright (c) 2014, 2015 by Chris Schlaeger <cs@taskjuggler.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of version 2 of the GNU General Public License as
# published by the Free Software Foundation.
#

$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))

require 'fit4ruby/BDFieldNameTranslator'

describe Fit4Ruby::BDFieldNameTranslator do

include described_class

it 'should translate "array" to "_array"' do
expect(to_bd_field_name('array')).to eq('_array')
end

it 'should translate "type" to "_type"' do
expect(to_bd_field_name('type')).to eq('_type')
end

it 'should NOT translate "blegga"' do
expect(to_bd_field_name('blegga')).to eq('blegga')
end

end