jared 0.0.7a2 → 0.0.7a3
Sign up to get free protection for your applications and to get access to all the features.
- data/jared.gemspec +2 -1
- data/lib/jared/helpers/date.rb +1 -1
- data/lib/jared/helpers/jamendo.rb +3 -3
- data/lib/jared/helpers/map.rb +2 -2
- data/lib/jared/helpers/weather.rb +17 -23
- data/lib/jared/jared.rb +3 -2
- data/lib/jared/lib.rb +13 -13
- data/lib/jared/models/music.rb +2 -0
- data/lib/jared/version.rb +2 -2
- data/lib/jared.rb +18 -16
- data/spec/spec_helper.rb +4 -0
- data/spec/template.rb +10 -0
- data/spec/tests/date_spec.rb +9 -0
- data/spec/tests/greeting_spec.rb +10 -0
- data/spec/tests/jamendo_spec.rb +10 -0
- data/spec/tests/mail_spec.rb +10 -0
- data/spec/tests/map_spec.rb +12 -0
- data/spec/tests/player_spec.rb +10 -0
- data/spec/tests/stock_spec.rb +10 -0
- metadata +30 -4
- data/lib/jared/models/info.rb +0 -2
data/jared.gemspec
CHANGED
@@ -27,7 +27,8 @@ Gem::Specification.new do |s|
|
|
27
27
|
s.add_runtime_dependency "activerecord"
|
28
28
|
s.add_runtime_dependency "sqlite3"
|
29
29
|
s.add_runtime_dependency "launchy"
|
30
|
-
s.add_runtime_dependency '
|
30
|
+
s.add_runtime_dependency 'weatherboy'
|
31
|
+
s.add_runtime_dependency 'area'
|
31
32
|
s.add_runtime_dependency 'gmail'
|
32
33
|
s.add_runtime_dependency 'gibberish'
|
33
34
|
s.add_runtime_dependency 'faster_require'
|
data/lib/jared/helpers/date.rb
CHANGED
@@ -23,20 +23,20 @@ class Helpers
|
|
23
23
|
|
24
24
|
def self.jamendo(mode='once')
|
25
25
|
Lib.db
|
26
|
-
@jared =
|
26
|
+
@jared = Music.first
|
27
27
|
@user = User.first
|
28
28
|
require 'gtk2'
|
29
29
|
require 'open-uri'
|
30
30
|
require 'json'
|
31
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=
|
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=25&order=ratingmonth_desc&tag_idstr=#{@user.music}").read
|
33
33
|
@d = JSON.parse(@list)
|
34
34
|
@data = @d[2]
|
35
35
|
|
36
36
|
if mode == 'loop'
|
37
37
|
puts 'Starting loop, use CTRL-Pause(Break) to stop.'
|
38
38
|
loop do
|
39
|
-
v = Random.rand(0..
|
39
|
+
v = Random.rand(0..24)
|
40
40
|
@data = @d[v]
|
41
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
42
|
Helpers.player(v)
|
data/lib/jared/helpers/map.rb
CHANGED
@@ -3,8 +3,8 @@ class Helpers
|
|
3
3
|
#
|
4
4
|
# TODO: make command work it this: <em>jared map Texas, USA</em> instead of using gets.
|
5
5
|
def self.map(place)
|
6
|
-
@m = place
|
6
|
+
@m = place.gsub(" ", "+")
|
7
7
|
puts @m
|
8
|
-
|
8
|
+
Launchy.open("http://maps.google.com/?q=#{@m}")
|
9
9
|
end
|
10
10
|
end
|
@@ -19,8 +19,7 @@ elsif Time.now.strftime("%a") == "Fri"
|
|
19
19
|
elsif Time.now.strftime("%a") == "Sat"
|
20
20
|
$day = "Sun"
|
21
21
|
$dn = "Sunday"
|
22
|
-
end
|
23
|
-
|
22
|
+
end
|
24
23
|
class Helpers
|
25
24
|
Lib.db
|
26
25
|
require_relative "../models/user.rb"
|
@@ -30,39 +29,34 @@ Lib.db
|
|
30
29
|
# Usage: <em>jared weather (10001/today/tomorrow/forecast)</em>
|
31
30
|
def self.weather(option=nil)
|
32
31
|
begin
|
33
|
-
weather =
|
32
|
+
weather = Weatherboy.new(@user.zip)
|
34
33
|
|
35
34
|
if option == nil
|
36
|
-
forecast = weather.
|
37
|
-
puts
|
38
|
-
puts forecast.temp_f + " Degrees Fahrenheit.", forecast.
|
35
|
+
forecast = weather.current
|
36
|
+
puts @user.zip.to_i.to_region
|
37
|
+
puts forecast.temp_f + " Degrees Fahrenheit.", forecast.weather + ".", forecast.wind_mph + " mile per hour winds from the #{forecast.wind_dir}."
|
39
38
|
|
40
39
|
elsif option == "today"
|
41
|
-
weather.
|
42
|
-
if condition.
|
43
|
-
puts
|
44
|
-
puts " #{condition.
|
45
|
-
puts " High: #{condition.high} Degrees Fahrenheit."
|
46
|
-
puts " Low: #{condition.low} Degrees Fahrenheit."
|
40
|
+
weather.forecasts.each do |condition|
|
41
|
+
if condition.title == 'Today'
|
42
|
+
puts "#{condition.title}."
|
43
|
+
puts " #{condition.text}"
|
47
44
|
end
|
48
45
|
end
|
49
46
|
|
50
47
|
elsif option == "tomorrow"
|
51
|
-
weather.
|
52
|
-
if condition.
|
53
|
-
puts
|
54
|
-
puts " #{condition.
|
55
|
-
puts " High: #{condition.high} Degrees Fahrenheit."
|
56
|
-
puts " Low: #{condition.low} Degrees Fahrenheit."
|
48
|
+
weather.forecasts.each do |condition|
|
49
|
+
if condition.title == $dn
|
50
|
+
puts "#{condition.title}."
|
51
|
+
puts " #{condition.text}"
|
57
52
|
end
|
58
53
|
end
|
59
54
|
|
60
55
|
elsif option == "forecast"
|
61
|
-
weather.
|
62
|
-
puts "#{condition.
|
63
|
-
puts " #{condition.
|
64
|
-
puts
|
65
|
-
puts " Low: #{condition.low} Degrees Fahrenheit."
|
56
|
+
weather.forecasts.each do |condition|
|
57
|
+
puts "#{condition.title}."
|
58
|
+
puts " #{condition.text}"
|
59
|
+
puts
|
66
60
|
end
|
67
61
|
else
|
68
62
|
puts "Unable to fetch weather due to argument error."
|
data/lib/jared/jared.rb
CHANGED
@@ -17,7 +17,8 @@ class Jared < Thor
|
|
17
17
|
desc "weather [FORECAST]", "Gets weather information, If no argument then returns current weather information."
|
18
18
|
def weather(option=nil)
|
19
19
|
require_relative 'helpers/weather.rb'
|
20
|
-
require '
|
20
|
+
require 'weatherboy'
|
21
|
+
require 'area'
|
21
22
|
Helpers.weather(option)
|
22
23
|
end
|
23
24
|
|
@@ -66,7 +67,7 @@ class Jared < Thor
|
|
66
67
|
at_exit do
|
67
68
|
require_relative 'lib.rb'
|
68
69
|
Lib.db
|
69
|
-
@jared =
|
70
|
+
@jared = Music.first
|
70
71
|
@jared.update_attributes(:author_url => "", :music_url => "", :album_image => "", :album_url => "", :now_playing => "", :now_playing_author => "", :now_playing_album => "")
|
71
72
|
end
|
72
73
|
Helpers.jamendo(mode)
|
data/lib/jared/lib.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
|
-
# Lib file loads all Helpers and Models.
|
2
|
-
|
3
|
-
class Lib
|
4
|
-
# ActiveRecord DataBase connect
|
5
|
-
def self.db
|
6
|
-
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
# Model files requires
|
11
|
-
require_relative 'models/
|
12
|
-
require_relative 'models/task.rb'
|
13
|
-
require_relative 'models/user.rb'
|
1
|
+
# Lib file loads all Helpers and Models.
|
2
|
+
|
3
|
+
class Lib
|
4
|
+
# ActiveRecord DataBase connect
|
5
|
+
def self.db
|
6
|
+
ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :database => "#{Dir.home}/.jared.sqlite3")
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
# Model files requires
|
11
|
+
require_relative 'models/music.rb'
|
12
|
+
require_relative 'models/task.rb'
|
13
|
+
require_relative 'models/user.rb'
|
data/lib/jared/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
module Jared
|
2
|
-
VERSION = "0.0.
|
3
|
-
end
|
2
|
+
VERSION = "0.0.7a3"
|
3
|
+
end
|
data/lib/jared.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
#!/bin/ruby
|
2
|
-
|
3
|
-
require '
|
4
|
-
require "fileutils"
|
2
|
+
|
3
|
+
require 'faster_require'
|
5
4
|
require 'sqlite3'
|
6
5
|
require 'active_record'
|
7
6
|
|
@@ -10,6 +9,7 @@ puts "Setting up database."
|
|
10
9
|
ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :database => "#{Dir.home}/.jared.sqlite3")
|
11
10
|
ActiveRecord::Migration.verbose = false
|
12
11
|
|
12
|
+
# Create Database table for Tasks
|
13
13
|
ActiveRecord::Schema.define do
|
14
14
|
create_table :tasks do |t|
|
15
15
|
t.column :title, :string
|
@@ -19,20 +19,22 @@ ActiveRecord::Migration.verbose = false
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
+
# Create table table for Ifos
|
22
23
|
ActiveRecord::Schema.define do
|
23
|
-
create_table :
|
24
|
+
create_table :musics do |t|
|
24
25
|
t.column :status, :string
|
25
|
-
t.column :now_playing, :string
|
26
|
-
t.column :now_playing_album, :string
|
27
|
-
t.column :album_image, :string
|
28
|
-
t.column :now_playing_author, :string
|
29
|
-
t.column :author_url, :string
|
30
|
-
t.column :music_url, :string
|
31
|
-
t.column :album_url, :string
|
26
|
+
t.column :now_playing, :string
|
27
|
+
t.column :now_playing_album, :string
|
28
|
+
t.column :album_image, :string
|
29
|
+
t.column :now_playing_author, :string
|
30
|
+
t.column :author_url, :string
|
31
|
+
t.column :music_url, :string
|
32
|
+
t.column :album_url, :string
|
32
33
|
t.timestamps
|
33
34
|
end
|
34
35
|
end
|
35
36
|
|
37
|
+
# Create Database table for User
|
36
38
|
ActiveRecord::Schema.define do
|
37
39
|
create_table :users do |t|
|
38
40
|
t.column :name, :string
|
@@ -47,7 +49,6 @@ ActiveRecord::Migration.verbose = false
|
|
47
49
|
end
|
48
50
|
|
49
51
|
require_relative "jared/lib.rb"
|
50
|
-
#require "jared/lib"
|
51
52
|
Lib.db
|
52
53
|
if User.first.blank?
|
53
54
|
require 'green_shoes'
|
@@ -55,20 +56,21 @@ if User.first.blank?
|
|
55
56
|
new_user.save
|
56
57
|
c=confirm "Setup Jared?"
|
57
58
|
if c == true
|
58
|
-
|
59
|
+
require 'jared/helpers/config'
|
60
|
+
Helpers.config
|
59
61
|
else
|
60
62
|
alert "Run: 'jared config' to setup later."
|
61
63
|
end
|
62
64
|
end
|
63
65
|
|
64
|
-
if
|
66
|
+
if Music.first.blank?
|
65
67
|
require 'green_shoes'
|
66
|
-
jrd =
|
68
|
+
jrd = Music.new(:status => "Ready", :now_playing => "", :now_playing_author => "")
|
67
69
|
jrd.save
|
68
70
|
if jrd
|
69
71
|
puts 'Ready.'
|
70
72
|
else
|
71
|
-
puts 'Failed to create
|
73
|
+
puts 'Failed to create Music!'
|
72
74
|
end
|
73
75
|
end
|
74
76
|
|
data/spec/spec_helper.rb
ADDED
data/spec/template.rb
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
require 'jared/helpers/jamendo.rb'
|
3
|
+
|
4
|
+
describe Helpers do
|
5
|
+
it "#jamendo should play media from Jamendo" do
|
6
|
+
#Helpers.jamendo('once')
|
7
|
+
pending "Don't know how to test Gstreamer."
|
8
|
+
end
|
9
|
+
end
|
10
|
+
puts 'Helpers#jamendo, Not tested.'
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
require 'jared/helpers/map.rb'
|
3
|
+
|
4
|
+
describe Helpers do
|
5
|
+
it "#map should respond open a browser to PLACE" do
|
6
|
+
a=open("http://maps.google.com/?q=google+ca").read
|
7
|
+
if a.include?('google ca')
|
8
|
+
else
|
9
|
+
fail
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
require 'jared/helpers/player.rb'
|
3
|
+
|
4
|
+
describe Helpers do
|
5
|
+
it "#player should open green_shoes powered media player (Windows Only)" do
|
6
|
+
#Helpers.player
|
7
|
+
pending "don't know how to test."
|
8
|
+
end
|
9
|
+
end
|
10
|
+
puts 'Helpers#player, Not tested.'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jared
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7a3
|
5
5
|
prerelease: 5
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-10-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: stock_quote
|
@@ -156,7 +156,23 @@ dependencies:
|
|
156
156
|
- !ruby/object:Gem::Version
|
157
157
|
version: '0'
|
158
158
|
- !ruby/object:Gem::Dependency
|
159
|
-
name:
|
159
|
+
name: weatherboy
|
160
|
+
requirement: !ruby/object:Gem::Requirement
|
161
|
+
none: false
|
162
|
+
requirements:
|
163
|
+
- - ! '>='
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: '0'
|
166
|
+
type: :runtime
|
167
|
+
prerelease: false
|
168
|
+
version_requirements: !ruby/object:Gem::Requirement
|
169
|
+
none: false
|
170
|
+
requirements:
|
171
|
+
- - ! '>='
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
- !ruby/object:Gem::Dependency
|
175
|
+
name: area
|
160
176
|
requirement: !ruby/object:Gem::Requirement
|
161
177
|
none: false
|
162
178
|
requirements:
|
@@ -268,11 +284,20 @@ files:
|
|
268
284
|
- lib/jared/helpers/weather.rb
|
269
285
|
- lib/jared/jared.rb
|
270
286
|
- lib/jared/lib.rb
|
271
|
-
- lib/jared/models/
|
287
|
+
- lib/jared/models/music.rb
|
272
288
|
- lib/jared/models/task.rb
|
273
289
|
- lib/jared/models/user.rb
|
274
290
|
- lib/jared/version.rb
|
275
291
|
- readme.md
|
292
|
+
- spec/spec_helper.rb
|
293
|
+
- spec/template.rb
|
294
|
+
- spec/tests/date_spec.rb
|
295
|
+
- spec/tests/greeting_spec.rb
|
296
|
+
- spec/tests/jamendo_spec.rb
|
297
|
+
- spec/tests/mail_spec.rb
|
298
|
+
- spec/tests/map_spec.rb
|
299
|
+
- spec/tests/player_spec.rb
|
300
|
+
- spec/tests/stock_spec.rb
|
276
301
|
homepage: https://github.com/cyberarm/jared
|
277
302
|
licenses: []
|
278
303
|
post_install_message:
|
@@ -299,3 +324,4 @@ signing_key:
|
|
299
324
|
specification_version: 3
|
300
325
|
summary: Ruby powered digital assistant
|
301
326
|
test_files: []
|
327
|
+
has_rdoc:
|
data/lib/jared/models/info.rb
DELETED