Skip to content

Commit

Permalink
added plugin example
Browse files Browse the repository at this point in the history
  • Loading branch information
davebryson committed Jul 30, 2008
1 parent 85de3f8 commit b351ef0
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 0 deletions.
20 changes: 20 additions & 0 deletions code/myblog/vendor/plugins/mail_tag/MIT-LICENSE
@@ -0,0 +1,20 @@
Copyright (c) 2008 [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.
4 changes: 4 additions & 0 deletions code/myblog/vendor/plugins/mail_tag/README
@@ -0,0 +1,4 @@
MailTag
=======

Really simple plugin. For education purposes only!
22 changes: 22 additions & 0 deletions code/myblog/vendor/plugins/mail_tag/Rakefile
@@ -0,0 +1,22 @@
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'

desc 'Default: run unit tests.'
task :default => :test

desc 'Test the mail_tag plugin.'
Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.pattern = 'test/**/*_test.rb'
t.verbose = true
end

desc 'Generate documentation for the mail_tag plugin.'
Rake::RDocTask.new(:rdoc) do |rdoc|
rdoc.rdoc_dir = 'rdoc'
rdoc.title = 'MailTag'
rdoc.options << '--line-numbers' << '--inline-source'
rdoc.rdoc_files.include('README')
rdoc.rdoc_files.include('lib/**/*.rb')
end
1 change: 1 addition & 0 deletions code/myblog/vendor/plugins/mail_tag/init.rb
@@ -0,0 +1 @@
ActionView::Base.send(:include, MailTag)
1 change: 1 addition & 0 deletions code/myblog/vendor/plugins/mail_tag/install.rb
@@ -0,0 +1 @@
# Install hook code here
12 changes: 12 additions & 0 deletions code/myblog/vendor/plugins/mail_tag/lib/mail_tag.rb
@@ -0,0 +1,12 @@
module MailTag

# a simple (and dumb) helper as an example
def mail_to(addr)
if addr =~ /(.+)@(.+)\.(.{3})/
"<a href='mailto:#{addr}'>#{addr}</a>"
else
"Bad!"
end
end

end
4 changes: 4 additions & 0 deletions code/myblog/vendor/plugins/mail_tag/tasks/mail_tag_tasks.rake
@@ -0,0 +1,4 @@
# desc "Explaining what the task does"
# task :mail_tag do
# # Task goes here
# end
19 changes: 19 additions & 0 deletions code/myblog/vendor/plugins/mail_tag/test/mail_tag_test.rb
@@ -0,0 +1,19 @@
require 'test/unit'

# Require our module
require File.dirname(__FILE__) + '/../lib/mail_tag'

class MailTagTest < Test::Unit::TestCase
include MailTag # include it

# Should pass
def test_tag_pass
assert_equal mail_to("bob@here.com"), "<a href='mailto:bob@here.com'>bob@here.com</a>"
end

# Better fail
def test_fail
assert_equal mail_to("bob_here.com"), "Bad!"
end

end
1 change: 1 addition & 0 deletions code/myblog/vendor/plugins/mail_tag/uninstall.rb
@@ -0,0 +1 @@
# Uninstall hook code here

0 comments on commit b351ef0

Please sign in to comment.