jared 0.0.7a4 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile.lock +18 -0
- data/jared.gemspec +21 -36
- data/lib/jared/cli.rb +19 -0
- data/lib/jared/logg.rb +14 -15
- data/lib/jared/plugin.rb +61 -35
- data/lib/jared/plugin_list.rb +16 -0
- data/lib/jared/setup.rb +5 -0
- data/lib/jared/setup_generator.rb +42 -0
- data/lib/jared/version.rb +2 -2
- data/lib/jared.rb +11 -86
- data/license.md +7 -0
- data/pkg/jared-0.1.0.gem +0 -0
- data/readme.md +9 -79
- metadata +24 -275
- data/.gitignore +0 -10
- data/Gemfile +0 -4
- data/Rakefile +0 -1
- data/lib/jared/core/clock/init.rb +0 -15
- data/lib/jared/core/clock/lib/clock.rb +0 -23
- data/lib/jared/core/configure/init.rb +0 -15
- data/lib/jared/core/configure/lib/config.rb +0 -60
- data/lib/jared/core/create/init.rb +0 -16
- data/lib/jared/core/create/lib/create.rb +0 -33
- data/lib/jared/core/daemon/daemon.rb +0 -104
- data/lib/jared/core/daemon/init.rb +0 -15
- data/lib/jared/core/date/init.rb +0 -15
- data/lib/jared/core/date/lib/date.rb +0 -45
- data/lib/jared/core/greeter/init.rb +0 -15
- data/lib/jared/core/greeter/lib/greeting.rb +0 -26
- data/lib/jared/core/jamendo/init.rb +0 -17
- data/lib/jared/core/jamendo/lib/jamendo.rb +0 -88
- data/lib/jared/core/mail/init.rb +0 -15
- data/lib/jared/core/mail/lib/mail.rb +0 -45
- data/lib/jared/core/map/New File +0 -0
- data/lib/jared/core/map/init.rb +0 -15
- data/lib/jared/core/map/lib/map.rb +0 -12
- data/lib/jared/core/player/init.rb +0 -15
- data/lib/jared/core/player/lib/player.rb +0 -33
- data/lib/jared/core/stock/init.rb +0 -17
- data/lib/jared/core/stock/lib/stock.rb +0 -34
- data/lib/jared/core/tasks/init.rb +0 -15
- data/lib/jared/core/tasks/lib/task.rb +0 -42
- data/lib/jared/core/weather/init.rb +0 -17
- data/lib/jared/core/weather/lib/weather.rb +0 -70
- data/lib/jared/database.rb +0 -59
- data/lib/jared/jared.rb +0 -22
- data/lib/jared/models/music.rb +0 -2
- data/lib/jared/models/task.rb +0 -5
- data/lib/jared/models/user.rb +0 -5
- data/lib/jared/plugins.rb +0 -92
- data/spec/spec_helper.rb +0 -4
- data/spec/template.rb +0 -10
- data/spec/tests/date_spec.rb +0 -9
- data/spec/tests/greeting_spec.rb +0 -10
- data/spec/tests/jamendo_spec.rb +0 -10
- data/spec/tests/mail_spec.rb +0 -10
- data/spec/tests/map_spec.rb +0 -12
- data/spec/tests/player_spec.rb +0 -10
- data/spec/tests/stock_spec.rb +0 -10
@@ -1,45 +0,0 @@
|
|
1
|
-
class Action
|
2
|
-
class Date
|
3
|
-
# Date and Time
|
4
|
-
#
|
5
|
-
# _jared_ _time_ returns the current time.
|
6
|
-
#
|
7
|
-
#e.g.
|
8
|
-
#
|
9
|
-
#02:33:19pm
|
10
|
-
#
|
11
|
-
# _Jared_ _date_ returns the current date.
|
12
|
-
#
|
13
|
-
#e.g.
|
14
|
-
#
|
15
|
-
#Tuesday the 1st of May 2012
|
16
|
-
#
|
17
|
-
#(05/01/2012)
|
18
|
-
def date
|
19
|
-
st = "#{Time.now.strftime("%A the %dst of %B %Y")}"
|
20
|
-
nd = "#{Time.now.strftime("%A the %dnd of %B %Y")}"
|
21
|
-
rd = "#{Time.now.strftime("%A the %drd of %B %Y")}"
|
22
|
-
|
23
|
-
if Time.now.strftime("%d") == "02"
|
24
|
-
puts nd.gsub("0", "")
|
25
|
-
elsif Time.now.strftime("%d") == "22"
|
26
|
-
puts nd
|
27
|
-
elsif Time.now.strftime("%d") == "03"
|
28
|
-
puts rd
|
29
|
-
elsif Time.now.strftime("%d") == "33"
|
30
|
-
puts rd
|
31
|
-
elsif Time.now.strftime("%d") == "21"
|
32
|
-
puts st
|
33
|
-
elsif Time.now.strftime("%d") == "31"
|
34
|
-
puts st
|
35
|
-
elsif Time.now.strftime("%d") == "01"
|
36
|
-
puts st.gsub("0", "")
|
37
|
-
else
|
38
|
-
puts "#{Time.now.strftime("%A the %dth of %B %Y")}"
|
39
|
-
end
|
40
|
-
puts "(#{Time.now.strftime("%m/%d/%Y")})"
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
Action::Date.new.date
|
@@ -1,15 +0,0 @@
|
|
1
|
-
require "jared/plugin"
|
2
|
-
|
3
|
-
Jared::Plugin.config do |plugin|
|
4
|
-
plugin.name = "Greeter"
|
5
|
-
plugin.description = "Shows a clock."
|
6
|
-
plugin.author = "Cyberarm"
|
7
|
-
plugin.homepage = "http://github.com/cyberarm/jared"
|
8
|
-
plugin.sourcecode = "http://github.com/cyberarm/jared"
|
9
|
-
plugin.command = "greet"
|
10
|
-
plugin.usage = "clock"
|
11
|
-
plugin.version = "0.4.0"
|
12
|
-
plugin.main_require = "lib/greeting"
|
13
|
-
plugin.jared_version = "0.0.7a5"
|
14
|
-
plugin.platform = :ruby
|
15
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
class Action
|
2
|
-
class Greet
|
3
|
-
Lib.db
|
4
|
-
# Dynamically greets the user by time when <em>jared hi/hello</em> is run.
|
5
|
-
def greet
|
6
|
-
if Time.now.strftime("%H").to_i < "04".to_i
|
7
|
-
puts "Go tee bed."
|
8
|
-
elsif Time.now.strftime("%H").to_i < "07".to_i
|
9
|
-
puts "Yawn Zzzz"
|
10
|
-
elsif Time.now.strftime("%H").to_i < "12".to_i
|
11
|
-
puts "Morning, #{User.first.name.capitalize}"
|
12
|
-
elsif Time.now.strftime("%H").to_i < "16".to_i
|
13
|
-
puts "Afternoon, #{User.first.name.capitalize}"
|
14
|
-
elsif Time.now.strftime("%H").to_i < "20".to_i
|
15
|
-
puts "Evening, #{User.first.name.capitalize}"
|
16
|
-
elsif Time.now.strftime("%H").to_i < "22".to_i
|
17
|
-
puts "Ummm, good night, #{User.first.name.capitalize}"
|
18
|
-
puts "Its getting late, consider getting some rest."
|
19
|
-
elsif Time.now.strftime("%H").to_i < "24".to_i
|
20
|
-
puts "Zzzz"
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
Action::Greet.new.greet
|
@@ -1,17 +0,0 @@
|
|
1
|
-
require "jared/plugin"
|
2
|
-
|
3
|
-
Jared::Plugin.config do |plugin|
|
4
|
-
plugin.name = "Jamendo"
|
5
|
-
plugin.description = "Streams prefered music from Jamendo. Experimental."
|
6
|
-
plugin.author = "Cyberarm"
|
7
|
-
plugin.author_email = "matthewlikesrobots@gmail.com"
|
8
|
-
plugin.homepage = "http://github.com/cyberarm/jared-core-plugins"
|
9
|
-
plugin.sourcecode = "http://github.com/cyberarm/jared-core-plugins"
|
10
|
-
plugin.command = "jamendo"
|
11
|
-
plugin.arguments = "ACTION"
|
12
|
-
plugin.usage = "jamendo play", "Now playing: title, by: composer (1 minute 30 seconds)"
|
13
|
-
plugin.version = "0.4.0"
|
14
|
-
plugin.main_require = "lib/jamendo"
|
15
|
-
plugin.jared_version = "0.0.7a4"
|
16
|
-
plugin.platform = :ruby
|
17
|
-
end
|
@@ -1,88 +0,0 @@
|
|
1
|
-
require "json"
|
2
|
-
require 'gst'
|
3
|
-
|
4
|
-
class Action
|
5
|
-
class Jamendo
|
6
|
-
attr_accessor :playloop, :playbin
|
7
|
-
def length(l)
|
8
|
-
@m="#{l.to_i.divmod(60)[0]} minutes"
|
9
|
-
if defined?(l.to_i.divmod(60)[1])
|
10
|
-
@s="#{l.to_i.divmod(60)[1]} seconds"
|
11
|
-
else
|
12
|
-
@s=nil
|
13
|
-
end
|
14
|
-
return "#{@m} #{@s}"
|
15
|
-
end
|
16
|
-
|
17
|
-
def player(n=0)
|
18
|
-
puts "Now playing: #{@data['name']}, By: #{@data['artist_name']} (#{length(@data['duration'])})"
|
19
|
-
@playbin = Gst::ElementFactory.make('playbin2')
|
20
|
-
@playbin.ready
|
21
|
-
@playloop = GLib::MainLoop.new(nil, false)
|
22
|
-
@playbin.bus.add_watch {|bus, message|
|
23
|
-
case message.type
|
24
|
-
when Gst::Message::EOS
|
25
|
-
@playloop.quit
|
26
|
-
when Gst::MessageError
|
27
|
-
@playloop.quit
|
28
|
-
@playbin.stop
|
29
|
-
end
|
30
|
-
true}
|
31
|
-
@playbin.uri = @data['stream']
|
32
|
-
@playbin.play
|
33
|
-
begin
|
34
|
-
@playloop.run
|
35
|
-
rescue Interrupt
|
36
|
-
ensure
|
37
|
-
@playbin.stop
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
# at_exit do
|
42
|
-
# require_relative 'lib.rb'
|
43
|
-
# Lib.db
|
44
|
-
# @jared = Music.first
|
45
|
-
# @jared.update_attributes(:author_url => "", :music_url => "", :album_image => "", :album_url => "", :now_playing => "", :now_playing_author => "", :now_playing_album => "")
|
46
|
-
# end
|
47
|
-
|
48
|
-
def jamendo(mode='play')
|
49
|
-
mode=mode.downcase
|
50
|
-
Lib.db
|
51
|
-
@jared = Music.first
|
52
|
-
@user = User.first
|
53
|
-
require 'gtk2'
|
54
|
-
require 'open-uri'
|
55
|
-
require 'json'
|
56
|
-
require 'gst'
|
57
|
-
@user.music
|
58
|
-
|
59
|
-
@radios = open("http://api.jamendo.com/get2/id+name/radio/json/?n=all").read
|
60
|
-
@radio_id = 0
|
61
|
-
@radio_data=JSON.parse(@radios)
|
62
|
-
@radio_data.select do |radio|
|
63
|
-
next unless radio['name'] == @user.music
|
64
|
-
@radio_id = radio['id']
|
65
|
-
end
|
66
|
-
|
67
|
-
sleep 1
|
68
|
-
|
69
|
-
@list = open("http://api.jamendo.com/get2/name+url+stream+album_name+album_url+album_image+artist_name+artist_url+duration/track/json/track_album+album_artist/?radioid=#{@radio_id}&n=100&streamencoding=ogg2").read
|
70
|
-
@d = JSON.parse(@list)
|
71
|
-
if mode == 'play'
|
72
|
-
puts 'Starting loop, use CTRL-Pause(Break) to stop.'
|
73
|
-
(@d.count-1).times do |v|
|
74
|
-
p (@d.count-1)
|
75
|
-
# v = Random.rand(0..@d.count-1)
|
76
|
-
@data = @d[v]
|
77
|
-
@jared.update_attributes(:author_url => "#{@data['artist_url']}", :album_image => "#{@data['album_image']}", :music_url => "#{@data['url']}", :album_url => "#{@data['album_url']}", :now_playing => "#{@data['name']}", :now_playing_author => "#{@data['artist_name']}", :now_playing_album => "#{@data['album_name']}")
|
78
|
-
player(v)
|
79
|
-
end
|
80
|
-
elsif mode == 'help'
|
81
|
-
puts 'loop|once'
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
a=Action::Jamendo.new.jamendo
|
88
|
-
p a
|
data/lib/jared/core/mail/init.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
require "jared/plugin"
|
2
|
-
|
3
|
-
Jared::Plugin.config do |plugin|
|
4
|
-
plugin.name = "Gmail"
|
5
|
-
plugin.description = "Check you Gmail for new messages."
|
6
|
-
plugin.author = "Cyberarm"
|
7
|
-
plugin.homepage = "http://github.com/cyberarm/jared"
|
8
|
-
plugin.sourcecode = "http://github.com/cyberarm/jared"
|
9
|
-
plugin.command = "mail"
|
10
|
-
plugin.usage = "mail"
|
11
|
-
plugin.version = "0.4.0"
|
12
|
-
plugin.main_require = "lib/mail"
|
13
|
-
plugin.jared_version = "0.0.7a4"
|
14
|
-
plugin.platform = :ruby
|
15
|
-
end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
require 'gmail'
|
2
|
-
require 'gibberish'
|
3
|
-
|
4
|
-
class Action
|
5
|
-
class Mail
|
6
|
-
Lib.db
|
7
|
-
# Checks Email on demand.
|
8
|
-
def mail
|
9
|
-
require 'gibberish'
|
10
|
-
begin
|
11
|
-
@user = User.first
|
12
|
-
if @user.mail_username.blank?
|
13
|
-
puts "Jared is not configured to check email."
|
14
|
-
puts "Please run, 'jared config'"
|
15
|
-
elsif @user.mail_password.blank?
|
16
|
-
puts "Jared is not configured to check email."
|
17
|
-
puts "Please run, 'jared config'"
|
18
|
-
else
|
19
|
-
cipher = Gibberish::AES.new(@user.mail_username)
|
20
|
-
password = cipher.dec(@user.mail_password)
|
21
|
-
Gmail.connect(@user.mail_username, password) do |gmail|
|
22
|
-
if gmail.logged_in?
|
23
|
-
puts "Google Mail"
|
24
|
-
puts gmail.inbox.count(:unread).to_s + " Unread messages."
|
25
|
-
gmail.inbox.emails(:unread).each do |email|
|
26
|
-
email.unread!
|
27
|
-
print "From:",email.sender[0].mailbox,"@", email.sender[0].host, ", Subject:",email.subject
|
28
|
-
puts
|
29
|
-
end
|
30
|
-
else
|
31
|
-
puts "Not logged in."
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
rescue => e
|
36
|
-
if e.to_s.include?("mail_")
|
37
|
-
puts "Jared is not configured to check email."
|
38
|
-
puts "Please run, 'jared config' or click 'OK' on the popup."
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
Action::Mail.new.mail
|
data/lib/jared/core/map/New File
DELETED
File without changes
|
data/lib/jared/core/map/init.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
require "jared/plugin"
|
2
|
-
|
3
|
-
Jared::Plugin.config do |plugin|
|
4
|
-
plugin.name = "Google Maps"
|
5
|
-
plugin.description = "Shows a clock."
|
6
|
-
plugin.author = "Cyberarm"
|
7
|
-
plugin.homepage = "http://github.com/cyberarm/jared"
|
8
|
-
plugin.sourcecode = "http://github.com/cyberarm/jared"
|
9
|
-
plugin.command = "map"
|
10
|
-
plugin.usage = "map 'location, io'"
|
11
|
-
plugin.version = "0.4.0"
|
12
|
-
plugin.main_require = "lib/map"
|
13
|
-
plugin.jared_version = "0.0.7a4"
|
14
|
-
plugin.platform = :ruby
|
15
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
require "jared/plugin"
|
2
|
-
|
3
|
-
Jared::Plugin.config do |plugin|
|
4
|
-
plugin.name = "Player"
|
5
|
-
plugin.description = "Shows a clock."
|
6
|
-
plugin.author = "Cyberarm"
|
7
|
-
plugin.homepage = "http://github.com/cyberarm/jared"
|
8
|
-
plugin.sourcecode = "http://github.com/cyberarm/jared"
|
9
|
-
plugin.command = "play"
|
10
|
-
plugin.usage = "play 'file or url'"
|
11
|
-
plugin.version = "0.4.0"
|
12
|
-
plugin.main_require = "lib/player"
|
13
|
-
plugin.jared_version = "0.0.7a4"
|
14
|
-
plugin.platform = :mingw32
|
15
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
require 'sys/uname'
|
2
|
-
include Sys
|
3
|
-
|
4
|
-
class Action
|
5
|
-
class Player
|
6
|
-
def play(request='')
|
7
|
-
unless Uname.sysname.include?('Windows')
|
8
|
-
puts 'Your platform is not supported by green_shoes Video.'
|
9
|
-
Kernel.exit
|
10
|
-
end
|
11
|
-
require 'green_shoes'
|
12
|
-
Shoes.app title: 'JaredPlayer' do
|
13
|
-
background gray..black, angle: 90
|
14
|
-
$v = video request
|
15
|
-
timer 1 do
|
16
|
-
$v.play
|
17
|
-
end
|
18
|
-
button 'Play/Pause' do
|
19
|
-
if $v.playing?
|
20
|
-
$v.pause
|
21
|
-
else
|
22
|
-
$v.play
|
23
|
-
end
|
24
|
-
end
|
25
|
-
button 'Stop' do
|
26
|
-
$v.stop
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
Action::Player.new.play(ARGV[1])
|
@@ -1,17 +0,0 @@
|
|
1
|
-
require "jared/plugin"
|
2
|
-
|
3
|
-
Jared::Plugin.config do |plugin|
|
4
|
-
plugin.name = "Stock"
|
5
|
-
plugin.description = "Fetches stock data, from source."
|
6
|
-
plugin.author = "Cyberarm"
|
7
|
-
plugin.author_email = "matthewlikesrobots@gmail.com"
|
8
|
-
plugin.homepage = "http://github.com/cyberarm/jared-core-plugins"
|
9
|
-
plugin.sourcecode = "http://github.com/cyberarm/jared-core-plugins"
|
10
|
-
plugin.command = "stock"
|
11
|
-
plugin.arguments = "SYMBOL"
|
12
|
-
plugin.usage = "stock dct", "Stock data for: DCT Industrial Trust Inc.\n6.38"
|
13
|
-
plugin.version = "0.4.0"
|
14
|
-
plugin.main_require = "lib/stock"
|
15
|
-
plugin.jared_version = "0.0.7a4"
|
16
|
-
plugin.platform = :ruby
|
17
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
require 'stock_quote'
|
2
|
-
|
3
|
-
class Action
|
4
|
-
class Stock
|
5
|
-
def initialize(a,b='last')
|
6
|
-
stock(a,b)
|
7
|
-
end
|
8
|
-
def stock(symbol='', mode='last')
|
9
|
-
stock = StockQuote::Stock.quote("#{symbol}")
|
10
|
-
puts "Stock data for: #{if stock.company.length == 0; raise "Invalid Stock. No stock data found for '#{symbol}'.";exit;else;stock.company;end}"
|
11
|
-
if mode == 'last'
|
12
|
-
puts "#{stock.last}"
|
13
|
-
elsif mode == 'open'
|
14
|
-
puts "#{stock.open}"
|
15
|
-
elsif mode == 'close'
|
16
|
-
puts "#{stock.y_close}"
|
17
|
-
elsif mode == 'high'
|
18
|
-
puts "#{stock.high}"
|
19
|
-
elsif mode == 'low'
|
20
|
-
puts "#{stock.low}"
|
21
|
-
else
|
22
|
-
puts "Mode: '#{mode}' not understood. try again."
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
if ARGV[1].length <= 0
|
29
|
-
puts "Symbol not defined."
|
30
|
-
Kernel.exit
|
31
|
-
end
|
32
|
-
|
33
|
-
Action::Stock.new(ARGV[1]) unless defined?(ARGV[2].length)
|
34
|
-
Action::Stock.new(ARGV[1], ARGV[2]) if defined?(ARGV[2].length)
|
@@ -1,15 +0,0 @@
|
|
1
|
-
require "jared/plugin"
|
2
|
-
|
3
|
-
Jared::Plugin.config do |plugin|
|
4
|
-
plugin.name = "Tasks"
|
5
|
-
plugin.description = "Manage tasks."
|
6
|
-
plugin.author = "Cyberarm"
|
7
|
-
plugin.homepage = "http://github.com/cyberarm/jared"
|
8
|
-
plugin.sourcecode = "http://github.com/cyberarm/jared"
|
9
|
-
plugin.command = "tasks"
|
10
|
-
plugin.usage = "tasks"
|
11
|
-
plugin.version = "0.4.0"
|
12
|
-
plugin.main_require = "lib/task"
|
13
|
-
plugin.jared_version = "0.0.7a4"
|
14
|
-
plugin.platform = :ruby
|
15
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
require "green_shoes"
|
2
|
-
require "chronic"
|
3
|
-
require_relative "../../../database"
|
4
|
-
|
5
|
-
module TasksExtensions
|
6
|
-
def create_or_edit_task(task)
|
7
|
-
window do
|
8
|
-
para "Are cans awesome?"
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
class Action
|
14
|
-
class Tasks
|
15
|
-
extend TasksExtensions
|
16
|
-
def time_parse(time)
|
17
|
-
Time.parse(time.to_s).strftime("%A, %B %dth %Y")
|
18
|
-
end
|
19
|
-
|
20
|
-
# Opens a Green Shoes app to manage tasks.
|
21
|
-
def task
|
22
|
-
Lib.db
|
23
|
-
Shoes.app title: "Jared Tasks" do
|
24
|
-
title "Tasks"
|
25
|
-
flow do
|
26
|
-
button "Create Task" do
|
27
|
-
create_or_edit_task
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
stack do
|
32
|
-
Task.all.each do |task|
|
33
|
-
caption "Task: #{task.title}"
|
34
|
-
para "#{task.description}"
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
Action::Tasks.new.task
|
@@ -1,17 +0,0 @@
|
|
1
|
-
require "jared/plugin"
|
2
|
-
|
3
|
-
Jared::Plugin.config do |plugin|
|
4
|
-
plugin.name = "Weather"
|
5
|
-
plugin.description = "Fetches weather data."
|
6
|
-
plugin.author = "Cyberarm"
|
7
|
-
plugin.author_email = "matthewlikesrobots@gmail.com"
|
8
|
-
plugin.homepage = "http://github.com/cyberarm/jared-core-plugins"
|
9
|
-
plugin.sourcecode = "http://github.com/cyberarm/jared-core-plugins"
|
10
|
-
plugin.command = "weather"
|
11
|
-
plugin.arguments = "FORECAST"
|
12
|
-
plugin.usage = "weather 10001", "D"
|
13
|
-
plugin.version = "0.4.0"
|
14
|
-
plugin.main_require = "lib/weather"
|
15
|
-
plugin.jared_version = "0.0.7a4"
|
16
|
-
plugin.platform = :ruby
|
17
|
-
end
|
@@ -1,70 +0,0 @@
|
|
1
|
-
require 'weatherboy'
|
2
|
-
require 'area'
|
3
|
-
|
4
|
-
if Time.now.strftime("%a") == "Sun"
|
5
|
-
$day = "Mon"
|
6
|
-
$dn = "Monday"
|
7
|
-
elsif Time.now.strftime("%a") == "Mon"
|
8
|
-
$day = "Tue"
|
9
|
-
$dn = "Tuesday"
|
10
|
-
elsif Time.now.strftime("%a") == "Tue"
|
11
|
-
$day = "Wed"
|
12
|
-
$dn = "Wednesday"
|
13
|
-
elsif Time.now.strftime("%a") == "Wed"
|
14
|
-
$day = "Thu"
|
15
|
-
$dn = "Thursday"
|
16
|
-
elsif Time.now.strftime("%a") == "Thu"
|
17
|
-
$day = "Fri"
|
18
|
-
$dn = "Friday"
|
19
|
-
elsif Time.now.strftime("%a") == "Fri"
|
20
|
-
$day = "Sat"
|
21
|
-
$dn = "Saturday"
|
22
|
-
elsif Time.now.strftime("%a") == "Sat"
|
23
|
-
$day = "Sun"
|
24
|
-
$dn = "Sunday"
|
25
|
-
end
|
26
|
-
|
27
|
-
class Action
|
28
|
-
class Weather
|
29
|
-
Lib.db
|
30
|
-
# Checks weather.
|
31
|
-
#
|
32
|
-
# Usage: <em>jared weather (10001/today/tomorrow/forecast)</em>
|
33
|
-
def weather(option=nil)
|
34
|
-
option=option.downcase unless option.nil?
|
35
|
-
@user = User.first
|
36
|
-
begin
|
37
|
-
weather = Weatherboy.new(@user.zip)
|
38
|
-
puts @user.zip.to_region
|
39
|
-
if option == nil
|
40
|
-
forecast = weather.current
|
41
|
-
puts forecast.temp_f + " Degrees Fahrenheit.", forecast.weather + ".", forecast.wind_mph + " mile per hour winds from the #{forecast.wind_dir}."
|
42
|
-
|
43
|
-
elsif option == "today"
|
44
|
-
condition=weather.forecasts[0]
|
45
|
-
puts "#{condition.title}."
|
46
|
-
puts " #{condition.text}"
|
47
|
-
|
48
|
-
elsif option == "tomorrow"
|
49
|
-
condition=weather.forecasts[1]
|
50
|
-
puts "#{condition.title}."
|
51
|
-
puts " #{condition.text}"
|
52
|
-
|
53
|
-
elsif option == "forecast"
|
54
|
-
weather.forecasts.each do |condition|
|
55
|
-
puts "#{condition.title}."
|
56
|
-
puts " #{condition.text}"
|
57
|
-
puts
|
58
|
-
end
|
59
|
-
else
|
60
|
-
puts "Unable to fetch weather due to argument error."
|
61
|
-
end
|
62
|
-
rescue SocketError
|
63
|
-
puts "A connection error occurred fetching weather information."
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
Action::Weather.new.weather unless defined?(ARGV[1].length)
|
70
|
-
Action::Weather.new.weather(ARGV[1]) if defined?(ARGV[1].length)
|
data/lib/jared/database.rb
DELETED
@@ -1,59 +0,0 @@
|
|
1
|
-
# Lib file loads all Action and ActiveRecord Models.
|
2
|
-
|
3
|
-
require 'sqlite3'
|
4
|
-
require 'active_record'
|
5
|
-
unless File.exist?("#{Dir.home}/.jared/db/jared.sqlite3")
|
6
|
-
puts "Setting up database..."
|
7
|
-
ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :database => "#{Dir.home}/.jared/db/jared.sqlite3")
|
8
|
-
ActiveRecord::Migration.verbose = false
|
9
|
-
|
10
|
-
# Create Database table for Tasks
|
11
|
-
ActiveRecord::Schema.define do
|
12
|
-
create_table :tasks do |t|
|
13
|
-
t.column :title, :string
|
14
|
-
t.column :description, :string
|
15
|
-
t.column :due, :datetime
|
16
|
-
t.timestamps
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
# Create table table for Musics
|
21
|
-
ActiveRecord::Schema.define do
|
22
|
-
create_table :musics do |t|
|
23
|
-
t.column :status, :string
|
24
|
-
t.column :now_playing, :string
|
25
|
-
t.column :now_playing_album, :string
|
26
|
-
t.column :album_image, :string
|
27
|
-
t.column :now_playing_author, :string
|
28
|
-
t.column :author_url, :string
|
29
|
-
t.column :music_url, :string
|
30
|
-
t.column :album_url, :string
|
31
|
-
t.timestamps
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
# Create Database table for User
|
36
|
-
ActiveRecord::Schema.define do
|
37
|
-
create_table :users do |t|
|
38
|
-
t.column :name, :string
|
39
|
-
t.column :zip, :string
|
40
|
-
t.column :mail_username, :string
|
41
|
-
t.column :mail_password, :string
|
42
|
-
t.column :mail_provider, :string
|
43
|
-
t.column :music, :string
|
44
|
-
t.timestamps
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
class Lib
|
50
|
-
# ActiveRecord DataBase connect
|
51
|
-
def self.db
|
52
|
-
ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :database => "#{Dir.home}/.jared/db/jared.sqlite3")
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
# Model files required
|
57
|
-
require_relative 'models/music.rb'
|
58
|
-
require_relative 'models/task.rb'
|
59
|
-
require_relative 'models/user.rb'
|
data/lib/jared/jared.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
@commands=[]
|
2
|
-
@path="#{Dir.home}/.jared/plugins"
|
3
|
-
log.info "Plugin count: #{@plugins.count}"
|
4
|
-
@found=false
|
5
|
-
@plugins.each do |plugin|
|
6
|
-
next unless defined?(ARGV[0].length)
|
7
|
-
next unless plugin[:command].downcase == ARGV[0].downcase
|
8
|
-
if plugin[:command].downcase == ARGV[0].downcase
|
9
|
-
require_relative "#{plugin[:dir]}/#{plugin[:main_require]}"
|
10
|
-
@found=true
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
unless @found
|
15
|
-
unless defined?(ARGV[0].length)
|
16
|
-
require_relative "core/greeter/lib/greeting"
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
unless @found
|
21
|
-
puts "Plugin for '#{ARGV[0]}' not found." if defined?(ARGV[0].length)
|
22
|
-
end
|
data/lib/jared/models/music.rb
DELETED
data/lib/jared/models/task.rb
DELETED