Class: Tweetlr::Core

Inherits:
Object
  • Object
show all
Includes:
LogAware
Defined in:
lib/tweetlr/core.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from LogAware

log=

Constructor Details

#initialize(args) ⇒ Core

Returns a new instance of Core.



17
18
19
20
21
# File 'lib/tweetlr/core.rb', line 17

def initialize(args)
  initialize_logging(args[:loglevel])
  initialize_attributes(args)
  Tweetlr::LogAware.log.info "Tweetlr #{Tweetlr::VERSION} initialized. Ready to roll."
end

Class Method Details

.crawl(config) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/tweetlr/core.rb', line 23

def self.crawl(config)
  log.debug "#{self}.crawl() using config: #{config.inspect}"
  twitter_config = prepare_twitter_config config
  tumblr_config = prepare_tumblr_config config
  twitter_config[:search_term] = URI::escape(twitter_config[:search_term]) if twitter_config[:search_term]
  log.info "starting tweetlr crawl..."
  response = {}
  response = Tweetlr::Processors::Twitter::lazy_search(twitter_config)
  if response
    process_response response, config
    # store the highest tweet id
    config[:since_id] = response['max_id']
  else
    log.error "twitter search returned no response. hail the failwhale!"
  end
  log.info "finished tweetlr crawl."
  return config
end

.logObject



13
14
15
# File 'lib/tweetlr/core.rb', line 13

def self.log
  Tweetlr::LogAware.log #TODO why doesn't the include make the log method accessible?
end