crapi 0.1.3 → 1.0.1

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.
data/lib/crapi/proxy.rb CHANGED
@@ -1,120 +1,120 @@
1
1
  require 'active_support/all'
2
2
 
3
- module Crapi
4
- ## Proxies simple CRUD methods ({#delete} / {#get} / {#patch} / {#post} / {#put}) for a
5
- ## {Crapi::Client Crapi::Client} or another {Crapi::Proxy Crapi::Proxy}. Like
6
- ## {Crapi::Client Crapi::Client}, it also provides a proxy generator.
7
- ##
8
- ## A {Crapi::Proxy Crapi::Proxy} has its own set of default headers and has a segment that is
9
- ## prepended to its CRUD methods' *path* before being passed to the parent
10
- ## {Crapi::Client Crapi::Client}/{Crapi::Proxy Crapi::Proxy}. This makes the proxxy functionally
11
- ## equivalent to a new {Crapi::Client Crapi::Client} with a new base path (the parent's base path
12
- ## plus the proxy's segment) and more default headers, but without the need for a separate
13
- ## connection to the target system.
14
- ##
3
+ module CrAPI
4
+ # Proxies simple CRUD methods ({#delete} / {#get} / {#patch} / {#post} / {#put}) for a
5
+ # {CrAPI::Client CrAPI::Client} or another {CrAPI::Proxy CrAPI::Proxy}. Like
6
+ # {CrAPI::Client CrAPI::Client}, it also provides a proxy generator.
7
+ #
8
+ # A {CrAPI::Proxy CrAPI::Proxy} has its own set of default headers and has a segment that is
9
+ # prepended to its CRUD methods' *path* before being passed to the parent
10
+ # {CrAPI::Client CrAPI::Client}/{CrAPI::Proxy CrAPI::Proxy}. This makes the proxxy functionally
11
+ # equivalent to a new {CrAPI::Client CrAPI::Client} with a new base path (the parent's base path
12
+ # plus the proxy's segment) and more default headers, but without the need for a separate
13
+ # connection to the target system.
14
+ #
15
15
  class Proxy
16
- ## A Hash containing headers to send with every request (unless overriden elsewhere). In case of
17
- ## conflicts, headers set as default for a {Crapi::Proxy Crapi::Proxy} override those set by the
18
- ## parent. As in a {Crapi::Client Crapi::Client}, headers set by the user via the CRUD methods'
19
- ## *headers* still override any conflicting default header.
20
- ##
21
- ##
22
- ## @see Crapi::Client#default_headers Crapi::Client#default_headers
23
- ##
16
+ # A Hash containing headers to send with every request (unless overriden elsewhere). In case of
17
+ # conflicts, headers set as default for a {CrAPI::Proxy CrAPI::Proxy} override those set by the
18
+ # parent. As in a {CrAPI::Client CrAPI::Client}, headers set by the user via the CRUD methods'
19
+ # *headers* still override any conflicting default header.
20
+ #
21
+ #
22
+ # @see CrAPI::Client#default_headers CrAPI::Client#default_headers
23
+ #
24
24
  attr_accessor :default_headers
25
25
 
26
- ## @param add [String]
27
- ## The new base path. This path (added to the parent's base path) will be used as the base
28
- ## path for the {Crapi::Proxy Crapi::Proxy}'s CRUD methods.
29
- ##
30
- ## @param to [Crapi::Client, Crapi::Proxy]
31
- ## The parent {Crapi::Client Crapi::Client} or {Crapi::Proxy Crapi::Proxy} that we'll be
32
- ## delegating CRUD calls to after proprocessing of headers and paths.
33
- ##
34
- ## @param headers [Hash]
35
- ## The default headers to send with every request (unless overriden elsewhere).
36
- ##
26
+ # @param add [String]
27
+ # The new base path. This path (added to the parent's base path) will be used as the base
28
+ # path for the {CrAPI::Proxy CrAPI::Proxy}'s CRUD methods.
29
+ #
30
+ # @param to [CrAPI::Client, CrAPI::Proxy]
31
+ # The parent {CrAPI::Client CrAPI::Client} or {CrAPI::Proxy CrAPI::Proxy} that we'll be
32
+ # delegating CRUD calls to after proprocessing of headers and paths.
33
+ #
34
+ # @param headers [Hash]
35
+ # The default headers to send with every request (unless overriden elsewhere).
36
+ #
37
37
  def initialize(add:, to:, headers: nil)
38
38
  @parent = to
39
39
  @segment = add
40
40
  @default_headers = (headers || {}).with_indifferent_access
41
41
  end
