smartgen_erb 0.1.0

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.
@@ -0,0 +1,5 @@
1
+ pkg/*
2
+ .rvmrc
3
+ *.gem
4
+ .bundle
5
+ .project
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --format documentation
3
+ --debug
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ platforms :mri_18 do
6
+ gem "ruby-debug"
7
+ end
8
+
9
+ platforms :mri_19 do
10
+ gem "ruby-debug19" if RUBY_VERSION < "1.9.3"
11
+ end
@@ -0,0 +1,63 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ smartgen_erb (0.1.0)
5
+ smartgen
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ RedCloth (4.2.3)
11
+ activesupport (3.0.4)
12
+ archive-tar-minitar (0.5.2)
13
+ bluecloth (2.0.10)
14
+ columnize (0.3.2)
15
+ diff-lcs (1.1.2)
16
+ directory_watcher (1.3.2)
17
+ i18n (0.5.0)
18
+ linecache (0.43)
19
+ linecache19 (0.5.11)
20
+ ruby_core_source (>= 0.1.4)
21
+ nokogiri (1.4.4)
22
+ rspec (2.5.0)
23
+ rspec-core (~> 2.5.0)
24
+ rspec-expectations (~> 2.5.0)
25
+ rspec-mocks (~> 2.5.0)
26
+ rspec-core (2.5.1)
27
+ rspec-expectations (2.5.0)
28
+ diff-lcs (~> 1.1.2)
29
+ rspec-mocks (2.5.0)
30
+ ruby-debug (0.10.4)
31
+ columnize (>= 0.1)
32
+ ruby-debug-base (~> 0.10.4.0)
33
+ ruby-debug-base (0.10.4)
34
+ linecache (>= 0.3)
35
+ ruby-debug-base19 (0.11.24)
36
+ columnize (>= 0.3.1)
37
+ linecache19 (>= 0.5.11)
38
+ ruby_core_source (>= 0.1.4)
39
+ ruby-debug19 (0.11.6)
40
+ columnize (>= 0.3.1)
41
+ linecache19 (>= 0.5.11)
42
+ ruby-debug-base19 (>= 0.11.19)
43
+ ruby_core_source (0.1.4)
44
+ archive-tar-minitar (>= 0.5.2)
45
+ smartgen (0.4.0)
46
+ RedCloth (= 4.2.3)
47
+ activesupport (>= 2.3.5)
48
+ bluecloth (>= 2.0.9)
49
+ directory_watcher (>= 1.3.2)
50
+ i18n (>= 0.5.0)
51
+ nokogiri (>= 1.4.4)
52
+ thor (>= 0.14.6)
53
+ thor (0.14.6)
54
+
55
+ PLATFORMS
56
+ ruby
57
+
58
+ DEPENDENCIES
59
+ rspec (>= 2.3.0)
60
+ ruby-debug
61
+ ruby-debug19
62
+ smartgen
63
+ smartgen_erb!
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 Wandenberg Peixoto
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,19 @@
1
+ Smartgen erb
2
+ ==========================
3
+
4
+ Adds support to use ruby syntax with smartgen.
5
+
6
+ ## How it works?
7
+
8
+ Basically it creates a pre processor to process ruby code like in erb files:
9
+
10
+ ## Using
11
+
12
+ To use it, add gem to your gemspec:
13
+
14
+ gem 'smartgen_erb'
15
+
16
+ And then require all engines pre processors after smartgen:
17
+
18
+ require 'smartgen'
19
+ require 'smartgen_erb'
@@ -0,0 +1,7 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ require "rspec/core/rake_task"
5
+
6
+ desc "Run all examples"
7
+ RSpec::Core::RakeTask.new(:spec)
@@ -0,0 +1,5 @@
1
+ require 'smartgen'
2
+ require File.expand_path(File.join('smartgen_erb/pre_processor'), File.dirname(__FILE__))
3
+
4
+ Smartgen::Engine::Markdown.register(ErbPreProcessor.new)
5
+ Smartgen::Engine::Textile.register(ErbPreProcessor.new)
@@ -0,0 +1,12 @@
1
+ class ErbPreProcessor
2
+
3
+ def initialize(opts={})
4
+ end
5
+
6
+ def process(body, metadata={})
7
+ metadata = Smartgen::ObjectHash.new(metadata)
8
+
9
+ ERB.new(body).result(binding)
10
+ end
11
+
12
+ end
@@ -0,0 +1,5 @@
1
+ module Smartgen
2
+ module Erb
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "smartgen_erb/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "smartgen_erb"
7
+ s.version = Smartgen::Erb::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Wandenberg Peixoto"]
10
+ s.email = ["wandenberg@gmail.com"]
11
+ s.homepage = ""
12
+ s.summary = %q{Adds Erb support for smartgen}
13
+ s.description = %q{Use Erb plugin when generating files with smartgen}
14
+
15
+ s.rubyforge_project = "smartgen_erb"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.require_paths = ["lib"]
20
+
21
+ s.add_dependency "smartgen"
22
+
23
+ s.add_development_dependency "rspec", ">= 2.3.0"
24
+ end
@@ -0,0 +1,27 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
3
+ require 'rspec'
4
+ require 'smartgen'
5
+ require 'smartgen_erb/pre_processor'
6
+
7
+ describe ErbPreProcessor do
8
+
9
+ it "should render textile code generated by erb" do
10
+ body = """
11
+ <% 1.upto(6) do |i|
12
+ if (i % 2) == 1
13
+ %>
14
+ * <%= i %>
15
+ <% end
16
+ end
17
+ %>
18
+ """
19
+ subject.process(body).should == "\n \n * 1\n \n * 3\n \n * 5\n \n "
20
+ end
21
+
22
+ it "should render textile code generated by erb accessing metadata" do
23
+ body = "*<%= metadata.user.name %>* <%= metadata.user.surname %>"
24
+ subject.process(body, {:user => {:name => 'John', :surname => 'Nesh'} }).should == "*John* Nesh"
25
+ end
26
+
27
+ end
metadata ADDED
@@ -0,0 +1,103 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: smartgen_erb
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ - 0
9
+ version: 0.1.0
10
+ platform: ruby
11
+ authors:
12
+ - Wandenberg Peixoto
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2011-02-10 00:00:00 -02:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: smartgen
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 0
30
+ version: "0"
31
+ type: :runtime
32
+ version_requirements: *id001
33
+ - !ruby/object:Gem::Dependency
34
+ name: rspec
35
+ prerelease: false
36
+ requirement: &id002 !ruby/object:Gem::Requirement
37
+ none: false
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ segments:
42
+ - 2
43
+ - 3
44
+ - 0
45
+ version: 2.3.0
46
+ type: :development
47
+ version_requirements: *id002
48
+ description: Use Erb plugin when generating files with smartgen
49
+ email:
50
+ - wandenberg@gmail.com
51
+ executables: []
52
+
53
+ extensions: []
54
+
55
+ extra_rdoc_files: []
56
+
57
+ files:
58
+ - .gitignore
59
+ - .rspec
60
+ - Gemfile
61
+ - Gemfile.lock
62
+ - LICENSE
63
+ - README.md
64
+ - Rakefile
65
+ - lib/smartgen_erb.rb
66
+ - lib/smartgen_erb/pre_processor.rb
67
+ - lib/smartgen_erb/version.rb
68
+ - smartgen_erb.gemspec
69
+ - spec/lib/pre_processor_spec.rb
70
+ has_rdoc: true
71
+ homepage: ""
72
+ licenses: []
73
+
74
+ post_install_message:
75
+ rdoc_options: []
76
+
77
+ require_paths:
78
+ - lib
79
+ required_ruby_version: !ruby/object:Gem::Requirement
80
+ none: false
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ segments:
85
+ - 0
86
+ version: "0"
87
+ required_rubygems_version: !ruby/object:Gem::Requirement
88
+ none: false
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ segments:
93
+ - 0
94
+ version: "0"
95
+ requirements: []
96
+
97
+ rubyforge_project: smartgen_erb
98
+ rubygems_version: 1.3.7
99
+ signing_key:
100
+ specification_version: 3
101
+ summary: Adds Erb support for smartgen
102
+ test_files: []
103
+