From e72c216f0a20f0039862f8cbfc5956adbe3c4a2b Mon Sep 17 00:00:00 2001 From: Brian Haberer Date: Thu, 20 Feb 2014 02:53:28 -0800 Subject: [PATCH] v1.0.5 - Dep Bump --- cinch-hangouts.gemspec | 27 +++++++++++----------- lib/cinch/plugins/hangouts.rb | 8 +++---- lib/cinch/plugins/hangouts/hangout.rb | 8 ++----- lib/cinch/plugins/hangouts/subscription.rb | 9 ++++---- lib/cinch/plugins/hangouts/version.rb | 2 +- spec/cinch-hangouts_spec.rb | 22 ++++++++++++++---- 6 files changed, 43 insertions(+), 33 deletions(-) diff --git a/cinch-hangouts.gemspec b/cinch-hangouts.gemspec index 6ee92c4..b99c717 100644 --- a/cinch-hangouts.gemspec +++ b/cinch-hangouts.gemspec @@ -4,26 +4,27 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'cinch/plugins/hangouts/version' Gem::Specification.new do |gem| - gem.name = "cinch-hangouts" + gem.name = 'cinch-hangouts' gem.version = Cinch::Plugins::Hangouts::VERSION - gem.authors = ["Brian Haberer"] - gem.email = ["bhaberer@gmail.com"] + gem.authors = ['Brian Haberer'] + gem.email = ['bhaberer@gmail.com'] gem.description = %q{Cinch Plugin to track any Google Hangouts that are linked into the channel} gem.summary = %q{Cinch Plugin for racking Google Hangouts} - gem.homepage = "https://github.com/bhaberer/cinch-hangouts" + gem.homepage = 'https://github.com/bhaberer/cinch-hangouts' + gem.license = 'MIT' gem.files = `git ls-files`.split($/) gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) } gem.test_files = gem.files.grep(%r{^(test|spec|features)/}) - gem.require_paths = ["lib"] + gem.require_paths = ['lib'] - gem.add_development_dependency 'rake' - gem.add_development_dependency 'rspec' - gem.add_development_dependency 'coveralls' - gem.add_development_dependency 'cinch-test' + gem.add_development_dependency 'rake' + gem.add_development_dependency 'rspec' + gem.add_development_dependency 'coveralls' + gem.add_development_dependency 'cinch-test' - gem.add_dependency 'cinch', '~> 2.0.5' - gem.add_dependency 'cinch-storage', '~> 1.0.3' - gem.add_dependency 'cinch-toolbox', '~> 1.0.3' - gem.add_dependency 'time-lord', '~> 1.0.1' + gem.add_dependency 'cinch', '~> 2.0.12' + gem.add_dependency 'cinch-storage', '~> 1.1.0' + gem.add_dependency 'cinch-toolbox', '~> 1.1.0' + gem.add_dependency 'time-lord', '~> 1.0.1' end diff --git a/lib/cinch/plugins/hangouts.rb b/lib/cinch/plugins/hangouts.rb index 92b3573..6e6428d 100644 --- a/lib/cinch/plugins/hangouts.rb +++ b/lib/cinch/plugins/hangouts.rb @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- require 'cinch' -require 'cinch-storage' +require 'cinch/storage' require 'cinch/toolbox' require 'time-lord' @@ -95,12 +95,12 @@ def list_hangouts(m) end end - def respond(m, message) + def respond(user, message) case @response_type when :notice - m.user.notice message + user.notice message when :pm - m.user.send message + user.send message end end end diff --git a/lib/cinch/plugins/hangouts/hangout.rb b/lib/cinch/plugins/hangouts/hangout.rb index fe814a3..385e777 100644 --- a/lib/cinch/plugins/hangouts/hangout.rb +++ b/lib/cinch/plugins/hangouts/hangout.rb @@ -10,16 +10,12 @@ def initialize(nick, id, time) end def save - storage = CinchStorage.new(@@hangout_filename) + storage = Cinch::Storage.new(@@hangout_filename) storage.data[:hangouts] ||= {} storage.data[:hangouts][id] = self storage.save end - def to_yaml - { nick: @nick, id: @id, time: @time } - end - def self.find_by_id(id) listing[id] end @@ -52,7 +48,7 @@ def self.url(id, shorten = true) private def self.read_file - storage = CinchStorage.new(@@hangout_filename) + storage = Cinch::Storage.new(@@hangout_filename) unless storage.data[:hangouts] storage.data[:hangouts] = {} storage.save diff --git a/lib/cinch/plugins/hangouts/subscription.rb b/lib/cinch/plugins/hangouts/subscription.rb index be2062a..78ed419 100644 --- a/lib/cinch/plugins/hangouts/subscription.rb +++ b/lib/cinch/plugins/hangouts/subscription.rb @@ -34,10 +34,11 @@ def self.notify(hangout_id, bot) nick = Hangout.find_by_id(hangout_id).nick list.each_value do |s| # Don't link the person who linked it. - if nick != s.nick + unless nick == s.nick user = Cinch::User.new(s.nick, bot) - user.msg("#{nick} just linked a new hangout at: " + - Hangout.url(hangout_id)) + message = "#{nick} just linked a new hangout at: " + + Hangout.url(hangout_id) + Hangout.respond(user, message) end end end @@ -45,6 +46,6 @@ def self.notify(hangout_id, bot) private def self.storage - CinchStorage.new(@@subscription_filename) + Cinch::Storage.new(@@subscription_filename) end end diff --git a/lib/cinch/plugins/hangouts/version.rb b/lib/cinch/plugins/hangouts/version.rb index 0e76273..03e8652 100644 --- a/lib/cinch/plugins/hangouts/version.rb +++ b/lib/cinch/plugins/hangouts/version.rb @@ -3,7 +3,7 @@ module Cinch module Plugins # Versioning Info class Hangouts - VERSION = '1.0.4' + VERSION = '1.0.5' end end end diff --git a/spec/cinch-hangouts_spec.rb b/spec/cinch-hangouts_spec.rb index 291244b..dc31624 100644 --- a/spec/cinch-hangouts_spec.rb +++ b/spec/cinch-hangouts_spec.rb @@ -57,6 +57,18 @@ reply.should match(/it was last linked \d seconds? ago/) end + it 'should recapture a legit Hangout link' do + id = random_hangout_id + msg = make_message(@bot, Hangout.url(id, false), { channel: '#foo' }) + get_replies(msg) + sleep 1 # hack until 'time-lord' fix gets released + get_replies(msg) + sleep 1 # hack until 'time-lord' fix gets released + msg = make_message(@bot, '!hangouts') + reply = get_replies(msg).length + .should == 2 + end + it 'should capture a new short Hangout link and store it in @storage' do msg = make_message(@bot, Hangout.url('7acpjrpcmgl00u0b665mu25b1g', false), { :channel => '#foo' }) get_replies(msg).should be_empty @@ -76,9 +88,9 @@ end it 'should allow users to subscribe' do - msg = make_message(@bot, '!hangouts subscribe') - get_replies(msg).first.text. - should include("You are now subscribed") + get_replies(make_message(@bot, '!hangouts subscribe')) + Cinch::Plugins::Hangouts::Subscription.list.length + .should == 1 end it 'should inform users that they already subscribed' do @@ -91,8 +103,8 @@ it 'should allow users to unsubscribe' do get_replies(make_message(@bot, '!hangouts subscribe')) msg = make_message(@bot, '!hangouts unsubscribe') - get_replies(msg).first.text. - should include("You are now unsubscribed") + Cinch::Plugins::Hangouts::Subscription.list.length + .should == 0 end it 'should inform users that they are not subscribed on an unsubscribe' do