red-api 0.2.1 → 0.2.2

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: b953b6b0eb60428808e5e4e96bee115704ccb947e181d1ca00273607ee741a78
4
- data.tar.gz: c4658cbf00f844f698f46ab5a3c0e68816d67f82af29971a76914b8337a5d7a7
3
+ metadata.gz: d3137705ce3933690cf5048fc78576d68a7638499f8a9cdb18c59e83a7010fec
4
+ data.tar.gz: c01ba2e7a05de477e32e5441677b10f5f488fcd515d81897de746a358fe1fdd4
5
5
  SHA512:
6
- metadata.gz: f075a31f36be34e96985768565d8e3a49c1644c5c3562b5290374d9cf8ec714a3b0d1d1a01db2af96f9cd84dff08307d8eafa615d984b7c1068444face8f6cc8
7
- data.tar.gz: 3d6a8aaba3eb5448c479258d45ff3a0c9e9c1dfa136570c7923908c2915a5e8db5e2e25e0d29fa951d108d0837833d16bd051d7eec97df46cd10ca0cf396b222
6
+ metadata.gz: 48f9ed3cfc7b046bd5aab5b642322e42e86120905f474d76651aae224bad5fb1147024d445e23743de6bec8c66fee46b92bc29c33bbe700dfc20e070c7f2d87d
7
+ data.tar.gz: 74bb4846dab7e79cec7bc43da97f0d64bd4b0013fd18ff29ec328ac6adb657d25f01f1608867c61045694111e741e4b3ef13feaa93ef1e0b886adf318bf84e40
@@ -5,7 +5,7 @@ Description:
5
5
  Will copy the --method-params given to your endpoint helper method to use in your endpoint URI path
6
6
 
7
7
  Example:
8
- rails generate endpoint ServiceName version EndpointName /endpoint/#{param1}/#{param2} --method-params param1 param2 --include-helper-params
8
+ rails generate endpoint ServiceName version EndpointName --endpoint /endpoint/#{param1}/#{param2} --endpoint-params param1 param2 --include-helper-params
9
9
 
10
10
  Simple Form:
11
11
  rails generate endpoint ServiceName V1 EndpointName /endpoint
@@ -3,8 +3,8 @@ class EndpointGenerator < Rails::Generators::NamedBase
3
3
 
4
4
  argument :api_version, type: :string
5
5
  argument :endpoint_name, type: :string
6
- argument :endpoint, type: :string
7
6
 
7
+ class_option :endpoint, type: :string, default: '/'
8
8
  class_option :method, type: :string, default: 'get'
9
9
  class_option :endpoint_params, type: :array
10
10
  class_option :include_helper_params
@@ -13,15 +13,17 @@ class EndpointGenerator < Rails::Generators::NamedBase
13
13
  @api_service = file_name.underscore
14
14
  @api_version = api_version
15
15
  @endpoint_name = endpoint_name
16
- @endpoint = endpoint
16
+ @endpoint = options[:endpoint]
17
17
 
18
- raise ArgumentError 'Endpoint name required' unless @endpoint_name
19
- raise ArgumentError 'Endpoint is required' unless @endpoint
18
+ raise ArgumentError, 'Endpoint name required' unless @endpoint_name
19
+ raise ArgumentError, 'Version is required, e.g. V1' unless @api_version
20
+ raise ArgumentError, 'Version should not be included in your endpoint, generator will build it for you' if @endpoint.downcase.include?(@api_version.downcase)
20
21
 
21
22
  @endpoint_reference = @api_service.camelize + '::' + @api_version.camelize + '::ApiEndpoints'
22
23
  @full_endpoint_reference = @endpoint_reference + '.' + @endpoint_name.underscore
23
24
 
24
- @endpoint = @endpoint[1..] unless @endpoint.first != '/'
25
+ @endpoint = '/' + @endpoint unless @endpoint.first == '/'
26
+ @endpoint = @api_version.downcase + @endpoint
25
27
  @method = options[:method].to_sym
26
28
 
27
29
  create_endpoint_params if options[:endpoint_params].present?
@@ -2,17 +2,16 @@ class ServiceGenerator < Rails::Generators::NamedBase
2
2
  source_root File.expand_path('templates', __dir__)
3
3
 
4
4
  argument :version, type: :string
5
- argument :api_endpoint, type: :string
5
+ class_option :api_endpoint, type: :string, default: 'https://'
6
6
  class_option :key, type: :array
7
7
 
8
8
  def create_api_service
9
9
  @api_name = file_name
10
10
  @api_version = version
11
- @api_endpoint = api_endpoint
11
+ @api_endpoint = options[:api_endpoint]
12
12
  @env_var_opts = options[:key]
13
13
 
14
14
  raise ArgumentError, 'Need to give the API version' unless @api_version.present?
15
- raise ArgumentError, 'Need to give the API endpoint URI e.g. https://api/' unless @api_endpoint.present?
16
15
 
17
16
  @full_api_reference = @api_name.camelize + '::' + @api_version.upcase
18
17
  @api_endpoint = @api_endpoint + '/' unless @api_endpoint.last == '/'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: red-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard DeSilvey