rails-rapido 0.7.0 → 0.9.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,3 @@
1
1
  module Rapido
2
- VERSION = '0.7.0'
2
+ VERSION = '0.9.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-rapido
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.9.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Kirst
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-06-21 00:00:00.000000000 Z
11
+ date: 2021-02-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -56,18 +56,10 @@ files:
56
56
  - LICENSE
57
57
  - README.md
58
58
  - Rakefile
59
- - app/views/rapido/app/edit.slim
60
- - app/views/rapido/app/index.slim
61
- - app/views/rapido/app/new.slim
62
- - app/views/rapido/app/show.slim
63
59
  - bin/console
64
60
  - bin/setup
65
61
  - lib/rapido.rb
66
62
  - lib/rapido/api_controller.rb
67
- - lib/rapido/app_controller.rb
68
- - lib/rapido/app_record_not_found.rb
69
- - lib/rapido/auth.rb
70
- - lib/rapido/auth/api_key.rb
71
63
  - lib/rapido/controller.rb
72
64
  - lib/rapido/errors.rb
73
65
  - lib/rapido/version.rb
@@ -91,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
91
83
  - !ruby/object:Gem::Version
92
84
  version: '0'
93
85
  requirements: []
94
- rubygems_version: 3.0.3
86
+ rubygems_version: 3.1.4
95
87
  signing_key:
96
88
  specification_version: 4
97
89
  summary: Rails API Dryer-o
