Module: Omnom
- Defined in:
- lib/omnom.rb,
lib/omnom/feed.rb,
lib/omnom/utils.rb,
lib/omnom/engine.rb,
lib/omnom/source.rb,
lib/omnom/railtie.rb,
lib/omnom/version.rb,
lib/omnom/reporting.rb,
lib/omnom/scheduler.rb,
app/models/omnom/post.rb,
lib/omnom/source/atom.rb,
lib/omnom/source/base.rb,
lib/omnom/source/feed.rb,
lib/omnom/parser_methods.rb,
lib/omnom/source_parsers.rb,
lib/omnom/feed_sources_dsl.rb,
lib/omnom/source/github/blog.rb,
app/models/omnom/posts_origin.rb,
lib/omnom/source/xkcd/default.rb,
app/helpers/omnom/posts_helper.rb,
lib/omnom/source/reddit/images.rb,
lib/omnom/source/github/default.rb,
lib/omnom/source/reddit/default.rb,
lib/omnom/source/twitter/search.rb,
lib/omnom/source/facebook/default.rb,
lib/omnom/source/slashdot/default.rb,
lib/omnom/source/instagram/default.rb,
lib/omnom/source/techcrunch/default.rb,
lib/omnom/source/techcrunch/section.rb,
lib/omnom/source_parsers/feedburner.rb,
lib/omnom/source/github/blog_section.rb,
lib/omnom/source/hacker_news/default.rb,
lib/omnom/source/the_next_web/default.rb,
app/controllers/omnom/feeds_controller.rb,
app/controllers/omnom/posts_controller.rb,
lib/omnom/source/stackoverflow/default.rb,
lib/omnom/source/google_analytics/default.rb,
lib/omnom/source/google_analytics/visitors.rb,
lib/omnom/source/google_analytics/pageviews.rb,
app/controllers/omnom/application_controller.rb,
lib/generators/omnom/install/install_generator.rb
Defined Under Namespace
Modules: Generators, ParserMethods, PostsHelper, Source, SourceParsers, Utils
Classes: ApplicationController, Engine, Feed, FeedSourcesDSL, FeedsController, Post, PostsController, PostsOrigin, Railtie, Reporting, Scheduler
Constant Summary
collapse
- VERSION =
'0.0.2'
Class Method Summary
collapse
Class Method Details
.active_sources ⇒ Object
40
41
42
|
# File 'lib/omnom.rb', line 40
def self.active_sources
feeds.values.collect { |feed| feed.sources }.flatten.compact
end
|
.add_feed(feed) ⇒ Object
24
25
26
|
# File 'lib/omnom.rb', line 24
def self.add_feed(feed)
feeds[feed.key] = feed
end
|
.add_source(source) ⇒ Object
28
29
30
|
# File 'lib/omnom.rb', line 28
def self.add_source(source)
sources[source.key] = source
end
|
.config ⇒ Object
44
45
46
47
48
49
50
51
|
# File 'lib/omnom.rb', line 44
def self.config
begin
return Rails.configuration.omnom
rescue NoMethodError
Reporting.warn_once 'Omnom.config', 'Please make sure that omnom.yml has been installed and has configuration for Omnom'
end
nil
end
|
94
95
96
97
98
|
# File 'lib/omnom.rb', line 94
def self.configure
sources.each do |key, source|
source.configure
end
end
|
.directory ⇒ Object
57
58
59
|
# File 'lib/omnom.rb', line 57
def self.directory
Pathname.new(File.dirname(File.absolute_path(__FILE__)))
end
|
.feeds ⇒ Object
32
33
34
|
# File 'lib/omnom.rb', line 32
def self.feeds
@feeds ||= {}
end
|
.instantiate_feeds ⇒ Object
88
89
90
91
92
|
# File 'lib/omnom.rb', line 88
def self.instantiate_feeds
feeds.each do |key, feed_class|
feeds[key] = feed_class.new
end
end
|
.is_database_ready? ⇒ Boolean
78
79
80
81
82
|
# File 'lib/omnom.rb', line 78
def self.is_database_ready?
is_ready = Omnom::Post.table_exists? && Omnom::PostsOrigin.table_exists?
Reporting.warn_once 'Omnom.is_database_ready?', 'Database migrations for Omnom have not been run' unless is_ready
is_ready
end
|
.is_server_being_run? ⇒ Boolean
74
75
76
|
# File 'lib/omnom.rb', line 74
def self.is_server_being_run?
defined?(Rails) && Rails.const_defined?('Server')
end
|
.load ⇒ Object
61
62
63
64
65
66
67
68
69
70
71
72
|
# File 'lib/omnom.rb', line 61
def self.load
require_glob(directory.join('omnom', 'source_parsers', '**', '*.rb'))
require_glob(directory.join('omnom', 'source', 'base.rb'))
require_glob(directory.join('omnom', 'source', 'atom.rb'))
require_glob(directory.join('omnom', 'source', '**', '*.rb'))
require_glob(Rails.root.join('lib', 'omnom', 'source', '**', '*.rb'))
require_glob(Rails.root.join('app', 'feeds', '**', '*.rb'))
configure
instantiate_feeds
start_scheduler if config.present? && config.run_scheduler_on_web_server && is_server_being_run? && is_database_ready?
end
|
.require_glob(path) ⇒ Object
100
101
102
|
# File 'lib/omnom.rb', line 100
def self.require_glob(path)
Dir.glob(path) { |file| require file }
end
|
.sources ⇒ Object
36
37
38
|
# File 'lib/omnom.rb', line 36
def self.sources
@sources ||= {}
end
|
.start_scheduler ⇒ Object
.table_name_prefix ⇒ Object
53
54
55
|
# File 'lib/omnom.rb', line 53
def self.table_name_prefix
'omnom_'
end
|