monoriel 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.
- data/README.md +2 -1
- data/Rakefile +11 -0
- data/lib/monoriel.rb +20 -10
- data/monoriel-0.1.0.gem +0 -0
- data/monoriel-0.1.1.gem +0 -0
- data/monoriel.gemspec +2 -2
- data/sample/app.rb +9 -10
- data/test/Rakefile +5 -0
- data/test/monoriel-test.rb +40 -0
- metadata +10 -11
data/README.md
CHANGED
@@ -10,7 +10,7 @@ MonoRiel is an attempt to fork from mini-rail
|
|
10
10
|
which is in itself a fork from another rack project(rack-golem) into
|
11
11
|
super simplistic but useful web mini-framework (MonoRiel (spanish) = monorail (english))
|
12
12
|
|
13
|
-
|
13
|
+
gem updated and uploaded, now you can:
|
14
14
|
|
15
15
|
sudo gem install monoriel
|
16
16
|
|
@@ -111,3 +111,4 @@ Now save this into app.rb
|
|
111
111
|
- You need to provide the class Page in your models.
|
112
112
|
- You can use slim, haml, scss and erb templates with Monoriel
|
113
113
|
- Please use App in Samples for testing and documentation
|
114
|
+
- You can see my monoblog project for a real app sample code
|
data/Rakefile
ADDED
data/lib/monoriel.rb
CHANGED
@@ -78,7 +78,7 @@ module Monoriel
|
|
78
78
|
"ERROR 500"
|
79
79
|
end
|
80
80
|
|
81
|
-
def tpl(template, extention)
|
81
|
+
def tpl(template, extention,&block)
|
82
82
|
key = (template.to_s + extention.gsub(/[.]/,"_")).to_sym
|
83
83
|
@@tilt_cache ||= {}
|
84
84
|
if @@tilt_cache.has_key?(key)
|
@@ -90,23 +90,33 @@ module Monoriel
|
|
90
90
|
@@tilt_cache.store(key,template_obj) if ENV['RACK_ENV']=='production'
|
91
91
|
end
|
92
92
|
@res['Content-Type'] = "text/html;charset=utf-8"
|
93
|
-
template_obj.render(self)
|
93
|
+
template_obj.render(self) do
|
94
|
+
yield if block_given?
|
95
|
+
end
|
94
96
|
end
|
95
97
|
|
96
|
-
def erb(template)
|
97
|
-
tpl(template,'.erb')
|
98
|
+
def erb(template,&block)
|
99
|
+
tpl(template,'.erb') do
|
100
|
+
yield if block_given?
|
101
|
+
end
|
98
102
|
end
|
99
103
|
|
100
|
-
def slim(template)
|
101
|
-
tpl(template,'.slim')
|
104
|
+
def slim(template,&block)
|
105
|
+
tpl(template,'.slim') do
|
106
|
+
yield if block_given?
|
107
|
+
end
|
102
108
|
end
|
103
109
|
|
104
|
-
def haml(template)
|
105
|
-
tpl(template,'.haml')
|
110
|
+
def haml(template,&block)
|
111
|
+
tpl(template,'.haml',block) do
|
112
|
+
yield if block_given?
|
113
|
+
end
|
106
114
|
end
|
107
115
|
|
108
|
-
def scss(template)
|
109
|
-
tpl(template,'.scss')
|
116
|
+
def scss(template,&block)
|
117
|
+
tpl(template,'.scss',block) do
|
118
|
+
yield if block_given?
|
119
|
+
end
|
110
120
|
end
|
111
121
|
end
|
112
122
|
|
data/monoriel-0.1.0.gem
ADDED
Binary file
|
data/monoriel-0.1.1.gem
ADDED
Binary file
|
data/monoriel.gemspec
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'monoriel'
|
3
|
-
s.version = "0.1.
|
3
|
+
s.version = "0.1.2"
|
4
4
|
s.platform = Gem::Platform::RUBY
|
5
5
|
s.summary = "A rack based web framework forked from mini-train"
|
6
|
-
s.description = "
|
6
|
+
s.description = "A super simplistic but useful web framework with layout support"
|
7
7
|
s.files = `git ls-files`.split("\n").sort
|
8
8
|
s.require_path = './lib'
|
9
9
|
s.author = "Carlos Esquer"
|
data/sample/app.rb
CHANGED
@@ -22,15 +22,15 @@ class App
|
|
22
22
|
"<b>Always generate BOLD</b>"
|
23
23
|
end
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
25
|
+
def json_response(data=nil)
|
26
|
+
@res['Content-Type'] = "text/plain;charset=utf-8"
|
27
|
+
data.nil? ? "{}" : JSON.generate(data)
|
28
|
+
end
|
29
|
+
|
30
|
+
def yaml_response(data=nil)
|
31
|
+
@res['Content-Type'] = "text/plain;charset=utf-8"
|
32
|
+
data.to_yaml
|
33
|
+
end
|
34
34
|
|
35
35
|
end
|
36
36
|
|
@@ -120,7 +120,6 @@ class App
|
|
120
120
|
def not_found(*args)
|
121
121
|
# This one is defined by mini-train but here we decided to override it
|
122
122
|
# Like :index this method receives the arguments in order to make something with it
|
123
|
-
#Email.alert('Too many people are looking for porn here') if args.includes?("porn")
|
124
123
|
super(args)
|
125
124
|
end
|
126
125
|
|
data/test/Rakefile
ADDED
data/test/monoriel-test.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
require 'minitest/autorun'
|
2
2
|
require 'rack/lobster'
|
3
|
+
require 'slim'
|
3
4
|
require_relative '../lib/monoriel'
|
4
5
|
|
6
|
+
|
5
7
|
# =========
|
6
8
|
# = Basic =
|
7
9
|
# =========
|
@@ -95,6 +97,37 @@ class UsingPostPutAndDelete
|
|
95
97
|
end
|
96
98
|
UsingPostPutAndDeleteR = ::Rack::MockRequest.new(::Rack::Lint.new(Rack::MethodOverride.new(UsingPostPutAndDelete.new)))
|
97
99
|
|
100
|
+
# =======================
|
101
|
+
# = Templates with Blocks =
|
102
|
+
# =========
|
103
|
+
|
104
|
+
class UsingTemplatesWithBlocks
|
105
|
+
include Monoriel
|
106
|
+
helpers do
|
107
|
+
def render template
|
108
|
+
slim :layout do
|
109
|
+
slim template.to_sym
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
def index
|
114
|
+
render 'test'
|
115
|
+
end
|
116
|
+
end
|
117
|
+
UsingTemplatesWithBlocksR = ::Rack::MockRequest.new(::Rack::Lint.new(Rack::MethodOverride.new(UsingTemplatesWithBlocks.new)))
|
118
|
+
|
119
|
+
# =======================
|
120
|
+
# = Templates with Blocks =
|
121
|
+
# =========
|
122
|
+
|
123
|
+
class UsingTemplatesWithoutBlocks
|
124
|
+
include Monoriel
|
125
|
+
def index
|
126
|
+
slim :layout
|
127
|
+
end
|
128
|
+
end
|
129
|
+
UsingTemplatesWithoutBlocksR = ::Rack::MockRequest.new(::Rack::Lint.new(Rack::MethodOverride.new(UsingTemplatesWithoutBlocks.new)))
|
130
|
+
|
98
131
|
# =========
|
99
132
|
# = Specs =
|
100
133
|
# =========
|
@@ -200,4 +233,11 @@ describe "Monoriel" do
|
|
200
233
|
assert_equal "PUT",UsingPostPutAndDeleteR.put("/data").body
|
201
234
|
assert_equal "DELETE",UsingPostPutAndDeleteR.delete("/data").body
|
202
235
|
end
|
236
|
+
it "Should respond with Page in a Layout" do
|
237
|
+
assert_equal "<h1><p>Carlitos</p></h1>",UsingTemplatesWithBlocksR.get("/").body
|
238
|
+
end
|
239
|
+
it "Should respond with only the Layout content" do
|
240
|
+
assert_equal "<h1></h1>",UsingTemplatesWithoutBlocksR.get("/").body
|
241
|
+
end
|
242
|
+
|
203
243
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: monoriel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-01-
|
12
|
+
date: 2013-01-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: tilt
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirement: &81927660 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,20 +21,18 @@ dependencies:
|
|
21
21
|
version: 1.2.2
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
25
|
-
|
26
|
-
requirements:
|
27
|
-
- - ! '>='
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: 1.2.2
|
30
|
-
description: This is a super simplistic but useful web framework
|
24
|
+
version_requirements: *81927660
|
25
|
+
description: A super simplistic but useful web framework with layout support
|
31
26
|
email: carlosesquer@zinlim.com
|
32
27
|
executables: []
|
33
28
|
extensions: []
|
34
29
|
extra_rdoc_files: []
|
35
30
|
files:
|
36
31
|
- README.md
|
32
|
+
- Rakefile
|
37
33
|
- lib/monoriel.rb
|
34
|
+
- monoriel-0.1.0.gem
|
35
|
+
- monoriel-0.1.1.gem
|
38
36
|
- monoriel.gemspec
|
39
37
|
- sample/app.rb
|
40
38
|
- sample/config.ru
|
@@ -44,6 +42,7 @@ files:
|
|
44
42
|
- sample/views/index.haml
|
45
43
|
- sample/views/index.slim
|
46
44
|
- sample/views/index.slim~
|
45
|
+
- test/Rakefile
|
47
46
|
- test/monoriel-test.rb
|
48
47
|
homepage: http://monoriel.zinlim.com
|
49
48
|
licenses: []
|
@@ -65,7 +64,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
65
64
|
version: '0'
|
66
65
|
requirements: []
|
67
66
|
rubyforge_project:
|
68
|
-
rubygems_version: 1.8.
|
67
|
+
rubygems_version: 1.8.11
|
69
68
|
signing_key:
|
70
69
|
specification_version: 3
|
71
70
|
summary: A rack based web framework forked from mini-train
|