outreach_gem 1.0.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 2733f5412eb220c523ca06636a7c559cfc0d3f95bedc0b24dc17056a7d2bc499
4
+ data.tar.gz: e1f7845f728dc659dc9393f680a693cc1ce6b7a2c31a07182f33527168e0a829
5
+ SHA512:
6
+ metadata.gz: e45707419659c0704e4b2089a860ee82ec2f1d19209531ceffddbb7865e4a5aa69e70ba4b4500040887c58d092729c443c2ebbc8228210509b34714aeda49968
7
+ data.tar.gz: 6fc8c909fac3fb6c10d6647b735295e1bee0bbafb33f5020231ae67db5fc542f0a2b3167cf6586d685d8a6d7aa38a0b1ede345d523b5f0937aea1c01c7b8aa72
@@ -0,0 +1,37 @@
1
+ class Helpers
2
+
3
+ def initialize()
4
+ end
5
+
6
+ def getLastCharacter(string)
7
+ raise TypeError unless string.is_a? String
8
+ return string[-1]
9
+ end
10
+
11
+ def removeLastCharacterIf(string, character)
12
+ raise TypeError unless character.is_a? String
13
+
14
+ string = string.chomp(character)
15
+ return string
16
+ end
17
+
18
+ def removeMultipleLastCharacterIf(string, characters)
19
+ raise TypeError unless characters.is_a? Array
20
+
21
+ characters.each { |i|
22
+ string = removeLastCharacterIf(string, i)
23
+ }
24
+
25
+ return string
26
+ end
27
+
28
+ def replaceAllCharacter(string, pattern, replacement)
29
+ raise TypeError unless string.is_a? String
30
+ raise TypeError unless pattern.is_a? String
31
+ raise TypeError unless replacement.is_a? String
32
+
33
+ string = string.gsub(pattern, replacement)
34
+
35
+ return string
36
+ end
37
+ end
@@ -0,0 +1,72 @@
1
+ require 'net/http'
2
+ require 'json'
3
+
4
+ require_relative 'resttype'
5
+
6
+ class RestClient
7
+
8
+ def initialize(uri, headers, rest_type, ssl, params)
9
+ @uri = URI(uri)
10
+ @http = Net::HTTP.new(@uri.host, @uri.port)
11
+
12
+ if ssl === true
13
+ @http.use_ssl = true
14
+ end
15
+
16
+ if params.nil?
17
+ if RestTypes::POST === rest_type
18
+ @req = Net::HTTP::Post.new(@uri.path, headers)
19
+ elsif RestTypes::GET === rest_type
20
+ @req = Net::HTTP::Get.new(@uri.path, headers)
21
+ end
22
+ else
23
+ @uri.query = URI.encode_www_form( params )
24
+ if RestTypes::POST === rest_type
25
+ @req = Net::HTTP::Post.new(@uri.path + '?' + @uri.query, headers)
26
+ elsif RestTypes::GET === rest_type
27
+ @req = Net::HTTP::Get.new(@uri.path + '?' + @uri.query, headers)
28
+ end
29
+ end
30
+
31
+ end
32
+
33
+ def getURI()
34
+ return @uri.to_s
35
+ end
36
+
37
+ def getHost()
38
+ return @uri.host
39
+ end
40
+
41
+ def getPort()
42
+ return @uri.port
43
+ end
44
+
45
+ def getPath()
46
+ return @uri.path
47
+ end
48
+
49
+ def getQuery()
50
+ return @uri.query
51
+ end
52
+
53
+ def setQueryStringParams(params)
54
+ @uri.query = URI.encode_www_form( params )
55
+ end
56
+
57
+ def setBody(content)
58
+ @req.body = content
59
+ end
60
+
61
+ def getBody()
62
+ return @req.body
63
+ end
64
+
65
+ def post()
66
+ return @http.request(@req)
67
+ end
68
+
69
+ def get()
70
+ return @http.request(@req)
71
+ end
72
+ end
@@ -0,0 +1,4 @@
1
+ module RestTypes
2
+ GET = 1
3
+ POST = 2
4
+ end
metadata ADDED
@@ -0,0 +1,46 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: outreach_gem
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Patrique Legault
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-06-11 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email:
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/helpers/helpers.rb
20
+ - lib/rest-client/restfulclient.rb
21
+ - lib/rest-client/resttype.rb
22
+ homepage: https://github.com/AES-Outreach/Outreach-Ruby-Gems
23
+ licenses: []
24
+ metadata:
25
+ allowed_push_host: https://rubygems.org
26
+ post_install_message:
27
+ rdoc_options: []
28
+ require_paths:
29
+ - lib
30
+ required_ruby_version: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ required_rubygems_version: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ requirements: []
41
+ rubyforge_project:
42
+ rubygems_version: 2.7.6.2
43
+ signing_key:
44
+ specification_version: 4
45
+ summary: outreach_gem is the best
46
+ test_files: []