Sha256: a2e4a236e600f6a84f5bdac2845e26a9ebd858a9502ab04eb8542a4c265a4aa9
Contents?: true
Size: 696 Bytes
Versions: 3
Compression:
Stored size: 696 Bytes
Contents
# frozen_string_literal: true require 'dotenv' Dotenv.load('.env.local', '.env') require 'soapy_bing' desc 'Fetch country codes from geo_locations API and update country_codes.yml file' task :update_country_codes do TARGET_TYPES = %w[Country State].freeze campaign_management = SoapyBing::CampaignManagement.new rows = campaign_management.get_geo_locations rows.select! { |row| TARGET_TYPES.include?(row['Target Type']) } rows.map! { |row| row.slice('ID', 'Code') } country_codes = rows.each_with_object({}) do |row, hash| hash[row['ID']] = row['Code'] end File.open(SoapyBing::CountryCodes::YML_FILE_PATH, 'wb') do |file| file.write country_codes.to_yaml end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
soapy_bing-1.0.1 | lib/tasks/update_country_codes.rake |
soapy_bing-1.0.0 | lib/tasks/update_country_codes.rake |
soapy_bing-0.4.0 | lib/tasks/update_country_codes.rake |