@@ -1,4 +0,0 @@
1
- = simple_form_for([@owner, @resource].compact) do |f|
2
- - @resource_permitted_params.each do |param|
3
- = f.input param
4
- = f.submit "Save"
@@ -1,13 +0,0 @@
1
- h2= [@owner&.name, @resource_class.name.capitalize.pluralize].compact.join(" ")
2
- = link_to "New #{@resource_class.name.capitalize}", @new_path
3
- table
4
- thead
5
- tr
6
- - @resource_permitted_params.each do |key|
7
- th= key.to_s.capitalize
8
- - @resource_collection.each do |resource|
9
- tr
10
- td= link_to resource.name, url_for([@owner, resource].compact)
11
- - @resource_permitted_params.each do |key|
12
- - next if key == "name"
13
- td= resource[key]
@@ -1,5 +0,0 @@
1
- h1 New #{@resource.class.name}
2
- = simple_form_for([@owner, @resource].compact) do |f|
3
- - @resource_permitted_params.each do |param|
4
- = f.input param
5
- = f.submit "Save"
@@ -1,13 +0,0 @@
1
- h2= @resource.name
2
-
3
- = link_to "Edit", url_for([:edit, @owner, @resource].compact)
4
- = link_to "Delete", url_for([@owner, @resource].compact), method: :delete
5
- = link_to "Back", controller: params[:controller], action: "index"
6
-
7
- dl
8
- - @resource_permitted_params.each do |key, value|
9
- dt= key
10
- dd= value
11
-
12
- - owned_resources.each do |owned_resource|
13
- = link_to "View #{owned_resource.to_s.pluralize.capitalize}", url_for([nil, @owner, @resource, owned_resource].compact)
@@ -1,124 +0,0 @@
1
- require 'active_support'
2
- require 'active_support/core_ext'
3
- require 'rapido/errors'
4
-
5
- module Rapido
6
- module AppController
7
- extend ActiveSupport::Concern
8
- include Rapido::Errors
9
-
10
- included do
11
- Rails.logger.info 'The AppController has been deprecated and will be removed in the v1.0 release.'
12
- before_action do
13
- resource_permitted_params
14
- end
15
- helper_method :owned_resources
16
- end
17
-
18
- def index
19
- @resource_collection = resource_collection
20
- end
21
-
22
- def show
23
- @resource = resource
24
- end
25
-
26
- def new
27
- @resource = build_resource
28
- end
29
-
30
- def create
31
- new_resource = build_resource(resource_params)
32
- if new_resource.save
33
- after_create_success(new_resource)
34
- return if performed?
35
- redirect_to after_create_path(new_resource)
36
- else
37
- flash[:error] = new_resource.errors.full_messages.join('. ')
38
- after_create_failure(new_resource)
39
- return if performed?
40
- redirect_to new_path
41
- end
42
- end
43
-
44
- def destroy
45
- unless resource.destroy
46
- flash[:error] = resource.errors.full_messages.join('. ')
47
- end
48
- after_destroy_success(resource)
49
- return if performed?
50
- redirect_to after_delete_path(resource)
51
- end
52
-
53
- def edit
54
- @resource = resource
55
- end
56
-
57
- def update
58
- resource.assign_attributes(resource_params)
59
- if resource.save
60
- after_update_success(resource)
61
- return if performed?
62
- redirect_to after_update_path(resource)
63
- else
64
- flash[:error] = resource.errors.full_messages.join('. ')
65
- resource.reload
66
- after_update_failure(resource)
67
- return if performed?
68
- redirect_to edit_path(resource)
69
- end
70
- end
71
-
72
- private
73
-
74
- def after_create_success(*)
75
- end
76
-
77
- def after_create_failure(*)
78
- end
79
-
80
- def after_update_success(*)
81
- end
82
-
83
- def after_update_failure(*)
84
- end
85
-
86
- def after_destroy_success(*)
87
- end
88
-
89
- def resource_path(action, resource = nil)
90
- keys = { controller: params[:controller], action: action }
91
- keys[resource_lookup_param] = resource.send(resource_lookup_param) if resource
92
- keys[owner_lookup_param] = owner.send(owner_lookup_field) if owner_lookup_param.present?
93
- url_for(keys)
94
- end
95
-
96
- def edit_path(resource)
97
- @edit_path ||= resource_path(:edit, resource)
98
- end
99
-
100
- def show_path(resource)
101
- @show_path ||= resource_path(:show, resource)
102
- end
103
-
104
- def new_path
105
- @new_path ||= resource_path(:new)
106
- end
107
-
108
- def index_path
109
- @index_path ||= resource_path(:index)
110
- end
111
-
112
- def after_create_path(resource)
113
- show_path(resource)
114
- end
115
-
116
- def after_update_path(resource)
117
- show_path(resource)
118
- end
119
-
120
- def after_delete_path(*)
121
- index_path
122
- end
123
- end
124
- end
@@ -1,12 +0,0 @@
1
- module Rapido
2
- module AppRecordNotFound
3
- extend ActiveSupport::Concern
4
- include Rapido::Errors
5
-
6
- included do
7
- rescue_from RecordNotFound do |e|
8
- render file: 'public/404', status: :not_found, layout: false
9
- end
10
- end
11
- end
12
- end
data/lib/rapido/auth.rb DELETED
@@ -1,4 +0,0 @@
1
- module Rapido
2
- module Auth
3
- end
4
- end
@@ -1,42 +0,0 @@
1
- module Rapido
2
- module Auth
3
- module ApiKey
4
- extend ActiveSupport::Concern
5
-
6
- included do
7
- Rails.logger.info 'The Auth module has been deprecated and will be removed in the 1.0 release.'
8
- before_action :load_authority
9
-
10
- rescue_from LackAuthority do |e|
11
- render json: { error: 'Request denied.' }, status: 401
12
- end
13
- end
14
-
15
- def authority_class
16
- @authority_class ||=
17
- Rapido.configuration.authority_class.to_s.camelize.constantize
18
- end
19
-
20
- def authority_lookup_param
21
- @authority_lookup_param ||=
22
- Rapido.configuration.authority_lookup_param
23
- end
24
-
25
- def authority_lookup_field
26
- @authority_lookup_field ||=
27
- Rapido.configuration.authority_lookup_field
28
- end
29
-
30
- def load_authority
31
- @authority = authority_class.find_by(authority_lookup_field => params[authority_lookup_param])
32
- raise LackAuthority unless @authority
33
- end
34
-
35
- def authority
36
- @authority
37
- end
38
-
39
- class LackAuthority < StandardError; end
40
- end
41
- end
42
- end