merb-haml 1.0.15 → 1.1.0.pre

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -1,74 +1,65 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), "..", "rake_helpers"))
2
-
3
- ##############################################################################
4
- # Package && release
5
- ##############################################################################
6
- RUBY_FORGE_PROJECT = "merb"
7
- PROJECT_URL = "http://merbivore.com"
8
- PROJECT_SUMMARY = "Merb plugin that provides HAML support"
9
- PROJECT_DESCRIPTION = PROJECT_SUMMARY
10
-
11
- GEM_AUTHOR = "Yehuda Katz"
12
- GEM_EMAIL = "ykatz@engineyard.com"
13
-
14
- GEM_NAME = "merb-haml"
15
- PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
16
- GEM_VERSION = Merb::VERSION + PKG_BUILD
17
-
18
- RELEASE_NAME = "REL #{GEM_VERSION}"
19
-
20
- require "extlib/tasks/release"
21
-
22
- spec = Gem::Specification.new do |s|
23
- s.rubyforge_project = RUBY_FORGE_PROJECT
24
- s.name = GEM_NAME
25
- s.version = GEM_VERSION
26
- s.platform = Gem::Platform::RUBY
27
- s.has_rdoc = true
28
- s.extra_rdoc_files = ["README", "LICENSE", 'TODO']
29
- s.summary = PROJECT_SUMMARY
30
- s.description = PROJECT_DESCRIPTION
31
- s.author = GEM_AUTHOR
32
- s.email = GEM_EMAIL
33
- s.homepage = PROJECT_URL
34
- s.add_dependency('merb-core', "~> #{Merb::VERSION}")
35
- s.add_dependency('haml', '>= 2.0.3')
36
- s.require_path = 'lib'
37
- s.files = %w(LICENSE README Rakefile TODO Generators) + Dir.glob("{lib}/**/*")
38
- end
1
+ require 'rubygems'
2
+ require 'rake'
39
3
 
40
- Rake::GemPackageTask.new(spec) do |pkg|
41
- pkg.gem_spec = spec
42
- end
4
+ # Assume a typical dev checkout to fetch the current merb-core version
5
+ require File.expand_path('../../merb-core/lib/merb-core/version', __FILE__)
43
6
 
44
- desc "Install the gem"
45
- task :install do
46
- Merb::RakeHelper.install(GEM_NAME, :version => GEM_VERSION)
47
- end
7
+ # Load this library's version information
8
+ require File.expand_path('../lib/merb-haml/version', __FILE__)
48
9
 
49
- desc "Uninstall the gem"
50
- task :uninstall do
51
- Merb::RakeHelper.uninstall(GEM_NAME, :version => GEM_VERSION)
52
- end
10
+ begin
11
+
12
+ gem 'jeweler', '~> 1.4'
13
+ require 'jeweler'
14
+
15
+ Jeweler::Tasks.new do |gemspec|
16
+
17
+ gemspec.version = Merb::Haml::VERSION
18
+
19
+ gemspec.name = "merb-haml"
20
+ gemspec.description = "Merb plugin for HAML support"
21
+ gemspec.summary = "Merb plugin that provides support for writing view template with HAML"
22
+
23
+ gemspec.authors = [ "Yehuda Katz" ]
24
+ gemspec.email = "ykatz@engineyard.com"
25
+ gemspec.homepage = "http://merbivore.com/"
26
+
27
+ gemspec.files = %w(Generators LICENSE Rakefile README TODO) + Dir['{lib,spec}/**/*']
28
+
29
+ # Runtime dependencies
30
+ gemspec.add_dependency 'merb-core', "~> #{Merb::VERSION}"
31
+ gemspec.add_dependency 'haml', '>= 2.0.3'
32
+
33
+ # Development dependencies
34
+ gemspec.add_development_dependency 'rspec', '>= 1.2.9'
53
35
 
54
- desc "Create a gemspec file"
55
- task :gemspec do
56
- File.open("#{GEM_NAME}.gemspec", "w") do |file|
57
- file.puts spec.to_ruby
58
36
  end
37
+
38
+ Jeweler::GemcutterTasks.new
39
+
40
+ rescue LoadError
41
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
59
42
  end
60
43
 
