crapi 0.1.2 → 0.1.3

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: 2ffc82957409a8df0940450867c2a1325f21819f07fe90e8f3c50920fa5b18d3
4
- data.tar.gz: bc596d700607f8409166acf07dcc88c30d21e49eb70b2fdf8758be868c70a3a1
3
+ metadata.gz: 526054c0e4505c430bcc3d63e726e679d611a14c6523b007b2d55e73ed5e6cb5
4
+ data.tar.gz: 69fbccd69cee1dc78d25620bffa29e39443e04025177da5bd80f5663de7bdbde
5
5
  SHA512:
6
- metadata.gz: 0ed50ee3802edc54336af81f71502b602960c7608ca2b540919ab8a9255c94f8fe77abe1e9ee28ac045ee864c47ce14dacf5bab068231050999bfa366b3c8ec1
7
- data.tar.gz: f551f92822f103927b9c47387c2fbebf2bb1fc9f74a23ea5761aa8a127ac470c299e7c5fb7e817231518969083b960e524f346317870c9cfa5cde7f9672cbbfe
6
+ metadata.gz: f149b73275cb33895908b1f01fcd00d1bd6031897563bd9d209286a7d01b06b66689ed518551c9b783140f49928bc02dfa11ca74ddbea21ad1d4d412e9ad9139
7
+ data.tar.gz: 7a3d54904295924ae1bd7d04e97788de460a2b8ffdd3324bc3da074885baded829fd759bc797e0c150f500ddb5fb792eced8c5ec28d772403b69f808a955285b
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- crapi (0.1.2)
4
+ crapi (0.1.3)
5
5
  activesupport (~> 5.2.0)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -1,8 +1,11 @@
