doterb_http 0.1.3 → 0.1.5

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: 98065179f7270e94614eb2d329503425055f8d6b7b096fd3a9fabd4ab371c478
4
- data.tar.gz: f44816e58cc03ad02c1d4df4889e24efd72802ec975b44c4189a1a560beb39bb
3
+ metadata.gz: 4ae76798e3f0263a88bd8c140c1ad760f6882ee4987e5497e37b86a455973526
4
+ data.tar.gz: a34bdeb34f0e430da1a95d2db38fb9b6a92b6af313b21f8e3750a9dc9fa65dfc
5
5
  SHA512:
6
- metadata.gz: 4a7985c51ef75fc1c07053ab4d0bd4c5d342f29e53e68910699fcf5b812e2145c59f292702bfd4bb24d906a8b0180d352ebbb920c89a3f3c7c1cc9e004695f0f
7
- data.tar.gz: 742926752a96e8201c706c484c8adc40bb14f01737598865a86bf9ce7bf91b05b074c02b6217d8000902ae187ed50edb9bec501bd9483d9daaafd4e3e8ba0547
6
+ metadata.gz: 8c91ab88f3a4f271762c8c2cbf21f033d42c977c542f2204532945482bcbe16ad45bd8a626eb60904e22e9c73b0d67c538f880853b8227332ef5cf325f324f84
7
+ data.tar.gz: c24989999503c04fb49fa3484d62408065e4c80e529377216d86293da42173f3685bb06cbec2d0431f7ec1e2b590d3b5083b1d40713e98f124b808554f484eba
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/Gemfile.lock ADDED
@@ -0,0 +1,59 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ doterb_http (0.1.5)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ ast (2.4.2)
10
+ diff-lcs (1.5.0)
11
+ dry-initializer (3.0.4)
12
+ json (2.6.3)
13
+ parallel (1.23.0)
14
+ parser (3.2.2.1)
15
+ ast (~> 2.4.1)
16
+ rainbow (3.1.1)
17
+ rake (13.0.6)
18
+ regexp_parser (2.8.0)
19
+ rexml (3.2.5)
20
+ rspec (3.12.0)
21
+ rspec-core (~> 3.12.0)
22
+ rspec-expectations (~> 3.12.0)
23
+ rspec-mocks (~> 3.12.0)
24
+ rspec-core (3.12.2)
25
+ rspec-support (~> 3.12.0)
26
+ rspec-expectations (3.12.3)
27
+ diff-lcs (>= 1.2.0, < 2.0)
28
+ rspec-support (~> 3.12.0)
29
+ rspec-mocks (3.12.5)
30
+ diff-lcs (>= 1.2.0, < 2.0)
31
+ rspec-support (~> 3.12.0)
32
+ rspec-support (3.12.0)
33
+ rubocop (1.51.0)
34
+ json (~> 2.3)
35
+ parallel (~> 1.10)
36
+ parser (>= 3.2.0.0)
37
+ rainbow (>= 2.2.2, < 4.0)
38
+ regexp_parser (>= 1.8, < 3.0)
39
+ rexml (>= 3.2.5, < 4.0)
40
+ rubocop-ast (>= 1.28.0, < 2.0)
41
+ ruby-progressbar (~> 1.7)
42
+ unicode-display_width (>= 2.4.0, < 3.0)
43
+ rubocop-ast (1.28.1)
44
+ parser (>= 3.2.1.0)
45
+ ruby-progressbar (1.13.0)
46
+ unicode-display_width (2.4.2)
47
+
48
+ PLATFORMS
49
+ x86_64-darwin-19
50
+
51
+ DEPENDENCIES
52
+ doterb_http!
53
+ dry-initializer (~> 3.0.4)
54
+ rake (~> 13.0)
55
+ rspec (~> 3.0)
56
+ rubocop (~> 1.21)
57
+
58
+ BUNDLED WITH
59
+ 2.4.4
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "doterb_http"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
15
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/doterb_http.gemspec CHANGED
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ lib = File.expand_path('../lib', __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
5
  require_relative "lib/doterb_http/version"
4
6
 
5
7
  Gem::Specification.new do |spec|
@@ -11,7 +13,6 @@ Gem::Specification.new do |spec|
11
13
  spec.summary = ""
12
14
  spec.description = ""
13
15
  spec.homepage = "https://github.com/thufailathhar0/doterb_http"
14
- spec.required_ruby_version = ">= 2.6.0"
15
16
 
16
17
  spec.metadata["allowed_push_host"] = "https://rubygems.org/"
17
18
 
@@ -21,13 +22,12 @@ Gem::Specification.new do |spec|
21
22
 
22
23
  # Specify which files should be added to the gem when it is released.
23
24
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
24
- spec.files = Dir.chdir(__dir__) do
25
- `git ls-files -z`.split("\x0").reject do |f|
26
- (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|circleci)|appveyor)})
27
- end
25
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
26
+ f.match(%r{^(test|spec|features)/})
28
27
  end
