diff --git a/lib/ax25/encoder/igate_tcp.rb b/lib/ax25/encoder/igate_tcp.rb index 2b60b7447be0672fccf65bf5c8c971faddd4c604..c93f7c0b4e715bfd0eed2389e3e43dc21d4f425f 100644 --- a/lib/ax25/encoder/igate_tcp.rb +++ b/lib/ax25/encoder/igate_tcp.rb @@ -56,21 +56,21 @@ module Ax25 path = path.split(',') - decoded_source = Ax25::ImmutableAddress.from_raw(decoded_source, strict_callsign: false, strict_ssid: false) - decoded_destination = Ax25::ImmutableAddress.from_raw(path.shift, strict_callsign: false, strict_ssid: false) - decoded_path = Ax25::ImmutablePath.from_raw(path, strict_callsign: false, strict_ssid: false) + decoded_source = Ax25::ImmutableAddress.from_raw(decoded_source, strict_entity: false, strict_ssid: false) + decoded_destination = Ax25::ImmutableAddress.from_raw(path.shift, strict_entity: false, strict_ssid: false) + decoded_path = Ax25::ImmutablePath.from_raw(path, strict_entity: false, strict_ssid: false) decoded_payload = frame_so_far return Ax25::ImmutableFrame.new(decoded_source, decoded_destination, decoded_path, decoded_payload) end private - def self.calculatePasscode(callsign_raw) - callsign = callsign_raw.upcase.split('-').first + def self.calculatePasscode(entity_raw) + entity = entity_raw.upcase.split('-').first hash = 0x73e2 flag = true - callsign.split('').each do |c| + entity.split('').each do |c| hash = if flag (hash ^ (c.ord << 8)) else diff --git a/lib/ax25/frame/address.rb b/lib/ax25/frame/address.rb index 48c098780c9c3149763f139750bae963843a4b99..7a5347f155737a35559ef42ec6f4f08826397a84 100644 --- a/lib/ax25/frame/address.rb +++ b/lib/ax25/frame/address.rb @@ -3,8 +3,8 @@ module Ax25 module Address include Abstractify::Abstract - abstract :decrement_ssid, :==, :eql?, :to_s + abstract :==, :eql?, :to_s - attr_reader :callsign, :ssid + attr_reader :entity, :ssid end end diff --git a/lib/ax25/frame/hop.rb b/lib/ax25/frame/hop.rb index 43050bad143ea2da7a012524a602b18c57516ccd..a2a6d2c47e017ac78a461038035b529aad523a19 100644 --- a/lib/ax25/frame/hop.rb +++ b/lib/ax25/frame/hop.rb @@ -6,6 +6,6 @@ module Ax25 include Ax25::Address include Abstractify::Abstract - abstract :toggle_seen, :decrement_ssid, :==, :eql?, :to_s, :seen? + abstract :toggle_seen, :==, :eql?, :to_s, :seen? end end diff --git a/lib/ax25/frame/immutable_address.rb b/lib/ax25/frame/immutable_address.rb index 8bb5ac4a5fcf5af5ae7645913a289c3ed5e9b7e2..8f3e59282a411033fc70731a64450a3426e772bd 100644 --- a/lib/ax25/frame/immutable_address.rb +++ b/lib/ax25/frame/immutable_address.rb @@ -5,20 +5,20 @@ module Ax25 class ImmutableAddress include Address - attr_reader :callsign, :ssid + attr_reader :entity, :ssid public - def initialize(callsign, ssid, strict_callsign: true, strict_ssid: true) - raise ArgumentError.new("callsign can not be nil") if callsign.nil? + def initialize(entity, ssid, strict_entity: true, strict_ssid: true) + raise ArgumentError.new("entity can not be nil") if entity.nil? - raise ArgumentError.new("callsign must be a String") if not callsign.kind_of? String + raise ArgumentError.new("entity must be a String") if not entity.kind_of? String raise ArgumentError.new("ssid must be an Integer.") if (not ssid.nil?) && (not ssid.kind_of? Integer) - raise ArgumentError.new("ssid must be a value between 0 (inclusive) and 15 (inclusive): #{callsign}-#{ssid}") if (not ssid.nil?) && (ssid < 0 || ssid > 15) && (strict_ssid) - raise ArgumentError.new("Callsign can not be an empty string") if callsign.empty? && strict_callsign - raise ArgumentError.new("Callsign must only contain numebers and letters") if callsign.strip.match?(/[^a-zA-Z0-9]/) && (strict_callsign) + raise ArgumentError.new("ssid must be a value between 0 (inclusive) and 15 (inclusive): #{entity}-#{ssid}") if (not ssid.nil?) && (ssid < 0 || ssid > 15) && (strict_ssid) + raise ArgumentError.new("Entity can not be an empty string") if entity.empty? && strict_entity + raise ArgumentError.new("Entity must only contain numebers and letters") if entity.strip.match?(/[^a-zA-Z0-9]/) && (strict_entity) - @callsign = callsign.strip.upcase.freeze + @entity = entity.strip.upcase.freeze if (ssid.nil?) || (ssid.eql? 0) @ssid = nil else @@ -27,35 +27,35 @@ module Ax25 end public - def self.from_raw(raw_hop, strict_callsign: true, strict_ssid: true) + def self.from_raw(raw_hop, strict_entity: true, strict_ssid: true) raise ArgumentError.new("raw_hop can not be nil") if raw_hop.nil? - callsign = nil + entity = nil ssid = nil hop = raw_hop.dup - raise ArgumentError.new("Hops can only contain letters, numbers and dashes") if hop.strip.match?(/[^a-zA-Z0-9\-]/) && strict_callsign + raise ArgumentError.new("Hops can only contain letters, numbers and dashes") if hop.strip.match?(/[^a-zA-Z0-9\-]/) && strict_entity if not hop.include? "-" ssid = nil - callsign = hop.strip + entity = hop.strip else split_hop = hop.strip.split("-") raise ArgumentError.new("More than one hypen seen in a hop, invalid format") if split_hop.length > 2 raise ArgumentError.new("Hop format was not valid, hyphen placed at end or beginning of string") if split_hop.length <= 1 - callsign = split_hop[0] + entity = split_hop[0] ssid = split_hop[1].to_i end - return Ax25::ImmutableAddress.new(callsign, ssid, strict_callsign: strict_callsign, strict_ssid: strict_ssid) + return Ax25::ImmutableAddress.new(entity, ssid, strict_entity: strict_entity, strict_ssid: strict_ssid) end public def decrement_ssid raise RangeError.new("SSID can not be decremented when it is currently 0 or nil") if (self.ssid.nil?) or (self.ssid <= 0) - return Ax25::ImmutableAddress.new(self.callsign, self.ssid - 1, strict_callsign: false, strict_ssid: false) + return Ax25::ImmutableAddress.new(self.entity, self.ssid - 1, strict_entity: false, strict_ssid: false) end public @@ -68,10 +68,10 @@ module Ax25 public def ==(other) return false if other.nil? - return false if not other.respond_to? :callsign + return false if not other.respond_to? :entity return false if not other.respond_to? :ssid - return false if not self.callsign.eql? other.callsign + return false if not self.entity.eql? other.entity return false if not self.ssid.eql? other.ssid return true @@ -79,7 +79,7 @@ module Ax25 public def to_s - ret_val = self.callsign.dup + ret_val = self.entity.dup ret_val << ("-" + self.ssid.to_s) if not self.ssid.nil? return ret_val end diff --git a/lib/ax25/frame/immutable_hop.rb b/lib/ax25/frame/immutable_hop.rb index cce45ec637eeb94f9a7d0864af7c499809e31fed..d0c309ae7e33ca5052cd32d7ce9bf1b4b7bd079f 100644 --- a/lib/ax25/frame/immutable_hop.rb +++ b/lib/ax25/frame/immutable_hop.rb @@ -7,21 +7,21 @@ module Ax25 include Hop public - def initialize(callsign, ssid, seen, strict_callsign: true, strict_ssid: true) + def initialize(entity, ssid, seen, strict_entity: true, strict_ssid: true) raise ArgumentError.new("seen can not be nil") if seen.nil? raise ArgumentError.new("seen must be a Boolean") if not (!!seen == seen) - super(callsign, ssid, strict_callsign: strict_callsign, strict_ssid: strict_ssid) + super(entity, ssid, strict_entity: strict_entity, strict_ssid: strict_ssid) @seen = seen end public - def self.from_raw(raw_hop, strict_callsign: true, strict_ssid: true) + def self.from_raw(raw_hop, strict_entity: true, strict_ssid: true) raise ArgumentError.new("raw_hop can not be nil") if raw_hop.nil? - callsign = nil + entity = nil ssid = nil seen = nil @@ -33,20 +33,20 @@ module Ax25 seen = false end - raise ArgumentError.new("Hops can only contain letters, numbers and dashes. Hop: #{hop.to_s}") if hop.strip.match?(/[^a-zA-Z0-9\-]/) && strict_callsign + raise ArgumentError.new("Hops can only contain letters, numbers and dashes. Hop: #{hop.to_s}") if hop.strip.match?(/[^a-zA-Z0-9\-]/) && strict_entity if not hop.include? "-" ssid = nil - callsign = hop.strip + entity = hop.strip else split_hop = hop.strip.split("-") raise ArgumentError.new("More than one hypen seen in a hop, invalid format") if split_hop.length > 2 raise ArgumentError.new("Hop format was not valid, hyphen placed at end or beginning of string") if split_hop.length <= 1 - callsign = split_hop[0] + entity = split_hop[0] ssid = split_hop[1].to_i end - return Ax25::ImmutableHop.new(callsign, ssid, seen, strict_callsign: strict_callsign, strict_ssid: strict_ssid) + return Ax25::ImmutableHop.new(entity, ssid, seen, strict_entity: strict_entity, strict_ssid: strict_ssid) end public @@ -56,14 +56,14 @@ module Ax25 public def toggle_seen - return Ax25::ImmutableHop.new(self.callsign, self.ssid, !self.seen?, strict_callsign: false, strict_ssid: false) + return Ax25::ImmutableHop.new(self.entity, self.ssid, !self.seen?, strict_entity: false, strict_ssid: false) end public def decrement_ssid raise RangeError.new("SSID can not be decremented when it is currently 0 or nil") if (self.ssid.nil?) or (self.ssid <= 0) - return Ax25::ImmutableHop.new(self.callsign, self.ssid - 1, self.seen?, strict_callsign: false, strict_ssid: false) + return Ax25::ImmutableHop.new(self.entity, self.ssid - 1, self.seen?, strict_entity: false, strict_ssid: false) end public diff --git a/lib/ax25/frame/immutable_message.rb b/lib/ax25/frame/immutable_message.rb index b58b44d7def34d532a86e8804bcbf38b61c8ae69..a27b9077a8a1f0aac108986def15a6175b96f958 100644 --- a/lib/ax25/frame/immutable_message.rb +++ b/lib/ax25/frame/immutable_message.rb @@ -17,10 +17,10 @@ module Ax25 # Creates a new frame, all fields are duplicated but and immutable. All # fields are validated. # - # @param source [Ax25::Address] The source callsign for the frame. Must be a + # @param source [Ax25::Address] The source entity for the frame. Must be a # non-null string of non-zero length with only letters, numbers and # dashes. Will be converted uppercase. - # @param destination [Ax25::Address] The destination callsign for the frame. Must + # @param destination [Ax25::Address] The destination entity for the frame. Must # be a non-null string of non-zero length with only letters, numbers, # and dashes. Will be converted to uppercase. # @param payload [String] The payload of the frame. Must be a non-null diff --git a/lib/ax25/frame/immutable_path.rb b/lib/ax25/frame/immutable_path.rb index 4e965fbe6e5d109deea2be7c644049a874923bdc..ebeb617ddb7c0788beeab7a38cba92896dfb9497 100644 --- a/lib/ax25/frame/immutable_path.rb +++ b/lib/ax25/frame/immutable_path.rb @@ -23,7 +23,7 @@ module Ax25 end public - def self.from_raw(raw_path, strict_callsign: true, strict_ssid: true) + def self.from_raw(raw_path, strict_entity: true, strict_ssid: true) raise ArgumentError.new("raw_path can not be nil") if raw_path.nil? if raw_path.kind_of? String @@ -43,7 +43,7 @@ module Ax25 if hop.kind_of? Ax25::Hop new_hop = hop else - new_hop = Ax25::ImmutableHop.from_raw(hop, strict_callsign: strict_callsign, strict_ssid: strict_ssid) + new_hop = Ax25::ImmutableHop.from_raw(hop, strict_entity: strict_entity, strict_ssid: strict_ssid) end new_path_array << new_hop end diff --git a/spec/ax25/frame/entity_spec.rb b/spec/ax25/frame/entity_spec.rb index 7cede04be0f98e4776837b477ab192ad073907a3..ca4a185dc52d69963cdebddef68385569b2fbe27 100644 --- a/spec/ax25/frame/entity_spec.rb +++ b/spec/ax25/frame/entity_spec.rb @@ -29,7 +29,7 @@ BAD_HIGHSSID_ENTITY_SSID = 16 class AddressEquiv public - def callsign + def entity return "WI2ARD" end @@ -41,151 +41,151 @@ end describe Ax25::Address do describe ".new" do - context "Given a valid callsign with ssid" do + context "Given a valid entity with ssid" do address = Ax25::ImmutableAddress.new(BASE_ENTITY_CALLSIGN, BASE_ENTITY_SSID) it "returns a Address object with correct properties" do expect(address).not_to be_nil expect(address).to be_kind_of(Ax25::Address) end - it "set the callsign property correctly" do - expect(address.callsign).to eql(BASE_ENTITY_CALLSIGN) + it "set the entity property correctly" do + expect(address.entity).to eql(BASE_ENTITY_CALLSIGN) end it "set the ssid property correctly" do expect(address.ssid).to eql(BASE_ENTITY_SSID) end - it "callsign is frozen" do - expect(address.callsign).to be_frozen + it "entity is frozen" do + expect(address.entity).to be_frozen end end - context "Given a valid callsign with nil ssid" do + context "Given a valid entity with nil ssid" do address = Ax25::ImmutableAddress.new(NOSSID_ENTITY_CALLSIGN, NOSSID_ENTITY_SSID) it "returns a Address object with correct properties" do expect(address).not_to be_nil expect(address).to be_kind_of(Ax25::Address) end - it "set the callsign property correctly" do - expect(address.callsign).to eql(NOSSID_ENTITY_CALLSIGN) + it "set the entity property correctly" do + expect(address.entity).to eql(NOSSID_ENTITY_CALLSIGN) end it "set the ssid property correctly" do expect(address.ssid).to eql(NOSSID_ENTITY_SSID) end end - context "Given a valid callsign with zero for ssid" do + context "Given a valid entity with zero for ssid" do address = Ax25::ImmutableAddress.new(ZEROSSID_ENTITY_CALLSIGN, ZEROSSID_ENTITY_SSID) it "returns a Address object with correct properties" do expect(address).not_to be_nil expect(address).to be_kind_of(Ax25::Address) end - it "set the callsign property correctly" do - expect(address.callsign).to eql(ZEROSSID_ENTITY_CALLSIGN) + it "set the entity property correctly" do + expect(address.entity).to eql(ZEROSSID_ENTITY_CALLSIGN) end it "set the ssid property correctly" do expect(address.ssid).to be_nil end end - context "Given an invalid callsign with valid ssid" do + context "Given an invalid entity with valid ssid" do it "throws an argument error" do expect { address = Ax25::ImmutableAddress.new(BAD_CALLSIGN_ENTITY_CALLSIGN, BAD_CALLSIGN_ENTITY_SSID) }.to raise_error(ArgumentError) end end - context "Given a nil callsign with valid ssid" do + context "Given a nil entity with valid ssid" do it "throws an argument error" do expect { address = Ax25::ImmutableAddress.new(nil, BASE_ENTITY_SSID) }.to raise_error(ArgumentError) end end - context "Given a non-string callsign with valid ssid" do + context "Given a non-string entity with valid ssid" do it "throws an argument error" do expect { address = Ax25::ImmutableAddress.new(5, BASE_ENTITY_SSID) }.to raise_error(ArgumentError) end end - context "Given a empty string callsign with valid ssid" do + context "Given a empty string entity with valid ssid" do it "throws an argument error" do expect { address = Ax25::ImmutableAddress.new("", BASE_ENTITY_SSID) }.to raise_error(ArgumentError) end end - context "Given a valid callsign with non-integer ssid" do + context "Given a valid entity with non-integer ssid" do it "throws an argument error" do expect { address = Ax25::ImmutableAddress.new(BASE_ENTITY_CALLSIGN, "invalid") }.to raise_error(ArgumentError) end end - context "Given a valid callsign with ssid below 0" do + context "Given a valid entity with ssid below 0" do it "throws an argument error" do expect { address = Ax25::ImmutableAddress.new(BAD_LOWSSID_ENTITY_CALLSIGN,BAD_LOWSSID_ENTITY_SSID) }.to raise_error(ArgumentError) end end - context "Given a valid callsign with ssid above 15" do + context "Given a valid entity with ssid above 15" do it "throws an argument error" do expect { address = Ax25::ImmutableAddress.new(BAD_HIGHSSID_ENTITY_CALLSIGN,BAD_HIGHSSID_ENTITY_SSID) }.to raise_error(ArgumentError) end end - context "Given a lowercase callsign with valid ssid" do + context "Given a lowercase entity with valid ssid" do address = Ax25::ImmutableAddress.new("wi2ard", 2) - it "converts the callsign to uppercase" do - expect(address.callsign).to eql("WI2ARD") + it "converts the entity to uppercase" do + expect(address.entity).to eql("WI2ARD") end end - context "Given a callsign with extra spaces before and after and valid ssid" do + context "Given a entity with extra spaces before and after and valid ssid" do address = Ax25::ImmutableAddress.new(" WI2ARD ", 2) it "strips the extra spaces" do - expect(address.callsign).to eql("WI2ARD") + expect(address.entity).to eql("WI2ARD") end end end describe ".from_raw" do - context "Given a valid callsign with ssid" do + context "Given a valid entity with ssid" do address = Ax25::ImmutableAddress.from_raw(BASE_ENTITY) it "returns a Address object" do expect(address).not_to be_nil expect(address).to be_kind_of(Ax25::Address) end - it "set the callsign correctly" do - expect(address.callsign).to eql(BASE_ENTITY_CALLSIGN) + it "set the entity correctly" do + expect(address.entity).to eql(BASE_ENTITY_CALLSIGN) end it "set the ssid correctly" do expect(address.ssid).to eql(BASE_ENTITY_SSID) end end - context "Given a valid callsign with 0 ssid" do + context "Given a valid entity with 0 ssid" do address = Ax25::ImmutableAddress.from_raw(ZEROSSID_ENTITY) it "returns a FrameAddress object" do expect(address).not_to be_nil expect(address).to be_kind_of(Ax25::Address) end - it "the callsign field was parssed correctly" do - expect(address.callsign).to eql(ZEROSSID_ENTITY_CALLSIGN) + it "the entity field was parssed correctly" do + expect(address.entity).to eql(ZEROSSID_ENTITY_CALLSIGN) end it "the ssid field was parssed correctly" do expect(address.ssid).to be_nil end end - context "Given a valid callsign with no ssid" do + context "Given a valid entity with no ssid" do address = Ax25::ImmutableAddress.from_raw(NOSSID_ENTITY) it "returns a FrameAddress object" do expect(address).not_to be_nil expect(address).to be_kind_of(Ax25::Address) end - it "the callsign field was parssed correctly" do - expect(address.callsign).to eql(NOSSID_ENTITY_CALLSIGN) + it "the entity field was parssed correctly" do + expect(address.entity).to eql(NOSSID_ENTITY_CALLSIGN) end it "the ssid field was parssed correctly" do expect(address.ssid).to eql(NOSSID_ENTITY_SSID) end end - context "Given an invalid callsign with valid ssid" do + context "Given an invalid entity with valid ssid" do it "throws an argument error" do expect { address = Ax25::ImmutableAddress.from_raw(BAD_CALLSIGN_ENTITY) @@ -214,37 +214,37 @@ describe Ax25::Address do end end end - describe ".callsign" do - context "Given a Address with valid callsign and with an ssid" do + describe ".entity" do + context "Given a Address with valid entity and with an ssid" do address = Ax25::ImmutableAddress.from_raw(BASE_ENTITY) - it "then the callsign should be frozen" do - expect(address.callsign).to be_frozen + it "then the entity should be frozen" do + expect(address.entity).to be_frozen end end - context "Given a Address with valid callsign and without an ssid" do + context "Given a Address with valid entity and without an ssid" do address = Ax25::ImmutableAddress.from_raw(NOSSID_ENTITY) - it "then the callsign should be frozen" do - expect(address.callsign).to be_frozen + it "then the entity should be frozen" do + expect(address.entity).to be_frozen end end context "Given any valid Address" do address = Ax25::ImmutableAddress.from_raw(BASE_ENTITY) it "then we should not be able to set a value" do expect { - address.callsign = "BAD1B" + address.entity = "BAD1B" }.to raise_error(NoMethodError) end it "then we should not be able to alter a value" do expect { - address.callsign << "XX" + address.entity << "XX" }.to raise_error(FrozenError) end - it "then the callsign passed to from_raw should be duplicated" do + it "then the entity passed to from_raw should be duplicated" do passed_call = "WI2AR" orig_call = passed_call.dup.freeze address = Ax25::ImmutableAddress.from_raw(passed_call) passed_call << "D" - expect(address.callsign).to eql(orig_call) + expect(address.entity).to eql(orig_call) expect(passed_call).to eql("WI2ARD") expect(orig_call).to eql("WI2AR") end @@ -293,31 +293,31 @@ describe Ax25::Address do end end describe ".to_s" do - context "Given a raw string with valid callsign with ssid" do + context "Given a raw string with valid entity with ssid" do address = Ax25::ImmutableAddress.from_raw(BASE_ENTITY) it "then we should produce the correct string" do expect(address.to_s).to eql(BASE_ENTITY) end end - context "Given a raw string with valid callsign with ssid of zero" do + context "Given a raw string with valid entity with ssid of zero" do address = Ax25::ImmutableAddress.from_raw(ZEROSSID_ENTITY) it "then we should produce the correct string" do expect(address.to_s).to eql(NOSSID_ENTITY) end end - context "Given a raw string with valid callsign without ssid" do + context "Given a raw string with valid entity without ssid" do address = Ax25::ImmutableAddress.from_raw(NOSSID_ENTITY) it "then we should produce the correct string" do expect(address.to_s).to eql(NOSSID_ENTITY) end end - context "Given a FrameAddress from new with valid callsign with non-zero ssid" do + context "Given a FrameAddress from new with valid entity with non-zero ssid" do address = Ax25::ImmutableAddress.new(BASE_ENTITY_CALLSIGN, BASE_ENTITY_SSID) it "then we should produce the correct string" do expect(address.to_s).to eql(BASE_ENTITY) end end - context "Given a FrameAddress from new with valid callsign with ssid of 0" do + context "Given a FrameAddress from new with valid entity with ssid of 0" do address = Ax25::ImmutableAddress.new(ZEROSSID_ENTITY_CALLSIGN, ZEROSSID_ENTITY_SSID) it "then we should produce the correct string" do expect(address.to_s).to eql(NOSSID_ENTITY) diff --git a/spec/ax25/frame/hop_spec.rb b/spec/ax25/frame/hop_spec.rb index 3f0d2be3b8400d81da4b27ac28df2690427a2215..6dc667f993f33d7257f3e7e4969996e16d49e601 100644 --- a/spec/ax25/frame/hop_spec.rb +++ b/spec/ax25/frame/hop_spec.rb @@ -50,7 +50,7 @@ BAD_HIGHSSID_HOP_SEEN = true class HopEquiv public - def callsign + def entity return "WI2ARD" end @@ -67,14 +67,14 @@ end describe Ax25::Hop do describe ".new" do - context "Given a valid callsign with ssid and with seen flag" do + context "Given a valid entity with ssid and with seen flag" do hop = Ax25::ImmutableHop.new(BASE_HOP_CALLSIGN, BASE_HOP_SSID, BASE_HOP_SEEN) it "returns a FrameHop object with correct properties" do expect(hop).not_to be_nil expect(hop).to be_kind_of(Ax25::Hop) end - it "set the callsign property correctly" do - expect(hop.callsign).to eql(BASE_HOP_CALLSIGN) + it "set the entity property correctly" do + expect(hop.entity).to eql(BASE_HOP_CALLSIGN) end it "set the ssid property correctly" do expect(hop.ssid).to eql(BASE_HOP_SSID) @@ -83,14 +83,14 @@ describe Ax25::Hop do expect(hop.seen?).to eql(BASE_HOP_SEEN) end end - context "Given a valid callsign with nil ssid and with seen flag" do + context "Given a valid entity with nil ssid and with seen flag" do hop = Ax25::ImmutableHop.new(NOSSID_HOP_CALLSIGN, NOSSID_HOP_SSID, NOSSID_HOP_SEEN) it "returns a FrameHop object with correct properties" do expect(hop).not_to be_nil expect(hop).to be_kind_of(Ax25::Hop) end - it "set the callsign property correctly" do - expect(hop.callsign).to eql(NOSSID_HOP_CALLSIGN) + it "set the entity property correctly" do + expect(hop.entity).to eql(NOSSID_HOP_CALLSIGN) end it "set the ssid property correctly" do expect(hop.ssid).to eql(NOSSID_HOP_SSID) @@ -99,14 +99,14 @@ describe Ax25::Hop do expect(hop.seen?).to eql(NOSSID_HOP_SEEN) end end - context "Given a valid callsign with zero for ssid and with seen flag" do + context "Given a valid entity with zero for ssid and with seen flag" do hop = Ax25::ImmutableHop.new(ZEROSSID_HOP_CALLSIGN, ZEROSSID_HOP_SSID, ZEROSSID_HOP_SEEN) it "returns a FrameHop object with correct properties" do expect(hop).not_to be_nil expect(hop).to be_kind_of(Ax25::Hop) end - it "set the callsign property correctly" do - expect(hop.callsign).to eql(ZEROSSID_HOP_CALLSIGN) + it "set the entity property correctly" do + expect(hop.entity).to eql(ZEROSSID_HOP_CALLSIGN) end it "set the ssid property correctly" do expect(hop.ssid).to be_nil @@ -115,91 +115,91 @@ describe Ax25::Hop do expect(hop.seen?).to eql(ZEROSSID_HOP_SEEN) end end - context "Given an invalid callsign with valid ssid and valid seen flag" do + context "Given an invalid entity with valid ssid and valid seen flag" do it "throws an argument error" do expect { hop = Ax25::ImmutableHop.new(BAD_CALLSIGN_HOP_CALLSIGN, BAD_CALLSIGN_HOP_SSID, BAD_CALLSIGN_HOP_SEEN) }.to raise_error(ArgumentError) end end - context "Given a nil callsign with valid ssid and valid seen flag" do + context "Given a nil entity with valid ssid and valid seen flag" do it "throws an argument error" do expect { hop = Ax25::ImmutableHop.new(nil, BASE_HOP_SSID, BASE_HOP_SEEN) }.to raise_error(ArgumentError) end end - context "Given a valid callsign with valid ssid and nil seen flag" do + context "Given a valid entity with valid ssid and nil seen flag" do it "throws an argument error" do expect { hop = Ax25::ImmutableHop.new(BASE_HOP_CALLSIGN, BASE_HOP_SSID, nil) }.to raise_error(ArgumentError) end end - context "Given a non-string callsign with valid ssid and valid seen flag" do + context "Given a non-string entity with valid ssid and valid seen flag" do it "throws an argument error" do expect { hop = Ax25::ImmutableHop.new(5, BASE_HOP_SSID, BASE_HOP_SEEN) }.to raise_error(ArgumentError) end end - context "Given a empty string callsign with valid ssid and valid seen flag" do + context "Given a empty string entity with valid ssid and valid seen flag" do it "throws an argument error" do expect { hop = Ax25::ImmutableHop.new("", BASE_HOP_SSID, BASE_HOP_SEEN) }.to raise_error(ArgumentError) end end - context "Given a valid callsign with non-integer ssid and valid seen flag" do + context "Given a valid entity with non-integer ssid and valid seen flag" do it "throws an argument error" do expect { hop = Ax25::ImmutableHop.new(BASE_HOP_CALLSIGN, "invalid", BASE_HOP_SEEN) }.to raise_error(ArgumentError) end end - context "Given a valid callsign with valid ssid and non-boolean seen flag" do + context "Given a valid entity with valid ssid and non-boolean seen flag" do it "throws an argument error" do expect { hop = Ax25::ImmutableHop.new(BASE_HOP_CALLSIGN,BASE_HOP_SSID, "invalid") }.to raise_error(ArgumentError) end end - context "Given a valid callsign with ssid below 0 and valid seen flag" do + context "Given a valid entity with ssid below 0 and valid seen flag" do it "throws an argument error" do expect { hop = Ax25::ImmutableHop.new(BAD_LOWSSID_HOP_CALLSIGN,BAD_LOWSSID_HOP_SSID, BAD_LOWSSID_HOP_SEEN) }.to raise_error(ArgumentError) end end - context "Given a valid callsign with ssid above 15 and valid seen flag" do + context "Given a valid entity with ssid above 15 and valid seen flag" do it "throws an argument error" do expect { hop = Ax25::ImmutableHop.new(BAD_HIGHSSID_HOP_CALLSIGN,BAD_HIGHSSID_HOP_SSID, BAD_HIGHSSID_HOP_SEEN) }.to raise_error(ArgumentError) end end - context "Given a lowercase callsign with valid ssid and valid seen flag" do + context "Given a lowercase entity with valid ssid and valid seen flag" do hop = Ax25::ImmutableHop.new("wi2ard", 2, true) - it "converts the callsign to uppercase" do - expect(hop.callsign).to eql("WI2ARD") + it "converts the entity to uppercase" do + expect(hop.entity).to eql("WI2ARD") end end - context "Given a callsign with extra spaces before and after and valid ssid and valid seen flag" do + context "Given a entity with extra spaces before and after and valid ssid and valid seen flag" do hop = Ax25::ImmutableHop.new(" WI2ARD ", 2, true) it "strips the extra spaces" do - expect(hop.callsign).to eql("WI2ARD") + expect(hop.entity).to eql("WI2ARD") end end end describe ".from_raw" do - context "Given a valid callsign with ssid and with seen flag" do + context "Given a valid entity with ssid and with seen flag" do hop = Ax25::ImmutableHop.from_raw(BASE_HOP) it "returns a FrameHop object" do expect(hop).not_to be_nil expect(hop).to be_kind_of(Ax25::Hop) end - it "set the callsign correctly" do - expect(hop.callsign).to eql(BASE_HOP_CALLSIGN) + it "set the entity correctly" do + expect(hop.entity).to eql(BASE_HOP_CALLSIGN) end it "set the ssid correctly" do expect(hop.ssid).to eql(BASE_HOP_SSID) @@ -208,14 +208,14 @@ describe Ax25::Hop do expect(hop.seen?).to eql(BASE_HOP_SEEN) end end - context "Given a valid callsign with ssid and without seen flag" do + context "Given a valid entity with ssid and without seen flag" do hop = Ax25::ImmutableHop.from_raw(UNSEEN_HOP) it "returns a FrameHop object" do expect(hop).not_to be_nil expect(hop).to be_kind_of(Ax25::Hop) end - it "the callsign field was parssed correctly" do - expect(hop.callsign).to eql(UNSEEN_HOP_CALLSIGN) + it "the entity field was parssed correctly" do + expect(hop.entity).to eql(UNSEEN_HOP_CALLSIGN) end it "the ssid field was parssed correctly" do expect(hop.ssid).to eql(UNSEEN_HOP_SSID) @@ -224,14 +224,14 @@ describe Ax25::Hop do expect(hop.seen?).to eql(UNSEEN_HOP_SEEN) end end - context "Given a valid callsign with 0 ssid and with seen flag" do + context "Given a valid entity with 0 ssid and with seen flag" do hop = Ax25::ImmutableHop.from_raw(ZEROSSID_HOP) it "returns a FrameHop object" do expect(hop).not_to be_nil expect(hop).to be_kind_of(Ax25::Hop) end - it "the callsign field was parssed correctly" do - expect(hop.callsign).to eql(ZEROSSID_HOP_CALLSIGN) + it "the entity field was parssed correctly" do + expect(hop.entity).to eql(ZEROSSID_HOP_CALLSIGN) end it "the ssid field was parssed correctly" do expect(hop.ssid).to be_nil @@ -240,14 +240,14 @@ describe Ax25::Hop do expect(hop.seen?).to eql(ZEROSSID_HOP_SEEN) end end - context "Given a valid callsign with nil ssid and with seen flag" do + context "Given a valid entity with nil ssid and with seen flag" do hop = Ax25::ImmutableHop.from_raw(NOSSID_HOP) it "returns a FrameHop object" do expect(hop).not_to be_nil expect(hop).to be_kind_of(Ax25::Hop) end - it "the callsign field was parssed correctly" do - expect(hop.callsign).to eql(NOSSID_HOP_CALLSIGN) + it "the entity field was parssed correctly" do + expect(hop.entity).to eql(NOSSID_HOP_CALLSIGN) end it "the ssid field was parssed correctly" do expect(hop.ssid).to eql(NOSSID_HOP_SSID) @@ -256,14 +256,14 @@ describe Ax25::Hop do expect(hop.seen?).to eql(NOSSID_HOP_SEEN) end end - context "Given a valid callsign without ssid and without seen flag" do + context "Given a valid entity without ssid and without seen flag" do hop = Ax25::ImmutableHop.from_raw(NOSSID_UNSEEN_HOP) it "returns a FrameHop object" do expect(hop).not_to be_nil expect(hop).to be_kind_of(Ax25::Hop) end - it "the callsign field was parssed correctly" do - expect(hop.callsign).to eql(NOSSID_UNSEEN_HOP_CALLSIGN) + it "the entity field was parssed correctly" do + expect(hop.entity).to eql(NOSSID_UNSEEN_HOP_CALLSIGN) end it "the ssid field was parssed correctly" do expect(hop.ssid).to eql(NOSSID_UNSEEN_HOP_SSID) @@ -272,7 +272,7 @@ describe Ax25::Hop do expect(hop.seen?).to eql(NOSSID_UNSEEN_HOP_SEEN) end end - context "Given an invalid callsign with valid ssid and valid seen flag" do + context "Given an invalid entity with valid ssid and valid seen flag" do it "throws an argument error" do expect { hop = Ax25::ImmutableHop.from_raw(BAD_CALLSIGN_HOP) @@ -301,37 +301,37 @@ describe Ax25::Hop do end end end - describe ".callsign" do - context "Given a FrameHop with valid callsign and with an ssid" do + describe ".entity" do + context "Given a FrameHop with valid entity and with an ssid" do hop = Ax25::ImmutableHop.from_raw(BASE_HOP) - it "then the callsign should be frozen" do - expect(hop.callsign).to be_frozen + it "then the entity should be frozen" do + expect(hop.entity).to be_frozen end end - context "Given a FrameHop with valid callsign and without an ssid" do + context "Given a FrameHop with valid entity and without an ssid" do hop = Ax25::ImmutableHop.from_raw(NOSSID_HOP) - it "then the callsign should be frozen" do - expect(hop.callsign).to be_frozen + it "then the entity should be frozen" do + expect(hop.entity).to be_frozen end end context "Given any valid FrameHop" do hop = Ax25::ImmutableHop.from_raw(BASE_HOP) it "then we should not be able to set a value" do expect { - hop.callsign = "BAD1B" + hop.entity = "BAD1B" }.to raise_error(NoMethodError) end it "then we should not be able to alter a value" do expect { - hop.callsign << "XX" + hop.entity << "XX" }.to raise_error(FrozenError) end - it "then the callsign passed to from_raw should be duplicated" do + it "then the entity passed to from_raw should be duplicated" do passed_call = "WI2AR" orig_call = passed_call.dup.freeze hop = Ax25::ImmutableHop.from_raw(passed_call) passed_call << "D" - expect(hop.callsign).to eql(orig_call) + expect(hop.entity).to eql(orig_call) expect(passed_call).to eql("WI2ARD") expect(orig_call).to eql("WI2AR") end @@ -422,67 +422,67 @@ describe Ax25::Hop do end end describe ".to_s" do - context "Given a raw string with valid callsign with ssid and with seen flag" do + context "Given a raw string with valid entity with ssid and with seen flag" do hop = Ax25::ImmutableHop.from_raw(BASE_HOP) it "then we should produce the correct string" do expect(hop.to_s).to eql(BASE_HOP) end end - context "Given a raw string with valid callsign with non-zero ssid and without seen flag" do + context "Given a raw string with valid entity with non-zero ssid and without seen flag" do hop = Ax25::ImmutableHop.from_raw(UNSEEN_HOP) it "then we should produce the correct string" do expect(hop.to_s).to eql(UNSEEN_HOP) end end - context "Given a raw string with valid callsign with ssid of zero and without seen flag" do + context "Given a raw string with valid entity with ssid of zero and without seen flag" do hop = Ax25::ImmutableHop.from_raw(ZEROSSID_HOP) it "then we should produce the correct string" do expect(hop.to_s).to eql(NOSSID_HOP) end end - context "Given a raw string with valid callsign without ssid and with seen flag" do + context "Given a raw string with valid entity without ssid and with seen flag" do hop = Ax25::ImmutableHop.from_raw(NOSSID_HOP) it "then we should produce the correct string" do expect(hop.to_s).to eql(NOSSID_HOP) end end - context "Given a raw string with valid callsign without ssid and without seen flag" do + context "Given a raw string with valid entity without ssid and without seen flag" do hop = Ax25::ImmutableHop.from_raw(NOSSID_UNSEEN_HOP) it "then we should produce the correct string" do expect(hop.to_s).to eql(NOSSID_UNSEEN_HOP) end end - context "Given a raw string with valid callsign with ssid of 0 and without seen flag" do + context "Given a raw string with valid entity with ssid of 0 and without seen flag" do hop = Ax25::ImmutableHop.from_raw(ZEROSSID_UNSEEN_HOP) it "then we should produce the correct string" do expect(hop.to_s).to eql(NOSSID_UNSEEN_HOP) end end - context "Given a FrameHop from new with valid callsign with non-zero ssid and with seen flag" do + context "Given a FrameHop from new with valid entity with non-zero ssid and with seen flag" do hop = Ax25::ImmutableHop.new(BASE_HOP_CALLSIGN, BASE_HOP_SSID, BASE_HOP_SEEN) it "then we should produce the correct string" do expect(hop.to_s).to eql(BASE_HOP) end end - context "Given a FrameHop from new with valid callsign with non-zero ssid and without seen flag" do + context "Given a FrameHop from new with valid entity with non-zero ssid and without seen flag" do hop = Ax25::ImmutableHop.new(UNSEEN_HOP_CALLSIGN, UNSEEN_HOP_SSID, UNSEEN_HOP_SEEN) it "then we should produce the correct string" do expect(hop.to_s).to eql(UNSEEN_HOP) end end - context "Given a FrameHop from new with valid callsign with nil ssid and with seen flag" do + context "Given a FrameHop from new with valid entity with nil ssid and with seen flag" do hop = Ax25::ImmutableHop.new(NOSSID_HOP_CALLSIGN, NOSSID_HOP_SSID, NOSSID_HOP_SEEN) it "then we should produce the correct string" do expect(hop.to_s).to eql(NOSSID_HOP) end end - context "Given a FrameHop from new with valid callsign with ssid of 0 and with seen flag" do + context "Given a FrameHop from new with valid entity with ssid of 0 and with seen flag" do hop = Ax25::ImmutableHop.new(ZEROSSID_HOP_CALLSIGN, ZEROSSID_HOP_SSID, ZEROSSID_HOP_SEEN) it "then we should produce the correct string" do expect(hop.to_s).to eql(NOSSID_HOP) end end - context "Given a FrameHop from new with valid callsign with ssid of zero and without seen flag" do + context "Given a FrameHop from new with valid entity with ssid of zero and without seen flag" do hop = Ax25::ImmutableHop.new(ZEROSSID_UNSEEN_HOP_CALLSIGN, ZEROSSID_UNSEEN_HOP_SSID, ZEROSSID_UNSEEN_HOP_SEEN) it "then we should produce the correct string" do expect(hop.to_s).to eql(NOSSID_UNSEEN_HOP)