jared 0.0.5 → 0.0.7a1
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 +8 -4
- data/Gemfile +4 -4
- data/Rakefile +1 -1
- data/bin/jared +8 -8
- data/jared.gemspec +35 -18
- data/lib/jared/helpers/calculator.rb +8 -0
- data/lib/jared/helpers/calendar.rb +15 -0
- data/lib/jared/helpers/clock.rb +19 -0
- data/lib/jared/helpers/config.rb +46 -0
- data/lib/jared/helpers/create.rb +27 -0
- data/lib/jared/helpers/date.rb +41 -0
- data/lib/jared/helpers/deamon.rb +100 -0
- data/lib/jared/helpers/define.rb +8 -0
- data/lib/jared/helpers/greeting.rb +22 -0
- data/lib/jared/helpers/jamendo.rb +58 -0
- data/lib/jared/helpers/mail.rb +38 -0
- data/lib/jared/helpers/map.rb +10 -0
- data/lib/jared/helpers/notfound.rb +14 -0
- data/lib/jared/helpers/player.rb +29 -0
- data/lib/jared/helpers/stock.rb +21 -0
- data/lib/jared/helpers/task.rb +114 -0
- data/lib/jared/helpers/weather.rb +74 -0
- data/lib/jared/jared.rb +140 -130
- data/lib/jared/lib.rb +13 -0
- data/lib/jared/models/info.rb +2 -0
- data/lib/jared/models/task.rb +5 -0
- data/lib/jared/models/user.rb +5 -0
- data/lib/jared/version.rb +3 -3
- data/lib/jared.rb +75 -0
- data/readme.md +87 -2
- metadata +248 -14
- data/lib/config.yml +0 -4
- data/lib/jared/helpers.rb +0 -87
data/.gitignore
CHANGED
data/Gemfile
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
source "http://rubygems.org"
|
2
|
-
|
3
|
-
# Specify your gem's dependencies in jared.gemspec
|
4
|
-
gemspec
|
1
|
+
source "http://rubygems.org"
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in jared.gemspec
|
4
|
+
gemspec
|
data/Rakefile
CHANGED
@@ -1 +1 @@
|
|
1
|
-
require
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/jared
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
begin
|
4
|
-
require 'jared
|
5
|
-
rescue LoadError
|
6
|
-
require 'rubygems'
|
7
|
-
require 'jared
|
8
|
-
end
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
begin
|
4
|
+
require 'jared'
|
5
|
+
rescue LoadError
|
6
|
+
require 'rubygems'
|
7
|
+
require 'jared'
|
8
|
+
end
|
data/jared.gemspec
CHANGED
@@ -1,18 +1,35 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
$:.push File.expand_path("../lib", __FILE__)
|
3
|
-
|
4
|
-
|
5
|
-
Gem::Specification.new do |s|
|
6
|
-
s.name
|
7
|
-
s.version
|
8
|
-
s.authors
|
9
|
-
s.email
|
10
|
-
s.homepage
|
11
|
-
s.summary
|
12
|
-
s.description = "
|
13
|
-
|
14
|
-
s.
|
15
|
-
|
16
|
-
s.
|
17
|
-
s.
|
18
|
-
|
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_development_dependency "stock_quote"
|
22
|
+
s.add_runtime_dependency "green_shoes"
|
23
|
+
s.add_runtime_dependency "gstreamer"
|
24
|
+
s.add_runtime_dependency "thor"
|
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 'google-weather'
|
31
|
+
s.add_runtime_dependency 'gmail'
|
32
|
+
s.add_runtime_dependency 'gibberish'
|
33
|
+
s.add_runtime_dependency 'faster_require'
|
34
|
+
s.add_runtime_dependency 'json'
|
35
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class Helpers
|
2
|
+
# Not yet implemented.
|
3
|
+
#
|
4
|
+
# _jared_ _cal_ Manage your appointments in a Green Shoes app.
|
5
|
+
def self.cal
|
6
|
+
require "green_shoes"
|
7
|
+
Shoes.app do
|
8
|
+
title "Calendar Events"
|
9
|
+
events = ["Sidney", "Call Bob"]
|
10
|
+
events.each do |e|
|
11
|
+
para e
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class Helpers
|
2
|
+
# _jared_ _clock_ Opens a digital clock in a Green Shoes app.
|
3
|
+
def self.clock
|
4
|
+
begin
|
5
|
+
require "green_shoes"
|
6
|
+
Shoes.app width: 400, height: 70, title: "Jared Clock" do
|
7
|
+
@clock = stack do
|
8
|
+
title "#{Time.now.strftime("%I:%M:%P")}"
|
9
|
+
end
|
10
|
+
every 0.5 do
|
11
|
+
@clock.clear do
|
12
|
+
title "#{Time.now.strftime("%I:%M:%S%P")}"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
rescue LoadError
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
class Helpers
|
2
|
+
Lib.db
|
3
|
+
# Opens a Green Shoes window to configure your name, zipcode, gmail username, gmail password.
|
4
|
+
def self.config
|
5
|
+
require 'gibberish'
|
6
|
+
Shoes.app title: "Jared - Configuration", height: 300, width: 500 do
|
7
|
+
background "#333".."#666"
|
8
|
+
tagline "Configure Jared to your person"
|
9
|
+
@user = User.first
|
10
|
+
if @user.blank?
|
11
|
+
button "Create profile" do
|
12
|
+
new_user = User.new(:name => "#{Etc.getlogin}", :zip => "10001")
|
13
|
+
new_user.save
|
14
|
+
if new_user == true
|
15
|
+
exit
|
16
|
+
Helpers.config
|
17
|
+
else
|
18
|
+
alert "Failed. Retry."
|
19
|
+
end
|
20
|
+
end
|
21
|
+
else
|
22
|
+
para 'Your name:'
|
23
|
+
@name = edit_line "#{@user.name}"
|
24
|
+
para 'Your zipcode (For weather)'
|
25
|
+
@zip = edit_line "#{@user.zip}"
|
26
|
+
para 'Prefered music genre (For jamendo)'
|
27
|
+
@music = list_box items: ['classical', 'rock', 'jazz', 'electro', 'hiphop'].sort
|
28
|
+
para 'Your Gmail email address (For email checking)'
|
29
|
+
@mail = edit_line "#{@user.mail_username}"
|
30
|
+
para 'Your Gmail password (Will be encrypted)'
|
31
|
+
@password = edit_line "#{@user.mail_password}", secret: true
|
32
|
+
button "Save" do
|
33
|
+
cipher = Gibberish::AES.new(@mail.text)
|
34
|
+
@secret = cipher.enc(@password.text)
|
35
|
+
update_user = @user.update_attributes(:name => @name.text, :zip => @zip.text, :music => @music.text, :mail_username => @mail.text, :mail_password => @secret)
|
36
|
+
if update_user
|
37
|
+
alert "Saved."
|
38
|
+
close
|
39
|
+
else
|
40
|
+
alert "failed to save."
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
class Helpers
|
2
|
+
# Creates a File or Folder.
|
3
|
+
#
|
4
|
+
# Usage:
|
5
|
+
#
|
6
|
+
# <em>jared create file/folder/dir</em>
|
7
|
+
def self.create
|
8
|
+
begin
|
9
|
+
if ARGV[1].include?("folder")
|
10
|
+
FileUtils.mkdir "#{ARGV[2]}"
|
11
|
+
puts "New Folder is at: #{Dir.pwd}/#{ARGV[2]}"
|
12
|
+
elsif ARGV[1].include?("dir")
|
13
|
+
FileUtils.mkdir "#{ARGV[2]}"
|
14
|
+
puts "New Directory is at: #{Dir.pwd}/#{ARGV[2]}"
|
15
|
+
elsif ARGV[1].include?("file")
|
16
|
+
File.open("#{ARGV[2]}", 'w') do |file|
|
17
|
+
file.puts "Hello World"
|
18
|
+
end
|
19
|
+
puts "New file is at: #{Dir.pwd}/#{ARGV[2]}"
|
20
|
+
else
|
21
|
+
puts "Don't know how-to create that."
|
22
|
+
end
|
23
|
+
rescue NoMethodError
|
24
|
+
puts "Folder/File name can't be blank."
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
class Helpers
|
2
|
+
# Date and Time
|
3
|
+
#
|
4
|
+
# _jared_ _time_ returns the current time.
|
5
|
+
#
|
6
|
+
#e.g.
|
7
|
+
#
|
8
|
+
#02:33:19pm
|
9
|
+
#
|
10
|
+
# _Jared_ _date_ returns the current date.
|
11
|
+
#
|
12
|
+
#e.g.
|
13
|
+
#
|
14
|
+
#Tuesday the 1st of May 2012
|
15
|
+
#
|
16
|
+
#(05/01/2012)
|
17
|
+
def self.date
|
18
|
+
st = "#{Time.now.strftime("%A the %dst of %B %Y")}"
|
19
|
+
nd = "#{Time.now.strftime("%A the %dnd of %B %Y")}"
|
20
|
+
rd = "#{Time.now.strftime("%A the %drd of %B %Y")}"
|
21
|
+
|
22
|
+
if Time.now.strftime("%d") == "02"
|
23
|
+
puts nd.gsub("0", "")
|
24
|
+
elsif Time.now.strftime("%d") == "22"
|
25
|
+
puts nd
|
26
|
+
elsif Time.now.strftime("%d") == "3"
|
27
|
+
puts rd
|
28
|
+
elsif Time.now.strftime("%d") == "33"
|
29
|
+
puts rd
|
30
|
+
elsif Time.now.strftime("%d") == "21"
|
31
|
+
puts st
|
32
|
+
elsif Time.now.strftime("%d") == "31"
|
33
|
+
puts st
|
34
|
+
elsif Time.now.strftime("%d") == "01"
|
35
|
+
puts st.gsub("0", "")
|
36
|
+
else
|
37
|
+
puts "#{Time.now.strftime("%A the %dth of %B %Y")}"
|
38
|
+
end
|
39
|
+
puts "(#{Time.now.strftime("%m/%d/%Y")})"
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,100 @@
|
|
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
|
+
# TODO: add appointments to deamon
|
12
|
+
#
|
13
|
+
# NOTE: Research Google Calendar
|
14
|
+
def self.appointment
|
15
|
+
puts "Jared Calendar"
|
16
|
+
puts "0 Appointments occurring today."
|
17
|
+
puts "Google Calendar"
|
18
|
+
puts "x Appointments occurring today"
|
19
|
+
end
|
20
|
+
# Actually checks mail.
|
21
|
+
def self.message
|
22
|
+
begin
|
23
|
+
@user = User.first
|
24
|
+
if @user.mail_username.blank?
|
25
|
+
puts "Jared is not configured to check email."
|
26
|
+
puts "Please run, 'jared config'"
|
27
|
+
Kernel.exit
|
28
|
+
elsif @user.mail_password.blank?
|
29
|
+
puts "Jared is not configured to check email."
|
30
|
+
puts "Please run, 'jared config'"
|
31
|
+
Kernel.exit
|
32
|
+
else
|
33
|
+
cipher = Gibberish::AES.new(@user.mail_username)
|
34
|
+
password = cipher.dec(@user.mail_password)
|
35
|
+
Gmail.connect(@user.mail_username, password) do |gmail|
|
36
|
+
if gmail.logged_in?
|
37
|
+
if gmail.inbox.count(:unread) == 0
|
38
|
+
else
|
39
|
+
puts "Google Mail"
|
40
|
+
puts gmail.inbox.count(:unread).to_s + " Unread messages."
|
41
|
+
|
42
|
+
gmail.inbox.emails(:unread).first(15).each do |email|
|
43
|
+
email.unread!
|
44
|
+
print "From:",email.sender[0].mailbox,"@", email.sender[0].host, ", Subject:",email.subject
|
45
|
+
puts
|
46
|
+
puts
|
47
|
+
end
|
48
|
+
end
|
49
|
+
else
|
50
|
+
puts "Failed to login."
|
51
|
+
Kernel.exit
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
rescue => e
|
57
|
+
if e.to_s.include?("mail_")
|
58
|
+
puts "Jared is not configured to check email."
|
59
|
+
puts "Please run, 'jared config' or click 'OK' on the popup."
|
60
|
+
Kernel.exit
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
class Helpers
|
66
|
+
# Checks every 60 seconds for, Tasks, Appointments, Emails.
|
67
|
+
#
|
68
|
+
# Usage: <em>jared deamon (task/cal/mail)</em>
|
69
|
+
def self.deamon
|
70
|
+
if ARGV[1] == nil
|
71
|
+
Helpers.mail
|
72
|
+
loop do
|
73
|
+
Deamon.message
|
74
|
+
Deamon.task
|
75
|
+
Deamon.appointment
|
76
|
+
puts
|
77
|
+
puts
|
78
|
+
sleep(60)
|
79
|
+
end
|
80
|
+
elsif ARGV[1] == "cal" || ARGV[1] == "calendar"
|
81
|
+
loop do
|
82
|
+
Deamon.appointment
|
83
|
+
puts
|
84
|
+
sleep(60)
|
85
|
+
end
|
86
|
+
elsif ARGV[1] == 'mail'
|
87
|
+
Helpers.mail
|
88
|
+
loop do
|
89
|
+
Deamon.message
|
90
|
+
sleep(60)
|
91
|
+
end
|
92
|
+
elsif ARGV[1] == "task"
|
93
|
+
loop do
|
94
|
+
Deamon.task
|
95
|
+
puts
|
96
|
+
sleep(60)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
class Helpers
|
2
|
+
Lib.db
|
3
|
+
# Dynamically greets the user by time when <em>jared hi/hello</em> is run.
|
4
|
+
def self.greeting
|
5
|
+
if Time.now.strftime("%H").to_i < "04".to_i
|
6
|
+
puts "Go tee bed."
|
7
|
+
elsif Time.now.strftime("%H").to_i < "07".to_i
|
8
|
+
puts "Yawn Zzzz"
|
9
|
+
elsif Time.now.strftime("%H").to_i < "12".to_i
|
10
|
+
puts "Morning, #{User.first.name.capitalize}"
|
11
|
+
elsif Time.now.strftime("%H").to_i < "16".to_i
|
12
|
+
puts "Afternoon, #{User.first.name.capitalize}"
|
13
|
+
elsif Time.now.strftime("%H").to_i < "20".to_i
|
14
|
+
puts "Evening, #{User.first.name.capitalize}"
|
15
|
+
elsif Time.now.strftime("%H").to_i < "22".to_i
|
16
|
+
puts "Ummm, good night, #{User.first.name.capitalize}"
|
17
|
+
puts "Its getting late, consider getting some rest."
|
18
|
+
elsif Time.now.strftime("%H").to_i < "24".to_i
|
19
|
+
puts "Zzzz"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
class Helpers
|
2
|
+
|
3
|
+
def self.player(n=0)
|
4
|
+
puts "Now playing: #{@data['name']}, By: #{@data['artist_name']} (#{n})"
|
5
|
+
@playbin = Gst::ElementFactory.make('playbin2')
|
6
|
+
@playbin.uri = @data['stream']
|
7
|
+
loop = GLib::MainLoop.new(nil, false)
|
8
|
+
bus = @playbin.bus
|
9
|
+
bus.add_watch {|bus, message|
|
10
|
+
case message.type
|
11
|
+
when Gst::Message::EOS
|
12
|
+
loop.quit
|
13
|
+
end
|
14
|
+
true}
|
15
|
+
@playbin.play
|
16
|
+
begin
|
17
|
+
loop.run
|
18
|
+
rescue Interrupt
|
19
|
+
ensure
|
20
|
+
@playbin.stop
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.jamendo(mode='once')
|
25
|
+
Lib.db
|
26
|
+
@jared = Info.first
|
27
|
+
@user = User.first
|
28
|
+
require 'gtk2'
|
29
|
+
require 'open-uri'
|
30
|
+
require 'json'
|
31
|
+
require 'gst'
|
32
|
+
@list = open("http://api.jamendo.com/get2/name+url+stream+album_name+album_url+album_image+artist_name+artist_url/track/json/track_album+album_artist/?n=100&order=ratingmonth_desc&tag_idstr=#{@user.music}").read
|
33
|
+
@d = JSON.parse(@list)
|
34
|
+
@data = @d[2]
|
35
|
+
|
36
|
+
if mode == 'loop'
|
37
|
+
puts 'Starting loop, use CTRL-Pause(Break) to stop.'
|
38
|
+
loop do
|
39
|
+
v = Random.rand(0..49)
|
40
|
+
@data = @d[v]
|
41
|
+
@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']}")
|
42
|
+
Helpers.player(v)
|
43
|
+
end
|
44
|
+
elsif mode == 'once'
|
45
|
+
v = Random.rand(0..49)
|
46
|
+
@data = @d[v]
|
47
|
+
@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']}")
|
48
|
+
Helpers.player(v)
|
49
|
+
elsif mode == 'help'
|
50
|
+
puts 'loop|once'
|
51
|
+
else
|
52
|
+
v = mode.to_s.to_i
|
53
|
+
@data = @d[v]
|
54
|
+
@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']}")
|
55
|
+
Helpers.player(mode.to_s.to_i)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
class Helpers
|
2
|
+
Lib.db
|
3
|
+
# Checks Email on demand.
|
4
|
+
def self.mail
|
5
|
+
require 'gibberish'
|
6
|
+
begin
|
7
|
+
@user = User.first
|
8
|
+
if @user.mail_username.blank?
|
9
|
+
puts "Jared is not configured to check email."
|
10
|
+
puts "Please run, 'jared config'"
|
11
|
+
elsif @user.mail_password.blank?
|
12
|
+
puts "Jared is not configured to check email."
|
13
|
+
puts "Please run, 'jared config'"
|
14
|
+
else
|
15
|
+
cipher = Gibberish::AES.new(@user.mail_username)
|
16
|
+
password = cipher.dec(@user.mail_password)
|
17
|
+
Gmail.connect(@user.mail_username, password) do |gmail|
|
18
|
+
if gmail.logged_in?
|
19
|
+
puts "Google Mail"
|
20
|
+
puts gmail.inbox.count(:unread).to_s + " Unread messages."
|
21
|
+
gmail.inbox.emails(:unread).each do |email|
|
22
|
+
email.unread!
|
23
|
+
print "From:",email.sender[0].mailbox,"@", email.sender[0].host, ", Subject:",email.subject
|
24
|
+
puts
|
25
|
+
end
|
26
|
+
else
|
27
|
+
puts "Not logged in."
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
rescue => e
|
32
|
+
if e.to_s.include?("mail_")
|
33
|
+
puts "Jared is not configured to check email."
|
34
|
+
puts "Please run, 'jared config' or click 'OK' on the popup."
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class Helpers
|
2
|
+
# Lists available commands.
|
3
|
+
def self.notfound
|
4
|
+
puts "Error: Command '#{ARGV[0]}' not found."
|
5
|
+
puts "Hi, Hello - Jared Hi -Morning, #{Etc.getlogin}"
|
6
|
+
puts "Create - Jared Create file index.html - Creates a File/Folder at curent location."
|
7
|
+
puts "Time - Jared Time - 04:12pm"
|
8
|
+
puts "Date - Jared Date - Tuesday the 22nd of December 2012"
|
9
|
+
#puts "calc(ulator) - Jared Calc 22 / 2 - 11"
|
10
|
+
puts "Task - Jared task - Opens a window listing tasks."
|
11
|
+
puts "View - Jared View lib/lib.rb - Opens a file(e.g. Picture, document) in the system viewer."
|
12
|
+
puts "Whereis - Jared Whereis - Opens the system default browser to Gmaps."
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'sys/uname'
|
2
|
+
include Sys
|
3
|
+
|
4
|
+
class Helpers
|
5
|
+
def self.play(request='')
|
6
|
+
unless Uname.sysname.include?('Windows')
|
7
|
+
puts 'Your platform is not supported by green_shoes Video.'
|
8
|
+
Kernel.exit
|
9
|
+
end
|
10
|
+
require 'green_shoes'
|
11
|
+
Shoes.app title: 'JaredPlayer' do
|
12
|
+
background gray..black, angle: 90
|
13
|
+
$v = video request
|
14
|
+
timer 1 do
|
15
|
+
$v.play
|
16
|
+
end
|
17
|
+
button 'Play/Pause' do
|
18
|
+
if $v.playing?
|
19
|
+
$v.pause
|
20
|
+
else
|
21
|
+
$v.play
|
22
|
+
end
|
23
|
+
end
|
24
|
+
button 'Stop' do
|
25
|
+
$v.stop
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'stock_quote'
|
2
|
+
|
3
|
+
class Helpers
|
4
|
+
def self.stock(symbol='', mode='last')
|
5
|
+
stock = StockQuote::Stock.quote("#{symbol}")
|
6
|
+
puts "Stock data for: #{if stock.company.length == 0; raise "Invalid Stock. No stock data found for '#{symbol}'.";exit;else;stock.company;end}"
|
7
|
+
if mode == 'last'
|
8
|
+
puts "#{stock.last}"
|
9
|
+
elsif mode == 'open'
|
10
|
+
puts "#{stock.open}"
|
11
|
+
elsif mode == 'close'
|
12
|
+
puts "#{stock.y_close}"
|
13
|
+
elsif mode == 'high'
|
14
|
+
puts "#{stock.high}"
|
15
|
+
elsif mode == 'low'
|
16
|
+
puts "#{stock.low}"
|
17
|
+
else
|
18
|
+
puts "Mode: '#{mode}' not understood. try again."
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|