carrier-pigeon 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in carrier-pigeon.gemspec
4
+ gemspec
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "carrier-pigeon/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "carrier-pigeon"
7
+ s.version = Carrier::Pigeon::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Sean Porter"]
10
+ s.email = ["portertech@gmail.com"]
11
+ s.homepage = "https://github.com/portertech/carrier-pigeon"
12
+ s.summary = %q{The simplest library to say something on IRC}
13
+ s.description = %q{The simplest library to say something on IRC}
14
+ s.has_rdoc = false
15
+ s.license = "MIT"
16
+
17
+ s.rubyforge_project = "carrier-pigeon"
18
+
19
+ s.files = `git ls-files`.split("\n")
20
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
21
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
22
+ s.require_paths = ["lib"]
23
+ end
@@ -0,0 +1,47 @@
1
+ require "addressable/uri"
2
+ require "socket"
3
+ require "openssl"
4
+
5
+ class CarrierPigeon
6
+
7
+ def initialize(server, port, nick, password, ssl)
8
+ tcp_socket = TCPSocket.new(server, port || 6667)
9
+ if ssl
10
+ ssl_context = OpenSSL::SSL::SSLContext.new
11
+ ssl_context.verify_mode = OpenSSL::SSL::VERIFY_NONE
12
+ @socket = OpenSSL::SSL::SSLSocket.new(tcp_socket, ssl_context)
13
+ @socket.sync = true
14
+ @socket.connect
15
+ else
16
+ @socket = tcp_socket
17
+ end
18
+ sendln "PASS #{password}" if password
19
+ sendln "NICK #{nick}"
20
+ sendln "USER #{nick} 0 * :#{nick}"
21
+ end
22
+
23
+ def message(channel, message)
24
+ sendln "PRIVMSG #{channel} :#{message}"
25
+ end
26
+
27
+ def die
28
+ @socket.close
29
+ end
30
+
31
+ def self.send(options={})
32
+ raise ArgumentError unless options[:uri] && options[:message]
33
+ uri = Addressable::URI.parse(options[:uri])
34
+ ssl = options[:ssl] || false
35
+ pidgeon = new(uri.host, uri.port, uri.user, uri.password, ssl)
36
+ pidgeon.message("#" + uri.fragment, options[:message])
37
+ pidgeon.die
38
+ end
39
+
40
+ private
41
+
42
+ def sendln(cmd)
43
+ @socket.write("#{cmd}\r\n")
44
+ STDOUT.flush
45
+ end
46
+
47
+ end
@@ -0,0 +1,5 @@
1
+ module Carrier
2
+ module Pigeon
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,62 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: carrier-pigeon
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.1
6
+ platform: ruby
7
+ authors:
8
+ - Sean Porter
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-06-14 00:00:00 +09:00
14
+ default_executable:
15
+ dependencies: []
16
+
17
+ description: The simplest library to say something on IRC
18
+ email:
19
+ - portertech@gmail.com
20
+ executables: []
21
+
22
+ extensions: []
23
+
24
+ extra_rdoc_files: []
25
+
26
+ files:
27
+ - .gitignore
28
+ - Gemfile
29
+ - Rakefile
30
+ - carrier-pigeon.gemspec
31
+ - lib/carrier-pigeon.rb
32
+ - lib/carrier-pigeon/version.rb
33
+ has_rdoc: true
34
+ homepage: https://github.com/portertech/carrier-pigeon
35
+ licenses:
36
+ - MIT
37
+ post_install_message:
38
+ rdoc_options: []
39
+
40
+ require_paths:
41
+ - lib
42
+ required_ruby_version: !ruby/object:Gem::Requirement
43
+ none: false
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: "0"
48
+ required_rubygems_version: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: "0"
54
+ requirements: []
55
+
56
+ rubyforge_project: carrier-pigeon
57
+ rubygems_version: 1.6.2
58
+ signing_key:
59
+ specification_version: 3
60
+ summary: The simplest library to say something on IRC
61
+ test_files: []
62
+