Skip to content
Newer
Older
100644 114 lines (85 sloc) 3.15 KB
576a555 @cldwalker gemification
authored Apr 4, 2011
1 == Description
a32f19b @cldwalker more readme
authored Apr 5, 2011
2 Tux dresses up sinatra in a shell. Use it to interact with your helpers, view rendering and
576a555 @cldwalker gemification
authored Apr 4, 2011
3 your app's response objects. Tux also gives you commands to view your app's routes and settings.
4
5 == Install
6 Install the gem with:
7
8 gem install tux
9
10 == Usage
11
a32f19b @cldwalker more readme
authored Apr 5, 2011
12 Start with:
13
14 $ tux
15
16 If your app's config file isn't config.ru, specify with -c
17
18 $ tux -c app.ru
19
576a555 @cldwalker gemification
authored Apr 4, 2011
20 To interact with your helpers:
21
22 >> app.my_helper_method
23 ...
24
25 To interact with any built-in sinatra methods i.e. request and response specific helper
26 methods:
27
28 # depends on request
29 >> app.uri '/'
30 => "http://:/"
31
32 # depends on response
33 >> app.headers
34 => {"Content-Type"=>"text/html"}
35
36 For the above to work, tux sets up default empty request and response objects. To try the helpers
a32f19b @cldwalker more readme
authored Apr 5, 2011
37 with custom requests and responses:
576a555 @cldwalker gemification
authored Apr 4, 2011
38
39 >> app.request = Sinatra::Request.new({})
40 >> app.response = Sinatra::Response.new
41
42 To interact with your views:
43
44 >> app.erb :my_template
45 => 'template rendered'
46
a32f19b @cldwalker more readme
authored Apr 5, 2011
47 # also
48 >> app.haml
49 >> app.markdown
50 ...
51
52 Tux let's you you make requests and interact with rack response objects thanks to
53 {rack-test}[https://github.com/brynary/rack-test]:
54
55 >> get '/'
56 => #<Rack::MockResponse:0x13d452c @headers={"Content-Type"=>"text/html;charset=utf-8",
57 "Content-Length"=>"4"}, @errors="127.0.0.1 - - [05/Apr/2011 02:22:27] \"GET / \" 200 4
58 0.0015\n", @status=200, @original_headers={"Content-Type"=>"text/html;charset=utf-8",
59 "Content-Length"=>"4"}, @body="dude">
60
61 >> puts last_response.body
62 dude
63
64 >> post '/create'
65 ...
66
67 To see the full list of rack-test actions you can make
68
69 >> rack.actions
70 => [:request, :get, :post, :put, :delete, :head, :follow_redirect!, :header, :set_cookie,
71 :clear_cookies, :authorize, :basic_authorize, :digest_authorize, :last_response, :last_request]
72
576a555 @cldwalker gemification
authored Apr 4, 2011
73 Tux also comes with commands to give you a good overview of your app
74
75 >> routes
76 HEAD "/"
77 HEAD /book/:id
78 GET "/"
79 GET /book/:id
80
81 >> settings
82 absolute_redirects true
83 add_charset [/^text\//, "application/javascript", "application/xml",
84 "application/xhtml+xml"]
85 app_file "./sample.rb"
86 bind "0.0.0.0"
87 default_encoding "utf-8"
88 dump_errors true
89 empty_path_info nil
90 environment :development
91 lock false
92 logging false
93 method_override false
94 port 4567
95 prefixed_redirects false
96 public "/my/path/public"
97 raise_errors false
98 reload_templates true
99 root "/my/path"
100 run false
101 running false
102 server ["thin", "mongrel", "webrick"]
103 session_secret "XXX"
104 sessions false
105 show_exceptions true
106 static true
107 views "/my/path/views"
108
a32f19b @cldwalker more readme
authored Apr 5, 2011
109 == Configure
110
111 Since tux is a {ripl shell}[http://github.com/cldwalker/ripl], tux is highly configurable. You can
112 create tux commands in the format tux-COMMAND and enhance your shell by adding ripl plugins to
113 ~/.riplrc. Read {ripl's readme}[http://github.com/cldwalker/ripl#readme] for more.
Something went wrong with that request. Please try again.