bubbles-rest-client 0.3.1 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d85396895955c45173bf56e4f7efb61a841bceb90c0d4f3348f99fcb0271e7a0
4
- data.tar.gz: c7147c2c317a496d577a63f19f7fe4a398997b9bb6d8b3084585f7da6f93da3c
3
+ metadata.gz: 0e98610b1755842e9daf75e52a69e406f76ee3726c5b1d5b7094b519a289a8dd
4
+ data.tar.gz: eef0efcad84ca786a3e425c3251020f54539015ed199b4ccf00d5aaa7acc8e60
5
5
  SHA512:
6
- metadata.gz: '076759218897e4bac3955b296fa5a0eabb58fb826c5e51c063da34f39d659f7fa2c61d85e8ae064fa5dd46c88a7d3b33baad513bff1951ea629fa30de2c9091e'
7
- data.tar.gz: b84b861758a6bd7b44ae4f4153da1467fb6cd5e69b2846450088b7946af21539efe20d9fb3b80f136aa6f0f40cd6f58e5ca5fab3e2cd6fe2f7af8a75a38e8bb4
6
+ metadata.gz: d57f7ef6b948deec157e1109e17912c0fb923d4bc21626d6df2a91d4958c7cb0ac60c377507f27b3c142a88d09bc09e6e391f9ec8c9ebbe08566fca5c9ba76ce
7
+ data.tar.gz: 6649af7c90e05d2260bc7fd51ba26c43693b09f9a1e38df18483f78873f761e7261ab13f7fe615909e5da66a299b13eb1830dee3663e6f7bdc881265e72ab374
@@ -0,0 +1 @@
1
+ github: jwir3
data/.gitignore CHANGED
@@ -43,3 +43,6 @@
43
43
 
44
44
  # Ignore RubyMine files
