Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Deamon (Email checking) and other additions/fixes
- Loading branch information
Showing
12 changed files
with
177 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
source "http://rubygems.org" | ||
|
||
# Specify your gem's dependencies in jared.gemspec | ||
gemspec | ||
gemspec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
class Helpers | ||
Lib.db | ||
|
||
def self.config | ||
Shoes.app title: "Jared - Configuration", height: 300, width: 500 do | ||
background "#333".."#666" | ||
tagline "Configure Jared to your person" | ||
@user = User.first | ||
if @user.blank? | ||
button "Create profile" do | ||
new_user = User.new(:name => "#{Etc.getlogin}", :zip => "00000") | ||
new_user.save | ||
if new_user | ||
alert "Success. Rerun command `jared config` to continue." | ||
close | ||
else | ||
alert "Failed. Retry." | ||
end | ||
end | ||
else | ||
para 'Your name:' | ||
@name = edit_line "#{@user.name}" | ||
para 'Your zipcode (For weather)' | ||
@zip = edit_line "#{@user.zip}" | ||
para 'Your Gmail email address (For email checking)' | ||
@mail = edit_line "#{@user.mail_username}" | ||
para 'Your Gmail password (Will be encrypted)' | ||
@password = edit_line "#{@user.mail_password}", secret: true | ||
button "Save" do | ||
update_user = @user.update_attributes(:name => @name.text, :zip => @zip.text, :mail_username => @mail.text, :mail_password => @password.text) | ||
if update_user == true | ||
alert "Saved." | ||
close | ||
else | ||
alert "failed to save." | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
class Helpers | ||
# = Date and Time | ||
# == Date and Time | ||
# _jared_ _time_ returns the current time. | ||
# | ||
#e.g. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,44 @@ | ||
# Deamon | ||
# TODO: run every x minutes on Linux and Windows | ||
|
||
class Deamon | ||
Lib.db | ||
|
||
def self.task | ||
# TODO: Add tasks to deamon | ||
puts "Jared Tasks" | ||
puts "0 Tasks due today." | ||
end | ||
def self.appointment | ||
# TODO: add appointments to deamon | ||
puts "Jared Calendar" | ||
puts "0 Appointments due today." | ||
end | ||
def self.message | ||
# TODO: add messages(emails) to deamon | ||
# limit to lastest 15 messages | ||
@user = User.first | ||
Gmail.connect(@user.mail_username, @user.mail_password) do |gmail| | ||
puts "Google Mail" | ||
puts gmail.inbox.count(:unread).to_s + " Unread messages." | ||
gmail.inbox.emails(:unread).each do |email| | ||
email.unread! | ||
print "From:",email.sender[0].mailbox,"@", email.sender[0].host, ", Subject:",email.subject | ||
puts | ||
end | ||
end | ||
end | ||
end | ||
|
||
class Helpers | ||
def self.deamon | ||
end | ||
end | ||
loop do | ||
Deamon.task | ||
Deamon.appointment | ||
Deamon.message | ||
puts | ||
puts | ||
sleep(60) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
class Helpers | ||
Lib.db | ||
|
||
require_relative "../models/user.rb" | ||
@user = User.first | ||
def self.weather(zip) | ||
begin | ||
if zip == nil | ||
weather = GoogleWeather.new(@user.zip) | ||
else | ||
weather = GoogleWeather.new(zip) | ||
end | ||
forecast = weather.current_conditions | ||
puts forecast.temp_f + " Degrees Fahrenheit", forecast.condition | ||
rescue SocketError | ||
puts "A connection error occurred fetching weather information." | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,18 @@ | ||
# Lib file loads all Helpers | ||
# Lib file loads all Helpers and Models. | ||
# ActiveRecord DataBase connect | ||
|
||
class Lib | ||
def self.db | ||
ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :database => "#{Dir.home}/.jared.sqlite3") | ||
end | ||
end | ||
|
||
path = Gem::Specification.find_by_name("jared") | ||
Dir["#{path.gem_dir}/lib/jared/helpers/*.rb"].each {|file| require file } | ||
#Dir[File.dirname(__FILE__) + '/helpers/*.rb'].each {|file| require file } | ||
|
||
# Model files requires | ||
Dir["#{path.gem_dir}/lib/jared/models/*.rb"].each {|file| require file } | ||
#Dir[File.dirname(__FILE__) + '/models/*.rb'].each {|file| require file } | ||
|
||
# Helper files requires | ||
#Dir["#{path.gem_dir}/lib/jared/helpers/*.rb"].each {|file| require file } | ||
Dir[File.dirname(__FILE__) + '/helpers/*.rb'].each {|file| require file } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class User < ActiveRecord::Base | ||
validates_presence_of :name, :zip | ||
validates_length_of :zip, :minimum=>5, :maximum=>5 | ||
default_scope :order => 'created_at DESC' | ||
end |