rails_templater 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,17 +1,25 @@
1
+ 0.1.2 (February 1, 2011)
2
+
3
+ * Added the Slim template engine (via fredwu)
4
+ * Fixed the layout template for Haml
5
+
1
6
  0.1.1 (January 30, 2011)
2
- rails-templater choices are now agnostic
3
- Add ActiveRecord as an ORM option
4
- Add TestUnit as a Testing Framework option
5
- Add Prototype as a JavaScript Framework option
6
- Remarkable RSpec matchers are optional and are dependent on the RSpec recipe
7
- Haml is an optional choice for your View Templates
8
- Sass is an optional choice for composing Stylesheets
9
- Compass is now dependent on the Sass recipe
10
- Compass has three options: core, blueprint semantic, and blueprint basic
11
- Cucumber is an optional choice for Integration Testing
7
+
8
+ * rails-templater choices are now agnostic
9
+ * Add ActiveRecord as an ORM option
10
+ * Add TestUnit as a Testing Framework option
11
+ * Add Prototype as a JavaScript Framework option
12
+ * Remarkable RSpec matchers are optional and are dependent on the RSpec recipe
13
+ * Haml is an optional choice for your View Templates
14
+ * Sass is an optional choice for composing Stylesheets
15
+ * Compass is now dependent on the Sass recipe
16
+ * Compass has three options: core, blueprint semantic, and blueprint basic
17
+ * Cucumber is an optional choice for Integration Testing
12
18
 
13
19
  0.0.2 (January 23, 2011)
14
- Add a custom generator for FactoryGirl which uses the new 2.0.0 syntax
20
+
21
+ * Add a custom generator for FactoryGirl which uses the new 2.0.0 syntax
15
22
 
16
23
  0.0.1 (January 13, 2011)
17
- First version
24
+
25
+ * First version
data/README.textile CHANGED
@@ -44,15 +44,16 @@ h3. Template Engine
44
44
 
45
45
  * ERB
46
46
  * "Haml":http://haml-lang.com (optional)
47
+ * "Slim":http://github.com/stonean/slim (optional)
47
48
 
48
- h3. Stylesheets
49
+ h3. Stylesheets
49
50
 
50
51
  * "Sass":http://sass-lang.com for generating CSS (optional)
51
52
  ** "Compass":http://compass-style.org as your stylesheet authoring framework (optional)
52
53
 
53
-
54
+
54
55
  h2. Note on Patches/Pull Requests
55
-
56
+
56
57
  * Fork the project.
57
58
  * Make your feature addition or bug fix in a branch.
58
59
  * Send me a pull request.
@@ -0,0 +1,23 @@
1
+ module RailsTemplater
2
+ class TemplateEngine
3
+
4
+ DEFAULT = :haml
5
+ SUPPORTED_TYPES = [:haml, :slim, :erb]
6
+
7
+ def type
8
+ @type || DEFAULT
9
+ end
10
+
11
+ def type=(value)
12
+ raise NotSupportedError unless SUPPORTED_TYPES.include?(value)
13
+ @type ||= value
14
+ end
15
+
16
+ SUPPORTED_TYPES.each do |type|
17
+ define_method "#{type}?" do
18
+ self.type == type
19
+ end
20
+ end
21
+
22
+ end
23
+ end
@@ -15,11 +15,15 @@ module RailsTemplater
15
15
  def orm
16
16
  @orm ||= Orm.new
17
17
  end
18
-
18
+
19
19
  def javascript_framework
20
20
  @javascript_framework ||= JavaScriptFramework.new
21
21
  end
22
22
 
23
+ def template_engine
24
+ @template_engine ||= TemplateEngine.new
25
+ end
26
+
23
27
  def post_bundler(&block)
24
28
  @post_bundler_strategies << block
25
29
  end
@@ -40,10 +44,10 @@ module RailsTemplater
40
44
  end
41
45
 
42
46
  end
43
-
47
+
44
48
  def testing_framework
