short_io 0.1.7 → 0.1.8

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: 66e27baedf7c15353601fd2bc71baff3643f7f585fb25d03c742beccc0bd8f4d
4
- data.tar.gz: 9eb89a4c0779cdbe553b43889e9768b4f6bbd55605606b28cf2184cbee53a36c
3
+ metadata.gz: '01299ccaa6348aa2c516c54877e28d7c12ffd318056ba5b862c470ef87f0a7dc'
4
+ data.tar.gz: 619507d110ac39cb4f7930381e30a8c049449249d06bfbc291b77cb1075e5c49
5
5
  SHA512:
6
- metadata.gz: 7ef024ad351002d6a489ff210968c81413ef313fbdc804993bb3bfe7825f00083a4c4abef9092543b54f7bbd0de0d4267baa3cb698b307e4cac4f752c14beb32
7
- data.tar.gz: 7384f591050e9add6c7bcd4b59d8802b304de97763f20a629af5cfc122cea86f6f205c7015a910d05a7180a9ff584bb92e3d5780476c3d3b477ae98c70946aa3
6
+ metadata.gz: b5f397a7d6bee167a5f69da748738f2abd85c052b78adc9cca1f6ace7ce88fd57bf7d77ec32770e5758dffe42d64697986e72b78a5610243fcbe733e960667b6
7
+ data.tar.gz: 98f790b50b2f830052ac8d6a0e7f8c2b78f9e5c9f052e5ed794abbb2eef641de75df76cb83c2cae4e31ccf387ee30c8e6ea00f167e2c5d4f23bb4db43b5f469e
data/.gitignore CHANGED
@@ -6,3 +6,5 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+ .env
10
+ .envrc
data/.travis.yml CHANGED
@@ -1,6 +1,8 @@
1
- ---
2
1
  language: ruby
3
2
  cache: bundler
4
3
  rvm:
5
- - 2.7.1
4
+ - 2.7.1
6
5
  before_install: gem install bundler -v 2.1.4
