composable-client 0.0.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +5 -0
- data/LICENSE.txt +21 -0
- data/README.md +43 -0
- data/lib/composable/client/base.rb +35 -0
- data/lib/composable/client/callbacks.rb +15 -0
- data/lib/composable/client/gem_version.rb +19 -0
- data/lib/composable/client/http_verb_methods.rb +50 -0
- data/lib/composable/client/version.rb +12 -0
- data/lib/composable/client.rb +16 -0
- metadata +69 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 298a5cb93de3d53f31d508501fd7c0fc9593d0cb28fd8f88dc22d993a5bdcc72
|
4
|
+
data.tar.gz: b6a7e51a9a2ce957ab95f4c1d6cea52436d4e793c127c490a7bae1897846e7a8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 28358a526c2942206f3b68d0e9f48aa1d8341510dc1823582e979a2501c03f3693bb7c83d5cb26c4e3cdc77ad9fd65a2eb8636b9f14ab961d1e25ad905e53b18
|
7
|
+
data.tar.gz: 7a37cdd43a8729b580a4e72a48a34ffc28ed0ba370a45a16edb9eb146478e47898faaf77bc6742001ff88836f4e25bfe65c4ac2f28957135f6c37a70a17e2d03
|
data/CHANGELOG.md
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2023 Jairo Vazquez
|
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 in
|
13
|
+
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 NONINFRINGEMENT. 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
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# Composable::Client
|
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/composable/client`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'composable-client'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle install
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install composable-client
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/composable-client. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/composable-client/blob/master/CODE_OF_CONDUCT.md).
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
40
|
+
|
41
|
+
## Code of Conduct
|
42
|
+
|
43
|
+
Everyone interacting in the Composable::Client project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/composable-client/blob/master/CODE_OF_CONDUCT.md).
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Composable
|
4
|
+
module Client
|
5
|
+
class Base
|
6
|
+
include Core::AttributeDSL
|
7
|
+
include Callbacks
|
8
|
+
include HTTPVerbMethods
|
9
|
+
|
10
|
+
class << self
|
11
|
+
def inherited(subclass)
|
12
|
+
super
|
13
|
+
subclass.prepend(Core::Command)
|
14
|
+
subclass.attribute :endpoint, type: :string, default: -> { raise "endpoint is required" }
|
15
|
+
subclass.attribute :payload, default: {}
|
16
|
+
subclass.attribute :headers, default: {}
|
17
|
+
subclass.attribute :basic_auth, default: {}
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def call
|
22
|
+
return unless valid?
|
23
|
+
|
24
|
+
run_callbacks :request do
|
25
|
+
request
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def request
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Composable
|
4
|
+
module Client
|
5
|
+
# Returns the currently-loaded version of Composable::Client as a <tt>Gem::Version</tt>.
|
6
|
+
def self.gem_version
|
7
|
+
Gem::Version.new VERSION::STRING
|
8
|
+
end
|
9
|
+
|
10
|
+
module VERSION
|
11
|
+
MAJOR = 0
|
12
|
+
MINOR = 0
|
13
|
+
TINY = 12
|
14
|
+
PRE = nil
|
15
|
+
|
16
|
+
STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Composable
|
4
|
+
module Client
|
5
|
+
module HTTPVerbMethods
|
6
|
+
private
|
7
|
+
|
8
|
+
def parse_uri(uri)
|
9
|
+
URI.parse(uri).tap do |uri|
|
10
|
+
raise "Invalid URL: #{uri}" unless uri.host
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def get(path)
|
15
|
+
make_request(:get, path)
|
16
|
+
end
|
17
|
+
|
18
|
+
def post(path)
|
19
|
+
make_request(:post, path)
|
20
|
+
end
|
21
|
+
|
22
|
+
def put(path)
|
23
|
+
make_request(:put, path)
|
24
|
+
end
|
25
|
+
|
26
|
+
def patch(path)
|
27
|
+
make_request(:patch, path)
|
28
|
+
end
|
29
|
+
|
30
|
+
def delete(path)
|
31
|
+
make_request(:delete, path)
|
32
|
+
end
|
33
|
+
|
34
|
+
def make_request(method, path)
|
35
|
+
uri = parse_uri("#{endpoint}/#{path}")
|
36
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
37
|
+
http.use_ssl = uri.scheme == "https"
|
38
|
+
|
39
|
+
request = Net::HTTP.const_get(method.to_s.capitalize).new(uri).tap do |r|
|
40
|
+
r.body = payload.to_json if payload.present?
|
41
|
+
r.content_type = "application/json"
|
42
|
+
r.basic_auth(basic_auth["user"], basic_auth["password"]) unless basic_auth.empty?
|
43
|
+
headers.each { |key, value| r[key] = value }
|
44
|
+
end
|
45
|
+
|
46
|
+
http.request(request)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "uri"
|
4
|
+
require "net/http"
|
5
|
+
require "composable/core"
|
6
|
+
require_relative "client/version"
|
7
|
+
|
8
|
+
module Composable
|
9
|
+
module Client
|
10
|
+
class Error < StandardError; end
|
11
|
+
|
12
|
+
autoload :Base, "composable/client/base"
|
13
|
+
autoload :Callbacks, "composable/client/callbacks"
|
14
|
+
autoload :HTTPVerbMethods, "composable/client/http_verb_methods"
|
15
|
+
end
|
16
|
+
end
|
metadata
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: composable-client
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.12
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jairo Vazquez
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-03-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: composable-core
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.0.12
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.0.12
|
27
|
+
description: Composable Client provides CURD operations for a REST API
|
28
|
+
email:
|
29
|
+
- jairovm20@gmail.com
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- CHANGELOG.md
|
35
|
+
- LICENSE.txt
|
36
|
+
- README.md
|
37
|
+
- lib/composable/client.rb
|
38
|
+
- lib/composable/client/base.rb
|
39
|
+
- lib/composable/client/callbacks.rb
|
40
|
+
- lib/composable/client/gem_version.rb
|
41
|
+
- lib/composable/client/http_verb_methods.rb
|
42
|
+
- lib/composable/client/version.rb
|
43
|
+
homepage: https://github.com/jairovm/composables
|
44
|
+
licenses:
|
45
|
+
- MIT
|
46
|
+
metadata:
|
47
|
+
homepage_uri: https://github.com/jairovm/composables
|
48
|
+
source_code_uri: https://github.com/jairovm/composables/tree/main/composable-client
|
49
|
+
changelog_uri: https://github.com/jairovm/composables/tree/main/composable-client/CHANGELOG.md
|
50
|
+
post_install_message:
|
51
|
+
rdoc_options: []
|
52
|
+
require_paths:
|
53
|
+
- lib
|
54
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: 2.7.0
|
59
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
64
|
+
requirements: []
|
65
|
+
rubygems_version: 3.5.5
|
66
|
+
signing_key:
|
67
|
+
specification_version: 4
|
68
|
+
summary: Client Composable Object
|
69
|
+
test_files: []
|