ways-and-means 0.0.2 → 0.0.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.
@@ -34,12 +34,12 @@ module Sinatra
|
|
34
34
|
|
35
35
|
send dispatch[:verb], "/#{endpoint}" do
|
36
36
|
# before hooks before
|
37
|
-
['before_anyway', "before_#{dispatch[:to]}"].each { |hook| respond_to?(hook) && send(hook) }
|
37
|
+
['before_anyway', "before_#{dispatch[:to]}"].each { |hook| respond_to?(hook, true) && send(hook) }
|
38
38
|
send(dispatch[:to]).tap do
|
39
39
|
# after hooks in a tap, because i like tap
|
40
40
|
# Mmmh ? And yes, also because i need to maintain the return of the
|
41
41
|
# route call back as the return value of the route
|
42
|
-
['after_anyway', "after_#{dispatch[:to]}"].each { |hook| respond_to?(hook) && send(hook) }
|
42
|
+
['after_anyway', "after_#{dispatch[:to]}"].each { |hook| respond_to?(hook, true) && send(hook) }
|
43
43
|
end
|
44
44
|
end
|
45
45
|
end
|
@@ -82,7 +82,7 @@ module Sinatra
|
|
82
82
|
# show_person
|
83
83
|
# end
|
84
84
|
else
|
85
|
-
yield endpoint, { verb: 'get', to: (dispatch || endpoint) }
|
85
|
+
yield endpoint, { verb: 'get', to: (dispatch || rationalize(endpoint)) }
|
86
86
|
end
|
87
87
|
end
|
88
88
|
end
|
@@ -117,6 +117,11 @@ module Sinatra
|
|
117
117
|
@config ||= YAML.load(open(File.join('config', 'ways-and-means.yml'))) rescue nil
|
118
118
|
end
|
119
119
|
|
120
|
+
def rationalize(endpoint)
|
121
|
+
# rationalized... but not too clever though.
|
122
|
+
endpoint.to_s.gsub('/', '_').gsub(/[^A-Za-z0-9_]/, '').gsub('_id', '').gsub(/_$/, '')
|
123
|
+
end
|
124
|
+
|
120
125
|
end
|
121
126
|
|
122
127
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ways-and-means
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-01-
|
12
|
+
date: 2013-01-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sinatra
|