kilya 0.0.6 → 0.0.9

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7721bbcbaec01abe3435af363b9e526706a363f39b3c252f064b92da32db95a8
4
- data.tar.gz: 59b6b5235b56e43f74c369525ece78a5103669dc6943e2012cc5d2cd18f72ed0
3
+ metadata.gz: 7f885532921685dd80e9fa6506957715d2a4c19f0eae3b20f34ddec5e29dc5be
4
+ data.tar.gz: 80bbcb8a41cbdf6422dd150ad61f16445353bc6cb7f62056f2109bf155163c9a
5
5
  SHA512:
6
- metadata.gz: 0f7c7d1ed5a0b0e6ccb22c8f9c97b50fc29b0508f1f6038bba8d635a8cafb6d34c7722492fc18f5d0a43d7f070c1e89a4af5cae4c80ab22a91bf22cfa982d6d7
7
- data.tar.gz: 89d6500ca89306f57c3497e9e1bcfce9ae7bc08bb4351f6b3aa235dcaed0acc11701f2bc39b2481a993792748e568962411baeb2c76c6f7ad63f28ca83350267
6
+ metadata.gz: 7fff8d8f743f78468adcf96dcb1b417a04b921a67bb384f2ec6c7491a54fe0064d4a35988cc03d59e313e157772935738179e6331a72267eb246838e014043ed
7
+ data.tar.gz: a7372840ee44c591ab193c6afd194c76f4555d1d2985663d44d2081f4ec04b42f4f88d3857a7887b43479060493c4169acf06e887be16f81e0650e11faa7ba88
data/.gitignore CHANGED
@@ -1,3 +1,5 @@
1
1
  *.gem
2
2
 
3
3
  .idea/
