Permalink
Browse files

made task functional

  • Loading branch information...
1 parent 732f383 commit 2941cf76cad27bc58136402ae716a210367a1ba3 @cyberarm committed Feb 21, 2012
Showing with 355 additions and 25 deletions.
  1. 0 bin/jared
  2. +3 −0 jared.gemspec
  3. +46 −13 lib/jared.rb
  4. +103 −11 lib/jared/lib.rb
  5. +197 −0 lib/jared/lib.rb~
  6. +5 −0 lib/jared/models/task.rb
  7. +1 −1 lib/jared/version.rb
View
0 bin/jared 100644 → 100755
No changes.
View
@@ -21,4 +21,7 @@ Gem::Specification.new do |s|
# s.add_development_dependency ""
s.add_runtime_dependency "green_shoes"
s.add_runtime_dependency "sys-uname"
+ s.add_runtime_dependency "activerecord"
+ s.add_runtime_dependency "sqlite3"
+ s.add_runtime_dependency "launchy"
end
View
@@ -1,8 +1,27 @@
require 'etc'
+require "fileutils"
require 'sys/uname'
+require 'launchy'
+require 'sqlite3'
+require 'active_record'
include Sys
-#require_relative "jared/lib.rb"
-require "jared/lib"
+require_relative "jared/lib.rb"
+#require "jared/lib"
+
+ActiveRecord::Base.establish_connection(
+ :adapter => 'sqlite3',
+ :database => "#{Etc.getpwuid.dir}/.jared.sqlite3")
+
+unless File.exist?("#{Etc.getpwuid.dir}/.jared.sqlite3")
+ ActiveRecord::Schema.define do
+ create_table :tasks do |t|
+ t.column :title, :string
+ t.column :desciption, :string
+ t.column :due, :string
+ t.timestamps
+ end
+ end
+end
begin
require "green_shoes"
@@ -33,10 +52,10 @@ def self.clock
end
case ARGV[0]
-when "hi", "hello"
+when "hi", "Hi", "hello", "Hello"
Helpers.greeting
-when "view"
+when "view", "View"
puts "Opening #{ARGV[1]}"
if Uname.sysname == "Linux"
system("xdg-open #{Dir.pwd}/#{ARGV[1]}")
@@ -46,30 +65,44 @@ def self.clock
puts "Your system is not supported."
end
-when "calc", "calculator"
+when "calc", "Calc", "calculator", "Calculator"
Helpers.calc(a=ARGV[1], b=ARGV[2], c=ARGV[3])
-when "clock"
+when "clock", "Clock"
Jared.clock
-when "date"
+when "date", "Date"
Jared.date
-when "cal", "calendar"
+when "cal", "Cal", "calendar", "Calendar"
puts "Calendar is not yet available."
- Helpers.cal
+ if Dir.pwd.include?("/home/#{Etc.getlogin}/jared")
+ Helpers.cal
+ end
-when "task"
+when "task", "Task"
puts "Task is not yet available."
+ Helpers.task
-when "day"
+when "day", "Day"
+ puts Time.now.strftime("%A")
-when "deamon"
+when "deamon", "Deamon"
puts "Deamon is not yet available."
Helpers.deamon
-when "time"
+when "time", "Time"
puts Jared.time
+
+when "whatis", "Whatis"
+ Helpers.define(ARGV[1])
+
+when "whereis", "Whereis"
+ Helpers.map
+
+when "create", "Create"
+ Helpers.create
+
else
Helpers.notfound
end
View
@@ -81,25 +81,117 @@ def self.calc(a, b, c)
end
def self.deamon
- loop do
- keypress do |a|
- if a == "\n"
- Shoes.app do
- title "Jared Services"
- para "something"
- list do
+ end
+
+ def self.task
+ ActiveRecord::Base.establish_connection(
+ :adapter => 'sqlite3',
+ :database => "#{Etc.getpwuid.dir}/.jared.sqlite3")
+ require "green_shoes"
+ require "jared/models/task.rb"
+ Shoes.app title: "Jared Tasks" do
+ title "Tasks"
+ button "add task" do
+ Shoes.app title: "Add Task", width: 250, height: 400 do
+ title "add task"
+ stack do
+ para "Task title:"
+ @title = edit_line text: ""
+ para "Task desciption:"
+ @desciption = edit_box text: ""
+ para "Task due date:"
+ @due = edit_line text: ""
+ button "Add Task" do
+ new_task = Task.new(:title => @title.text, :desciption => @desciption.text, :due => @due.text)
+ new_task.save!
+ if new_task
+ alert "added task"
+ close
+ else
+ alert "failed to add task. Make sure you use a unique title"
+ end
+ end
+ end
end
end
+ task = Task.find(:all)
+ task.each do |t|
+ tagline t.title
+ tagline "Desciption:"
+ para t.desciption
+ tagline "Due:"
+ para t.due
+ button "Edit" do
+ Shoes.app title: "Editing Task: #{t.title}", width: 250, height: 400 do
+ title "edit task"
+ stack do
+ para "Task title:"
+ @title = edit_line text: "#{t.title}"
+ para "Task desciption:"
+ @desciption = edit_box text: "#{t.desciption}"
+ para "Task due date:"
+ @due = edit_line text: "#{t.due}"
+ button "update Task" do
+ task = Task.find(t.id)
+ @edit_task = task.update_attributes(:title => @title.text, :desciption => @desciption.text, :due => @due.text)
+ end
+ end
+ end
+ end
+ button "Delete" do
+ delete = confirm "Deleting... Are you sure?"
+ if delete == true
+ Task.destroy(t.id)
+ alert "removed #{t.title}"
+ end
+ end
+ para
+ end
+ end
+ end
+
+ def self.create
+ begin
+ if ARGV[1].include?("folder")
+ FileUtils.mkdir "#{ARGV[2]}"
+ puts "New Folder is at: #{Dir.pwd}/#{ARGV[2]}"
+ elsif ARGV[1].include?("dir")
+ FileUtils.mkdir "#{ARGV[2]}"
+ puts "New Directory is at: #{Dir.pwd}/#{ARGV[2]}"
+ elsif ARGV[1].include?("file")
+ File.open("#{ARGV[2]}", 'w') do |file|
+ file.puts "Hello World"
end
+ puts "New file is at: #{Dir.pwd}/#{ARGV[2]}"
+ else
+ puts "Don't know how-to create that."
end
- sleep(0.1)
+ rescue NoMethodError
+ puts "Folder/File name can't be blank."
end
end
+ def self.define(word)
+ puts "this function is unavailable. Word: #{word}"
+ end
+
+ def self.map
+ print "search Gmaps for > "
+ @m = STDIN.gets.chomp
+ puts "Opening Gmaps in default browser."
+ puts "#{@m}"
+ Launchy.open("http://maps.google.com/?q=#{@m}")
+ end
+
def self.notfound
puts "Error: Command '#{ARGV[0]}' not found."
- puts "Time - 04:12pm"
- puts "Date - Tuesday the 22nd of December 2012"
- puts "calc - 22 / 2"
+ puts "Hi, Hello - Jared Hi -Morning, #{Etc.getlogin}"
+ puts "Create - Jared Create file index.html - Creates a File/Folder at curent location."
+ puts "Time - Jared Time - 04:12pm"
+ puts "Date - Jared Date - Tuesday the 22nd of December 2012"
+ puts "calc(ulator) - Jared Calc 22 / 2 - 11"
+ puts "Task - Jared task - Opens a window listing tasks."
+ puts "View - Jared View lib/lib.rb - Opens a file(e.g. Picture, text, opendocument) in the system viewer."
+ puts "Whereis - Jared Whereis - Opens the system default browser to Gmaps."
end
end
Oops, something went wrong. Retry.

0 comments on commit 2941cf7

Please sign in to comment.