diff --git a/CHANGELOG.md b/CHANGELOG.md index 420388e907ab7d58f9fbc3ebb81d6d0a645d5400..30ea40de4ccc00c508e17278c61c167f239d13ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,32 +1,5 @@ # Changelog -## 2.0.0 - -* Refactored handling of Frames completely, no longer backwards compatible. -* Frames now use interfaces and immutable implementations for type safety. -* Added Path, Entity, and Hop class for handling the pathing portion of frames. -* Moved unit tests over to RSpec -* Added testing with significant coverage -* Fixed IGate so it wont get stuck in an infinite loop when receiving data faster than it can process -* Added EMPTY_PATH constant to represent a path with 0 hops. - -## 1.0.4 - -* Frames are now classes rather than a map -* Added mechanism for comparing frames for equivalence. - -## 1.0.3 - -* Implemented the IGateTcp class for handling internet gateways. - -## 1.0.2 - -* Updates to dependencies only. - -## 1.0.1 - -* Updates to dependencies only. - -## 1.0.0 +## 0.0.1 * Initial release diff --git a/Gemfile b/Gemfile index 3e25c3c0d072f6ea4eaeaba1bdb46aef304ed943..fa75df15632305f9badb9a7ac0028e4b2ef4d221 100644 --- a/Gemfile +++ b/Gemfile @@ -1,4 +1,3 @@ source 'https://rubygems.org' -# Specify your gem's dependencies in apex.gemspec gemspec diff --git a/README.md b/README.md index add447d44fbef1891478da7c0023ce27249a3a78..0d0efcd4aa25db9d00b7b605b1bc843dacc1fa80 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# APRS +# AX.25 -Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/apex`. To experiment with that code, run `bin/console` for an interactive prompt. +Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/ax25`. To experiment with that code, run `bin/console` for an interactive prompt. TODO: Delete this and the text above, and describe your gem @@ -9,7 +9,7 @@ TODO: Delete this and the text above, and describe your gem Add this line to your application's Gemfile: ```ruby -gem 'apex-aprs' +gem 'ax25' ``` And then execute: @@ -18,7 +18,7 @@ And then execute: Or install it yourself as: - $ gem install apex-aprs + $ gem install ax25 ## Usage @@ -41,9 +41,9 @@ bundle install then run the tests with: ```bash -bundle exec rake test +bundle exec rspec ``` ## Contributing -Bug reports and pull requests are welcome on Git at https://git.qoto.org/digipex/apex-aprs +Bug reports and pull requests are welcome on Git at https://git.qoto.org/digipex/ax25 diff --git a/README.rdoc b/README.rdoc deleted file mode 100644 index 0a09a724a0af7f58f1623e20005cf64d19ac074f..0000000000000000000000000000000000000000 --- a/README.rdoc +++ /dev/null @@ -1,19 +0,0 @@ -= apex - DESCRIBE YOUR GEM - -Author:: Jeffrey Phillips Freeman (freemo@gmail.com) -Copyright:: Copyright (c) 2016 Syncleus - - -DESCRIBE YOUR GEM HERE - -== Links - -* {Source on Github}[https://github.com/Syncleus/aprs] -* RDoc[LINK TO RDOC.INFO] - -== Install - -== Examples - -== Contributing - diff --git a/apex-aprs.gemspec b/ax25.gemspec similarity index 69% rename from apex-aprs.gemspec rename to ax25.gemspec index 9b69ce3c2293cbdc91716640c9802be1475281e7..20082a7c74f7d5e221f5da10576a863cec792cb1 100644 --- a/apex-aprs.gemspec +++ b/ax25.gemspec @@ -1,18 +1,18 @@ # coding: utf-8 lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require 'apex/app_info' +require 'ax25/app_info' Gem::Specification.new do |spec| - spec.name = 'apex-aprs' - spec.version = Apex::VERSION + spec.name = 'ax25' + spec.version = Ax25::VERSION spec.licenses = ['Apache-2.0'] spec.authors = ['Jeffrey Phillips Freeman'] - spec.email = ['jeffrey.freeman@syncleus.com'] + spec.email = ['the@jeffreyfreeman.me'] - spec.summary = %q{Library for APRS, Automatic Packet Reporting System, communications including the next-generation APEX extensions. Includes an APRS-IS client.} - spec.description = %q{Ruby library for APRS, Automatic Packet Reporting System, communications including the next-generation APEX extensions. Includes an APRS-IS client.} - spec.homepage = 'https://git.qoto.org/digipex/apex-aprs' + spec.summary = %q{A library implementing a complete implementation of the AX.25 v2.2 protocol.} + spec.description = %q{A library implementing a complete implementation of the AX.25 v2.2 protocol.} + spec.homepage = 'https://git.qoto.org/digipex/ax25' # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host' # to allow pushing to a single host or delete this section to allow pushing to any host. @@ -25,13 +25,13 @@ Gem::Specification.new do |spec| spec.files = `git ls-files -z`.split("\x0").reject do |f| f.match(%r{^(test|spec|features)/}) end - spec.bindir = 'exe' + spec.bindir = 'bin' spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } spec.require_paths = ['lib'] spec.add_dependency 'abstractify', '~> 1.1' spec.add_dependency 'json', '~> 2.5' - spec.add_dependency 'kiss-tnc', '~> 2.1' + spec.add_dependency 'kiss-tnc', '~> 3.0' spec.add_development_dependency 'bundler', '~> 2.2' spec.add_development_dependency 'rake', '~> 13.0' spec.add_development_dependency 'rspec', '~> 3.12' diff --git a/lib/apex.rb b/lib/apex.rb deleted file mode 100644 index 0b2e392f890b4587d45079da165020478891bcf7..0000000000000000000000000000000000000000 --- a/lib/apex.rb +++ /dev/null @@ -1,3 +0,0 @@ -require 'apex/encoder' -require 'apex/frame' -require 'apex/app_info' diff --git a/lib/apex/app_info.rb b/lib/apex/app_info.rb deleted file mode 100644 index 9e3e8c91772a3462c10a0f9811aeaf91ed4883c1..0000000000000000000000000000000000000000 --- a/lib/apex/app_info.rb +++ /dev/null @@ -1,3 +0,0 @@ -module Apex - VERSION = "2.0.0" -end diff --git a/lib/apex/encoder.rb b/lib/apex/encoder.rb deleted file mode 100644 index b1585810f530ee084c04bb1cf02c9e62f11c9453..0000000000000000000000000000000000000000 --- a/lib/apex/encoder.rb +++ /dev/null @@ -1,3 +0,0 @@ -require 'apex/encoder/aprs_kiss' -require 'apex/encoder/igate_tcp' -require 'apex/encoder/encoder' diff --git a/lib/apex/frame.rb b/lib/apex/frame.rb deleted file mode 100644 index 1d729a565578badd1ed510ca63e73f6698ad8747..0000000000000000000000000000000000000000 --- a/lib/apex/frame.rb +++ /dev/null @@ -1,11 +0,0 @@ -require 'apex/frame/immutable_frame' -require 'apex/frame/entity' -require 'apex/frame/immutable_entity' -require 'apex/frame/hop' -require 'apex/frame/immutable_hop' -require 'apex/frame/path' -require 'apex/frame/immutable_path' -require 'apex/frame/immutable_message' -require 'apex/frame/path_agnostic_immutable_frame' -require 'apex/frame/message' -require 'apex/frame/frame' diff --git a/lib/ax25.rb b/lib/ax25.rb new file mode 100644 index 0000000000000000000000000000000000000000..fa7ae4b44ec72de3416eb93931faf228abadcf8b --- /dev/null +++ b/lib/ax25.rb @@ -0,0 +1,3 @@ +require 'ax25/encoder' +require 'ax25/frame' +require 'ax25/app_info' diff --git a/lib/ax25/app_info.rb b/lib/ax25/app_info.rb new file mode 100644 index 0000000000000000000000000000000000000000..43818c2bb953ac2ab7a2c7f21d8dfe2e82806f43 --- /dev/null +++ b/lib/ax25/app_info.rb @@ -0,0 +1,3 @@ +module Ax25 + VERSION = "0.0.1" +end diff --git a/lib/ax25/encoder.rb b/lib/ax25/encoder.rb new file mode 100644 index 0000000000000000000000000000000000000000..e132c1e9629d621792a503bccb1efb275d9f9c84 --- /dev/null +++ b/lib/ax25/encoder.rb @@ -0,0 +1,3 @@ +require 'ax25/encoder/aprs_kiss' +require 'ax25/encoder/igate_tcp' +require 'ax25/encoder/encoder' diff --git a/lib/apex/encoder/aprs_kiss.rb b/lib/ax25/encoder/aprs_kiss.rb similarity index 81% rename from lib/apex/encoder/aprs_kiss.rb rename to lib/ax25/encoder/aprs_kiss.rb index 1f7f3ff6c5feb795dfd2e992dbbd0e8dfed9cbf3..76c067b2811a4d760685bc18b04f7a32179592d5 100644 --- a/lib/apex/encoder/aprs_kiss.rb +++ b/lib/ax25/encoder/aprs_kiss.rb @@ -1,8 +1,8 @@ -require 'apex/frame' +require 'ax25/frame' require 'kiss' -require 'apex/encoder/encoder' +require 'ax25/encoder/encoder' -module Apex +module Ax25 class AprsKiss include Encoder @@ -34,12 +34,12 @@ module Apex frame_map = @data_stream.read return nil if frame_map.nil? - source = Apex::ImmutableEntity.from_raw(frame_map[:source]) - destination = Apex::ImmutableEntity.from_raw(frame_map[:destination]) + source = Ax25::ImmutableEntity.from_raw(frame_map[:source]) + destination = Ax25::ImmutableEntity.from_raw(frame_map[:destination]) - path = Apex::ImmutablePath.from_raw(frame_map[:path]) + path = Ax25::ImmutablePath.from_raw(frame_map[:path]) - return Apex::ImmutableFrame.new(source, destination, path, frame_map[:payload]) + return Ax25::ImmutableFrame.new(source, destination, path, frame_map[:payload]) end public diff --git a/lib/apex/encoder/encoder.rb b/lib/ax25/encoder/encoder.rb similarity index 92% rename from lib/apex/encoder/encoder.rb rename to lib/ax25/encoder/encoder.rb index 0ac43964376cec0a65d0ab12d0b4455854ed4baa..23e2062c3ee88744ab849da542d9bd77d2f21fd3 100644 --- a/lib/apex/encoder/encoder.rb +++ b/lib/ax25/encoder/encoder.rb @@ -1,6 +1,6 @@ require 'abstractify' -module Apex +module Ax25 module Encoder include Abstractify::Abstract diff --git a/lib/apex/encoder/igate_tcp.rb b/lib/ax25/encoder/igate_tcp.rb similarity index 93% rename from lib/apex/encoder/igate_tcp.rb rename to lib/ax25/encoder/igate_tcp.rb index edd73fea87d8011bfececef73ecd4ecf487f8b28..96a8d9c14c4154abff5771a6e9d57495aa8bc5cf 100644 --- a/lib/apex/encoder/igate_tcp.rb +++ b/lib/ax25/encoder/igate_tcp.rb @@ -1,7 +1,7 @@ -require 'apex/app_info' +require 'ax25/app_info' require 'socket' -module Apex +module Ax25 class IGateTcp include Encoder @@ -13,7 +13,7 @@ module Apex def initialize(user, password=nil) @user = user password = IGateTcp.calculatePasscode(user) if password.nil? - @auth = ['user', user, 'pass', password, 'vers', "APEX #{VERSION}"].join(' ') + @auth = ['user', user, 'pass', password, 'vers', "ax25 #{VERSION}"].join(' ') @aprsis_sock = nil @data_buffer = '' @packet_buffer = [] @@ -56,12 +56,12 @@ module Apex path = path.split(',') - decoded_source = Apex::ImmutableEntity.from_raw(decoded_source, strict_callsign: false, strict_ssid: false) - decoded_destination = Apex::ImmutableEntity.from_raw(path.shift, strict_callsign: false, strict_ssid: false) - decoded_path = Apex::ImmutablePath.from_raw(path, strict_callsign: false, strict_ssid: false) + decoded_source = Ax25::ImmutableEntity.from_raw(decoded_source, strict_callsign: false, strict_ssid: false) + decoded_destination = Ax25::ImmutableEntity.from_raw(path.shift, strict_callsign: false, strict_ssid: false) + decoded_path = Ax25::ImmutablePath.from_raw(path, strict_callsign: false, strict_ssid: false) decoded_payload = frame_so_far - return Apex::ImmutableFrame.new(decoded_source, decoded_destination, decoded_path, decoded_payload) + return Ax25::ImmutableFrame.new(decoded_source, decoded_destination, decoded_path, decoded_payload) end private diff --git a/lib/ax25/frame.rb b/lib/ax25/frame.rb new file mode 100644 index 0000000000000000000000000000000000000000..1043b96fe844e30d7e84556eab04163a0ba308b3 --- /dev/null +++ b/lib/ax25/frame.rb @@ -0,0 +1,11 @@ +require 'ax25/frame/immutable_frame' +require 'ax25/frame/entity' +require 'ax25/frame/immutable_entity' +require 'ax25/frame/hop' +require 'ax25/frame/immutable_hop' +require 'ax25/frame/path' +require 'ax25/frame/immutable_path' +require 'ax25/frame/immutable_message' +require 'ax25/frame/path_agnostic_immutable_frame' +require 'ax25/frame/message' +require 'ax25/frame/frame' diff --git a/lib/apex/frame/entity.rb b/lib/ax25/frame/entity.rb similarity index 92% rename from lib/apex/frame/entity.rb rename to lib/ax25/frame/entity.rb index c43114abdaff5d73617deff49339ae2d494b33e2..2f86f9d1a7ff137c8df2d230d958d45173416639 100644 --- a/lib/apex/frame/entity.rb +++ b/lib/ax25/frame/entity.rb @@ -1,4 +1,4 @@ -module Apex +module Ax25 public module Entity include Abstractify::Abstract diff --git a/lib/apex/frame/frame.rb b/lib/ax25/frame/frame.rb similarity index 68% rename from lib/apex/frame/frame.rb rename to lib/ax25/frame/frame.rb index 6d8e3423a83dd763e2756a832d357d31b349d4f2..445c15f664ae714200e3003978cd05079107acdc 100644 --- a/lib/apex/frame/frame.rb +++ b/lib/ax25/frame/frame.rb @@ -1,18 +1,18 @@ require 'abstractify' -require 'apex/frame/message' +require 'ax25/frame/message' -module Apex +module Ax25 ## # An APXP compatible APRS frame, excluding the path data entierly. The # UnpathedFrame and all its fields are immutable. # # @example Comparing frames - # orig_frame = Apex.new('WI2ARD-1', 'OMG', ['WIDE2-2' 'WIDE1-1'], 'payload goes here') - # diff_frame = Apex.new('WI2ARD-1', 'OMG', ['WIDE2-2' 'WIDE1-1'], 'different payload') + # orig_frame = Ax25.new('WI2ARD-1', 'OMG', ['WIDE2-2' 'WIDE1-1'], 'payload goes here') + # diff_frame = Ax25.new('WI2ARD-1', 'OMG', ['WIDE2-2' 'WIDE1-1'], 'different payload') # assert not orig_frame.eql? diff_frame public module Frame - include Apex::Message + include Ax25::Message include Abstractify::Abstract abstract :path_agnostic_identity diff --git a/lib/apex/frame/hop.rb b/lib/ax25/frame/hop.rb similarity index 67% rename from lib/apex/frame/hop.rb rename to lib/ax25/frame/hop.rb index d5cf965f920fdc78cdbddd723372a57dd9e786b0..63e7fa77778ee11dfc0b9fc9bfa988dda8b1f905 100644 --- a/lib/apex/frame/hop.rb +++ b/lib/ax25/frame/hop.rb @@ -1,9 +1,9 @@ -require 'apex/frame/entity' +require 'ax25/frame/entity' -module Apex +module Ax25 public module Hop - include Apex::Entity + include Ax25::Entity include Abstractify::Abstract abstract :toggle_seen, :decrement_ssid, :==, :eql?, :to_s, :seen? diff --git a/lib/apex/frame/immutable_entity.rb b/lib/ax25/frame/immutable_entity.rb similarity index 92% rename from lib/apex/frame/immutable_entity.rb rename to lib/ax25/frame/immutable_entity.rb index 7fe078154c50318b4022dc0c90fc41549b27c636..e50830447714062a7467d0b5044165bfe9a8d581 100644 --- a/lib/apex/frame/immutable_entity.rb +++ b/lib/ax25/frame/immutable_entity.rb @@ -1,6 +1,6 @@ -require 'apex/frame/entity' +require 'ax25/frame/entity' -module Apex +module Ax25 public class ImmutableEntity include Entity @@ -48,19 +48,19 @@ module Apex ssid = split_hop[1].to_i end - return Apex::ImmutableEntity.new(callsign, ssid, strict_callsign: strict_callsign, strict_ssid: strict_ssid) + return Ax25::ImmutableEntity.new(callsign, ssid, strict_callsign: strict_callsign, 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 Apex::ImmutableEntity.new(self.callsign, self.ssid - 1, strict_callsign: false, strict_ssid: false) + return Ax25::ImmutableEntity.new(self.callsign, self.ssid - 1, strict_callsign: false, strict_ssid: false) end public def eql?(other) - raise ArgumentError.new("The argument must be of type Hop (or a child class).") if not other.kind_of? Apex::Entity + raise ArgumentError.new("The argument must be of type Hop (or a child class).") if not other.kind_of? Ax25::Entity return self == other end diff --git a/lib/apex/frame/immutable_frame.rb b/lib/ax25/frame/immutable_frame.rb similarity index 85% rename from lib/apex/frame/immutable_frame.rb rename to lib/ax25/frame/immutable_frame.rb index 44bd4f3808bfcd168ac30f00adaad09e9a88c3b0..0abbdcb62c9c66aa1143024321a040be8a62329c 100644 --- a/lib/apex/frame/immutable_frame.rb +++ b/lib/ax25/frame/immutable_frame.rb @@ -1,15 +1,15 @@ -require 'apex/frame/immutable_message' -require 'apex/frame/frame' +require 'ax25/frame/immutable_message' +require 'ax25/frame/frame' -module Apex +module Ax25 public - class ImmutableFrame < Apex::ImmutableMessage + class ImmutableFrame < Ax25::ImmutableMessage include Frame protected def initialize(source, destination, path, payload) raise ArgumentError.new("path argument can not be nil") if path.nil? - raise ArgumentError.new("path argument must be a Path, but found: " + path.class.to_s) if not path.kind_of? Apex::Path + raise ArgumentError.new("path argument must be a Path, but found: " + path.class.to_s) if not path.kind_of? Ax25::Path super(source, destination, payload) diff --git a/lib/apex/frame/immutable_hop.rb b/lib/ax25/frame/immutable_hop.rb similarity index 85% rename from lib/apex/frame/immutable_hop.rb rename to lib/ax25/frame/immutable_hop.rb index 36137655d5cc1fe7e6e4b6d0588a52e2590b9458..5bac37b74454981007f940fee9143b1d3c6114b9 100644 --- a/lib/apex/frame/immutable_hop.rb +++ b/lib/ax25/frame/immutable_hop.rb @@ -1,9 +1,9 @@ -require 'apex/frame/hop' -require 'apex/frame/immutable_entity' +require 'ax25/frame/hop' +require 'ax25/frame/immutable_entity' -module Apex +module Ax25 public - class ImmutableHop < Apex::ImmutableEntity + class ImmutableHop < Ax25::ImmutableEntity include Hop public @@ -46,7 +46,7 @@ module Apex ssid = split_hop[1].to_i end - return Apex::ImmutableHop.new(callsign, ssid, seen, strict_callsign: strict_callsign, strict_ssid: strict_ssid) + return Ax25::ImmutableHop.new(callsign, ssid, seen, strict_callsign: strict_callsign, strict_ssid: strict_ssid) end public @@ -56,19 +56,19 @@ module Apex public def toggle_seen - return Apex::ImmutableHop.new(self.callsign, self.ssid, !self.seen?, strict_callsign: false, strict_ssid: false) + return Ax25::ImmutableHop.new(self.callsign, self.ssid, !self.seen?, strict_callsign: 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 Apex::ImmutableHop.new(self.callsign, self.ssid - 1, self.seen?, strict_callsign: false, strict_ssid: false) + return Ax25::ImmutableHop.new(self.callsign, self.ssid - 1, self.seen?, strict_callsign: false, strict_ssid: false) end public def eql?(other) - raise ArgumentError.new("The argument must be of type Hop (or a child class).") if not other.kind_of? Apex::Hop + raise ArgumentError.new("The argument must be of type Hop (or a child class).") if not other.kind_of? Ax25::Hop return self == other end diff --git a/lib/apex/frame/immutable_message.rb b/lib/ax25/frame/immutable_message.rb similarity index 85% rename from lib/apex/frame/immutable_message.rb rename to lib/ax25/frame/immutable_message.rb index 4301ca6a0071ad4819d6c0c978628830dc682c20..21f6018c6bd2f5559aff50d90ac72be450e6d4e9 100644 --- a/lib/apex/frame/immutable_message.rb +++ b/lib/ax25/frame/immutable_message.rb @@ -1,13 +1,13 @@ -require 'apex/frame/message' +require 'ax25/frame/message' -module Apex +module Ax25 ## # An APXP compatible APRS frame, excluding the path data entierly. The # UnpathedFrame and all its fields are immutable. # # @example Comparing frames - # orig_frame = Apex.new('WI2ARD-1', 'OMG', ['WIDE2-2' 'WIDE1-1'], 'payload goes here') - # diff_frame = Apex.new('WI2ARD-1', 'OMG', ['WIDE2-2' 'WIDE1-1'], 'different payload') + # orig_frame = Ax25.new('WI2ARD-1', 'OMG', ['WIDE2-2' 'WIDE1-1'], 'payload goes here') + # diff_frame = Ax25.new('WI2ARD-1', 'OMG', ['WIDE2-2' 'WIDE1-1'], 'different payload') # assert not orig_frame.eql? diff_frame public class ImmutableMessage @@ -17,10 +17,10 @@ module Apex # Creates a new frame, all fields are duplicated but and immutable. All # fields are validated. # - # @param source [Apex::Entity] The source callsign for the frame. Must be a + # @param source [Ax25::Entity] The source callsign 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 [Apex::Entity] The destination callsign for the frame. Must + # @param destination [Ax25::Entity] The destination callsign 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 @@ -31,8 +31,8 @@ module Apex raise ArgumentError.new("destination argument can not be nil") if destination.nil? raise ArgumentError.new("payload argument can not be nil") if payload.nil? - raise ArgumentError.new("source argument must be a Entity, but found: " + source.class.to_s) if not source.kind_of? Apex::Entity - raise ArgumentError.new("destination argument must be a Entity, but found: " + source.class.to_s) if not destination.kind_of? Apex::Entity + raise ArgumentError.new("source argument must be a Entity, but found: " + source.class.to_s) if not source.kind_of? Ax25::Entity + raise ArgumentError.new("destination argument must be a Entity, but found: " + source.class.to_s) if not destination.kind_of? Ax25::Entity raise ArgumentError.new("payload argument must be a string, but found: " + source.class.to_s) if not payload.kind_of? String # The following both duplicate/clone the argument and convert it to uppercase @@ -43,7 +43,7 @@ module Apex public def path_agnostic_eql?(other) - raise ArgumentError.new("The argument must be either an ImmutableMessage or a PathAgnosticFrame") if not ((other.instance_of? Apex::ImmutableMessage) || (other.instance_of? Apex::PathAgnosticImmutableFrame)) + raise ArgumentError.new("The argument must be either an ImmutableMessage or a PathAgnosticFrame") if not ((other.instance_of? Ax25::ImmutableMessage) || (other.instance_of? Ax25::PathAgnosticImmutableFrame)) return self.path_agnostic_equality? other end diff --git a/lib/apex/frame/immutable_path.rb b/lib/ax25/frame/immutable_path.rb similarity index 90% rename from lib/apex/frame/immutable_path.rb rename to lib/ax25/frame/immutable_path.rb index b04cf390c80070149f5ca86b4f2ef410b161776d..4e965fbe6e5d109deea2be7c644049a874923bdc 100644 --- a/lib/apex/frame/immutable_path.rb +++ b/lib/ax25/frame/immutable_path.rb @@ -1,7 +1,7 @@ -require 'apex/frame/hop' -require 'apex/frame/path' +require 'ax25/frame/hop' +require 'ax25/frame/path' -module Apex +module Ax25 public class ImmutablePath @@ -13,7 +13,7 @@ module Apex last_seen = true hops.each do |hop| raise ArgumentError.new("All arguments must not be nil: #{hops.to_s}") if (hop.nil?) - raise ArgumentError.new("All arguments must be of type Hop: #{hops.class.to_s}") if not hop.kind_of? Apex::Hop + raise ArgumentError.new("All arguments must be of type Hop: #{hops.class.to_s}") if not hop.kind_of? Ax25::Hop last_seen = false if not hop.seen? @path_array << hop end @@ -40,15 +40,15 @@ module Apex new_path_array = [] raw_path.each do |hop| - if hop.kind_of? Apex::Hop + if hop.kind_of? Ax25::Hop new_hop = hop else - new_hop = Apex::ImmutableHop.from_raw(hop, strict_callsign: strict_callsign, strict_ssid: strict_ssid) + new_hop = Ax25::ImmutableHop.from_raw(hop, strict_callsign: strict_callsign, strict_ssid: strict_ssid) end new_path_array << new_hop end - return Apex::ImmutablePath.new(*new_path_array) + return Ax25::ImmutablePath.new(*new_path_array) end public diff --git a/lib/apex/frame/message.rb b/lib/ax25/frame/message.rb similarity index 78% rename from lib/apex/frame/message.rb rename to lib/ax25/frame/message.rb index e72dc0fa63a5298f1a817006a5fa3e05abf6cee8..52ab20a1fd7103bfd6e79102d96e8883600064ff 100644 --- a/lib/apex/frame/message.rb +++ b/lib/ax25/frame/message.rb @@ -1,13 +1,13 @@ require 'abstractify' -module Apex +module Ax25 ## # An APXP compatible APRS frame, excluding the path data entierly. The # UnpathedFrame and all its fields are immutable. # # @example Comparing frames - # orig_frame = Apex.new('WI2ARD-1', 'OMG', ['WIDE2-2' 'WIDE1-1'], 'payload goes here') - # diff_frame = Apex.new('WI2ARD-1', 'OMG', ['WIDE2-2' 'WIDE1-1'], 'different payload') + # orig_frame = Ax25.new('WI2ARD-1', 'OMG', ['WIDE2-2' 'WIDE1-1'], 'payload goes here') + # diff_frame = Ax25.new('WI2ARD-1', 'OMG', ['WIDE2-2' 'WIDE1-1'], 'different payload') # assert not orig_frame.eql? diff_frame public module Message diff --git a/lib/apex/frame/path.rb b/lib/ax25/frame/path.rb similarity index 92% rename from lib/apex/frame/path.rb rename to lib/ax25/frame/path.rb index 75af1dc802ddf783acd62e841220171c40ee696e..faf576ba205a2542d810bf87abd7bf5ad3f8ef60 100644 --- a/lib/apex/frame/path.rb +++ b/lib/ax25/frame/path.rb @@ -1,4 +1,4 @@ -module Apex +module Ax25 public module Path include Abstractify::Abstract diff --git a/lib/apex/frame/path_agnostic_immutable_frame.rb b/lib/ax25/frame/path_agnostic_immutable_frame.rb similarity index 91% rename from lib/apex/frame/path_agnostic_immutable_frame.rb rename to lib/ax25/frame/path_agnostic_immutable_frame.rb index 6f125f2ec2e3736fdf34cc33449e2ea2780efdc5..e4a0acba514e7c4ff587789f7cab9e87b6d43415 100644 --- a/lib/apex/frame/path_agnostic_immutable_frame.rb +++ b/lib/ax25/frame/path_agnostic_immutable_frame.rb @@ -1,6 +1,6 @@ -require 'apex/frame/immutable_frame' +require 'ax25/frame/immutable_frame' -module Apex +module Ax25 private class PathAgnosticImmutableFrame < ImmutableFrame protected diff --git a/spec/apex/encoder/aprs_kiss_spec.rb b/spec/ax25/encoder/aprs_kiss_spec.rb similarity index 76% rename from spec/apex/encoder/aprs_kiss_spec.rb rename to spec/ax25/encoder/aprs_kiss_spec.rb index 97b8e9eeb246a75972b98bf735026997ef219ea3..555a970be5123ef7054aad04f4d9e8adfd22755d 100644 --- a/spec/apex/encoder/aprs_kiss_spec.rb +++ b/spec/ax25/encoder/aprs_kiss_spec.rb @@ -1,9 +1,9 @@ -require_relative '../../../lib/apex' +require_relative '../../../lib/ax25' -FRAME_KISS = Apex::ImmutableFrame.new( - Apex::ImmutableEntity.from_raw('W2GMD-1'), - Apex::ImmutableEntity.from_raw('OMG'), - Apex::ImmutablePath.from_raw(['WIDE1-1', 'WIDE2-2']), +FRAME_KISS = Ax25::ImmutableFrame.new( + Ax25::ImmutableEntity.from_raw('W2GMD-1'), + Ax25::ImmutableEntity.from_raw('OMG'), + Ax25::ImmutablePath.from_raw(['WIDE1-1', 'WIDE2-2']), 'test_encode_frame' ) @@ -14,10 +14,10 @@ FRAME_MAP = { :payload => 'test_encode_frame' } -describe Apex::AprsKiss do +describe Ax25::AprsKiss do let(:data_stream) { double(Kiss::KissAbstract, kind_of?: true) } - let(:aprs_kiss) { Apex::AprsKiss.new(data_stream) } + let(:aprs_kiss) { Ax25::AprsKiss.new(data_stream) } describe ".read" do context "Given a mocked data_stream with a valid Frame" do diff --git a/spec/apex/encoder/igate_tcp_spec.rb b/spec/ax25/encoder/igate_tcp_spec.rb similarity index 81% rename from spec/apex/encoder/igate_tcp_spec.rb rename to spec/ax25/encoder/igate_tcp_spec.rb index db4f79e40fc9401e232e41b2e0cd2eec782a1c68..c9b9970173f124a3f5650b722a25c59a5ba8e610 100644 --- a/spec/apex/encoder/igate_tcp_spec.rb +++ b/spec/ax25/encoder/igate_tcp_spec.rb @@ -1,22 +1,22 @@ -require_relative '../../../lib/apex' +require_relative '../../../lib/ax25' -DECODED_FRAME_IGATE = Apex::ImmutableFrame.new( - Apex::ImmutableEntity.from_raw('W2GMD-1'), - Apex::ImmutableEntity.from_raw('OMG'), - Apex::ImmutablePath.from_raw(['WIDE1-1', 'WIDE2-2']), +DECODED_FRAME_IGATE = Ax25::ImmutableFrame.new( + Ax25::ImmutableEntity.from_raw('W2GMD-1'), + Ax25::ImmutableEntity.from_raw('OMG'), + Ax25::ImmutablePath.from_raw(['WIDE1-1', 'WIDE2-2']), 'test_encode_frame' ) ENCODED_FRAME_IGATE = "W2GMD-1>OMG,WIDE1-1,WIDE2-2:test_encode_frame" -describe Apex::IGateTcp do +describe Ax25::IGateTcp do let(:aprsis_socket) { double("aprsis_socket") } - let(:igate_tcp) {Apex::IGateTcp.new("WI2ARD")} + let(:igate_tcp) {Ax25::IGateTcp.new("WI2ARD")} describe ".connect" do context "When attempting to connect to an igate" do it "The correct login message is sent" do - expect(aprsis_socket).to receive(:puts).with("user WI2ARD pass 17582 vers APEX #{Apex::VERSION}\r\n") + expect(aprsis_socket).to receive(:puts).with("user WI2ARD pass 17582 vers ax25 #{Ax25::VERSION}\r\n") igate_tcp.connect(aprsis_socket_override: aprsis_socket) end end diff --git a/spec/apex/frame/entity_spec.rb b/spec/ax25/frame/entity_spec.rb similarity index 78% rename from spec/apex/frame/entity_spec.rb rename to spec/ax25/frame/entity_spec.rb index 5823238f12e9112f196817c9d3e728e5dda640b7..0a65e158ef7ba86e5bb23670ab1bcc6f3997637a 100644 --- a/spec/apex/frame/entity_spec.rb +++ b/spec/ax25/frame/entity_spec.rb @@ -1,4 +1,4 @@ -require_relative '../../../lib/apex' +require_relative '../../../lib/ax25' BASE_ENTITY = "WI2ARD-10".freeze BASE_ENTITY_CALLSIGN = "WI2ARD".freeze @@ -39,13 +39,13 @@ class EntityEquiv end end -describe Apex::Entity do +describe Ax25::Entity do describe ".new" do context "Given a valid callsign with ssid" do - entity = Apex::ImmutableEntity.new(BASE_ENTITY_CALLSIGN, BASE_ENTITY_SSID) + entity = Ax25::ImmutableEntity.new(BASE_ENTITY_CALLSIGN, BASE_ENTITY_SSID) it "returns a Entity object with correct properties" do expect(entity).not_to be_nil - expect(entity).to be_kind_of(Apex::Entity) + expect(entity).to be_kind_of(Ax25::Entity) end it "set the callsign property correctly" do expect(entity.callsign).to eql(BASE_ENTITY_CALLSIGN) @@ -58,10 +58,10 @@ describe Apex::Entity do end end context "Given a valid callsign with nil ssid" do - entity = Apex::ImmutableEntity.new(NOSSID_ENTITY_CALLSIGN, NOSSID_ENTITY_SSID) + entity = Ax25::ImmutableEntity.new(NOSSID_ENTITY_CALLSIGN, NOSSID_ENTITY_SSID) it "returns a Entity object with correct properties" do expect(entity).not_to be_nil - expect(entity).to be_kind_of(Apex::Entity) + expect(entity).to be_kind_of(Ax25::Entity) end it "set the callsign property correctly" do expect(entity.callsign).to eql(NOSSID_ENTITY_CALLSIGN) @@ -71,10 +71,10 @@ describe Apex::Entity do end end context "Given a valid callsign with zero for ssid" do - entity = Apex::ImmutableEntity.new(ZEROSSID_ENTITY_CALLSIGN, ZEROSSID_ENTITY_SSID) + entity = Ax25::ImmutableEntity.new(ZEROSSID_ENTITY_CALLSIGN, ZEROSSID_ENTITY_SSID) it "returns a Entity object with correct properties" do expect(entity).not_to be_nil - expect(entity).to be_kind_of(Apex::Entity) + expect(entity).to be_kind_of(Ax25::Entity) end it "set the callsign property correctly" do expect(entity.callsign).to eql(ZEROSSID_ENTITY_CALLSIGN) @@ -86,60 +86,60 @@ describe Apex::Entity do context "Given an invalid callsign with valid ssid" do it "throws an argument error" do expect { - entity = Apex::ImmutableEntity.new(BAD_CALLSIGN_ENTITY_CALLSIGN, BAD_CALLSIGN_ENTITY_SSID) + entity = Ax25::ImmutableEntity.new(BAD_CALLSIGN_ENTITY_CALLSIGN, BAD_CALLSIGN_ENTITY_SSID) }.to raise_error(ArgumentError) end end context "Given a nil callsign with valid ssid" do it "throws an argument error" do expect { - entity = Apex::ImmutableEntity.new(nil, BASE_ENTITY_SSID) + entity = Ax25::ImmutableEntity.new(nil, BASE_ENTITY_SSID) }.to raise_error(ArgumentError) end end context "Given a non-string callsign with valid ssid" do it "throws an argument error" do expect { - entity = Apex::ImmutableEntity.new(5, BASE_ENTITY_SSID) + entity = Ax25::ImmutableEntity.new(5, BASE_ENTITY_SSID) }.to raise_error(ArgumentError) end end context "Given a empty string callsign with valid ssid" do it "throws an argument error" do expect { - entity = Apex::ImmutableEntity.new("", BASE_ENTITY_SSID) + entity = Ax25::ImmutableEntity.new("", BASE_ENTITY_SSID) }.to raise_error(ArgumentError) end end context "Given a valid callsign with non-integer ssid" do it "throws an argument error" do expect { - entity = Apex::ImmutableEntity.new(BASE_ENTITY_CALLSIGN, "invalid") + entity = Ax25::ImmutableEntity.new(BASE_ENTITY_CALLSIGN, "invalid") }.to raise_error(ArgumentError) end end context "Given a valid callsign with ssid below 0" do it "throws an argument error" do expect { - entity = Apex::ImmutableEntity.new(BAD_LOWSSID_ENTITY_CALLSIGN,BAD_LOWSSID_ENTITY_SSID) + entity = Ax25::ImmutableEntity.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 it "throws an argument error" do expect { - entity = Apex::ImmutableEntity.new(BAD_HIGHSSID_ENTITY_CALLSIGN,BAD_HIGHSSID_ENTITY_SSID) + entity = Ax25::ImmutableEntity.new(BAD_HIGHSSID_ENTITY_CALLSIGN,BAD_HIGHSSID_ENTITY_SSID) }.to raise_error(ArgumentError) end end context "Given a lowercase callsign with valid ssid" do - entity = Apex::ImmutableEntity.new("wi2ard", 2) + entity = Ax25::ImmutableEntity.new("wi2ard", 2) it "converts the callsign to uppercase" do expect(entity.callsign).to eql("WI2ARD") end end context "Given a callsign with extra spaces before and after and valid ssid" do - entity = Apex::ImmutableEntity.new(" WI2ARD ", 2) + entity = Ax25::ImmutableEntity.new(" WI2ARD ", 2) it "strips the extra spaces" do expect(entity.callsign).to eql("WI2ARD") end @@ -147,10 +147,10 @@ describe Apex::Entity do end describe ".from_raw" do context "Given a valid callsign with ssid" do - entity = Apex::ImmutableEntity.from_raw(BASE_ENTITY) + entity = Ax25::ImmutableEntity.from_raw(BASE_ENTITY) it "returns a Entity object" do expect(entity).not_to be_nil - expect(entity).to be_kind_of(Apex::Entity) + expect(entity).to be_kind_of(Ax25::Entity) end it "set the callsign correctly" do expect(entity.callsign).to eql(BASE_ENTITY_CALLSIGN) @@ -160,10 +160,10 @@ describe Apex::Entity do end end context "Given a valid callsign with 0 ssid" do - entity = Apex::ImmutableEntity.from_raw(ZEROSSID_ENTITY) + entity = Ax25::ImmutableEntity.from_raw(ZEROSSID_ENTITY) it "returns a FrameEntity object" do expect(entity).not_to be_nil - expect(entity).to be_kind_of(Apex::Entity) + expect(entity).to be_kind_of(Ax25::Entity) end it "the callsign field was parssed correctly" do expect(entity.callsign).to eql(ZEROSSID_ENTITY_CALLSIGN) @@ -173,10 +173,10 @@ describe Apex::Entity do end end context "Given a valid callsign with no ssid" do - entity = Apex::ImmutableEntity.from_raw(NOSSID_ENTITY) + entity = Ax25::ImmutableEntity.from_raw(NOSSID_ENTITY) it "returns a FrameEntity object" do expect(entity).not_to be_nil - expect(entity).to be_kind_of(Apex::Entity) + expect(entity).to be_kind_of(Ax25::Entity) end it "the callsign field was parssed correctly" do expect(entity.callsign).to eql(NOSSID_ENTITY_CALLSIGN) @@ -188,47 +188,47 @@ describe Apex::Entity do context "Given an invalid callsign with valid ssid" do it "throws an argument error" do expect { - entity = Apex::ImmutableEntity.from_raw(BAD_CALLSIGN_ENTITY) + entity = Ax25::ImmutableEntity.from_raw(BAD_CALLSIGN_ENTITY) }.to raise_error(ArgumentError) end end context "Given a entity with two hyphens" do it "throws an argument error" do expect { - entity = Apex::ImmutableEntity.from_raw(BAD_HYPHEN_ENTITY) + entity = Ax25::ImmutableEntity.from_raw(BAD_HYPHEN_ENTITY) }.to raise_error(ArgumentError) end end context "Given a entity with a hyphen but no ssid" do it "throws an argument error" do expect { - entity = Apex::ImmutableEntity.from_raw(BAD_HYPHEN_NOSSID_ENTITY) + entity = Ax25::ImmutableEntity.from_raw(BAD_HYPHEN_NOSSID_ENTITY) }.to raise_error(ArgumentError) end end context "Given a entity with a an ssid greater than 15" do it "throws an argument error" do expect { - entity = Apex::ImmutableEntity.from_raw(BAD_HIGHSSID_ENTITY) + entity = Ax25::ImmutableEntity.from_raw(BAD_HIGHSSID_ENTITY) }.to raise_error(ArgumentError) end end end describe ".callsign" do context "Given a Entity with valid callsign and with an ssid" do - entity = Apex::ImmutableEntity.from_raw(BASE_ENTITY) + entity = Ax25::ImmutableEntity.from_raw(BASE_ENTITY) it "then the callsign should be frozen" do expect(entity.callsign).to be_frozen end end context "Given a Entity with valid callsign and without an ssid" do - entity = Apex::ImmutableEntity.from_raw(NOSSID_ENTITY) + entity = Ax25::ImmutableEntity.from_raw(NOSSID_ENTITY) it "then the callsign should be frozen" do expect(entity.callsign).to be_frozen end end context "Given any valid Entity" do - entity = Apex::ImmutableEntity.from_raw(BASE_ENTITY) + entity = Ax25::ImmutableEntity.from_raw(BASE_ENTITY) it "then we should not be able to set a value" do expect { entity.callsign = "BAD1B" @@ -242,7 +242,7 @@ describe Apex::Entity do it "then the callsign passed to from_raw should be duplicated" do passed_call = "WI2AR" orig_call = passed_call.dup.freeze - entity = Apex::ImmutableEntity.from_raw(passed_call) + entity = Ax25::ImmutableEntity.from_raw(passed_call) passed_call << "D" expect(entity.callsign).to eql(orig_call) expect(passed_call).to eql("WI2ARD") @@ -252,7 +252,7 @@ describe Apex::Entity do end describe ".ssid" do context "Given any valid Entity" do - entity = Apex::ImmutableEntity.from_raw(BASE_ENTITY) + entity = Ax25::ImmutableEntity.from_raw(BASE_ENTITY) it "then we should not be able to set a value" do expect { entity.ssid = "1" @@ -267,7 +267,7 @@ describe Apex::Entity do end describe ".decrement_ssid" do context "Given a Entity that has a greater than 0 ssid" do - entity = Apex::ImmutableEntity.from_raw(BASE_ENTITY) + entity = Ax25::ImmutableEntity.from_raw(BASE_ENTITY) context "which has its ssid decremented" do new_entity = entity.decrement_ssid it "should produce a duplicated Entity" do @@ -282,7 +282,7 @@ describe Apex::Entity do end end context "Given a Entity that has a ssid of 0" do - entity = Apex::ImmutableEntity.from_raw(ZEROSSID_ENTITY) + entity = Ax25::ImmutableEntity.from_raw(ZEROSSID_ENTITY) context "which has its ssid decremented" do it "throws a range error" do expect{ @@ -294,31 +294,31 @@ describe Apex::Entity do end describe ".to_s" do context "Given a raw string with valid callsign with ssid" do - entity = Apex::ImmutableEntity.from_raw(BASE_ENTITY) + entity = Ax25::ImmutableEntity.from_raw(BASE_ENTITY) it "then we should produce the correct string" do expect(entity.to_s).to eql(BASE_ENTITY) end end context "Given a raw string with valid callsign with ssid of zero" do - entity = Apex::ImmutableEntity.from_raw(ZEROSSID_ENTITY) + entity = Ax25::ImmutableEntity.from_raw(ZEROSSID_ENTITY) it "then we should produce the correct string" do expect(entity.to_s).to eql(NOSSID_ENTITY) end end context "Given a raw string with valid callsign without ssid" do - entity = Apex::ImmutableEntity.from_raw(NOSSID_ENTITY) + entity = Ax25::ImmutableEntity.from_raw(NOSSID_ENTITY) it "then we should produce the correct string" do expect(entity.to_s).to eql(NOSSID_ENTITY) end end context "Given a FrameEntity from new with valid callsign with non-zero ssid" do - entity = Apex::ImmutableEntity.new(BASE_ENTITY_CALLSIGN, BASE_ENTITY_SSID) + entity = Ax25::ImmutableEntity.new(BASE_ENTITY_CALLSIGN, BASE_ENTITY_SSID) it "then we should produce the correct string" do expect(entity.to_s).to eql(BASE_ENTITY) end end context "Given a FrameEntity from new with valid callsign with ssid of 0" do - entity = Apex::ImmutableEntity.new(ZEROSSID_ENTITY_CALLSIGN, ZEROSSID_ENTITY_SSID) + entity = Ax25::ImmutableEntity.new(ZEROSSID_ENTITY_CALLSIGN, ZEROSSID_ENTITY_SSID) it "then we should produce the correct string" do expect(entity.to_s).to eql(NOSSID_ENTITY) end @@ -328,15 +328,15 @@ describe Apex::Entity do describe ".==" do context "Given one Entity and an equivelant non-Entity class with the same properties" do entity_equiv = EntityEquiv.new - entity = Apex::ImmutableEntity.new(BASE_ENTITY_CALLSIGN, BASE_ENTITY_SSID) + entity = Ax25::ImmutableEntity.new(BASE_ENTITY_CALLSIGN, BASE_ENTITY_SSID) it "then equality should return true" do expect(entity == entity_equiv).to be_truthy end end context "Given two equivelant entitys both instaces of Entity class with the same properties" do - entity = Apex::ImmutableEntity.new(BASE_ENTITY_CALLSIGN, 0) - entity_equiv = Apex::ImmutableEntity.new(BASE_ENTITY_CALLSIGN, nil) + entity = Ax25::ImmutableEntity.new(BASE_ENTITY_CALLSIGN, 0) + entity_equiv = Ax25::ImmutableEntity.new(BASE_ENTITY_CALLSIGN, nil) it "then equality should return true" do expect(entity == entity_equiv).to be_truthy end @@ -344,15 +344,15 @@ describe Apex::Entity do context "Given one Entity and a equivelant non-Entity class with different properties" do entity_equiv = EntityEquiv.new - entity = Apex::ImmutableEntity.new("BADCALL", BASE_ENTITY_SSID) + entity = Ax25::ImmutableEntity.new("BADCALL", BASE_ENTITY_SSID) it "then equality should return true" do expect(entity == entity_equiv).to be_falsey end end context "Given two equivelant entitys both instaces of Entity class with different properties" do - entity = Apex::ImmutableEntity.new(BASE_ENTITY_CALLSIGN, 0) - entity_equiv = Apex::ImmutableEntity.new("BADCALL", nil) + entity = Ax25::ImmutableEntity.new(BASE_ENTITY_CALLSIGN, 0) + entity_equiv = Ax25::ImmutableEntity.new("BADCALL", nil) it "then equality should return true" do expect(entity == entity_equiv).to be_falsey end @@ -362,7 +362,7 @@ describe Apex::Entity do describe ".eql?" do context "Given one Entity and an equivelant non-Entity class with the same properties" do entity_equiv = EntityEquiv.new - entity = Apex::ImmutableEntity.new(BASE_ENTITY_CALLSIGN, BASE_ENTITY_SSID) + entity = Ax25::ImmutableEntity.new(BASE_ENTITY_CALLSIGN, BASE_ENTITY_SSID) it "throws an ArgumentError" do expect { entity.eql? entity_equiv @@ -371,8 +371,8 @@ describe Apex::Entity do end context "Given two equivelant entitys both instaces of Entity class" do - entity = Apex::ImmutableEntity.new(BASE_ENTITY_CALLSIGN, 0) - entity_equiv = Apex::ImmutableEntity.new(BASE_ENTITY_CALLSIGN, nil) + entity = Ax25::ImmutableEntity.new(BASE_ENTITY_CALLSIGN, 0) + entity_equiv = Ax25::ImmutableEntity.new(BASE_ENTITY_CALLSIGN, nil) it "then eql should return true" do expect(entity.eql? entity_equiv).to be_truthy end @@ -380,7 +380,7 @@ describe Apex::Entity do context "Given one Entity and a equivelant non-Entity class with different properties" do entity_equiv = EntityEquiv.new - entity = Apex::ImmutableEntity.new("BADCALL", BASE_ENTITY_SSID) + entity = Ax25::ImmutableEntity.new("BADCALL", BASE_ENTITY_SSID) it "throws an ArgumentError" do expect { entity.eql? entity_equiv @@ -389,8 +389,8 @@ describe Apex::Entity do end context "Given two equivelant entitys both instaces of Entity class with different properties" do - entity = Apex::ImmutableEntity.new(BASE_ENTITY_CALLSIGN, 0) - entity_equiv = Apex::ImmutableEntity.new("BADCALL", nil) + entity = Ax25::ImmutableEntity.new(BASE_ENTITY_CALLSIGN, 0) + entity_equiv = Ax25::ImmutableEntity.new("BADCALL", nil) it "then eql should return false" do expect(entity.eql? entity_equiv).to be_falsey end diff --git a/spec/apex/frame/hop_spec.rb b/spec/ax25/frame/hop_spec.rb similarity index 81% rename from spec/apex/frame/hop_spec.rb rename to spec/ax25/frame/hop_spec.rb index e3af2b2bdbafb9c861935c47eeb430e7c7da2e02..3f0d2be3b8400d81da4b27ac28df2690427a2215 100644 --- a/spec/apex/frame/hop_spec.rb +++ b/spec/ax25/frame/hop_spec.rb @@ -1,4 +1,4 @@ -require_relative '../../../lib/apex/frame/hop' +require_relative '../../../lib/ax25/frame/hop' BASE_HOP = "WI2ARD-10*".freeze BASE_HOP_CALLSIGN = "WI2ARD".freeze @@ -65,13 +65,13 @@ class HopEquiv end end -describe Apex::Hop do +describe Ax25::Hop do describe ".new" do context "Given a valid callsign with ssid and with seen flag" do - hop = Apex::ImmutableHop.new(BASE_HOP_CALLSIGN, BASE_HOP_SSID, BASE_HOP_SEEN) + 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(Apex::Hop) + expect(hop).to be_kind_of(Ax25::Hop) end it "set the callsign property correctly" do expect(hop.callsign).to eql(BASE_HOP_CALLSIGN) @@ -84,10 +84,10 @@ describe Apex::Hop do end end context "Given a valid callsign with nil ssid and with seen flag" do - hop = Apex::ImmutableHop.new(NOSSID_HOP_CALLSIGN, NOSSID_HOP_SSID, NOSSID_HOP_SEEN) + 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(Apex::Hop) + expect(hop).to be_kind_of(Ax25::Hop) end it "set the callsign property correctly" do expect(hop.callsign).to eql(NOSSID_HOP_CALLSIGN) @@ -100,10 +100,10 @@ describe Apex::Hop do end end context "Given a valid callsign with zero for ssid and with seen flag" do - hop = Apex::ImmutableHop.new(ZEROSSID_HOP_CALLSIGN, ZEROSSID_HOP_SSID, ZEROSSID_HOP_SEEN) + 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(Apex::Hop) + expect(hop).to be_kind_of(Ax25::Hop) end it "set the callsign property correctly" do expect(hop.callsign).to eql(ZEROSSID_HOP_CALLSIGN) @@ -118,74 +118,74 @@ describe Apex::Hop do context "Given an invalid callsign with valid ssid and valid seen flag" do it "throws an argument error" do expect { - hop = Apex::ImmutableHop.new(BAD_CALLSIGN_HOP_CALLSIGN, BAD_CALLSIGN_HOP_SSID, BAD_CALLSIGN_HOP_SEEN) + 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 it "throws an argument error" do expect { - hop = Apex::ImmutableHop.new(nil, BASE_HOP_SSID, BASE_HOP_SEEN) + 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 it "throws an argument error" do expect { - hop = Apex::ImmutableHop.new(BASE_HOP_CALLSIGN, BASE_HOP_SSID, nil) + 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 it "throws an argument error" do expect { - hop = Apex::ImmutableHop.new(5, BASE_HOP_SSID, BASE_HOP_SEEN) + 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 it "throws an argument error" do expect { - hop = Apex::ImmutableHop.new("", BASE_HOP_SSID, BASE_HOP_SEEN) + 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 it "throws an argument error" do expect { - hop = Apex::ImmutableHop.new(BASE_HOP_CALLSIGN, "invalid", BASE_HOP_SEEN) + 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 it "throws an argument error" do expect { - hop = Apex::ImmutableHop.new(BASE_HOP_CALLSIGN,BASE_HOP_SSID, "invalid") + 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 it "throws an argument error" do expect { - hop = Apex::ImmutableHop.new(BAD_LOWSSID_HOP_CALLSIGN,BAD_LOWSSID_HOP_SSID, BAD_LOWSSID_HOP_SEEN) + 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 it "throws an argument error" do expect { - hop = Apex::ImmutableHop.new(BAD_HIGHSSID_HOP_CALLSIGN,BAD_HIGHSSID_HOP_SSID, BAD_HIGHSSID_HOP_SEEN) + 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 - hop = Apex::ImmutableHop.new("wi2ard", 2, true) + hop = Ax25::ImmutableHop.new("wi2ard", 2, true) it "converts the callsign to uppercase" do expect(hop.callsign).to eql("WI2ARD") end end context "Given a callsign with extra spaces before and after and valid ssid and valid seen flag" do - hop = Apex::ImmutableHop.new(" WI2ARD ", 2, true) + hop = Ax25::ImmutableHop.new(" WI2ARD ", 2, true) it "strips the extra spaces" do expect(hop.callsign).to eql("WI2ARD") end @@ -193,10 +193,10 @@ describe Apex::Hop do end describe ".from_raw" do context "Given a valid callsign with ssid and with seen flag" do - hop = Apex::ImmutableHop.from_raw(BASE_HOP) + 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(Apex::Hop) + expect(hop).to be_kind_of(Ax25::Hop) end it "set the callsign correctly" do expect(hop.callsign).to eql(BASE_HOP_CALLSIGN) @@ -209,10 +209,10 @@ describe Apex::Hop do end end context "Given a valid callsign with ssid and without seen flag" do - hop = Apex::ImmutableHop.from_raw(UNSEEN_HOP) + 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(Apex::Hop) + 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) @@ -225,10 +225,10 @@ describe Apex::Hop do end end context "Given a valid callsign with 0 ssid and with seen flag" do - hop = Apex::ImmutableHop.from_raw(ZEROSSID_HOP) + 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(Apex::Hop) + 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) @@ -241,10 +241,10 @@ describe Apex::Hop do end end context "Given a valid callsign with nil ssid and with seen flag" do - hop = Apex::ImmutableHop.from_raw(NOSSID_HOP) + 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(Apex::Hop) + 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) @@ -257,10 +257,10 @@ describe Apex::Hop do end end context "Given a valid callsign without ssid and without seen flag" do - hop = Apex::ImmutableHop.from_raw(NOSSID_UNSEEN_HOP) + 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(Apex::Hop) + 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) @@ -275,47 +275,47 @@ describe Apex::Hop do context "Given an invalid callsign with valid ssid and valid seen flag" do it "throws an argument error" do expect { - hop = Apex::ImmutableHop.from_raw(BAD_CALLSIGN_HOP) + hop = Ax25::ImmutableHop.from_raw(BAD_CALLSIGN_HOP) }.to raise_error(ArgumentError) end end context "Given a hop with two hyphens" do it "throws an argument error" do expect { - hop = Apex::ImmutableHop.from_raw(BAD_HYPHEN_HOP) + hop = Ax25::ImmutableHop.from_raw(BAD_HYPHEN_HOP) }.to raise_error(ArgumentError) end end context "Given a hop with a hyphen but no ssid" do it "throws an argument error" do expect { - hop = Apex::ImmutableHop.from_raw(BAD_HYPHEN_NOSSID_HOP) + hop = Ax25::ImmutableHop.from_raw(BAD_HYPHEN_NOSSID_HOP) }.to raise_error(ArgumentError) end end context "Given a hop with a an ssid greater than 15" do it "throws an argument error" do expect { - hop = Apex::ImmutableHop.from_raw(BAD_HIGHSSID_HOP) + hop = Ax25::ImmutableHop.from_raw(BAD_HIGHSSID_HOP) }.to raise_error(ArgumentError) end end end describe ".callsign" do context "Given a FrameHop with valid callsign and with an ssid" do - hop = Apex::ImmutableHop.from_raw(BASE_HOP) + hop = Ax25::ImmutableHop.from_raw(BASE_HOP) it "then the callsign should be frozen" do expect(hop.callsign).to be_frozen end end context "Given a FrameHop with valid callsign and without an ssid" do - hop = Apex::ImmutableHop.from_raw(NOSSID_HOP) + hop = Ax25::ImmutableHop.from_raw(NOSSID_HOP) it "then the callsign should be frozen" do expect(hop.callsign).to be_frozen end end context "Given any valid FrameHop" do - hop = Apex::ImmutableHop.from_raw(BASE_HOP) + hop = Ax25::ImmutableHop.from_raw(BASE_HOP) it "then we should not be able to set a value" do expect { hop.callsign = "BAD1B" @@ -329,7 +329,7 @@ describe Apex::Hop do it "then the callsign passed to from_raw should be duplicated" do passed_call = "WI2AR" orig_call = passed_call.dup.freeze - hop = Apex::ImmutableHop.from_raw(passed_call) + hop = Ax25::ImmutableHop.from_raw(passed_call) passed_call << "D" expect(hop.callsign).to eql(orig_call) expect(passed_call).to eql("WI2ARD") @@ -339,7 +339,7 @@ describe Apex::Hop do end describe ".ssid" do context "Given any valid FrameHop" do - hop = Apex::ImmutableHop.from_raw(BASE_HOP) + hop = Ax25::ImmutableHop.from_raw(BASE_HOP) it "then we should not be able to set a value" do expect { hop.ssid = "1" @@ -354,7 +354,7 @@ describe Apex::Hop do end describe ".seen" do context "Given any valid FrameHop" do - hop = Apex::ImmutableHop.from_raw(BASE_HOP) + hop = Ax25::ImmutableHop.from_raw(BASE_HOP) it "then we should not be able to set a value" do expect { hop.seen = false @@ -364,7 +364,7 @@ describe Apex::Hop do end describe ".toggle_seen" do context "Given a FrameHop that has been seen" do - hop = Apex::ImmutableHop.from_raw(BASE_HOP) + hop = Ax25::ImmutableHop.from_raw(BASE_HOP) context "which has its seen flag toggled" do toggled_hop = hop.toggle_seen it "should produce a duplicated FrameHop" do @@ -379,7 +379,7 @@ describe Apex::Hop do end end context "Given a FrameHop that has not been seen" do - hop = Apex::ImmutableHop.from_raw(UNSEEN_HOP) + hop = Ax25::ImmutableHop.from_raw(UNSEEN_HOP) context "which has its seen flag toggled" do new_hop = hop.toggle_seen it "should produce a duplicated FrameHop" do @@ -396,7 +396,7 @@ describe Apex::Hop do end describe ".decrement_ssid" do context "Given a FrameHop that has a greater than 0 SSID" do - hop = Apex::ImmutableHop.from_raw(BASE_HOP) + hop = Ax25::ImmutableHop.from_raw(BASE_HOP) context "which has its ssid decremented" do new_hop = hop.decrement_ssid it "should produce a duplicated FrameHop" do @@ -411,7 +411,7 @@ describe Apex::Hop do end end context "Given a FrameHop that has a SSID of 0" do - hop = Apex::ImmutableHop.from_raw(ZEROSSID_HOP) + hop = Ax25::ImmutableHop.from_raw(ZEROSSID_HOP) context "which has its ssid decremented" do it "throws a range error" do expect{ @@ -423,67 +423,67 @@ describe Apex::Hop do end describe ".to_s" do context "Given a raw string with valid callsign with ssid and with seen flag" do - hop = Apex::ImmutableHop.from_raw(BASE_HOP) + 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 - hop = Apex::ImmutableHop.from_raw(UNSEEN_HOP) + 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 - hop = Apex::ImmutableHop.from_raw(ZEROSSID_HOP) + 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 - hop = Apex::ImmutableHop.from_raw(NOSSID_HOP) + 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 - hop = Apex::ImmutableHop.from_raw(NOSSID_UNSEEN_HOP) + 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 - hop = Apex::ImmutableHop.from_raw(ZEROSSID_UNSEEN_HOP) + 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 - hop = Apex::ImmutableHop.new(BASE_HOP_CALLSIGN, BASE_HOP_SSID, BASE_HOP_SEEN) + 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 - hop = Apex::ImmutableHop.new(UNSEEN_HOP_CALLSIGN, UNSEEN_HOP_SSID, UNSEEN_HOP_SEEN) + 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 - hop = Apex::ImmutableHop.new(NOSSID_HOP_CALLSIGN, NOSSID_HOP_SSID, NOSSID_HOP_SEEN) + 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 - hop = Apex::ImmutableHop.new(ZEROSSID_HOP_CALLSIGN, ZEROSSID_HOP_SSID, ZEROSSID_HOP_SEEN) + 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 - hop = Apex::ImmutableHop.new(ZEROSSID_UNSEEN_HOP_CALLSIGN, ZEROSSID_UNSEEN_HOP_SSID, ZEROSSID_UNSEEN_HOP_SEEN) + 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) end @@ -493,15 +493,15 @@ describe Apex::Hop do describe ".==" do context "Given one Hop and an equivelant non-Hop class with the same properties" do hop_equiv = HopEquiv.new - hop = Apex::ImmutableHop.new(BASE_HOP_CALLSIGN, BASE_HOP_SSID, BASE_HOP_SEEN) + hop = Ax25::ImmutableHop.new(BASE_HOP_CALLSIGN, BASE_HOP_SSID, BASE_HOP_SEEN) it "then equality should return true" do expect(hop == hop_equiv).to be_truthy end end context "Given two equivelant hops both instaces of Hop class with the same properties" do - hop = Apex::ImmutableHop.new(BASE_HOP_CALLSIGN, 0, BASE_HOP_SEEN) - hop_equiv = Apex::ImmutableHop.new(BASE_HOP_CALLSIGN, nil, BASE_HOP_SEEN) + hop = Ax25::ImmutableHop.new(BASE_HOP_CALLSIGN, 0, BASE_HOP_SEEN) + hop_equiv = Ax25::ImmutableHop.new(BASE_HOP_CALLSIGN, nil, BASE_HOP_SEEN) it "then equality should return true" do expect(hop == hop_equiv).to be_truthy end @@ -509,15 +509,15 @@ describe Apex::Hop do context "Given one Hop and a equivelant non-Hop class with different properties" do hop_equiv = HopEquiv.new - hop = Apex::ImmutableHop.new("BADCALL", BASE_HOP_SSID, BASE_HOP_SEEN) + hop = Ax25::ImmutableHop.new("BADCALL", BASE_HOP_SSID, BASE_HOP_SEEN) it "then equality should return true" do expect(hop == hop_equiv).to be_falsey end end context "Given two equivelant hops both instaces of Hop class with different properties" do - hop = Apex::ImmutableHop.new(BASE_HOP_CALLSIGN, 0, BASE_HOP_SEEN) - hop_equiv = Apex::ImmutableHop.new("BADCALL", nil, BASE_HOP_SEEN) + hop = Ax25::ImmutableHop.new(BASE_HOP_CALLSIGN, 0, BASE_HOP_SEEN) + hop_equiv = Ax25::ImmutableHop.new("BADCALL", nil, BASE_HOP_SEEN) it "then equality should return true" do expect(hop == hop_equiv).to be_falsey end @@ -527,7 +527,7 @@ describe Apex::Hop do describe ".eql?" do context "Given one Hop and an equivelant non-Hop class with the same properties" do hop_equiv = HopEquiv.new - hop = Apex::ImmutableHop.new(BASE_HOP_CALLSIGN, BASE_HOP_SSID, BASE_HOP_SEEN) + hop = Ax25::ImmutableHop.new(BASE_HOP_CALLSIGN, BASE_HOP_SSID, BASE_HOP_SEEN) it "throws an ArgumentError" do expect { hop.eql? hop_equiv @@ -536,8 +536,8 @@ describe Apex::Hop do end context "Given two equivelant hops both instaces of Hop class" do - hop = Apex::ImmutableHop.new(BASE_HOP_CALLSIGN, 0, BASE_HOP_SEEN) - hop_equiv = Apex::ImmutableHop.new(BASE_HOP_CALLSIGN, nil, BASE_HOP_SEEN) + hop = Ax25::ImmutableHop.new(BASE_HOP_CALLSIGN, 0, BASE_HOP_SEEN) + hop_equiv = Ax25::ImmutableHop.new(BASE_HOP_CALLSIGN, nil, BASE_HOP_SEEN) it "then eql should return true" do expect(hop.eql? hop_equiv).to be_truthy end @@ -545,7 +545,7 @@ describe Apex::Hop do context "Given one Hop and a equivelant non-Hop class with different properties" do hop_equiv = HopEquiv.new - hop = Apex::ImmutableHop.new("BADCALL", BASE_HOP_SSID, BASE_HOP_SEEN) + hop = Ax25::ImmutableHop.new("BADCALL", BASE_HOP_SSID, BASE_HOP_SEEN) it "throws an ArgumentError" do expect { hop.eql? hop_equiv @@ -554,8 +554,8 @@ describe Apex::Hop do end context "Given two equivelant hops both instaces of Hop class with different properties" do - hop = Apex::ImmutableHop.new(BASE_HOP_CALLSIGN, 0, BASE_HOP_SEEN) - hop_equiv = Apex::ImmutableHop.new("BADCALL", nil, BASE_HOP_SEEN) + hop = Ax25::ImmutableHop.new(BASE_HOP_CALLSIGN, 0, BASE_HOP_SEEN) + hop_equiv = Ax25::ImmutableHop.new("BADCALL", nil, BASE_HOP_SEEN) it "then eql should return false" do expect(hop.eql? hop_equiv).to be_falsey end diff --git a/spec/apex/frame/path_spec.rb b/spec/ax25/frame/path_spec.rb similarity index 70% rename from spec/apex/frame/path_spec.rb rename to spec/ax25/frame/path_spec.rb index 003bf0adba3fdd8b26ab5a9674b85b361a819c4f..3e58814351eb6fea08bc162c362e78cc455f8341 100644 --- a/spec/apex/frame/path_spec.rb +++ b/spec/ax25/frame/path_spec.rb @@ -1,39 +1,39 @@ -require_relative '../../../lib/apex/frame/path' +require_relative '../../../lib/ax25/frame/path' -describe Apex::Path do +describe Ax25::Path do describe "::EMPTY_PATH" do it "must not be nil" do - expect(Apex::ImmutablePath::EMPTY_PATH).to_not be_nil + expect(Ax25::ImmutablePath::EMPTY_PATH).to_not be_nil end end describe ".new" do context "Given no arguments" do it "creates an empty path" do - path = Apex::ImmutablePath.new() - expect(path).to eql(Apex::ImmutablePath::EMPTY_PATH) + path = Ax25::ImmutablePath.new() + expect(path).to eql(Ax25::ImmutablePath::EMPTY_PATH) end end context "Given a single nil argument" do it "throws an ArgumentError" do expect { - path = Apex::ImmutablePath.new(nil) + path = Ax25::ImmutablePath.new(nil) }.to raise_error(ArgumentError) end end context "Given a single non-Hop argument" do it "throws an ArgumentError" do expect { - path = Apex::ImmutablePath.new(5) + path = Ax25::ImmutablePath.new(5) }.to raise_error(ArgumentError) end end context "Given a single valid hop" do - hop = Apex::ImmutableHop.new("WI2ARD", 4, true) - path = Apex::ImmutablePath.new(hop) + hop = Ax25::ImmutableHop.new("WI2ARD", 4, true) + path = Ax25::ImmutablePath.new(hop) it "instantiates a Path" do expect(path).to_not be_nil - expect(path).to be_kind_of(Apex::Path) + expect(path).to be_kind_of(Ax25::Path) end it "with a single hop" do expect(path.length).to eql(1) @@ -46,17 +46,17 @@ describe Apex::Path do end it "the Path can not be appended" do expect { - path << Apex::ImmutableHop.from_raw("NO4CALL-6") + path << Ax25::ImmutableHop.from_raw("NO4CALL-6") }.to raise_error(NoMethodError) end end context "Given two valid hops" do - hop1 = Apex::ImmutableHop.new("WI2ARD", 4, true) - hop2 = Apex::ImmutableHop.new("K3TXD", 0, false) - path = Apex::ImmutablePath.new(hop1, hop2) + hop1 = Ax25::ImmutableHop.new("WI2ARD", 4, true) + hop2 = Ax25::ImmutableHop.new("K3TXD", 0, false) + path = Ax25::ImmutablePath.new(hop1, hop2) it "instantiates a Path" do expect(path).to_not be_nil - expect(path).to be_kind_of(Apex::Path) + expect(path).to be_kind_of(Ax25::Path) end it "with two hops" do expect(path.length).to eql(2) @@ -68,23 +68,23 @@ describe Apex::Path do end context "Given two hops where the first is unseen and second is seen" do - hop1 = Apex::ImmutableHop.new("WI2ARD", 4, false) - hop2 = Apex::ImmutableHop.new("K3TXD", 0, true) + hop1 = Ax25::ImmutableHop.new("WI2ARD", 4, false) + hop2 = Ax25::ImmutableHop.new("K3TXD", 0, true) it "instantiates a path" do - path = Apex::ImmutablePath.new(hop1, hop2) + path = Ax25::ImmutablePath.new(hop1, hop2) expect(path).to_not be_nil - expect(path).to be_kind_of(Apex::ImmutablePath) - expect(path).to be_kind_of(Apex::Path) + expect(path).to be_kind_of(Ax25::ImmutablePath) + expect(path).to be_kind_of(Ax25::Path) end end end describe ".from_raw" do context "Given an array of two valid hops as strings" do - path = Apex::ImmutablePath.from_raw(['WIDE2-2', "WI2ARD"]) + path = Ax25::ImmutablePath.from_raw(['WIDE2-2', "WI2ARD"]) it "instantiates a path" do expect(path).to_not be_nil - expect(path).to be_kind_of(Apex::Path) + expect(path).to be_kind_of(Ax25::Path) end it "has exactly two hops" do expect(path.length).to eql(2) @@ -95,10 +95,10 @@ describe Apex::Path do end end context "Given an array of a single valid hop as a string" do - path = Apex::ImmutablePath.from_raw(['WIDE2-2']) + path = Ax25::ImmutablePath.from_raw(['WIDE2-2']) it "instantiates a path" do expect(path).to_not be_nil - expect(path).to be_kind_of(Apex::Path) + expect(path).to be_kind_of(Ax25::Path) end it "has exactly two hops" do expect(path.length).to eql(1) @@ -108,10 +108,10 @@ describe Apex::Path do end end context "Given a single string of two valid hops" do - path = Apex::ImmutablePath.from_raw("WIDE2-2,WI2ARD") + path = Ax25::ImmutablePath.from_raw("WIDE2-2,WI2ARD") it "instantiates a path" do expect(path).to_not be_nil - expect(path).to be_kind_of(Apex::Path) + expect(path).to be_kind_of(Ax25::Path) end it "has exactly two hops" do expect(path.length).to eql(2) @@ -122,10 +122,10 @@ describe Apex::Path do end end context "Given a single string for a single valid hop" do - path = Apex::ImmutablePath.from_raw("WIDE2-2") + path = Ax25::ImmutablePath.from_raw("WIDE2-2") it "instantiates a path" do expect(path).to_not be_nil - expect(path).to be_kind_of(Apex::Path) + expect(path).to be_kind_of(Ax25::Path) end it "has exactly two hops" do expect(path.length).to eql(1) @@ -135,10 +135,10 @@ describe Apex::Path do end end context "Given an array of two hops as strings with space as padding" do - path = Apex::ImmutablePath.from_raw([' WIDE2-2 ', " WI2ARD"]) + path = Ax25::ImmutablePath.from_raw([' WIDE2-2 ', " WI2ARD"]) it "instantiates a path" do expect(path).to_not be_nil - expect(path).to be_kind_of(Apex::Path) + expect(path).to be_kind_of(Ax25::Path) end it "has exactly two hops" do expect(path.length).to eql(2) @@ -149,10 +149,10 @@ describe Apex::Path do end end context "Given a single string of two valid hops with space as padding" do - path = Apex::ImmutablePath.from_raw(" WIDE2-2 , WI2ARD") + path = Ax25::ImmutablePath.from_raw(" WIDE2-2 , WI2ARD") it "instantiates a path" do expect(path).to_not be_nil - expect(path).to be_kind_of(Apex::Path) + expect(path).to be_kind_of(Ax25::Path) end it "has exactly two hops" do expect(path.length).to eql(2) @@ -165,14 +165,14 @@ describe Apex::Path do context "Given an array of two hops as strings with invalid commas appended" do it "throws an ArgumentError" do expect { - path = Apex::ImmutablePath.from_raw(['WIDE2-2,', "WI2ARD"]) + path = Ax25::ImmutablePath.from_raw(['WIDE2-2,', "WI2ARD"]) }.to raise_error(ArgumentError) end end context "Given an array of a single element but with two hops as a single string" do it "throws an ArgumentError" do expect { - path = Apex::ImmutablePath.from_raw(["WIDE2-2,WI2ARD"]) + path = Ax25::ImmutablePath.from_raw(["WIDE2-2,WI2ARD"]) }.to raise_error(ArgumentError) end end @@ -180,7 +180,7 @@ describe Apex::Path do describe ".each" do context "Given a valid path with two hops" do - path = Apex::ImmutablePath.from_raw(["WIDE2-2", "WI2ARD"]) + path = Ax25::ImmutablePath.from_raw(["WIDE2-2", "WI2ARD"]) it "can be iterated over twice but no more" do hop_count = 0 path.each do |hop| @@ -193,19 +193,19 @@ describe Apex::Path do describe ".[]" do context "Given a valid path with two hops" do - path = Apex::ImmutablePath.from_raw(["WIDE2-2", "WI2ARD"]) + path = Ax25::ImmutablePath.from_raw(["WIDE2-2", "WI2ARD"]) it "the first hop can be referenced via array notation" do - expect(path[0]).to eql(Apex::ImmutableHop.from_raw("WIDE2-2")) + expect(path[0]).to eql(Ax25::ImmutableHop.from_raw("WIDE2-2")) end it "the second hop can be referenced via array notation" do - expect(path[1]).to eql(Apex::ImmutableHop.from_raw("WI2ARD")) + expect(path[1]).to eql(Ax25::ImmutableHop.from_raw("WI2ARD")) end end end describe ".length" do context "Given a valid path with two hops" do - path = Apex::ImmutablePath.from_raw(["WIDE2-2", "WI2ARD"]) + path = Ax25::ImmutablePath.from_raw(["WIDE2-2", "WI2ARD"]) it "the length should be exactly 2" do expect(path.length).to eql(2) end @@ -214,7 +214,7 @@ describe Apex::Path do describe ".to_s" do context "Given a valid path with two hops" do - path = Apex::ImmutablePath.from_raw(["WIDE2-2", "WI2ARD"]) + path = Ax25::ImmutablePath.from_raw(["WIDE2-2", "WI2ARD"]) it "the string should represent the path" do expect(path.to_s).to eql("WIDE2-2,WI2ARD") end @@ -223,7 +223,7 @@ describe Apex::Path do describe ".to_string_array" do context "Given a valid path with two hops" do - let(:path) {Apex::ImmutablePath.from_raw("WIDE2-2,WI2ARD")} + let(:path) {Ax25::ImmutablePath.from_raw("WIDE2-2,WI2ARD")} it "do" do expect(path.to_string_array).to eql(["WIDE2-2", "WI2ARD"]) end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 68552f2b40f5fbb9366cb8931bd3f7b8b173154b..73e8e70ec271f3b0f3e844965d6b1af99d604546 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -23,9 +23,9 @@ SimpleCov.start do add_filter '/vendor/' # Can't cover files with only require statements - add_filter '/lib/apex/app_info.rb' + add_filter '/lib/ax25/app_info.rb' - add_group 'Frames', 'lib/apex/frame' + add_group 'Frames', 'lib/ax25/frame' #coverage_criterion :branch enable_coverage :branch