42
42
 
43
- ## Returns a new {Crapi::Proxy Crapi::Proxy} for this proxy.
44
- ##
45
- ##
46
- ## @param segment [String]
47
- ## The segment to add to this proxy's path.
48
- ##
49
- ## @param headers [Hash]
50
- ## The default headers for the new proxy.
51
- ##
52
- ##
53
- ## @return [Crapi::Proxy]
54
- ##
55
- ## @see Crapi::Client#new_proxy Crapi::Client#new_proxy
56
- ##
43
+ # Returns a new {CrAPI::Proxy CrAPI::Proxy} for this proxy.
44
+ #
45
+ #
46
+ # @param segment [String]
47
+ # The segment to add to this proxy's path.
48
+ #
49
+ # @param headers [Hash]
50
+ # The default headers for the new proxy.
51
+ #
52
+ #
53
+ # @return [CrAPI::Proxy]
54
+ #
55
+ # @see CrAPI::Client#new_proxy CrAPI::Client#new_proxy
56
+ #
57
57
  def new_proxy(segment = '/', headers: nil)
58
58
  Proxy.new(add: segment, to: self, headers: headers)
59
59
  end
60
60
 
61
- ## CRUD methods ...
61
+ # CRUD methods ...
62
62
 
63
- ## CRUD method: DELETE
64
- ##
65
- ##
66
- ## @return [Object]
67
- ##
68
- ## @see Crapi::Client#delete Crapi::Client#delete
69
- ##
63
+ # CRUD method: DELETE
64
+ #
65
+ #
66
+ # @return [Object]
67
+ #
68
+ # @see CrAPI::Client#delete CrAPI::Client#delete
69
+ #
70
70
  def delete(path, headers: {}, query: {})
71
71
  @parent.delete("/#{@segment}/#{path}".gsub(%r{/+}, '/'),
72
72
  headers: @default_headers.merge(headers), query: query)
73
73
  end
74
74
 
75
- ## CRUD method: GET
76
- ##
77
- ##
78
- ## @return [Object]
79
- ##
80
- ## @see Crapi::Client#get Crapi::Client#get
81
- ##
75
+ # CRUD method: GET
76
+ #
77
+ #
78
+ # @return [Object]
79
+ #
80
+ # @see CrAPI::Client#get CrAPI::Client#get
81
+ #
82
82
  def get(path, headers: {}, query: {})
83
83
  @parent.get("/#{@segment}/#{path}".gsub(%r{/+}, '/'),
84
84
  headers: @default_headers.merge(headers), query: query)
85
85
  end
86
86
 
87
- ## CRUD method: PATCH
88
- ##
89
- ##
90
- ## @return [Object]
91
- ##
92
- ## @see Crapi::Client#patch Crapi::Client#patch
93
- ##
87
+ # CRUD method: PATCH
88
+ #
89
+ #
90
+ # @return [Object]
91
+ #
92
+ # @see CrAPI::Client#patch CrAPI::Client#patch
93
+ #
94
94
  def patch(path, headers: {}, query: {}, payload: {})
95
95
  @parent.patch("/#{@segment}/#{path}".gsub(%r{/+}, '/'),
96
- heades: @default_headers.merge(headers), query: query, payload: payload)
96
+ headers: @default_headers.merge(headers), query: query, payload: payload)
97
97
  end
98
98
 
99
- ## CRUD method: POST
100
- ##
101
- ##
102
- ## @return [Object]
103
- ##
104
- ## @see Crapi::Client#post Crapi::Client#post
105
- ##
99
+ # CRUD method: POST
100
+ #
101
+ #
102
+ # @return [Object]
103
+ #
104
+ # @see CrAPI::Client#post CrAPI::Client#post
105
+ #
106
106
  def post(path, headers: {}, query: {}, payload: {})
107
107
  @parent.post("/#{@segment}/#{path}".gsub(%r{/+}, '/'),
108
108
  headers: @default_headers.merge(headers), query: query, payload: payload)
109
109
  end
110
110
 
111
- ## CRUD method: PUT
112
- ##
113
- ##
114
- ## @return [Object]
115
- ##
116
- ## @see Crapi::Client#put Crapi::Client#put
117
- ##
111
+ # CRUD method: PUT
112
+ #
113
+ #
114
+ # @return [Object]
115
+ #
116
+ # @see CrAPI::Client#put CrAPI::Client#put
117
+ #
118
118
  def put(path, headers: {}, query: {}, payload: {})
119
119
  @parent.put("/#{@segment}/#{path}".gsub(%r{/+}, '/'),
120
120
  headers: @default_headers.merge(headers), query: query, payload: payload)
