Sha256: 98702beb454f77f4ecb4e7bc96481deb9cc305c1e39b74fe510c9acfa59dc216

Contents?: true

Size: 557 Bytes

Versions: 2

Compression:

Stored size: 557 Bytes

Contents

CommitMsgUrlShortener::Service.define do |commit_message|
  def call_googl_api long_url
    error_safe_request do
      uri = URI 'https://www.googleapis.com/urlshortener/v1/url'
      http = Net::HTTP.new uri.host, 443
      http.use_ssl = true
      http.read_timeout = 3
      http.verify_mode = OpenSSL::SSL::VERIFY_NONE
      resp = http.post uri.path, "{'longUrl': '#{long_url}'}", {"content-type" => "application/json"}
      json = JSON.parse resp.body
      json['id']
    end
  end
  
  each_long_url(commit_message) {|url| call_googl_api url}
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
commit-msg-url-shortener-0.0.2 lib/commit-msg-url-shortener/services/goo.gl.rb
commit-msg-url-shortener-0.0.1 lib/commit-msg-url-shortener/services/goo.gl.rb