Permalink
Browse files

initial commit

  • Loading branch information...
bcantin committed Apr 23, 2011
0 parents commit e30858056d1693c4c650377b8f584e3752e361be
Showing with 35 additions and 0 deletions.
  1. +4 −0 .todo.yml
  2. +31 −0 todo.rb
@@ -0,0 +1,4 @@
+adapter: sqlite3
+database: /Users/bcantin/projects/todo/db/development.sqlite3
+pool: 5
+timeout: 5000
31 todo.rb
@@ -0,0 +1,31 @@
+#!/usr/bin/env ruby
+
+require 'rubygems'
+require 'active_record'
+require 'yaml'
+# require 'logger'
+require 'sqlite3'
+require 'pathname'
+
+config_file = Pathname.new(__FILE__).dirname + '.todo.yml'
+
+dbconfig = YAML::load(File.open(config_file))
+ActiveRecord::Base.establish_connection(dbconfig)
+# ActiveRecord::Base.logger = Logger.new(STDERR)
+
+class Project < ActiveRecord::Base
+ has_many :tasks
+end
+
+class Task < ActiveRecord::Base
+ belongs_to :project
+end
+
+project_name = Pathname.new(Dir.pwd).basename.to_s
+unless project = Project.where('title like ?', project_name).first
+ project = Project.find_or_create_by_title('general')
+end
+
+task = *ARGV
+
+project.tasks.create(:description => task.join(' '))

0 comments on commit e308580

Please sign in to comment.