diff --git a/Rakefile b/Rakefile index 12bacaf9fdfa80ba3c1641b9d4a2636ded2b2d25..96a90c55f8345b7d47dc9e56dd3eb4b4e2995717 100644 --- a/Rakefile +++ b/Rakefile @@ -1,28 +1,29 @@ def dump_load_path - puts $LOAD_PATH.join("\n") - found = nil - $LOAD_PATH.each do |path| - if File.exists?(File.join(path,"rspec")) - puts "Found rspec in #{path}" - if File.exists?(File.join(path,"rspec","core")) - puts "Found core" - if File.exists?(File.join(path,"rspec","core","rake_task")) - puts "Found rake_task" - found = path - else - puts "!! no rake_task" + puts $LOAD_PATH.join("\n") + found = nil + $LOAD_PATH.each do |path| + if File.exists?(File.join(path, "rspec")) + puts "Found rspec in #{path}" + if File.exists?(File.join(path, "rspec", "core")) + puts "Found core" + if File.exists?(File.join(path, "rspec", "core", "rake_task")) + puts "Found rake_task" + found = path + else + puts "!! no rake_task" + end + else + puts "!!! no core" + end end - else - puts "!!! no core" - end end - end - if found.nil? - puts "Didn't find rspec/core/rake_task anywhere" - else - puts "Found in #{path}" - end + if found.nil? + puts "Didn't find rspec/core/rake_task anywhere" + else + puts "Found in #{path}" + end end + gem 'json', '~> 1.8.3' gem 'bundler', '~> 1.13' @@ -44,23 +45,23 @@ Bundler::GemHelper.install_tasks Rake::TestTask.new do |t| - t.pattern = 'test/tc_*.rb' + t.pattern = 'test/tc_*.rb' end CUKE_RESULTS = 'results.html' CLEAN << CUKE_RESULTS Cucumber::Rake::Task.new(:features) do |t| - t.cucumber_opts = "features --format html -o #{CUKE_RESULTS} --format pretty --no-source -x" - t.fork = false + t.cucumber_opts = "features --format html -o #{CUKE_RESULTS} --format pretty --no-source -x" + t.fork = false end Rake::RDocTask.new do |rd| - - rd.main = "README.rdoc" - - rd.rdoc_files.include("README.rdoc","lib/**/*.rb","bin/**/*") + + rd.main = "README.rdoc" + + rd.rdoc_files.include("README.rdoc", "lib/**/*.rb", "bin/**/*") end -task :default => [:test,:features] +task :default => [:test, :features] diff --git a/apex.gemspec b/apex.gemspec index b2e0cc4462007d83ff62631d5a9c0b08d3a5aa01..b4843ff5633f427d9f6443b92f3eb692621f830a 100644 --- a/apex.gemspec +++ b/apex.gemspec @@ -4,37 +4,37 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'apex' Gem::Specification.new do |spec| - spec.name = 'apex' - spec.version = Apex::VERSION - spec.authors = ['Jeffrey Phillips Freeman'] - spec.email = ['jeffrey.freeman@syncleus.com'] + spec.name = 'apex' + spec.version = Apex::VERSION + spec.authors = ['Jeffrey Phillips Freeman'] + spec.email = ['jeffrey.freeman@syncleus.com'] - spec.summary = %q{Reference implementation for the APEX Radio protocol.} - spec.description = %q{Reference implementation for the APEX Radio protocol.} - spec.homepage = 'http://apexprotocol.com' + spec.summary = %q{Reference implementation for the APEX Radio protocol.} + spec.description = %q{Reference implementation for the APEX Radio protocol.} + spec.homepage = 'http://apexprotocol.com' - # 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. - if spec.respond_to?(:metadata) - spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'" - else - raise 'RubyGems 2.0 or newer is required to protect against public gem pushes.' - end + # 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. + if spec.respond_to?(:metadata) + spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'" + else + raise 'RubyGems 2.0 or newer is required to protect against public gem pushes.' + end - spec.files = `git ls-files -z`.split("\x0").reject do |f| - f.match(%r{^(test|spec|features)/}) - end - spec.bindir = 'exe' - spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } - spec.require_paths = ['lib'] + spec.files = `git ls-files -z`.split("\x0").reject do |f| + f.match(%r{^(test|spec|features)/}) + end + spec.bindir = 'exe' + spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } + spec.require_paths = ['lib'] - spec.add_development_dependency 'bundler' - spec.add_development_dependency 'rake' - spec.add_development_dependency 'rdoc' - spec.add_development_dependency 'aruba' - spec.add_dependency 'abstraction' - spec.add_dependency 'json' - spec.add_dependency 'serialport' - spec.add_dependency 'methadone' - spec.add_dependency 'colorize' + spec.add_development_dependency 'bundler' + spec.add_development_dependency 'rake' + spec.add_development_dependency 'rdoc' + spec.add_development_dependency 'aruba' + spec.add_dependency 'abstraction' + spec.add_dependency 'json' + spec.add_dependency 'serialport' + spec.add_dependency 'methadone' + spec.add_dependency 'colorize' end diff --git a/bin/apex b/bin/apex index 927b3c69fee98fb19507ed161de1ddfd72d67f89..0930b96d5305262cbba654586170dee8ba467476 100755 --- a/bin/apex +++ b/bin/apex @@ -5,29 +5,29 @@ require 'methadone' require_relative '../lib/apex' class App - include Methadone::Main - include Methadone::CLILogging + include Methadone::Main + include Methadone::CLILogging - main do |needed, maybe| - puts options[:switch] - puts options[:flag] - Apex::main - end + main do |needed, maybe| + puts options[:switch] + puts options[:flag] + Apex::main + end - description "APEX reference implementation for the APEX protocol." - version Apex::VERSION + description "APEX reference implementation for the APEX protocol." + version Apex::VERSION - # Proxy to an OptionParser instance's on method - on("--[no]-switch", "Toggles the switch") - on("--flag VALUE", "Sets the flag.") + # Proxy to an OptionParser instance's on method + on("--[no]-switch", "Toggles the switch") + on("--flag VALUE", "Sets the flag.") - arg :needed - arg :maybe, :optional + arg :needed + arg :maybe, :optional - defaults_from_env_var 'SOME_VAR' - defaults_from_config_file '.apex.rc' + defaults_from_env_var 'SOME_VAR' + defaults_from_config_file '.apex.rc' - use_log_level_option :toggle_debug_on_signal => 'USR1' + use_log_level_option :toggle_debug_on_signal => 'USR1' - go! + go! end diff --git a/features/apex.feature b/features/apex.feature index 7ba029b40d24d5b89ac995842cae9279e002e45e..6b0e99eb03e50c9e1b25e95e70c373ef0d7ffb0c 100644 --- a/features/apex.feature +++ b/features/apex.feature @@ -9,10 +9,10 @@ Feature: My bootstrapped app kinda works And the banner should be present And the banner should document that this app takes options And the following options should be documented: - |--version| - |--[no]-switch| - |--flag| + | --version | + | --[no]-switch | + | --flag | And the banner should document that this app's arguments are: - |needed|which is required| - |maybe|which is optional| + | needed | which is required | + | maybe | which is optional | And there should be a one line summary of what the app does diff --git a/features/support/env.rb b/features/support/env.rb index f7495c8d418d620b47c3dc6dc9ca704083b181e6..83f43167f8c4eb5238d7fa26a9c3af09dbd4a1e5 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -2,15 +2,15 @@ require 'aruba/cucumber' require 'methadone/cucumber' ENV['PATH'] = "#{File.expand_path(File.dirname(__FILE__) + '/../../bin')}#{File::PATH_SEPARATOR}#{ENV['PATH']}" -LIB_DIR = File.join(File.expand_path(File.dirname(__FILE__)),'..','..','lib') +LIB_DIR = File.join(File.expand_path(File.dirname(__FILE__)), '..', '..', 'lib') Before do - # Using "announce" causes massive warnings on 1.9.2 - @puts = true - @original_rubylib = ENV['RUBYLIB'] - ENV['RUBYLIB'] = LIB_DIR + File::PATH_SEPARATOR + ENV['RUBYLIB'].to_s + # Using "announce" causes massive warnings on 1.9.2 + @puts = true + @original_rubylib = ENV['RUBYLIB'] + ENV['RUBYLIB'] = LIB_DIR + File::PATH_SEPARATOR + ENV['RUBYLIB'].to_s end After do - ENV['RUBYLIB'] = @original_rubylib + ENV['RUBYLIB'] = @original_rubylib end diff --git a/lib/apex.rb b/lib/apex.rb index 957c0870e4e90cd944b14a60220a864100c4df25..a05e577e95f89fbe6964ae78d3957221f65ec883 100644 --- a/lib/apex.rb +++ b/lib/apex.rb @@ -3,7 +3,7 @@ require 'aprs/aprs_kiss' module Apex VERSION = "0.0.1" - + def self.main kiss = Kiss::KissSerial.new('/dev/ttyUSB1', 9600) aprs_kiss = Aprs::AprsKiss.new(kiss) diff --git a/lib/aprs/aprs_kiss.rb b/lib/aprs/aprs_kiss.rb index aa68c6bd57e77dc94cbfa166cbf5b382798724f6..caad0ef8f1d0ba22126051119f37057770f86c64 100644 --- a/lib/aprs/aprs_kiss.rb +++ b/lib/aprs/aprs_kiss.rb @@ -110,7 +110,7 @@ module Aprs enc_ssid = (callsign[:ssid] << 1) | 0x60 if call_sign.include? '*' - call_sign.gsub!(/\*/,'') + call_sign.gsub!(/\*/, '') enc_ssid |= 0x80 end diff --git a/lib/kiss/kiss_abstract.rb b/lib/kiss/kiss_abstract.rb index 27686644f6e7d62c5174f36a653385be4a12a110..b4112e41f3f546600a7b8a24a2a6cf5d18f2b10b 100644 --- a/lib/kiss/kiss_abstract.rb +++ b/lib/kiss/kiss_abstract.rb @@ -54,12 +54,7 @@ module Kiss protected def write_setting(command, value) - write_interface( - [FEND] + - [command] + - escape_special_codes(value) + - [FEND] - ) + write_interface([FEND] + [command] + escape_special_codes(value) + [FEND]) end private @@ -81,19 +76,19 @@ module Kiss # No FEND in frame if len_fend == 1 read_buffer += split_data[0] - # Single FEND in frame + # Single FEND in frame elsif len_fend == 2 # Closing FEND found if split_data[0] # Partial frame continued, otherwise drop new_frames << read_buffer + split_data[0] read_buffer = [] - # Opening FEND found + # Opening FEND found else new_frames << read_buffer read_buffer = split_data[1] end - # At least one complete frame received + # At least one complete frame received elsif len_fend >= 3 (0...len_fend - 1).each do |i| read_buffer_tmp = read_buffer + split_data[i] @@ -109,7 +104,7 @@ module Kiss # Get anymore data that is waiting read_data = read_interface end - + new_frames.each do |new_frame| if new_frame.length > 0 and new_frame[0] == 0 if @strip_df_start diff --git a/lib/kiss/kiss_serial.rb b/lib/kiss/kiss_serial.rb index 95384e67971ac7ac724d4fc15fcab9b3bc9f6048..5a90d70b261dfc07df46c961d2dbedbb8212eb49 100644 --- a/lib/kiss/kiss_serial.rb +++ b/lib/kiss/kiss_serial.rb @@ -59,7 +59,7 @@ module Kiss # Previous verious defaulted to Xastir-friendly configs. Unfortunately # those don't work with Bluetooth TNCs, so we're reverting to None. if kwargs - kwargs.each do |name,value| + kwargs.each do |name, value| write_setting(name, value) end end diff --git a/test/tc_kiss.rb b/test/tc_kiss.rb index 3a27e2da110481cc52578a87c1a6cdaae83d79df..4cf33bd93164fc571cacf3df048be1360339df10 100644 --- a/test/tc_kiss.rb +++ b/test/tc_kiss.rb @@ -11,7 +11,7 @@ module Kiss 69, 50, 42, 44, 113, 65, 82, 44, 75, 70, 54, 70, 73, 82, 45, 49, 48, 58, 96, 49, 55, 69, 108, 35, 88, 45, 47, 107, 103, 54, 119, 116, 102, 64, 103, 111, 115, 115, 101, 108, 105, 110, 102, 97, 109, 105, 108, 121, 46, 99, 111, 109] - + class TestKiss < Test::Unit::TestCase def test_read kiss_mock = KissMock.new