45
45
  .idea/**
46
+
47
+ # Ignore Gemfile.lock because this is a gem
48
+ Gemfile.lock
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.6.1
4
+ script: bundle exec rake spec
5
+ branches:
6
+ only:
7
+ - master
@@ -0,0 +1,77 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers of Bubbles pledge to making participation in our
7
+ project and our community a harassment-free experience for everyone,
8
+ regardless of age, body size, disability, ethnicity, sex characteristics,
9
+ gender identity and expression, level of experience, education,
10
+ socio-economic status, nationality, personal appearance, race, religion,
11
+ or sexual identity and orientation.
12
+
13
+ ## Our Standards
14
+
15
+ Examples of behavior that contributes to creating a positive environment
16
+ include:
17
+
18
+ * Using welcoming and inclusive language
19
+ * Being respectful of differing viewpoints and experiences
20
+ * Gracefully accepting constructive criticism
21
+ * Focusing on what is best for the community and users
22
+ * Showing empathy towards other community members
23
+
24
+ Examples of unacceptable behavior by participants include:
25
+
26
+ * The use of sexualized language or imagery and unwelcome sexual attention or
27
+ advances
28
+ * Trolling, insulting/derogatory comments, and personal or political attacks
29
+ * Public or private harassment
30
+ * Publishing others' private information, such as a physical or electronic
31
+ address, without explicit permission
32
+ * Other conduct which could reasonably be considered inappropriate in a
33
+ professional setting
34
+
35
+ ## Our Responsibilities
36
+
37
+ Project maintainers are responsible for clarifying the standards of acceptable
38
+ behavior and are expected to take appropriate and fair corrective action in
39
+ response to any instances of unacceptable behavior.
40
+
41
+ Project maintainers have the right and responsibility to remove, edit, or
42
+ reject comments, commits, code, wiki edits, issues, and other contributions
43
+ that are not aligned to this Code of Conduct, or to ban temporarily or
44
+ permanently any contributor for other behaviors that they deem inappropriate,
45
+ threatening, offensive, or harmful.
46
+
47
+ ## Scope
48
+
49
+ This Code of Conduct applies both within project spaces and in public spaces
50
+ when an individual is representing the project or its community. Examples of
51
+ representing a project or community include using an official project e-mail
52
+ address, posting via an official social media account, or acting as an appointed
53
+ representative at an online or offline event. Representation of a project may be
54
+ further defined and clarified by project maintainers.
55
+
56
+ ## Enforcement
57
+
58
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
59
+ reported by contacting Scott Johnson, our project lead, at jaywir3@gmail.com. All
60
+ complaints will be reviewed and investigated and will result in a response that
61
+ is deemed necessary and appropriate to the circumstances. The project leadership
62
+ team is obligated to maintain confidentiality with regard to the reporter of an
63
+ incident. Further details of specific enforcement policies may be posted separately.
64
+
65
+ Project maintainers who do not follow or enforce the Code of Conduct in good
66
+ faith may face temporary or permanent repercussions as determined by other
67
+ members of the project's leadership.
68
+
69
+ ## Attribution
70
+
71
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
72
+ available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
73
+
74
+ [homepage]: https://www.contributor-covenant.org
75
+
76
+ For answers to common questions about this code of conduct, see
77
+ https://www.contributor-covenant.org/faq
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,31 @@
1
+ # Contributing to Bubbles
2
+
3
+ ## Introduction
4
+ First off, thanks for looking to contribute to Bubbles! We need people like you
5
+ to help us make the best quality product we possibly can. Regardless of whether
6
+ you're a developer, a designer, a technical writer, a student, or even someone
7
+ just interested in learning more about open source and how to contribute, you're
8
+ welcome here.
9
+
10
+ ## Code of Conduct
11
+ Please take a look at our contributor [Code of Conduct](CODE_OF_CONDUCT.md). We
12
+ take harassment and non-inclusive behavior very seriously and will not tolerate
13
+ bullying in any form.
14
+
15
+ ## Development Process
16
+ Our development process works as follows:
17
+
18
+ 1. Fork this repository to your own local Github account.
19
+ 2. Clone your local version of the repository: `git clone git@github.com:<username>/bubbles`.
20
+ 3. Create a branch on your local repository: `git checkout -b <username>/#<issue>-<short-description>`.
21
+ 4. Make any changes you see fit to fix the issue or add your work.
22
+ 5. Verify that tests pass: `bundle install && rake spec`.
23
+ 6. If you're adding a new feature, make sure to add tests for the feature.
24
+ 7. Commit your changes and push to your fork of the repository.
25
+ 8. Submit a pull request to the `master` branch of the original repository.
26
+ 9. You will receive a review within 7 days, at which time, you may need to make
27
+ modifications to your code, or your contribution might be accepted as-is.
28
+
29
+ ## Good First Issues
30
+ You can take a look at our [good first issues](https://github.com/FoamFactory/bubbles/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22)
31
+ to check out some issues that might be a good starting point for you.
data/README.md CHANGED
@@ -1,4 +1,6 @@
1
1
  # bubbles
2
+ [![Build Status](https://travis-ci.org/FoamFactory/bubbles.svg?branch=master)](https://travis-ci.org/FoamFactory/bubbles)
3
+
2
4
  A gem for easily defining client REST interfaces in ruby
3
5
 
4
6
  ## Project Goals
@@ -23,17 +25,6 @@ What this does is allow you to focus on your _handling_ of the REST responses, r
23
25
 
24
26
  _bubbles_ is a Gem that seeks to provide this same behavior.
25
27
 
26
- ## :warning: Limitations
27
- **Please read this section before using!**
28
-
29
- Currently, bubbles has a number of limitations that make it likely not suitable for use in a production environment. Each of these is tracked by an issue on our [issues page](https://github.com/FoamFactory/bubbles/issues).
30
-
31
- - Passing an API key with a request is restricted to using `X-Api-Key` as a header key (#10).
32
- - Some request methods (specifically `DELETE`) do not currently allow unauthenticated access. In other words, it is not possible to perform a `DELETE` request on your API without passing an authorization token. (#16)
33
- - Not all possible combinations of `has_uri_params`, `authenticated`, and `api_key_required` are tested. In some cases, such as with `GET` requests, there aren't any tests for possible configuration cases that might cause issues when combined. (#12)
34
-
35
- If you're interested in working on any of the issues above, please feel free to submit a pull request and a member of our team will review that pull request within a couple of days.
36
-
37
28
  ## Usage
38
29
  If you're using Rails, it's suggested to have a `config/initializers/bubbles.rb` configuration file where you can easily configure your endpoints and environments. If you're not using Rails, then you can put this configuration just about anywhere, provided it's executed before where you want to use it.
39
30
 
@@ -52,20 +43,19 @@ Bubbles.configure do |config|
52
43
  }
53
44
  ]
54
45
 
55
- config.local_environment = {
46
+ config.environments = [{
56
47
  :scheme => 'http',
57
48
  :host => '0.0.0.0',
58
49
  :port => '1234'
59
- }
50
+ }]
60
51
  end
61
52
  ```
62
53
 
63
- The `config.endpoints` section is where you configure which endpoints you want to support. The `config.local_environment` defines an environment, or remote configuration, for accessing the endpoint on a specific remote destination.
54
+ The `config.endpoints` section is where you configure which endpoints you want to support. The `config.environments` defines the environments, or remote configurations, for accessing the endpoint on specific remote destinations.
64
55
 
65
56
  Now, you can use this endpoint with:
66
57
  ```ruby
67
58
  require 'bubbles'
68
-
69
59
  ...
70
60
 
71
61
  def version
@@ -73,105 +63,11 @@ def version
73
63
 
74
64
  # The following will make a GET request to
75
65
  # http://0.0.0.0:1234/version and return the result.
76
- result = resources.local_environment.version
66
+ result = resources.environment.version
77
67
 
78
68
  puts(result)
79
69
  end
80
70
  ```
81
71
 
82
72
  ## Detailed Documentation
83
- There are currently two parts to a bubbles configuration: the _environments_ and the _endpoints_. Bubbles is configured in a _bubbles configuration block_:
84
- ```ruby
85
- Bubbles.configure do |config|
86
- ...
87
- end
88
- ```
89
-
90
- This configuration block can be run at any time, but is typically set up in the initializer section of an app's startup. If desired, configuration can happen separately. That is, you can initialize environments within your initializer file and then initialize endpoints within another section of the application. Just note that when endpoints are defined, it overwrites _all_ endpoints of a configuration, not just the ones you choose to change.
91
-
92
- ### Environments
93
- Three environments are currently available to be set up within bubbles. These are:
94
- - `local_environment` : Designed to be used for a local API for development testing.
95
- - `staging_environment` : Designed to be used for a remote API for second-stage testing or production-like deployment.
96
- - `production_environment` : Designed to be used for a production environment.
97
-
98
- While the names are hardcoded, the environments can be used for anything - you could easily use a `local_environment` to store the information for one of your production servers.
99
-
100
- #### Configuration of Environments
101
- Environments are configured as part of the _bubbles configuration block_ and can have the following parameters:
102
-
103
- - `scheme`: The scheme for accessing endpoints on this host. Should be one of `http` or `https`. Defaults to `http`.
104
- - `host`: A domain name or IP address for the remote host to access for the environment. Defaults to `127.0.0.1`.
105
- - `port`: The port to use to access the remote host. Defaults to `1234`.
106
- - `api_key`: The API key to send along with requests for a given environment, if an API key is required. This is optional, and defaults to `nil`.
107
-
108
- You can configure all three environments at once in the _bubbles configuration block_:
109
- ```ruby
110
- Bubbles.configure do |config|
111
- config.local_environment = {
112
- :scheme => 'http',
113
- :host => '0.0.0.0',
114
- :port => '1234'
115
- }
116
-
117
- config.staging_environment = {
118
- :scheme => 'http',
119
- :host => 'stage.api.foamfactory.com',
120
- :port => '80'
121
- }
122
-
123
- config.production_environment = {
124
- :scheme => 'https',
125
- :host => 'api.foamfactory.com',
126
- :port => '443'
127
- }
128
- end
129
- ```
130
-
131
- If you choose a scheme of `http` and leave off the `port` configuration variable, it will default to `80`. Similarly, `https` will default to a port of `443`.
132
-
133
- #### Configuration of Endpoints
134
- Endpoints are the meat and potatoes of REST interaction. By indicating a _method_, _uri_, _body_, and _headers_, you are effectively making a function call on a remote server.
135
-
136
- _Endpoints_ are specified as an array of objects within the _bubbles configuration block_:
137
-
138
- ```ruby
139
- config.endpoints = [
140
- # Individual endpoint definitions go here
141
- ]
142
- ```
143
-
144
- When processing each of these endpoint definitions, a method is created on instances of `RestEnvironment` that allows you to call the method in question. For example, an endpoint defined as:
145
- ```ruby
146
- {
147
- :method => :get,
148
- :location => :version,
149
- :authenticated => false,
150
- :api_key_required => false
151
- }
152
- ```
153
-
154
- will create a method on instances of `RestEnvironment` called `version`, which will execute the appropriate REST call (via `RestClient`) and return a `RestClient::Response` object.
155
-
156
- Each _endpoint_ object can have the following attributes:
157
-
158
- | Name | Description | Required? | Default |
159
- | :--- | :------------------ | :-------: | :-----: |
160
- | `method`| The HTTP method to use to access the API for this endpoint. Must be one of `GET`, `POST`, `PUT`, `PATCH`, `DELETE`, or `HEAD`. | Yes | N/A |
161
- | `location`| The path to access the endpoint. This is placed after the `host:port` section to build the URI. It may have URI parameters in the form of `{paramName}`. If a URI parameter is specified within the `location`, a `uri_params` hash will be expected to be passed to the calling method to replace the placeholder values. | Yes | N/A |
162
- | `name` | The name to give the method created to make this REST call. | No | The value of the `location` parameter, with slashes (`/`) replaced with underscores (`_`). |
163
- | `authorization` | Whether or not this endpoint requires authentication prior to executing the call. If true, then an `authorization_token` will be added to the method as a parameter to be passed when the method is called. This parameter will be placed in an `Authorization` header when the REST call is executed. | No | `false` |
164
- | `api_key_required` | Whether or not an API key is required. If `true`, a parameter will be added to the method created to execute the REST API call named `api_key`. The value of this parameter will be set as the value of the `X-Api-Key` header when making the REST API call. | No | `false` |
165
- | `return_type` | Must be one of: `[full_response, body_as_object, body_as_string]`. This specifies what type of response is expected from the `Endpoint`. A value of `full_response` will return the full `RestClient::Response` object to the client. A value of `body_as_string` will return the `RestClient::Response.body` value as a `String`. A value of `body_as_object` will take the `RestClient::Response.body` parameter and parse it as an `OpenStruct` object, and return the result of this parsing operation. | No | `body_as_string` |
166
- | `encode_authorization` | Whether the `data` passed as part of the request should be re-encoded as an `Authorization: Basic` header (and Base64 encoded). Typically, this is only used for initial username/password authentication. | No | `false` |
167
-
168
- ### Examples
169
- #### GET the version of the software (unauthenticated, no API key required)
170
-
171
- #### GET a specific user by id (authentication required)
172
-
173
- #### POST a login (i.e. retrieve an authorization token)
174
-
175
- #### DELETE a user by id
176
-
177
- #### PATCH a user's information by providing a body containing information to update
73
+ For more examples and detailed documentation, please see [the Bubbles GitHub page](http://foamfactory.github.io/bubbles).
data/Rakefile CHANGED
@@ -1,10 +1,5 @@
1
1
  require "bundler/gem_tasks"
2
- require "rake/testtask"
3
2
 
4
- Rake::TestTask.new(:test) do |t|
5
- t.libs << "test"
6
- t.libs << "lib"
7
- t.test_files = FileList['test/**/*_test.rb']
8
- end
3
+ Dir.glob('lib/tasks/*.rake').each { |r| load r}
9
4
 
10
- task :default => :test
5
+ task :default => :build
data/bubbles.gemspec CHANGED
@@ -32,14 +32,15 @@ Gem::Specification.new do |spec|
32
32
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
33
33
  spec.require_paths = ["lib"]
34
34
 
35
- spec.add_development_dependency "bundler", "~> 2.0.0"
36
- spec.add_development_dependency "rake", "~> 10.0"
35
+ spec.add_development_dependency "bundler", "~> 2.2.26"
36
+ spec.add_development_dependency "rake", ">= 12.3.3"
37
37
  spec.add_development_dependency "minitest", "~> 5.0"
38
38
  spec.add_development_dependency "minitest-reporters", "~> 1.1"
39
39
  spec.add_development_dependency "simplecov", "~> 0.16"
40
40
  spec.add_development_dependency "webmock", "~> 3.5"
41
41
  spec.add_development_dependency "vcr", "~> 3.0"
42
42
  spec.add_development_dependency "rspec", "~> 3.8"
43
+ spec.add_development_dependency "os"
43
44
  spec.add_dependency "addressable", "~> 2.5"
44
45
  spec.add_dependency "rest-client", "~> 2.0"
45
- end
46
+ end