cuhaml-contrib 0.0.1

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e39d8b4bbb6c5d92bc73daed7b18a6e2a2fbe25d
4
+ data.tar.gz: 84ab878c57c501f804e263ddc33e6181f68906b1
5
+ SHA512:
6
+ metadata.gz: a3b5d2c54c63092febe83bab9e2eacbec78ed8424ac8ab29e8253292d0cbd4f0c520dbaec304a7a3ec50760fff35a6ecedcf25e5aab6417701c3b182c17417fd
7
+ data.tar.gz: 0a6681782f142c3f8ed836c4d310c36626487b45d9f42967dfae57e519a14219997959b30397145bd34c876ed157d736254f28d8b9e21b0f7f2c02196f094cdb
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ .rbenv-gemsets
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in cuhaml-contrib.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Cristian Rasch
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,46 @@
1
+ # Cuhaml::Contrib
2
+
3
+ Contributed helpers to spice up your cuba+haml apps
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'cuhaml-contrib'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install cuhaml-contrib
18
+
19
+ ## Usage
20
+
21
+ 1. Require it:
22
+
23
+ `require "cuhaml-contrib"`
24
+
25
+ 2. Enable the plugin:
26
+
27
+ `Cuba.plugin Cuhaml::Contrib::ContentFor`
28
+
29
+ 3. In your layout files:
30
+
31
+ `- yield_for :js`
32
+
33
+ 4. In your views:
34
+
35
+ `- content_for :js do`
36
+
37
+ :javascript
38
+ console.log('hello world!');
39
+
40
+ ## Contributing
41
+
42
+ 1. Fork it
43
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
44
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
45
+ 4. Push to the branch (`git push origin my-new-feature`)
46
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,9 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new do |t|
5
+ t.pattern = "spec/**/*_spec.rb"
6
+ t.verbose = true
7
+ end
8
+
9
+ task :default => :test
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'cuhaml/contrib/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "cuhaml-contrib"
8
+ spec.version = Cuhaml::Contrib::VERSION
9
+ spec.authors = ["Cristian Rasch"]
10
+ spec.email = ["cristianrasch@gmail.com"]
11
+ spec.description = %q{Contributed helpers to spice up your cuba+haml apps}
12
+ spec.summary = spec.description
13
+ spec.homepage = "https://github.com/cristianrasch/cuhaml-contrib"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_runtime_dependency "haml", "~> 4.0.0"
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.3"
24
+ spec.add_development_dependency "rake"
25
+ spec.add_development_dependency "cuba", "~> 3.0"
26
+ end
@@ -0,0 +1,43 @@
1
+ require "haml/helpers"
2
+
3
+ module Cuhaml
4
+ module Contrib
5
+ module ContentFor
6
+ def self.setup(app)
7
+ app.settings[:render][:template_engine] = "haml"
8
+ end
9
+
10
+ # Public: yields a content in a view
11
+ #
12
+ # symbol - The symbol to be searched
13
+ #
14
+ # Examples:
15
+ #
16
+ # <% yield_for :menu %>
17
+ def yield_for(symbol)
18
+ haml_concat(content_blocks[symbol].join)
19
+ end
20
+
21
+ # Public: Sets a content for a given symbol
22
+ #
23
+ # symbol - The symbol key
24
+ # &block - Block to be called
25
+ #
26
+ # Examples:
27
+ #
28
+ # <% content_for :menu do %>
29
+ # Home | Admin
30
+ # <% end %>
31
+ def content_for(symbol, &block)
32
+ content_blocks[symbol] << capture_haml(&block)
33
+ end
34
+
35
+ private
36
+
37
+ # Private: Hash of arrays to store content blocks
38
+ def content_blocks
39
+ @content_blocks ||= Hash.new { |h, k| h[k] = [] }
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,5 @@
1
+ module Cuhaml
2
+ module Contrib
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,7 @@
1
+ require "cuhaml/contrib/version"
2
+
3
+ module Cuhaml
4
+ module Contrib
5
+ require "cuhaml/contrib/content_for"
6
+ end
7
+ end
@@ -0,0 +1,32 @@
1
+ require File.expand_path("spec_helper", File.dirname(__FILE__))
2
+ require "cuba"
3
+ require "cuba/render"
4
+ require "cuhaml/contrib/content_for"
5
+ require "haml"
6
+
7
+ module Cuhaml::Contrib
8
+ describe ContentFor do
9
+ before do
10
+ Cuba.plugin Cuba::Render
11
+ Cuba.plugin Cuhaml::Contrib::ContentFor
12
+
13
+ Cuba.settings[:render][:views] = "./spec/views"
14
+ Cuba.settings[:render][:template_engine] = "haml"
15
+
16
+ Cuba.define do
17
+ on root do
18
+ res.write view("index")
19
+ end
20
+ end
21
+ end
22
+
23
+ it "yields the given block" do
24
+ _, _, body = Cuba.call({ "PATH_INFO" => "/", "SCRIPT_NAME" => "/" })
25
+ body.first.must_match /alpha\s+beta\s+gamma\s+/
26
+ end
27
+
28
+ it "sets the default template engine" do
29
+ Cuba.settings[:render][:template_engine].must_equal "haml"
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,4 @@
1
+ require "minitest/autorun"
2
+ require "minitest/pride"
3
+
4
+ $:.unshift(File.expand_path("../lib", File.dirname(__FILE__)))
@@ -0,0 +1,3 @@
1
+ gamma
2
+ - content_for :menu do
3
+ alpha
@@ -0,0 +1,4 @@
1
+ - yield_for :menu
2
+ - yield_for :not
3
+ beta
4
+ = content
metadata ADDED
@@ -0,0 +1,117 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cuhaml-contrib
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Cristian Rasch
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-08-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: haml
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: 4.0.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 4.0.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: cuba
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ description: Contributed helpers to spice up your cuba+haml apps
70
+ email:
71
+ - cristianrasch@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - .gitignore
77
+ - Gemfile
78
+ - LICENSE.txt
79
+ - README.md
80
+ - Rakefile
81
+ - cuhaml-contrib.gemspec
82
+ - lib/cuhaml/contrib.rb
83
+ - lib/cuhaml/contrib/content_for.rb
84
+ - lib/cuhaml/contrib/version.rb
85
+ - spec/content_for_spec.rb
86
+ - spec/spec_helper.rb
87
+ - spec/views/index.haml
88
+ - spec/views/layout.haml
89
+ homepage: https://github.com/cristianrasch/cuhaml-contrib
90
+ licenses:
91
+ - MIT
92
+ metadata: {}
93
+ post_install_message:
94
+ rdoc_options: []
95
+ require_paths:
96
+ - lib
97
+ required_ruby_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ required_rubygems_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - '>='
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ requirements: []
108
+ rubyforge_project:
109
+ rubygems_version: 2.0.3
110
+ signing_key:
111
+ specification_version: 4
112
+ summary: Contributed helpers to spice up your cuba+haml apps
113
+ test_files:
114
+ - spec/content_for_spec.rb
115
+ - spec/spec_helper.rb
116
+ - spec/views/index.haml
117
+ - spec/views/layout.haml