PageRenderTime 42ms CodeModel.GetById 15ms RepoModel.GetById 1ms app.codeStats 0ms

/Rakefile

http://github.com/atduskgreg/rad
Rakefile | 142 lines | 116 code | 20 blank | 6 comment | 7 complexity | ebd6050f21c123c115871ee88dbd77d4 MD5 | raw file
  1. require 'rubygems'
  2. require 'rake'
  3. require 'rake/clean'
  4. require 'rake/testtask'
  5. require 'rake/packagetask'
  6. require 'rake/gempackagetask'
  7. require 'rake/rdoctask'
  8. require 'rake/contrib/rubyforgepublisher'
  9. require 'fileutils'
  10. require 'hoe'
  11. RAD_ROOT = File.expand_path(File.dirname(__FILE__))
  12. begin
  13. require 'spec/rake/spectask'
  14. rescue LoadError
  15. puts 'To use rspec for testing you must install rspec gem:'
  16. puts '$ sudo gem install rspec'
  17. exit
  18. end
  19. include FileUtils
  20. require File.join(File.dirname(__FILE__), 'lib', 'rad', 'version')
  21. BIN = "rad"
  22. AUTHOR = 'Greg Borenstein' # can also be an array of Authors
  23. EMAIL = "greg@mfdz.com"
  24. DESCRIPTION = "A framework for programming the Arduino physcial computing platform using Ruby. RAD converts Ruby scripts written using a set of Rails-like conventions and helpers into C source code which can be compiled and run on the Arduino microcontroller."
  25. GEM_NAME = 'rad' # what ppl will type to install your gem
  26. @config_file = "~/.rubyforge/user-config.yml"
  27. @config = nil
  28. def rubyforge_username
  29. unless @config
  30. begin
  31. @config = YAML.load(File.read(File.expand_path(@config_file)))
  32. rescue
  33. puts <<-EOS
  34. ERROR: No rubyforge config file found: #{@config_file}"
  35. Run 'rubyforge setup' to prepare your env for access to Rubyforge
  36. - See http://newgem.rubyforge.org/rubyforge.html for more details
  37. EOS
  38. exit
  39. end
  40. end
  41. @rubyforge_username ||= @config["username"]
  42. end
  43. RUBYFORGE_PROJECT = 'rad' # The unix name for your project
  44. HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
  45. DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
  46. NAME = "rad"
  47. REV = nil
  48. # UNCOMMENT IF REQUIRED:
  49. # REV = `svn info`.each {|line| if line =~ /^Revision:/ then k,v = line.split(': '); break v.chomp; else next; end} rescue nil
  50. VERS = Rad::VERSION::STRING + (REV ? ".#{REV}" : "")
  51. CLEAN.include ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store']
  52. RDOC_OPTS = ['--quiet', '--title', 'rad documentation',
  53. "--opname", "index.html",
  54. "--line-numbers",
  55. "--main", "README",
  56. "--inline-source"]
  57. class Hoe
  58. def extra_deps
  59. @extra_deps.reject { |x| Array(x).first == 'hoe' }
  60. end
  61. end
  62. # Generate all the Rake tasks
  63. # Run 'rake -T' to see list of generated tasks (from gem root directory)
  64. hoe = Hoe.new(GEM_NAME, VERS) do |p|
  65. p.author = AUTHOR
  66. p.description = DESCRIPTION
  67. p.email = EMAIL
  68. p.summary = DESCRIPTION
  69. p.url = HOMEPATH
  70. p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
  71. p.test_globs = ["test/**/test_*.rb"]
  72. p.clean_globs |= CLEAN #An array of file patterns to delete on clean.
  73. # == Optional
  74. p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
  75. p.extra_deps = [ ['RubyToC', '>= 1.0.0'] ]
  76. #p.spec_extras = {} # A hash of extra values to set in the gemspec.
  77. end
  78. CHANGES = hoe.paragraphs_of('History.txt', 0..1).join("\n\n")
  79. PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
  80. hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
  81. desc 'Generate website files'
  82. task :website_generate do
  83. Dir['website/**/*.txt'].each do |txt|
  84. sh %{ ruby scripts/txt2html #{txt} > #{txt.gsub(/txt$/,'html')} }
  85. end
  86. end
  87. desc 'Upload website files to rubyforge'
  88. task :website_upload do
  89. host = "#{rubyforge_username}@rubyforge.org"
  90. remote_dir = "/var/www/gforge-projects/#{PATH}/"
  91. local_dir = 'website'
  92. sh %{rsync -aCv #{local_dir}/ #{host}:#{remote_dir}}
  93. end
  94. desc 'Generate and upload website files'
  95. task :website => [:website_generate, :website_upload, :publish_docs]
  96. desc 'Release the website and new gem version'
  97. task :deploy => [:check_version, :website, :release] do
  98. puts "Remember to create SVN tag:"
  99. puts "svn copy svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/trunk " +
  100. "svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/tags/REL-#{VERS} "
  101. puts "Suggested comment:"
  102. puts "Tagging release #{CHANGES}"
  103. end
  104. desc 'Runs tasks website_generate and install_gem as a local deployment of the gem'
  105. task :local_deploy => [:website_generate, :install_gem]
  106. task :check_version do
  107. unless ENV['VERSION']
  108. puts 'Must pass a VERSION=x.y.z release version'
  109. exit
  110. end
  111. unless ENV['VERSION'] == VERS
  112. puts "Please update your version.rb to match the release version, currently #{VERS}"
  113. exit
  114. end
  115. end
  116. desc "Run the specs under spec/models"
  117. Spec::Rake::SpecTask.new do |t|
  118. t.spec_opts = ['--options', "spec/spec.opts"]
  119. t.spec_files = FileList['spec/models/*_spec.rb']
  120. end
  121. desc "Default task is to run specs"
  122. task :default => :spec