Permalink
Browse files

Changed namespace, code cleanup.

  • Loading branch information...
cyberarm committed Oct 28, 2012
1 parent 68ffe6e commit 7799e24e47d2e88b161b1e33b73716926424e24c
View
@@ -6,3 +6,5 @@ pkg/*
*.*~
doc/*
.project
+._redcar
+lib/jared/drb/
View
@@ -1,9 +1,8 @@
#!/bin/ruby
-
+s=Time.now
require 'faster_require'
require 'sqlite3'
require 'active_record'
-
unless File.exist?("#{Dir.home}/.jared.sqlite3")
puts "Setting up database."
ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :database => "#{Dir.home}/.jared.sqlite3")
@@ -54,7 +53,7 @@
require 'green_shoes'
new_user = User.new(:name => "#{Etc.getlogin}", :zip => "10001", :music => 'classical')
new_user.save
- c=confirm "Setup Jared?"
+ c=confirm "Setup Jared?\nSetting up Jared will enable it to retrieve personalized data for you."
if c == true
require 'jared/helpers/config'
Helpers.config
@@ -64,7 +63,6 @@
end
if Music.first.blank?
- require 'green_shoes'
jrd = Music.new(:status => "Ready", :now_playing => "", :now_playing_author => "")
jrd.save
if jrd
@@ -74,4 +72,8 @@
end
end
+f=Time.now
+@load_time = f-s
+puts "Main dependencies took #{@load_time} seconds to load."
+
require_relative "jared/jared.rb"
View
@@ -1,141 +1,146 @@
require 'thor'
+ class Jared < Thor
+ default_tasks :hi
-class Jared < Thor
- default_task :hi
-
- desc "hi", "Dynamic greeting based on the current time."
- def hi
- require_relative 'helpers/greeting.rb'
- Helpers.greeting
- end
-
- desc "time", "Gets the current time."
- def time
- puts "#{Time.now.strftime("%I:%M:%S%P")}"
- end
-
- desc "weather [FORECAST]", "Gets weather information, If no argument then returns current weather information."
- def weather(option=nil)
- require_relative 'helpers/weather.rb'
- require 'weatherboy'
- require 'area'
- Helpers.weather(option)
- end
-
- desc "clock", "Open a Green Shoes powered clock."
- def clock
- require_relative 'helpers/clock.rb'
- require 'green_shoes'
- Helpers.clock
- end
-
- desc "create TYPE NAME", "create"
- def create(type,name)
- require_relative 'helpers/create.rb'
- Helpers.create
- end
-
- desc "whereis PLACE", "Finds PLACE via Google Maps"
- def whereis(place)
- require_relative 'helpers/map.rb'
- require 'launchy'
- Helpers.map(place)
- end
-
- desc "day", "Displays the current day"
- def day
- puts Time.now.strftime("%A")
- end
-
- desc "whatis WORD", "Looks up the meaning of WORD."
- def whatis(word)
- require_relative 'helpers/define.rb'
- Helpers.define(word)
- end
-
- desc "deamon MAIL/TASK/CAL", "Checks every minute for new mail/tasks/appointments."
- def deamon(function=nil)
- require_relative 'helpers/deamon.rb'
- require 'gmail'
- require 'gibberish'
- Helpers.deamon
- end
-
- desc "jamendo MODE", "Plays music from Jamendo."
- def jamendo(mode='once')
- require_relative 'helpers/jamendo.rb'
- at_exit do
- require_relative 'lib.rb'
- Lib.db
- @jared = Music.first
- @jared.update_attributes(:author_url => "", :music_url => "", :album_image => "", :album_url => "", :now_playing => "", :now_playing_author => "", :now_playing_album => "")
- end
- Helpers.jamendo(mode)
- end
-
- desc "play FILE", "Plays File, local or remote."
- def play(media='')
- require_relative 'helpers/player.rb'
- Helpers.play(media)
- end
-
- desc "task", "Manage your Tasks"
- def task
- #require 'green_shoes'
- #require 'chronic'
- puts "Task is not yet available."
- #Helpers.task
- end
-
- desc "config", "Configure Jared."
- def config
- require_relative 'helpers/config.rb'
- require 'green_shoes'
- require 'gibberish'
- Helpers.config
- end
-
- desc "view FILENAME", "View file.png in system viewer."
- def view(filename)
- require 'sys/uname'
- include Sys
- if Uname.sysname.include?("Linux")
- puts "Opening #{filename}"
- system("xdg-open #{Dir.pwd}/#{filename}")
- elsif Uname.sysname.include?("Windows")
- puts "Opening #{filename}"
- system("call \"#{Dir.pwd}/#{filename}\"")
- else
- puts "Your system is not supported."
+ desc "server", "Dynamic greeting based on the current time."
+ def server
+ require 'drb'
+ require_relative 'drb/drb_server.rb'
+ Helpers::Drb.start_server
+ end
+
+ desc "hi", "Dynamic greeting based on the current time."
+ def hi
+ require_relative 'tasks/greeting.rb'
+ Task::Greet.new.greet
+ end
+
+ desc "time", "Gets the current time."
+ def time
+ puts "#{Time.now.strftime("%I:%M:%S%P")}"
+ end
+
+ desc "weather [FORECAST]", "Gets weather information, If no argument then returns current weather information."
+ def weather(option=nil)
+ require_relative 'tasks/weather.rb'
+ require 'weatherboy'
+ require 'area'
+ Task::Weather.new.weather(option)
+ end
+
+ desc "clock", "Open a Green Shoes powered clock."
+ def clock
+ require_relative 'tasks/clock.rb'
+ require 'green_shoes'
+ Task::Clock.new.clock
+ end
+
+ desc "create TYPE NAME", "create"
+ def create(type,name)
+ require_relative 'tasks/create.rb'
+ Task::Create.new.create
+ end
+
+ desc "whereis PLACE", "Finds PLACE via Google Maps"
+ def whereis(place)
+ require_relative 'tasks/map.rb'
+ require 'launchy'
+ Task::Map.new.map(place)
+ end
+
+ desc "day", "Displays the current day"
+ def day
+ puts Time.now.strftime("%A")
+ end
+
+ desc "whatis WORD", "Looks up the meaning of WORD."
+ def whatis(word)
+ require_relative 'tasks/define.rb'
+ Task::Word.new.define(word)
+ end
+
+ desc "deamon MAIL/TASK/CAL", "Checks every minute for new mail/taskss/appointments."
+ def deamon(function=nil)
+ require_relative 'tasks/deamon.rb'
+ require 'gmail'
+ require 'gibberish'
+ Task::Daemon.new.deamon
+ end
+
+ desc "jamendo MODE", "Plays music from Jamendo."
+ def jamendo(mode='play')
+ require_relative 'tasks/jamendo.rb'
+ Task::Jamendo.new.jamendo(mode)
+ end
+
+ desc "play FILE", "Plays File, local or remote."
+ def play(media='')
+ require_relative 'tasks/player.rb'
+ Task::Player.new.play(media)
+ end
+
+ desc "tasks", "Manage your Tasks"
+ def tasks
+ require 'green_shoes'
+ require 'chronic'
+ require_relative 'tasks/tasks.rb'
+ puts "Task is not yet available."
+ begin
+ Task::Tasks.new.tasks
+ rescue => e
+ p e
+ end
+ end
+
+ desc "config", "Configure Jared."
+ def config
+ require_relative 'tasks/config.rb'
+ require 'green_shoes'
+ require 'gibberish'
+ Task::Configure.new.config
+ end
+
+ desc "view FILENAME", "View file.png in system viewer."
+ def view(filename)
+ require 'sys/uname'
+ include Sys
+ if Uname.sysname.include?("Linux")
+ puts "Opening #{filename}"
+ system("xdg-open #{Dir.pwd}/#{filename}")
+ elsif Uname.sysname.include?("Windows")
+ puts "Opening #{filename}"
+ system("call \"#{Dir.pwd}/#{filename}\"")
+ else
+ puts "Your system is not supported."
+ end
+ end
+
+ desc "date", "Gets the current date."
+ def date
+ require_relative 'tasks/date.rb'
+ Task::Date.new.date
+ end
+
+ # desc "cal", "Calendar"
+ # def cal
+ # puts "Calendar is not yet available."
+ # #require 'green_shoes'
+ # #Helpers.cal
+ # end
+
+ desc "mail", "Checks your mailbox for new mails."
+ def mail
+ require_relative 'tasks/mail.rb'
+ require 'gmail'
+ require 'gibberish'
+ Task::Mail.new.mail
+ end
+
+ desc "stock SYMBOL MODE", "Check semi-current stock data."
+ def stock(s,m='last')
+ require_relative 'tasks/stock.rb'
+ Task::Stock.new.stock(s,m)
+ end
end
- end
-
- desc "date", "Gets the current date."
- def date
- require_relative 'helpers/date.rb'
- Helpers.date
- end
-
- desc "cal", "Calendar"
- def cal
- puts "Calendar is not yet available."
- #require 'green_shoes'
- #Helpers.cal
- end
-
- desc "mail", "Checks your mailbox for new mails."
- def mail
- require_relative 'helpers/mail.rb'
- require 'gmail'
- require 'gibberish'
- Helpers.mail
- end
-
- desc "stock SYMBOL MODE", "Check semi-current stock data."
- def stock(s,m='last')
- require_relative 'helpers/stock.rb'
- Helpers.stock(s,m)
- end
-end
-
-Jared.start
+
+Jared.start
@@ -0,0 +1,10 @@
+class Task
+ # Not yet implemented.
+ #
+ # Calculates.
+ class Calculator
+ def calculate(x,y,z)
+ puts "Calc(ulator) is not yet available."
+ end
+ end
+end
@@ -0,0 +1,17 @@
+class Task
+# Not yet implemented.
+#
+# _jared_ _cal_ Manage your appointments in a Green Shoes app.
+ class Calendar
+ def calendar
+ require "green_shoes"
+ Shoes.app do
+ title "Calendar Events"
+ events = ["Sidney", "Call Bob"]
+ events.each do |e|
+ para e
+ end
+ end
+ end
+ end
+end
View
@@ -0,0 +1,21 @@
+class Task
+# _jared_ _clock_ Opens a digital clock in a Green Shoes app.
+ class Clock
+ def clock
+ begin
+ require "green_shoes"
+ Shoes.app width: 400, height: 70, title: "Jared Clock" do
+ @clock = stack do
+ title "#{Time.now.strftime("%I:%M:%P")}"
+ end
+ every 0.5 do
+ @clock.clear do
+ title "#{Time.now.strftime("%I:%M:%S%P")}"
+ end
+ end
+ end
+ rescue LoadError
+ end
+ end
+ end
+end
Oops, something went wrong.

0 comments on commit 7799e24

Please sign in to comment.