Skip to content

Commit

Permalink
initial plugin build with code grabbed from other projects
Browse files Browse the repository at this point in the history
  • Loading branch information
rughetto committed Jan 20, 2009
0 parents commit 1cc75df
Show file tree
Hide file tree
Showing 17 changed files with 176 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Generators
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
scope 'merb-gen' do
Merb.add_generators(File.join(File.dirname(__FILE__), 'lib', 'generators', 'rear_views_generator'))
end
20 changes: 20 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Copyright (c) 2009 YOUR NAME

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.
4 changes: 4 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
rear_views
==========

A plugin for the Merb framework that provides ...
51 changes: 51 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
require 'rubygems'
require 'rake/gempackagetask'

require 'merb-core'
require 'merb-core/tasks/merb'

GEM_NAME = "rear_views"
GEM_VERSION = "0.0.1"
AUTHOR = "Your Name"
EMAIL = "Your Email"
HOMEPAGE = "http://merbivore.com/"
SUMMARY = "Merb plugin that provides ..."

spec = Gem::Specification.new do |s|
s.rubyforge_project = 'merb'
s.name = GEM_NAME
s.version = GEM_VERSION
s.platform = Gem::Platform::RUBY
s.has_rdoc = true
s.extra_rdoc_files = ["README", "LICENSE", 'TODO']
s.summary = SUMMARY
s.description = s.summary
s.author = AUTHOR
s.email = EMAIL
s.homepage = HOMEPAGE
s.add_dependency('merb', '>= 1.0.8')
s.require_path = 'lib'
s.files = %w(LICENSE README Rakefile TODO) + Dir.glob("{lib,spec}/**/*")

end

Rake::GemPackageTask.new(spec) do |pkg|
pkg.gem_spec = spec
end

desc "install the plugin as a gem"
task :install do
Merb::RakeHelper.install(GEM_NAME, :version => GEM_VERSION)
end

desc "Uninstall the gem"
task :uninstall do
Merb::RakeHelper.uninstall(GEM_NAME, :version => GEM_VERSION)
end

desc "Create a gemspec file"
task :gemspec do
File.open("#{GEM_NAME}.gemspec", "w") do |file|
file.puts spec.to_ruby
end
end
5 changes: 5 additions & 0 deletions TODO
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
TODO:
Fix LICENSE with your name
Fix Rakefile with your name and contact info
Add your code to lib/rear_views.rb
Add your Merb rake tasks to lib/rear_views/merbtasks.rb
60 changes: 60 additions & 0 deletions lib/generators/rear_views_generator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
module Merb::Generators

class RearViewsGenerator < NamespacedGenerator

def self.source_root
File.dirname(__FILE__) / 'templates'
end

desc <<-DESC
Generators a REST views for a resource, so that complex views and forms can be easily built
DESC

first_argument :name, :required => true, :desc => "model name"
second_argument :attachments, :required => true, :as => :array, :default => [], :desc => "space separated list of fields"

[:index, :show, :edit, :new, :_form, :_list_view, :_full_view ].each do |view|
template "#{view}".to_sym, :template_engine => :erb, :orm => :none do |template|
template.source = "app/views/%file_name%/#{view}.html.erb"
template.destination = "app/views" / base_path / "#{file_name}/#{view}.html.erb"
end
end

# template :paperclip do
# source(File.dirname(__FILE__) / 'templates' / '%file_name%.rb')
# destination("schema/migrations/#{migration_file_name}.rb")
# end
#
# def version
# format("%03d", current_migration_nr + 1)
# end
#
# def migration_file_name
# names = migration_attachments
# "#{version}_add_attachments_#{names.join("_")}_to_#{class_name.underscore}"
# end
#
# def migration_name
# names = migration_attachments
# "add_attachments_#{names.join("_")}_to_#{class_name.underscore}".classify
# end
#
# protected
#
# def migration_attachments
# names = attachments.map(&:underscore)
# attachments.length == 1 ? names : names[0..-2] + ["and", names[-1]]
# end
#
# def destination_directory
# File.join(destination_root, 'schema', 'migrations')
# end
#
# def current_migration_nr
# Dir["#{destination_directory}/*"].map{|f| File.basename(f).match(/^(\d+)/)[0].to_i }.max.to_i
# end
#
# end

add :rear_views, RearViewsGenerator
end
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
18 changes: 18 additions & 0 deletions lib/rear_views.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# make sure we're running inside Merb
if defined?(Merb::Plugins)

# Merb gives you a Merb::Plugins.config hash...feel free to put your stuff in your piece of it
Merb::Plugins.config[:rear_views] = {
:chickens => false
}

Merb::BootLoader.before_app_loads do
# require code that must be loaded before the application
end

Merb::BootLoader.after_app_loads do
# code that can be required after the application loads
end

Merb::Plugins.add_rakefiles "rear_views/merbtasks"
end
6 changes: 6 additions & 0 deletions lib/rear_views/merbtasks.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace :rear_views do
desc "Do something for rear_views"
task :default do
puts "rear_views doesn't do anything"
end
end
7 changes: 7 additions & 0 deletions spec/rear_views_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require File.dirname(__FILE__) + '/spec_helper'

describe "rear_views" do
it "should do nothing" do
true.should == true
end
end
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$:.push File.join(File.dirname(__FILE__), '..', 'lib')
Empty file added test/rear_views_test.rb
Empty file.
1 change: 1 addition & 0 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$:.push File.join(File.dirname(__FILE__), '..', 'lib')

0 comments on commit 1cc75df

Please sign in to comment.