45
49
  @testing_framework ||= TestingFramework.new
46
50
  end
47
-
51
+
48
52
  end
49
53
  end
@@ -1,3 +1,3 @@
1
1
  module RailsTemplater
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -10,6 +10,7 @@ module RailsTemplater
10
10
  autoload :JavaScriptFramework, 'rails_templater/javascript_framework'
11
11
  autoload :Orm, 'rails_templater/orm'
12
12
  autoload :Templater, 'rails_templater/templater'
13
+ autoload :TemplateEngine, 'rails_templater/template_engine'
13
14
  autoload :TestingFramework, 'rails_templater/testing_framework'
14
15
 
15
16
  def template_runner
@@ -1,7 +1,7 @@
1
- if yes?("\n[Template Engine] Would you like use Haml for your view templates? [y|n]: ", Thor::Shell::Color::BLUE)
2
- gem 'haml'
3
- gem "haml-rails"
1
+ say "\nReplacing ERb with Haml as your Template Engine\n", Thor::Shell::Color::YELLOW
4
2
 
5
- remove_file 'app/views/layouts/application.html.erb'
6
- create_file 'app/views/layouts/application.html.haml', templater.load_template('app/views/layouts/application.html.haml','haml')
7
- end
3
+ gem 'haml'
4
+ gem "haml-rails"
5
+
6
+ remove_file 'app/views/layouts/application.html.erb'
7
+ create_file 'app/views/layouts/application.html.haml', templater.load_template('app/views/layouts/application.html.haml', 'haml')
@@ -0,0 +1,6 @@
1
+ say "\nReplacing ERb with Slim as your Template Engine\n", Thor::Shell::Color::YELLOW
2
+
3
+ gem 'slim', :require => 'slim/rails'
4
+
5
+ remove_file 'app/views/layouts/application.html.erb'
6
+ create_file 'app/views/layouts/application.html.slim', templater.load_template('app/views/layouts/application.html.slim', 'slim')
@@ -0,0 +1,20 @@
1
+ say "\nWhich Template Engine would you like to use?\n", Thor::Shell::Color::BLUE
2
+
3
+ template_engine_options = {
4
+ 'Option' => 'Template Engine',
5
+ '1' => 'Haml',
6
+ '2' => 'Slim',
7
+ '3' => 'ERb',
8
+ }
9
+
10
+ print_table template_engine_options.to_a, :ident => 4
11
+
12
+ template_engine_selection = ask("\nOption: ", Thor::Shell::Color::BLUE)
13
+ if template_engine_selection.present?
14
+ templater.template_engine.type = template_engine_options[template_engine_selection].underscore.to_sym
15
+ end
16
+
17
+ $stdout << "\n\n"
18
+
19
+ apply templater.recipe('haml') if templater.template_engine.haml?
20
+ apply templater.recipe('slim') if templater.template_engine.slim?
@@ -3,7 +3,7 @@ $LOAD_PATH.unshift(File.expand_path('./../../', __FILE__))
3
3
  require 'rails_templater'
4
4
  require File.join(File.dirname(__FILE__), 'core_ext.rb')
5
5
 
6
- %w(default orm testing_framework javascript_framework haml sass cucumber).each do |recipe|
6
+ %w(default orm testing_framework javascript_framework template_engine sass cucumber).each do |recipe|
7
7
  apply templater.recipe(recipe)
8
8
  end
9
9
 
@@ -16,4 +16,4 @@ say("\nbundle install complete\n", Thor::Shell::Color::YELLOW)
16
16
  execute_post_bundler_strategies
17
17
 
18
18
  git :add => "."
19
- git :commit => "-m 'Initial commit'"
19
+ git :commit => "-m 'Initial commit'"
@@ -1,9 +1,9 @@
1
1
  !!! 5
2
2
  %html
