rest-api-generator 0.1.3 → 0.1.4

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: a3c84db27490fa76b76096f10ba351092bfb42479890a2a279d725f579c4edb7
4
- data.tar.gz: 25e537cd496a09eb3b5755fadf4d04bbcaad38c941bf54af60e230ed7a1ccd13
3
+ metadata.gz: 4873b5f52ba8ca76abbc7449e0c0398ee1d38fbfb47ebec80dabb293b3ca0cea
4
+ data.tar.gz: bd96d06619b7a14eb9e6b953d60bc6a2f84bb7d48b0cca5181c0a588bb066cba
5
5
  SHA512:
6
- metadata.gz: a0f07b832a6373ed5197f114a0bdc54c6a6c2088d712e3641b8d55d717a5d5b019bba3427907b73495ac6a97de2bfbdd68ee48de267651808cf3d6adbe9f2547
7
- data.tar.gz: 565c3cc7797794a6c59008990e58727173c5fa472ef8a8a188cb2a2ba60789cf03994ba8feaff7d8d5dfcf3443333412ece5dbb926f5a44156fa71ad240531b0
6
+ metadata.gz: 7cd7f1d823c9b0abba38301024eefb393eb460b10a0ff92e41b7f377b401f09f37771afd039701539fd697a4612e0b0a46ef99b6eccf81d118a23e5fff63bfbb
7
+ data.tar.gz: dbb337a4c098fdc2b04e71456b5664be8ca670fdd277436cf05111897a7f72ac0559bd47bacf840c6248406aae0e931506e00ad6f3715d9f22da4a9a30984b90
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rest-api-generator (0.1.3)
4
+ rest-api-generator (0.1.4)
5
5
  rails (>= 5.0)
6
6
 
7
7
  GEM
@@ -71,22 +71,24 @@ module RestApiGenerator
71
71
  def nested_routes
72
72
  return "" if options["father"].blank?
73
73
 
74
- "#{options["father"].downcase.pluralize}/\#{#{options["father"].singularize.downcase}.id}/#{plural_name}"
74
+ "#{options["father"].downcase.pluralize}/\#{#{options["father"].singularize.downcase}.id}"
75
75
  end
76
76
 
77
77
  def initial_route
78
- return "/#{plural_name}" if options["father"].blank? && options["scope"].blank?
79
-
80
- scope_route_path + "/" + nested_routes
78
+ route = ""
79
+ route += scope_route_path if options["scope"].present?
80
+ route += options["father"].present? && route.present? ? "/#{nested_routes}" : nested_routes
81
+ route += "/#{plural_name}"
82
+ route[0] == "/" ? route : "/#{route}"
81
83
  end
82
84
 
83
85
  def spec_routes
84
86
  {
85
87
  index: initial_route,
86
- show: initial_route + "\#{#{singular_name}.id}",
88
+ show: initial_route + "/\#{#{singular_name}.id}",
87
89
  create: initial_route,
88
- update: initial_route + "\#{#{singular_name}.id}",
89
- delete: initial_route + "\#{#{singular_name}.id}",
90
+ update: initial_route + "/\#{#{singular_name}.id}",
91
+ delete: initial_route + "/\#{#{singular_name}.id}",
90
92
  }
91
93
  end
92
94
  end
@@ -26,9 +26,9 @@ module RestApiGenerator
26
26
 
27
27
  def spec_controller_template
28
28
  if options["father"].present?
29
- "rspec/resource_controller_spec.rb"
30
- else
31
29
  "rspec/nested_resource_controller_spec.rb"
30
+ else
31
+ "rspec/resource_controller_spec.rb"
32
32
  end
33
33
  end
34
34
  end
@@ -25,7 +25,7 @@ module RestApiGenerator
25
25
  def nested_routes
26
26
  return "" if options["father"].blank?
27
27
 
28
- "#{options["father"].downcase.pluralize}/{#{options["father"].singularize.downcase}_id}/#{plural_name}"
28
+ "#{options["father"].downcase.pluralize}/{#{options["father"].singularize.downcase}_id}"
29
29
  end
30
30
 
31
31
  def spec_routes
@@ -38,7 +38,7 @@ RSpec.describe "<%= class_name %>", type: :request do
38
38
 
39
39
  describe "DELETE /<%= plural_name %>/:id" do
40
40
  it "deletes an <%= plural_name %>" do
41
- item = create(:<%= singular_name %>)
41
+ <%= singular_name %> = create(:<%= singular_name %>)
42
42
  expect do
43
43
  delete "<%= spec_routes[:delete] %>"
44
44
  end.to change(<%= class_name %>, :count).by(-1)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RestApiGenerator
4
- VERSION = "0.1.3"
4
+ VERSION = "0.1.4"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rest-api-generator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - PedroAugustoRamalhoDuarte