29
- spec.bindir = "exe"
30
- spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
28
+
29
+ # spec.bindir = "exe"
30
+ # spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
31
31
  spec.require_paths = ["lib"]
32
32
 
33
33
  # Uncomment to register a new dependency of your gem
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "net/http"
4
+ require "dry-initializer"
5
+ require "json"
6
+
7
+ module DoterbHttp
8
+ class Get
9
+ extend Dry::Initializer
10
+
11
+ option :url
12
+ option :body, optional: true
13
+
14
+ def call
15
+ uri = URI.parse(url)
16
+ uri.query = URI.encode_www_form(body) if body
17
+
18
+ http = Net::HTTP.new(uri.host, uri.port)
19
+ http.use_ssl = true
20
+ request = Net::HTTP::Get.new(uri.request_uri)
21
+ request['Content-Type'] = "application/json"
22
+ request['Accept'] = "application/json"
23
+
24
+ response = http.request(request)
25
+ if response.code == '200'
26
+ JSON.parse(response.body)
27
+ else
28
+ raise response.body
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "net/http"
4
+ require "dry-initializer"
5
+ require "json"
6
+
7
+ module DoterbHttp
8
+ class Post
9
+ extend Dry::Initializer
10
+
11
+ option :url
12
+ option :body, optional: true
13
+
14
+ def call
15
+ uri = URI.parse(url)
16
+
17
+ http = Net::HTTP.new(uri.host, uri.port)
18
+ http.use_ssl = true
19
+ request = Net::HTTP::Post.new(uri.request_uri)
20
+ request['Content-Type'] = "application/json"
21
+ request['Accept'] = "application/json"
22
+ request.body = body.to_json if body
23
+
24
+ response = http.request(request)
25
+ if response.code == '200'
26
+ JSON.parse(response.body)
27
+ else
28
+ raise response.body
29
+ end
30
+ end
31
+ end
32
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DoterbHttp
4
- VERSION = "0.1.3"
4
+ VERSION = "0.1.5"
5
5
  end
data/lib/doterb_http.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "doterb_http/version"
4
- require "doterb_http/get"
5
- require "doterb_http/post"
4
+ require 'doterb_http/get'
5
+ require 'doterb_http/post'
6
6
  require "net/http"
7
7
  require "dry-initializer"
8
8
 
metadata CHANGED
@@ -1,12 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: doterb_http
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - thufail athhar
8
8
  autorequire:
9
- bindir: exe
9
+ bindir: bin
10
10
  cert_chain: []
11
11
  date: 2023-05-26 00:00:00.000000000 Z
12
12
  dependencies: []
@@ -17,17 +17,22 @@ executables: []
17
17
  extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
+ - ".gitignore"
20
21
  - ".rspec"
21
22
  - ".rubocop.yml"
22
23
  - CHANGELOG.md
23
24
  - CODE_OF_CONDUCT.md
24
25
  - Gemfile
26
+ - Gemfile.lock
25
27
  - README.md
26
28
  - Rakefile
29
+ - bin/console
30
+ - bin/setup
27
31
  - doterb_http.gemspec
28
32
  - lib/doterb_http.rb
33
+ - lib/doterb_http/get.rb
34
+ - lib/doterb_http/post.rb
29
35
  - lib/doterb_http/version.rb
30
- - sig/doterb_http.rbs
31
36
  homepage: https://github.com/thufailathhar0/doterb_http
32
37
  licenses: []
33
38
  metadata:
@@ -43,7 +48,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
43
48
  requirements:
44
49
  - - ">="
45
50
  - !ruby/object:Gem::Version
46
- version: 2.6.0
51
+ version: '0'
47
52
  required_rubygems_version: !ruby/object:Gem::Requirement
48
53
  requirements:
49
54
  - - ">="
data/sig/doterb_http.rbs DELETED
@@ -1,4 +0,0 @@
1
- module DoterbHttp
2
- VERSION: String
3
- # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
- end