Skip to content

Commit

Permalink
Move bin scripts to rakefile
Browse files Browse the repository at this point in the history
  • Loading branch information
alloy committed Dec 3, 2010
1 parent e8c7b9a commit 8edf479
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 60 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1 +1,2 @@
*.swp *.swp
data
4 changes: 2 additions & 2 deletions INSTALL
@@ -1,4 +1,4 @@
* git update --init * git update --init
* sudo gem19 install sequel sqlite3-ruby * sudo gem19 install sequel sqlite3-ruby
* ruby19 ./bin/init * rake init
* ruby19 ./bin/update-active-tickets * rake update_open_tickets
19 changes: 19 additions & 0 deletions Rakefile
@@ -0,0 +1,19 @@
$:.unshift File.expand_path("../lib", __FILE__)

desc "Initialize the db"
task :init do
require "macruby_bugmash_bot/db"
mkdir_p(File.dirname(DB.db_path))
DB.create!
end

desc "Update the open tickets"
task :update_open_tickets do
require "macruby_bugmash_bot/db"
DB.update_open_tickets!
end

desc "Run the bot"
task :run do
require "macruby_bugmash_bot"
end
16 changes: 0 additions & 16 deletions bin/init

This file was deleted.

2 changes: 0 additions & 2 deletions bin/macruby_bugmash_bot

This file was deleted.

37 changes: 0 additions & 37 deletions bin/update-active-tickets

This file was deleted.

5 changes: 2 additions & 3 deletions lib/macruby_bugmash_bot/db.rb
Expand Up @@ -10,15 +10,14 @@


class DB class DB
def self.db_path def self.db_path
db = File.expand_path('../../data/db.sqlite3', __FILE__) db = File.expand_path('../../../data/db.sqlite3', __FILE__)
end end


def self.connection def self.connection
@db ||= Sequel.sqlite(db_path) @db ||= Sequel.sqlite(db_path)
end end


def self.create! def self.create!
puts "CREATE #{db_path}"
connection.create_table :users do connection.create_table :users do
primary_key :id primary_key :id
String :name String :name
Expand Down Expand Up @@ -80,7 +79,7 @@ def self.random_open_ticket
OPEN_TICKETS_RSS_FEED = URI.parse("http://www.macruby.org/trac/query?status=new&status=reopened&format=rss&order=priority&col=id&col=summary&col=status&col=time&milestone=%21MacRuby+1.0&milestone=%21MacRuby+Later") OPEN_TICKETS_RSS_FEED = URI.parse("http://www.macruby.org/trac/query?status=new&status=reopened&format=rss&order=priority&col=id&col=summary&col=status&col=time&milestone=%21MacRuby+1.0&milestone=%21MacRuby+Later")


def self.raw_open_tickets_feed def self.raw_open_tickets_feed
Net::HTTP.get(ACTIVE_TICKETS_RSS_FEED) Net::HTTP.get(OPEN_TICKETS_RSS_FEED)
rescue Exception => e rescue Exception => e
# obviously this is a bad thing to do, but I really don't want the bot to break this weekend due to HTTP problems... # obviously this is a bad thing to do, but I really don't want the bot to break this weekend due to HTTP problems...
puts "[!] FETCHING THE MACRUBY TICKET FEED FAILED DUE TO: #{e.message}\n\t#{e.backtrace.join("\n\t")}" puts "[!] FETCHING THE MACRUBY TICKET FEED FAILED DUE TO: #{e.message}\n\t#{e.backtrace.join("\n\t")}"
Expand Down

0 comments on commit 8edf479

Please sign in to comment.