<commit_before>require 'naver_map/version'
require 'rest-client'
require 'json'

class NaverMap
  attr_accessor :client_id, :client_secret

  def initialize(client_id, client_secret)
    @client_id = client_id
    @client_secret = client_secret
  end

  def address_to_coordinates(address)
    begin
      url = 'https://openapi.naver.com/v1/map/geocode'
      response = RestClient.get(url, params: { query: address }, 'X-Naver-Client-Id': @client_id,
                                'X-Naver-Client-Secret': @client_secret)
      result = JSON.parse(response.body, symbolize_names: true)[:result]
      result[:items].map do |element| element[:point] end
    rescue RestClient::ExceptionWithResponse => err
      err.response.body
    end
  end


  def query(address)
    begin
      url = 'https://openapi.naver.com/v1/map/geocode'
      response = RestClient.get(url, params: { query: address }, 'X-Naver-Client-Id': @client_id,
                                'X-Naver-Client-Secret': @client_secret)
      JSON.parse(response.body, symbolize_names: true)[:result]
    rescue RestClient::ExceptionWithResponse => err
      err.response.body
    end
  end

  def to_s
    "Client ID: #{@client_id}, Client Secret: #{@client_secret}"
  end
end<commit_msg>Refactoring rescue clauses in method<commit_after>require 'naver_map/version'
require 'rest-client'
require 'json'

class NaverMap
  attr_accessor :client_id, :client_secret

  def initialize(client_id, client_secret)
    @client_id = client_id
    @client_secret = client_secret
  end

  def address_to_coordinates(address)
    url = 'https://openapi.naver.com/v1/map/geocode'
    response = RestClient.get(url, params: { query: address }, 'X-Naver-Client-Id': @client_id,
                              'X-Naver-Client-Secret': @client_secret)
    result = JSON.parse(response.body, symbolize_names: true)[:result]
    result[:items].map do |element| element[:point] end
  rescue RestClient::ExceptionWithResponse => err
    err.response.body
  end


  def query(address)
    url = 'https://openapi.naver.com/v1/map/geocode'
    response = RestClient.get(url, params: { query: address }, 'X-Naver-Client-Id': @client_id,
                              'X-Naver-Client-Secret': @client_secret)
    JSON.parse(response.body, symbolize_names: true)[:result]
  rescue RestClient::ExceptionWithResponse => err
    err.response.body
  end

  def to_s
    "Client ID: #{@client_id}, Client Secret: #{@client_secret}"
  end
end

{'fraction_non_alphanumeric': 0.12106537530266344, 'fraction_numerical': 0.0016142050040355124, 'mean_word_length': 3.274137931034483, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1019034', 'n_tokens_mistral': 807, 'n_tokens_neox': 797, 'n_words': 161}