4
+
5
+ Gemfile.lock
data/.rubocop.yml ADDED
@@ -0,0 +1,61 @@
1
+ AllCops:
2
+ Exclude:
3
+ - config/*
4
+ - Gemfile
5
+ - test/*
6
+ - Rakefile
7
+ - kilya.gemspec
8
+
9
+ Style/FrozenStringLiteralComment:
10
+ Enabled: false
11
+
12
+ Metrics/LineLength:
13
+ Max: 190
14
+
15
+ Style/Documentation:
16
+ Enabled: false
17
+
18
+ Style/StringLiterals:
19
+ Enabled: false
20
+
21
+ Style/GlobalVars:
22
+ Enabled: false
23
+
24
+ Metrics/MethodLength:
25
+ Max: 77
26
+
27
+ Metrics/BlockLength:
28
+ Max: 177
29
+
30
+ Naming/PredicateName:
31
+ Enabled: false
32
+
33
+ Style/GuardClause:
34
+ Enabled: false
35
+
36
+ Metrics/AbcSize:
37
+ Enabled: false
38
+
39
+ Style/MixinUsage:
40
+ Enabled: false
41
+
42
+ Lint/AmbiguousOperator:
43
+ Enabled: false
44
+
45
+ Naming/MemoizedInstanceVariableName:
46
+ Enabled: false
47
+
48
+ Naming/VariableNumber:
49
+ Enabled: false
50
+
51
+ Layout/DefEndAlignment:
52
+ Enabled: false
53
+
54
+ Style/MultilineIfModifier:
55
+ Enabled: false
56
+
57
+ Style/RaiseArgs:
58
+ Enabled: false
59
+
60
+ Style/IdenticalConditionalBranches:
61
+ Enabled: false
data/.travis.yml ADDED
@@ -0,0 +1,8 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.7.2
4
+ branches:
5
+ only:
6
+ - master
7
+ script:
8
+ - rake
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org/'
2
+ ruby '2.7.2'
3
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019-2022 Kondratev Ilya
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included
13
+ in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
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 CHANGED
@@ -1,8 +1,16 @@
1
- require 'rake/testtask'
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ desc "Run spec"
5
+ task default: %i[test rubocop]
2
6
 
7
+ require 'rake/testtask'
3
8
  Rake::TestTask.new do |test|
4
9
  test.libs << 'test'
5
10
  end
6
11
 
7
- desc "Run test"
8
- task :default => :test
12
+ require 'rubocop/rake_task'
13
+ RuboCop::RakeTask.new do |task|
14
+ task.fail_on_error = true
15
+ task.requires << 'rubocop-rake'
16
+ end
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.6'
10
+ s.version = '0.0.9'
11
11
  s.executables << 'kilya'
12
12
  s.license = 'MIT'
13
13
  s.summary = 'Simple first Ruby gem'
@@ -16,4 +16,7 @@ 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'
20
+ s.add_dependency 'rubocop', '~> 1.26'
21
+ s.add_dependency 'rubocop-rake'
19
22
  end
data/lib/kilya.rb CHANGED
@@ -1,16 +1,37 @@
1
- # main pont
1
+ # frozen_string_literal: true
2
+
3
+ # (The MIT License)
4
+ #
5
+ # Copyright (c) 2019-2021 Kondratev Ilya
6
+ #
7
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ # of this software and associated documentation files (the 'Software'), to deal
9
+ # in the Software without restriction, including without limitation the rights
10
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ # copies of the Software, and to permit persons to whom the Software is
12
+ # furnished to do so, subject to the following conditions:
13
+ #
14
+ # The above copyright notice and this permission notice shall be included in all
15
+ # copies or substantial portions of the Software.
16
+ #
17
+ # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ # SOFTWARE.
24
+
2
25
  require 'services/string_builder'
26
+ require 'services/requester'
3
27
 
4
28
  class Kilya
5
- # It's my first simple gem
6
- #
7
- # Example:
8
- # >> Kilya.reverse("abcd")
9
- # => "dcba"
10
- #
11
- # Arguments:
12
- # line: (String)
13
29
  class << self
14
30
  include Services::StringBuilder
31
+
32
+ def request(url)
33
+ requester = Services::Requester.new
34
+ requester.request(url: url)
35
+ end
15
36
  end
16
37
  end
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ # (The MIT License)
4
+ #
5
+ # Copyright (c) 2019-2021 Kondratev Ilya
6
+ #
7
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ # of this software and associated documentation files (the 'Software'), to deal
9
+ # in the Software without restriction, including without limitation the rights
10
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ # copies of the Software, and to permit persons to whom the Software is
12
+ # furnished to do so, subject to the following conditions:
13
+ #
14
+ # The above copyright notice and this permission notice shall be included in all
15
+ # copies or substantial portions of the Software.
16
+ #
17
+ # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ # SOFTWARE.
24
+
25
+ require 'faraday'
26
+
27
+ module Services
28
+ class Requester
29
+ # @param [String] method: default get
30
+ # @param [String] url: example: "http://example.com"
31
+ # @return [Hash] response
32
+ def request(url:, method: "get")
33
+ result = Faraday.send(method, url)
34
+ parse_response(result)
35
+ rescue StandardError
36
+ parse_response(error_response)
37
+ end
38
+
39
+ private
40
+
41
+ def parse_response(result)
42
+ {
43
+ status: result.status,
44
+ body: result.body
45
+ }
46
+ end
47
+
48
+ def error_response
49
+ OpenStruct.new(
50
+ status: 500,
51
+ body: "Backend error"
52
+ )
53
+ end
54
+ end
55
+ end
@@ -1,7 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ # (The MIT License)
4
+ #
5
+ # Copyright (c) 2019-2021 Kondratev Ilya
6
+ #
7
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ # of this software and associated documentation files (the 'Software'), to deal
9
+ # in the Software without restriction, including without limitation the rights
10
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ # copies of the Software, and to permit persons to whom the Software is
12
+ # furnished to do so, subject to the following conditions:
13
+ #
14
+ # The above copyright notice and this permission notice shall be included in all
15
+ # copies or substantial portions of the Software.
16
+ #
17
+ # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ # SOFTWARE.
24
+
1
25
  module Services
2
26
  module StringBuilder
27
+ class StringBuilderError < StandardError; end
28
+
29
+ # @param [String] line
30
+ # @return [String]
31
+ # @raise [StringBuilderError]
3
32
  def reverse(line)
4
33
  line.nil? ? "nothing to reverse" : line.reverse!
34
+ rescue StandardError => e
35
+ StringBuilderError.new(e.message)
5
36
  end
6
37
  end
7
- end
38
+ end
data/test/test_kilya.rb CHANGED
@@ -9,4 +9,9 @@ class TestKilya < Minitest::Test
9
9
  def test_not_empty_reverse
10
10
  assert_equal("nothing to reverse", Kilya.reverse(nil))
11
11
  end
12
+
13
+ def test_fatrady_request
14
+ result = Kilya.request("http://google.com")
15
+ assert_equal(301, result.dig(:status))
16
+ end
12
17
  end
metadata CHANGED
@@ -1,15 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kilya
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.9
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-11 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2022-03-20 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'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rubocop
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.26'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.26'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rubocop-rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
13
55
  description: Class Kilya for test new gem.
14
56
  email: ilyafulleveline@gmail.com
15
57
  executables:
@@ -18,10 +60,16 @@ extensions: []
18
60
  extra_rdoc_files: []
19
61
  files:
20
62
  - ".gitignore"
63
+ - ".rubocop.yml"
64
+ - ".travis.yml"
65
+ - Gemfile
66
+ - LICENSE.txt
67
+ - README.md
21
68
  - Rakefile
22
69
  - bin/kilya
23
70
  - kilya.gemspec
24
71
  - lib/kilya.rb
72
+ - lib/services/requester.rb
25
73
  - lib/services/string_builder.rb
26
74
  - test/test_kilya.rb
27
75
  homepage: https://github.com/ikondratev/kilya