short_io 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eeae1a268f6b5060f6df86afd2af9156137a49c889fda818774b7e9b285a7c4d
4
- data.tar.gz: 102a515ab66654bb4e211b158a10c6273a1ffbdc6fa5de628a57c9ea19e5374f
3
+ metadata.gz: 66e27baedf7c15353601fd2bc71baff3643f7f585fb25d03c742beccc0bd8f4d
4
+ data.tar.gz: 9eb89a4c0779cdbe553b43889e9768b4f6bbd55605606b28cf2184cbee53a36c
5
5
  SHA512:
6
- metadata.gz: b19f0eb932a6f64fba5f528b4d04380ac103397223cd2618e571baa4c83eec5f982bf74692b6535da7c8092b745f7b55e06e9fc15dd9ef68989d2be2fc1aa324
7
- data.tar.gz: b6e1734c29a6256a262e322658900c6743352b6a0397ea5427de5fba2fa71a0796e9ad1d4e963a3a22e52a3fa5faf4180674c9ed6830f9513e84498d2551bf30
6
+ metadata.gz: 7ef024ad351002d6a489ff210968c81413ef313fbdc804993bb3bfe7825f00083a4c4abef9092543b54f7bbd0de0d4267baa3cb698b307e4cac4f752c14beb32
7
+ data.tar.gz: 7384f591050e9add6c7bcd4b59d8802b304de97763f20a629af5cfc122cea86f6f205c7015a910d05a7180a9ff584bb92e3d5780476c3d3b477ae98c70946aa3
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- short_io (0.1.6)
4
+ short_io (0.1.7)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -8,13 +8,19 @@ module ShortIo
8
8
  REQUEST_TYPE = 'application/json'
9
9
  SHORT_IO_BASE_URL = 'https://api.short.io/domains/'
10
10
 
11
- def initialize(host_name = 'example.com', api_key = 'API_KEY', options={})
12
- @host_name = host_name
13
- @api_key = api_key
14
- @hide_referer = options.key?(:hide_referer) ? options[:hide_referer] : false
15
- @https_link = options.key?(:https_link) ? options[:https_link] : false
16
- @link_type = options.key?(:link_type) ? options[:link_type] : 'random'
17
- @short_io_base_url = 'https://api.short.io/domains/'
11
+ def initialize(host_name, api_key, options={})
12
+ @host_name ||= host_name
13
+ @api_key ||= api_key
14
+ @hide_referer ||= options.key?(:hide_referer) ? options[:hide_referer] : false
15
+ @https_link ||= options.key?(:https_link) ? options[:https_link] : false
16
+ @link_type ||= options.key?(:link_type) ? options[:link_type] : 'random'
17
+ @short_io_base_url ||= SHORT_IO_BASE_URL
18
+ check_variables
19
+ end
20
+
21
+ def check_variables
22
+ raise ShortIo::HostNameError.new(host_name: 'Please provide a host name') if (@host_name.nil? || @host_name.empty?)
23
+ raise ShortIo::ApiKeyError.new(api_key: 'Please provide an API key') if (@api_key.nil? || @api_key.empty?)
18
24
  end
19
25
 
20
26
  def setup
@@ -1,3 +1,3 @@
1
1
  module ShortIo
2
- VERSION = "0.1.6"
2
+ VERSION = "0.1.7"
3
3
  end
data/lib/short_io.rb CHANGED
@@ -3,5 +3,7 @@ require "short_io/short_url"
3
3
 
4
4
  module ShortIo
5
5
  class Error < StandardError; end
6
+ class HostNameError < Error; end
7
+ class ApiKeyError < Error; end
6
8
  # Your code goes here...
7
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: short_io
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yosef Benny Widyokarsono