sharp 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/TUTORIAL.md +3 -3
- data/lib/sharp.rb +5 -3
- data/lib/sharp/version.rb +1 -1
- data/sharp.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 56a3c1b04900e2eac73293a6154091656f396064
|
4
|
+
data.tar.gz: d205ccaa90533b6cb4172acb4da134d80cd5bbc8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f0053271cadaefdc097eac457834f5f87748c4bca1425fcbdc11ed462b86c628170a95d5babca035f5f541e0defcc84e63bde016d38e95dad1f091a5d2f171d6
|
7
|
+
data.tar.gz: 546ada98108d2cced8007707b6676f15fd120ea6171be1937b15c2cfb888c96cd269a4994b35bdaac0d4aa39e26a65f21a89a31d822af665e055645988bf6dfc
|
data/TUTORIAL.md
CHANGED
@@ -124,8 +124,6 @@ end
|
|
124
124
|
|
125
125
|
Huh, not much going on there, is there? That's because the default behavior of an action is to render the template that matches the name of the action. In this case, the action is `app/actions/root_action.rb`, so the template will be `templates/root.erb`. We'll cover actions in more depth later, but let's take a look at the template next.
|
126
126
|
|
127
|
-
But in case you are curious now, Sharp actions are [Rack::Action][rack-action], so you can read up on the documentation for [Rack::Action][rack-action] to find out more about what you can do with actions.
|
128
|
-
|
129
127
|
# Templates
|
130
128
|
|
131
129
|
There is what the template that is used to generate our response, `templates/root.erb`, looks like:
|
@@ -246,6 +244,8 @@ end
|
|
246
244
|
|
247
245
|
In this example, unless there is a param password equal to "secret", a redirect response will be generate, which prevents the action from calling the respond method and instead returns the redirect response.
|
248
246
|
|
247
|
+
Each Sharp action is an instance of `Rack::Action`, so you can read the documentation for [rack-action][rack-action] to find out more about what you can do with actions.
|
248
|
+
|
249
249
|
# Custom Views
|
250
250
|
|
251
251
|
Another way to make data available to the templates in Sharp is by creating a view object that corresponds to your action. Create a file at `app/views/root_view.rb` that looks like this:
|
@@ -267,7 +267,7 @@ end
|
|
267
267
|
|
268
268
|
If you hit the root URL in your browser or with curl now, you will see the same result. It is a good practice to build up a hierarchy of view objects and use inheritance to share functionality between related views.
|
269
269
|
|
270
|
-
|
270
|
+
Each Sharp view is an instance of `Curtain::View`, so you read the documentation on [Curtain][curtain] to find out more about what you can do with views.
|
271
271
|
|
272
272
|
# Console
|
273
273
|
|
data/lib/sharp.rb
CHANGED
@@ -5,6 +5,7 @@ require 'pathname'
|
|
5
5
|
require 'rack-action'
|
6
6
|
require 'rack-router'
|
7
7
|
require 'stringio'
|
8
|
+
require 'uri'
|
8
9
|
require 'yaml'
|
9
10
|
require 'sharp/action'
|
10
11
|
require 'sharp/config'
|
@@ -74,11 +75,12 @@ module Sharp
|
|
74
75
|
end
|
75
76
|
|
76
77
|
# Generates a Rack env Hash
|
77
|
-
def self.env(method, path,
|
78
|
+
def self.env(method, path, env={})
|
79
|
+
uri = URI.parse(path)
|
78
80
|
DEFAULT_ENV.merge(env || {}).merge(
|
79
81
|
'REQUEST_METHOD' => method.to_s.upcase,
|
80
|
-
'PATH_INFO' => path,
|
81
|
-
'QUERY_STRING' => query
|
82
|
+
'PATH_INFO' => uri.path,
|
83
|
+
'QUERY_STRING' => uri.query,
|
82
84
|
'rack.input' => StringIO.new)
|
83
85
|
end
|
84
86
|
|
data/lib/sharp/version.rb
CHANGED
data/sharp.gemspec
CHANGED