sinatra-mvc 0.0.2 → 0.0.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.
- data/README.md +30 -6
- data/bin/sinatra-mvc +2 -0
- data/lib/sinatra-mvc.rb +5 -9
- data/lib/sinatra-mvc/base.rb +3 -0
- data/lib/sinatra-mvc/conditional_form_field.rb +12 -11
- data/lib/sinatra-mvc/database_connection.rb +9 -6
- data/lib/sinatra-mvc/environment_helpers.rb +23 -0
- data/lib/sinatra-mvc/escaping.rb +6 -5
- data/lib/sinatra-mvc/flash_messages.rb +8 -2
- data/lib/sinatra-mvc/i18n.rb +6 -0
- data/lib/sinatra-mvc/load_app.rb +13 -9
- data/lib/sinatra-mvc/post_handler.rb +57 -56
- data/lib/sinatra-mvc/render_params.rb +17 -16
- data/lib/sinatra-mvc/session_store.rb +14 -13
- data/lib/sinatra-mvc/settings.rb +27 -18
- data/lib/sinatra-mvc/view_prefix.rb +17 -13
- data/skel/Gemfile +6 -0
- data/skel/conf/environment.rb +1 -0
- data/skel/config.ru +1 -1
- data/skel/views/docs.md +30 -6
- metadata +7 -43
data/README.md
CHANGED
@@ -12,16 +12,17 @@ with this document.
|
|
12
12
|
A rule of thumb: In command line examples, a `$` prefix means your own
|
13
13
|
user and a `#` prefix is a root terminal.
|
14
14
|
|
15
|
+
A big fat warning: Sinatra MVC < 0.1.0 is not fit for production. The API
|
16
|
+
_will_ change with almost _every_ release during sub-0.1.0 development.
|
17
|
+
Feel free to play around with it, though.
|
18
|
+
|
15
19
|
System Dependencies
|
16
20
|
-------------------
|
17
21
|
|
18
22
|
Your system needs to have a working Ruby 1.9.2 installation (or later,
|
19
23
|
but I haven't tested that). You'll also need some kind of database. The
|
20
|
-
currently supported databases are
|
21
|
-
|
22
|
-
* MySQL
|
23
|
-
* PostgreSQL
|
24
|
-
* Sqlite3
|
24
|
+
currently supported databases are all of the database backends
|
25
|
+
[supported][10] by DataMapper.
|
25
26
|
|
26
27
|
Sinatra MVC also has the possibility to use Memcache as a session storage
|
27
28
|
system. This is the default. It's recommended as well.
|
@@ -68,7 +69,6 @@ mirrors of the development tree at wasda.nl.
|
|
68
69
|
- or if you prefer github -
|
69
70
|
$ git clone git://github.com/jorrizza/sinatra-mvc.git
|
70
71
|
$ cd sinatra-mvc
|
71
|
-
$ rm sinatra-mvc-*.gem
|
72
72
|
$ gem build sinatra-mvc.gemspec
|
73
73
|
# gem install sinatra-mvc-*.gem
|
74
74
|
|
@@ -99,6 +99,28 @@ in the `Gemfile`, will be available to your project. For further
|
|
99
99
|
documentation about the `Gemfile`, read the [Bundler documentation about
|
100
100
|
the `Gemfile`][17]
|
101
101
|
|
102
|
+
Sharing your project with others
|
103
|
+
--------------------------------
|
104
|
+
|
105
|
+
The project is prepared for use in Git and Mercurial. It's recommended to
|
106
|
+
make a repository of your project directory right from the get-go.
|
107
|
+
|
108
|
+
For example, when using Mercurial:
|
109
|
+
|
110
|
+
$ cd $HOME/src/my_project
|
111
|
+
$ hg init
|
112
|
+
$ hg add * .gitignore .hgignore
|
113
|
+
$ hg commit -m "First commit."
|
114
|
+
|
115
|
+
When your friend clones your repository, the Bundler cache is not included.
|
116
|
+
The Bundler installer has to be re-run for a clone of your project.
|
117
|
+
|
118
|
+
Again, an example using Mercurial:
|
119
|
+
|
120
|
+
$ hg clone ~jameshacker/src/my_project $HOME/src/my_project
|
121
|
+
$ cd $HOME/src/my_project
|
122
|
+
$ bundle install --path vendor --binstubs
|
123
|
+
|
102
124
|
Updating
|
103
125
|
--------
|
104
126
|
|
@@ -113,6 +135,7 @@ To get the latest updates from the repository, just pull (and merge if needed).
|
|
113
135
|
$ hg update
|
114
136
|
- or when using github -
|
115
137
|
$ git pull
|
138
|
+
$ rm sinatra-mvc-*.gem
|
116
139
|
$ gem build sinatra-mvc.gemspec
|
117
140
|
# gem install sinatra-mvc-*.gem
|
118
141
|
|
@@ -455,6 +478,7 @@ Just don't use these as variables within controllers and views, mkay?
|
|
455
478
|
[7]: http://rubydoc.info/gems/dm-core/1.0.2/frames
|
456
479
|
[8]: https://github.com/jorrizza/sinatra-mvc
|
457
480
|
[9]: https://bitbucket.org/jorrizza/sinatra-mvc
|
481
|
+
[10]: https://github.com/search?langOverride=&q=dm+adapter&repo=&start_value=1&type=Repositories
|
458
482
|
[12]: http://www.rubydoc.info/gems/dm-migrations/1.0.2/frames
|
459
483
|
[13]: http://www.rubydoc.info/gems/dm-aggregates/1.0.2/frames
|
460
484
|
[14]: http://www.rubydoc.info/gems/dm-validations/1.0.2/frames
|
data/bin/sinatra-mvc
CHANGED
data/lib/sinatra-mvc.rb
CHANGED
@@ -15,17 +15,15 @@ $:.push PROJECT
|
|
15
15
|
|
16
16
|
# Guess what. We need these.
|
17
17
|
require 'rubygems'
|
18
|
-
require 'sinatra'
|
19
|
-
require 'erubis'
|
20
|
-
|
21
|
-
# i18n using R18n.
|
22
|
-
require 'sinatra/r18n'
|
18
|
+
require 'sinatra/base'
|
23
19
|
|
24
20
|
# Load all of the core modules, in order.
|
21
|
+
require 'sinatra-mvc/base'
|
22
|
+
require 'sinatra-mvc/i18n'
|
25
23
|
require 'sinatra-mvc/settings'
|
24
|
+
require 'sinatra-mvc/environment_helpers'
|
26
25
|
require 'sinatra-mvc/view_prefix'
|
27
26
|
require 'sinatra-mvc/render_params'
|
28
|
-
require 'sinatra-mvc/database_connection'
|
29
27
|
require 'sinatra-mvc/session_store'
|
30
28
|
require 'sinatra-mvc/flash_messages'
|
31
29
|
require 'sinatra-mvc/post_handler'
|
@@ -37,8 +35,6 @@ require 'bundler/setup'
|
|
37
35
|
|
38
36
|
# Load the application.
|
39
37
|
require 'conf/environment'
|
38
|
+
require 'sinatra-mvc/database_connection'
|
40
39
|
require 'sinatra-mvc/load_app'
|
41
40
|
require 'sinatra-mvc/load_utils'
|
42
|
-
|
43
|
-
# Start the classic mode.
|
44
|
-
set :run, true
|
@@ -1,14 +1,15 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
1
|
+
class SinatraMVC
|
2
|
+
helpers do
|
3
|
+
# Simple helper to display form field data when available.
|
4
|
+
# It prefers params, but when unavailable it'll use the supplied object (if available).
|
5
|
+
def c(field, object = nil)
|
6
|
+
if params.has_key? field.to_s
|
7
|
+
h params[field.to_s]
|
8
|
+
elsif object.respond_to? field
|
9
|
+
h object.send(field)
|
10
|
+
else
|
11
|
+
""
|
12
|
+
end
|
12
13
|
end
|
13
14
|
end
|
14
15
|
end
|
@@ -1,15 +1,18 @@
|
|
1
|
+
# These DataMapper parts are required by Sinatra MVC.
|
1
2
|
require 'dm-core'
|
2
3
|
require 'dm-types'
|
3
4
|
require 'dm-validations'
|
4
5
|
|
5
|
-
# Add translations to models
|
6
|
+
# Add translations to models.
|
6
7
|
require 'r18n-core/translated'
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
class SinatraMVC
|
10
|
+
# When we're developing, some DataMapper debug would be nice.
|
11
|
+
if development?
|
12
|
+
DataMapper::Logger.new $stdout, :debug
|
13
|
+
#DataMapper::Model.raise_on_save_failure = true
|
14
|
+
end
|
12
15
|
end
|
13
16
|
|
14
17
|
# Set up our database connection.
|
15
|
-
DataMapper.setup :default, Settings.settings['database_connection']
|
18
|
+
DataMapper.setup :default, SinatraMVC::Settings.settings['database_connection']
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class SinatraMVC
|
2
|
+
# In classic mode, the helpers are available in request
|
3
|
+
# context. Now we have to re-supply these because some people
|
4
|
+
# use them a lot. Using the Delegator is a bit too much for
|
5
|
+
# this use case.
|
6
|
+
helpers do
|
7
|
+
# Is my application running in development mode?
|
8
|
+
# Uses Rack's environment.
|
9
|
+
def development?
|
10
|
+
settings.environment == 'development'
|
11
|
+
end
|
12
|
+
# Is my application running in test mode?
|
13
|
+
# Uses Rack's environment.
|
14
|
+
def test?
|
15
|
+
settings.environment == 'test'
|
16
|
+
end
|
17
|
+
# Is my application running in production mode?
|
18
|
+
# Uses Rack's environment.
|
19
|
+
def production?
|
20
|
+
settings.environment == 'production'
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/sinatra-mvc/escaping.rb
CHANGED
@@ -1,4 +1,10 @@
|
|
1
|
-
# Flash messages on redirect
|
1
|
+
# Flash messages on redirect.
|
2
|
+
# See https://github.com/vast/sinatra-redirect-with-flash
|
3
|
+
|
2
4
|
require 'rack-flash'
|
3
|
-
use Rack::Flash
|
4
5
|
require 'sinatra/redirect_with_flash'
|
6
|
+
|
7
|
+
class SinatraMVC
|
8
|
+
use Rack::Flash
|
9
|
+
register Sinatra::RedirectWithFlash
|
10
|
+
end
|
data/lib/sinatra-mvc/load_app.rb
CHANGED
@@ -1,12 +1,16 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
|
1
|
+
# Load the models in Object scope.
|
2
|
+
Dir.glob(File.join PROJECT, 'models', '**', '*.rb').sort.each do |file|
|
3
|
+
require file
|
4
|
+
end
|
4
5
|
|
5
|
-
|
6
|
-
|
7
|
-
|
6
|
+
class SinatraMVC
|
7
|
+
# Load the app recursively.
|
8
|
+
# We have to run the code in our SinatraMVC class. We'll be nice to
|
9
|
+
# our developers and don't require them to open the class in every
|
10
|
+
# app file.
|
11
|
+
Dir.glob(File.join PROJECT, 'app', '**', '*.rb').sort.each do |file|
|
12
|
+
# TODO I'm sure we can think of a better way to do this.
|
13
|
+
self.class_eval File.new(file).read, file
|
8
14
|
end
|
9
|
-
end
|
10
15
|
|
11
|
-
|
12
|
-
load_app 'app'
|
16
|
+
end
|
@@ -1,67 +1,68 @@
|
|
1
|
-
|
2
|
-
#
|
3
|
-
|
4
|
-
helpers do
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
end
|
9
|
-
|
10
|
-
# Create or modify a single object from POST data.
|
11
|
-
# We assume the programmer isn't stupid, and actually provided a DataMapper
|
12
|
-
# class or object as the first argument.
|
13
|
-
# The second and third arguments supply a redirection mechanism on succes
|
14
|
-
# and failure. By default it's the referer. When nil, no redirection will
|
15
|
-
# take place.
|
16
|
-
def fetch(mode, input,
|
17
|
-
the_way_forward = request.env['HTTP_REFERER'],
|
18
|
-
the_way_back = request.env['HTTP_REFERER'])
|
19
|
-
|
20
|
-
# Get the proper object and class.
|
21
|
-
if input.is_a? DataMapper::Resource
|
22
|
-
the_object = input
|
23
|
-
the_class = the_object.class
|
24
|
-
else
|
25
|
-
the_class = input
|
26
|
-
the_object = the_class.new
|
1
|
+
class SinatraMVC
|
2
|
+
# Utility functions to handle POST data.
|
3
|
+
# TODO: Write post_object_multi for field[] input fields
|
4
|
+
helpers do
|
5
|
+
# Makes fetch more readable
|
6
|
+
def n
|
7
|
+
:n
|
27
8
|
end
|
9
|
+
|
10
|
+
# Create or modify a single object from POST data.
|
11
|
+
# We assume the programmer isn't stupid, and actually provided a DataMapper
|
12
|
+
# class or object as the first argument.
|
13
|
+
# The second and third arguments supply a redirection mechanism on succes
|
14
|
+
# and failure. By default it's the referer. When nil, no redirection will
|
15
|
+
# take place.
|
16
|
+
def fetch(mode, input,
|
17
|
+
the_way_forward = request.env['HTTP_REFERER'],
|
18
|
+
the_way_back = request.env['HTTP_REFERER'])
|
28
19
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
the_object.send(method, value)
|
37
|
-
end
|
20
|
+
# Get the proper object and class.
|
21
|
+
if input.is_a? DataMapper::Resource
|
22
|
+
the_object = input
|
23
|
+
the_class = the_object.class
|
24
|
+
else
|
25
|
+
the_class = input
|
26
|
+
the_object = the_class.new
|
38
27
|
end
|
39
28
|
|
40
|
-
#
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
29
|
+
# fetch 1, ...
|
30
|
+
if mode == 1
|
31
|
+
# Check for each parameter if we've got a model field
|
32
|
+
# and call the setter for that field and redirect.
|
33
|
+
params.each do |field, value|
|
34
|
+
method = (field + '=').to_sym
|
35
|
+
if the_object.respond_to? method
|
36
|
+
the_object.send(method, value)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
# If the object's valid, save and redirect. If not, show all
|
41
|
+
# the errors to the user at the way back location. We also make
|
42
|
+
# sure the same error doesn't show twice.
|
43
|
+
if the_object.valid?
|
44
|
+
the_object.save
|
45
|
+
redirect the_way_forward unless the_way_forward.nil?
|
46
|
+
else
|
47
|
+
flash[:error] = []
|
48
|
+
found_errors = []
|
49
|
+
the_object.errors.each_pair do |field, error|
|
50
|
+
field = field.to_s
|
51
|
+
field.gsub! /_id$/, ''
|
52
|
+
error.each do |e|
|
53
|
+
unless found_errors.include? [field, error]
|
54
|
+
flash[:error] << t[the_class.inspect.downcase.to_sym][field.to_sym] + ': ' + e
|
55
|
+
found_errors << [field, error]
|
56
|
+
end
|
56
57
|
end
|
57
58
|
end
|
59
|
+
redirect the_way_back unless the_way_back.nil?
|
58
60
|
end
|
59
|
-
|
61
|
+
elsif mode == :n
|
62
|
+
raise NotImplementedError, 'Sorry, fetch n, ... is not implemented yet.'
|
63
|
+
else
|
64
|
+
raise ArgumentError, 'No such mode: ' + mode.inspect
|
60
65
|
end
|
61
|
-
elsif mode == :n
|
62
|
-
raise NotImplementedError, 'Sorry, fetch n, ... is not implemented yet.'
|
63
|
-
else
|
64
|
-
raise ArgumentError, 'No such mode: ' + mode.inspect
|
65
66
|
end
|
66
67
|
end
|
67
68
|
end
|
@@ -1,18 +1,19 @@
|
|
1
|
-
|
2
|
-
#
|
3
|
-
#
|
4
|
-
|
5
|
-
before do
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
1
|
+
class SinatraMVC
|
2
|
+
# This will enable neat parameters like Rails and PHP have.
|
3
|
+
# You know, the variable[key] things.
|
4
|
+
# From the Sinatra book.
|
5
|
+
before do
|
6
|
+
new_params = {}
|
7
|
+
params.each_pair do |full_key, value|
|
8
|
+
this_param = new_params
|
9
|
+
split_keys = full_key.split(/\]\[|\]|\[/)
|
10
|
+
split_keys.each_index do |index|
|
11
|
+
break if split_keys.length == index + 1
|
12
|
+
this_param[split_keys[index]] ||= {}
|
13
|
+
this_param = this_param[split_keys[index]]
|
14
|
+
end
|
15
|
+
this_param[split_keys.last] = value
|
16
|
+
end
|
17
|
+
request.params.replace new_params
|
16
18
|
end
|
17
|
-
request.params.replace new_params
|
18
19
|
end
|
@@ -1,14 +1,15 @@
|
|
1
|
-
|
2
|
-
#
|
3
|
-
|
4
|
-
case settings.session_backend
|
5
|
-
when :cookie
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
when :memcache
|
11
|
-
|
12
|
-
else
|
13
|
-
|
1
|
+
class SinatraMVC
|
2
|
+
# Sessions for Sinatra
|
3
|
+
# Both cookie based as Memcache based sessions are supported
|
4
|
+
case settings.session_backend
|
5
|
+
when :cookie
|
6
|
+
secret = (0..50).map do
|
7
|
+
(65 + rand(25)).chr
|
8
|
+
end.join
|
9
|
+
use Rack::Session::Cookie, :expire_after => settings.session_max_age, :key => 'sinatra.mvc.session', :secret => secret
|
10
|
+
when :memcache
|
11
|
+
use Rack::Session::Memcache, :expire_after => settings.session_max_age, :key => 'sinatra.mvc.session', :namespace => 'sinatra:mvc:session', :memcache_server => settings.session_store
|
12
|
+
else
|
13
|
+
raise 'Unknown session backend: ' + settings.session_backend.inspect
|
14
|
+
end
|
14
15
|
end
|
data/lib/sinatra-mvc/settings.rb
CHANGED
@@ -2,28 +2,37 @@
|
|
2
2
|
|
3
3
|
require 'psych'
|
4
4
|
|
5
|
-
class
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
5
|
+
class SinatraMVC
|
6
|
+
# The settings loading class. It pretty much takes care of loading
|
7
|
+
# the settings from your project's settings.yml file.
|
8
|
+
class Settings
|
9
|
+
|
10
|
+
# Loads the settings file and populates the Settings class.
|
11
|
+
# Later, these settings will be passed into Sinatra's set().
|
12
|
+
def self.load(filename)
|
13
|
+
begin
|
14
|
+
@@settings = Psych.load_file filename
|
15
|
+
rescue
|
16
|
+
raise 'Could not load configuration! Psych said: ' + $!.to_s
|
17
|
+
end
|
11
18
|
end
|
12
|
-
end
|
13
19
|
|
14
|
-
|
15
|
-
|
20
|
+
# Public class attr_reader of the settings.
|
21
|
+
# It's just the output of Psych.load_file, really.
|
22
|
+
def self.settings
|
23
|
+
@@settings
|
24
|
+
end
|
16
25
|
end
|
17
|
-
end
|
18
26
|
|
19
|
-
Settings.load File.join(PROJECT, 'conf', 'settings.yml')
|
27
|
+
Settings.load File.join(PROJECT, 'conf', 'settings.yml')
|
20
28
|
|
21
|
-
# Now we have to feed the Sinatra settings
|
22
|
-
Settings.settings.each_pair do |setting, value|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
29
|
+
# Now we have to feed the Sinatra settings
|
30
|
+
Settings.settings.each_pair do |setting, value|
|
31
|
+
case setting
|
32
|
+
when 'views_root', 'translations', 'public'
|
33
|
+
set setting.to_sym, File.join(PROJECT, value)
|
34
|
+
else
|
35
|
+
set setting.to_sym, value
|
36
|
+
end
|
28
37
|
end
|
29
38
|
end
|
@@ -1,17 +1,21 @@
|
|
1
|
-
|
2
|
-
# first part of the URL exists as a subdir
|
3
|
-
# of our main view directory.
|
1
|
+
class SinatraMVC
|
2
|
+
# Set the view prefix right if the first part of the URL exists as a subdir
|
3
|
+
# of our main view directory.
|
4
|
+
# This construction enables us to recreate some liberty we had in classic
|
5
|
+
# mode, in which set() could be called in the request scope.
|
6
|
+
before do |obj|
|
7
|
+
obj.class.class_exec request do |request|
|
8
|
+
first_dir = request.env['REQUEST_URI'].split('/')[1]
|
4
9
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
if first_dir
|
11
|
+
if File.directory? File.join(settings.views_root, first_dir)
|
12
|
+
set :views, File.join(settings.views_root, first_dir)
|
13
|
+
else
|
14
|
+
set :views, settings.views_root
|
15
|
+
end
|
16
|
+
else
|
17
|
+
set :views, settings.views_root
|
18
|
+
end
|
13
19
|
end
|
14
|
-
else
|
15
|
-
set :views, settings.views_root
|
16
20
|
end
|
17
21
|
end
|
data/skel/Gemfile
CHANGED
@@ -11,7 +11,13 @@ gem 'maruku'
|
|
11
11
|
gem 'dm-migrations'
|
12
12
|
gem 'dm-aggregates'
|
13
13
|
|
14
|
+
# Datamapper connection methods.
|
15
|
+
gem 'dm-mysql-adapter'
|
16
|
+
#gem 'dm-postgres-adapter'
|
17
|
+
#gem 'dm-sqlite-adapter'
|
18
|
+
|
14
19
|
# Some often used template utilities. Add/enable at will.
|
20
|
+
gem 'erubis'
|
15
21
|
# gem 'RedCloth'
|
16
22
|
# gem 'liquid'
|
17
23
|
# gem 'less'
|
data/skel/conf/environment.rb
CHANGED
data/skel/config.ru
CHANGED
data/skel/views/docs.md
CHANGED
@@ -12,16 +12,17 @@ with this document.
|
|
12
12
|
A rule of thumb: In command line examples, a `$` prefix means your own
|
13
13
|
user and a `#` prefix is a root terminal.
|
14
14
|
|
15
|
+
A big fat warning: Sinatra MVC < 0.1.0 is not fit for production. The API
|
16
|
+
_will_ change with almost _every_ release during sub-0.1.0 development.
|
17
|
+
Feel free to play around with it, though.
|
18
|
+
|
15
19
|
System Dependencies
|
16
20
|
-------------------
|
17
21
|
|
18
22
|
Your system needs to have a working Ruby 1.9.2 installation (or later,
|
19
23
|
but I haven't tested that). You'll also need some kind of database. The
|
20
|
-
currently supported databases are
|
21
|
-
|
22
|
-
* MySQL
|
23
|
-
* PostgreSQL
|
24
|
-
* Sqlite3
|
24
|
+
currently supported databases are all of the database backends
|
25
|
+
[supported][10] by DataMapper.
|
25
26
|
|
26
27
|
Sinatra MVC also has the possibility to use Memcache as a session storage
|
27
28
|
system. This is the default. It's recommended as well.
|
@@ -68,7 +69,6 @@ mirrors of the development tree at wasda.nl.
|
|
68
69
|
- or if you prefer github -
|
69
70
|
$ git clone git://github.com/jorrizza/sinatra-mvc.git
|
70
71
|
$ cd sinatra-mvc
|
71
|
-
$ rm sinatra-mvc-*.gem
|
72
72
|
$ gem build sinatra-mvc.gemspec
|
73
73
|
# gem install sinatra-mvc-*.gem
|
74
74
|
|
@@ -99,6 +99,28 @@ in the `Gemfile`, will be available to your project. For further
|
|
99
99
|
documentation about the `Gemfile`, read the [Bundler documentation about
|
100
100
|
the `Gemfile`][17]
|
101
101
|
|
102
|
+
Sharing your project with others
|
103
|
+
--------------------------------
|
104
|
+
|
105
|
+
The project is prepared for use in Git and Mercurial. It's recommended to
|
106
|
+
make a repository of your project directory right from the get-go.
|
107
|
+
|
108
|
+
For example, when using Mercurial:
|
109
|
+
|
110
|
+
$ cd $HOME/src/my_project
|
111
|
+
$ hg init
|
112
|
+
$ hg add * .gitignore .hgignore
|
113
|
+
$ hg commit -m "First commit."
|
114
|
+
|
115
|
+
When your friend clones your repository, the Bundler cache is not included.
|
116
|
+
The Bundler installer has to be re-run for a clone of your project.
|
117
|
+
|
118
|
+
Again, an example using Mercurial:
|
119
|
+
|
120
|
+
$ hg clone ~jameshacker/src/my_project $HOME/src/my_project
|
121
|
+
$ cd $HOME/src/my_project
|
122
|
+
$ bundle install --path vendor --binstubs
|
123
|
+
|
102
124
|
Updating
|
103
125
|
--------
|
104
126
|
|
@@ -113,6 +135,7 @@ To get the latest updates from the repository, just pull (and merge if needed).
|
|
113
135
|
$ hg update
|
114
136
|
- or when using github -
|
115
137
|
$ git pull
|
138
|
+
$ rm sinatra-mvc-*.gem
|
116
139
|
$ gem build sinatra-mvc.gemspec
|
117
140
|
# gem install sinatra-mvc-*.gem
|
118
141
|
|
@@ -455,6 +478,7 @@ Just don't use these as variables within controllers and views, mkay?
|
|
455
478
|
[7]: http://rubydoc.info/gems/dm-core/1.0.2/frames
|
456
479
|
[8]: https://github.com/jorrizza/sinatra-mvc
|
457
480
|
[9]: https://bitbucket.org/jorrizza/sinatra-mvc
|
481
|
+
[10]: https://github.com/search?langOverride=&q=dm+adapter&repo=&start_value=1&type=Repositories
|
458
482
|
[12]: http://www.rubydoc.info/gems/dm-migrations/1.0.2/frames
|
459
483
|
[13]: http://www.rubydoc.info/gems/dm-aggregates/1.0.2/frames
|
460
484
|
[14]: http://www.rubydoc.info/gems/dm-validations/1.0.2/frames
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 3
|
9
|
+
version: 0.0.3
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Joris van Rooij
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date:
|
17
|
+
date: 2011-01-12 00:00:00 +01:00
|
18
18
|
default_executable: sinatra-mvc
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -150,7 +150,7 @@ dependencies:
|
|
150
150
|
type: :runtime
|
151
151
|
version_requirements: *id010
|
152
152
|
- !ruby/object:Gem::Dependency
|
153
|
-
name:
|
153
|
+
name: memcache-client
|
154
154
|
prerelease: false
|
155
155
|
requirement: &id011 !ruby/object:Gem::Requirement
|
156
156
|
none: false
|
@@ -162,45 +162,6 @@ dependencies:
|
|
162
162
|
version: "0"
|
163
163
|
type: :runtime
|
164
164
|
version_requirements: *id011
|
165
|
-
- !ruby/object:Gem::Dependency
|
166
|
-
name: dm-postgres-adapter
|
167
|
-
prerelease: false
|
168
|
-
requirement: &id012 !ruby/object:Gem::Requirement
|
169
|
-
none: false
|
170
|
-
requirements:
|
171
|
-
- - ">="
|
172
|
-
- !ruby/object:Gem::Version
|
173
|
-
segments:
|
174
|
-
- 0
|
175
|
-
version: "0"
|
176
|
-
type: :runtime
|
177
|
-
version_requirements: *id012
|
178
|
-
- !ruby/object:Gem::Dependency
|
179
|
-
name: dm-sqlite-adapter
|
180
|
-
prerelease: false
|
181
|
-
requirement: &id013 !ruby/object:Gem::Requirement
|
182
|
-
none: false
|
183
|
-
requirements:
|
184
|
-
- - ">="
|
185
|
-
- !ruby/object:Gem::Version
|
186
|
-
segments:
|
187
|
-
- 0
|
188
|
-
version: "0"
|
189
|
-
type: :runtime
|
190
|
-
version_requirements: *id013
|
191
|
-
- !ruby/object:Gem::Dependency
|
192
|
-
name: memcache-client
|
193
|
-
prerelease: false
|
194
|
-
requirement: &id014 !ruby/object:Gem::Requirement
|
195
|
-
none: false
|
196
|
-
requirements:
|
197
|
-
- - ">="
|
198
|
-
- !ruby/object:Gem::Version
|
199
|
-
segments:
|
200
|
-
- 0
|
201
|
-
version: "0"
|
202
|
-
type: :runtime
|
203
|
-
version_requirements: *id014
|
204
165
|
description: A custom MVC stack that tries to keep the lightweight Sinatra feeling, while adding structure to an already awesome workflow.
|
205
166
|
email: jorrizza@jrrzz.net
|
206
167
|
executables:
|
@@ -212,7 +173,10 @@ extra_rdoc_files: []
|
|
212
173
|
|
213
174
|
files:
|
214
175
|
- bin/sinatra-mvc
|
176
|
+
- lib/sinatra-mvc/base.rb
|
177
|
+
- lib/sinatra-mvc/i18n.rb
|
215
178
|
- lib/sinatra-mvc/escaping.rb
|
179
|
+
- lib/sinatra-mvc/environment_helpers.rb
|
216
180
|
- lib/sinatra-mvc/load_utils.rb
|
217
181
|
- lib/sinatra-mvc/render_params.rb
|
218
182
|
- lib/sinatra-mvc/database_connection.rb
|