mont 0.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/.gitignore +13 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +51 -0
- data/LICENSE.txt +21 -0
- data/README.md +100 -0
- data/Rakefile +11 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/mont/config/server.rb +20 -0
- data/lib/mont/controller_base.rb +93 -0
- data/lib/mont/flash.rb +45 -0
- data/lib/mont/router.rb +57 -0
- data/lib/mont/session.rb +21 -0
- data/lib/mont/show_exceptions.rb +24 -0
- data/lib/mont/static.rb +34 -0
- data/lib/mont/templates/rescue.html.erb +0 -0
- data/lib/mont/version.rb +3 -0
- data/lib/mont.rb +6 -0
- data/mont.gemspec +36 -0
- data/views/cats_controller/index.html.erb +3 -0
- data/views/cats_controller/new.html.erb +11 -0
- data/views/dogs_controller/index.html.erb +8 -0
- data/views/dogs_controller/new.html.erb +21 -0
- data/views/dogs_controller/show.html.erb +1 -0
- data/views/dummy_controller/index.html.erb +0 -0
- data/views/my_controller/counting_show.html.erb +1 -0
- data/views/my_controller/show.html.erb +1 -0
- metadata +155 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 5d630ceeb262a34ec2e009f9a2f2f79c4ac67456
|
|
4
|
+
data.tar.gz: c39a7d6f9efc9cbeef14c4bed7bfc53504ccb105
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 0e90c9e88cecf750d0008b197514f21969bd86d48497b2cf6a26c9db42e8fd686aa7340b0c9cc9cfa3edeab98b3808f3bb3f747e731558d8027343665baeb7ab
|
|
7
|
+
data.tar.gz: 17eed143838572ad48b06f81c665b0978f59764c8d902b0189eabe471f131f4b1673892727e5f3b89217ba3c30a9c05a9a9e942d5cdffe173cccc6688adbdcfe
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
mont (0.0.0)
|
|
5
|
+
|
|
6
|
+
GEM
|
|
7
|
+
remote: https://rubygems.org/
|
|
8
|
+
specs:
|
|
9
|
+
activesupport (4.2.7.1)
|
|
10
|
+
i18n (~> 0.7)
|
|
11
|
+
json (~> 1.7, >= 1.7.7)
|
|
12
|
+
minitest (~> 5.1)
|
|
13
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
|
14
|
+
tzinfo (~> 1.1)
|
|
15
|
+
byebug (9.0.5)
|
|
16
|
+
diff-lcs (1.2.5)
|
|
17
|
+
i18n (0.7.0)
|
|
18
|
+
json (1.8.3)
|
|
19
|
+
minitest (5.9.0)
|
|
20
|
+
rack (1.6.4)
|
|
21
|
+
rake (10.4.2)
|
|
22
|
+
rspec (3.1.0)
|
|
23
|
+
rspec-core (~> 3.1.0)
|
|
24
|
+
rspec-expectations (~> 3.1.0)
|
|
25
|
+
rspec-mocks (~> 3.1.0)
|
|
26
|
+
rspec-core (3.1.7)
|
|
27
|
+
rspec-support (~> 3.1.0)
|
|
28
|
+
rspec-expectations (3.1.2)
|
|
29
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
30
|
+
rspec-support (~> 3.1.0)
|
|
31
|
+
rspec-mocks (3.1.3)
|
|
32
|
+
rspec-support (~> 3.1.0)
|
|
33
|
+
rspec-support (3.1.2)
|
|
34
|
+
thread_safe (0.3.5)
|
|
35
|
+
tzinfo (1.2.2)
|
|
36
|
+
thread_safe (~> 0.1)
|
|
37
|
+
|
|
38
|
+
PLATFORMS
|
|
39
|
+
ruby
|
|
40
|
+
|
|
41
|
+
DEPENDENCIES
|
|
42
|
+
activesupport (< 5.0)
|
|
43
|
+
bundler (~> 1.12)
|
|
44
|
+
byebug
|
|
45
|
+
mont!
|
|
46
|
+
rack (< 2.0)
|
|
47
|
+
rake (~> 10.0)
|
|
48
|
+
rspec (~> 3.1.0)
|
|
49
|
+
|
|
50
|
+
BUNDLED WITH
|
|
51
|
+
1.12.5
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2016 Mac Siri
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# Mont
|
|
2
|
+
|
|
3
|
+
A lightweight Ruby MVC framework inspired by Rails.
|
|
4
|
+
|
|
5
|
+
## Featuring
|
|
6
|
+
|
|
7
|
+
### CSRF protection
|
|
8
|
+
|
|
9
|
+
```Ruby
|
|
10
|
+
require_relative '../models/cat'
|
|
11
|
+
|
|
12
|
+
class DogesController < ControllerBase
|
|
13
|
+
|
|
14
|
+
def create
|
|
15
|
+
verify_authenticity_token
|
|
16
|
+
@Doge = Doge.new(name: params["name"], wow_id: params["wow_id"])
|
|
17
|
+
@Doge.save
|
|
18
|
+
|
|
19
|
+
render :show
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
end
|
|
23
|
+
```
|
|
24
|
+
Simply include ```verify_authenticity_token``` to ensures no none 'GET' action can be done without authenticity token being checked
|
|
25
|
+
|
|
26
|
+
### Session
|
|
27
|
+
|
|
28
|
+
```Ruby
|
|
29
|
+
session['sample_key'] = 'sample_text!'
|
|
30
|
+
```
|
|
31
|
+
Persist states by storing cookies in session
|
|
32
|
+
|
|
33
|
+
### Flash
|
|
34
|
+
|
|
35
|
+
```Ruby
|
|
36
|
+
flash[:error] = 'Invalid credentials!'
|
|
37
|
+
```
|
|
38
|
+
or
|
|
39
|
+
```Ruby
|
|
40
|
+
flash.now[:error] = 'Invalid credentials'
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Whether you want to alert the user for just this session or the next, Flash will be written into the cookies and will get cleared with each request.
|
|
44
|
+
|
|
45
|
+
### Static Assets
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
app
|
|
49
|
+
└─── public
|
|
50
|
+
├── doge
|
|
51
|
+
| └── much-wow.jpg
|
|
52
|
+
└── summer
|
|
53
|
+
└── june
|
|
54
|
+
├── sandle.png
|
|
55
|
+
└── italian-ice.jpg
|
|
56
|
+
```
|
|
57
|
+
Including contents in your app/public and it will automatically be served as a static assets.
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
## Installation
|
|
61
|
+
|
|
62
|
+
1. Fork or clone this repo.
|
|
63
|
+
2. run ```bundle install```
|
|
64
|
+
3. make a controller
|
|
65
|
+
|
|
66
|
+
```
|
|
67
|
+
# app/controllers/doges_controller.rb
|
|
68
|
+
|
|
69
|
+
require_relative 'lib/controller_base'
|
|
70
|
+
require_relative '../models/doge'
|
|
71
|
+
|
|
72
|
+
class DogesController < ControllerBase
|
|
73
|
+
def index
|
|
74
|
+
@doges = Doge.all
|
|
75
|
+
|
|
76
|
+
render :index
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
```
|
|
80
|
+
4. construct a route
|
|
81
|
+
|
|
82
|
+
```
|
|
83
|
+
# config/routes.rb
|
|
84
|
+
|
|
85
|
+
ROUTER.draw do
|
|
86
|
+
get Regexp.new("^/doges$"), DogesController, :index
|
|
87
|
+
get Regexp.new("^/doges/new$"), DogesController, :new
|
|
88
|
+
post Regexp.new("^/doges$"), DogesController, :create
|
|
89
|
+
end
|
|
90
|
+
```
|
|
91
|
+
5. start the server with ```bundle exec rackup config/server.rb```
|
|
92
|
+
|
|
93
|
+
## Contributing
|
|
94
|
+
|
|
95
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/maestromac/Mont.
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
## License
|
|
99
|
+
|
|
100
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "mont"
|
|
5
|
+
|
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
8
|
+
|
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
10
|
+
# require "pry"
|
|
11
|
+
# Pry.start
|
|
12
|
+
|
|
13
|
+
require "irb"
|
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
router = Router.new
|
|
2
|
+
|
|
3
|
+
router.draw do
|
|
4
|
+
get Regexp.new("^/dogs$"), DogsController, :index
|
|
5
|
+
get Regexp.new("^/dogs/new$"), DogsController, :new
|
|
6
|
+
get Regexp.new("^/dogs/(?<id>\\d+)$"), DogsController, :show
|
|
7
|
+
post Regexp.new("^/dogs$"), DogsController, :create
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
app = Proc.new do |env|
|
|
11
|
+
req = Rack::Request.new(env)
|
|
12
|
+
res = Rack::Response.new
|
|
13
|
+
router.run(req, res)
|
|
14
|
+
res.finish
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
Rack::Server.start(
|
|
18
|
+
app: app,
|
|
19
|
+
Port: 3000
|
|
20
|
+
)
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
require 'active_support'
|
|
2
|
+
require 'active_support/core_ext'
|
|
3
|
+
require 'erb'
|
|
4
|
+
require_relative './session'
|
|
5
|
+
|
|
6
|
+
class ControllerBase
|
|
7
|
+
attr_reader :req, :res, :params
|
|
8
|
+
|
|
9
|
+
def initialize(req, res, params = {} )
|
|
10
|
+
@req, @res, @params = req, res, params.merge(req.params)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def already_built_response?
|
|
14
|
+
@already_built_response
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def redirect_to(url)
|
|
18
|
+
unless already_built_response?
|
|
19
|
+
|
|
20
|
+
res['location'] = url
|
|
21
|
+
res.status = 302
|
|
22
|
+
session.store_session(res)
|
|
23
|
+
@already_built_response = true
|
|
24
|
+
else
|
|
25
|
+
raise "Error!"
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def render_content(content, content_type)
|
|
30
|
+
unless already_built_response?
|
|
31
|
+
res['content-type'] = content_type
|
|
32
|
+
res.body = [content]
|
|
33
|
+
session.store_session(res)
|
|
34
|
+
@already_built_response = true
|
|
35
|
+
else
|
|
36
|
+
raise "Error!"
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def render(template_name)
|
|
41
|
+
controller_name = self.class.to_s
|
|
42
|
+
path = "views/#{controller_name.underscore}/#{template_name}.html.erb"
|
|
43
|
+
contents = File.read(path)
|
|
44
|
+
erb = ERB.new(contents).result(binding)
|
|
45
|
+
render_content( erb , 'text/html')
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def session
|
|
49
|
+
@session ||= Session.new(req)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def invoke_action(name)
|
|
53
|
+
unless @req.request_method == 'GET'
|
|
54
|
+
|
|
55
|
+
if protect_from_forgery?
|
|
56
|
+
check_authenticity_token
|
|
57
|
+
else
|
|
58
|
+
form_authenticity_token
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
self.send(name)
|
|
64
|
+
render(name) unless already_built_response?
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def form_authenticity_token
|
|
68
|
+
@token ||= generate_authenticity_token
|
|
69
|
+
res.set_cookie('authenticity_token', @token)
|
|
70
|
+
@token
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def check_authenticity_token
|
|
74
|
+
c = req.cookies['authenticity_token']
|
|
75
|
+
|
|
76
|
+
unless c && c == params['authenticity_token']
|
|
77
|
+
raise 'Invalid authenticity token'
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def self.protect_from_forgery
|
|
82
|
+
@@protect_from_forgery = true
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def protect_from_forgery?
|
|
86
|
+
@@protect_from_forgery
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def generate_authenticity_token
|
|
90
|
+
SecureRandom.urlsafe_base64(16)
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
end
|
data/lib/mont/flash.rb
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
require 'json'
|
|
2
|
+
|
|
3
|
+
class Flash
|
|
4
|
+
attr_reader :now
|
|
5
|
+
|
|
6
|
+
def initialize(req)
|
|
7
|
+
c = req.cookies['_rails_lite_app_flash']
|
|
8
|
+
c_content = c ? JSON.parse(c) : {}
|
|
9
|
+
@flash = FlashStore.new
|
|
10
|
+
@now = FlashStore.new(c_content)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def [](key)
|
|
14
|
+
@flash[key] || @now[key]
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def []=(key, value)
|
|
18
|
+
@flash[key] = value
|
|
19
|
+
@now[key] = value
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def store_flash(res)
|
|
23
|
+
res.set_cookie('_rails_lite_app_flash', {path: '/', value: @flash.to_json})
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
class FlashStore
|
|
29
|
+
def initialize(store={})
|
|
30
|
+
@store = store
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def [](key)
|
|
34
|
+
@store[key]
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def []=(key, value)
|
|
38
|
+
@store[key] = value
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def to_json
|
|
42
|
+
@store.to_json
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
end
|
data/lib/mont/router.rb
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
class Route
|
|
2
|
+
attr_reader :pattern, :http_method, :controller_class, :action_name
|
|
3
|
+
|
|
4
|
+
def initialize(pattern, http_method, controller_class, action_name)
|
|
5
|
+
@pattern, @http_method, @controller_class, @action_name =
|
|
6
|
+
pattern, http_method, controller_class, action_name
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def matches?(req)
|
|
10
|
+
(req.request_method.downcase.to_sym == http_method) &&
|
|
11
|
+
(pattern =~ req.path)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def run(req, res)
|
|
15
|
+
match_data = @pattern.match(req.path)
|
|
16
|
+
route_params = Hash[match_data.names.zip(match_data.captures)]
|
|
17
|
+
|
|
18
|
+
@controller_class.new(req, res, route_params).invoke_action(action_name)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
class Router
|
|
23
|
+
attr_reader :routes
|
|
24
|
+
|
|
25
|
+
def initialize
|
|
26
|
+
@routes = []
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def add_route(pattern, method, controller_class, action_name)
|
|
30
|
+
@routes.push(Route.new(pattern, method, controller_class, action_name))
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def draw(&proc)
|
|
34
|
+
instance_eval(&proc)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
[:get, :post, :put, :delete].each do |http_method|
|
|
38
|
+
define_method(http_method) do |pattern, controller_class, action_name|
|
|
39
|
+
add_route(pattern, http_method ,controller_class, action_name)
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def match(req)
|
|
44
|
+
@routes.each do |route|
|
|
45
|
+
return route if route.matches?(req)
|
|
46
|
+
end
|
|
47
|
+
nil
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def run(req, res)
|
|
51
|
+
if match(req)
|
|
52
|
+
match(req).run(req, res)
|
|
53
|
+
else
|
|
54
|
+
res.status = 404
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
data/lib/mont/session.rb
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
require 'json'
|
|
2
|
+
|
|
3
|
+
class Session
|
|
4
|
+
|
|
5
|
+
def initialize(req)
|
|
6
|
+
c = req.cookies['_mont_app']
|
|
7
|
+
@cookies = c ? JSON.parse(c) : {}
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def [](key)
|
|
11
|
+
@cookies[key]
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def []=(key, val)
|
|
15
|
+
@cookies[key] = val
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def store_session(res)
|
|
19
|
+
res.set_cookie('_mont_app', {path: '/', value: @cookies.to_json})
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
require 'erb'
|
|
2
|
+
|
|
3
|
+
class ShowExceptions
|
|
4
|
+
attr_reader :app
|
|
5
|
+
|
|
6
|
+
def initialize(app)
|
|
7
|
+
@app = app
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def call(env)
|
|
11
|
+
begin
|
|
12
|
+
@app.call(env)
|
|
13
|
+
rescue => e
|
|
14
|
+
render_exception(e)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
private
|
|
19
|
+
|
|
20
|
+
def render_exception(e)
|
|
21
|
+
['500', {'Content-type' => 'text/html'}, [e.message]]
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
end
|
data/lib/mont/static.rb
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
class Static
|
|
2
|
+
attr_reader :app, :root
|
|
3
|
+
def initialize(app)
|
|
4
|
+
@app = app
|
|
5
|
+
@root = root
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def call(env)
|
|
9
|
+
req = Rack::Request.new(env)
|
|
10
|
+
path = req.path[1..-1]
|
|
11
|
+
|
|
12
|
+
return app.call(env) unless can_serve?(path)
|
|
13
|
+
|
|
14
|
+
mime_type = Rack::Mime.mime_type(File.extname(path))
|
|
15
|
+
|
|
16
|
+
if File.file?(path)
|
|
17
|
+
file = File.read(path)
|
|
18
|
+
serve(200, file, mime_type)
|
|
19
|
+
else
|
|
20
|
+
serve(404, nil, mime_type)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
private
|
|
26
|
+
|
|
27
|
+
def can_serve?(path)
|
|
28
|
+
path.index("/#{root}")
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def serve(status, file, mime_type)
|
|
32
|
+
[404, { 'Content-Type' => "#{mime_type}" }, [file]]
|
|
33
|
+
end
|
|
34
|
+
end
|
|
File without changes
|
data/lib/mont/version.rb
ADDED
data/lib/mont.rb
ADDED
data/mont.gemspec
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'mont/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "mont"
|
|
8
|
+
spec.version = Mont::VERSION
|
|
9
|
+
spec.authors = ["Mac Siri"]
|
|
10
|
+
spec.email = ["krairit.siri@gmail.com"]
|
|
11
|
+
|
|
12
|
+
spec.summary = %q{MVC framework inspired by Rails}
|
|
13
|
+
spec.description = %q{This is still WIP}
|
|
14
|
+
spec.homepage = "https://github.com/maestromac/Mont"
|
|
15
|
+
spec.license = "MIT"
|
|
16
|
+
|
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
|
19
|
+
# if spec.respond_to?(:metadata)
|
|
20
|
+
# spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
|
|
21
|
+
# else
|
|
22
|
+
# raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
|
23
|
+
# end
|
|
24
|
+
|
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
26
|
+
spec.bindir = "exe"
|
|
27
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
28
|
+
spec.require_paths = ["lib"]
|
|
29
|
+
|
|
30
|
+
spec.add_development_dependency "bundler", "~> 1.12"
|
|
31
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
32
|
+
spec.add_development_dependency "rack", "< 2.0"
|
|
33
|
+
spec.add_development_dependency "byebug"
|
|
34
|
+
spec.add_development_dependency "rspec", "~> 3.1.0"
|
|
35
|
+
spec.add_development_dependency "activesupport", "< 5.0"
|
|
36
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<% if flash[:errors] %>
|
|
2
|
+
<% flash[:errors].each do |error| %>
|
|
3
|
+
<%= error %>
|
|
4
|
+
<% end %>
|
|
5
|
+
<% end %>
|
|
6
|
+
|
|
7
|
+
<form action="/dogs" method="POST">
|
|
8
|
+
<label>Name
|
|
9
|
+
<input type="text" name="dog[name]" value="<%= @dog.name %>">
|
|
10
|
+
</label>
|
|
11
|
+
|
|
12
|
+
<!-- <label>Form Authenticity Token
|
|
13
|
+
<input type="text" name="authenticity_token" value="<%= # form_authenticity_token %>">
|
|
14
|
+
</label> -->
|
|
15
|
+
|
|
16
|
+
<label>Owner
|
|
17
|
+
<input type="text" name="dog[owner]" value="<%= @dog.owner %>">
|
|
18
|
+
</label>
|
|
19
|
+
|
|
20
|
+
<input type="submit">
|
|
21
|
+
</form>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<%= link_to "all dogs", dogs_path %>
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<%= session["count"] %>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<%= (1..10).to_a.join(", ") %>
|
metadata
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: mont
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Mac Siri
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2016-10-02 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: bundler
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '1.12'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.12'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rake
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '10.0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '10.0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: rack
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "<"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '2.0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "<"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '2.0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: byebug
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - ">="
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '0'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - ">="
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '0'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: rspec
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - "~>"
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: 3.1.0
|
|
76
|
+
type: :development
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - "~>"
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: 3.1.0
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: activesupport
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - "<"
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: '5.0'
|
|
90
|
+
type: :development
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - "<"
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '5.0'
|
|
97
|
+
description: This is still WIP
|
|
98
|
+
email:
|
|
99
|
+
- krairit.siri@gmail.com
|
|
100
|
+
executables: []
|
|
101
|
+
extensions: []
|
|
102
|
+
extra_rdoc_files: []
|
|
103
|
+
files:
|
|
104
|
+
- ".gitignore"
|
|
105
|
+
- Gemfile
|
|
106
|
+
- Gemfile.lock
|
|
107
|
+
- LICENSE.txt
|
|
108
|
+
- README.md
|
|
109
|
+
- Rakefile
|
|
110
|
+
- bin/console
|
|
111
|
+
- bin/setup
|
|
112
|
+
- lib/mont.rb
|
|
113
|
+
- lib/mont/config/server.rb
|
|
114
|
+
- lib/mont/controller_base.rb
|
|
115
|
+
- lib/mont/flash.rb
|
|
116
|
+
- lib/mont/router.rb
|
|
117
|
+
- lib/mont/session.rb
|
|
118
|
+
- lib/mont/show_exceptions.rb
|
|
119
|
+
- lib/mont/static.rb
|
|
120
|
+
- lib/mont/templates/rescue.html.erb
|
|
121
|
+
- lib/mont/version.rb
|
|
122
|
+
- mont.gemspec
|
|
123
|
+
- views/cats_controller/index.html.erb
|
|
124
|
+
- views/cats_controller/new.html.erb
|
|
125
|
+
- views/dogs_controller/index.html.erb
|
|
126
|
+
- views/dogs_controller/new.html.erb
|
|
127
|
+
- views/dogs_controller/show.html.erb
|
|
128
|
+
- views/dummy_controller/index.html.erb
|
|
129
|
+
- views/my_controller/counting_show.html.erb
|
|
130
|
+
- views/my_controller/show.html.erb
|
|
131
|
+
homepage: https://github.com/maestromac/Mont
|
|
132
|
+
licenses:
|
|
133
|
+
- MIT
|
|
134
|
+
metadata: {}
|
|
135
|
+
post_install_message:
|
|
136
|
+
rdoc_options: []
|
|
137
|
+
require_paths:
|
|
138
|
+
- lib
|
|
139
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
140
|
+
requirements:
|
|
141
|
+
- - ">="
|
|
142
|
+
- !ruby/object:Gem::Version
|
|
143
|
+
version: '0'
|
|
144
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
145
|
+
requirements:
|
|
146
|
+
- - ">="
|
|
147
|
+
- !ruby/object:Gem::Version
|
|
148
|
+
version: '0'
|
|
149
|
+
requirements: []
|
|
150
|
+
rubyforge_project:
|
|
151
|
+
rubygems_version: 2.2.2
|
|
152
|
+
signing_key:
|
|
153
|
+
specification_version: 4
|
|
154
|
+
summary: MVC framework inspired by Rails
|
|
155
|
+
test_files: []
|