data/lib/crapi/version.rb CHANGED
@@ -1,11 +1,11 @@
1
- ## The Crapi module houses the {Crapi::Client Crapi::Client} and {Crapi::Proxy Crapi::Proxy} classes
2
- ## in this gem.
3
- ##
4
- module Crapi
5
- ## The canonical **crapi** gem version.
6
- ##
7
- ## This should only ever be updated *immediately* before a release; the commit that updates this
8
- ## value should be pushed **by** the `rake release` process.
9
- ##
10
- VERSION = '0.1.3'.freeze
1
+ # The CrAPI module houses the {CrAPI::Client CrAPI::Client} and {CrAPI::Proxy CrAPI::Proxy} classes
2
+ # in this gem.
3
+ #
4
+ module CrAPI
5
+ # The canonical **crapi** gem version.
6
+ #
7
+ # This should only ever be updated *immediately* before a release; the commit that updates this
8
+ # value should be pushed **by** the `rake release` process.
9
+ #
10
+ VERSION = '1.0.1'.freeze
11
11
  end
data/lib/crapi.rb CHANGED
@@ -2,5 +2,7 @@ require 'crapi/client'
2
2
  require 'crapi/proxy'
3
3
  require 'crapi/version'
4
4
 
5
- module Crapi
5
+ # Parent module for the various CrAPI classes.
6
+ #
7
+ module CrAPI
6
8
  end
metadata CHANGED
@@ -1,125 +1,129 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nestor Custodio
8
- autorequire:
9
- bindir: exe
8
+ bindir: bin
10
9
  cert_chain: []
11
- date: 2018-05-30 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
- name: bundler
13
+ name: activesupport
15
14
  requirement: !ruby/object:Gem::Requirement
16
15
  requirements:
17
- - - "~>"
16
+ - - ">="
18
17
  - !ruby/object:Gem::Version
19
- version: '1.16'
20
- type: :development
18
+ version: 6.1.0
19
+ - - "<"
20
+ - !ruby/object:Gem::Version
21
+ version: '9'
22
+ type: :runtime
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
23
25
  requirements:
24
- - - "~>"
26
+ - - ">="
25
27
  - !ruby/object:Gem::Version
26
- version: '1.16'
28
+ version: 6.1.0
29
+ - - "<"
30
+ - !ruby/object:Gem::Version
31
+ version: '9'
27
32
  - !ruby/object:Gem::Dependency
28
- name: pry
33
+ name: bundler
29
34
  requirement: !ruby/object:Gem::Requirement
30
35
  requirements:
31
36
  - - "~>"
32
37
  - !ruby/object:Gem::Version
33
- version: '0.11'
38
+ version: '4'
34
39
  type: :development
35
40
  prerelease: false
36
41
  version_requirements: !ruby/object:Gem::Requirement
37
42
  requirements:
38
43
  - - "~>"
39
44
  - !ruby/object:Gem::Version
40
- version: '0.11'
45
+ version: '4'
41
46
  - !ruby/object:Gem::Dependency
42
- name: pry-byebug
47
+ name: rspec
43
48
  requirement: !ruby/object:Gem::Requirement
44
49
  requirements:
45
50
  - - "~>"
46
51
  - !ruby/object:Gem::Version
47
- version: '3.6'
52
+ version: '3'
48
53
  type: :development
49
54
  prerelease: false
50
55
  version_requirements: !ruby/object:Gem::Requirement
51
56
  requirements:
52
57
  - - "~>"
53
58
  - !ruby/object:Gem::Version
54
- version: '3.6'
59
+ version: '3'
55
60
  - !ruby/object:Gem::Dependency
56
- name: rake
61
+ name: rspec_junit_formatter
57
62
  requirement: !ruby/object:Gem::Requirement
58
63
  requirements:
59
- - - "~>"
64
+ - - ">="
60
65
  - !ruby/object:Gem::Version
61
- version: '10.0'
66
+ version: '0'
62
67
  type: :development
63
68
  prerelease: false
64
69
  version_requirements: !ruby/object:Gem::Requirement
65
70
  requirements:
66
- - - "~>"
71
+ - - ">="
67
72
  - !ruby/object:Gem::Version
68
- version: '10.0'
73
+ version: '0'
69
74
  - !ruby/object:Gem::Dependency
70
- name: rspec
75
+ name: rubocop
71
76
  requirement: !ruby/object:Gem::Requirement
72
77
  requirements:
73
- - - "~>"
78
+ - - ">="
74
79
  - !ruby/object:Gem::Version
