short_io 0.1.4 → 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: d3b1df1b6217060cf630fc97329d90088144e7c16d8a811fee42859278145622
4
- data.tar.gz: b0c7b8a778694fe65e9064a1bbc0064a214519f628ca61214f6d9115250d7842
3
+ metadata.gz: '01299ccaa6348aa2c516c54877e28d7c12ffd318056ba5b862c470ef87f0a7dc'
4
+ data.tar.gz: 619507d110ac39cb4f7930381e30a8c049449249d06bfbc291b77cb1075e5c49
5
5
  SHA512:
6
- metadata.gz: 246036801ad71eda0d3214cf2445fbbba6fc555b15114068e642e1aa7c60753014eb9cfd91e2f7f9b371f3ff7903488a4fa33bdcc1b92a1381528164e3d10f68
7
- data.tar.gz: 351cc7b7a6e538b0c325b215c47e674103e928cf3fa990b3dd191081fb1ceb210992ea76bc242dda49930c6c0c0016b91b566f8dc05638db9d9a7e66fd58cb8c
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,31 @@
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
+
17
+ 0.1.6 (2021-01-25)
18
+ ------------------
19
+
20
+ * fix version on CHANGELOG.md
21
+ * update version to [0.1.6](https://rubygems.org/gems/short_io/versions/0.1.6)
22
+
23
+ 0.1.5 (2021-01-25)
24
+ ------------------
25
+
26
+ * fix CHANGELOG.md path
27
+ * update version to [0.1.5](https://rubygems.org/gems/short_io/versions/0.1.5)
28
+
1
29
  0.1.4 (2021-01-25)
2
30
  ------------------
3
31
 
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.4)
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,14 +7,29 @@ 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
- 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/'
13
+ def initialize(host_name, api_key, options={})
14
+ @host_name ||= host_name
15
+ @api_key ||= api_key
16
+ @short_io_base_url ||= SHORT_IO_BASE_URL
17
+ @options ||= options
18
+ options_default_value
19
+ check_variables
20
+ end
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
+
30
+ def check_variables
31
+ raise ShortIo::HostNameError.new(host_name: 'Please provide a host name') if (@host_name.nil? || @host_name.empty?)
32
+ raise ShortIo::ApiKeyError.new(api_key: 'Please provide an API key') if (@api_key.nil? || @api_key.empty?)
18
33
  end
19
34
 
20
35
  def setup
@@ -32,15 +47,17 @@ module ShortIo
32
47
  request["content-type"] = REQUEST_TYPE
33
48
  request["authorization"] = @api_key
34
49
  request.body = JSON.generate(
35
- {"hideReferer":"#{@hide_referer}",
36
- "httpsLinks":"#{@https_link}",
37
- "hostname":"#{@host_name}",
38
- "linkType":"#{@link_type}"}
50
+ {
51
+ "hideReferer":"#{@options[:hide_referer]}",
52
+ "httpsLinks":"#{@options[:https_link]}",
53
+ "hostname":"#{@host_name}",
54
+ "linkType":"#{@options[:link_type]}"
55
+ }
39
56
  )
40
57
  response = @http.request(request)
41
58
  return response.read_body
42
59
  end
43
-
60
+
44
61
  def domain_list
45
62
  setup
46
63
  request = Net::HTTP::Get.new(@url)
@@ -1,3 +1,3 @@
1
1
  module ShortIo
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.8"
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
data/short_io.gemspec CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
16
16
 
17
17
  spec.metadata["homepage_uri"] = spec.homepage
18
18
  spec.metadata["source_code_uri"] = "https://github.com/yosefbennywidyo/short_io"
19
- spec.metadata["changelog_uri"] = "https://github.com/yosefbennywidyo/short_io/CHANGELOG.md"
19
+ spec.metadata["changelog_uri"] = "https://github.com/yosefbennywidyo/short_io/blob/main/CHANGELOG.md"
20
20
 
21
21
  # Specify which files should be added to the gem when it is released.
22
22
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
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.4
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:
@@ -38,7 +38,7 @@ licenses:
38
38
  metadata:
39
39
  homepage_uri: https://github.com/yosefbennywidyo/short_io
40
40
  source_code_uri: https://github.com/yosefbennywidyo/short_io
41
- changelog_uri: https://github.com/yosefbennywidyo/short_io/CHANGELOG.md
41
+ changelog_uri: https://github.com/yosefbennywidyo/short_io/blob/main/CHANGELOG.md
42
42
  post_install_message:
43
43
  rdoc_options: []
44
44
  require_paths: