Class: Birdwatcher::Modules::Users::KloutId
- Inherits:
-
Birdwatcher::Module
- Object
- Birdwatcher::Module
- Birdwatcher::Modules::Users::KloutId
- Defined in:
- lib/birdwatcher/modules/users/klout_id.rb
Constant Summary
Constants inherited from Birdwatcher::Module
Birdwatcher::Module::MODULE_PATH
Constants included from Concerns::Concurrency
Concerns::Concurrency::DEFAULT_THREAD_POOL_SIZE
Constants included from Concerns::Core
Concerns::Core::DATA_DIRECTORY
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Birdwatcher::Module
_file_path, _file_path=, descendants, #execute, inherited, meta, meta=, module_by_path, module_paths, modules, path
Methods included from Concerns::Concurrency
Methods included from Concerns::Persistence
included, #save_status, #save_user
Methods included from Concerns::Presentation
included, #make_status_summary_output, #make_url_summary_output, #make_user_details_output, #make_user_summary_output, #output_status_summary, #output_user_details, #output_user_summary, #page_text
Methods included from Concerns::Outputting
#confirm, #error, #fatal, included, #info, #line_separator, #newline, #output, #output_formatted, #task, #warn
Methods included from Concerns::Util
#escape_html, #excerpt, included, #parse_time, #pluralize, #strip_control_characters, #strip_html, #suppress_output, #suppress_warnings, #time_ago_in_words, #unescape_html
Methods included from Concerns::Core
#console, #current_workspace, #current_workspace=, #database, included, #klout_client, #read_data_file, #twitter_client
Class Method Details
.info ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/birdwatcher/modules/users/klout_id.rb', line 18 def self.info <<-INFO The User Klout IDs module can populate the current workspace's users with their Klout ID. Having a Klout ID on users makes it possible to gather information with other modules such as #{'users/klout_influence'.bold}, #{'users/klout_topics'.bold} and #{'users/klout_score'.bold}. #{'Note:'.bold} Birdwatcher must be configured with one or more Klout API keys in order to work. INFO end |
Instance Method Details
#run ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/birdwatcher/modules/users/klout_id.rb', line 30 def run if !klout_client error("Birdwatcher has not been configured with any Klout API keys") return false end users = current_workspace.users_dataset.order(:screen_name) if users.empty? error("There are no users to process") return false end threads = thread_pool(option_setting("THREADS").to_i) users.each do |user| threads.process do begin klout_id = klout_client.get_id(user.screen_name) if klout_id.nil? warn("User #{user.screen_name.bold} doesn't have a Klout ID; skipping") next end user.klout_id = klout_id user.save info("User #{user.screen_name.bold} has a Klout ID: #{klout_id.to_s.bold}") rescue => e error("Processing of #{user.screen_name.bold} failed (#{e.class})") end end end threads.shutdown end |