fictium 0.3.2 → 0.3.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 +4 -4
- data/CHANGELOG.md +8 -0
- data/Gemfile.lock +1 -1
- data/lib/fictium/rspec/autocomplete/action.rb +1 -16
- data/lib/fictium/rspec/autocomplete/params.rb +22 -0
- data/lib/fictium/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6d68f0182b847a3713bd7891b4e63273ffa7a79759fea9f3081d7b840ed693a3
|
4
|
+
data.tar.gz: 91b28c80cc8291ccc7474fb4d643a5c12119742886e737eee6a0af8e4f7d7de4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 925a29a49dc0dc7ba6987e9970e500d90d327869709ad7c5134a416f71404b685219c954359acd4d5ca3e8bfb584d205dd74826cfbc7059919175c00895fa54e
|
7
|
+
data.tar.gz: f68a1b545102693083580f8cdc2542f8ddf846b0846d123bf7147ebd8dc504a0896938fee6956df6ed5b3d86ef8b92029b83477f87b6149b2646193a9cfabf30
|
data/CHANGELOG.md
CHANGED
@@ -17,6 +17,14 @@
|
|
17
17
|
|
18
18
|
## LOG
|
19
19
|
|
20
|
+
### 0.3.3 (2019-11-12)
|
21
|
+
|
22
|
+
Improve path recognition using controller actions.
|
23
|
+
|
24
|
+
#### Changes
|
25
|
+
|
26
|
+
- Use path parameters instead of formatting path.
|
27
|
+
|
20
28
|
### 0.3.2 (2019-11-12)
|
21
29
|
|
22
30
|
Use path parameters instead of formatting path.
|
data/Gemfile.lock
CHANGED
@@ -3,19 +3,11 @@ module Fictium
|
|
3
3
|
module Autocomplete
|
4
4
|
module Action
|
5
5
|
ACTION_NAME = /#([A-Z_]+)/i.freeze
|
6
|
-
|
7
|
-
index: '',
|
8
|
-
create: '',
|
9
|
-
new: '/new',
|
10
|
-
show: '/{id}',
|
11
|
-
update: '/{id}',
|
12
|
-
destroy: '/{id}'
|
13
|
-
}.freeze
|
6
|
+
|
14
7
|
class << self
|
15
8
|
def description_attributes(action, description)
|
16
9
|
name = find_action_name(description)&.downcase
|
17
10
|
find_summary(action, name)
|
18
|
-
find_path(action, name)
|
19
11
|
end
|
20
12
|
|
21
13
|
private
|
@@ -34,13 +26,6 @@ module Fictium
|
|
34
26
|
@descriptors ||= Fictium.configuration.default_action_descriptors || {}
|
35
27
|
end
|
36
28
|
|
37
|
-
def find_path(action, name)
|
38
|
-
return if name.blank?
|
39
|
-
|
40
|
-
key = name.to_sym
|
41
|
-
action.path = DEFAULT_PATHS[key] || "/{id}/#{name}"
|
42
|
-
end
|
43
|
-
|
44
29
|
def find_action_name(description)
|
45
30
|
match = description.match(ACTION_NAME)
|
46
31
|
match.presence && match[1]
|
@@ -6,7 +6,10 @@ module Fictium
|
|
6
6
|
IGNORED_PATH_PARAMETERS = %i[action controller].freeze
|
7
7
|
|
8
8
|
class << self
|
9
|
+
include Rails.application.routes.url_helpers
|
10
|
+
|
9
11
|
def extract_from_request(action, request)
|
12
|
+
extract_path(action, request)
|
10
13
|
REQUEST_SECTIONS.each do |section|
|
11
14
|
action.params[section] ||= ActiveSupport::HashWithIndifferentAccess.new
|
12
15
|
send(:"parse_request_#{section}", action.params[section], action, request)
|
@@ -27,6 +30,25 @@ module Fictium
|
|
27
30
|
|
28
31
|
private
|
29
32
|
|
33
|
+
def extract_path(action, request)
|
34
|
+
return unless action.path.nil?
|
35
|
+
|
36
|
+
mapped_controllers = transform_path(request)
|
37
|
+
full_path = CGI.unescape(url_for(**mapped_controllers.merge(only_path: true)))
|
38
|
+
action.path = full_path.sub(action.resource.base_path || '', '')
|
39
|
+
end
|
40
|
+
|
41
|
+
def transform_path(request)
|
42
|
+
{}.tap do |result|
|
43
|
+
request.path_parameters.except(*IGNORED_PATH_PARAMETERS).each do |key, _|
|
44
|
+
result[key] = "{#{key}}"
|
45
|
+
end
|
46
|
+
request.path_parameters.slice(*IGNORED_PATH_PARAMETERS).each do |key, value|
|
47
|
+
result[key] = value
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
30
52
|
def parse_request_query(params, _action, request)
|
31
53
|
request.query_parameters.each do |key, value|
|
32
54
|
params[key] ||= {}
|
data/lib/fictium/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fictium
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ramiro Rojo
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-11-
|
11
|
+
date: 2019-11-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|