Module: OpencBot::CompanyFetcherBot

Includes:
OpencBot, Helpers::AlphaSearch, Helpers::IncrementalSearch
Included in:
MyModule
Defined in:
lib/openc_bot/company_fetcher_bot.rb

Constant Summary

Constants included from Helpers::RegisterMethods

Helpers::RegisterMethods::MAX_BUSY_RETRIES

Constants included from OpencBot

VERSION

Instance Method Summary collapse

Methods included from Helpers::AlphaSearch

#alpha_terms, #each_search_term, #fetch_data_via_alpha_search, #get_results_and_extract_data_for, #letters_and_numbers, #numbers_of_chars_in_search, #search_for_entities_for_term

Methods included from Helpers::RegisterMethods

#computed_registry_url, #datum_exists?, #export_data, #fetch_data, #fetch_registry_page, #post_process, #prepare_and_save_data, #registry_url, #registry_url_from_db, #stale_entry_uids, #update_data, #update_datum, #update_stale, #use_alpha_search, #validate_datum

Methods included from Helpers::IncrementalSearch

#entity_uid_prefixes, #entity_uid_suffixes, #fetch_data_via_incremental_search, #highest_entry_uid_result, #highest_entry_uids, #increment_number, #incremental_rewind_count, #incremental_search, #max_failed_count

Methods included from OpencBot

#db_name, #export, extended, #insert_or_update, #root_directory, #save_data, #save_run_report, #spotcheck, #sqlite_magic_connection, #unlock_database, #verbose?

Methods included from Helpers::Text

#normalise_utf8_spaces, #strip_all_spaces

Instance Method Details

#fetch_datum(company_number) ⇒ Object

This is called by #update_datum



13
14
15
16
# File 'lib/openc_bot/company_fetcher_bot.rb', line 13

def fetch_datum(company_number)
  company_page = fetch_registry_page(company_number)
  {:company_page => company_page}
end

#inferred_jurisdiction_codeObject



18
19
20
21
# File 'lib/openc_bot/company_fetcher_bot.rb', line 18

def inferred_jurisdiction_code
  poss_j_code = self.name.sub(/CompaniesFetcher/,'').underscore
  poss_j_code[/^[a-z]{2}$|^[a-z]{2}_[a-z]{2}$/]
end

#primary_key_nameObject



23
24
25
# File 'lib/openc_bot/company_fetcher_bot.rb', line 23

def primary_key_name
  :company_number
end

#save_entity(entity_info) ⇒ Object

This overrides default #save_entity (defined in RegisterMethods) and adds the inferred jurisdiction_code, unless it is overridden in entity_info



29
30
31
32
33
# File 'lib/openc_bot/company_fetcher_bot.rb', line 29

def save_entity(entity_info)
  return if entity_info.blank?
  default_options = {:jurisdiction_code => inferred_jurisdiction_code}
  super(default_options.merge(entity_info))
end

#save_entity!(entity_info) ⇒ Object



35
36
37
38
39
# File 'lib/openc_bot/company_fetcher_bot.rb', line 35

def save_entity!(entity_info)
  return if entity_info.blank?
  default_options = {:jurisdiction_code => inferred_jurisdiction_code}
  super(default_options.merge(entity_info))
end

#schema_nameObject



41
42
43
# File 'lib/openc_bot/company_fetcher_bot.rb', line 41

def schema_name
  super || 'company-schema'
end