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
@@ -0,0 +1,15 @@
|
|
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
|
@@ -0,0 +1,33 @@
|
|
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])
|
@@ -0,0 +1,17 @@
|
|
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
|
@@ -0,0 +1,34 @@
|
|
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)
|
@@ -0,0 +1,15 @@
|
|
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
|
@@ -0,0 +1,42 @@
|
|
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
|
@@ -0,0 +1,17 @@
|
|
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
|
@@ -0,0 +1,70 @@
|
|
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)
|
@@ -0,0 +1,59 @@
|
|
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
CHANGED
@@ -1,141 +1,22 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
end
|
24
|
-
|
25
|
-
desc "clock", "Open a Green Shoes powered clock."
|
26
|
-
def clock
|
27
|
-
require_relative 'helpers/clock.rb'
|
28
|
-
require 'green_shoes'
|
29
|
-
Helpers.clock
|
30
|
-
end
|
31
|
-
|
32
|
-
desc "create TYPE NAME", "create"
|
33
|
-
def create(type,name)
|
34
|
-
require_relative 'helpers/create.rb'
|
35
|
-
Helpers.create
|
36
|
-
end
|
37
|
-
|
38
|
-
desc "whereis PLACE", "Finds PLACE via Google Maps"
|
39
|
-
def whereis(place)
|
40
|
-
require_relative 'helpers/map.rb'
|
41
|
-
require 'launchy'
|
42
|
-
Helpers.map(place)
|
43
|
-
end
|
44
|
-
|
45
|
-
desc "day", "Displays the current day"
|
46
|
-
def day
|
47
|
-
puts Time.now.strftime("%A")
|
48
|
-
end
|
49
|
-
|
50
|
-
desc "whatis WORD", "Looks up the meaning of WORD."
|
51
|
-
def whatis(word)
|
52
|
-
require_relative 'helpers/define.rb'
|
53
|
-
Helpers.define(word)
|
54
|
-
end
|
55
|
-
|
56
|
-
desc "deamon MAIL/TASK/CAL", "Checks every minute for new mail/tasks/appointments."
|
57
|
-
def deamon(function=nil)
|
58
|
-
require_relative 'helpers/deamon.rb'
|
59
|
-
require 'gmail'
|
60
|
-
require 'gibberish'
|
61
|
-
Helpers.deamon
|
62
|
-
end
|
63
|
-
|
64
|
-
desc "jamendo MODE", "Plays music from Jamendo."
|
65
|
-
def jamendo(mode='once')
|
66
|
-
require_relative 'helpers/jamendo.rb'
|
67
|
-
at_exit do
|
68
|
-
require_relative 'lib.rb'
|
69
|
-
Lib.db
|
70
|
-
@jared = Music.first
|
71
|
-
@jared.update_attributes(:author_url => "", :music_url => "", :album_image => "", :album_url => "", :now_playing => "", :now_playing_author => "", :now_playing_album => "")
|
72
|
-
end
|
73
|
-
Helpers.jamendo(mode)
|
74
|
-
end
|
75
|
-
|
76
|
-
desc "play FILE", "Plays File, local or remote."
|
77
|
-
def play(media='')
|
78
|
-
require_relative 'helpers/player.rb'
|
79
|
-
Helpers.play(media)
|
80
|
-
end
|
81
|
-
|
82
|
-
desc "task", "Manage your Tasks"
|
83
|
-
def task
|
84
|
-
#require 'green_shoes'
|
85
|
-
#require 'chronic'
|
86
|
-
puts "Task is not yet available."
|
87
|
-
#Helpers.task
|
88
|
-
end
|
89
|
-
|
90
|
-
desc "config", "Configure Jared."
|
91
|
-
def config
|
92
|
-
require_relative 'helpers/config.rb'
|
93
|
-
require 'green_shoes'
|
94
|
-
require 'gibberish'
|
95
|
-
Helpers.config
|
96
|
-
end
|
97
|
-
|
98
|
-
desc "view FILENAME", "View file.png in system viewer."
|
99
|
-
def view(filename)
|
100
|
-
require 'sys/uname'
|
101
|
-
include Sys
|
102
|
-
if Uname.sysname.include?("Linux")
|
103
|
-
puts "Opening #{filename}"
|
104
|
-
system("xdg-open #{Dir.pwd}/#{filename}")
|
105
|
-
elsif Uname.sysname.include?("Windows")
|
106
|
-
puts "Opening #{filename}"
|
107
|
-
system("call \"#{Dir.pwd}/#{filename}\"")
|
108
|
-
else
|
109
|
-
puts "Your system is not supported."
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
desc "date", "Gets the current date."
|
114
|
-
def date
|
115
|
-
require_relative 'helpers/date.rb'
|
116
|
-
Helpers.date
|
117
|
-
end
|
118
|
-
|
119
|
-
desc "cal", "Calendar"
|
120
|
-
def cal
|
121
|
-
puts "Calendar is not yet available."
|
122
|
-
#require 'green_shoes'
|
123
|
-
#Helpers.cal
|
124
|
-
end
|
125
|
-
|
126
|
-
desc "mail", "Checks your mailbox for new mails."
|
127
|
-
def mail
|
128
|
-
require_relative 'helpers/mail.rb'
|
129
|
-
require 'gmail'
|
130
|
-
require 'gibberish'
|
131
|
-
Helpers.mail
|
132
|
-
end
|
133
|
-
|
134
|
-
desc "stock SYMBOL MODE", "Check semi-current stock data."
|
135
|
-
def stock(s,m='last')
|
136
|
-
require_relative 'helpers/stock.rb'
|
137
|
-
Helpers.stock(s,m)
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
|
-
Jared.start
|
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/logg.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
module Logg
|
2
|
+
def log
|
3
|
+
Logg.logger
|
4
|
+
end
|
5
|
+
|
6
|
+
# Global, memoized, lazy initialized instance of a logger
|
7
|
+
def self.logger
|
8
|
+
if File.exists?("#{Dir.home}/.jared/logs/#{Time.new.strftime('%m-%d-%y-%H')}-debug.log")
|
9
|
+
@file = File.open("#{Dir.home}/.jared/logs/#{Time.new.strftime('%m-%d-%y-%H')}-debug.log", 'a')
|
10
|
+
@logger ||= Logger.new(@file)
|
11
|
+
else
|
12
|
+
@logger ||= Logger.new("#{Dir.home}/.jared/logs/#{Time.new.strftime('%m-%d-%y-%H')}-debug.log")
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/jared/models/task.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
class Task < ActiveRecord::Base
|
2
|
-
validates_presence_of :title, :desciption
|
3
|
-
validates_uniqueness_of :title
|
4
|
-
default_scope :order => '
|
5
|
-
end
|
1
|
+
class Task < ActiveRecord::Base
|
2
|
+
validates_presence_of :title, :desciption
|
3
|
+
validates_uniqueness_of :title
|
4
|
+
default_scope :order => 'due DESC'
|
5
|
+
end
|
data/lib/jared/plugin.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
module Jared
|
2
|
+
module Plugin
|
3
|
+
class << self
|
4
|
+
attr_accessor :configuration
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.config
|
8
|
+
self.configuration ||= Configuration.new
|
9
|
+
yield(configuration)
|
10
|
+
end
|
11
|
+
|
12
|
+
class Configuration
|
13
|
+
attr_accessor :name
|
14
|
+
attr_accessor :description
|
15
|
+
attr_accessor :author
|
16
|
+
attr_accessor :author_email
|
17
|
+
attr_accessor :homepage
|
18
|
+
attr_accessor :sourcecode
|
19
|
+
attr_accessor :command
|
20
|
+
attr_accessor :arguments
|
21
|
+
attr_accessor :usage
|
22
|
+
attr_accessor :main_require
|
23
|
+
attr_accessor :platform
|
24
|
+
attr_accessor :version
|
25
|
+
attr_accessor :jared_version
|
26
|
+
|
27
|
+
def initialize
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.version
|
32
|
+
"1.0.0"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
require 'set'
|
2
|
+
require_relative "plugin"
|
3
|
+
# require 'jared/version'
|
4
|
+
class Plugins
|
5
|
+
PLUGINS=Set.new
|
6
|
+
PATH="#{Dir.home}/.jared/plugins"
|
7
|
+
class Load
|
8
|
+
include Logg
|
9
|
+
def initialize(path='')
|
10
|
+
@path=path
|
11
|
+
end
|
12
|
+
|
13
|
+
def load(path)
|
14
|
+
count=0
|
15
|
+
Dir.glob("#{path}/*").select do |file|
|
16
|
+
if File.directory?(file)
|
17
|
+
next
|
18
|
+
elsif file.include?("init.rb")
|
19
|
+
require_relative "#{file}"
|
20
|
+
else
|
21
|
+
next
|
22
|
+
end
|
23
|
+
plugin=Jared::Plugin.configuration
|
24
|
+
log.info "Plugin path: #{file}"
|
25
|
+
begin
|
26
|
+
if plugin.name.nil? or plugin.name == ""
|
27
|
+
raise raise ArgumentError, "Plugin Name for #{file.gsub("#{path}", '')} is not defined or is blank!"
|
28
|
+
elsif plugin.command.nil? or plugin.command == ""
|
29
|
+
raise ArgumentError, "Plugin Command for #{file.gsub("#{path}", '')} is not defined or is blank!"
|
30
|
+
elsif plugin.platform.nil? or plugin.platform == ""
|
31
|
+
raise ArgumentError, "Plugin Platform for #{file.gsub("#{path}", '')} is not defined or is blank!"
|
32
|
+
elsif plugin.main_require.nil? or plugin.main_require == ""
|
33
|
+
raise ArgumentError, "Plugin Main_Require for #{file.gsub("#{path}", '')} is not defined or is blank!"
|
34
|
+
end
|
35
|
+
rescue => e
|
36
|
+
log.error e
|
37
|
+
next
|
38
|
+
end
|
39
|
+
count+=1
|
40
|
+
data={
|
41
|
+
dir: file.sub("init.rb",''),
|
42
|
+
name: plugin.name,
|
43
|
+
description: plugin.description,
|
44
|
+
author: plugin.author,
|
45
|
+
author_email: plugin.author_email,
|
46
|
+
homepage: plugin.homepage,
|
47
|
+
sourcecode: plugin.sourcecode,
|
48
|
+
command: plugin.command,
|
49
|
+
arguments: plugin.arguments,
|
50
|
+
usage: plugin.usage,
|
51
|
+
main_require: plugin.main_require,
|
52
|
+
jared_version: plugin.jared_version
|
53
|
+
}
|
54
|
+
if plugin.jared_version == Jared::VERSION && plugin.platform == :ruby
|
55
|
+
a=PLUGINS.add?(data)
|
56
|
+
if a
|
57
|
+
log.info "Loaded: #{plugin.name}"
|
58
|
+
end
|
59
|
+
elsif RUBY_PLATFORM.include?(plugin.platform.to_s)
|
60
|
+
a=PLUGINS.add?(data)
|
61
|
+
if a
|
62
|
+
log.info "Loaded: #{plugin.name}"
|
63
|
+
end
|
64
|
+
else
|
65
|
+
log.warn "Could not load plugin: #{plugin.name}. Reason: Version mismatch."
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def load_core
|
71
|
+
spec=Gem::Specification.find_by_name("jared")
|
72
|
+
load("#{spec.gem_dir}/lib/jared/core/*")
|
73
|
+
end
|
74
|
+
|
75
|
+
def load_all
|
76
|
+
load_core
|
77
|
+
load(PATH)
|
78
|
+
return PLUGINS
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
# This class contains code for installing plugins.
|
83
|
+
class Get
|
84
|
+
include Logg
|
85
|
+
def initialize
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
class List
|
90
|
+
include Logg
|
91
|
+
end
|
92
|
+
end
|
data/lib/jared/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
module Jared
|
2
|
-
VERSION = "0.0.
|
3
|
-
end
|
2
|
+
VERSION = "0.0.7a4"
|
3
|
+
end
|