diff --git a/.gitignore b/.gitignore index daedea2..5d67793 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,4 @@ Gemfile.lock /.git-rewrite/ .yardoc/ doc/ +bin/ diff --git a/Rakefile b/Rakefile index eaf68dc..6333ca6 100644 --- a/Rakefile +++ b/Rakefile @@ -3,6 +3,7 @@ require 'bundler/gem_tasks' require 'rspec/core/rake_task' require 'coveralls/rake/task' require 'yard' +require 'yard-rspec' Coveralls::RakeTask.new RSpec::Core::RakeTask.new(:spec) do |spec| @@ -16,10 +17,12 @@ end # Dummy::Application.load_tasks # Rake::Task["db:test:prepare"].invoke # end +YARD::Config.options[:load_plugins] = true +YARD::Config.load_plugins YARD::Rake::YardocTask.new do |t| - t.files = ['lib/**/*.rb'] # optional - t.options = ['--any', '--extra', '--opts', '--markup-provider=redcarpet', '--markup=markdown'] # optional + t.files = ['lib/**/*.rb', 'spec/**/*_spec.rb'] # optional + t.options = ['--any', '--extra', '--opts', '--markup-provider=redcarpet', '--markup=markdown', '--debug'] # optional t.stats_options = ['--list-undoc'] # optional end @@ -44,7 +47,7 @@ task :all do |_t| if ENV['TRAVIS'] exec(' bundle exec phare && bundle exec rake spec && bundle exec rake coveralls:push') else - exec('bundle exec phare && bundle exec rake spec') + exec('bundle exec rubocop -a . && bundle exec phare && bundle exec rake spec') end end diff --git a/bin/appraisal b/bin/appraisal deleted file mode 100755 index 8a77bcd..0000000 --- a/bin/appraisal +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env ruby -# -# This file was generated by Bundler. -# -# The application 'appraisal' is installed as part of a gem, and -# this file is here to facilitate running it. -# - -require 'pathname' -ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile", - Pathname.new(__FILE__).realpath) - -require 'rubygems' -require 'bundler/setup' - -load Gem.bin_path('appraisal', 'appraisal') diff --git a/bin/autospec b/bin/autospec deleted file mode 100755 index 64dcb9c..0000000 --- a/bin/autospec +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env ruby -# -# This file was generated by Bundler. -# -# The application 'autospec' is installed as part of a gem, and -# this file is here to facilitate running it. -# - -require 'pathname' -ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile", - Pathname.new(__FILE__).realpath) - -require 'rubygems' -require 'bundler/setup' - -load Gem.bin_path('rspec-core', 'autospec') diff --git a/bin/bundler b/bin/bundler deleted file mode 100755 index 72c62ec..0000000 --- a/bin/bundler +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env ruby -# -# This file was generated by Bundler. -# -# The application 'bundler' is installed as part of a gem, and -# this file is here to facilitate running it. -# - -require 'pathname' -ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile", - Pathname.new(__FILE__).realpath) - -require 'rubygems' -require 'bundler/setup' - -load Gem.bin_path('bundler', 'bundler') diff --git a/bin/cdiff b/bin/cdiff deleted file mode 100755 index 066279d..0000000 --- a/bin/cdiff +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env ruby -# -# This file was generated by Bundler. -# -# The application 'cdiff' is installed as part of a gem, and -# this file is here to facilitate running it. -# - -require 'pathname' -ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile", - Pathname.new(__FILE__).realpath) - -require 'rubygems' -require 'bundler/setup' - -load Gem.bin_path('term-ansicolor', 'cdiff') diff --git a/bin/coderay b/bin/coderay deleted file mode 100755 index 5be1c00..0000000 --- a/bin/coderay +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env ruby -# -# This file was generated by Bundler. -# -# The application 'coderay' is installed as part of a gem, and -# this file is here to facilitate running it. -# - -require 'pathname' -ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile", - Pathname.new(__FILE__).realpath) - -require 'rubygems' -require 'bundler/setup' - -load Gem.bin_path('coderay', 'coderay') diff --git a/bin/colortab b/bin/colortab deleted file mode 100755 index 195df76..0000000 --- a/bin/colortab +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env ruby -# -# This file was generated by Bundler. -# -# The application 'colortab' is installed as part of a gem, and -# this file is here to facilitate running it. -# - -require 'pathname' -ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile", - Pathname.new(__FILE__).realpath) - -require 'rubygems' -require 'bundler/setup' - -load Gem.bin_path('term-ansicolor', 'colortab') diff --git a/bin/coveralls b/bin/coveralls deleted file mode 100755 index 5a8ac81..0000000 --- a/bin/coveralls +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env ruby -# -# This file was generated by Bundler. -# -# The application 'coveralls' is installed as part of a gem, and -# this file is here to facilitate running it. -# - -require 'pathname' -ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile", - Pathname.new(__FILE__).realpath) - -require 'rubygems' -require 'bundler/setup' - -load Gem.bin_path('coveralls', 'coveralls') diff --git a/bin/decolor b/bin/decolor deleted file mode 100755 index 214e8d1..0000000 --- a/bin/decolor +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env ruby -# -# This file was generated by Bundler. -# -# The application 'decolor' is installed as part of a gem, and -# this file is here to facilitate running it. -# - -require 'pathname' -ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile", - Pathname.new(__FILE__).realpath) - -require 'rubygems' -require 'bundler/setup' - -load Gem.bin_path('term-ansicolor', 'decolor') diff --git a/bin/erubis b/bin/erubis deleted file mode 100755 index 2c7348b..0000000 --- a/bin/erubis +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env ruby -# -# This file was generated by Bundler. -# -# The application 'erubis' is installed as part of a gem, and -# this file is here to facilitate running it. -# - -require 'pathname' -ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile", - Pathname.new(__FILE__).realpath) - -require 'rubygems' -require 'bundler/setup' - -load Gem.bin_path('erubis', 'erubis') diff --git a/bin/guard b/bin/guard deleted file mode 100755 index 0c1a532..0000000 --- a/bin/guard +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env ruby -# -# This file was generated by Bundler. -# -# The application 'guard' is installed as part of a gem, and -# this file is here to facilitate running it. -# - -require 'pathname' -ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile", - Pathname.new(__FILE__).realpath) - -require 'rubygems' -require 'bundler/setup' - -load Gem.bin_path('guard', 'guard') diff --git a/bin/htmldiff b/bin/htmldiff deleted file mode 100755 index c70e238..0000000 --- a/bin/htmldiff +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env ruby -# -# This file was generated by Bundler. -# -# The application 'htmldiff' is installed as part of a gem, and -# this file is here to facilitate running it. -# - -require 'pathname' -ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile", - Pathname.new(__FILE__).realpath) - -require 'rubygems' -require 'bundler/setup' - -load Gem.bin_path('diff-lcs', 'htmldiff') diff --git a/bin/inch b/bin/inch deleted file mode 100755 index 6d2ad25..0000000 --- a/bin/inch +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env ruby -# -# This file was generated by Bundler. -# -# The application 'inch' is installed as part of a gem, and -# this file is here to facilitate running it. -# - -require 'pathname' -ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile", - Pathname.new(__FILE__).realpath) - -require 'rubygems' -require 'bundler/setup' - -load Gem.bin_path('inch', 'inch') diff --git a/bin/ldiff b/bin/ldiff deleted file mode 100755 index 8e3524a..0000000 --- a/bin/ldiff +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env ruby -# -# This file was generated by Bundler. -# -# The application 'ldiff' is installed as part of a gem, and -# this file is here to facilitate running it. -# - -require 'pathname' -ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile", - Pathname.new(__FILE__).realpath) - -require 'rubygems' -require 'bundler/setup' - -load Gem.bin_path('diff-lcs', 'ldiff') diff --git a/bin/listen b/bin/listen deleted file mode 100755 index 093a5fc..0000000 --- a/bin/listen +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env ruby -# -# This file was generated by Bundler. -# -# The application 'listen' is installed as part of a gem, and -# this file is here to facilitate running it. -# - -require 'pathname' -ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile", - Pathname.new(__FILE__).realpath) - -require 'rubygems' -require 'bundler/setup' - -load Gem.bin_path('listen', 'listen') diff --git a/bin/nokogiri b/bin/nokogiri deleted file mode 100755 index d55f84b..0000000 --- a/bin/nokogiri +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env ruby -# -# This file was generated by Bundler. -# -# The application 'nokogiri' is installed as part of a gem, and -# this file is here to facilitate running it. -# - -require 'pathname' -ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile", - Pathname.new(__FILE__).realpath) - -require 'rubygems' -require 'bundler/setup' - -load Gem.bin_path('nokogiri', 'nokogiri') diff --git a/bin/phare b/bin/phare deleted file mode 100755 index eeb7f10..0000000 --- a/bin/phare +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env ruby -# -# This file was generated by Bundler. -# -# The application 'phare' is installed as part of a gem, and -# this file is here to facilitate running it. -# - -require 'pathname' -ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile", - Pathname.new(__FILE__).realpath) - -require 'rubygems' -require 'bundler/setup' - -load Gem.bin_path('phare', 'phare') diff --git a/bin/pry b/bin/pry deleted file mode 100755 index 54678a3..0000000 --- a/bin/pry +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env ruby -# -# This file was generated by Bundler. -# -# The application 'pry' is installed as part of a gem, and -# this file is here to facilitate running it. -# - -require 'pathname' -ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile", - Pathname.new(__FILE__).realpath) - -require 'rubygems' -require 'bundler/setup' - -load Gem.bin_path('pry', 'pry') diff --git a/bin/rackup b/bin/rackup deleted file mode 100755 index 8cc9953..0000000 --- a/bin/rackup +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env ruby -# -# This file was generated by Bundler. -# -# The application 'rackup' is installed as part of a gem, and -# this file is here to facilitate running it. -# - -require 'pathname' -ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile", - Pathname.new(__FILE__).realpath) - -require 'rubygems' -require 'bundler/setup' - -load Gem.bin_path('rack', 'rackup') diff --git a/bin/rails b/bin/rails deleted file mode 100755 index 657440d..0000000 --- a/bin/rails +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env ruby -# -# This file was generated by Bundler. -# -# The application 'rails' is installed as part of a gem, and -# this file is here to facilitate running it. -# - -require 'pathname' -ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile", - Pathname.new(__FILE__).realpath) - -require 'rubygems' -require 'bundler/setup' - -load Gem.bin_path('railties', 'rails') diff --git a/bin/rake b/bin/rake deleted file mode 100755 index 26c7a2d..0000000 --- a/bin/rake +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env ruby -# -# This file was generated by Bundler. -# -# The application 'rake' is installed as part of a gem, and -# this file is here to facilitate running it. -# - -require 'pathname' -ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile", - Pathname.new(__FILE__).realpath) - -require 'rubygems' -require 'bundler/setup' - -load Gem.bin_path('rake', 'rake') diff --git a/bin/restclient b/bin/restclient deleted file mode 100755 index 4d7bdcf..0000000 --- a/bin/restclient +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env ruby -# -# This file was generated by Bundler. -# -# The application 'restclient' is installed as part of a gem, and -# this file is here to facilitate running it. -# - -require 'pathname' -ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile", - Pathname.new(__FILE__).realpath) - -require 'rubygems' -require 'bundler/setup' - -load Gem.bin_path('rest-client', 'restclient') diff --git a/bin/rspec b/bin/rspec deleted file mode 100755 index 0c86b5c..0000000 --- a/bin/rspec +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env ruby -# -# This file was generated by Bundler. -# -# The application 'rspec' is installed as part of a gem, and -# this file is here to facilitate running it. -# - -require 'pathname' -ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile", - Pathname.new(__FILE__).realpath) - -require 'rubygems' -require 'bundler/setup' - -load Gem.bin_path('rspec-core', 'rspec') diff --git a/bin/rubocop b/bin/rubocop deleted file mode 100755 index a8a38b7..0000000 --- a/bin/rubocop +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env ruby -# -# This file was generated by Bundler. -# -# The application 'rubocop' is installed as part of a gem, and -# this file is here to facilitate running it. -# - -require 'pathname' -ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile", - Pathname.new(__FILE__).realpath) - -require 'rubygems' -require 'bundler/setup' - -load Gem.bin_path('rubocop', 'rubocop') diff --git a/bin/ruby-parse b/bin/ruby-parse deleted file mode 100755 index 757c56c..0000000 --- a/bin/ruby-parse +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env ruby -# -# This file was generated by Bundler. -# -# The application 'ruby-parse' is installed as part of a gem, and -# this file is here to facilitate running it. -# - -require 'pathname' -ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile", - Pathname.new(__FILE__).realpath) - -require 'rubygems' -require 'bundler/setup' - -load Gem.bin_path('parser', 'ruby-parse') diff --git a/bin/ruby-rewrite b/bin/ruby-rewrite deleted file mode 100755 index f686c65..0000000 --- a/bin/ruby-rewrite +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env ruby -# -# This file was generated by Bundler. -# -# The application 'ruby-rewrite' is installed as part of a gem, and -# this file is here to facilitate running it. -# - -require 'pathname' -ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile", - Pathname.new(__FILE__).realpath) - -require 'rubygems' -require 'bundler/setup' - -load Gem.bin_path('parser', 'ruby-rewrite') diff --git a/bin/sass b/bin/sass deleted file mode 100755 index d65bb10..0000000 --- a/bin/sass +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env ruby -# -# This file was generated by Bundler. -# -# The application 'sass' is installed as part of a gem, and -# this file is here to facilitate running it. -# - -require 'pathname' -ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile", - Pathname.new(__FILE__).realpath) - -require 'rubygems' -require 'bundler/setup' - -load Gem.bin_path('sass', 'sass') diff --git a/bin/sass-convert b/bin/sass-convert deleted file mode 100755 index ddde743..0000000 --- a/bin/sass-convert +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env ruby -# -# This file was generated by Bundler. -# -# The application 'sass-convert' is installed as part of a gem, and -# this file is here to facilitate running it. -# - -require 'pathname' -ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile", - Pathname.new(__FILE__).realpath) - -require 'rubygems' -require 'bundler/setup' - -load Gem.bin_path('sass', 'sass-convert') diff --git a/bin/scss b/bin/scss deleted file mode 100755 index 9f5e435..0000000 --- a/bin/scss +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env ruby -# -# This file was generated by Bundler. -# -# The application 'scss' is installed as part of a gem, and -# this file is here to facilitate running it. -# - -require 'pathname' -ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile", - Pathname.new(__FILE__).realpath) - -require 'rubygems' -require 'bundler/setup' - -load Gem.bin_path('sass', 'scss') diff --git a/bin/scss-lint b/bin/scss-lint deleted file mode 100755 index 7789c37..0000000 --- a/bin/scss-lint +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env ruby -# -# This file was generated by Bundler. -# -# The application 'scss-lint' is installed as part of a gem, and -# this file is here to facilitate running it. -# - -require 'pathname' -ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile", - Pathname.new(__FILE__).realpath) - -require 'rubygems' -require 'bundler/setup' - -load Gem.bin_path('scss-lint', 'scss-lint') diff --git a/bin/sparkr b/bin/sparkr deleted file mode 100755 index 6a79a18..0000000 --- a/bin/sparkr +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env ruby -# -# This file was generated by Bundler. -# -# The application 'sparkr' is installed as part of a gem, and -# this file is here to facilitate running it. -# - -require 'pathname' -ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile", - Pathname.new(__FILE__).realpath) - -require 'rubygems' -require 'bundler/setup' - -load Gem.bin_path('sparkr', 'sparkr') diff --git a/bin/term_display b/bin/term_display deleted file mode 100755 index d65c316..0000000 --- a/bin/term_display +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env ruby -# -# This file was generated by Bundler. -# -# The application 'term_display' is installed as part of a gem, and -# this file is here to facilitate running it. -# - -require 'pathname' -ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile", - Pathname.new(__FILE__).realpath) - -require 'rubygems' -require 'bundler/setup' - -load Gem.bin_path('term-ansicolor', 'term_display') diff --git a/bin/term_mandel b/bin/term_mandel deleted file mode 100755 index c7dd35e..0000000 --- a/bin/term_mandel +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env ruby -# -# This file was generated by Bundler. -# -# The application 'term_mandel' is installed as part of a gem, and -# this file is here to facilitate running it. -# - -require 'pathname' -ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile", - Pathname.new(__FILE__).realpath) - -require 'rubygems' -require 'bundler/setup' - -load Gem.bin_path('term-ansicolor', 'term_mandel') diff --git a/bin/thor b/bin/thor deleted file mode 100755 index 8421e00..0000000 --- a/bin/thor +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env ruby -# -# This file was generated by Bundler. -# -# The application 'thor' is installed as part of a gem, and -# this file is here to facilitate running it. -# - -require 'pathname' -ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile", - Pathname.new(__FILE__).realpath) - -require 'rubygems' -require 'bundler/setup' - -load Gem.bin_path('thor', 'thor') diff --git a/bin/yard b/bin/yard deleted file mode 100755 index bd489a8..0000000 --- a/bin/yard +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env ruby -# -# This file was generated by Bundler. -# -# The application 'yard' is installed as part of a gem, and -# this file is here to facilitate running it. -# - -require 'pathname' -ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile", - Pathname.new(__FILE__).realpath) - -require 'rubygems' -require 'bundler/setup' - -load Gem.bin_path('yard', 'yard') diff --git a/bin/yardoc b/bin/yardoc deleted file mode 100755 index 43eff6b..0000000 --- a/bin/yardoc +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env ruby -# -# This file was generated by Bundler. -# -# The application 'yardoc' is installed as part of a gem, and -# this file is here to facilitate running it. -# - -require 'pathname' -ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile", - Pathname.new(__FILE__).realpath) - -require 'rubygems' -require 'bundler/setup' - -load Gem.bin_path('yard', 'yardoc') diff --git a/bin/yardstick b/bin/yardstick deleted file mode 100755 index 71d7ca0..0000000 --- a/bin/yardstick +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env ruby -# -# This file was generated by Bundler. -# -# The application 'yardstick' is installed as part of a gem, and -# this file is here to facilitate running it. -# - -require 'pathname' -ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile", - Pathname.new(__FILE__).realpath) - -require 'rubygems' -require 'bundler/setup' - -load Gem.bin_path('yardstick', 'yardstick') diff --git a/bin/yri b/bin/yri deleted file mode 100755 index 05f2461..0000000 --- a/bin/yri +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env ruby -# -# This file was generated by Bundler. -# -# The application 'yri' is installed as part of a gem, and -# this file is here to facilitate running it. -# - -require 'pathname' -ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile", - Pathname.new(__FILE__).realpath) - -require 'rubygems' -require 'bundler/setup' - -load Gem.bin_path('yard', 'yri') diff --git a/celluloid_pubsub.gemspec b/celluloid_pubsub.gemspec index 833168d..a3a5be4 100644 --- a/celluloid_pubsub.gemspec +++ b/celluloid_pubsub.gemspec @@ -33,8 +33,8 @@ Gem::Specification.new do |s| s.add_development_dependency 'rubocop', '0.29' s.add_development_dependency 'phare', '~> 0.6', '>= 0.6' - s.add_development_dependency 'scss-lint', '~> 0.34', '>= 0.34' s.add_development_dependency 'yard', '~> 0.8.7', '>= 0.8.7' + s.add_development_dependency 'yard-rspec', '~> 0.1', '>= 0.1' s.add_development_dependency 'redcarpet', '~> 3.2.2', '>= 3.2.2' s.add_development_dependency 'github-markup', '~> 1.3.3', '>= 1.3.3' s.add_development_dependency 'inch', '~> 0.5.10' diff --git a/lib/celluloid_pubsub/reactor.rb b/lib/celluloid_pubsub/reactor.rb index 9fbd64b..d4902b6 100644 --- a/lib/celluloid_pubsub/reactor.rb +++ b/lib/celluloid_pubsub/reactor.rb @@ -2,15 +2,13 @@ module CelluloidPubsub # The reactor handles new connections. Based on what the client sends it either subscribes to a channel # or will publish to a channel or just dispatch to the server if command is neither subscribe, publish or unsubscribe + # # @!attribute websocket # @return [Reel::WebSocket] websocket connection # # @!attribute server # @return [CelluloidPubsub::Webserver] the server actor to which the reactor is connected to # - # @!attribute mutex - # @return [Mutex] mutex used to lock when subscribing to a channel - # # @!attribute channels # @return [Array] array of channels to which the current reactor has subscribed to class Reactor @@ -18,10 +16,10 @@ class Reactor include Celluloid::IO include Celluloid::Logger - attr_accessor :websocket, :server, :mutex, :channels + attr_accessor :websocket, :server, :channels # rececives a new socket connection from the server - # and initiates a new mutex that can be used when subsribing to a channel + # and listens for messages # # @param [Reel::WebSocket] websocket # @@ -30,7 +28,6 @@ class Reactor # @api public def work(websocket, server) @server = server - @mutex = Mutex.new @channels = [] @websocket = websocket info "Streaming changes for #{websocket.url}" if @server.debug_enabled? @@ -44,11 +41,14 @@ def work(websocket, server) # @return [void] # # @api public + # + # :nocov: def run while message = @websocket.read handle_websocket_message(message) end end + # :nocov: # method used to parse a JSON object into a Hash object # @@ -170,11 +170,11 @@ def handle_unknown_action(json_data) # @api public def unsubscribe_client(channel) return unless channel.present? - @channels.delete(channel) + @channels.delete(channel) unless @channels.blank? @websocket.close if @channels.blank? @server.subscribers[channel].delete_if do |hash| hash[:reactor] == Actor.current - end + end if @server.subscribers[channel].present? end # the method will terminate the current actor @@ -200,13 +200,9 @@ def shutdown # @api public def start_subscriber(channel, message) return unless channel.present? - begin - add_subscriber_to_channel(channel, message) - debug "Subscribed to #{channel} with #{message}" if @server.debug_enabled? - @websocket << message.merge('client_action' => 'successful_subscription', 'channel' => channel).to_json - rescue => e - raise [e, e.respond_to?(:backtrace) ? e.backtrace : '', channel, message].inspect - end + add_subscriber_to_channel(channel, message) + debug "Subscribed to #{channel} with #{message}" if @server.debug_enabled? + @websocket << message.merge('client_action' => 'successful_subscription', 'channel' => channel).to_json end # adds the curent actor the list of the subscribers for a particular channel diff --git a/lib/celluloid_pubsub/version.rb b/lib/celluloid_pubsub/version.rb index 34dc88c..08e352c 100644 --- a/lib/celluloid_pubsub/version.rb +++ b/lib/celluloid_pubsub/version.rb @@ -17,7 +17,7 @@ module VERSION # minor release version MINOR = 0 # tiny release version - TINY = 8 + TINY = 9 # prelease version ( set this only if it is a prelease) PRE = nil diff --git a/lib/celluloid_pubsub/web_server.rb b/lib/celluloid_pubsub/web_server.rb index d9c4dda..7308e54 100644 --- a/lib/celluloid_pubsub/web_server.rb +++ b/lib/celluloid_pubsub/web_server.rb @@ -51,12 +51,15 @@ class WebServer < Reel::Server::HTTP # @return [void] # # @api public + # + # :nocov: def initialize(options = {}) parse_options(options) @subscribers = {} info "CelluloidPubsub::WebServer example starting on #{@hostname}:#{@port}" if debug_enabled? super(@hostname, @port, { spy: @spy, backlog: @backlog }, &method(:on_connection)) end + # :nocov: # receives a list of options that are used to configure the webserver # diff --git a/spec/lib/celluloid_pubsub/client_pubsub_spec.rb b/spec/lib/celluloid_pubsub/client_pubsub_spec.rb index bc1608b..49f3583 100644 --- a/spec/lib/celluloid_pubsub/client_pubsub_spec.rb +++ b/spec/lib/celluloid_pubsub/client_pubsub_spec.rb @@ -3,7 +3,135 @@ require 'spec_helper' describe CelluloidPubsub::Client do + let(:options) { {} } + let(:blk) { proc { |a| puts a } } + + it 'runs the connect method' do + expected = nil + CelluloidPubsub::Client::PubSubWorker.stubs(:new).returns(expected) + res = CelluloidPubsub::Client.connect(options, &blk) + res.should eq expected + end end describe CelluloidPubsub::Client::PubSubWorker do + let(:blk) { proc { |a| puts a } } + let(:options) { {} } + let(:socket) { mock } + let(:actor) { mock } + + before(:each) do + Celluloid::WebSocket::Client.stubs(:new).returns(socket) + socket.stubs(:text) + @worker = CelluloidPubsub::Client::PubSubWorker.new({ 'actor' => actor }, &blk) + @worker.stubs(:client).returns(socket) + @worker.stubs(:debug) + @worker.stubs(:async).returns(@worker) + actor.stubs(:async).returns(actor) + end + + describe '#initialize' do + it 'creates a object' do + @worker.connect_blk.should_not be_nil + @worker.actor.should eq actor + end + end + + describe '#parse_options' do + let(:actor) { mock } + let(:hostname) { '127.0.0.1' } + let(:port) { 9999 } + let(:path) { '/some_path' } + let(:custom_options) { { actor: actor, hostname: hostname, port: port, path: path } } + + it 'parses options' do + @worker.parse_options(custom_options) + @worker.actor.should eq(actor) + @worker.hostname.should eq(hostname) + @worker.port.should eq(port) + @worker.path.should eq(path) + end + + it 'sets defaults' do + @worker.parse_options({}) + @worker.actor.should eq(nil) + @worker.hostname.should eq('0.0.0.0') + @worker.port.should eq(1234) + @worker.path.should eq('/ws') + end + end + + describe '#debug_enabled?' do + it 'checks if debug is enabled' do + CelluloidPubsub::WebServer.expects(:debug_enabled?).returns(true) + act = @worker.debug_enabled? + act.should eq(true) + end + end + + describe '#subscribe' do + let(:channel) { 'some_channel' } + it 'chats with the server' do + @worker.expects(:chat).with('client_action' => 'subscribe', 'channel' => channel) + @worker.subscribe(channel) + end + end + + describe '#publish' do + let(:channel) { 'some_channel' } + let(:data) { 'some_message' } + it 'chats with the server' do + @worker.expects(:chat).with('client_action' => 'publish', 'channel' => channel, 'data' => data) + @worker.publish(channel, data) + end + end + + describe '#on_open' do + let(:channel) { 'some_channel' } + let(:data) { 'some_message' } + it 'chats with the server' do + @worker.connect_blk.expects(:call) + @worker.on_open + end + end + + describe '#on_message' do + let(:channel) { 'some_channel' } + let(:data) { 'some_message' } + it 'chats with the server' do + JSON.expects(:parse).with(data).returns(data) + @worker.actor.expects(:async).returns(actor) + @worker.actor.expects(:on_message).with(data) + @worker.on_message(data) + end + end + + describe '#on_close' do + let(:channel) { 'some_channel' } + let(:code) { 'some_message' } + let(:reason) { 'some reason' } + + it 'chats with the server' do + @worker.client.expects(:terminate) + @worker.actor.expects(:on_close).with(code, reason) + @worker.on_close(code, reason) + end + end + + describe '#chat' do + let(:channel) { 'some_channel' } + let(:data) { 'some_message' } + let(:data_hash) { { a: 'some mesage ' } } + let(:json) { { action: 'message', message: data } } + it 'chats witout hash' do + JSON.expects(:dump).with(json).returns(json) + @worker.client.expects(:text).with(json) + @worker.send(:chat, data) + end + + it 'chats with a hash' do + @worker.client.expects(:text).with(data_hash.to_json) + @worker.send(:chat, data_hash) + end + end end diff --git a/spec/lib/celluloid_pubsub/reactor_spec.rb b/spec/lib/celluloid_pubsub/reactor_spec.rb index 0d06e36..c3dd6b5 100644 --- a/spec/lib/celluloid_pubsub/reactor_spec.rb +++ b/spec/lib/celluloid_pubsub/reactor_spec.rb @@ -3,4 +3,212 @@ require 'spec_helper' describe CelluloidPubsub::Reactor do + let(:websocket) { mock } + let(:server) { mock } + + before(:each) do + subject.stubs(:async).returns(subject) + server.stubs(:debug_enabled?).returns(false) + server.stubs(:async).returns(server) + server.stubs(:handle_dispatched_message) + server.stubs(:subscribers).returns({}) + websocket.stubs(:read) + subject.stubs(:inspect).returns(subject) + subject.stubs(:run) + subject.work(websocket, server) + end + + describe '#work' do + it 'works ' do + subject.expects(:run) + subject.work(websocket, server) + subject.websocket.should eq websocket + subject.server.should eq server + subject.channels.should eq [] + end + end + + # describe '#rub' do + # let(:data) { 'some message' } + # + # it 'works ' do + # subject.unstub(:run) + # websocket.stubs(:read).returns(data) + # subject.expects(:handle_websocket_message).with(data) + # subject.run + # end + # end + + describe '#parse_json_data' do + let(:data) { 'some message' } + let(:expected) { data.to_json } + + it 'works with hash ' do + JSON.expects(:parse).with(data).returns(expected) + actual = subject.parse_json_data(data) + actual.should eq expected + end + + it 'works with exception parsing ' do + JSON.expects(:parse).with(data).raises(StandardError) + actual = subject.parse_json_data(data) + actual.should eq data + end + end + + describe '#handle_websocket_message' do + let(:data) { 'some message' } + let(:json_data) { { a: 'b' } } + + it 'handle_websocket_message' do + subject.expects(:parse_json_data).with(data).returns(json_data) + subject.expects(:handle_parsed_websocket_message).with(json_data) + subject.handle_websocket_message(data) + end + end + + describe '#handle_parsed_websocket_message' do + it 'handle_websocket_message with a hash' do + data = { 'client_action' => 'b' } + data.expects(:stringify_keys).returns(data) + subject.expects(:delegate_action).with(data) + subject.handle_parsed_websocket_message(data) + end + + it 'handle_websocket_message with something else than a hash' do + data = 'some message' + subject.expects(:handle_unknown_action).with(data) + subject.handle_parsed_websocket_message(data) + end + end + + describe '#delegate_action' do + it 'unsubscribes all' do + data = { 'client_action' => 'unsubscribe_all' } + subject.expects(:unsubscribe_all).returns('bla') + subject.delegate_action(data) + end + + it 'unsubscribes all' do + data = { 'client_action' => 'unsubscribe', 'channel' => 'some channel' } + subject.expects(:unsubscribe_client).with(data['channel']) + subject.delegate_action(data) + end + + it 'subscribes to channell' do + data = { 'client_action' => 'subscribe', 'channel' => 'some channel' } + subject.expects(:start_subscriber).with(data['channel'], data) + subject.delegate_action(data) + end + + it 'publish' do + data = { 'client_action' => 'publish', 'channel' => 'some channel', 'data' => 'some data' } + server.expects(:publish_event).with(data['channel'], data['data'].to_json) + subject.delegate_action(data) + end + + it 'handles unknown' do + data = { 'client_action' => 'some action', 'channel' => 'some channel' } + subject.expects(:handle_unknown_action).with(data) + subject.delegate_action(data) + end + end + + describe '#handle_unknown_action' do + it 'handles unknown' do + data = 'some data' + server.expects(:handle_dispatched_message) + subject.handle_unknown_action(data) + end + end + + describe '#unsubscribe_client' do + let(:channel) { 'some channel' } + it 'returns nil' do + act = subject.unsubscribe_client('') + act.should eq(nil) + end + + it 'unsubscribes' do + subject.channels.stubs(:blank?).returns(false) + subject.channels.expects(:delete).with(channel) + act = subject.unsubscribe_client(channel) + act.should eq(nil) + end + + it 'unsubscribes' do + subject.channels.stubs(:blank?).returns(true) + subject.websocket.expects(:close) + act = subject.unsubscribe_client(channel) + act.should eq(nil) + end + + it 'unsubscribes' do + subject.channels.stubs(:blank?).returns(false) + subject.channels.stubs(:delete) + server.stubs(:subscribers).returns("#{channel}" => [{ reactor: subject }]) + subject.unsubscribe_client(channel) + server.subscribers[channel].should eq([]) + end + end + + describe '#shutdown' do + it 'shutdowns' do + subject.expects(:terminate) + subject.shutdown + end + end + + describe '#start_subscriber' do + let(:channel) { 'some channel' } + let(:message) { { a: 'b' } } + + it 'subscribes ' do + act = subject.start_subscriber('', message) + act.should eq(nil) + end + + it 'subscribes ' do + subject.stubs(:add_subscriber_to_channel).with(channel, message) + subject.websocket.expects(:<<).with(message.merge('client_action' => 'successful_subscription', 'channel' => channel).to_json) + subject.start_subscriber(channel, message) + end + + # it 'raises error' do + # subject.stubs(:add_subscriber_to_channel).raises(StandardError) + # + # expect do + # subject.start_subscriber(channel, message) + # end.to raise_error(StandardError) { |e| + # expect(e.message).to include(channel) + # } + # end + end + + describe '#add_subscriber_to_channel' do + let(:channel) { 'some channel' } + let(:message) { { a: 'b' } } + + it 'adds subscribed' do + CelluloidPubsub::Registry.channels.stubs(:include?).with(channel).returns(false) + CelluloidPubsub::Registry.channels.expects(:<<).with(channel) + server.subscribers[channel] = [] + server.subscribers[channel].expects(:<<).with(reactor: subject, message: message) + subject.add_subscriber_to_channel(channel, message) + subject.channels.should include(channel) + end + end + + describe '#unsubscribe_all' do + let(:channel) { 'some channel' } + let(:message) { { a: 'b' } } + + it 'adds subscribed' do + CelluloidPubsub::Registry.stubs(:channels).returns([channel]) + server.subscribers.stubs(:[]).with(channel).returns([{ reactor: subject, message: message }]) + subject.websocket.expects(:close) + subject.expects(:shutdown) + subject.unsubscribe_all + end + end end diff --git a/spec/lib/celluloid_pubsub/registry_spec.rb b/spec/lib/celluloid_pubsub/registry_spec.rb index b5b5347..ba687f4 100644 --- a/spec/lib/celluloid_pubsub/registry_spec.rb +++ b/spec/lib/celluloid_pubsub/registry_spec.rb @@ -3,4 +3,8 @@ require 'spec_helper' describe CelluloidPubsub::Registry do + it 'has class atributes' do + act = CelluloidPubsub::Registry.respond_to?(:channels) + act.should eq true + end end diff --git a/spec/lib/celluloid_pubsub/web_server_spec.rb b/spec/lib/celluloid_pubsub/web_server_spec.rb index 55ab3ed..dd1861b 100644 --- a/spec/lib/celluloid_pubsub/web_server_spec.rb +++ b/spec/lib/celluloid_pubsub/web_server_spec.rb @@ -3,4 +3,47 @@ require 'spec_helper' describe CelluloidPubsub::WebServer do + it 'should have host constant' do + CelluloidPubsub::WebServer::HOST.should eq('0.0.0.0') + end + + it 'should have host constant' do + CelluloidPubsub::WebServer::PORT.should eq(1234) + end + + it 'should have host constant' do + CelluloidPubsub::WebServer::PATH.should eq('/ws') + end + let(:options) { {} } + let(:web_server) { mock } + + before(:each) do + CelluloidPubsub::WebServer.stubs(:new).returns(web_server) + end + + # it '#initialize with default values ' do + # web_server.parse_options({}) + # web_server.hostname.should eq(CelluloidPubsub::WebServer::HOST) + # web_server.port.should eq(CelluloidPubsub::WebServer::PORT) + # web_server.path.should eq(CelluloidPubsub::WebServer::PATH) + # web_server.backlog.should eq(1024) + # web_server.spy.should eq(false) + # end + # + # describe '#with custom values' do + # let(:hostname) { '192.0.0.1' } + # let(:port) { 13_456 } + # let(:path) { '/pathy' } + # let(:backlog) { 2048 } + # let(:spy) { true } + # + # it '#initialize with custom values ' do + # web_server.parse_options(hostname: hostname, port: port, path: path, spy: spy, backlog: backlog) + # web_server.hostname.should eq(hostname) + # web_server.port.should eq(port) + # web_server.path.should eq(path) + # web_server.backlog.should eq(backlog) + # web_server.spy.should eq(spy) + # end + # end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 7e65ee7..a865dc6 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -46,3 +46,11 @@ end end end + +# class used for testing actions +class TestActor + include Celluloid + include Celluloid::Logger +end + +TestActor.supervise_as(:test_actor)