rack-cgi 0.4.2 → 0.4.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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +42 -43
  3. data/lib/rack/cgi/version.rb +1 -1
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2dcab38b6e1fc83699f610007eac3c3cd7f931fb
4
- data.tar.gz: 00abaf13b44be8e28a64d6e027f373276b3d196c
3
+ metadata.gz: 79b63dd716b9dcd6cd7369512c08f11e860b5838
4
+ data.tar.gz: a4334d97836b664f375fcc412f3ac32921aeb841
5
5
  SHA512:
6
- metadata.gz: c0b1b1b999cbb66b494f705b94885d9bb73f08827be21723214de717c8b692189f3b82c765d1551f97492b648560fe0478c155bda1e3284892d7a81384e3fc8f
7
- data.tar.gz: ea0460d72eaf739ffdb21bd03310ceafa1c10232a5f36c4d19320c713de6f0b889f53ba4d513badccd898cbe79ce6e0014748e61f2ab9dc37f1725ed9fa0b117
6
+ metadata.gz: cb7fe7f8b01088c1b68639bafa2f36ae33521df8606410b16345df0060e0f10e7f194a0db38dfbc573a4accac450a55f5b9a2475f757559ac151a1255b29da67
7
+ data.tar.gz: 4cc7cdddb15eafffcc4a0f6b7c08a3d7c733df22bc8349eaa2a51e1870489a5dee7efefdea3bbb8dc7890e12e98dbd0ee0ad69f42fb9f3972a7ea63209ec07e6
data/README.md CHANGED
@@ -7,13 +7,12 @@ Usage
7
7
  -----
8
8
 
9
9
  Here is an example for using Rack::CGI
10
- ```ruby
11
- # config.ru
10
+ # config.ru
11
+
12
+ use Rack::CGI, cgi_path: 'cgi', index: 'index.cgi', Rack::CGI::Executable => '', /\.php$/ => '/usr/bin/php-cgi'
13
+ use Rack::Static, urls: ['/'], root: 'cgi'
14
+ run proc{ [404, {"CONTENT-TYPE" => "text/plain"}, ['404 Not Found']] }
12
15
 
13
- use Rack::CGI, cgi_path: 'cgi', index: 'index.cgi', Rack::CGI::Executable => '', /\.php$/ => '/usr/bin/php-cgi'
14
- use Rack::Static, urls: ['/'], root: 'cgi'
15
- run proc{ [404, {"CONTENT-TYPE" => "text/plain"}, ['404 Not Found']] }
16
- ```
17
16
  How to
18
17
  -----
19
18
 
@@ -28,20 +27,20 @@ When user access directory, Rack::CGI will use index script instand of.
28
27
  If you not special index, Rack::CGI will not have a default value, and it's not works.
29
28
 
30
29
  You can special index as follow:
31
- ```ruby
32
- use Rack::CGI, index: 'index.php'
33
30
 
34
- # or special multiple, Rack::CGI will try each by order
35
- use Rack::CGI, index: ['index.php', 'index.cgi']
36
- ```
31
+ use Rack::CGI, index: 'index.php'
32
+
33
+ # or special multiple, Rack::CGI will try each by order
34
+ use Rack::CGI, index: ['index.php', 'index.cgi']
35
+
37
36
  ### Rules
38
37
 
39
38
  When Rack::CGI found a script file in disk, it will try to find a rule to deal it.
40
39
 
41
40
  You can special multiple rules, in follow format:
42
- ```ruby
43
- use Rack::CGI, match1 => deal1, match2 => deal2, match3 => deal3 ...
44
- ```
41
+
42
+ use Rack::CGI, match1 => deal1, match2 => deal2, match3 => deal3 ...
43
+
45
44
  `match` can be Rack::CGI::Executable or Regexp.
46
45
  Rack::CGI::Executable match all script that is executable.
47
46
  Regexp will try to match script full path.
@@ -61,41 +60,41 @@ All relative resource will cannot accessed. In this case, we have to redirect 'h
61
60
  'http://wps-community.org/forum/' to avoid this problem.
62
61
 
63
62
  You can use following code to open this feature.
64
- ```ruby
65
- use Rack::CGI, ..., dir_redirect: true, ...
66
- ```
63
+
64
+ use Rack::CGI, ..., dir_redirect: true, ...
65
+
67
66
  ### Use Rack::CGI in Rails project
68
67
 
69
68
  Originally I intended to write a project named rails-cgi.
70
69
  But it's so trouble, and run Rack app in rails is not very complex.
71
70
  So I give up rails-cgi.
72
71
 
73
- 1. Create a cgi controller
74
- ```bash
75
- $ rails g controller cgi
76
- ```
77
- 2. Create a Rack Application in CgiController
78
- ```ruby
79
- # You can changed arguments as you want
80
- CGI = Rack::Builder.new do
81
- use Rack::CGI, cgi_path: 'cgi', index: ['index.cgi', 'index.php'], Rack::CGI::Executable => '', /\.php$/ => '/usr/bin/php-cgi'
82
- use Rack::Static, urls: ['/'], root: 'cgi'
83
- run proc{ |env| raise ActionController::RoutingError, env['PATH_INFO'] + " not found!" }
84
- end
85
- ```
86
- 3. Call Rack App in rails controller
87
- ```ruby
88
- # add an action to controller
89
- def cgi
90
- [self.status, self.response.headers, self.response_body] = CGI.call env
91
- end
92
- # of course, you can add decoration code here, such as call rails layout
93
- ```
94
- 4. Add route
95
- ```ruby
96
- # add follow to config/routes.rb
97
- get '/cgi-bin/*path' => 'cgi#cgi'
98
- ```
72
+ Create a cgi controller
73
+
74
+ $ rails g controller cgi
75
+
76
+ Create a Rack Application in CgiController
77
+
78
+ # You can changed arguments as you want
79
+ CGI = Rack::Builder.new do
80
+ use Rack::CGI, cgi_path: 'cgi', index: ['index.cgi', 'index.php'], Rack::CGI::Executable => '', /\.php$/ => '/usr/bin/php-cgi'
81
+ use Rack::Static, urls: ['/'], root: 'cgi'
82
+ run proc{ |env| raise ActionController::RoutingError, env['PATH_INFO'] + " not found!" }
83
+ end
84
+
85
+ Call Rack App in rails controller
86
+
87
+ # add an action to controller
88
+ def cgi
89
+ [self.status, self.response.headers, self.response_body] = CGI.call env
90
+ end
91
+ # of course, you can add decoration code here, such as call rails layout
92
+
93
+ Add route
94
+
95
+ # add follow to config/routes.rb
96
+ get '/cgi-bin/*path' => 'cgi#cgi'
97
+
99
98
  TODO
100
99
  ----
101
100
 
@@ -1,5 +1,5 @@
1
1
  module Rack
2
2
  module Cgi
3
- VERSION = "0.4.2"
3
+ VERSION = "0.4.3"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-cgi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chizhong Jin