slim-rails 0.2.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +15 -19
- data/.rvmrc +81 -0
- data/.travis.yml +4 -0
- data/Gemfile +7 -0
- data/Guardfile +20 -0
- data/README.md +1 -1
- data/Rakefile +3 -43
- data/lib/generators/slim/controller/controller_generator.rb +3 -4
- data/lib/generators/slim/mailer/mailer_generator.rb +3 -4
- data/lib/generators/slim/scaffold/scaffold_generator.rb +6 -8
- data/lib/generators/slim/scaffold/templates/_form.html.slim +5 -6
- data/lib/generators/slim/scaffold/templates/index.html.slim +6 -6
- data/lib/generators/slim/scaffold/templates/show.html.slim +2 -2
- data/lib/slim-rails.rb +3 -3
- data/lib/slim-rails/version.rb +2 -2
- data/slim-rails.gemspec +24 -67
- data/test/fixtures/routes.rb +56 -0
- data/test/lib/generators/slim/controller_generator_test.rb +2 -2
- data/test/lib/generators/slim/mailer_generator_test.rb +3 -3
- data/test/lib/generators/slim/scaffold_generator_test.rb +10 -5
- data/test/lib/generators/slim/testing_helper.rb +1 -1
- data/test/test_helper.rb +10 -4
- metadata +148 -44
- data/.document +0 -5
data/.gitignore
CHANGED
@@ -1,21 +1,17 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
*~
|
10
|
-
\#*
|
11
|
-
.\#*
|
12
|
-
|
13
|
-
## VIM
|
14
|
-
*.swp
|
15
|
-
|
16
|
-
## PROJECT::GENERAL
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
17
9
|
coverage
|
18
|
-
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
19
12
|
pkg
|
20
|
-
|
21
|
-
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
data/.rvmrc
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
# This is an RVM Project .rvmrc file, used to automatically load the ruby
|
4
|
+
# development environment upon cd'ing into the directory
|
5
|
+
|
6
|
+
# First we specify our desired <ruby>[@<gemset>], the @gemset name is optional.
|
7
|
+
environment_id="ruby-1.9.3-p0@slim-rails"
|
8
|
+
|
9
|
+
#
|
10
|
+
# Uncomment the following lines if you want to verify rvm version per project
|
11
|
+
#
|
12
|
+
# rvmrc_rvm_version="1.10.2" # 1.10.1 seams as a safe start
|
13
|
+
# eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || {
|
14
|
+
# echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading."
|
15
|
+
# return 1
|
16
|
+
# }
|
17
|
+
#
|
18
|
+
|
19
|
+
#
|
20
|
+
# Uncomment following line if you want options to be set only for given project.
|
21
|
+
#
|
22
|
+
# PROJECT_JRUBY_OPTS=( --1.9 )
|
23
|
+
#
|
24
|
+
# The variable PROJECT_JRUBY_OPTS requires the following to be run in shell:
|
25
|
+
#
|
26
|
+
# chmod +x ${rvm_path}/hooks/after_use_jruby_opts
|
27
|
+
#
|
28
|
+
|
29
|
+
#
|
30
|
+
# First we attempt to load the desired environment directly from the environment
|
31
|
+
# file. This is very fast and efficient compared to running through the entire
|
32
|
+
# CLI and selector. If you want feedback on which environment was used then
|
33
|
+
# insert the word 'use' after --create as this triggers verbose mode.
|
34
|
+
#
|
35
|
+
if [[ -d "${rvm_path:-$HOME/.rvm}/environments" \
|
36
|
+
&& -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
|
37
|
+
then
|
38
|
+
\. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
|
39
|
+
|
40
|
+
if [[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]]
|
41
|
+
then
|
42
|
+
. "${rvm_path:-$HOME/.rvm}/hooks/after_use"
|
43
|
+
fi
|
44
|
+
else
|
45
|
+
# If the environment file has not yet been created, use the RVM CLI to select.
|
46
|
+
if ! rvm --create "$environment_id"
|
47
|
+
then
|
48
|
+
echo "Failed to create RVM environment '${environment_id}'."
|
49
|
+
return 1
|
50
|
+
fi
|
51
|
+
fi
|
52
|
+
|
53
|
+
#
|
54
|
+
# If you use an RVM gemset file to install a list of gems (*.gems), you can have
|
55
|
+
# it be automatically loaded. Uncomment the following and adjust the filename if
|
56
|
+
# necessary.
|
57
|
+
#
|
58
|
+
# filename=".gems"
|
59
|
+
# if [[ -s "$filename" ]]
|
60
|
+
# then
|
61
|
+
# rvm gemset import "$filename" | grep -v already | grep -v listed | grep -v complete | sed '/^$/d'
|
62
|
+
# fi
|
63
|
+
|
64
|
+
# If you use bundler, this might be useful to you:
|
65
|
+
# if [[ -s Gemfile ]] && ! command -v bundle >/dev/null
|
66
|
+
# then
|
67
|
+
# printf "%b" "The rubygem 'bundler' is not installed. Installing it now.\n"
|
68
|
+
# gem install bundler
|
69
|
+
# fi
|
70
|
+
# if [[ -s Gemfile ]] && command -v bundle
|
71
|
+
# then
|
72
|
+
# bundle install
|
73
|
+
# fi
|
74
|
+
|
75
|
+
if [[ $- == *i* ]] # check for interactive shells
|
76
|
+
then
|
77
|
+
echo "Using: $(tput setaf 2)$GEM_HOME$(tput sgr0)" # show the user the ruby and gemset they are using in green
|
78
|
+
else
|
79
|
+
echo "Using: $GEM_HOME" # don't use colors in interactive shells
|
80
|
+
fi
|
81
|
+
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Guardfile
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
guard 'minitest' do
|
5
|
+
# with Minitest::Unit
|
6
|
+
watch(%r|^test/test_(.*)\.rb|)
|
7
|
+
watch(%r|^lib/(.*)\.rb|) { |m| "test/test_#{m[1]}.rb" }
|
8
|
+
watch(%r|^test/test_helper\.rb|) { "test" }
|
9
|
+
|
10
|
+
# with Minitest::Spec
|
11
|
+
# watch(%r|^spec/(.*)_spec\.rb|)
|
12
|
+
# watch(%r|^lib/(.*)\.rb|) { |m| "spec/#{m[1]}_spec.rb" }
|
13
|
+
# watch(%r|^spec/spec_helper\.rb|) { "spec" }
|
14
|
+
end
|
15
|
+
|
16
|
+
guard 'rocco' do
|
17
|
+
watch(%r{^lib/.*\.rb$})
|
18
|
+
end
|
19
|
+
|
20
|
+
watch(%r|^benchmarks/(.*)\.rb$|) { |m| eval File.read "benchmarks/#{m[1]}.rb" }
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# slim-rails
|
2
2
|
|
3
|
-
slim-rails provides Slim generators for Rails 3. It was based on [haml-rails](http://
|
3
|
+
slim-rails provides Slim generators for Rails 3. It was based on [haml-rails](http://github.com/indirect/haml-rails) and it does basically the same: configures Slim as the template engine automatically for your rails app.
|
4
4
|
To use it, add this line to your Gemfile:
|
5
5
|
|
6
6
|
gem "slim-rails"
|
data/Rakefile
CHANGED
@@ -1,21 +1,6 @@
|
|
1
|
-
|
2
|
-
require '
|
3
|
-
|
4
|
-
begin
|
5
|
-
require 'jeweler'
|
6
|
-
Jeweler::Tasks.new do |gem|
|
7
|
-
gem.name = "slim-rails"
|
8
|
-
gem.version = Slim::Rails::VERSION
|
9
|
-
gem.summary = "Provides generators for Rails 3"
|
10
|
-
gem.description = "Provide generators for Rails 3"
|
11
|
-
gem.email = "lalmeida08@gmail.com"
|
12
|
-
gem.homepage = "http://github.com/leogalmeida/slim-rails"
|
13
|
-
gem.authors = ["Leonardo Almeida"]
|
14
|
-
end
|
15
|
-
Jeweler::GemcutterTasks.new
|
16
|
-
rescue LoadError
|
17
|
-
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
18
|
-
end
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
require 'bundler'
|
3
|
+
Bundler::GemHelper.install_tasks
|
19
4
|
|
20
5
|
require 'rake/testtask'
|
21
6
|
Rake::TestTask.new(:test) do |test|
|
@@ -24,29 +9,4 @@ Rake::TestTask.new(:test) do |test|
|
|
24
9
|
test.verbose = true
|
25
10
|
end
|
26
11
|
|
27
|
-
begin
|
28
|
-
require 'rcov/rcovtask'
|
29
|
-
Rcov::RcovTask.new do |test|
|
30
|
-
test.libs << 'test'
|
31
|
-
test.pattern = 'test/**/*_test.rb'
|
32
|
-
test.verbose = true
|
33
|
-
end
|
34
|
-
rescue LoadError
|
35
|
-
task :rcov do
|
36
|
-
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
task :test => :check_dependencies
|
41
|
-
|
42
12
|
task :default => :test
|
43
|
-
|
44
|
-
require 'rake/rdoctask'
|
45
|
-
Rake::RDocTask.new do |rdoc|
|
46
|
-
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
47
|
-
|
48
|
-
rdoc.rdoc_dir = 'rdoc'
|
49
|
-
rdoc.title = "slim-rails #{version}"
|
50
|
-
rdoc.rdoc_files.include('README*')
|
51
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
52
|
-
end
|
@@ -3,14 +3,13 @@ require 'rails/generators/erb/controller/controller_generator'
|
|
3
3
|
module Slim
|
4
4
|
module Generators
|
5
5
|
class ControllerGenerator < Erb::Generators::ControllerGenerator
|
6
|
-
source_root File.expand_path
|
7
|
-
|
8
|
-
protected
|
6
|
+
source_root File.expand_path '..', 'templates', __FILE__
|
9
7
|
|
8
|
+
protected
|
10
9
|
def handler
|
11
10
|
:slim
|
12
11
|
end
|
13
12
|
|
14
13
|
end
|
15
14
|
end
|
16
|
-
end
|
15
|
+
end
|
@@ -3,14 +3,13 @@ require 'generators/slim/controller/controller_generator'
|
|
3
3
|
module Slim
|
4
4
|
module Generators
|
5
5
|
class MailerGenerator < ControllerGenerator
|
6
|
-
source_root File.expand_path
|
7
|
-
|
8
|
-
protected
|
6
|
+
source_root File.expand_path '..', 'templates', __FILE__
|
9
7
|
|
8
|
+
protected
|
10
9
|
def format
|
11
10
|
:text
|
12
11
|
end
|
13
12
|
|
14
13
|
end
|
15
14
|
end
|
16
|
-
end
|
15
|
+
end
|
@@ -3,27 +3,25 @@ require 'rails/generators/erb/scaffold/scaffold_generator'
|
|
3
3
|
module Slim
|
4
4
|
module Generators
|
5
5
|
class ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
6
|
-
source_root File.expand_path
|
6
|
+
source_root File.expand_path File.join '..', templates, __FILE__
|
7
7
|
|
8
8
|
def copy_view_files
|
9
9
|
available_views.each do |view|
|
10
|
-
filename = filename_with_extensions
|
11
|
-
template "#{view}.html.slim", File.join
|
10
|
+
filename = filename_with_extensions view
|
11
|
+
template "#{view}.html.slim", File.join 'app', 'views', controller_file_path, filename
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
15
|
hook_for :form_builder, :as => :scaffold
|
16
16
|
|
17
|
-
|
18
|
-
|
17
|
+
protected
|
19
18
|
def available_views
|
20
|
-
|
19
|
+
['index', 'edit', 'show', 'new', '_form']
|
21
20
|
end
|
22
21
|
|
23
22
|
def handler
|
24
23
|
:slim
|
25
24
|
end
|
26
|
-
|
27
25
|
end
|
28
26
|
end
|
29
|
-
end
|
27
|
+
end
|
@@ -1,15 +1,14 @@
|
|
1
1
|
= form_for @<%= singular_table_name %> do |f|
|
2
|
-
-if @<%= singular_table_name %>.errors.any?
|
2
|
+
- if @<%= singular_table_name %>.errors.any?
|
3
3
|
#error_explanation
|
4
4
|
h2 = "#{pluralize(@<%= singular_table_name %>.errors.count, "error")} prohibited this <%= singular_table_name %> from being saved:"
|
5
5
|
ul
|
6
|
-
- @<%= singular_table_name %>.errors.full_messages.each do |
|
7
|
-
li=
|
6
|
+
- @<%= singular_table_name %>.errors.full_messages.each do |message|
|
7
|
+
li = message
|
8
8
|
|
9
|
-
<%
|
9
|
+
<% attributes.each do |attribute| -%>
|
10
10
|
.field
|
11
11
|
= f.label :<%= attribute.name %>
|
12
12
|
= f.<%= attribute.field_type %> :<%= attribute.name %>
|
13
13
|
<% end -%>
|
14
|
-
.actions
|
15
|
-
= f.submit 'Save'
|
14
|
+
.actions = f.submit 'Save'
|
@@ -2,7 +2,7 @@ h1 Listing <%= plural_table_name %>
|
|
2
2
|
|
3
3
|
table
|
4
4
|
tr
|
5
|
-
<%
|
5
|
+
<% attributes.each do |attribute| -%>
|
6
6
|
th <%= attribute.human_name %>
|
7
7
|
<% end -%>
|
8
8
|
th
|
@@ -11,12 +11,12 @@ table
|
|
11
11
|
|
12
12
|
- @<%= plural_table_name %>.each do |<%= singular_table_name %>|
|
13
13
|
tr
|
14
|
-
<%
|
15
|
-
td= <%= singular_table_name %>.<%= attribute.name %>
|
14
|
+
<% attributes.each do |attribute| -%>
|
15
|
+
td = <%= singular_table_name %>.<%= attribute.name %>
|
16
16
|
<% end -%>
|
17
|
-
td= link_to 'Show', <%= singular_table_name %>
|
18
|
-
td= link_to 'Edit', edit_<%= singular_table_name %>_path(<%= singular_table_name %>)
|
19
|
-
td= link_to 'Destroy', <%= singular_table_name %>, :confirm => 'Are you sure?', :method => :delete
|
17
|
+
td = link_to 'Show', <%= singular_table_name %>
|
18
|
+
td = link_to 'Edit', edit_<%= singular_table_name %>_path(<%= singular_table_name %>)
|
19
|
+
td = link_to 'Destroy', <%= singular_table_name %>, :confirm => 'Are you sure?', :method => :delete
|
20
20
|
|
21
21
|
br
|
22
22
|
|
data/lib/slim-rails.rb
CHANGED
@@ -4,10 +4,10 @@ require 'slim'
|
|
4
4
|
module Slim
|
5
5
|
module Rails
|
6
6
|
class Railtie < ::Rails::Railtie
|
7
|
-
|
8
|
-
config.app_generators.template_engine :slim
|
9
|
-
else
|
7
|
+
unless ::Rails.version =~ /$3.1/
|
10
8
|
config.generators.template_engine :slim
|
9
|
+
else
|
10
|
+
config.app_generators.template_engine :slim
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
data/lib/slim-rails/version.rb
CHANGED
data/slim-rails.gemspec
CHANGED
@@ -1,73 +1,30 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
1
|
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/slim-rails/version', __FILE__)
|
5
3
|
|
6
|
-
Gem::Specification.new do |
|
7
|
-
|
8
|
-
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Leonardo Almeida"]
|
6
|
+
gem.email = ["lalmeida08@gmail.com"]
|
7
|
+
gem.description = 'Provides the generator settings required for Rails 3 to use Slim'
|
8
|
+
gem.summary = %q{Provides the generator settings required for Rails 3 to use Slim}
|
9
|
+
gem.homepage = 'http://github.com/leogalmeida/slim-rails'
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
"LICENSE",
|
17
|
-
"README.md"
|
18
|
-
]
|
19
|
-
s.files = [
|
20
|
-
".document",
|
21
|
-
".gitignore",
|
22
|
-
"LICENSE",
|
23
|
-
"README.md",
|
24
|
-
"Rakefile",
|
25
|
-
"lib/generators/slim/controller/controller_generator.rb",
|
26
|
-
"lib/generators/slim/controller/templates/view.html.slim",
|
27
|
-
"lib/generators/slim/mailer/mailer_generator.rb",
|
28
|
-
"lib/generators/slim/mailer/templates/view.text.slim",
|
29
|
-
"lib/generators/slim/scaffold/scaffold_generator.rb",
|
30
|
-
"lib/generators/slim/scaffold/templates/_form.html.slim",
|
31
|
-
"lib/generators/slim/scaffold/templates/edit.html.slim",
|
32
|
-
"lib/generators/slim/scaffold/templates/index.html.slim",
|
33
|
-
"lib/generators/slim/scaffold/templates/new.html.slim",
|
34
|
-
"lib/generators/slim/scaffold/templates/show.html.slim",
|
35
|
-
"lib/slim-rails.rb",
|
36
|
-
"lib/slim-rails/version.rb",
|
37
|
-
"slim-rails.gemspec",
|
38
|
-
"test/fixtures/routes.rb",
|
39
|
-
"test/lib/generators/slim/controller_generator_test.rb",
|
40
|
-
"test/lib/generators/slim/mailer_generator_test.rb",
|
41
|
-
"test/lib/generators/slim/scaffold_generator_test.rb",
|
42
|
-
"test/lib/generators/slim/testing_helper.rb",
|
43
|
-
"test/test_helper.rb",
|
44
|
-
"tmp/rails/config/routes.rb",
|
45
|
-
"tmp/rails/public/stylesheets/scaffold.css"
|
46
|
-
]
|
47
|
-
s.homepage = %q{http://github.com/leogalmeida/slim-rails}
|
48
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
49
|
-
s.require_paths = ["lib"]
|
50
|
-
s.rubygems_version = %q{1.3.7}
|
51
|
-
s.summary = %q{Provides generators for Rails 3}
|
52
|
-
s.test_files = [
|
53
|
-
"test/fixtures/routes.rb",
|
54
|
-
"test/lib/generators/slim/controller_generator_test.rb",
|
55
|
-
"test/lib/generators/slim/mailer_generator_test.rb",
|
56
|
-
"test/lib/generators/slim/scaffold_generator_test.rb",
|
57
|
-
"test/lib/generators/slim/testing_helper.rb",
|
58
|
-
"test/test_helper.rb"
|
59
|
-
]
|
11
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
12
|
+
gem.files = `git ls-files`.split("\n")
|
13
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
14
|
+
gem.name = 'slim-rails'
|
15
|
+
gem.require_paths = ['lib']
|
16
|
+
gem.version = Slim::Rails::VERSION
|
60
17
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
18
|
+
gem.add_development_dependency 'rake', '~> 0.9'
|
19
|
+
gem.add_development_dependency 'rocco', '~> 0.8'
|
20
|
+
gem.add_development_dependency 'redcarpet', '~> 1.0'
|
21
|
+
gem.add_development_dependency 'awesome_print', '~> 1.0'
|
22
|
+
gem.add_development_dependency 'guard', '~> 0.10'
|
23
|
+
gem.add_development_dependency 'guard-minitest', '~> 0.4'
|
24
|
+
gem.add_development_dependency 'guard-rocco', '~> 0.0.3'
|
25
|
+
gem.add_runtime_dependency 'activesupport', '~> 3.0'
|
26
|
+
gem.add_runtime_dependency 'actionpack', '~> 3.0'
|
27
|
+
gem.add_runtime_dependency 'railties', '~> 3.0'
|
28
|
+
gem.add_runtime_dependency 'slim', '~> 1.0'
|
72
29
|
end
|
73
30
|
|
data/test/fixtures/routes.rb
CHANGED
@@ -1,2 +1,58 @@
|
|
1
1
|
TestApp.routes.draw do |map|
|
2
|
+
# The priority is based upon order of creation:
|
3
|
+
# first created -> highest priority.
|
4
|
+
|
5
|
+
# Sample of regular route:
|
6
|
+
# match 'products/:id' => 'catalog#view'
|
7
|
+
# Keep in mind you can assign values other than :controller and :action
|
8
|
+
|
9
|
+
# Sample of named route:
|
10
|
+
# match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
|
11
|
+
# This route can be invoked with purchase_url(:id => product.id)
|
12
|
+
|
13
|
+
# Sample resource route (maps HTTP verbs to controller actions automatically):
|
14
|
+
# resources :products
|
15
|
+
|
16
|
+
# Sample resource route with options:
|
17
|
+
# resources :products do
|
18
|
+
# member do
|
19
|
+
# get :short
|
20
|
+
# post :toggle
|
21
|
+
# end
|
22
|
+
#
|
23
|
+
# collection do
|
24
|
+
# get :sold
|
25
|
+
# end
|
26
|
+
# end
|
27
|
+
|
28
|
+
# Sample resource route with sub-resources:
|
29
|
+
# resources :products do
|
30
|
+
# resources :comments, :sales
|
31
|
+
# resource :seller
|
32
|
+
# end
|
33
|
+
|
34
|
+
# Sample resource route with more complex sub-resources
|
35
|
+
# resources :products do
|
36
|
+
# resources :comments
|
37
|
+
# resources :sales do
|
38
|
+
# get :recent, :on => :collection
|
39
|
+
# end
|
40
|
+
# end
|
41
|
+
|
42
|
+
# Sample resource route within a namespace:
|
43
|
+
# namespace :admin do
|
44
|
+
# # Directs /admin/products/* to Admin::ProductsController
|
45
|
+
# # (app/controllers/admin/products_controller.rb)
|
46
|
+
# resources :products
|
47
|
+
# end
|
48
|
+
|
49
|
+
# You can have the root of your site routed with "root"
|
50
|
+
# just remember to delete public/index.html.
|
51
|
+
# root :to => "welcome#index"
|
52
|
+
|
53
|
+
# See how all your routes lay out with "rake routes"
|
54
|
+
|
55
|
+
# This is a legacy wild controller route that's not recommended for RESTful applications.
|
56
|
+
# Note: This route will make all actions in every controller accessible via GET requests.
|
57
|
+
# match ':controller(/:action(/:id(.:format)))'
|
2
58
|
end
|
@@ -11,7 +11,7 @@ class Slim::Generators::ControllerGeneratorTest < Rails::Generators::TestCase
|
|
11
11
|
|
12
12
|
test "should invoke template engine" do
|
13
13
|
run_generator
|
14
|
-
assert_file "app
|
15
|
-
assert_file "app
|
14
|
+
assert_file File.join "app", "views", "account", "foo.html.slim", %r(app/views/account/foo\.html\.slim)
|
15
|
+
assert_file File.join "app", "views", "account", "bar.html.slim", %r(app/views/account/bar\.html\.slim)
|
16
16
|
end
|
17
17
|
end
|
@@ -11,14 +11,14 @@ class Slim::Generators::MailerGeneratorTest < Rails::Generators::TestCase
|
|
11
11
|
|
12
12
|
test "should invoke template engine" do
|
13
13
|
run_generator
|
14
|
-
assert_file "app
|
14
|
+
assert_file File.join "app", "views", "notifier", "foo.text.slim" do |view|
|
15
15
|
assert_match %r(app/views/notifier/foo\.text\.slim), view
|
16
16
|
assert_match /\= @greeting/, view
|
17
17
|
end
|
18
18
|
|
19
|
-
assert_file "app
|
19
|
+
assert_file File.join "app", "views", "notifier", "bar.text.slim" do |view|
|
20
20
|
assert_match %r(app/views/notifier/bar\.text\.slim), view
|
21
21
|
assert_match /\= @greeting/, view
|
22
22
|
end
|
23
23
|
end
|
24
|
-
end
|
24
|
+
end
|
@@ -12,15 +12,20 @@ class Slim::Generators::ScaffoldGeneratorTest < Rails::Generators::TestCase
|
|
12
12
|
test "should invoke template engine" do
|
13
13
|
run_generator
|
14
14
|
|
15
|
-
%w(index edit new show _form).each { |view| assert_file "app
|
16
|
-
assert_no_file "app
|
15
|
+
%w(index edit new show _form).each { |view| assert_file File.join "app", "views", "product_lines", "#{view}.html.slim" }
|
16
|
+
assert_no_file File.join "app", "views", "layouts", "product_lines.html.slim"
|
17
17
|
end
|
18
18
|
|
19
19
|
test "should revoke template engine" do
|
20
20
|
run_generator
|
21
21
|
run_generator ["product_line"], :behavior => :revoke
|
22
22
|
|
23
|
-
assert_no_file "app
|
24
|
-
assert_no_file "app
|
23
|
+
assert_no_file File.join "app", "views", "product_lines"
|
24
|
+
assert_no_file File.join "app", "views", "layouts", "product_lines.html.slim"
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
|
+
test "should invoke form builder" do
|
28
|
+
run_generator %w(product_line title:string price:integer --template-engine slim --form-builder some-form-builder)
|
29
|
+
assert_no_file File.join "app", "views", "product_lines", "_form.html.slim"
|
30
|
+
end
|
31
|
+
end
|
@@ -1 +1 @@
|
|
1
|
-
require_generators :slim => ['scaffold', 'controller', 'mailer']
|
1
|
+
require_generators :slim => ['scaffold', 'controller', 'mailer']
|
data/test/test_helper.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'rubygems'
|
2
1
|
require 'test/unit'
|
3
2
|
require 'rails/all'
|
4
3
|
require 'rails/generators'
|
@@ -16,9 +15,7 @@ module Rails
|
|
16
15
|
end
|
17
16
|
Rails.application.config.root = Rails.root
|
18
17
|
|
19
|
-
|
20
|
-
|
21
|
-
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
18
|
+
Dir[File.join File.dirname(__FILE__), 'support', '**', '*.rb'].each {|f| require f}
|
22
19
|
|
23
20
|
def copy_routes
|
24
21
|
routes = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'routes.rb'))
|
@@ -27,6 +24,15 @@ def copy_routes
|
|
27
24
|
FileUtils.cp File.expand_path(routes), destination
|
28
25
|
end
|
29
26
|
|
27
|
+
# Asserts the given class exists in the given content. When a block is given,
|
28
|
+
# it yields the content of the class.
|
29
|
+
#
|
30
|
+
# assert_file "test/functional/accounts_controller_test.rb" do |controller_test|
|
31
|
+
# assert_class "AccountsControllerTest", controller_test do |klass|
|
32
|
+
# assert_match /context "index action"/, klass
|
33
|
+
# end
|
34
|
+
# end
|
35
|
+
#
|
30
36
|
def assert_class(klass, content)
|
31
37
|
assert content =~ /class #{klass}(\(.+\))?(.*?)\nend/m, "Expected to have class #{klass}"
|
32
38
|
yield $2.strip if block_given?
|
metadata
CHANGED
@@ -1,41 +1,149 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: slim-rails
|
3
|
-
version: !ruby/object:Gem::Version
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
4
5
|
prerelease:
|
5
|
-
version: 0.2.1
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- Leonardo Almeida
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
12
|
+
date: 2012-01-30 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rake
|
16
|
+
requirement: &70169858863060 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0.9'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70169858863060
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rocco
|
27
|
+
requirement: &70169858862300 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ~>
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0.8'
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70169858862300
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: redcarpet
|
38
|
+
requirement: &70169858861480 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '1.0'
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70169858861480
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: awesome_print
|
49
|
+
requirement: &70169858860800 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.0'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *70169858860800
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: guard
|
60
|
+
requirement: &70169858860100 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ~>
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0.10'
|
66
|
+
type: :development
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *70169858860100
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: guard-minitest
|
71
|
+
requirement: &70169858859460 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ~>
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0.4'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: *70169858859460
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: guard-rocco
|
82
|
+
requirement: &70169858858600 !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ~>
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: 0.0.3
|
88
|
+
type: :development
|
18
89
|
prerelease: false
|
19
|
-
|
90
|
+
version_requirements: *70169858858600
|
91
|
+
- !ruby/object:Gem::Dependency
|
92
|
+
name: activesupport
|
93
|
+
requirement: &70169858858080 !ruby/object:Gem::Requirement
|
20
94
|
none: false
|
21
|
-
requirements:
|
22
|
-
- -
|
23
|
-
- !ruby/object:Gem::Version
|
24
|
-
version: 0
|
95
|
+
requirements:
|
96
|
+
- - ~>
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '3.0'
|
25
99
|
type: :runtime
|
26
|
-
|
27
|
-
|
28
|
-
|
100
|
+
prerelease: false
|
101
|
+
version_requirements: *70169858858080
|
102
|
+
- !ruby/object:Gem::Dependency
|
103
|
+
name: actionpack
|
104
|
+
requirement: &70169858857400 !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ~>
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '3.0'
|
110
|
+
type: :runtime
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: *70169858857400
|
113
|
+
- !ruby/object:Gem::Dependency
|
114
|
+
name: railties
|
115
|
+
requirement: &70169858856760 !ruby/object:Gem::Requirement
|
116
|
+
none: false
|
117
|
+
requirements:
|
118
|
+
- - ~>
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '3.0'
|
121
|
+
type: :runtime
|
122
|
+
prerelease: false
|
123
|
+
version_requirements: *70169858856760
|
124
|
+
- !ruby/object:Gem::Dependency
|
125
|
+
name: slim
|
126
|
+
requirement: &70169858856140 !ruby/object:Gem::Requirement
|
127
|
+
none: false
|
128
|
+
requirements:
|
129
|
+
- - ~>
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '1.0'
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: *70169858856140
|
135
|
+
description: Provides the generator settings required for Rails 3 to use Slim
|
136
|
+
email:
|
137
|
+
- lalmeida08@gmail.com
|
29
138
|
executables: []
|
30
|
-
|
31
139
|
extensions: []
|
32
|
-
|
33
|
-
|
34
|
-
- LICENSE
|
35
|
-
- README.md
|
36
|
-
files:
|
37
|
-
- .document
|
140
|
+
extra_rdoc_files: []
|
141
|
+
files:
|
38
142
|
- .gitignore
|
143
|
+
- .rvmrc
|
144
|
+
- .travis.yml
|
145
|
+
- Gemfile
|
146
|
+
- Guardfile
|
39
147
|
- LICENSE
|
40
148
|
- README.md
|
41
149
|
- Rakefile
|
@@ -60,35 +168,31 @@ files:
|
|
60
168
|
- test/test_helper.rb
|
61
169
|
- tmp/rails/config/routes.rb
|
62
170
|
- tmp/rails/public/stylesheets/scaffold.css
|
63
|
-
has_rdoc: true
|
64
171
|
homepage: http://github.com/leogalmeida/slim-rails
|
65
172
|
licenses: []
|
66
|
-
|
67
173
|
post_install_message:
|
68
|
-
rdoc_options:
|
69
|
-
|
70
|
-
require_paths:
|
174
|
+
rdoc_options: []
|
175
|
+
require_paths:
|
71
176
|
- lib
|
72
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
177
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
73
178
|
none: false
|
74
|
-
requirements:
|
75
|
-
- -
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
version:
|
78
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
179
|
+
requirements:
|
180
|
+
- - ! '>='
|
181
|
+
- !ruby/object:Gem::Version
|
182
|
+
version: '0'
|
183
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
184
|
none: false
|
80
|
-
requirements:
|
81
|
-
- -
|
82
|
-
- !ruby/object:Gem::Version
|
83
|
-
version:
|
185
|
+
requirements:
|
186
|
+
- - ! '>='
|
187
|
+
- !ruby/object:Gem::Version
|
188
|
+
version: '0'
|
84
189
|
requirements: []
|
85
|
-
|
86
190
|
rubyforge_project:
|
87
|
-
rubygems_version: 1.
|
191
|
+
rubygems_version: 1.8.10
|
88
192
|
signing_key:
|
89
193
|
specification_version: 3
|
90
|
-
summary: Provides
|
91
|
-
test_files:
|
194
|
+
summary: Provides the generator settings required for Rails 3 to use Slim
|
195
|
+
test_files:
|
92
196
|
- test/fixtures/routes.rb
|
93
197
|
- test/lib/generators/slim/controller_generator_test.rb
|
94
198
|
- test/lib/generators/slim/mailer_generator_test.rb
|