Permalink
Browse files

basic gem/plugin structure

  • Loading branch information...
1 parent a262df5 commit 9c46e17044e20ca3093f21df1b9d46beb43ae41a @jamesarosen committed Feb 23, 2010
Showing with 122 additions and 0 deletions.
  1. +5 −0 .gitignore
  2. +6 −0 Rakefile
  3. +29 −0 developer_tasks/doc.rake
  4. +34 −0 developer_tasks/gem.rake
  5. +20 −0 developer_tasks/test.rake
  6. +7 −0 init.rb
  7. +2 −0 lib/xebec.rb
  8. +3 −0 rails/init.rb
  9. +3 −0 tasks/README.md
  10. +13 −0 test/test_helper.rb
View
@@ -0,0 +1,5 @@
+.DS_Store
+*/.DS_Store
+doc/rdoc
+.yardoc
+pkg
View
@@ -0,0 +1,6 @@
+require 'rake'
+
+Dir['developer_tasks/*.rake'].each { |f| load(f) }
+
+desc "Default: run all tests"
+task :default => ['test']
View
@@ -0,0 +1,29 @@
+desc "Generate RDoc"
+task :doc => ['doc:generate']
+
+namespace :doc do
+ project_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
+ doc_destination = File.join(project_root, 'doc', 'rdoc')
+
+ begin
+ require 'yard'
+ require 'yard/rake/yardoc_task'
+
+ YARD::Rake::YardocTask.new(:generate) do |yt|
+ yt.files = Dir.glob(File.join(project_root, 'lib', '**', '*.rb')) +
+ [ File.join(project_root, 'README.rdoc') ]
+ yt.options = ['--output-dir', doc_destination, '--readme', 'README.rdoc']
+ end
+ rescue LoadError
+ desc "Generate YARD Documentation"
+ task :generate do
+ abort "Please install the YARD gem to generate rdoc."
+ end
+ end
+
+ desc "Remove generated documenation"
+ task :clean do
+ rm_r doc_dir if File.exists?(doc_destination)
+ end
+
+end
View
@@ -0,0 +1,34 @@
+namespace :gem do
+ begin
+ require 'jeweler'
+ Jeweler::Tasks.new do |gemspec|
+ gemspec.name = "xebec"
+ gemspec.summary = "Navigation helpers"
+ gemspec.description = "Helpers for generating navigation bars"
+ gemspec.email = "james.a.rosen@gmail.com"
+ gemspec.homepage = "http://github.com/jamesarosen/xebec"
+ gemspec.authors = ["James Rosen"]
+ gemspec.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Xebec Documentation", "--charset", "utf-8"]
+ gemspec.platform = Gem::Platform::RUBY
+ gemspec.add_development_dependency 'shoulda', '~> 2.10.3'
+ gemspec.add_development_dependency 'mocha', '~> 0.9.8'
+ gemspec.add_development_dependency 'redgreen', '~> 1.2.2'
+ end
+ rescue LoadError
+ puts "Jeweler not available. Install it with [sudo] gem install jeweler -s http://gemscutter.org"
+ end
+
+ task :push do
+ command = ('gem push')
+ command << " -p $#{ENV['http_proxy']}" if ENV['http_proxy']
+ command << " #{latest_gem}"
+ puts "Pushing gem..."
+ IO.popen(command) { |io| io.each { |line| puts ' ' + line } }
+ end
+
+ def latest_gem
+ result = File.expand_path(Dir.glob(File.join(File.dirname(__FILE__), '..', 'pkg', '*.gem')).sort.last)
+ abort "No gems found in pkg/. Did you run gem:build?" if result.nil?
+ result
+ end
+end
View
@@ -0,0 +1,20 @@
+require 'rake/testtask'
+
+project_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
+
+lib_directories = FileList.new do |fl|
+ fl.include "#{project_root}/lib"
+ fl.include "#{project_root}/test/lib"
+end
+
+test_files = FileList.new do |fl|
+ fl.include "#{project_root}/test/**/*_test.rb"
+ fl.exclude "#{project_root}/test/test_helper.rb"
+ fl.exclude "#{project_root}/test/lib/**/*.rb"
+end
+
+Rake::TestTask.new(:test) do |t|
+ t.libs = lib_directories
+ t.test_files = test_files
+ t.verbose = true
+end
View
@@ -0,0 +1,7 @@
+# Rails uses rails/init.rb, not this file. Put any Rails-specific
+# initialization in that file.
+
+lib_path = File.expand_path(File.join(File.dirname(__FILE__), 'lib'))
+$: << lib_path unless $:.include?(lib_path)
+
+require 'xebec'
View
@@ -0,0 +1,2 @@
+module Xebec
+end
View
@@ -0,0 +1,3 @@
+load File.join(File.dirname(__FILE__), '..', 'init.rb')
+
+# do any Rails-specific initialization here:
View
@@ -0,0 +1,3 @@
+This directory holds tasks that users of the gem will use. If a user adds this gem to a Rails project, Rails will automatically load all tasks in this directory.
+
+Tasks for the development of this gem go in the `developer_tasks` (a sibling directory to this one).
View
@@ -0,0 +1,13 @@
+require 'test/unit'
+require 'test/unit/testcase'
+require 'rubygems'
+require 'shoulda'
+require 'mocha'
+require 'redgreen'
+
+[['..', 'lib'], ['lib']].each do |lib_dir|
+ lib_path = File.expand_path(File.join(File.dirname(__FILE__), *lib_dir))
+ $: << lib_path unless $:.include?(lib_path)
+end
+
+require 'xebec'

0 comments on commit 9c46e17

Please sign in to comment.