61
- desc "Run all examples (or a specific spec with TASK=xxxx)"
62
- Spec::Rake::SpecTask.new('spec') do |t|
63
- t.spec_opts = ["-cfs"]
64
- t.spec_files = begin
65
- if ENV["TASK"]
66
- ENV["TASK"].split(',').map { |task| "spec/**/#{task}_spec.rb" }
67
- else
68
- FileList['spec/**/*_spec.rb']
69
- end
70
- end
44
+ require 'spec/rake/spectask'
45
+ Spec::Rake::SpecTask.new(:spec) do |spec|
46
+ spec.spec_opts << '--options' << 'spec/spec.opts' if File.exists?('spec/spec.opts')
47
+ spec.libs << 'lib' << 'spec'
48
+ spec.spec_files = FileList['spec/**/*_spec.rb']
71
49
  end
72
50
 
73
- desc 'Default: run spec examples'
74
- task :default => 'spec'
51
+ Spec::Rake::SpecTask.new(:rcov) do |spec|
52
+ spec.libs << 'lib' << 'spec'
53
+ spec.pattern = 'spec/**/*_spec.rb'
54
+ spec.rcov = true
55
+ end
56
+
57
+ task :default => :spec
58
+
59
+ require 'rake/rdoctask'
60
+ Rake::RDocTask.new do |rdoc|
61
+ rdoc.rdoc_dir = 'rdoc'
62
+ rdoc.title = "test_gem #{Merb::Haml::VERSION}"
63
+ rdoc.rdoc_files.include('README*')
64
+ rdoc.rdoc_files.include('lib/**/*.rb')
65
+ end
@@ -3,7 +3,7 @@
3
3
  %p
4
4
  Edit this file in
5
5
  %tt
6
- app/views/<%= file_name %>/edit.html.erb
6
+ app/views/<%= file_name %>/edit.html.haml
7
7
  = error_messages_for @<%= singular_model %>
8
8
 
9
9
  = form_for(@<%= singular_model %>, :action => url(:<%= singular_model %>, @<%= singular_model %>)) do
@@ -3,7 +3,7 @@
3
3
  %p
4
4
  Edit this file in
5
5
  %tt
6
- app/views/<%= file_name %>/index.html.erb
6
+ app/views/<%= file_name %>/index.html.haml
7
7
  %table
8
8
  %tr
9
9
  <% for property in properties.reject{|p| p.lazy?} -%>
@@ -2,7 +2,7 @@
2
2
 
3
3
  %p
4
4
  Edit this file in
5
- %tt app/views/<%= file_name %>/new.html.erb
5
+ %tt app/views/<%= file_name %>/new.html.haml
6
6
 
7
7
  = error_messages_for @<%= singular_model %>
8
8
 
@@ -3,7 +3,7 @@
3
3
  %p
4
4
  Edit this file in
5
5
  %tt
6
- app/views/<%= file_name %>/show.html.erb
6
+ app/views/<%= file_name %>/show.html.haml
7
7
  <% for property in properties -%>
8
8
  %p
9
9
  %b
data/lib/merb-haml.rb CHANGED
@@ -8,7 +8,19 @@ if defined?(Merb)
8
8
 
9
9
  Merb::BootLoader.after_app_loads do
10
10
 
11
- if File.directory?(Merb::Plugins.config[:sass][:template_location] || Merb.dir_for(:stylesheet) / "sass")
11
+ template_locations = []
12
+ template_locations << Merb.dir_for(:stylesheet) / "sass"
13
+
14
+ # extract template locations list from sass config
15
+ config_location = Merb::Plugins.config[:sass][:template_location]
16
+ if config_location.is_a? Hash
17
+ template_locations += config_location.keys
18
+ elsif config_location
19
+ template_locations << config_location.to_s
20
+ end
21
+
22
+ # setup sass if any template paths match
23
+ if template_locations.any?{|location| File.directory?(location) }
12
24
  require "sass"
13
25
  if Merb::Config[:sass]
14
26
  Merb.logger.info("Please define your sass settings in Merb::Plugins.config[:sass] not Merb::Config")
@@ -20,13 +32,6 @@ if defined?(Merb)
20
32
 
21
33
  end
22
34
 
23
- # Hack because Haml uses symbolize_keys
24
- class Hash
25
- def symbolize_keys!
26
- self
27
- end
28
- end
29
-
30
35
  generators = File.join(File.dirname(__FILE__), 'generators')
