kilya 0.0.5 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +4 -0
- data/.travis.yml +8 -0
- data/Gemfile +3 -0
- data/README.md +21 -0
- data/Rakefile +8 -0
- data/kilya.gemspec +2 -1
- data/lib/kilya.rb +16 -0
- data/lib/services/requester.rb +31 -0
- data/test/test_kilya.rb +17 -0
- metadata +23 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a3f110ce68d21c0ece35a75a4dc342e42eefec0a64724aeea1e3ba2654cf3ba
|
4
|
+
data.tar.gz: f9fd21dca091d4b2761ca2919bd36acbfec0f04ba779c323322ae733e3c4ab16
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 92991d3145471311233098eb8fbecaa38b0d134c269cde3dbd10055982e5c39f2142b89b18d0f84d2dc8856ed93aeaaa955e20aa29589a01af5005e72aeb0c1d
|
7
|
+
data.tar.gz: fb97e979f816064c309b4d337ca11edf7888eb9b0191695800e65e010423fc897cee0bb300823c48021b9c7248c21d8fc5256ec69820b530546c33cd03d55c72
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# kilya
|
2
|
+
**kilya** - It's just a simple example of your own gem.
|
3
|
+
|
4
|
+
## Dependencies:
|
5
|
+
```sh
|
6
|
+
ruby '2.7.2'
|
7
|
+
faraday '2.2'
|
8
|
+
```
|
9
|
+
## Install:
|
10
|
+
```sh
|
11
|
+
bundle install kilya
|
12
|
+
|
13
|
+
requre 'kilya'
|
14
|
+
```
|
15
|
+
## How is it works?:
|
16
|
+
```sh
|
17
|
+
require 'kilya'
|
18
|
+
|
19
|
+
Kilya.reverse("line")
|
20
|
+
Kilya.requrest("http://example.com")
|
21
|
+
```
|
data/Rakefile
ADDED
data/kilya.gemspec
CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
|
|
7
7
|
s.rubygems_version = '2.7'
|
8
8
|
s.required_ruby_version = '>=2.2'
|
9
9
|
s.name = 'kilya'
|
10
|
-
s.version = '0.0.
|
10
|
+
s.version = '0.0.8'
|
11
11
|
s.executables << 'kilya'
|
12
12
|
s.license = 'MIT'
|
13
13
|
s.summary = 'Simple first Ruby gem'
|
@@ -16,4 +16,5 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.email = 'ilyafulleveline@gmail.com'
|
17
17
|
s.homepage = 'https://github.com/ikondratev/kilya'
|
18
18
|
s.files = `git ls-files`.split($RS)
|
19
|
+
s.add_dependency 'faraday', '2.2'
|
19
20
|
end
|
data/lib/kilya.rb
CHANGED
@@ -1,7 +1,23 @@
|
|
1
|
+
# main point
|
1
2
|
require 'services/string_builder'
|
3
|
+
require 'services/requester'
|
2
4
|
|
3
5
|
class Kilya
|
6
|
+
# It's my first simple gem
|
7
|
+
#
|
8
|
+
# Example:
|
9
|
+
# >> Kilya.reverse("abcd")
|
10
|
+
# => "dcba"
|
11
|
+
# >> Kilya.request("http://example.com")
|
12
|
+
# =><HTML><HEAD><meta http-equiv=\"content-type\" content=\"text/html;charset=utf-8\"> ...
|
13
|
+
# Arguments:
|
14
|
+
# line: (String)
|
4
15
|
class << self
|
5
16
|
include Services::StringBuilder
|
17
|
+
|
18
|
+
def request(url)
|
19
|
+
requester = Services::Requester.new
|
20
|
+
requester.request(url: url)
|
21
|
+
end
|
6
22
|
end
|
7
23
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'faraday'
|
2
|
+
|
3
|
+
module Services
|
4
|
+
class Requester
|
5
|
+
# @param [String] method: default get
|
6
|
+
# @param [String] url: example: "http://example.com"
|
7
|
+
# @return [Hash] response
|
8
|
+
def request(method: :get, url:)
|
9
|
+
result = Faraday.send(method, url)
|
10
|
+
parse_response(result)
|
11
|
+
rescue StandardError
|
12
|
+
parse_response(error_response)
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def parse_response(result)
|
18
|
+
{
|
19
|
+
status: result.status,
|
20
|
+
body: result.body
|
21
|
+
}
|
22
|
+
end
|
23
|
+
|
24
|
+
def error_response
|
25
|
+
OpenStruct.new(
|
26
|
+
status: 500,
|
27
|
+
body: "Backend Error"
|
28
|
+
)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/test/test_kilya.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
require 'kilya'
|
3
|
+
|
4
|
+
class TestKilya < Minitest::Test
|
5
|
+
def test_reverse_string
|
6
|
+
assert_equal("aaasss", Kilya.reverse("sssaaa"))
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_not_empty_reverse
|
10
|
+
assert_equal("nothing to reverse", Kilya.reverse(nil))
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_fatrady_request
|
14
|
+
result = Kilya.request("http://google.com")
|
15
|
+
assert_equal(301, result.dig(:status))
|
16
|
+
end
|
17
|
+
end
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kilya
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ilya Kondratev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-03-
|
12
|
-
dependencies:
|
11
|
+
date: 2022-03-15 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: faraday
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.2'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.2'
|
13
27
|
description: Class Kilya for test new gem.
|
14
28
|
email: ilyafulleveline@gmail.com
|
15
29
|
executables:
|
@@ -18,10 +32,16 @@ extensions: []
|
|
18
32
|
extra_rdoc_files: []
|
19
33
|
files:
|
20
34
|
- ".gitignore"
|
35
|
+
- ".travis.yml"
|
36
|
+
- Gemfile
|
37
|
+
- README.md
|
38
|
+
- Rakefile
|
21
39
|
- bin/kilya
|
22
40
|
- kilya.gemspec
|
23
41
|
- lib/kilya.rb
|
42
|
+
- lib/services/requester.rb
|
24
43
|
- lib/services/string_builder.rb
|
44
|
+
- test/test_kilya.rb
|
25
45
|
homepage: https://github.com/ikondratev/kilya
|
26
46
|
licenses:
|
27
47
|
- MIT
|