From 4a372636d055033f82b676c457426a532cd8a4ca Mon Sep 17 00:00:00 2001 From: Justin French Date: Tue, 26 Apr 2011 21:09:31 +1000 Subject: [PATCH] initial commit, just enought to do some damage --- MIT-LICENSE | 20 ++++++++++++ README | 13 ++++++++ Rakefile | 23 +++++++++++++ app/helpers/nestive_layout_helper.rb | 48 ++++++++++++++++++++++++++++ init.rb | 1 + install.rb | 1 + lib/nestive.rb | 4 +++ lib/nestive/engine.rb | 6 ++++ nestive.gemspec | 23 +++++++++++++ test/nestive_test.rb | 8 +++++ test/test_helper.rb | 3 ++ uninstall.rb | 1 + 12 files changed, 151 insertions(+) create mode 100644 MIT-LICENSE create mode 100644 README create mode 100644 Rakefile create mode 100644 app/helpers/nestive_layout_helper.rb create mode 100644 init.rb create mode 100644 install.rb create mode 100644 lib/nestive.rb create mode 100644 lib/nestive/engine.rb create mode 100644 nestive.gemspec create mode 100644 test/nestive_test.rb create mode 100644 test/test_helper.rb create mode 100644 uninstall.rb diff --git a/MIT-LICENSE b/MIT-LICENSE new file mode 100644 index 0000000..bfe9381 --- /dev/null +++ b/MIT-LICENSE @@ -0,0 +1,20 @@ +Copyright (c) 2011 [name of plugin creator] + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README b/README new file mode 100644 index 0000000..03d285a --- /dev/null +++ b/README @@ -0,0 +1,13 @@ +Nestive +======= + +Introduction goes here. + + +Example +======= + +Example goes here. + + +Copyright (c) 2011 [name of plugin creator], released under the MIT license diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..0a033e7 --- /dev/null +++ b/Rakefile @@ -0,0 +1,23 @@ +#!/usr/bin/env rake +require 'rake/testtask' +require 'rake/rdoctask' + +desc 'Default: run unit tests.' +task :default => :test + +desc 'Test the nestive plugin.' +Rake::TestTask.new(:test) do |t| + t.libs << 'lib' + t.libs << 'test' + t.pattern = 'test/**/*_test.rb' + t.verbose = true +end + +desc 'Generate documentation for the nestive plugin.' +Rake::RDocTask.new(:rdoc) do |rdoc| + rdoc.rdoc_dir = 'rdoc' + rdoc.title = 'Nestive' + rdoc.options << '--line-numbers' << '--inline-source' + rdoc.rdoc_files.include('README') + rdoc.rdoc_files.include('lib/**/*.rb') +end \ No newline at end of file diff --git a/app/helpers/nestive_layout_helper.rb b/app/helpers/nestive_layout_helper.rb new file mode 100644 index 0000000..954ac2e --- /dev/null +++ b/app/helpers/nestive_layout_helper.rb @@ -0,0 +1,48 @@ +module NestiveLayoutHelper + + def extends(name, &block) + capture(&block) + render(:file => "layouts/#{name}") + end + + def block(name, &block) + append(name, &block) + render_block(name) + end + + def append(name, content=nil, &block) + content = capture(&block) if block_given? + instruct_block(name, :push, content) + end + + def prepend(name, content=nil, &block) + content = capture(&block) if block_given? + instruct_block(name, :unshift, content) + end + + def replace(name, content=nil, &block) + content = capture(&block) if block_given? + instruct_block(name, :replace, [content]) + end + + private + + def instruct_block(name, instruction, value) + @_block_for ||= {} + @_block_for[name] ||= [] + @_block_for[name] << [instruction, value] + end + + def render_block(name) + output = [] + instructions_for_block(name).each do |i| + output.send(i.first, i.last) + end + output.join.html_safe + end + + def instructions_for_block(name) + instructions = (@_block_for[name] || []).reverse + end + +end \ No newline at end of file diff --git a/init.rb b/init.rb new file mode 100644 index 0000000..3c19a74 --- /dev/null +++ b/init.rb @@ -0,0 +1 @@ +# Include hook code here diff --git a/install.rb b/install.rb new file mode 100644 index 0000000..f7732d3 --- /dev/null +++ b/install.rb @@ -0,0 +1 @@ +# Install hook code here diff --git a/lib/nestive.rb b/lib/nestive.rb new file mode 100644 index 0000000..e35ac5c --- /dev/null +++ b/lib/nestive.rb @@ -0,0 +1,4 @@ +require 'nestive/engine' + +module Nestive +end \ No newline at end of file diff --git a/lib/nestive/engine.rb b/lib/nestive/engine.rb new file mode 100644 index 0000000..069cba6 --- /dev/null +++ b/lib/nestive/engine.rb @@ -0,0 +1,6 @@ +if defined?(Rails) && Rails.version.to_i >= 3 + module Nestive + class Engine < Rails::Engine + end + end +end diff --git a/nestive.gemspec b/nestive.gemspec new file mode 100644 index 0000000..04d13ba --- /dev/null +++ b/nestive.gemspec @@ -0,0 +1,23 @@ +# encoding: utf-8 + +Gem::Specification.new do |s| + s.name = %q{nestive} + s.version = "0.0.1.pre" + s.date = %q{2011-04-26} + + s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= + s.authors = ["Justin French"] + s.description = %q{A Rails plugin/gem for awesome nested templates and layouts} + s.summary = %q{A Rails plugin/gem for awesome nested templates and layouts} + s.email = %q{justin@indent.com.au} + s.extra_rdoc_files = ["README"] + s.files = Dir.glob("{app,lib}/**/*") + s.homepage = %q{http://github.com/justinfrench/nestive} + s.post_install_message = %q{} + s.rdoc_options = ["--charset=UTF-8"] + s.require_paths = ["lib"] + s.rubygems_version = %q{1.3.6} + + s.add_dependency(%q, ["~> 3.1.0.pre"]) + +end diff --git a/test/nestive_test.rb b/test/nestive_test.rb new file mode 100644 index 0000000..a7a426e --- /dev/null +++ b/test/nestive_test.rb @@ -0,0 +1,8 @@ +require 'test_helper' + +class NestiveTest < ActiveSupport::TestCase + # Replace this with your real tests. + test "the truth" do + assert true + end +end diff --git a/test/test_helper.rb b/test/test_helper.rb new file mode 100644 index 0000000..2ca36a1 --- /dev/null +++ b/test/test_helper.rb @@ -0,0 +1,3 @@ +require 'rubygems' +require 'test/unit' +require 'active_support' diff --git a/uninstall.rb b/uninstall.rb new file mode 100644 index 0000000..9738333 --- /dev/null +++ b/uninstall.rb @@ -0,0 +1 @@ +# Uninstall hook code here