31
36
  Merb.add_generators generators / "resource_controller"
32
37
  Merb.add_generators generators / "controller"
@@ -1,7 +1,6 @@
1
1
  namespace :haml do
2
2
  desc "Compiles all sass files into CSS"
3
3
  task :compile_sass do
4
- gem 'haml'
5
4
  require 'sass'
6
5
  puts "*** Updating stylesheets"
7
6
  Sass::Plugin.options = Merb::Config[:sass] if Merb::Config[:sass]
@@ -0,0 +1,5 @@
1
+ module Merb
2
+ module Haml
3
+ VERSION = '1.1.0.pre'.freeze
4
+ end
5
+ end
@@ -0,0 +1,31 @@
1
+ class HamlController < Merb::Controller
2
+ self._template_root = File.dirname(__FILE__) / "views"
3
+ def index
4
+ render
5
+ end
6
+ end
7
+
8
+ class PartialHaml < HamlController
9
+ end
10
+
11
+ class HamlConfig < HamlController
12
+ end
13
+
14
+ class PartialIvars < HamlController
15
+ def index
16
+ @var1 = "Partial"
17
+ render
18
+ end
19
+ end
20
+
21
+ class CaptureHaml < HamlController
22
+ end
23
+
24
+ module Merb::ConcatHamlHelper
25
+ def concatter(&blk)
26
+ concat("<p>Concat</p>", blk.binding)
27
+ end
28
+ end
29
+
30
+ class ConcatHaml < HamlController
31
+ end
@@ -0,0 +1,3 @@
1
+ - x = capture do
2
+ %p Hello
3
+ = x
@@ -0,0 +1,2 @@
1
+ - concatter do
2
+ Hello
@@ -0,0 +1,2 @@
1
+ #foo
2
+ %foo
@@ -0,0 +1,2 @@
1
+ #foo
2
+ %p Hello
@@ -0,0 +1,2 @@
1
+ #foo
2
+ = partial :partial_haml, :text => "Partial"
@@ -0,0 +1 @@
1
+ %p== #{@var1} #{@var2}
@@ -0,0 +1,3 @@
1
+ #foo
2
+ - @var2 = "HAML"
3
+ = partial :partial_haml
data/spec/haml_spec.rb ADDED
@@ -0,0 +1,33 @@
1
+ require 'spec_helper'
2
+
3
+ describe "HAML" do
4
+ it "should be able to render HAML templates" do
5
+ c = dispatch_to(HamlController, :index)
6
+ c.body.should == ::Haml::Engine.new("#foo\n %p Hello").render
7
+ end
8
+
9
+ it "should be able to render HAML templates with locals" do
10
+ c = dispatch_to(PartialHaml, :index)
11
+ c.body.should == ::Haml::Engine.new("#foo\n %p Partial").render
12
+ end
13
+
14
+ it "should use the haml configuration in Merb::Plugins.config" do
15
+ c = dispatch_to(HamlConfig, :index)
16
+ c.body.should == ::Haml::Engine.new("#foo\n %foo", :autoclose => ["foo"]).render
17
+ end
18
+
19
+ it "should be able to have ivars defined in both the controller and the parent template" do
20
+ c = dispatch_to(PartialIvars, :index)
21
+ c.body.should == ::Haml::Engine.new("#foo\n %p Partial HAML").render
22
+ end
23
+
24
+ it "should support capture" do
25
+ c = dispatch_to(CaptureHaml, :index)
26
+ c.body.should == "<p>Hello</p>\n"
27
+ end
28
+
29
+ it "should support concat" do
30
+ c = dispatch_to(ConcatHaml, :index)
31
+ c.body.should == "<p>Concat</p>"
32
+ end
33
+ end
data/spec/spec.opts ADDED
@@ -0,0 +1,2 @@
1
+ --format specdoc
2
+ --colour
@@ -0,0 +1,23 @@
1
+ require "rubygems"
2
+
3
+ # Use current merb-core sources if running from a typical dev checkout.
4
+ lib = File.expand_path('../../../merb-core/lib', __FILE__)
5
+ $LOAD_PATH.unshift(lib) if File.directory?(lib)
6
+ require 'merb-core'
7
+
8
+ # The lib under test
9
+ require "merb-haml"
10
+
11
+ # Satisfies Autotest and anyone else not using the Rake tasks
12
+ require 'spec'
13
+
14
+ # Shared spec files
15
+ require "controllers/haml"
16
+
17
+ Merb::Plugins.config[:haml] = { "autoclose" => ["foo"] }
18
+
19
+ Merb.start :environment => 'test'
20
+
21
+ Spec::Runner.configure do |config|
22
+ config.include Merb::Test::RequestHelper
23
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: merb-haml
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.15
4
+ version: 1.1.0.pre
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yehuda Katz
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-11-04 00:00:00 +00:00
12
+ date: 2010-02-20 00:00:00 +00:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -20,7 +20,7 @@ dependencies:
20
20
  requirements:
