diff --git a/.gitignore b/.gitignore index cc9d77d..b6f5290 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ /InstalledFiles /pkg/ /spec/reports/ +/spec/examples.txt /test/tmp/ /test/version_tmp/ /tmp/ @@ -16,7 +17,6 @@ Makefile ## Specific to RubyMotion: .dat* .repl_history -build/ ## Documentation cache and generated files: /.yardoc/ diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..616a7ac --- /dev/null +++ b/.gitmodules @@ -0,0 +1,6 @@ +[submodule "vendor/libtoxcore"] + path = vendor/libtoxcore + url = https://github.com/TokTok/c-toxcore.git +[submodule "vendor/libsodium"] + path = vendor/libsodium + url = https://github.com/jedisct1/libsodium.git diff --git a/.rubocop.yml b/.rubocop.yml index f7e84ec..7ae2a8c 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,3 +1,45 @@ AllCops: + TargetRubyVersion: 2.3 + DisplayCopNames: true + Exclude: - vendor/**/* + +Layout/AccessModifierIndentation: + EnforcedStyle: outdent + +Layout/MultilineOperationIndentation: + Exclude: + - ext/**/* + +Metrics/BlockLength: + Exclude: + - '**/*.gemspec' + - spec/**/* + +Metrics/LineLength: + Max: 120 + +Style/AndOr: + Exclude: + - ext/**/* + +Style/DoubleNegation: + Enabled: false + +Style/FileName: + Exclude: + - lib/lita-tox.rb + +Style/GlobalVars: + Exclude: + - ext/**/* + +Style/TrailingCommaInArguments: + EnforcedStyleForMultiline: comma + +Style/TrailingCommaInLiteral: + EnforcedStyleForMultiline: comma + +Style/VariableInterpolation: + Enabled: false diff --git a/.simplecov b/.simplecov index 4c1a5f7..9eddcfc 100644 --- a/.simplecov +++ b/.simplecov @@ -1,8 +1,10 @@ require 'coveralls' -SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[ +SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([ SimpleCov::Formatter::HTMLFormatter, Coveralls::SimpleCov::Formatter, -] +]) -SimpleCov.start { add_filter '/spec/' } +SimpleCov.start do + add_filter '/spec/' +end diff --git a/.travis.yml b/.travis.yml index a050099..77b8267 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,11 +4,22 @@ rvm: - 2.0 - 2.1 - 2.2 - -script: bundle exec rake - -before_install: - - gem update --system + - 2.3 + - 2.4 services: - redis-server + +before_install: + - sudo apt-get update + - sudo apt-get install -y build-essential libtool autotools-dev automake checkinstall check git yasm + + - sudo ./bin/build/libsodium + - sudo ./bin/build/libtoxcore + + - sudo mkdir -p '/etc/ld.so.conf.d/' + - echo '/usr/local/lib/' | sudo tee -a '/etc/ld.so.conf.d/locallib.conf' + - sudo ldconfig + +before_script: + - rake compile diff --git a/Gemfile b/Gemfile index 222c596..f0c8329 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,8 @@ +# frozen_string_literal: true + source 'https://rubygems.org' # Specify your gem's dependencies in lita-tox.gemspec gemspec -gem 'coveralls', require: false +gem 'coveralls', group: :test, require: false diff --git a/README.md b/README.md index e8beb53..774b5af 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ Lita::Adapters::Tox [![Gem Version](https://badge.fury.io/rb/lita-tox.svg)](http://badge.fury.io/rb/lita-tox) [![Build Status](https://travis-ci.org/braiden-vasco/lita-tox.svg)](https://travis-ci.org/braiden-vasco/lita-tox) -[![Coverage Status](https://coveralls.io/repos/braiden-vasco/lita-tox/badge.svg)](https://coveralls.io/r/braiden-vasco/lita-tox) +[![Coverage Status](https://coveralls.io/repos/github/braiden-vasco/lita-tox/badge.svg)](https://coveralls.io/github/braiden-vasco/lita-tox) [Tox](https://tox.chat) adapter for the [Lita](http://lita.io) chat bot. diff --git a/Rakefile b/Rakefile index 52f4cb4..568a4dd 100644 --- a/Rakefile +++ b/Rakefile @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rubygems' gemspec = Gem::Specification.load('lita-tox.gemspec') @@ -7,12 +9,14 @@ github_user, github_project = require 'bundler/gem_tasks' -task default: [:spec, :lint] +task default: %i[spec lint] require 'rspec/core/rake_task' RSpec::Core::RakeTask.new -task lint: [:rubocop] +task lint: :rubocop + +task fix: 'rubocop:auto_correct' require 'rubocop/rake_task' RuboCop::RakeTask.new diff --git a/bin/build/libsodium b/bin/build/libsodium new file mode 100755 index 0000000..751ed50 --- /dev/null +++ b/bin/build/libsodium @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +set -euo pipefail +IFS=$'\n\t' +set -vx + +pushd 'vendor/libsodium' +./autogen.sh +./configure +make install +popd diff --git a/bin/build/libtoxcore b/bin/build/libtoxcore new file mode 100755 index 0000000..7852e13 --- /dev/null +++ b/bin/build/libtoxcore @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +set -euo pipefail +IFS=$'\n\t' +set -vx + +pushd 'vendor/libtoxcore' +autoreconf -i +./configure +make install +popd diff --git a/bin/console b/bin/console index fd61fdc..3560345 100755 --- a/bin/console +++ b/bin/console @@ -1,4 +1,5 @@ #!/usr/bin/env ruby +# frozen_string_literal: true require 'bundler/setup' require 'lita-tox' diff --git a/ext/tox/extconf.rb b/ext/tox/extconf.rb index b8465f5..f2c98da 100755 --- a/ext/tox/extconf.rb +++ b/ext/tox/extconf.rb @@ -1,4 +1,5 @@ #!/usr/bin/env ruby +# frozen_string_literal: true require 'mkmf' diff --git a/lib/lita-tox.rb b/lib/lita-tox.rb index 4b39056..cb1b825 100644 --- a/lib/lita-tox.rb +++ b/lib/lita-tox.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # lita-tox - Tox adapter for the Lita chat bot # Copyright (C) 2015-2017 Braiden Vasco # @@ -14,8 +16,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -# rubocop:disable Style/FileName - require 'lita' Lita.load_locales Dir[File.expand_path( diff --git a/lib/lita/adapters/tox.rb b/lib/lita/adapters/tox.rb index ae16f60..3939e58 100644 --- a/lib/lita/adapters/tox.rb +++ b/lib/lita/adapters/tox.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # lita-tox - Tox adapter for the Lita chat bot # Copyright (C) 2015-2017 Braiden Vasco # @@ -31,7 +33,7 @@ module Lita config :savedata_filename, type: String config :status, type: String - def initialize(robot) + def initialize(robot) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength super options = ::Tox::Options.new diff --git a/lib/tox.rb b/lib/tox.rb index b35d450..db56afe 100644 --- a/lib/tox.rb +++ b/lib/tox.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # lita-tox - Tox adapter for the Lita chat bot # Copyright (C) 2015-2017 Braiden Vasco # @@ -14,36 +16,38 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +# rubocop:disable Layout/SpaceInsideArrayPercentLiteral + require 'tox/tox' -class Tox +class Tox # rubocop:disable Style/Documentation NODES = [ - %w(192.254.75.102 33445 951C88B7E75C867418ACDB5D273821372BB5BD652740BCDF623A4FA293E75D2F), - %w(144.76.60.215 33445 04119E835DF3E78BACF0F84235B300546AF8B936F035185E2A8E9E0A67C8924F), - %w(23.226.230.47 33445 A09162D68618E742FFBCA1C2C70385E6679604B2D80EA6E84AD0996A1AC8A074), - %w(178.62.125.224 33445 10B20C49ACBD968D7C80F2E8438F92EA51F189F4E70CFBBB2C2C8C799E97F03E), - %w(178.21.112.187 33445 4B2C19E924972CB9B57732FB172F8A8604DE13EEDA2A6234E348983344B23057), - %w(195.154.119.113 33445 E398A69646B8CEACA9F0B84F553726C1C49270558C57DF5F3C368F05A7D71354), - %w(192.210.149.121 33445 F404ABAA1C99A9D37D61AB54898F56793E1DEF8BD46B1038B9D822E8460FAB67), - %w(76.191.23.96 33445 93574A3FAB7D612FEA29FD8D67D3DD10DFD07A075A5D62E8AF3DD9F5D0932E11), - %w(46.38.239.179 33445 F5A1A38EFB6BD3C2C8AF8B10D85F0F89E931704D349F1D0720C3C4059AF2440A), - %w(178.62.250.138 33445 788236D34978D1D5BD822F0A5BEBD2C53C64CC31CD3149350EE27D4D9A2F9B6B), - %w(78.225.128.39 33445 7A2306BFBA665E5480AE59B31E116BE9C04DCEFE04D9FE25082316FA34B4DA0C), - %w(130.133.110.14 33445 461FA3776EF0FA655F1A05477DF1B3B614F7D6B124F7DB1DD4FE3C08B03B640F), - %w(104.167.101.29 33445 5918AC3C06955962A75AD7DF4F80A5D7C34F7DB9E1498D2E0495DE35B3FE8A57), - %w(195.154.109.148 33445 391C96CB67AE893D4782B8E4495EB9D89CF1031F48460C06075AA8CE76D50A21), - %w(192.3.173.88 33445 3E1FFDEB667BFF549F619EC6737834762124F50A89C8D0DBF1DDF64A2DD6CD1B), - %w(205.185.116.116 33445 A179B09749AC826FF01F37A9613F6B57118AE014D4196A0E1105A98F93A54702), - %w(198.98.51.198 33445 1D5A5F2F5D6233058BF0259B09622FB40B482E4FA0931EB8FD3AB8E7BF7DAF6F), - %w(80.232.246.79 33445 A7A060D553B017D9D8F038E265C7AFB6C70BAAC55070197F9C007432D0038E0F), - %w(108.61.165.198 33445 8E7D0B859922EF569298B4D261A8CCB5FEA14FB91ED412A7603A585A25698832), - %w(212.71.252.109 33445 C4CEB8C7AC607C6B374E2E782B3C00EA3A63B80D4910B8649CCACDD19F260819), - %w(194.249.212.109 33445 3CEE1F054081E7A011234883BC4FC39F661A55B73637A5AC293DDF1251D9432B), - %w(194.249.212.109 443 3CEE1F054081E7A011234883BC4FC39F661A55B73637A5AC293DDF1251D9432B), - %w(103.38.216.87 33445 601AEE6FC8C17E8CD8F8F1FFC4D4AD84E59A73BE451F037194E7A404E3795320), - %w(185.25.116.107 33445 DA4E4ED4B697F2E9B000EEFE3A34B554ACD3F45F5C96EAEA2516DD7FF9AF7B43), - %w(192.99.168.140 33445 6A4D0607A296838434A6A7DDF99F50EF9D60A2C510BBF31FE538A25CB6B4652F), - ] + %w[192.254.75.102 33445 951C88B7E75C867418ACDB5D273821372BB5BD652740BCDF623A4FA293E75D2F], + %w[144.76.60.215 33445 04119E835DF3E78BACF0F84235B300546AF8B936F035185E2A8E9E0A67C8924F], + %w[23.226.230.47 33445 A09162D68618E742FFBCA1C2C70385E6679604B2D80EA6E84AD0996A1AC8A074], + %w[178.62.125.224 33445 10B20C49ACBD968D7C80F2E8438F92EA51F189F4E70CFBBB2C2C8C799E97F03E], + %w[178.21.112.187 33445 4B2C19E924972CB9B57732FB172F8A8604DE13EEDA2A6234E348983344B23057], + %w[195.154.119.113 33445 E398A69646B8CEACA9F0B84F553726C1C49270558C57DF5F3C368F05A7D71354], + %w[192.210.149.121 33445 F404ABAA1C99A9D37D61AB54898F56793E1DEF8BD46B1038B9D822E8460FAB67], + %w[76.191.23.96 33445 93574A3FAB7D612FEA29FD8D67D3DD10DFD07A075A5D62E8AF3DD9F5D0932E11], + %w[46.38.239.179 33445 F5A1A38EFB6BD3C2C8AF8B10D85F0F89E931704D349F1D0720C3C4059AF2440A], + %w[178.62.250.138 33445 788236D34978D1D5BD822F0A5BEBD2C53C64CC31CD3149350EE27D4D9A2F9B6B], + %w[78.225.128.39 33445 7A2306BFBA665E5480AE59B31E116BE9C04DCEFE04D9FE25082316FA34B4DA0C], + %w[130.133.110.14 33445 461FA3776EF0FA655F1A05477DF1B3B614F7D6B124F7DB1DD4FE3C08B03B640F], + %w[104.167.101.29 33445 5918AC3C06955962A75AD7DF4F80A5D7C34F7DB9E1498D2E0495DE35B3FE8A57], + %w[195.154.109.148 33445 391C96CB67AE893D4782B8E4495EB9D89CF1031F48460C06075AA8CE76D50A21], + %w[192.3.173.88 33445 3E1FFDEB667BFF549F619EC6737834762124F50A89C8D0DBF1DDF64A2DD6CD1B], + %w[205.185.116.116 33445 A179B09749AC826FF01F37A9613F6B57118AE014D4196A0E1105A98F93A54702], + %w[198.98.51.198 33445 1D5A5F2F5D6233058BF0259B09622FB40B482E4FA0931EB8FD3AB8E7BF7DAF6F], + %w[80.232.246.79 33445 A7A060D553B017D9D8F038E265C7AFB6C70BAAC55070197F9C007432D0038E0F], + %w[108.61.165.198 33445 8E7D0B859922EF569298B4D261A8CCB5FEA14FB91ED412A7603A585A25698832], + %w[212.71.252.109 33445 C4CEB8C7AC607C6B374E2E782B3C00EA3A63B80D4910B8649CCACDD19F260819], + %w[194.249.212.109 33445 3CEE1F054081E7A011234883BC4FC39F661A55B73637A5AC293DDF1251D9432B], + %w[194.249.212.109 443 3CEE1F054081E7A011234883BC4FC39F661A55B73637A5AC293DDF1251D9432B], + %w[103.38.216.87 33445 601AEE6FC8C17E8CD8F8F1FFC4D4AD84E59A73BE451F037194E7A404E3795320], + %w[185.25.116.107 33445 DA4E4ED4B697F2E9B000EEFE3A34B554ACD3F45F5C96EAEA2516DD7FF9AF7B43], + %w[192.99.168.140 33445 6A4D0607A296838434A6A7DDF99F50EF9D60A2C510BBF31FE538A25CB6B4652F], + ].freeze attr_accessor :running @@ -51,11 +55,11 @@ class Tox initialize_with(options) NODES.each do |node| - bootstrap({ + bootstrap( ip: node[0], port: node[1].to_i, key: node[2], - }) + ) end end diff --git a/lita-tox.gemspec b/lita-tox.gemspec index 39da14f..32c7896 100644 --- a/lita-tox.gemspec +++ b/lita-tox.gemspec @@ -1,4 +1,5 @@ # coding: utf-8 +# frozen_string_literal: true Gem::Specification.new do |spec| spec.name = 'lita-tox' diff --git a/spec/lita/adapters/tox_spec.rb b/spec/lita/adapters/tox_spec.rb index f87b912..db12b0d 100644 --- a/spec/lita/adapters/tox_spec.rb +++ b/spec/lita/adapters/tox_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # lita-tox - Tox adapter for the Lita chat bot # Copyright (C) 2015-2017 Braiden Vasco # @@ -14,5 +16,5 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -describe Lita::Adapters::Tox, lita: true do -end +# RSpec.describe Lita::Adapters::Tox, lita: true do +# end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 1ef05ee..498ba15 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # lita-tox - Tox adapter for the Lita chat bot # Copyright (C) 2015-2017 Braiden Vasco # @@ -14,19 +16,9 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -# This should be on the top of the file +# This should be on the top of the file. require 'simplecov' -# rubocop:disable Style/BlockComments - -require 'lita-tox' -require 'lita/rspec' - -# A compatibility mode is provided for older plugins upgrading from Lita 3. -# Since this plugin was generated with Lita 4, the compatibility mode -# should be left disabled. -Lita.version_3_compatibility_mode = false - # This file was generated by the `rspec --init` command. Conventionally, all # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. # The generated `.rspec` file contains `--require spec_helper` which will cause @@ -41,10 +33,20 @@ Lita.version_3_compatibility_mode = false # the additional setup, and require it from the spec files that actually need # it. # -# The `.rspec` file also contains a few flags that are not defaults but that -# users commonly want. -# # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration + +require 'timeout' +require 'faker' + +require 'lita/rspec' + +# require 'lita-tox' + +# A compatibility mode is provided for older plugins upgrading from Lita 3. +# Since this plugin was generated with Lita 4, the compatibility mode +# should be left disabled. +Lita.version_3_compatibility_mode = false + RSpec.configure do |config| # rspec-expectations config goes here. You can use an alternate # assertion/expectation library such as wrong or the stdlib/minitest @@ -69,26 +71,30 @@ RSpec.configure do |config| mocks.verify_partial_doubles = true end -# The settings below are suggested to provide a good initial experience -# with RSpec, but feel free to customize to your heart's content. -=begin - # These two settings work together to allow you to limit a spec run - # to individual examples or groups you care about by tagging them with - # `:focus` metadata. When nothing is tagged with `:focus`, all examples - # get run. - config.filter_run :focus - config.run_all_when_everything_filtered = true + # This option will default to `:apply_to_host_groups` in RSpec 4 (and will + # have no way to turn it off -- the option exists only for backwards + # compatibility in RSpec 3). It causes shared context metadata to be + # inherited by the metadata hash of host groups and examples, rather than + # triggering implicit auto-inclusion in groups with matching metadata. + config.shared_context_metadata_behavior = :apply_to_host_groups + + # This allows you to limit a spec run to individual examples or groups + # you care about by tagging them with `:focus` metadata. When nothing + # is tagged with `:focus`, all examples get run. RSpec also provides + # aliases for `it`, `describe`, and `context` that include `:focus` + # metadata: `fit`, `fdescribe` and `fcontext`, respectively. + config.filter_run_when_matching :focus # Allows RSpec to persist some state between runs in order to support # the `--only-failures` and `--next-failure` CLI options. We recommend # you configure your source control system to ignore this file. - config.example_status_persistence_file_path = "spec/examples.txt" + config.example_status_persistence_file_path = 'spec/examples.txt' # Limits the available syntax to the non-monkey patched syntax that is # recommended. For more details, see: - # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax + # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/ # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/ - # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching + # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode config.disable_monkey_patching! # This setting enables warnings. It's recommended, but in some cases may @@ -121,5 +127,4 @@ RSpec.configure do |config| # test failures related to randomization by passing the same `--seed` value # as the one that triggered the failure. Kernel.srand config.seed -=end end diff --git a/vendor/libsodium b/vendor/libsodium new file mode 160000 index 0000000..63dd054 --- /dev/null +++ b/vendor/libsodium @@ -0,0 +1 @@ +Subproject commit 63dd05419e8a4175fd59da50a58afbdc20a2cd31 diff --git a/vendor/libtoxcore b/vendor/libtoxcore new file mode 160000 index 0000000..a429ef4 --- /dev/null +++ b/vendor/libtoxcore @@ -0,0 +1 @@ +Subproject commit a429ef4a28a5e5e0ad010efffb76d2abc3ada0af