otto 0.4.1 → 1.0.0
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 +7 -0
- data/LICENSE.txt +7 -5
- data/README.md +94 -89
- data/lib/otto.rb +1 -1
- data/otto.gemspec +10 -32
- metadata +33 -30
- data/CHANGES.txt +0 -35
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 8f45aaa59480c093a55b8bd202de6d8364e680cc90efea2ae808a3f87e31c69b
|
4
|
+
data.tar.gz: 7839bda85a1904ec353f144750a651fe4cd5b019a2a2d5adfd2a478c030886d6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: cd7cdf82cd9bdec7f614e95e1725ae3f6d0d7e8d9d3261cc92d34007ab614c6a6c7fe2eff10c4f6c5bea0372977c4bc3b56cc17473fb3c7e49f604fbf5d1e43f
|
7
|
+
data.tar.gz: b39c598eb016d29bd9f2bbacfe22d405a24c3fbd858fc583f5fa6d7d1bc66a71deee4bf2d1e4208b26f9ccd5d1f11cb46a091d7995a6b030ef9b73d07830d529
|
data/LICENSE.txt
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2011-2024 delano
|
2
4
|
|
3
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
6
|
of this software and associated documentation files (the "Software"), to deal
|
@@ -7,13 +9,13 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
9
|
copies of the Software, and to permit persons to whom the Software is
|
8
10
|
furnished to do so, subject to the following conditions:
|
9
11
|
|
10
|
-
The above copyright notice and this permission notice shall be included in
|
11
|
-
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
12
14
|
|
13
15
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
16
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
17
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
18
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
19
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
-
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
CHANGED
@@ -1,21 +1,23 @@
|
|
1
|
-
# Otto - 0
|
1
|
+
# Otto - 1.0 (2024-04-05)
|
2
2
|
|
3
3
|
**Auto-define your rack-apps in plain-text.**
|
4
4
|
|
5
|
-
## Overview
|
5
|
+
## Overview
|
6
6
|
|
7
|
-
Apps built with Otto have three, basic parts: a rackup file, a ruby file, and a routes file. If you've built a [Rack app](
|
7
|
+
Apps built with Otto have three, basic parts: a rackup file, a ruby file, and a routes file. If you've built a [Rack app](https://github.com/rack/rack) before, then you've seen a rackup file before. The ruby file is your actual app and the routes file is what Otto uses to map URI paths to a Ruby class and method.
|
8
8
|
|
9
9
|
A barebones app directory looks something like this:
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
```bash
|
12
|
+
$ cd myapp
|
13
|
+
$ ls
|
14
|
+
config.ru app.rb routes
|
15
|
+
```
|
14
16
|
|
15
17
|
See the examples/ directory for a working app.
|
16
18
|
|
17
19
|
|
18
|
-
### Routes
|
20
|
+
### Routes
|
19
21
|
|
20
22
|
The routes file is just a plain-text file which defines the end points of your application. Each route has three parts:
|
21
23
|
|
@@ -25,84 +27,91 @@ The routes file is just a plain-text file which defines the end points of your a
|
|
25
27
|
|
26
28
|
Here is an example:
|
27
29
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
30
|
+
```ruby
|
31
|
+
GET / App#index
|
32
|
+
POST / App#receive_feedback
|
33
|
+
GET /redirect App#redirect
|
34
|
+
GET /robots.txt App#robots_text
|
35
|
+
GET /product/:prodid App#display_product
|
33
36
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
37
|
+
# You can also define these handlers when no
|
38
|
+
# route can be found or there's a server error. (optional)
|
39
|
+
GET /404 App#not_found
|
40
|
+
GET /500 App#server_error
|
41
|
+
```
|
38
42
|
|
39
|
-
### App
|
43
|
+
### App
|
40
44
|
|
41
45
|
There is nothing special about the Ruby class. The only requirement is that the first two arguments to initialize be a Rack::Request object and a Rack::Response object. Otherwise, you can do anything you want. You're free to use any templating engine, any database mapper, etc. There is no magic.
|
42
46
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
def receive_feedback
|
64
|
-
res.body = req.params.inspect
|
65
|
-
end
|
66
|
-
|
67
|
-
def redirect
|
68
|
-
res.redirect '/robots.txt'
|
69
|
-
end
|
70
|
-
|
71
|
-
def robots_text
|
72
|
-
res.header['Content-Type'] = "text/plain"
|
73
|
-
rules = 'User-agent: *', 'Disallow: /private'
|
74
|
-
res.body = rules.join($/)
|
75
|
-
end
|
76
|
-
|
77
|
-
def display_product
|
78
|
-
res.header['Content-Type'] = "application/json; charset=utf-8"
|
79
|
-
prodid = req.params[:prodid]
|
80
|
-
res.body = '{"product":%s,"msg":"Hint: try another value"}' % [prodid]
|
81
|
-
end
|
82
|
-
|
83
|
-
def not_found
|
84
|
-
res.status = 404
|
85
|
-
res.body = "Item not found!"
|
86
|
-
end
|
87
|
-
|
88
|
-
def server_error
|
89
|
-
res.status = 500
|
90
|
-
res.body = "There was a server error!"
|
91
|
-
end
|
47
|
+
```ruby
|
48
|
+
class App
|
49
|
+
attr_reader :req, :res
|
50
|
+
|
51
|
+
# Otto creates an instance of this class for every request
|
52
|
+
# and passess the Rack::Request and Rack::Response objects.
|
53
|
+
def initialize req, res
|
54
|
+
@req, @res = req, res
|
55
|
+
end
|
56
|
+
|
57
|
+
def index
|
58
|
+
res.header['Content-Type'] = "text/html; charset=utf-8"
|
59
|
+
lines = [
|
60
|
+
'<img src="/img/otto.jpg" /><br/><br/>',
|
61
|
+
'Send feedback:<br/>',
|
62
|
+
'<form method="post"><input name="msg" /><input type="submit" /></form>',
|
63
|
+
'<a href="/product/100">A product example</a>'
|
64
|
+
]
|
65
|
+
res.body = lines.join($/)
|
92
66
|
end
|
93
67
|
|
94
|
-
|
68
|
+
def receive_feedback
|
69
|
+
res.body = req.params.inspect
|
70
|
+
end
|
71
|
+
|
72
|
+
def redirect
|
73
|
+
res.redirect '/robots.txt'
|
74
|
+
end
|
75
|
+
|
76
|
+
def robots_text
|
77
|
+
res.header['Content-Type'] = "text/plain"
|
78
|
+
rules = 'User-agent: *', 'Disallow: /private'
|
79
|
+
res.body = rules.join($/)
|
80
|
+
end
|
81
|
+
|
82
|
+
def display_product
|
83
|
+
res.header['Content-Type'] = "application/json; charset=utf-8"
|
84
|
+
prodid = req.params[:prodid]
|
85
|
+
res.body = '{"product":%s,"msg":"Hint: try another value"}' % [prodid]
|
86
|
+
end
|
87
|
+
|
88
|
+
def not_found
|
89
|
+
res.status = 404
|
90
|
+
res.body = "Item not found!"
|
91
|
+
end
|
92
|
+
|
93
|
+
def server_error
|
94
|
+
res.status = 500
|
95
|
+
res.body = "There was a server error!"
|
96
|
+
end
|
97
|
+
end
|
98
|
+
```
|
99
|
+
|
100
|
+
|
101
|
+
### Rackup
|
95
102
|
|
96
103
|
There is also nothing special about the rackup file. It just builds a Rack app using your routes file.
|
97
104
|
|
98
|
-
|
99
|
-
|
105
|
+
```ruby
|
106
|
+
require 'otto'
|
107
|
+
require 'app'
|
100
108
|
|
101
|
-
|
109
|
+
app = Otto.new("./routes")
|
102
110
|
|
103
|
-
|
104
|
-
|
105
|
-
|
111
|
+
map('/') {
|
112
|
+
run app
|
113
|
+
}
|
114
|
+
```
|
106
115
|
|
107
116
|
See the examples/ directory for a working app.
|
108
117
|
|
@@ -111,35 +120,31 @@ See the examples/ directory for a working app.
|
|
111
120
|
|
112
121
|
Get it in one of the following ways:
|
113
122
|
|
114
|
-
|
115
|
-
|
116
|
-
$ git clone git://github.com/delano/otto.git
|
123
|
+
```bash
|
124
|
+
$ gem install otto
|
117
125
|
|
118
|
-
|
126
|
+
[ Add it to yer Gemfile]
|
127
|
+
$ bundle install
|
119
128
|
|
129
|
+
$ git clone git://github.com/delano/otto.git
|
130
|
+
```
|
120
131
|
|
121
|
-
## More Information
|
122
|
-
|
123
|
-
* [Codes](http://github.com/delano/otto)
|
124
|
-
* [RDocs](http://solutious.com/otto)
|
125
132
|
|
133
|
+
You can also download via [tarball](https://github.com/delano/otto/tarball/latest) or [zip](https://github.com/delano/otto/zipball/latest).
|
126
134
|
|
127
|
-
## In the wild ##
|
128
135
|
|
129
|
-
|
136
|
+
## More Information
|
130
137
|
|
131
|
-
* [
|
132
|
-
* [BlameStella](https://www.blamestella.com/) -- Web monitoring for devs and designers.
|
138
|
+
* [Homepage](https://github.com/delano/otto)
|
133
139
|
|
134
140
|
|
135
|
-
##
|
141
|
+
## In the wild
|
136
142
|
|
137
|
-
|
143
|
+
Services that use Otto:
|
138
144
|
|
145
|
+
* [Onetime Secret](https://onetimesecret.com/) -- A safe way to share sensitive data.
|
139
146
|
|
140
|
-
## Related Projects
|
141
147
|
|
142
|
-
* [Sinatra](http://www.sinatrarb.com/)
|
143
148
|
|
144
149
|
## License
|
145
150
|
|
data/lib/otto.rb
CHANGED
@@ -42,7 +42,7 @@ class Otto
|
|
42
42
|
alias_method :options, :option
|
43
43
|
def load path
|
44
44
|
path = File.expand_path(path)
|
45
|
-
raise ArgumentError, "Bad path: #{path}" unless File.
|
45
|
+
raise ArgumentError, "Bad path: #{path}" unless File.exist?(path)
|
46
46
|
raw = File.readlines(path).select { |line| line =~ /^\w/ }.collect { |line| line.strip.split(/\s+/) }
|
47
47
|
raw.each { |entry|
|
48
48
|
begin
|
data/otto.gemspec
CHANGED
@@ -1,23 +1,14 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
1
|
# -*- encoding: utf-8 -*-
|
5
2
|
|
6
3
|
Gem::Specification.new do |s|
|
7
4
|
s.name = "otto"
|
8
|
-
s.version = "0.
|
9
|
-
|
10
|
-
s.
|
5
|
+
s.version = "1.0.0"
|
6
|
+
s.summary = "Auto-define your rack-apps in plaintext."
|
7
|
+
s.description = "Otto: #{s.summary}"
|
8
|
+
s.email = "gems@solutious.com"
|
11
9
|
s.authors = ["Delano Mandelbaum"]
|
12
|
-
s.
|
13
|
-
s.description = "Auto-define your rack-apps in plaintext."
|
14
|
-
s.email = "delano@solutious.com"
|
15
|
-
s.extra_rdoc_files = [
|
16
|
-
"LICENSE.txt",
|
17
|
-
"README.md"
|
18
|
-
]
|
10
|
+
s.license = "MIT"
|
19
11
|
s.files = [
|
20
|
-
"CHANGES.txt",
|
21
12
|
"LICENSE.txt",
|
22
13
|
"README.md",
|
23
14
|
"Rakefile",
|
@@ -30,25 +21,12 @@ Gem::Specification.new do |s|
|
|
30
21
|
"lib/otto.rb",
|
31
22
|
"otto.gemspec"
|
32
23
|
]
|
33
|
-
s.homepage = "
|
24
|
+
s.homepage = "https://github.com/delano/otto"
|
34
25
|
s.require_paths = ["lib"]
|
35
|
-
s.
|
36
|
-
s.rubygems_version = "1.8.23"
|
37
|
-
s.summary = "Auto-define your rack-apps in plaintext."
|
26
|
+
s.rubygems_version = "3.2.22" # Update to the latest version
|
38
27
|
|
39
|
-
|
40
|
-
s.specification_version = 3
|
28
|
+
s.required_ruby_version = '>= 2.6.8'
|
41
29
|
|
42
|
-
|
43
|
-
|
44
|
-
s.add_runtime_dependency(%q<addressable>, [">= 2.2.6"])
|
45
|
-
else
|
46
|
-
s.add_dependency(%q<rack>, [">= 1.2.1"])
|
47
|
-
s.add_dependency(%q<addressable>, [">= 2.2.6"])
|
48
|
-
end
|
49
|
-
else
|
50
|
-
s.add_dependency(%q<rack>, [">= 1.2.1"])
|
51
|
-
s.add_dependency(%q<addressable>, [">= 2.2.6"])
|
52
|
-
end
|
30
|
+
s.add_dependency 'rack', '~> 1.2', '>= 1.2.1'
|
31
|
+
s.add_dependency 'addressable', '~> 2.2', '>= 2.2.6'
|
53
32
|
end
|
54
|
-
|
metadata
CHANGED
@@ -1,57 +1,61 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: otto
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 1.0.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Delano Mandelbaum
|
9
|
-
autorequire:
|
8
|
+
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2024-04-05 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rack
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.2'
|
20
|
+
- - ">="
|
20
21
|
- !ruby/object:Gem::Version
|
21
22
|
version: 1.2.1
|
22
23
|
type: :runtime
|
23
24
|
prerelease: false
|
24
25
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
26
|
requirements:
|
27
|
-
- -
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.2'
|
30
|
+
- - ">="
|
28
31
|
- !ruby/object:Gem::Version
|
29
32
|
version: 1.2.1
|
30
33
|
- !ruby/object:Gem::Dependency
|
31
34
|
name: addressable
|
32
35
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
36
|
requirements:
|
35
|
-
- -
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '2.2'
|
40
|
+
- - ">="
|
36
41
|
- !ruby/object:Gem::Version
|
37
42
|
version: 2.2.6
|
38
43
|
type: :runtime
|
39
44
|
prerelease: false
|
40
45
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
46
|
requirements:
|
43
|
-
- -
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '2.2'
|
50
|
+
- - ">="
|
44
51
|
- !ruby/object:Gem::Version
|
45
52
|
version: 2.2.6
|
46
|
-
description: Auto-define your rack-apps in plaintext.
|
47
|
-
email:
|
53
|
+
description: 'Otto: Auto-define your rack-apps in plaintext.'
|
54
|
+
email: gems@solutious.com
|
48
55
|
executables: []
|
49
56
|
extensions: []
|
50
|
-
extra_rdoc_files:
|
51
|
-
- LICENSE.txt
|
52
|
-
- README.md
|
57
|
+
extra_rdoc_files: []
|
53
58
|
files:
|
54
|
-
- CHANGES.txt
|
55
59
|
- LICENSE.txt
|
56
60
|
- README.md
|
57
61
|
- Rakefile
|
@@ -63,28 +67,27 @@ files:
|
|
63
67
|
- example/routes
|
64
68
|
- lib/otto.rb
|
65
69
|
- otto.gemspec
|
66
|
-
homepage:
|
67
|
-
licenses:
|
68
|
-
|
70
|
+
homepage: https://github.com/delano/otto
|
71
|
+
licenses:
|
72
|
+
- MIT
|
73
|
+
metadata: {}
|
74
|
+
post_install_message:
|
69
75
|
rdoc_options: []
|
70
76
|
require_paths:
|
71
77
|
- lib
|
72
78
|
required_ruby_version: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
79
|
requirements:
|
75
|
-
- -
|
80
|
+
- - ">="
|
76
81
|
- !ruby/object:Gem::Version
|
77
|
-
version:
|
82
|
+
version: 2.6.8
|
78
83
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
|
-
none: false
|
80
84
|
requirements:
|
81
|
-
- -
|
85
|
+
- - ">="
|
82
86
|
- !ruby/object:Gem::Version
|
83
87
|
version: '0'
|
84
88
|
requirements: []
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
specification_version: 3
|
89
|
+
rubygems_version: 3.4.12
|
90
|
+
signing_key:
|
91
|
+
specification_version: 4
|
89
92
|
summary: Auto-define your rack-apps in plaintext.
|
90
93
|
test_files: []
|
data/CHANGES.txt
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
OTTO, CHANGES
|
2
|
-
|
3
|
-
#### 0.4.1 (2015-04-07) ###############################
|
4
|
-
|
5
|
-
* FIXED: Resolved error when ACCEPT-LANGUAGES header doesn't exist
|
6
|
-
|
7
|
-
#### 0.4.0 (2015-04-06) ###############################
|
8
|
-
|
9
|
-
* ADDED: Locale support via env['rack.locale']
|
10
|
-
|
11
|
-
#### 0.3.2 (2013-01-27) ###############################
|
12
|
-
|
13
|
-
* CHANGE: send_cookie doesn't set domain
|
14
|
-
|
15
|
-
#### 0.3.1 (2012-12-17) ###############################
|
16
|
-
|
17
|
-
* ADDED: Otto.debug (set w/ Otto.debug= or env variable OTTO_DEBUG)
|
18
|
-
* ADDED: RequestHelpers#ajax?
|
19
|
-
* CHANGE: Added internal subnets to RequestHelpers#local?
|
20
|
-
|
21
|
-
|
22
|
-
#### 0.3.0 (2011-12-17) ###############################
|
23
|
-
|
24
|
-
* ADDED: Example app, better docs in readme
|
25
|
-
* CHANGE: No default value for user agent
|
26
|
-
|
27
|
-
#### 0.2.1 (2011-07-07) ###############################
|
28
|
-
|
29
|
-
* ADDED: Otto#add_static_path
|
30
|
-
|
31
|
-
#### 0.2.0 (2011-07-06) ###############################
|
32
|
-
|
33
|
-
Initial public release
|
34
|
-
|
35
|
-
|