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
7 changes: 1 addition & 6 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2025-08-24 10:08:03 UTC using RuboCop version 1.80.0.
# on 2025-08-24 15:31:53 UTC using RuboCop version 1.80.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 2
Lint/ShadowedException:
Exclude:
- 'lib/uddf/base/models.rb'

# Offense count: 4
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
Metrics/AbcSize:
Expand Down
75 changes: 6 additions & 69 deletions lib/uddf/base/models.rb
Original file line number Diff line number Diff line change
@@ -1,75 +1,12 @@
# frozen_string_literal: true

require "uddf/base/models/generic"
require "uddf/base/models/deco"
require "uddf/base/models/media"
require "uddf/base/models/dive_computer"

module UDDF
module Base
module Models
##
# Inside <address> the own (<owner> element) address data,
# or that of dive buddies (<buddy> element),
# or that of a shop (<shop> element) etc., are given.
class Address
include HappyMapper

tag "address"

has_one :street, String
has_one :city, String
has_one :postcode, String
has_one :country, String
has_one :province, String
end

##
# Inside <contact> data concerning getting in touch with some one are
# given, like phone number, email address, language etc.
class Contact
include HappyMapper

tag "contact"

has_many :emails, String, tag: "email"
has_many :faxes, String, tag: "fax"
has_many :homepages, String, tag: "homepage"
has_many :languages, String, tag: "language"
has_many :mobile_phones, String, tag: "mobilephone"
has_many :phones, String, tag: "phone"
end

class DateTimeField
include HappyMapper

element :raw, String, tag: "datetime"

# Lazily parse on first access; memoize in @date_time
def date_time
return @date_time if @date_time

content = raw.to_s.strip
return nil if content.empty?

@date_time =
case content
when /^\d{4}$/ # "YYYY"
DateTime.new(content.to_i, 1, 1)
when /^\d{4}-\d{2}$/ # "YYYY-MM"
y, m = content.split("-").map!(&:to_i)
DateTime.new(y, m, 1)
else
begin
DateTime.iso8601(content)
rescue ArgumentError, Date::Error
begin
DateTime.rfc3339(content)
rescue ArgumentError, Date::Error
DateTime.parse(content)
end
end
end
end

# Allow manual assignment if you ever need it
attr_writer :date_time
end
end
module Models; end
end
end
102 changes: 102 additions & 0 deletions lib/uddf/base/models/deco.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# frozen_string_literal: true

module UDDF
module Base
module Models
class Tissue
include HappyMapper

tag "tissue"

attribute :gas, String
attribute :half_life, Float, tag: "halflife"
attribute :number, Integer
attribute :a, Float
attribute :b, Float
end

class Hargikas
include HappyMapper

tag "hargikas"

has_one :ambient, Float
has_many :tissues, Tissue, tag: "tissue"
has_one :arterial_micro_bubble_level, Integer, tag: "arterialmicrobubbleLevel"
has_one :intrapulmonary_right_left_shunt, Float, tag: "intrapulmonaryrightleftshunt"
has_one :estimated_skin_cool_level, Integer, tag: "estimatedskincoolLevel"
end

class VPM
include HappyMapper

tag "vpm"

attribute :id, String
has_one :conservatism, Float
has_one :gamma, Float
has_one :gc, Float
has_one :lambda, Float
has_one :r0, Float
has_many :tissues, Tissue, tag: "tissue"
end

class RGBM
include HappyMapper

tag "rgbm"

attribute :id, String
has_many :tissues, Tissue, tag: "tissue"
end

class Buehlmann
include HappyMapper

tag "buehlmann"

attribute :id, String
has_many :tissues, Tissue, tag: "tissue"
end

class BuehlmannV320
include HappyMapper

tag "buehlmann"

attribute :id, String
has_one :gradient_factor_high, Float, tag: "gradientfactorhigh"
has_one :gradient_factor_low, Float, tag: "gradientfactorlow"
has_many :tissues, Tissue, tag: "tissue"
end

class DecoModel
include HappyMapper

tag "decomodel"

content :value, String
end

class DecoModelV310
include HappyMapper

tag "decomodel"

has_many :buehlmanns, Buehlmann, tag: "buehlmann"
has_many :rgbms, RGBM, tag: "rbgm"
has_many :vpms, VPM, tag: "vpm"
end

class DecoModelV320
include HappyMapper

tag "decomodel"

has_many :buehlmanns, BuehlmannV320, tag: "buehlmann"
has_many :rgbms, RGBM, tag: "rbgm"
has_many :vpms, VPM, tag: "vpm"
end
end
end
end
193 changes: 193 additions & 0 deletions lib/uddf/base/models/dive_computer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
# frozen_string_literal: true

module UDDF
module Base
module Models
class DCAlarm
include HappyMapper

tag "dcalarm"

has_one :acknowledge, String
has_one :alarm_type, Integer, tag: "alarmtype"
has_one :period, Float
end

class SetDCDiveDepthAlarm
include HappyMapper

tag "setdcdivedethalarm"

has_one :dc_alarm, DCAlarm, tag: "dcalarm"
has_one :dc_alarm_depth, Float, tag: "dcalarmdepth"
end