1
- # Crapi
1
+ # Crapi [![Gem Version](https://badge.fury.io/rb/crapi.svg)](https://badge.fury.io/rb/crapi)
2
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/crapi`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ Crapi is yet another API wrapper. Yes, there is no shortage of these out there, but no other API wrapper gem (that I could find) provided the kind of functionality you get from the Crapi::Proxy class, which is really the biggest benefit here.
4
+
5
+ **Crapi::Client** will connect to the target system and handily provides a base path for you (becaue some APIs and services have a path that is always part of every request), **Crapi::Proxy** lets you add to the root client's base path or default set of headers without having to create any new connections.
6
+
7
+ Why "crapi"? Because it's a <u>CR</u>UD <u>API</u> client, and (honestly) "... It could be better."™️
4
8
 
5
- TODO: Delete this and the text above, and describe your gem
6
9
 
7
10
  ## Installation
8
11
 
@@ -20,19 +23,84 @@ Or install it yourself as:
20
23
 
21
24
  $ gem install crapi
22
25
 
23
- ## Usage
24
26
 
25
- TODO: Write usage instructions here
27
+ ## Using The Crapi Tools
26
28
 
27
- ## Development
29
+ ### Client Usage
30
+
31
+ ```ruby
32
+ ## Connect to an API.
33
+
34
+ api = Crapi::Client.new('https://jsonplaceholder.typicode.com/')
35
+
36
+
37
+ ## Issue requests against the API.
38
+
39
+ api.get('users/1') ## GETs /users/1; returns a Hash.
40
+
41
+ api.get('posts', query: { userId: 2 }) ## GETs /posts?userId=2; returns an Array.
42
+
43
+ mew_comment = { user: 'megapwner', text: 'FRIST!!1!' }
44
+ api.post('comments', payload: new_comment) ## POSTs to /comments; returns a Hash.
45
+ ```
46
+
47
+ ---
48
+
49
+ ### Proxy Usage
50
+
51
+ ```ruby
52
+ ## Connect to an API.
53
+
54
+ api = Crapi::Client.new('https://versioned.fake-api.com/api/')
55
+
56
+
57
+ ## Back in the v1 days, versioning of this API was via the URL ...
58
+
59
+ v1 = api.new_proxy('/v1')
60
+
61
+ v1.get('data') ## GETs /api/v1/data; pretty straight-forward.
62
+ v1.post('data', payload: values) ## POSTs *values* to /api/v1/data.
28
63
 
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
64
 
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 tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
65
+ ## For API v2, they switched to an Accept header approach ...
66
+
67
+ v2 = api.new_proxy('/', headers: { Accept: 'application/vnd.fake-api.v2+json' })
68
+
69
+ v2.get('data') ## GETs /api/data with the v2 header.
70
+
71
+
72
+ ## API v3 keeps the Accept header approach ...
73
+
74
+ v3 = api.new_proxy('/', headers: { Accept: 'application/vnd.fake-api.v3+json' })
75
+
76
+ v3.get('data') ## GETs /api/data with the v3 header.
77
+
78
+
79
+ ## Note that only one connection to the client is made and you can easily make
80
+ ## v1, v2, and v3 API calls ad hoc without having to juggle paths/headers yourself.
81
+ ```
82
+
83
+ ---
84
+
85
+ [Consult the repo docs for the full Crapi documentation.](http://nestor-custodio.github.io/crapi/Crapi.html)
86
+
87
+
88
+ ## Feature Roadmap / Future Development
89
+
90
+ Additional features/options coming in the future:
91
+
92
+ - Cleaner handling of non-body-returning calls.
93
+ - More resilient serializing of non-String paylods when using custom Content-Type headers.
94
+
95
+
96
+ ## Contribution / Development
97
+
98
+ Bug reports and pull requests are welcome on GitHub at https://github.com/nestor-custodio/crapi.
99
+
100
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
32
101
 
33
- ## Contributing
102
+ Linting is courtesy of [Rubocop](https://github.com/bbatsov/rubocop) and documentation is built using [Yard](https://yardoc.org/). Neither is included in the Gemspec; you'll need to install these locally (`gem install rubocop yard`) to take advantage.
34
103
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/crapi.
36
104
 
37
105
  ## License
38
106
 
@@ -0,0 +1,153 @@
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>
@@ -0,0 +1,143 @@
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
+ Exception: Crapi::ArgumentError
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::ArgumentError";
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 (A)</a> &raquo;
40
+ <span class='title'><span class='object_link'><a href="../Crapi.html" title="Crapi (module)">Crapi</a></span></span>
41
+ &raquo;
42
+ <span class="title">ArgumentError</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>Exception: Crapi::ArgumentError
63
+
64
+
65
+
66
+ </h1>
67
+ <div class="box_info">
68
+
69
+ <dl>
70
+ <dt>Inherits:</dt>
71
+ <dd>
72
+ <span class="inheritName"><span class='object_link'><a href="Error.html" title="Crapi::Error (class)">Error</a></span></span>
73
+
74
+ <ul class="fullTree">
75
+ <li>Object</li>
76
+
77
+ <li class="next">StandardError</li>
78
+
79
+ <li class="next"><span class='object_link'><a href="Error.html" title="Crapi::Error (class)">Error</a></span></li>
80
+
81
+ <li class="next">Crapi::ArgumentError</li>
82
+
83
+ </ul>
84
+ <a href="#" class="inheritanceTree">show all</a>
85
+
86
+ </dd>
87
+ </dl>
88
+
89
+
90
+
91
+
92
+
93
+
94
+
95
+
96
+
97
+
98
+
99
+ <dl>
100
+ <dt>Defined in:</dt>
101
+ <dd>lib/crapi/errors.rb</dd>
102
+ </dl>
103
+
104
+ </div>
105
+
106
+ <h2>Overview</h2><div class="docstring">
107
+ <div class="discussion">
108
+
109
+ <p>An error relating to missing, invalid, or incompatible method arguments.</p>
110
+
111
+
112
+ </div>
113
+ </div>
114
+ <div class="tags">
115
+
116
+
117
+ </div>
118
+
119
+
120
+
121
+
122
+
123
+
124
+
125
+
126
+
127
+
128
+
129
+
130
+
131
+
132
+
133
+ </div>
134
+
135
+ <div id="footer">
136
+ Generated on Wed May 30 11:27:03 2018 by
137
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
138
+ 0.9.12 (ruby-2.5.1).
139
+ </div>
140
+
141
+ </div>
142
+ </body>
143
+ </html>
@@ -0,0 +1,143 @@
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
+ Exception: Crapi::BadHttpResponseError
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::BadHttpResponseError";
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 (B)</a> &raquo;
40
+ <span class='title'><span class='object_link'><a href="../Crapi.html" title="Crapi (module)">Crapi</a></span></span>
41
+ &raquo;
42
+ <span class="title">BadHttpResponseError</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>Exception: Crapi::BadHttpResponseError
63
+
64
+
65
+
66
+ </h1>
67
+ <div class="box_info">
68
+
69
+ <dl>
70
+ <dt>Inherits:</dt>
71
+ <dd>
72
+ <span class="inheritName"><span class='object_link'><a href="Error.html" title="Crapi::Error (class)">Error</a></span></span>
73
+
74
+ <ul class="fullTree">
75
+ <li>Object</li>
76
+
77
+ <li class="next">StandardError</li>
78
+
79
+ <li class="next"><span class='object_link'><a href="Error.html" title="Crapi::Error (class)">Error</a></span></li>
80
+
81
+ <li class="next">Crapi::BadHttpResponseError</li>
82
+
83
+ </ul>
84
+ <a href="#" class="inheritanceTree">show all</a>
85
+
86
+ </dd>
87
+ </dl>
88
+
89
+
90
+
91
+
92
+
93
+
94
+
95
+
96
+
97
+
98
+
99
+ <dl>
100
+ <dt>Defined in:</dt>
101
+ <dd>lib/crapi/errors.rb</dd>
102
+ </dl>
103
+
104
+ </div>
105
+
106
+ <h2>Overview</h2><div class="docstring">
107
+ <div class="discussion">
108
+
109
+ <p>An error relating to a 4XX/5XX HTTP response code.</p>
110
+
111
+
112
+ </div>
113
+ </div>
114
+ <div class="tags">
115
+
116
+
117
+ </div>
118
+
119
+
120
+
121
+
122
+
123
+
124
+
125
+
126
+
127
+
128
+
129
+
130
+
131
+
132
+
133
+ </div>
134
+
135
+ <div id="footer">
136
+ Generated on Wed May 30 11:27:03 2018 by
137
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
138
+ 0.9.12 (ruby-2.5.1).
139
+ </div>
140
+
141
+ </div>
142
+ </body>
143
+ </html>