75
- version: '3.0'
80
+ version: '0'
76
81
  type: :development
77
82
  prerelease: false
78
83
  version_requirements: !ruby/object:Gem::Requirement
79
84
  requirements:
80
- - - "~>"
85
+ - - ">="
81
86
  - !ruby/object:Gem::Version
82
- version: '3.0'
87
+ version: '0'
83
88
  - !ruby/object:Gem::Dependency
84
- name: rspec_junit_formatter
89
+ name: webmock
85
90
  requirement: !ruby/object:Gem::Requirement
86
91
  requirements:
87
- - - "~>"
92
+ - - ">="
88
93
  - !ruby/object:Gem::Version
89
- version: '0.3'
94
+ version: '0'
90
95
  type: :development
91
96
  prerelease: false
92
97
  version_requirements: !ruby/object:Gem::Requirement
93
98
  requirements:
94
- - - "~>"
99
+ - - ">="
95
100
  - !ruby/object:Gem::Version
96
- version: '0.3'
101
+ version: '0'
97
102
  - !ruby/object:Gem::Dependency
98
- name: activesupport
103
+ name: yard
99
104
  requirement: !ruby/object:Gem::Requirement
100
105
  requirements:
101
- - - "~>"
106
+ - - ">="
102
107
  - !ruby/object:Gem::Version
103
- version: 5.2.0
104
- type: :runtime
108
+ version: '0'
109
+ type: :development
105
110
  prerelease: false
106
111
  version_requirements: !ruby/object:Gem::Requirement
107
112
  requirements:
108
- - - "~>"
113
+ - - ">="
109
114
  - !ruby/object:Gem::Version
110
- version: 5.2.0
111
- description:
115
+ version: '0'
112
116
  email:
113
- - sakimorix@gmail.com
117
+ - nestor@custodio.org
114
118
  executables: []
115
119
  extensions: []
116
120
  extra_rdoc_files: []
117
121
  files:
122
+ - ".circleci/config.yml"
118
123
  - ".gitignore"
119
124
  - ".rspec"
120
125
  - ".rubocop.yml"
121
126
  - ".ruby-version"
122
- - ".travis.yml"
123
127
  - ".yardopts"
124
128
  - Gemfile
125
129
  - Gemfile.lock
@@ -129,12 +133,12 @@ files:
129
133
  - bin/console
130
134
  - bin/setup
131
135
  - crapi.gemspec
132
- - docs/Crapi.html
133
- - docs/Crapi/ArgumentError.html
134
- - docs/Crapi/BadHttpResponseError.html
135
- - docs/Crapi/Client.html
136
- - docs/Crapi/Error.html
137
- - docs/Crapi/Proxy.html
136
+ - docs/CrAPI.html
137
+ - docs/CrAPI/ArgumentError.html
138
+ - docs/CrAPI/BadHttpResponseError.html
139
+ - docs/CrAPI/Client.html
140
+ - docs/CrAPI/Error.html
141
+ - docs/CrAPI/Proxy.html
138
142
  - docs/Net/HTTP.html
139
143
  - docs/_index.html
140
144
  - docs/class_list.html
@@ -155,11 +159,11 @@ files:
155
159
  - lib/crapi/errors.rb
156
160
  - lib/crapi/proxy.rb
157
161
  - lib/crapi/version.rb
158
- homepage: https://www.github.com/nestor-custodio/crapi
162
+ homepage: https://github.com/nestor-custodio/crapi
159
163
  licenses:
160
164
  - MIT
161
- metadata: {}
162
- post_install_message:
165
+ metadata:
166
+ rubygems_mfa_required: 'true'
163
167
  rdoc_options: []
164
168
  require_paths:
165
169
  - lib
@@ -167,17 +171,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
167
171
  requirements:
168
172
  - - ">="
169
173
  - !ruby/object:Gem::Version
170
- version: '0'
174
+ version: '3'
171
175
  required_rubygems_version: !ruby/object:Gem::Requirement
172
176
  requirements:
173
177
  - - ">="
174
178
  - !ruby/object:Gem::Version
175
179
  version: '0'
176
180
  requirements: []
177
- rubyforge_project:
178
- rubygems_version: 2.7.6
179
- signing_key:
181
+ rubygems_version: 3.6.9
180
182
  specification_version: 4
181
- summary: A simple API client with built-in segment/header proxy support. "... It could
182
- be better." ™️
183
+ summary: A simple API client with built-in segment/header proxy support.
183
184
  test_files: []