21
21
  - - ~>
22
22
  - !ruby/object:Gem::Version
23
- version: 1.0.15
23
+ version: 1.1.0.pre
24
24
  version:
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: haml
@@ -32,22 +32,32 @@ dependencies:
32
32
  - !ruby/object:Gem::Version
33
33
  version: 2.0.3
34
34
  version:
35
- description: Merb plugin that provides HAML support
35
+ - !ruby/object:Gem::Dependency
36
+ name: rspec
37
+ type: :development
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: 1.2.9
44
+ version:
45
+ description: Merb plugin for HAML support
36
46
  email: ykatz@engineyard.com
37
47
  executables: []
38
48
 
39
49
  extensions: []
40
50
 
41
51
  extra_rdoc_files:
42
- - README
43
52
  - LICENSE
53
+ - README
44
54
  - TODO
45
55
  files:
56
+ - Generators
46
57
  - LICENSE
47
58
  - README
48
59
  - Rakefile
49
60
  - TODO
50
- - Generators
51
61
  - lib/generators/controller.rb
52
62
  - lib/generators/layout.rb
53
63
  - lib/generators/resource_controller.rb
@@ -69,16 +79,29 @@ files:
69
79
  - lib/generators/templates/resource_controller/sequel/app/views/%file_name%/index.html.haml
70
80
  - lib/generators/templates/resource_controller/sequel/app/views/%file_name%/new.html.haml
71
81
  - lib/generators/templates/resource_controller/sequel/app/views/%file_name%/show.html.haml
82
+ - lib/merb-haml.rb
72
83
  - lib/merb-haml/merbtasks.rb
73
84
  - lib/merb-haml/template.rb
74
- - lib/merb-haml.rb
85
+ - lib/merb-haml/version.rb
86
+ - spec/controllers/haml.rb
87
+ - spec/controllers/views/capture_haml/index.html.haml
88
+ - spec/controllers/views/concat_haml/index.html.haml
89
+ - spec/controllers/views/haml_config/index.html.haml
90
+ - spec/controllers/views/haml_controller/index.html.haml
91
+ - spec/controllers/views/partial_haml/_partial_haml.html.haml
92
+ - spec/controllers/views/partial_haml/index.html.haml
93
+ - spec/controllers/views/partial_ivars/_partial_haml.html.haml
94
+ - spec/controllers/views/partial_ivars/index.html.haml
95
+ - spec/haml_spec.rb
96
+ - spec/spec.opts
97
+ - spec/spec_helper.rb
75
98
  has_rdoc: true
76
- homepage: http://merbivore.com
99
+ homepage: http://merbivore.com/
77
100
  licenses: []
78
101
 
79
102
  post_install_message:
80
- rdoc_options: []
81
-
103
+ rdoc_options:
104
+ - --charset=UTF-8
82
105
  require_paths:
83
106
  - lib
84
107
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -89,16 +112,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
89
112
  version:
90
113
  required_rubygems_version: !ruby/object:Gem::Requirement
91
114
  requirements:
92
- - - ">="
115
+ - - ">"
93
116
  - !ruby/object:Gem::Version
94
- version: "0"
117
+ version: 1.3.1
95
118
  version:
96
119
  requirements: []
97
120
 
98
- rubyforge_project: merb
121
+ rubyforge_project:
99
122
  rubygems_version: 1.3.5
100
123
  signing_key:
101
124
  specification_version: 3
102
- summary: Merb plugin that provides HAML support
125
+ summary: Merb plugin that provides support for writing view template with HAML
103
126
  test_files: []
104
127