rigle 0.1.1 → 0.1.2
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 +4 -4
- data/lib/rigle.rb +43 -2
- data/lib/rigle/routing.rb +11 -0
- data/lib/rigle/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e971d2b1f242808ff82afa4e24846e0e77f6a519
|
4
|
+
data.tar.gz: 1e8e805f8008479d6e343dac692aa57a429f3018
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 23f18e284b154330d6a68e2358f68ab9d3869f1dfaf261d05652b1fdc633bd6d9da05a1653c59724932ee1adee0ed6dc9cb81475739f287540984da789261d81
|
7
|
+
data.tar.gz: 45d847b625a439e9cce86fd68d9cb6da39494ddbbb2455aa4640e59e3ac043b1e2a52f73dff0cc9d14d25fd20d5dee212cfdf49f29ccf992819ba443bbc565fa
|
data/lib/rigle.rb
CHANGED
@@ -1,10 +1,51 @@
|
|
1
1
|
require 'rigle/version'
|
2
|
-
require 'rigle/
|
2
|
+
require 'rigle/routing'
|
3
3
|
|
4
4
|
module Rigle
|
5
5
|
class Application
|
6
6
|
def call(env)
|
7
|
-
|
7
|
+
case env['PATH_INFO']
|
8
|
+
when '/favicon.ico'
|
9
|
+
return render_html(status: 404, content: [])
|
10
|
+
when '/'
|
11
|
+
return redirect_to(path: '/quotes/quote')
|
12
|
+
end
|
13
|
+
|
14
|
+
klass, act = get_controller_and_action(env)
|
15
|
+
controller = klass.new(env)
|
16
|
+
begin
|
17
|
+
text = controller.send(act)
|
18
|
+
render_html(status: 200, content: [text])
|
19
|
+
rescue
|
20
|
+
render_html(status: 500, content: [
|
21
|
+
'<p>Huston, we have a problem!</p>',
|
22
|
+
%q(<p>Told you, there's no place like <a href="http://localhost:3001/">home</a>...</p>)
|
23
|
+
])
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def render_html(status:, content:)
|
30
|
+
[status, {'Content-Type' => 'text/html'}, content]
|
31
|
+
end
|
32
|
+
|
33
|
+
def redirect_to(path:)
|
34
|
+
headers = {
|
35
|
+
'Content-Type' => 'text/html',
|
36
|
+
'Location' => path
|
37
|
+
}
|
38
|
+
[302, headers, ['302 you are being redirected']]
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
class Controller
|
43
|
+
def initialize(env)
|
44
|
+
@env = env
|
45
|
+
end
|
46
|
+
|
47
|
+
def env
|
48
|
+
@env
|
8
49
|
end
|
9
50
|
end
|
10
51
|
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module Rigle
|
2
|
+
class Application
|
3
|
+
def get_controller_and_action(env)
|
4
|
+
_, cont, action, after = env['PATH_INFO'].split('/', 4)
|
5
|
+
cont = cont.capitalize # People
|
6
|
+
cont += 'Controller' # PeopleController
|
7
|
+
|
8
|
+
[Object.const_get(cont), action]
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
data/lib/rigle/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rigle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marius Butuc
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04-
|
11
|
+
date: 2015-04-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -98,6 +98,7 @@ files:
|
|
98
98
|
- bin/setup
|
99
99
|
- lib/rigle.rb
|
100
100
|
- lib/rigle/array.rb
|
101
|
+
- lib/rigle/routing.rb
|
101
102
|
- lib/rigle/version.rb
|
102
103
|
- rigle.gemspec
|
103
104
|
homepage: https://github.com/mariusbutuc/rigle
|