flype-merb_markaby 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2008 Eric Watson
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.
data/README ADDED
@@ -0,0 +1,4 @@
1
+ merb_markaby
2
+ ============
3
+
4
+ A plugin for the Merb framework that allows the use of Markaby view templates.
data/Rakefile ADDED
@@ -0,0 +1,44 @@
1
+ require 'rubygems'
2
+ require 'rake/gempackagetask'
3
+
4
+ PLUGIN = "merb_markaby"
5
+ NAME = "merb_markaby"
6
+ VERSION = "0.0.1"
7
+ AUTHOR = "Eric Watson"
8
+ EMAIL = "wasnotrice@gmail.com"
9
+ HOMEPAGE = "http://merb-plugins.rubyforge.org/merb_markaby/"
10
+ SUMMARY = "Merb plugin that allows the use of Markaby view templates"
11
+
12
+ spec = Gem::Specification.new do |s|
13
+ s.name = NAME
14
+ s.version = VERSION
15
+ s.platform = Gem::Platform::RUBY
16
+ s.has_rdoc = true
17
+ s.extra_rdoc_files = ["README", "LICENSE", 'TODO']
18
+ s.summary = SUMMARY
19
+ s.description = s.summary
20
+ s.author = AUTHOR
21
+ s.email = EMAIL
22
+ s.homepage = HOMEPAGE
23
+ # s.add_dependency('merb', '>= 0.4.0')
24
+ s.require_path = 'lib'
25
+ s.autorequire = PLUGIN
26
+ s.files = %w(LICENSE README Rakefile TODO) + Dir.glob("{lib,specs}/**/*")
27
+ end
28
+
29
+ Rake::GemPackageTask.new(spec) do |pkg|
30
+ pkg.gem_spec = spec
31
+ end
32
+
33
+ task :install => [:package] do
34
+ sh %{sudo gem install pkg/#{NAME}-#{VERSION}}
35
+ end
36
+
37
+ namespace :jruby do
38
+
39
+ desc "Run :package and install the resulting .gem with jruby"
40
+ task :install => :package do
41
+ sh %{#{SUDO} jruby -S gem install pkg/#{NAME}-#{Merb::VERSION}.gem --no-rdoc --no-ri}
42
+ end
43
+
44
+ end
@@ -0,0 +1,6 @@
1
+ namespace :merb_markaby do
2
+ desc "Do something for merb_markaby"
3
+ task :default do
4
+ puts "merb_markaby doesn't do anything"
5
+ end
6
+ end
@@ -0,0 +1,75 @@
1
+ module Merb::Template
2
+
3
+ class Markaby
4
+ # ==== Parameters
5
+ # path<String>:: A full path to the template
6
+ # name<String>:: The name of the method that will be created
7
+ # mod<Module>:: The module that the compiled method will be placed into
8
+ def self.compile_template(path, name, mod)
9
+ path = File.expand_path(path)
10
+ template = ::Markaby::Template.new(File.read(path))
11
+ template.def_method(mod, name)
12
+ name
13
+ end
14
+
15
+ module Mixin
16
+ # Provides direct acccess to the buffer for this view context
17
+ def _mab_buffer( binding )
18
+ @_buffer = eval( "to_s", binding )
19
+ end
20
+
21
+ # Allows throw_content and catch_content in .mab views. Same as
22
+ # Merb::Template::Erubis::Mixin#capture_erb
23
+ def capture_mab(*args, &block)
24
+ # get the buffer from the block's binding
25
+ buffer = _erb_buffer( block.binding ) rescue nil
26
+
27
+ # If there is no buffer, just call the block and get the contents
28
+ if buffer.nil?
29
+ block.call(*args)
30
+ # If there is a buffer, execute the block, then extract its contents
31
+ else
32
+ pos = buffer.length
33
+ block.call(*args)
34
+
35
+ # extract the block
36
+ data = buffer[pos..-1]
37
+
38
+ # replace it in the original with empty string
39
+ buffer[pos..-1] = ''
40
+
41
+ data
42
+ end
43
+ end
44
+
45
+ def _concat_mab(string, binding)
46
+ _mab_buffer(binding) << string
47
+ end
48
+
49
+ end
50
+ Merb::Template.register_extensions(self, %w[mab])
51
+ end
52
+ end
53
+
54
+ module Markaby
55
+ class Template
56
+
57
+ def def_method(object, name, filename=nil)
58
+ m = object.is_a?(Module) ? :module_eval : :instance_eval
59
+ setup = "@_engine = 'mab'"
60
+ method_body = <<-END_OF_METHOD
61
+ def #{name}(assigns={})
62
+ #{setup}
63
+ if $DEBUG
64
+ require 'ruby-debug'
65
+ debugger
66
+ end
67
+ assigns.merge!(@_merb_partial_locals) if @_merb_partial_locals
68
+ mab = Markaby::Builder.new(assigns, self) {#{@template}}.to_s
69
+ end
70
+ END_OF_METHOD
71
+ object.__send__(m, method_body, filename || @filename || 'merb_markaby/lib/merb_markaby/template.rb')
72
+ end
73
+
74
+ end
75
+ end
@@ -0,0 +1,11 @@
1
+ require 'markaby'
2
+ require 'lib/merb_markaby/template'
3
+
4
+ # make sure we're running inside Merb
5
+ if defined?(Merb::Plugins)
6
+
7
+ # Merb gives you a Merb::Plugins.config hash...feel free to put your stuff in your piece of it
8
+ Merb::Plugins.config[:merb_markaby] = { }
9
+
10
+ Merb::Plugins.add_rakefiles "merb_markaby/merbtasks"
11
+ end
metadata ADDED
@@ -0,0 +1,85 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: flype-merb_markaby
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Felipe Talavera
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-12-13 00:00:00 -08:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: diff-lcs
17
+ version_requirement:
18
+ version_requirements: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - ">"
21
+ - !ruby/object:Gem::Version
22
+ version: 0.0.0
23
+ version:
24
+ - !ruby/object:Gem::Dependency
25
+ name: mime-types
26
+ version_requirement:
27
+ version_requirements: !ruby/object:Gem::Requirement
28
+ requirements:
29
+ - - ">"
30
+ - !ruby/object:Gem::Version
31
+ version: 0.0.0
32
+ version:
33
+ - !ruby/object:Gem::Dependency
34
+ name: open4
35
+ version_requirement:
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.0.0
41
+ version:
42
+ description: it repository in and object oriented manner.
43
+ email: felipe.talavera@gmail.com
44
+ executables: []
45
+
46
+ extensions: []
47
+
48
+ extra_rdoc_files: []
49
+
50
+ files:
51
+ - LICENSE
52
+ - Rakefile
53
+ - README
54
+ - lib/merb_markaby.rb
55
+ - lib/merb_markaby/merbtasks.rb
56
+ - lib/merb_markaby/template.rb
57
+ has_rdoc: true
58
+ homepage: http://github.com/flype/merb_markaby.git
59
+ post_install_message:
60
+ rdoc_options:
61
+ - --main
62
+ - README.txt
63
+ require_paths:
64
+ - lib
65
+ required_ruby_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: "0"
70
+ version:
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: "0"
76
+ version:
77
+ requirements: []
78
+
79
+ rubyforge_project:
80
+ rubygems_version: 1.2.0
81
+ signing_key:
82
+ specification_version: 2
83
+ summary: merb_markaby
84
+ test_files: []
85
+