data/.travis.yml DELETED
@@ -1,5 +0,0 @@
1
- sudo: false
2
- language: ruby
3
- rvm:
4
- - 2.5.1
5
- before_install: gem install bundler -v 1.16.1
data/docs/Crapi.html DELETED
@@ -1,153 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>
7
- Module: Crapi
8
-
9
- &mdash; Documentation by YARD 0.9.12
10
-
11
- </title>
12
-
13
- <link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />
14
-
15
- <link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
16
-
17
- <script type="text/javascript" charset="utf-8">
18
- pathId = "Crapi";
19
- relpath = '';
20
- </script>
21
-
22
-
23
- <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
24
-
25
- <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
26
-
27
-
28
- </head>
29
- <body>
30
- <div class="nav_wrap">
31
- <iframe id="nav" src="class_list.html?1"></iframe>
32
- <div id="resizer"></div>
33
- </div>
34
-
35
- <div id="main" tabindex="-1">
36
- <div id="header">
37
- <div id="menu">
38
-
39
- <a href="_index.html">Index (C)</a> &raquo;
40
-
41
-
42
- <span class="title">Crapi</span>
43
-
44
- </div>
45
-
46
- <div id="search">
47
-
48
- <a class="full_list_link" id="class_list_link"
49
- href="class_list.html">
50
-
51
- <svg width="24" height="24">
52
- <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
53
- <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
54
- <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
55
- </svg>
56
- </a>
57
-
58
- </div>
59
- <div class="clear"></div>
60
- </div>
61
-
62
- <div id="content"><h1>Module: Crapi
63
-
64
-
65
-
66
- </h1>
67
- <div class="box_info">
68
-
69
-
70
-
71
-
72
-
73
-
74
-
75
-
76
-
77
-
78
-
79
- <dl>
80
- <dt>Defined in:</dt>
81
- <dd>lib/crapi/version.rb<span class="defines">,<br />
82
- lib/crapi.rb,<br /> lib/crapi/proxy.rb,<br /> lib/crapi/client.rb,<br /> lib/crapi/errors.rb</span>
83
- </dd>
84
- </dl>
85
-
86
- </div>
87
-
88
- <h2>Overview</h2><div class="docstring">
89
- <div class="discussion">
90
-
91
- <p>The Crapi module houses the <span class='object_link'><a href="Crapi/Client.html" title="Crapi::Client (class)">Crapi::Client</a></span> and <span class='object_link'><a href="Crapi/Proxy.html" title="Crapi::Proxy (class)">Crapi::Proxy</a></span> classes in this gem.</p>
92
-
93
-
94
- </div>
95
- </div>
96
- <div class="tags">
97
-
98
-
99
- </div><h2>Defined Under Namespace</h2>
100
- <p class="children">
101
-
102
-
103
-
104
-
105
- <strong class="classes">Classes:</strong> <span class='object_link'><a href="Crapi/ArgumentError.html" title="Crapi::ArgumentError (class)">ArgumentError</a></span>, <span class='object_link'><a href="Crapi/BadHttpResponseError.html" title="Crapi::BadHttpResponseError (class)">BadHttpResponseError</a></span>, <span class='object_link'><a href="Crapi/Client.html" title="Crapi::Client (class)">Client</a></span>, <span class='object_link'><a href="Crapi/Error.html" title="Crapi::Error (class)">Error</a></span>, <span class='object_link'><a href="Crapi/Proxy.html" title="Crapi::Proxy (class)">Proxy</a></span>
106
-
107
-
108
- </p>
109
-
110
- <h2>Constant Summary</h2>
111
- <dl class="constants">
112
-
113
- <dt id="VERSION-constant" class="">VERSION =
114
- <div class="docstring">
115
- <div class="discussion">
116
-
117
- <p>The canonical <strong>crapi</strong> gem version.</p>
118
-
119
- <p>This should only ever be updated <em>immediately</em> before a release; the
120
- commit that updates this value should be pushed <strong>by</strong> the
121
- <code>rake release</code> process.</p>
122
-
123
-
124
- </div>
125
- </div>
126
- <div class="tags">
127
-
128
-
129
- </div>
130
- </dt>
131
- <dd><pre class="code"><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>0.1.3</span><span class='tstring_end'>&#39;</span></span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</span></pre></dd>
132
-
133
- </dl>
134
-
135
-
136
-
137
-
138
-
139
-
140
-
141
-
142
-
143
- </div>
144
-
145
- <div id="footer">
146
- Generated on Wed May 30 16:20:53 2018 by
147
- <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
148
- 0.9.12 (ruby-2.5.1).
149
- </div>
150
-
151
- </div>
152
- </body>
153
- </html>