robut_whois 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ rvm:
2
+ - 1.9.2
3
+ - 1.9.3
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'http://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in robut_whois.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2011, Michael Smith
2
+
3
+ Permission is hereby granted, free of charge, to any person
4
+ obtaining a copy of this software and associated documentation
5
+ files (the "Software"), to deal in the Software without
6
+ restriction, including without limitation the rights to use,
7
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the
9
+ Software is furnished to do so, subject to the following
10
+ conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,32 @@
1
+ # robut_whois
2
+
3
+ A plugin for [robut](https://github.com/justinweiss/robut) for doing WHOIS lookups.
4
+
5
+ ## Build status
6
+
7
+ [![Build Status](https://secure.travis-ci.org/mikespokefire/robut_whois.png)](http://travis-ci.org/mikespokefire/robut_whois)
8
+
9
+ ## Installation
10
+
11
+ Add this to your Gemfile:
12
+
13
+ gem 'robut_whois'
14
+
15
+ And run `bundle install`
16
+
17
+ ## Usage
18
+
19
+ Add the following to your `Chatfile`
20
+
21
+ require 'robut_whois'
22
+ Robut::Plugin.plugins << RobutWhois::Plugin
23
+
24
+ And away you go!
25
+
26
+ ## Contribution
27
+
28
+ 1. Fork the repository
29
+ 2. Create a topic branch for your feature or fix
30
+ 3. Run `bundle install`
31
+ 4. Write specs for your changes, so I don't break anything in future
32
+ 5. Send me a pull request
data/Rakefile ADDED
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
3
+
4
+ # RSpec
5
+ require 'rspec/core'
6
+ require 'rspec/core/rake_task'
7
+ RSpec::Core::RakeTask.new(:spec) do |spec|
8
+ spec.pattern = FileList['spec/**/*_spec.rb']
9
+ spec.rspec_opts = ['--color']
10
+ end
11
+
12
+ # Testing should be the default task
13
+ task default: :spec
@@ -0,0 +1,29 @@
1
+ require "whois"
2
+
3
+ module RobutWhois
4
+ class Plugin
5
+ include Robut::Plugin
6
+
7
+ # Responds with +message+ if the command sent to robut is 'echo'.
8
+ def handle(time, sender_nick, message)
9
+ words = message.split
10
+ message_type = words.first
11
+ domain = words[1]
12
+ if message_type == 'whois' && domain
13
+ begin
14
+ reply Whois.query(domain).to_s
15
+ rescue Timeout::Error
16
+ reply "Sorry #{sender_nick}, request timed out for #{domain}"
17
+ rescue Whois::ServerNotFound
18
+ reply "Sorry #{sender_nick}, Unable to find a WHOIS server for #{domain}"
19
+ end
20
+ end
21
+ end
22
+
23
+ # Returns a description of how to use this plugin
24
+ def usage
25
+ "whois <domain> - Returns the WHOIS information for a domain"
26
+ end
27
+
28
+ end
29
+ end
@@ -0,0 +1,3 @@
1
+ module RobutWhois
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,6 @@
1
+ require "robut"
2
+ require "robut_whois/version"
3
+
4
+ module RobutWhois
5
+ autoload :Plugin, 'robut_whois/plugin'
6
+ end
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/robut_whois/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Michael Smith"]
6
+ gem.email = ["mike@spokefire.co.uk"]
7
+ gem.summary = %q{Robut WHOIS plugin}
8
+ gem.description = %q{Robut will give you the whois information about a domain}
9
+ gem.homepage = ""
10
+
11
+ gem.add_dependency "robut", "~> 0.3"
12
+ gem.add_dependency "whois", "~> 2.1.0"
13
+ gem.add_development_dependency "rspec", "~> 2.7.0"
14
+ gem.add_development_dependency "rake", "~> 0.9.2.2"
15
+
16
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
+ gem.files = `git ls-files`.split("\n")
18
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ gem.name = "robut_whois"
20
+ gem.require_paths = ["lib"]
21
+ gem.version = RobutWhois::VERSION
22
+ end
@@ -0,0 +1,48 @@
1
+ require 'spec_helper'
2
+
3
+ describe RobutWhois do
4
+
5
+ let(:connection) { Robut::ConnectionMock.new }
6
+ let(:plugin) { RobutWhois::Plugin.new(connection) }
7
+
8
+ it "should be an instance of Robut::Whois::Plugin" do
9
+ plugin.should be_an_instance_of(RobutWhois::Plugin)
10
+ end
11
+
12
+ it "should include Robut::Plugin" do
13
+ plugin.should be_a_kind_of(Robut::Plugin)
14
+ end
15
+
16
+ it "should return how to use the plugin when help is called" do
17
+ plugin.usage.should eq("whois <domain> - Returns the WHOIS information for a domain")
18
+ end
19
+
20
+ it "returns the whois information for example.com" do
21
+ Whois.stub!(:query).and_return("WHOIS information for example.com")
22
+
23
+ plugin.handle(Time.now, "@john", "whois example.com")
24
+ plugin.connection.replies.should include("WHOIS information for example.com")
25
+ end
26
+
27
+ it "returns the whois information for foo.com" do
28
+ Whois.stub!(:query).and_return("WHOIS information for foo.com")
29
+
30
+ plugin.handle(Time.now, "@john", "whois example.com")
31
+ plugin.connection.replies.should include("WHOIS information for foo.com")
32
+ end
33
+
34
+ it "should catch a Timeout::Error" do
35
+ Whois.stub!(:query).and_return{ raise Timeout::Error }
36
+
37
+ plugin.handle(Time.now, "@john", "whois example.com")
38
+ plugin.connection.replies.should include("Sorry @john, request timed out for example.com")
39
+ end
40
+
41
+ it "should catch a Whois::ServerNotFound" do
42
+ Whois.stub!(:query).and_return{ raise Whois::ServerNotFound }
43
+
44
+ plugin.handle(Time.now, "@john", "whois example.com")
45
+ plugin.connection.replies.should include("Sorry @john, Unable to find a WHOIS server for example.com")
46
+ end
47
+
48
+ end
@@ -0,0 +1,10 @@
1
+ require 'robut_whois'
2
+ require 'rspec'
3
+
4
+ # Requires supporting files with custom matchers and macros, etc,
5
+ # in ./support/ and its subdirectories.
6
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
7
+
8
+ RSpec.configure do |config|
9
+
10
+ end
@@ -0,0 +1,26 @@
1
+ require 'robut/storage/hash_store'
2
+
3
+ class Robut::ConnectionMock < Robut::Connection
4
+
5
+ def initialize(config = nil)
6
+ self.config = config || self.class.config
7
+ self.store = Robut::Storage::HashStore
8
+ end
9
+
10
+ def replies
11
+ @replies ||= []
12
+ end
13
+
14
+ def reply(msg, to = nil)
15
+ replies << msg
16
+ end
17
+
18
+ def handle_message(plugins, time, nick, message)
19
+ messages << [time, nick, message]
20
+ end
21
+
22
+ def messages
23
+ @messages ||= []
24
+ end
25
+
26
+ end
metadata ADDED
@@ -0,0 +1,105 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: robut_whois
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Michael Smith
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-11-21 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: robut
16
+ requirement: &70127188804080 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '0.3'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70127188804080
25
+ - !ruby/object:Gem::Dependency
26
+ name: whois
27
+ requirement: &70127188803580 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: 2.1.0
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70127188803580
36
+ - !ruby/object:Gem::Dependency
37
+ name: rspec
38
+ requirement: &70127188803120 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: 2.7.0
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *70127188803120
47
+ - !ruby/object:Gem::Dependency
48
+ name: rake
49
+ requirement: &70127188802660 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 0.9.2.2
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *70127188802660
58
+ description: Robut will give you the whois information about a domain
59
+ email:
60
+ - mike@spokefire.co.uk
61
+ executables: []
62
+ extensions: []
63
+ extra_rdoc_files: []
64
+ files:
65
+ - .gitignore
66
+ - .travis.yml
67
+ - Gemfile
68
+ - LICENSE
69
+ - README.md
70
+ - Rakefile
71
+ - lib/robut_whois.rb
72
+ - lib/robut_whois/plugin.rb
73
+ - lib/robut_whois/version.rb
74
+ - robut_whois.gemspec
75
+ - spec/robut_whois_spec.rb
76
+ - spec/spec_helper.rb
77
+ - spec/support/connection_mock.rb
78
+ homepage: ''
79
+ licenses: []
80
+ post_install_message:
81
+ rdoc_options: []
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ none: false
86
+ requirements:
87
+ - - ! '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
+ none: false
92
+ requirements:
93
+ - - ! '>='
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ requirements: []
97
+ rubyforge_project:
98
+ rubygems_version: 1.8.6
99
+ signing_key:
100
+ specification_version: 3
101
+ summary: Robut WHOIS plugin
102
+ test_files:
103
+ - spec/robut_whois_spec.rb
104
+ - spec/spec_helper.rb
105
+ - spec/support/connection_mock.rb