jared 0.0.7a3 → 0.0.7a4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +10 -8
- data/jared.gemspec +35 -35
- data/lib/jared/core/clock/init.rb +15 -0
- data/lib/jared/core/clock/lib/clock.rb +23 -0
- data/lib/jared/core/configure/init.rb +15 -0
- data/lib/jared/core/configure/lib/config.rb +60 -0
- data/lib/jared/core/create/init.rb +16 -0
- data/lib/jared/core/create/lib/create.rb +33 -0
- data/lib/jared/core/daemon/daemon.rb +104 -0
- data/lib/jared/core/daemon/init.rb +15 -0
- data/lib/jared/core/date/init.rb +15 -0
- data/lib/jared/core/date/lib/date.rb +45 -0
- data/lib/jared/core/greeter/init.rb +15 -0
- data/lib/jared/core/greeter/lib/greeting.rb +26 -0
- data/lib/jared/core/jamendo/init.rb +17 -0
- data/lib/jared/core/jamendo/lib/jamendo.rb +88 -0
- data/lib/jared/core/mail/init.rb +15 -0
- data/lib/jared/core/mail/lib/mail.rb +45 -0
- data/lib/jared/core/map/New File +0 -0
- data/lib/jared/core/map/init.rb +15 -0
- data/lib/jared/core/map/lib/map.rb +12 -0
- data/lib/jared/core/player/init.rb +15 -0
- data/lib/jared/core/player/lib/player.rb +33 -0
- data/lib/jared/core/stock/init.rb +17 -0
- data/lib/jared/core/stock/lib/stock.rb +34 -0
- data/lib/jared/core/tasks/init.rb +15 -0
- data/lib/jared/core/tasks/lib/task.rb +42 -0
- data/lib/jared/core/weather/init.rb +17 -0
- data/lib/jared/core/weather/lib/weather.rb +70 -0
- data/lib/jared/database.rb +59 -0
- data/lib/jared/jared.rb +22 -141
- data/lib/jared/logg.rb +15 -0
- data/lib/jared/models/task.rb +5 -5
- data/lib/jared/plugin.rb +35 -0
- data/lib/jared/plugins.rb +92 -0
- data/lib/jared/version.rb +2 -2
- data/lib/jared.rb +86 -77
- data/readme.md +14 -18
- metadata +34 -22
- data/lib/jared/helpers/calculator.rb +0 -8
- data/lib/jared/helpers/calendar.rb +0 -15
- data/lib/jared/helpers/clock.rb +0 -19
- data/lib/jared/helpers/config.rb +0 -46
- data/lib/jared/helpers/create.rb +0 -27
- data/lib/jared/helpers/date.rb +0 -41
- data/lib/jared/helpers/deamon.rb +0 -100
- data/lib/jared/helpers/define.rb +0 -8
- data/lib/jared/helpers/greeting.rb +0 -22
- data/lib/jared/helpers/jamendo.rb +0 -58
- data/lib/jared/helpers/mail.rb +0 -38
- data/lib/jared/helpers/map.rb +0 -10
- data/lib/jared/helpers/notfound.rb +0 -14
- data/lib/jared/helpers/player.rb +0 -29
- data/lib/jared/helpers/stock.rb +0 -21
- data/lib/jared/helpers/task.rb +0 -114
- data/lib/jared/helpers/weather.rb +0 -68
- data/lib/jared/lib.rb +0 -13
data/.gitignore
CHANGED
data/jared.gemspec
CHANGED
@@ -1,36 +1,36 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
$:.push File.expand_path("../lib", __FILE__)
|
3
|
-
require "jared/version"
|
4
|
-
|
5
|
-
Gem::Specification.new do |s|
|
6
|
-
s.name = "jared"
|
7
|
-
s.version = Jared::VERSION
|
8
|
-
s.authors = ["Cyber"]
|
9
|
-
s.email = ["matthewlikesrobots@gmail.com"]
|
10
|
-
s.homepage = "https://github.com/cyberarm/jared"
|
11
|
-
s.summary = "Ruby powered digital assistant"
|
12
|
-
s.description = "Ruby powered digital assistant"
|
13
|
-
|
14
|
-
s.rubyforge_project = "jared"
|
15
|
-
|
16
|
-
s.files = `git ls-files`.split("\n")
|
17
|
-
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
-
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
-
s.require_paths = ["lib", "bin"]
|
20
|
-
|
21
|
-
s.add_runtime_dependency "stock_quote"
|
22
|
-
s.add_runtime_dependency "green_shoes"
|
23
|
-
s.add_runtime_dependency "gstreamer"
|
24
|
-
s.add_runtime_dependency "
|
25
|
-
s.add_runtime_dependency "chronic"
|
26
|
-
s.add_runtime_dependency "sys-uname"
|
27
|
-
s.add_runtime_dependency "activerecord"
|
28
|
-
s.add_runtime_dependency "sqlite3"
|
29
|
-
s.add_runtime_dependency "launchy"
|
30
|
-
s.add_runtime_dependency 'weatherboy'
|
31
|
-
s.add_runtime_dependency 'area'
|
32
|
-
s.add_runtime_dependency 'gmail'
|
33
|
-
s.add_runtime_dependency 'gibberish'
|
34
|
-
s.add_runtime_dependency 'faster_require'
|
35
|
-
s.add_runtime_dependency 'json'
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "jared/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "jared"
|
7
|
+
s.version = Jared::VERSION
|
8
|
+
s.authors = ["Cyber"]
|
9
|
+
s.email = ["matthewlikesrobots@gmail.com"]
|
10
|
+
s.homepage = "https://github.com/cyberarm/jared"
|
11
|
+
s.summary = "Ruby powered digital assistant"
|
12
|
+
s.description = "Ruby powered digital assistant"
|
13
|
+
|
14
|
+
s.rubyforge_project = "jared"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib", "bin"]
|
20
|
+
|
21
|
+
s.add_runtime_dependency "stock_quote"
|
22
|
+
s.add_runtime_dependency "green_shoes"
|
23
|
+
s.add_runtime_dependency "gstreamer"
|
24
|
+
s.add_runtime_dependency "versionomy"
|
25
|
+
s.add_runtime_dependency "chronic"
|
26
|
+
s.add_runtime_dependency "sys-uname"
|
27
|
+
s.add_runtime_dependency "activerecord"
|
28
|
+
s.add_runtime_dependency "sqlite3"
|
29
|
+
s.add_runtime_dependency "launchy"
|
30
|
+
s.add_runtime_dependency 'weatherboy'
|
31
|
+
s.add_runtime_dependency 'area'
|
32
|
+
s.add_runtime_dependency 'gmail'
|
33
|
+
s.add_runtime_dependency 'gibberish'
|
34
|
+
s.add_runtime_dependency 'faster_require'
|
35
|
+
s.add_runtime_dependency 'json'
|
36
36
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require "jared/plugin"
|
2
|
+
|
3
|
+
plugin=Jared::Plugin.config do |plugin|
|
4
|
+
plugin.name = "Clock"
|
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 = "clock"
|
10
|
+
plugin.usage = "clock"
|
11
|
+
plugin.version = "0.4.0"
|
12
|
+
plugin.main_require = "lib/clock"
|
13
|
+
plugin.jared_version = "0.0.7a4"
|
14
|
+
plugin.platform = :ruby
|
15
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class Action
|
2
|
+
# _jared_ _clock_ Opens a digital clock in a Green Shoes app.
|
3
|
+
class Clock
|
4
|
+
def initialize
|
5
|
+
begin
|
6
|
+
require "green_shoes"
|
7
|
+
Shoes.app width: 400, height: 70, title: "Jared Clock" do
|
8
|
+
@clock = stack do
|
9
|
+
title "#{Time.now.strftime("%I:%M:%P")}"
|
10
|
+
end
|
11
|
+
every 0.5 do
|
12
|
+
@clock.clear do
|
13
|
+
title "#{Time.now.strftime("%I:%M:%S%P")}"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
rescue LoadError
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
Action::Clock.new
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require "jared/plugin"
|
2
|
+
|
3
|
+
Jared::Plugin.config do |plugin|
|
4
|
+
plugin.name = "Configure"
|
5
|
+
plugin.description = "Configure Jared."
|
6
|
+
plugin.author = "Cyberarm"
|
7
|
+
plugin.homepage = "http://github.com/cyberarm/jared"
|
8
|
+
plugin.sourcecode = "http://github.com/cyberarm/jared"
|
9
|
+
plugin.command = "config"
|
10
|
+
plugin.usage = "config"
|
11
|
+
plugin.version = "0.4.0"
|
12
|
+
plugin.main_require = "lib/config"
|
13
|
+
plugin.jared_version = "0.0.7a4"
|
14
|
+
plugin.platform = :ruby
|
15
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'green_shoes'
|
2
|
+
|
3
|
+
class Action
|
4
|
+
class Configure
|
5
|
+
Lib.db
|
6
|
+
# Opens a Green Shoes window to configure your name, zipcode, gmail username, gmail password.
|
7
|
+
def config
|
8
|
+
require 'gibberish'
|
9
|
+
require "json"
|
10
|
+
require "open-uri"
|
11
|
+
|
12
|
+
Shoes.app title: "Jared - Configuration", height: 300, width: 500 do
|
13
|
+
@radios = open("http://api.jamendo.com/get2/id+name/radio/json/?n=all").read
|
14
|
+
@music_array = []
|
15
|
+
JSON.parse(@radios).each do |radio|
|
16
|
+
@music_array << radio['name']
|
17
|
+
end
|
18
|
+
background "#333".."#666"
|
19
|
+
tagline "Configure Jared to your person"
|
20
|
+
@user = User.first
|
21
|
+
if @user.blank?
|
22
|
+
button "Create profile" do
|
23
|
+
new_user = User.new(:name => "#{Etc.getlogin}", :zip => "10001")
|
24
|
+
new_user.save
|
25
|
+
if new_user == true
|
26
|
+
close
|
27
|
+
Helpers.config
|
28
|
+
else
|
29
|
+
alert "Failed. Retry."
|
30
|
+
end
|
31
|
+
end
|
32
|
+
else
|
33
|
+
para 'Your name:'
|
34
|
+
@name = edit_line "#{@user.name}"
|
35
|
+
para 'Your zipcode (For weather)'
|
36
|
+
@zip = edit_line "#{@user.zip}"
|
37
|
+
para 'Prefered music genre (For jamendo)'
|
38
|
+
@music = list_box items: @music_array.sort
|
39
|
+
para 'Your Gmail email address (For email checking)'
|
40
|
+
@mail = edit_line "#{@user.mail_username}"
|
41
|
+
para 'Your Gmail password (Will be encrypted)'
|
42
|
+
@password = edit_line "", secret: true
|
43
|
+
button "Save" do
|
44
|
+
cipher = Gibberish::AES.new(@mail.text)
|
45
|
+
@secret = cipher.enc(@password.text)
|
46
|
+
update_user = @user.update_attributes(:name => @name.text, :zip => @zip.text, :music => @music.text, :mail_username => @mail.text, :mail_password => @secret)
|
47
|
+
if update_user
|
48
|
+
alert "Saved."
|
49
|
+
close
|
50
|
+
else
|
51
|
+
alert "failed to save."
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
Action::Configure.new.config
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require "jared/plugin"
|
2
|
+
|
3
|
+
Jared::Plugin.config do |plugin|
|
4
|
+
plugin.name = "Create"
|
5
|
+
plugin.description = "Create files and folders, as well as project skeleton files."
|
6
|
+
plugin.author = "Cyberarm"
|
7
|
+
plugin.homepage = "http://github.com/cyberarm/jared"
|
8
|
+
plugin.sourcecode = "http://github.com/cyberarm/jared"
|
9
|
+
plugin.command = "create"
|
10
|
+
plugin.usage = "create folder infos_project"
|
11
|
+
plugin.arguments = "TYPE, NAME"
|
12
|
+
plugin.version = "0.4.0"
|
13
|
+
plugin.main_require = "lib/create"
|
14
|
+
plugin.jared_version = "0.0.7a4"
|
15
|
+
plugin.platform = :ruby
|
16
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
class Action
|
2
|
+
class Create
|
3
|
+
# Creates a File or Folder.
|
4
|
+
#
|
5
|
+
# Usage:
|
6
|
+
#
|
7
|
+
# <em>jared create file/folder/dir</em>
|
8
|
+
def create
|
9
|
+
if defined?(ARGV[1].length)
|
10
|
+
begin
|
11
|
+
if ARGV[1].downcase == "folder"
|
12
|
+
FileUtils.mkdir "#{ARGV[2]}"
|
13
|
+
puts "New Folder is at: #{Dir.pwd}/#{ARGV[2]}"
|
14
|
+
elsif ARGV[1].downcase == "dir"
|
15
|
+
FileUtils.mkdir "#{ARGV[2]}"
|
16
|
+
puts "New Directory is at: #{Dir.pwd}/#{ARGV[2]}"
|
17
|
+
elsif ARGV[1].downcase == "file"
|
18
|
+
File.open("#{ARGV[2]}", 'w') do |file|
|
19
|
+
file.puts "Hello World"
|
20
|
+
end
|
21
|
+
puts "New file is at: #{Dir.pwd}/#{ARGV[2]}"
|
22
|
+
else
|
23
|
+
puts "Don't know how-to create that."
|
24
|
+
end
|
25
|
+
rescue NoMethodError
|
26
|
+
puts "Folder/File name can't be blank."
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
Action::Create.new.create
|
@@ -0,0 +1,104 @@
|
|
1
|
+
# == Deamon
|
2
|
+
#
|
3
|
+
# Functions for deamon command.
|
4
|
+
class Deamon
|
5
|
+
Lib.db
|
6
|
+
# TODO: Add tasks to deamon
|
7
|
+
def self.task
|
8
|
+
puts "Jared Tasks"
|
9
|
+
puts "0 Tasks due today."
|
10
|
+
end
|
11
|
+
|
12
|
+
# TODO: add appointments to deamon
|
13
|
+
#
|
14
|
+
# NOTE: Research Google Calendar
|
15
|
+
def self.appointment
|
16
|
+
puts "Jared Calendar"
|
17
|
+
puts "0 Appointments occurring today."
|
18
|
+
puts "Google Calendar"
|
19
|
+
puts "x Appointments occurring today"
|
20
|
+
end
|
21
|
+
|
22
|
+
# Actually checks mail.
|
23
|
+
def self.message
|
24
|
+
begin
|
25
|
+
@user = User.first
|
26
|
+
if @user.mail_username.blank?
|
27
|
+
puts "Jared is not configured to check email."
|
28
|
+
puts "Please run, 'jared config'"
|
29
|
+
Kernel.exit
|
30
|
+
elsif @user.mail_password.blank?
|
31
|
+
puts "Jared is not configured to check email."
|
32
|
+
puts "Please run, 'jared config'"
|
33
|
+
Kernel.exit
|
34
|
+
else
|
35
|
+
cipher = Gibberish::AES.new(@user.mail_username)
|
36
|
+
password = cipher.dec(@user.mail_password)
|
37
|
+
Gmail.connect(@user.mail_username, password) do |gmail|
|
38
|
+
if gmail.logged_in?
|
39
|
+
if gmail.inbox.count(:unread) == 0
|
40
|
+
else
|
41
|
+
puts "Google Mail"
|
42
|
+
puts gmail.inbox.count(:unread).to_s + " Unread messages."
|
43
|
+
gmail.inbox.emails(:unread).first(15).each do |email|
|
44
|
+
email.unread!
|
45
|
+
print "From:",email.sender[0].mailbox,"@", email.sender[0].host, ", Subject:",email.subject
|
46
|
+
puts
|
47
|
+
puts
|
48
|
+
end
|
49
|
+
end
|
50
|
+
else
|
51
|
+
puts "Failed to login."
|
52
|
+
Kernel.exit
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
rescue => e
|
58
|
+
if e.to_s.include?("mail_")
|
59
|
+
puts "Jared is not configured to check email."
|
60
|
+
puts "Please run, 'jared config' or click 'OK' on the popup."
|
61
|
+
Kernel.exit
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
# end
|
66
|
+
|
67
|
+
class Action
|
68
|
+
class Daemon
|
69
|
+
# Checks every 60 seconds for, Tasks, Appointments, Emails.
|
70
|
+
#
|
71
|
+
# Usage: <em>jared deamon (task/cal/mail)</em>
|
72
|
+
def deamon
|
73
|
+
if ARGV[1] == nil
|
74
|
+
Helpers.mail
|
75
|
+
loop do
|
76
|
+
Deamon.message
|
77
|
+
Deamon.task
|
78
|
+
Deamon.appointment
|
79
|
+
puts
|
80
|
+
puts
|
81
|
+
sleep(60)
|
82
|
+
end
|
83
|
+
elsif ARGV[1] == "cal" || ARGV[1] == "calendar"
|
84
|
+
loop do
|
85
|
+
Deamon.appointment
|
86
|
+
puts
|
87
|
+
sleep(60)
|
88
|
+
end
|
89
|
+
elsif ARGV[1] == 'mail'
|
90
|
+
Helpers.mail
|
91
|
+
loop do
|
92
|
+
Deamon.message
|
93
|
+
sleep(60)
|
94
|
+
end
|
95
|
+
elsif ARGV[1] == "task"
|
96
|
+
loop do
|
97
|
+
Deamon.task
|
98
|
+
puts
|
99
|
+
sleep(60)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require "jared/plugin"
|
2
|
+
|
3
|
+
Jared::Plugin.config do |plugin|
|
4
|
+
plugin.name = "Daemon"
|
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 = "daemon"
|
10
|
+
plugin.usage = "clock"
|
11
|
+
plugin.version = "0.4.0"
|
12
|
+
plugin.main_require = "lib/clock"
|
13
|
+
plugin.jared_version = "0.0.7a4"
|
14
|
+
plugin.platform = :ruby
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require "jared/plugin"
|
2
|
+
|
3
|
+
Jared::Plugin.config do |plugin|
|
4
|
+
plugin.name = "Date"
|
5
|
+
plugin.description = "Shows current date."
|
6
|
+
plugin.author = "Cyberarm"
|
7
|
+
plugin.homepage = "http://github.com/cyberarm/jared"
|
8
|
+
plugin.sourcecode = "http://github.com/cyberarm/jared"
|
9
|
+
plugin.command = "date"
|
10
|
+
plugin.usage = "date"
|
11
|
+
plugin.version = "0.4.0"
|
12
|
+
plugin.main_require = "lib/date"
|
13
|
+
plugin.jared_version = "0.0.7a4"
|
14
|
+
plugin.platform = :ruby
|
15
|
+
end
|
@@ -0,0 +1,45 @@
|
|
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
|
@@ -0,0 +1,15 @@
|
|
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
|
@@ -0,0 +1,26 @@
|
|
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
|
@@ -0,0 +1,17 @@
|
|
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
|
@@ -0,0 +1,88 @@
|
|
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
|
@@ -0,0 +1,15 @@
|
|
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
|
@@ -0,0 +1,45 @@
|
|
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
|
File without changes
|
@@ -0,0 +1,15 @@
|
|
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
|