sat 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +2 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +176 -0
- data/Rakefile +1 -0
- data/bin/sat +98 -0
- data/lib/sat.rb +5 -0
- data/lib/sat/version.rb +3 -0
- data/sat.gemspec +25 -0
- data/template/Gemfile +22 -0
- data/template/LICENSE +22 -0
- data/template/README.md +21 -0
- data/template/Rakefile +9 -0
- data/template/app/assets/images/.gitkeep +0 -0
- data/template/app/assets/javascripts/application.js +2 -0
- data/template/app/assets/stylesheets/application.css +4 -0
- data/template/app/controllers/application_controller.rb +34 -0
- data/template/app/controllers/root_controller.rb +12 -0
- data/template/app/helpers/application_helpers.rb +4 -0
- data/template/app/helpers/root_helpers.rb +4 -0
- data/template/app/models/.gitkeep +0 -0
- data/template/app/views/layouts/application.slim +8 -0
- data/template/app/views/root/index.slim +1 -0
- data/template/config.ru +3 -0
- data/template/config/application.rb +26 -0
- data/template/config/environment.rb +42 -0
- data/template/config/environments/development.rb +3 -0
- data/template/config/environments/production.rb +2 -0
- data/template/config/environments/test.rb +2 -0
- data/template/config/initializers/.gitkeep +0 -0
- data/template/config/locales/en.yml +5 -0
- data/template/log/.gitkeep +0 -0
- data/template/spec/controllers/application_controller_spec.rb +9 -0
- data/template/spec/controllers/root_controller_spec.rb +17 -0
- data/template/spec/helpers/application_helpers_spec.rb +9 -0
- data/template/spec/helpers/root_helpers_spec.rb +9 -0
- data/template/spec/minitest_helper.rb +3 -0
- data/template/spec/models/.gitkeep +0 -0
- metadata +126 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d61541e8ff5d1b9e7e73663114e0e191a6538176
|
4
|
+
data.tar.gz: 371a0d94add8edff5e0a7960e2a4579ae078b973
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 316d398b58aa9a1e98c88cfe16f7f19bf279987832b51b284ecf671d175e9ee1a017b1300ffd3ef3d553ac2ec7b9c4602c19d60a5707bd3b0c37f281d534f0f9
|
7
|
+
data.tar.gz: 47cc9a162000c3d4d820c28797594b2fd4c353321f977ab0145c32c523dacff73cc4994bd5478b5b0083b4481de958ffe84b2151da0debab24bf85149903a5fe
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Fernando Martinez
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,176 @@
|
|
1
|
+
# SAT
|
2
|
+
|
3
|
+
[Sinatra](https://github.com/sinatra/sinatra) Application Template.
|
4
|
+
|
5
|
+
## Features
|
6
|
+
|
7
|
+
* Sinatra modular application. Inspired by [travis-admin](https://github.com/travis-ci/travis-admin).
|
8
|
+
* Per-environment configuration in separated files.
|
9
|
+
* Separate routes in controllers.
|
10
|
+
* Separated directories for controllers' views.
|
11
|
+
* Per-controller helpers.
|
12
|
+
* Initializers support.
|
13
|
+
* [sinatra-contrib](https://github.com/sinatra/sinatra)
|
14
|
+
* [sinatra-partial](https://github.com/yb66/Sinatra-Partial)
|
15
|
+
* [i18n](https://github.com/svenfuchs/i18n).
|
16
|
+
* [minitest](https://github.com/seattlerb/minitest).
|
17
|
+
* [rack-test](https://github.com/brynary/rack-test).
|
18
|
+
* [slim](https://github.com/slim-template/slim).
|
19
|
+
* [sprockets](https://github.com/sstephenson/sprockets).
|
20
|
+
* [thin](https://github.com/macournoyer/thin).
|
21
|
+
|
22
|
+
## Install
|
23
|
+
|
24
|
+
For generating new projects with SAT you can use ```sat gem``` or do a manual install.
|
25
|
+
|
26
|
+
### Using the sat gem
|
27
|
+
|
28
|
+
Simply run:
|
29
|
+
|
30
|
+
```bash
|
31
|
+
$ gem install sat
|
32
|
+
$ sat <new_app_name>
|
33
|
+
```
|
34
|
+
|
35
|
+
Available options are:
|
36
|
+
|
37
|
+
* **--template <git_url>**: clone template from the specified repository.
|
38
|
+
* **--git <git_url>**: if specified, a new git repository will be setup for your project with its origin set to __<git_url>__.
|
39
|
+
* **--no-bundler**: switch to disable calling __bundle install__ after cloning the template.
|
40
|
+
|
41
|
+
|
42
|
+
### Manual install
|
43
|
+
|
44
|
+
* Clone the repository:
|
45
|
+
|
46
|
+
```bash
|
47
|
+
$ git clone git@github.com:patriciomacadden/sat.git
|
48
|
+
```
|
49
|
+
|
50
|
+
* Create a git repository and change the `origin`:
|
51
|
+
|
52
|
+
```bash
|
53
|
+
$ git remote rm origin
|
54
|
+
$ git remote add origin <YOUR_GIT_REPOSITORY>
|
55
|
+
```
|
56
|
+
|
57
|
+
* Change the application name (and commit the change):
|
58
|
+
|
59
|
+
```bash
|
60
|
+
$ APP_NAME=AwesomeApp; for i in `find . -type f | grep -v .git`; do if [ `grep SAT $i | wc -l` != 0 ]; then sed -i '' "s/SAT/$APP_NAME/g" $i; fi; done; git commit -am "SAT => $APP_NAME"
|
61
|
+
```
|
62
|
+
|
63
|
+
**Note**: Note the `APP_NAME` variable. You should change the application name
|
64
|
+
there.
|
65
|
+
|
66
|
+
## Creating a new controller
|
67
|
+
|
68
|
+
Let's create a controller for handling products.
|
69
|
+
|
70
|
+
* Create `app/controlers/products_controller.rb`
|
71
|
+
|
72
|
+
```ruby
|
73
|
+
module SAT::Application
|
74
|
+
class ProductsController < ApplicationController
|
75
|
+
set prefix: '/products'
|
76
|
+
# views will be found in app/views/products directory.
|
77
|
+
# If you want to change the views directory, use this
|
78
|
+
# configuration option.
|
79
|
+
# set views_prefix: '/some_other_directory'
|
80
|
+
|
81
|
+
get '/' do
|
82
|
+
# will render app/views/products/index.slim
|
83
|
+
# slim :index
|
84
|
+
'Hello World'
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
```
|
89
|
+
|
90
|
+
* Create `app/helpers/products_helpers.rb`
|
91
|
+
|
92
|
+
```ruby
|
93
|
+
module SAT::Application
|
94
|
+
module ProductsHelpers
|
95
|
+
# helper methods
|
96
|
+
end
|
97
|
+
end
|
98
|
+
```
|
99
|
+
|
100
|
+
* Create the views directory
|
101
|
+
|
102
|
+
```bash
|
103
|
+
$ mkdir app/views/products
|
104
|
+
```
|
105
|
+
|
106
|
+
* Create `spec/controllers/products_controller_spec.rb`
|
107
|
+
|
108
|
+
```ruby
|
109
|
+
require 'minitest_helper'
|
110
|
+
|
111
|
+
describe SAT::Application::ProductsController do
|
112
|
+
include Rack::Test::Methods
|
113
|
+
|
114
|
+
def app
|
115
|
+
SAT::Application
|
116
|
+
end
|
117
|
+
|
118
|
+
describe 'GET /products' do
|
119
|
+
it 'must be ok' do
|
120
|
+
get '/products'
|
121
|
+
last_response.must_be :ok?
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
```
|
126
|
+
|
127
|
+
* Create `spec/helpers/products_helpers_spec.rb`
|
128
|
+
|
129
|
+
```ruby
|
130
|
+
require 'minitest_helper'
|
131
|
+
|
132
|
+
describe SAT::Application::ProductsHelpers do
|
133
|
+
include Rack::Test::Methods
|
134
|
+
|
135
|
+
def app
|
136
|
+
SAT::Application
|
137
|
+
end
|
138
|
+
end
|
139
|
+
```
|
140
|
+
|
141
|
+
## Custom settings
|
142
|
+
|
143
|
+
Two settings are introduced:
|
144
|
+
|
145
|
+
* `prefix`: It indicates where to map a controller. **Must** be used in every
|
146
|
+
controller.
|
147
|
+
* `views_prefix`: It indicates where to find the views. If not set, `prefix` is
|
148
|
+
used to find the views.
|
149
|
+
|
150
|
+
## Caveats
|
151
|
+
|
152
|
+
Since the application itself its a `Rack::Builder` that maps the different
|
153
|
+
controllers to a particular path, you need to use that builder to use any rack
|
154
|
+
middleware.
|
155
|
+
|
156
|
+
See an example:
|
157
|
+
|
158
|
+
```ruby
|
159
|
+
# in environment.rb:
|
160
|
+
|
161
|
+
config.builder.use Rack::Auth::Basic do |username, password|
|
162
|
+
username == 'admin' && password == 'secret'
|
163
|
+
end
|
164
|
+
```
|
165
|
+
|
166
|
+
## Contributing
|
167
|
+
|
168
|
+
1. Fork it
|
169
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
170
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
171
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
172
|
+
5. Create new Pull Request
|
173
|
+
|
174
|
+
## License
|
175
|
+
|
176
|
+
See the [LICENSE](https://github.com/patriciomacadden/sat/blob/master/LICENSE).
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/sat
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require_relative '../lib/sat/version'
|
4
|
+
require 'trollop'
|
5
|
+
require 'pathname'
|
6
|
+
require 'tmpdir'
|
7
|
+
|
8
|
+
class App
|
9
|
+
@@version = "SAT Command Line Interface " << Sat::VERSION
|
10
|
+
@@usage = <<-EOS
|
11
|
+
Command line interface for the Sinatra Application Template
|
12
|
+
|
13
|
+
Usage:
|
14
|
+
sat [options] <app_name>
|
15
|
+
|
16
|
+
options:
|
17
|
+
EOS
|
18
|
+
|
19
|
+
def initialize(args)
|
20
|
+
parse_options!
|
21
|
+
@name = args.first
|
22
|
+
validate!
|
23
|
+
@name = @name.downcase
|
24
|
+
end
|
25
|
+
|
26
|
+
def run
|
27
|
+
clone_template
|
28
|
+
rename
|
29
|
+
git_setup if @options[:git]
|
30
|
+
install_bundle unless @options[:no_bundler]
|
31
|
+
|
32
|
+
puts "Done! your new app is in #{@name.downcase}"
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
def parse_options!
|
37
|
+
@options = Trollop::options do
|
38
|
+
version @@version
|
39
|
+
banner @@usage
|
40
|
+
|
41
|
+
opt :git, 'Git reposotory where new app will be versioned.', type: String
|
42
|
+
opt :template, 'Git repository url of template to use.', default: 'https://github.com/patriciomacadden/sat'
|
43
|
+
opt :no_bundler, "If specified, after processing template 'bundle install' won't be run"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def validate!
|
48
|
+
if @name.nil? || @name.empty?
|
49
|
+
Trollop::die "You must specify the new application name"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def clone_template
|
54
|
+
tmp = Pathname.new(Dir.tmpdir).join @name
|
55
|
+
exec "Aquiring template application from: #{@options[:template]}", "git clone #{@options[:template]} #{tmp}"
|
56
|
+
exec "Deploying template..." do
|
57
|
+
FileUtils.mv(tmp.join('template'), @name)
|
58
|
+
FileUtils.cd(@name)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def rename
|
63
|
+
exec("renaming project...") do
|
64
|
+
all_files.each {|path| replace_name(path, camelize(@name)) }
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def git_setup
|
69
|
+
exec('Initializing Git...', 'git init')
|
70
|
+
exec("Git origin set to #{@options[:git]}", "git remote add origin #{@options[:git]}")
|
71
|
+
end
|
72
|
+
|
73
|
+
def install_bundle
|
74
|
+
exec('installing your gem bundle...', 'bundle install')
|
75
|
+
end
|
76
|
+
|
77
|
+
def exec(message, task = nil, &block)
|
78
|
+
puts message
|
79
|
+
`#{task}` if task
|
80
|
+
block.call if block_given?
|
81
|
+
end
|
82
|
+
|
83
|
+
def replace_name(path, name)
|
84
|
+
contents = File.read(path)
|
85
|
+
template = 'SAT'
|
86
|
+
File.write(path, File.read(path).gsub(template, name)) if contents.include? template
|
87
|
+
end
|
88
|
+
|
89
|
+
def all_files
|
90
|
+
Dir.glob('**/*').reject {|file| Dir.exists? file }
|
91
|
+
end
|
92
|
+
|
93
|
+
def camelize(str)
|
94
|
+
str.split('_').collect{ |s| s.capitalize! }.join
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
App.new(ARGV).run
|
data/lib/sat.rb
ADDED
data/lib/sat/version.rb
ADDED
data/sat.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'sat/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "sat"
|
8
|
+
spec.version = Sat::VERSION
|
9
|
+
spec.authors = ["Patricio Mac Adden", "Fernando Martínez"]
|
10
|
+
spec.email = ["patriciomacadden@gmail.com"]
|
11
|
+
spec.description = "Sinatra Application Template"
|
12
|
+
spec.summary = "A sinatra application boilerplate"
|
13
|
+
spec.homepage = "https://github.com/patriciomacadden/sat"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = ['sat']
|
18
|
+
spec.test_files = []
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
|
24
|
+
spec.add_dependency 'trollop', '~> 2.0'
|
25
|
+
end
|
data/template/Gemfile
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
gem 'i18n'
|
4
|
+
gem 'sinatra', require: 'sinatra/base'
|
5
|
+
# or use master:
|
6
|
+
# gem 'sinatra', github: 'sinatra/sinatra', require: 'sinatra/base'
|
7
|
+
gem 'sinatra-contrib'
|
8
|
+
# or use master:
|
9
|
+
# gem 'sinatra-contrib', github: 'sinatra/sinatra-contrib'
|
10
|
+
gem 'sinatra-partial'
|
11
|
+
gem 'slim'
|
12
|
+
gem 'sprockets'
|
13
|
+
gem 'thin'
|
14
|
+
|
15
|
+
group :development, :test do
|
16
|
+
gem 'rake'
|
17
|
+
end
|
18
|
+
|
19
|
+
group :test do
|
20
|
+
gem 'minitest', require: 'minitest/autorun'
|
21
|
+
gem 'rack-test', require: 'rack/test'
|
22
|
+
end
|
data/template/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Patricio Mac Adden
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/template/README.md
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# SAT
|
2
|
+
|
3
|
+
TODO: Project description
|
4
|
+
|
5
|
+
## Features
|
6
|
+
|
7
|
+
## Install
|
8
|
+
|
9
|
+
## Usage
|
10
|
+
|
11
|
+
## Contributing
|
12
|
+
|
13
|
+
1. Fork it
|
14
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
15
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
16
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
17
|
+
5. Create new Pull Request
|
18
|
+
|
19
|
+
## License
|
20
|
+
|
21
|
+
See the [LICENSE](LICENSE).
|
data/template/Rakefile
ADDED
File without changes
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module SAT::Application
|
2
|
+
class ApplicationController < Sinatra::Base
|
3
|
+
set builder: Rack::Builder.new
|
4
|
+
set controllers: []
|
5
|
+
|
6
|
+
helpers SAT::Application::ApplicationHelpers
|
7
|
+
|
8
|
+
def self.inherited(subclass)
|
9
|
+
controllers << subclass unless controllers.include? subclass
|
10
|
+
subclass.set :app_file, caller_files.detect { |f| f != app_file }
|
11
|
+
super
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.new(*)
|
15
|
+
self == ApplicationController ? builder.to_app : super
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.prefix=(value)
|
19
|
+
controller = self
|
20
|
+
define_singleton_method(:prefix) { value }
|
21
|
+
builder.map(value) { run controller }
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.views_prefix=(value)
|
25
|
+
define_singleton_method(:views_prefix) { value }
|
26
|
+
end
|
27
|
+
|
28
|
+
def find_template(views, name, engine, &block)
|
29
|
+
super(File.join(views, settings.views_prefix), name, engine, &block) if settings.respond_to? :views_prefix
|
30
|
+
super(File.join(views, settings.prefix), name, engine, &block) if settings.respond_to? :prefix
|
31
|
+
super(File.join(views, 'application'), name, engine, &block)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
h1 = I18n.t 'views.root.index.title'
|
data/template/config.ru
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
require 'forwardable'
|
3
|
+
|
4
|
+
Bundler.require :default, ENV['RACK_ENV']
|
5
|
+
|
6
|
+
module SAT
|
7
|
+
module Application
|
8
|
+
# require the application helpers
|
9
|
+
require File.expand_path(File.join('app', 'helpers', 'application_helpers'))
|
10
|
+
# require the application controller
|
11
|
+
require File.expand_path(File.join('app', 'controllers', 'application_controller'))
|
12
|
+
|
13
|
+
extend SingleForwardable
|
14
|
+
def_single_delegators ApplicationController, :call, :configure, :new, :settings
|
15
|
+
|
16
|
+
require File.expand_path(File.join('config', 'environment'))
|
17
|
+
Dir[File.join('config', 'environments', '**/*.rb')].each { |file| require File.expand_path(file) }
|
18
|
+
|
19
|
+
# require the application's initializers
|
20
|
+
Dir[File.join('config', 'initializer', '**/*.rb')].each { |file| require File.expand_path(file) }
|
21
|
+
# require the rest of the helpers
|
22
|
+
Dir[File.join('app', 'helpers', '**/*.rb')].each { |file| require File.expand_path(file) }
|
23
|
+
# require the rest of the controllers
|
24
|
+
Dir[File.join('app', 'controllers', '**/*.rb')].each { |file| require File.expand_path(file) }
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
SAT::Application.configure do |config|
|
2
|
+
# directory structure
|
3
|
+
config.set :root, File.expand_path('../..', __FILE__)
|
4
|
+
config.set :views, File.join(config.root, 'app', 'views')
|
5
|
+
|
6
|
+
# i18n
|
7
|
+
I18n.load_path = Dir[File.join('config', 'locales', '*.{rb,yml}').to_s]
|
8
|
+
I18n.default_locale = 'en'
|
9
|
+
|
10
|
+
# link header
|
11
|
+
config.helpers Sinatra::LinkHeader
|
12
|
+
|
13
|
+
# logging
|
14
|
+
file = File.new("#{config.root}/log/#{config.environment}.log", 'a+')
|
15
|
+
file.sync = true
|
16
|
+
config.use Rack::CommonLogger, file
|
17
|
+
|
18
|
+
# method override
|
19
|
+
config.enable :method_override
|
20
|
+
|
21
|
+
# partial
|
22
|
+
config.register Sinatra::Partial
|
23
|
+
config.set :partial_template_engine, :slim
|
24
|
+
config.enable :partial_underscores
|
25
|
+
|
26
|
+
# sessions
|
27
|
+
config.enable :sessions
|
28
|
+
|
29
|
+
# show exceptions
|
30
|
+
config.enable :show_exceptions
|
31
|
+
|
32
|
+
# sprockets
|
33
|
+
config.builder.map '/assets' do
|
34
|
+
environment = Sprockets::Environment.new
|
35
|
+
environment.append_path File.join(config.root, 'app', 'assets', 'javascripts')
|
36
|
+
environment.append_path File.join(config.root, 'app', 'assets', 'stylesheets')
|
37
|
+
run environment
|
38
|
+
end
|
39
|
+
|
40
|
+
# template engine
|
41
|
+
config.set :slim, layout_engine: :slim, layout: '../layouts/application'.to_sym
|
42
|
+
end
|
File without changes
|
File without changes
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'minitest_helper'
|
2
|
+
|
3
|
+
describe SAT::Application::RootController do
|
4
|
+
include Rack::Test::Methods
|
5
|
+
|
6
|
+
def app
|
7
|
+
SAT::Application
|
8
|
+
end
|
9
|
+
|
10
|
+
describe 'GET /' do
|
11
|
+
it 'must be ok' do
|
12
|
+
get '/'
|
13
|
+
last_response.must_be :ok?
|
14
|
+
last_response.body.must_match 'Hello World'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
File without changes
|
metadata
ADDED
@@ -0,0 +1,126 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sat
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Patricio Mac Adden
|
8
|
+
- Fernando Martínez
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-08-18 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ~>
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '1.3'
|
21
|
+
type: :development
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ~>
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '1.3'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: rake
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - '>='
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - '>='
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: trollop
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ~>
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '2.0'
|
49
|
+
type: :runtime
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ~>
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '2.0'
|
56
|
+
description: Sinatra Application Template
|
57
|
+
email:
|
58
|
+
- patriciomacadden@gmail.com
|
59
|
+
executables:
|
60
|
+
- sat
|
61
|
+
extensions: []
|
62
|
+
extra_rdoc_files: []
|
63
|
+
files:
|
64
|
+
- .gitignore
|
65
|
+
- Gemfile
|
66
|
+
- LICENSE.txt
|
67
|
+
- README.md
|
68
|
+
- Rakefile
|
69
|
+
- bin/sat
|
70
|
+
- lib/sat.rb
|
71
|
+
- lib/sat/version.rb
|
72
|
+
- sat.gemspec
|
73
|
+
- template/Gemfile
|
74
|
+
- template/LICENSE
|
75
|
+
- template/README.md
|
76
|
+
- template/Rakefile
|
77
|
+
- template/app/assets/images/.gitkeep
|
78
|
+
- template/app/assets/javascripts/application.js
|
79
|
+
- template/app/assets/stylesheets/application.css
|
80
|
+
- template/app/controllers/application_controller.rb
|
81
|
+
- template/app/controllers/root_controller.rb
|
82
|
+
- template/app/helpers/application_helpers.rb
|
83
|
+
- template/app/helpers/root_helpers.rb
|
84
|
+
- template/app/models/.gitkeep
|
85
|
+
- template/app/views/layouts/application.slim
|
86
|
+
- template/app/views/root/index.slim
|
87
|
+
- template/config.ru
|
88
|
+
- template/config/application.rb
|
89
|
+
- template/config/environment.rb
|
90
|
+
- template/config/environments/development.rb
|
91
|
+
- template/config/environments/production.rb
|
92
|
+
- template/config/environments/test.rb
|
93
|
+
- template/config/initializers/.gitkeep
|
94
|
+
- template/config/locales/en.yml
|
95
|
+
- template/log/.gitkeep
|
96
|
+
- template/spec/controllers/application_controller_spec.rb
|
97
|
+
- template/spec/controllers/root_controller_spec.rb
|
98
|
+
- template/spec/helpers/application_helpers_spec.rb
|
99
|
+
- template/spec/helpers/root_helpers_spec.rb
|
100
|
+
- template/spec/minitest_helper.rb
|
101
|
+
- template/spec/models/.gitkeep
|
102
|
+
homepage: https://github.com/patriciomacadden/sat
|
103
|
+
licenses:
|
104
|
+
- MIT
|
105
|
+
metadata: {}
|
106
|
+
post_install_message:
|
107
|
+
rdoc_options: []
|
108
|
+
require_paths:
|
109
|
+
- lib
|
110
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
111
|
+
requirements:
|
112
|
+
- - '>='
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '0'
|
115
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - '>='
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '0'
|
120
|
+
requirements: []
|
121
|
+
rubyforge_project:
|
122
|
+
rubygems_version: 2.0.3
|
123
|
+
signing_key:
|
124
|
+
specification_version: 4
|
125
|
+
summary: A sinatra application boilerplate
|
126
|
+
test_files: []
|