6
+ env:
7
+ global:
8
+ secure: N+Yyasma8STO5NFjdcmCrn44Zf7x8SbNs6y4bv/FkB5PwcjHYG2sVU/aRB9u8V5F1TuPC7ZPHu74Q9oXgPq2GBnspCNcdvZKzFKLS7euMF+YOeXYSEl7slVvPSq9muuu5lu0cNJbflbTmSElHMXpshamSJxbr9joSvLZMDnJseHXJ+qPKEByB7YQEAFSThbStlgU3oZbRudbM65UBlwxAZ3PZnQ9voYkqPbPkH41SPhtwhLdIOVNR5EK84yypP8rOCCABsxXtfY7vM/ZQpyt/+Ty4cGHDjhiuxypwRFePr2vOqL/w9C2lRNsTRIDrt/krAh0XojIqeObn8d9ZXj+/59OGtAX5YGYKzfMg5Elar24dxUtgKoduD1MLbMBFhB6C8Ch7ULAGvtBDYFYE+0SaMguMr4ZdbxfsNDXIVHYsezLT27ZhSya8/ZOuHcWnveVTl7gktYaY8gdasyNm/uAP99m7/fFgyPYrSaxzLJXAx4EMFxHQtkNTpowETRYE9GFB77NI2QB4cH/5KeOjsvykm8ipmY5Uyfofqm5DV+vHW3zradgzeDogjgoByFlmtCmBpcnAlbmwygxZP303DlVy1pDjizbvITB5beb3HlHzvGbxFjgwvKvnDibjmsrY9NDz5Qzo7hOaJegenUrdgA8wZwV6JOD2Paz6UqKzi1x+2U=
data/CHANGELOG.md CHANGED
@@ -1,3 +1,19 @@
1
+ 0.1.8 (2021-02-03)
2
+ ------------------
3
+
4
+ * add webmock gem
5
+ * add test for add_domain and domain list methods
6
+ * add `:host_name`, `:api_key`, and `:options` attr_reader
7
+ * update version to [0.1.8](https://rubygems.org/gems/short_io/versions/0.1.8)
8
+
9
+ 0.1.7 (2021-01-25)
10
+ ------------------
11
+
12
+ * add test
13
+ * add memoization
14
+ * add check_variables method to raise error when `nil` or `empty` on host name or api_key
15
+ * update version to [0.1.7](https://rubygems.org/gems/short_io/versions/0.1.7)
16
+
1
17
  0.1.6 (2021-01-25)
2
18
  ------------------
3
19
 
data/Gemfile CHANGED
@@ -5,3 +5,9 @@ gemspec
5
5
 
6
6
  gem "rake", "~> 12.0"
7
7
  gem "minitest", "~> 5.0"
8
+
9
+ group :test do
10
+ gem 'simplecov', require: false
11
+ gem 'codecov', require: false
12
+ gem 'webmock'
13
+ end
data/Gemfile.lock CHANGED
@@ -1,21 +1,44 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- short_io (0.1.7)
4
+ short_io (0.1.8)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
+ addressable (2.8.0)
10
+ public_suffix (>= 2.0.2, < 5.0)
11
+ codecov (0.6.0)
12
+ simplecov (>= 0.15, < 0.22)
13
+ crack (0.4.5)
14
+ rexml
15
+ docile (1.4.0)
16
+ hashdiff (1.0.1)
17
+ json (2.6.1)
9
18
  minitest (5.15.0)
19
+ public_suffix (4.0.6)
10
20
  rake (12.3.3)
21
+ rexml (3.2.5)
22
+ simplecov (0.16.1)
23
+ docile (~> 1.1)
24
+ json (>= 1.8, < 3)
25
+ simplecov-html (~> 0.10.0)
26
+ simplecov-html (0.10.2)
27
+ webmock (3.14.0)
28
+ addressable (>= 2.8.0)
29
+ crack (>= 0.3.2)
30
+ hashdiff (>= 0.4.0, < 2.0.0)
11
31
 
12
32
  PLATFORMS
13
33
  ruby
14
34
 
15
35
  DEPENDENCIES
36
+ codecov
16
37
  minitest (~> 5.0)
17
38
  rake (~> 12.0)
18
39
  short_io!
40
+ simplecov
41
+ webmock
19
42
 
20
43
  BUNDLED WITH
21
44
  2.1.4
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
- # ShortIoShortBrandedUrl
1
+ # ShortIo
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/short_io`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ [![Gem Version](https://badge.fury.io/rb/short_io.svg)](https://badge.fury.io/rb/short_io) | [![Build Status](https://app.travis-ci.com/yosefbennywidyo/short_io.svg?branch=main)](https://app.travis-ci.com/yosefbennywidyo/short_io) | [![codecov](https://codecov.io/gh/yosefbennywidyo/short_io/branch/main/graph/badge.svg?token=MBMxFB57mZ)](https://codecov.io/gh/yosefbennywidyo/short_io)
4
+
5
+ A Ruby gem to use with [short.io](https://short.io)
4
6
 
5
7
  [Short IO documentation](https://developers.short.io/docs/deleting-a-domain)
6
8
 
@@ -7,17 +7,26 @@ module ShortIo
7
7
  class ShortUrl
8
8
  REQUEST_TYPE = 'application/json'
9
9
  SHORT_IO_BASE_URL = 'https://api.short.io/domains/'
10
+
11
+ attr_reader :host_name, :api_key, :options
10
12
 
11
13
  def initialize(host_name, api_key, options={})
12
14
  @host_name ||= host_name
13
15
  @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
16
  @short_io_base_url ||= SHORT_IO_BASE_URL
17
+ @options ||= options
18
+ options_default_value
18
19
  check_variables
19
20
  end
20
21
 
22
+ def options_default_value
23
+ @options = {
24
+ hide_referer: options.key?(:hide_referer) ? options[:hide_referer] : false,
25
+ https_link: options.key?(:https_link) ? options[:https_link] : false,
26
+ link_type: options.key?(:link_type) ? options[:link_type] : 'random'
27
+ }
28
+ end
29
+
21
30
  def check_variables
22
31
  raise ShortIo::HostNameError.new(host_name: 'Please provide a host name') if (@host_name.nil? || @host_name.empty?)
23
32
  raise ShortIo::ApiKeyError.new(api_key: 'Please provide an API key') if (@api_key.nil? || @api_key.empty?)
@@ -38,15 +47,17 @@ module ShortIo
38
47
  request["content-type"] = REQUEST_TYPE
39
48
  request["authorization"] = @api_key
40
49
  request.body = JSON.generate(
41
- {"hideReferer":"#{@hide_referer}",
42
- "httpsLinks":"#{@https_link}",
43
- "hostname":"#{@host_name}",
44
- "linkType":"#{@link_type}"}
50
+ {
51
+ "hideReferer":"#{@options[:hide_referer]}",
52
+ "httpsLinks":"#{@options[:https_link]}",
53
+ "hostname":"#{@host_name}",
54
+ "linkType":"#{@options[:link_type]}"
55
+ }
45
56
  )
46
57
  response = @http.request(request)
47
58
  return response.read_body
48
59
  end
49
-
60
+
50
61
  def domain_list
51
62
  setup
52
63
  request = Net::HTTP::Get.new(@url)
@@ -1,3 +1,3 @@
1
1
  module ShortIo
2
- VERSION = "0.1.7"
2
+ VERSION = "0.1.8"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: short_io
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yosef Benny Widyokarsono
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-01-25 00:00:00.000000000 Z
11
+ date: 2022-02-02 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: