Class: NewsCrawler::CrawlerConfig
- Inherits:
-
Object
- Object
- NewsCrawler::CrawlerConfig
- Defined in:
- lib/news_crawler/config.rb
Constant Summary collapse
- DEFAULT_CONFIG =
File.join(File.dirname(__FILE__), './default_config.yml')
- DEFAULT_SDS_CONFIG =
File.join(File.dirname(__FILE__), './default_sds.yml')
Class Method Summary collapse
- .load_application_config(file = CrawlerConfig::DEFAULT_CONFIG) ⇒ Object
- .load_samedomainselector_config(file = CrawlerConfig::DEFAULT_SDS_CONFIG) ⇒ Object
- .merge_config(mod, file) ⇒ Object
Class Method Details
.load_application_config(file = CrawlerConfig::DEFAULT_CONFIG) ⇒ Object
33 34 35 36 37 38 |
# File 'lib/news_crawler/config.rb', line 33 def self.load_application_config(file = CrawlerConfig::DEFAULT_CONFIG) if ((file != DEFAULT_CONFIG) || (@app_loaded != true)) @app_loaded = true merge_config(:application, file) end end |
.load_samedomainselector_config(file = CrawlerConfig::DEFAULT_SDS_CONFIG) ⇒ Object
40 41 42 43 44 45 |
# File 'lib/news_crawler/config.rb', line 40 def self.load_samedomainselector_config(file = CrawlerConfig::DEFAULT_SDS_CONFIG) if ((file != DEFAULT_SDS_CONFIG) || (@sds_loaded != true)) @sds_loaded = true merge_config(:same_domain_selector, file) end end |
.merge_config(mod, file) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/news_crawler/config.rb', line 47 def self.merge_config(mod, file) conf = YAML.load_file(file) conf.each do | key, val | if val.is_a? Hash val.each do | k1, v1 | SimpleConfig.for mod do group key do set k1, v1 end end end else SimpleConfig.for mod do set key, val end end end end |