Commit 5f39c850176612b611b16fd763b3fa5728fa7a67
- Diff rendering mode:
- inline
- side by side
Rakefile
(6 / 0)
|   | |||
| 1 | require 'rake' | ||
| 2 | require 'rake/testtask' | ||
| 3 | require 'rake/rdoctask' | ||
| 4 | require 'rake/gempackagetask' | ||
| 5 | |||
| 6 | require 'tasks/all_tasks' |
example/bot.rb
(0 / 49)
|   | |||
| 1 | #!/usr/bin/env ruby | ||
| 2 | |||
| 3 | $: << File.join(File.dirname(__FILE__), "../lib/") | ||
| 4 | |||
| 5 | require 'irc/bot' | ||
| 6 | |||
| 7 | class MyBot < IRC::Bot | ||
| 8 | def initialize(nick, server, port, name) | ||
| 9 | super | ||
| 10 | end | ||
| 11 | |||
| 12 | def on_endofmotd(event) | ||
| 13 | join("#channel1", "#channel2") | ||
| 14 | end | ||
| 15 | |||
| 16 | def on_message(event) | ||
| 17 | puts "<#{event.nick}> says '#{event.message}' in #{event.channel}" | ||
| 18 | end | ||
| 19 | |||
| 20 | def on_action(event) | ||
| 21 | puts "*** '#{event.nick} #{event.message}' in #{event.channel}" | ||
| 22 | end | ||
| 23 | |||
| 24 | def on_join(event) | ||
| 25 | puts "%%%% #{event.nick} join to #{event.channel}" | ||
| 26 | end | ||
| 27 | |||
| 28 | def do_join(event, args) | ||
| 29 | args.each { |channel| | ||
| 30 | join(channel) | ||
| 31 | } | ||
| 32 | end | ||
| 33 | |||
| 34 | def do_say(event, args) | ||
| 35 | send_message(event.channel, args.join(" ")) | ||
| 36 | end | ||
| 37 | |||
| 38 | def do_me(event, args) | ||
| 39 | send_message(event.channel, "I'm too lame!") | ||
| 40 | end | ||
| 41 | end | ||
| 42 | |||
| 43 | NICK = "ruby-irc" | ||
| 44 | SERVER = "localhost" | ||
| 45 | PORT = "6667" | ||
| 46 | IRC_NAME = "My Bot" | ||
| 47 | |||
| 48 | bot = MyBot.new(NICK, SERVER, PORT, IRC_NAME) | ||
| 49 | bot.connect |
examples/bot.rb
(49 / 0)
|   | |||
| 1 | #!/usr/bin/env ruby | ||
| 2 | |||
| 3 | $: << File.join(File.dirname(__FILE__), "../lib/") | ||
| 4 | |||
| 5 | require 'irc/bot' | ||
| 6 | |||
| 7 | class MyBot < IRC::Bot | ||
| 8 | def initialize(nick, server, port, name) | ||
| 9 | super | ||
| 10 | end | ||
| 11 | |||
| 12 | def on_endofmotd(event) | ||
| 13 | join("#channel1", "#channel2") | ||
| 14 | end | ||
| 15 | |||
| 16 | def on_message(event) | ||
| 17 | puts "<#{event.nick}> says '#{event.message}' in #{event.channel}" | ||
| 18 | end | ||
| 19 | |||
| 20 | def on_action(event) | ||
| 21 | puts "*** '#{event.nick} #{event.message}' in #{event.channel}" | ||
| 22 | end | ||
| 23 | |||
| 24 | def on_join(event) | ||
| 25 | puts "%%%% #{event.nick} join to #{event.channel}" | ||
| 26 | end | ||
| 27 | |||
| 28 | def do_join(event, args) | ||
| 29 | args.each { |channel| | ||
| 30 | join(channel) | ||
| 31 | } | ||
| 32 | end | ||
| 33 | |||
| 34 | def do_say(event, args) | ||
| 35 | send_message(event.channel, args.join(" ")) | ||
| 36 | end | ||
| 37 | |||
| 38 | def do_me(event, args) | ||
| 39 | send_message(event.channel, "I'm too lame!") | ||
| 40 | end | ||
| 41 | end | ||
| 42 | |||
| 43 | NICK = "ruby-irc" | ||
| 44 | SERVER = "localhost" | ||
| 45 | PORT = "6667" | ||
| 46 | IRC_NAME = "My Bot" | ||
| 47 | |||
| 48 | bot = MyBot.new(NICK, SERVER, PORT, IRC_NAME) | ||
| 49 | bot.connect |
tasks/all_tasks.rb
(1 / 0)
|   | |||
| 1 | Dir["#{File.dirname(__FILE__)}/*.rake"].each { |ext| load ext } |
tasks/distribution.rake
(72 / 0)
|   | |||
| 1 | |||
| 2 | |||
| 3 | PROJECT_NAME = PKG_NAME = 'rubyirc' | ||
| 4 | |||
| 5 | PKG_VERSION = "1.9" | ||
| 6 | PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}" | ||
| 7 | |||
| 8 | def get_files(dir) | ||
| 9 | files = [] | ||
| 10 | Dir.glob("#{dir}/*").each do |file| | ||
| 11 | if File.file?(file) | ||
| 12 | files << file | ||
| 13 | else | ||
| 14 | files.concat(get_files(file)) | ||
| 15 | end | ||
| 16 | end | ||
| 17 | end | ||
| 18 | |||
| 19 | desc 'Generate RDoc' | ||
| 20 | rd = Rake::RDocTask.new do |rdoc| | ||
| 21 | rdoc.rdoc_dir = 'doc/output/rdoc' | ||
| 22 | rdoc.options << '--title' << 'Docurb' << '--line-numbers' << | ||
| 23 | '--inline-source' << '--accessor' << 'delegate' << '--main' << 'README' | ||
| 24 | # rdoc.rdoc_files.include('README', 'CHANGES', 'LGPL-LICENSE', 'lib/**/*.rb') | ||
| 25 | end | ||
| 26 | |||
| 27 | spec = Gem::Specification.new do |s| | ||
| 28 | s.name = PKG_NAME | ||
| 29 | s.version = PKG_VERSION | ||
| 30 | s.summary = 'Application to read/browse ruby documentation' | ||
| 31 | s.description = <<-end_description | ||
| 32 | Application to read/browse ruby documentation | ||
| 33 | end_description | ||
| 34 | |||
| 35 | |||
| 36 | |||
| 37 | s.files = FileList[ | ||
| 38 | '[A-Z]*', | ||
| 39 | 'lib/irc/*.rb', | ||
| 40 | 'lib/irc/eventmap.yml', | ||
| 41 | 'examples/*.rb' | ||
| 42 | ].to_a | ||
| 43 | |||
| 44 | s.autorequire = 'rubyirc' | ||
| 45 | s.author = ["David A. Cuadrado"] | ||
| 46 | s.email = "krawek@gmail.com" | ||
| 47 | s.homepage = "http://gitorious.org/projects/rubyirc" | ||
| 48 | # s.rubyforge_project = "???" | ||
| 49 | end | ||
| 50 | |||
| 51 | desc "Generate #{PKG_NAME} Gem" | ||
| 52 | Rake::GemPackageTask.new(spec) do |pkg| | ||
| 53 | pkg.need_zip = true | ||
| 54 | pkg.need_tar = true | ||
| 55 | end | ||
| 56 | |||
| 57 | desc "Publish #{PKG_NAME} packages on RubyForge" | ||
| 58 | task :publish_ruby_irc_packages => [:verify_user, :package] do | ||
| 59 | release_files = FileList[ | ||
| 60 | "pkg/#{PKG_FILE_NAME}.gem", | ||
| 61 | "pkg/#{PKG_FILE_NAME}.tgz", | ||
| 62 | "pkg/#{PKG_FILE_NAME}.zip" | ||
| 63 | ] | ||
| 64 | require 'meta_project' | ||
| 65 | require 'rake/contrib/xforge' | ||
| 66 | |||
| 67 | Rake::XForge::Release.new(MetaProject::Project::XForge::RubyForge.new(PROJECT_NAME)) do |xf| | ||
| 68 | xf.user_name = ENV['RUBYFORGE_USER'] | ||
| 69 | xf.files = release_files.to_a | ||
| 70 | xf.release_name = "rubyirc #{PKG_VERSION}" | ||
| 71 | end | ||
| 72 | end |
tasks/specs.rake
(15 / 0)
|   | |||
| 1 | require 'spec/rake/spectask' | ||
| 2 | |||
| 3 | spec_files = FileList['specs/**/*.rb'] | ||
| 4 | |||
| 5 | desc 'Run all specs' | ||
| 6 | Spec::Rake::SpecTask.new('specs') do |t| | ||
| 7 | t.libs = ['lib'] | ||
| 8 | t.spec_files = spec_files | ||
| 9 | end | ||
| 10 | |||
| 11 | desc 'Generate an rspec html report' | ||
| 12 | Spec::Rake::SpecTask.new('spec_html') do |t| | ||
| 13 | t.spec_files = spec_files | ||
| 14 | t.spec_opts = ['--format html:doc/output/rspec.html','--backtrace'] | ||
| 15 | end |

