overlord 0.1.0 → 0.1.1
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/README.rdoc +108 -1
- data/VERSION +1 -1
- data/app/helpers/overlord_google_helper.rb +28 -18
- data/app/views/google/_feed.html.erb +1 -1
- data/overlord.gemspec +641 -0
- data/test/rails_root/app/controllers/default_controller.rb +14 -4
- data/test/rails_root/app/helpers/application_helper.rb +5 -0
- data/test/rails_root/app/models/entry.rb +5 -0
- data/test/rails_root/app/models/feed.rb +4 -0
- data/test/rails_root/app/models/service.rb +61 -0
- data/test/rails_root/app/models/service_category.rb +12 -0
- data/test/rails_root/app/views/default/google_combined_feeds.html.erb +1 -0
- data/test/rails_root/app/views/default/google_dynamic_feeds_vertical.html.erb +2 -0
- data/test/rails_root/app/views/default/google_feed_search.html.erb +2 -0
- data/test/rails_root/app/views/default/google_feeds.html.erb +1 -0
- data/test/rails_root/app/views/default/google_search.html.erb +1 -0
- data/test/rails_root/app/views/default/google_slide_show.html.erb +2 -0
- data/test/rails_root/db/migrate/20091031185622_create_feeds.rb +15 -0
- data/test/rails_root/db/migrate/20091031185627_create_services.rb +14 -0
- data/test/rails_root/db/migrate/20091031185634_create_entries.rb +18 -0
- data/test/rails_root/db/migrate/20091031215610_create_service_categories.rb +12 -0
- data/test/rails_root/test/factories.rb +31 -0
- data/test/rails_root/test/functional/default_controller_test.rb +4 -9
- data/test/rails_root/test/test_helper.rb +3 -0
- data/test/rails_root/test/unit/google_feed_request_test.rb +4 -1
- metadata +25 -3
- data/test/test_helper.rb +0 -10
@@ -1,14 +1,13 @@
|
|
1
1
|
class DefaultController < ApplicationController
|
2
|
-
|
2
|
+
|
3
|
+
before_filter :setup
|
4
|
+
|
3
5
|
def index
|
4
6
|
end
|
5
7
|
|
6
8
|
def google_search
|
7
9
|
end
|
8
10
|
|
9
|
-
def google_typed_search
|
10
|
-
end
|
11
|
-
|
12
11
|
def google_feeds
|
13
12
|
end
|
14
13
|
|
@@ -22,6 +21,17 @@ class DefaultController < ApplicationController
|
|
22
21
|
end
|
23
22
|
|
24
23
|
def google_slide_show
|
24
|
+
@feed = Feed.new(:uri => 'feed://api.flickr.com/services/feeds/photos_public.gne?tags=autumn&lang=en-us&format=rss_200')
|
25
|
+
end
|
26
|
+
|
27
|
+
def setup
|
28
|
+
@terms = CGI.unescape('mountain biking')
|
29
|
+
|
30
|
+
@number_of_items = 6
|
31
|
+
@number_of_images = 12
|
32
|
+
@number_of_videos = 6
|
33
|
+
@show_controls = false
|
34
|
+
@feeds = Feed.all
|
25
35
|
end
|
26
36
|
|
27
37
|
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
class Service < ActiveRecord::Base
|
2
|
+
|
3
|
+
belongs_to :service_category
|
4
|
+
|
5
|
+
def photo?
|
6
|
+
false
|
7
|
+
end
|
8
|
+
|
9
|
+
def video?
|
10
|
+
false
|
11
|
+
end
|
12
|
+
|
13
|
+
def bookmark?
|
14
|
+
false
|
15
|
+
end
|
16
|
+
|
17
|
+
def music?
|
18
|
+
false
|
19
|
+
end
|
20
|
+
|
21
|
+
def news?
|
22
|
+
false
|
23
|
+
end
|
24
|
+
|
25
|
+
def blog?
|
26
|
+
false
|
27
|
+
end
|
28
|
+
|
29
|
+
def search?
|
30
|
+
false
|
31
|
+
end
|
32
|
+
|
33
|
+
def general?
|
34
|
+
true
|
35
|
+
end
|
36
|
+
|
37
|
+
# Selects and caches all services from the database.
|
38
|
+
#
|
39
|
+
# refresh_services: By default all tag services are cached. Setting this value to true
|
40
|
+
# will result in the values being repopulated from the database
|
41
|
+
def self.get_services(refresh_services = false)
|
42
|
+
@all_services = nil if refresh_services
|
43
|
+
@all_services ||= Service.all
|
44
|
+
end
|
45
|
+
|
46
|
+
# Attempts to find a service object using a uri
|
47
|
+
#
|
48
|
+
# uri: Uri to search for. This method will attempt to all services for any part of the provided uri.
|
49
|
+
# refresh_services: Forces a refresh of the services. By default the services are cached for the duration of the request.
|
50
|
+
def self.find_service_by_uri(uri, refresh_services = false)
|
51
|
+
service = get_services(refresh_services).detect { |service| service.uri && service.uri.length > 0 && (uri.include?(service.uri) || service.uri.include?(uri)) }
|
52
|
+
service ||= default_service
|
53
|
+
service
|
54
|
+
end
|
55
|
+
|
56
|
+
# Default service is RSS
|
57
|
+
def self.default_service
|
58
|
+
Service.find_by_name('rss') # this will return the default rss service
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# == Schema Information
|
2
|
+
#
|
3
|
+
# Table name: service_categories
|
4
|
+
#
|
5
|
+
# id :integer(4) not null, primary key
|
6
|
+
# name :string(255) not null
|
7
|
+
# sort :integer(4) default(0)
|
8
|
+
#
|
9
|
+
|
10
|
+
class ServiceCategory < ActiveRecord::Base
|
11
|
+
has_many :services, :order => 'sort ASC'
|
12
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= google_combined_feeds(@feeds) %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= google_feeds(@feeds, @show_controls, @number_of_items, @number_of_images, @number_of_videos, false, true) %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= google_search('Google Search', [], @terms, %w{web video blog news image local book patent}, 'google_search', I18n.locale) %>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class CreateFeeds < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table "feeds", :force => true do |t|
|
4
|
+
t.string "uri", :limit => 2083
|
5
|
+
t.string "display_uri", :limit => 2083
|
6
|
+
t.string "title", :limit => 1000
|
7
|
+
t.integer "service_id", :default => 0
|
8
|
+
t.string "login"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.down
|
13
|
+
drop_table "feeds"
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class CreateServices < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table "services", :force => true do |t|
|
4
|
+
t.string "uri", :limit => 2083, :default => ""
|
5
|
+
t.string "name", :limit => 1000, :default => ""
|
6
|
+
t.string "api_uri", :limit => 2083, :default => ""
|
7
|
+
t.string "uri_key"
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.down
|
12
|
+
drop_table "services"
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class CreateEntries < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table "entries", :force => true do |t|
|
4
|
+
t.integer "feed_id", :null => false
|
5
|
+
t.string "permalink", :limit => 2083, :default => "", :null => false
|
6
|
+
t.string "author", :limit => 2083
|
7
|
+
t.text "title", :null => false
|
8
|
+
t.text "description"
|
9
|
+
t.text "content"
|
10
|
+
t.datetime "published_at", :null => false
|
11
|
+
t.string "direct_link", :limit => 2083
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.down
|
16
|
+
drop_table "entries"
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class CreateServiceCategories < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table "service_categories", :force => true do |t|
|
4
|
+
t.string "name", :null => false
|
5
|
+
t.integer "sort", :default => 0
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.down
|
10
|
+
drop_table "service_categories"
|
11
|
+
end
|
12
|
+
end
|
@@ -29,3 +29,34 @@ end
|
|
29
29
|
Factory.sequence :title do |n|
|
30
30
|
"This is the title: #{n}"
|
31
31
|
end
|
32
|
+
|
33
|
+
Factory.define :feed do |f|
|
34
|
+
f.uri { Factory.next(:uri) }
|
35
|
+
f.display_uri { Factory.next(:uri) }
|
36
|
+
f.title { Factory.next(:title) }
|
37
|
+
f.service { |a| a.association(:service) }
|
38
|
+
end
|
39
|
+
|
40
|
+
Factory.define :entry do |f|
|
41
|
+
f.feed { |a| a.association(:feed) }
|
42
|
+
f.permalink { Factory.next(:uri) }
|
43
|
+
f.author { Factory.next(:name) }
|
44
|
+
f.title { Factory.next(:title) }
|
45
|
+
f.description { Factory.next(:description) }
|
46
|
+
f.content { Factory.next(:description) }
|
47
|
+
f.unique_content { Factory.next(:description) }
|
48
|
+
f.published_at DateTime.now
|
49
|
+
f.language { |a| a.association(:language) }
|
50
|
+
f.direct_link { Factory.next(:uri) }
|
51
|
+
f.grain_size 'unknown'
|
52
|
+
end
|
53
|
+
|
54
|
+
Factory.define :service do |f|
|
55
|
+
f.uri { Factory.next(:uri) }
|
56
|
+
f.name { Factory.next(:name) }
|
57
|
+
f.service_category { |a| a.association(:service_category) }
|
58
|
+
end
|
59
|
+
|
60
|
+
Factory.define :service_category do |f|
|
61
|
+
f.name { Factory.next(:name) }
|
62
|
+
end
|
@@ -6,6 +6,10 @@ class DefaultControllerTest < ActionController::TestCase
|
|
6
6
|
|
7
7
|
context "topics controller" do
|
8
8
|
|
9
|
+
setup do
|
10
|
+
@feed = Factory(:feed, :uri => TEST_RSS_URI, :display_uri => TEST_URI)
|
11
|
+
end
|
12
|
+
|
9
13
|
context "GET google_search" do
|
10
14
|
setup do
|
11
15
|
get :google_search
|
@@ -15,15 +19,6 @@ class DefaultControllerTest < ActionController::TestCase
|
|
15
19
|
should_render_template :google_search
|
16
20
|
end
|
17
21
|
|
18
|
-
context "GET google_typed_search" do
|
19
|
-
setup do
|
20
|
-
get :google_typed_search
|
21
|
-
end
|
22
|
-
should_not_set_the_flash
|
23
|
-
should_respond_with :success
|
24
|
-
should_render_template :google_typed_search
|
25
|
-
end
|
26
|
-
|
27
22
|
context "GET google_feeds" do
|
28
23
|
setup do
|
29
24
|
get :google_feeds
|
@@ -16,6 +16,9 @@ class ActiveSupport::TestCase
|
|
16
16
|
self.use_transactional_fixtures = true
|
17
17
|
self.use_instantiated_fixtures = true
|
18
18
|
|
19
|
+
TEST_URI = 'http://www.engadget.com'
|
20
|
+
TEST_RSS_URI = 'http://www.engadget.com/rss.xml'
|
21
|
+
|
19
22
|
def ensure_flash(val)
|
20
23
|
assert_contains flash.values, val, ", Flash: #{flash.inspect}"
|
21
24
|
end
|
@@ -3,7 +3,10 @@ require 'test_helper'
|
|
3
3
|
class GoogleFeedRequestTest < ActiveSupport::TestCase
|
4
4
|
|
5
5
|
context "google feed requests" do
|
6
|
-
|
6
|
+
setup do
|
7
|
+
@service = Factory(:service, :name => 'rss')
|
8
|
+
end
|
9
|
+
|
7
10
|
context "find feeds" do
|
8
11
|
setup do
|
9
12
|
@feeds = Overlord::GoogleFeedRequest.find_feeds('ruby')
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: overlord
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Ball
|
@@ -49,6 +49,7 @@ files:
|
|
49
49
|
- app/views/google/_slide_show.html.erb
|
50
50
|
- lib/overlord.rb
|
51
51
|
- lib/overlord/google_feed_request.rb
|
52
|
+
- overlord.gemspec
|
52
53
|
- rails/init.rb
|
53
54
|
- test/rails_root/.gitignore
|
54
55
|
- test/rails_root/.rake_tasks
|
@@ -57,6 +58,16 @@ files:
|
|
57
58
|
- test/rails_root/app/controllers/default_controller.rb
|
58
59
|
- test/rails_root/app/helpers/application_helper.rb
|
59
60
|
- test/rails_root/app/models/.keep
|
61
|
+
- test/rails_root/app/models/entry.rb
|
62
|
+
- test/rails_root/app/models/feed.rb
|
63
|
+
- test/rails_root/app/models/service.rb
|
64
|
+
- test/rails_root/app/models/service_category.rb
|
65
|
+
- test/rails_root/app/views/default/google_combined_feeds.html.erb
|
66
|
+
- test/rails_root/app/views/default/google_dynamic_feeds_vertical.html.erb
|
67
|
+
- test/rails_root/app/views/default/google_feed_search.html.erb
|
68
|
+
- test/rails_root/app/views/default/google_feeds.html.erb
|
69
|
+
- test/rails_root/app/views/default/google_search.html.erb
|
70
|
+
- test/rails_root/app/views/default/google_slide_show.html.erb
|
60
71
|
- test/rails_root/app/views/default/index.html.erb
|
61
72
|
- test/rails_root/app/views/layouts/default.html.erb
|
62
73
|
- test/rails_root/config/amazon_s3.yml
|
@@ -74,6 +85,11 @@ files:
|
|
74
85
|
- test/rails_root/config/initializers/session_store.rb
|
75
86
|
- test/rails_root/config/routes.rb
|
76
87
|
- test/rails_root/db/.keep
|
88
|
+
- test/rails_root/db/migrate/20091031181115_create_sessions.rb
|
89
|
+
- test/rails_root/db/migrate/20091031185622_create_feeds.rb
|
90
|
+
- test/rails_root/db/migrate/20091031185627_create_services.rb
|
91
|
+
- test/rails_root/db/migrate/20091031185634_create_entries.rb
|
92
|
+
- test/rails_root/db/migrate/20091031215610_create_service_categories.rb
|
77
93
|
- test/rails_root/features/feeds.feature
|
78
94
|
- test/rails_root/features/step_definitions/common_steps.rb
|
79
95
|
- test/rails_root/features/step_definitions/visit_steps.rb
|
@@ -577,7 +593,6 @@ files:
|
|
577
593
|
- test/rails_root/test/test_helper.rb
|
578
594
|
- test/rails_root/test/unit/.keep
|
579
595
|
- test/rails_root/test/unit/google_feed_request_test.rb
|
580
|
-
- test/test_helper.rb
|
581
596
|
has_rdoc: true
|
582
597
|
homepage: http://github.com/jbasdf/overlord
|
583
598
|
licenses: []
|
@@ -610,6 +625,10 @@ test_files:
|
|
610
625
|
- test/rails_root/app/controllers/application_controller.rb
|
611
626
|
- test/rails_root/app/controllers/default_controller.rb
|
612
627
|
- test/rails_root/app/helpers/application_helper.rb
|
628
|
+
- test/rails_root/app/models/entry.rb
|
629
|
+
- test/rails_root/app/models/feed.rb
|
630
|
+
- test/rails_root/app/models/service.rb
|
631
|
+
- test/rails_root/app/models/service_category.rb
|
613
632
|
- test/rails_root/config/boot.rb
|
614
633
|
- test/rails_root/config/environment.rb
|
615
634
|
- test/rails_root/config/environments/cucumber.rb
|
@@ -622,6 +641,10 @@ test_files:
|
|
622
641
|
- test/rails_root/config/initializers/session_store.rb
|
623
642
|
- test/rails_root/config/routes.rb
|
624
643
|
- test/rails_root/db/migrate/20091031181115_create_sessions.rb
|
644
|
+
- test/rails_root/db/migrate/20091031185622_create_feeds.rb
|
645
|
+
- test/rails_root/db/migrate/20091031185627_create_services.rb
|
646
|
+
- test/rails_root/db/migrate/20091031185634_create_entries.rb
|
647
|
+
- test/rails_root/db/migrate/20091031215610_create_service_categories.rb
|
625
648
|
- test/rails_root/features/step_definitions/common_steps.rb
|
626
649
|
- test/rails_root/features/step_definitions/visit_steps.rb
|
627
650
|
- test/rails_root/features/step_definitions/webrat_steps.rb
|
@@ -638,4 +661,3 @@ test_files:
|
|
638
661
|
- test/rails_root/test/shoulda_macros/plugins.rb
|
639
662
|
- test/rails_root/test/test_helper.rb
|
640
663
|
- test/rails_root/test/unit/google_feed_request_test.rb
|
641
|
-
- test/test_helper.rb
|
data/test/test_helper.rb
DELETED