class SetDCDivePo2Alarm
include HappyMapper

tag "setdcdivepo2alarm"

has_one :dc_alarm, DCAlarm, tag: "dcalarm"
has_one :maximum_po2, Float, tag: "maximumpo2"
end

class SetDCDiveSiteData
include HappyMapper

tag "setdcdivesitedata"

attribute :dive_site, String, tag: "divesite"
end

class SetDCDiveTimeAlarm
include HappyMapper

tag "setdcdivetimealarm"

has_one :dc_alarm, DCAlarm, tag: "dcalarm"
has_one :timespan, Float
end

class SetDCEndNDTAlarm
include HappyMapper

tag "setdcendndtalarm"

has_one :dc_alarm, DCAlarm, tag: "dcalarm"
end

class ApplicationDataV300
include HappyMapper

tag "applicationdata"

has_one :hargikas, Hargikas
end

class ApplicationDataV310 < ApplicationDataV300
include HappyMapper

tag "applicationdata"

has_one :deco_trainer, String, tag: "decotrainer"
end

class ApplicationDataV330 < ApplicationDataV310
include HappyMapper

has_one :apdiving, String
has_one :ratio, String
end

class SetDCDecoModelV300
include HappyMapper

tag "setdcdecomodel"

has_many :alias_names, String, tag: "aliasname"
has_one :application_data, ApplicationDataV300, tag: "applicationdata"
has_one :name, String
end

class SetDCDecoModelV310 < SetDCDecoModelV300
include HappyMapper

has_one :application_data, ApplicationDataV310, tag: "applicationdata"
end

class SetDCDecoModelV330 < SetDCDecoModelV310
include HappyMapper

has_one :application_data, ApplicationDataV330, tag: "applicationdata"
end

class SetDCBuddyData
include HappyMapper

tag "setdcbuddydata"

attribute :buddy, String
end

class SetDCDataV300
include HappyMapper

tag "setdcdata"

has_one :set_dc_alarm_time, DateTime, tag: "setdcalarmtime"
has_one :set_dc_altitude, Float, tag: "setdcaltitude"
has_one :set_dc_buddy_data, SetDCBuddyData, tag: "setdcbuddydata"
has_one :set_dc_date_time, DateTime, tag: "setdcdatetime"
has_one :set_dc_deco_model, SetDCDecoModelV300, tag: "setdcdecomodel"
has_one :set_dc_dive_depth_alarm, SetDCDiveDepthAlarm, tag: "setdcdivedethalarm"
has_one :set_dc_dive_po2_alarm, SetDCDivePo2Alarm, tag: "setdcdivepo2alarm"
has_many :set_dc_dive_site_data, SetDCDiveSiteData, tag: "setdcdivesitedata"
has_one :set_dc_dive_time_alarm, SetDCDiveTimeAlarm, tag: "setdcdivetimealarm"
has_one :set_dc_end_ndt_alarm, SetDCEndNDTAlarm, tag: "setdcendndtalarm"
has_one :set_dc_gas_definitions_data, String, tag: "setdcgasdefinitionsdata"
has_one :set_dc_owner_data, String, tag: "setdcownerdata"
has_one :set_dc_password, String, tag: "setdcpassword"
has_one :set_dc_generator_data, String, tag: "setdcgeneratordata"
end

class SetDCDataV310 < SetDCDataV300
include HappyMapper

has_one :set_dc_deco_model, SetDCDecoModelV310, tag: "setdcdecomodel"
end

class SetDCDataV330 < SetDCDataV310
include HappyMapper

has_one :set_dc_deco_model, SetDCDecoModelV330, tag: "setdcdecomodel"
end

class GetDCData
include HappyMapper

tag "getdcdata"

has_one :get_dc_all_data, String, tag: "getdcalldata"
has_one :get_dc_generator_data, String, tag: "getdcgeneratordata"
has_one :get_dc_owner_data, String, tag: "getdcownerdata"
has_one :get_dc_buddy_data, String, tag: "getdcbuddydata"
has_one :get_dc_gas_definitions_data, String, tag: "getdcgasdefinitionsdata"
has_one :get_dc_dive_site_data, String, tag: "getdcdivesitedata"
has_one :get_dc_dive_trip_data, String, tag: "getdcdivetripdata"
has_one :get_dc_profile_data, String, tag: "getdcprofiledata"
end

class DiveComputerDump
include HappyMapper

tag "divecomputerdump"

has_one :datetime, DateTime
has_one :dc_dump, String, tag: "dcdump"
has_one :link, Link
end

class DiveComputerControlV300
include HappyMapper

tag "divecomputercontrol"

has_many :dive_computer_dumps, DiveComputerDump, tag: "divecomputerdump"
has_one :get_dc_data, GetDCData, tag: "getdcdata"
has_one :set_dc_data, SetDCDataV300, tag: "setdcdata"
end

class DiveComputerControlV310 < DiveComputerControlV300
include HappyMapper

has_one :set_dc_data, SetDCDataV310, tag: "setdcdata"
end

class DiveComputerControlV330 < DiveComputerControlV310
include HappyMapper

has_one :set_dc_data, SetDCDataV330, tag: "setdcdata"
end
end
end
end
Loading