3
- %head
4
- = csrf_meta_tag
5
- /[if lt IE 9]
6
- = javascript_include_tag 'html5'
7
- %body
8
- = yield
9
- = javascript_include_tag :defaults
3
+ %head
4
+ = csrf_meta_tag
5
+ /[if lt IE 9]
6
+ = javascript_include_tag 'html5'
7
+ %body
8
+ = yield
9
+ = javascript_include_tag :defaults
@@ -0,0 +1,10 @@
1
+ ! doctype 5
2
+ html
3
+ head
4
+ = csrf_meta_tag
5
+ /![if lt IE 9]
6
+ = javascript_include_tag 'html5'
7
+ /![endif]
8
+ body
9
+ = yield
10
+ = javascript_include_tag :defaults
@@ -0,0 +1,46 @@
1
+ require 'spec_helper'
2
+
3
+ describe RailsTemplater::TemplateEngine do
4
+
5
+ context "Template Engine type has not been set" do
6
+ its(:type) { should == :haml }
7
+ end
8
+
9
+ context "Template Engine type has been set to Haml" do
10
+
11
+ before(:each) do
12
+ subject.type = :haml
13
+ end
14
+
15
+ it { should be_haml }
16
+
17
+ end
18
+
19
+ context "Template Engine type has been set to Slim" do
20
+
21
+ before(:each) do
22
+ subject.type = :slim
23
+ end
24
+
25
+ it { should be_slim }
26
+
27
+ end
28
+
29
+ context "Template Engine type has been set to ERb" do
30
+
31
+ before(:each) do
32
+ subject.type = :erb
33
+ end
34
+
35
+ it { should be_erb }
36
+
37
+ end
38
+
39
+ it "only sets type to supported Template Engines" do
40
+ expect{
41
+ subject.type = :random
42
+ }.to raise_error(RailsTemplater::NotSupportedError)
43
+ end
44
+
45
+
46
+ end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 1
9
- version: 0.1.1
8
+ - 2
9
+ version: 0.1.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Kevin Faustino
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-01-30 00:00:00 -05:00
17
+ date: 2011-02-01 00:00:00 -05:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -100,6 +100,7 @@ files:
100
100
  - lib/rails_templater/fixture_replacement.rb
101
101
  - lib/rails_templater/javascript_framework.rb
102
102
  - lib/rails_templater/orm.rb
103
+ - lib/rails_templater/template_engine.rb
103
104
  - lib/rails_templater/templater.rb
104
105
  - lib/rails_templater/testing_framework.rb
105
106
  - lib/rails_templater/version.rb
@@ -120,6 +121,8 @@ files:
120
121
  - lib/template_framework/recipes/remarkable.rb
121
122
  - lib/template_framework/recipes/rspec.rb
122
123
  - lib/template_framework/recipes/sass.rb
124
+ - lib/template_framework/recipes/slim.rb
125
+ - lib/template_framework/recipes/template_engine.rb
123
126
  - lib/template_framework/recipes/test_unit.rb
124
127
  - lib/template_framework/recipes/testing_framework.rb
125
128
  - lib/template_framework/snippets/cucumber/factory_girl
@@ -131,12 +134,14 @@ files:
131
134
  - lib/template_framework/templates/haml/app/views/layouts/application.html.haml
132
135
  - lib/template_framework/templates/mongoid/features/step_definitions/mongoid_steps.rb
133
136
  - lib/template_framework/templates/mongoid/features/support/hooks.rb
137
+ - lib/template_framework/templates/slim/app/views/layouts/application.html.slim
134
138
  - rails_templater.gemspec
135
139
  - spec/fixtures/sample_snippet
136
140
  - spec/fixtures/sample_template.rb
137
141
  - spec/rails_templater/fixture_replacement_spec.rb
138
142
  - spec/rails_templater/javascript_framework_spec.rb
139
143
  - spec/rails_templater/orm_spec.rb
144
+ - spec/rails_templater/template_engine_spec.rb
140
145
  - spec/rails_templater/templater_spec.rb
141
146
  - spec/rails_templater/testing_framework_spec.rb
142
147
  - spec/rails_templater_spec.rb