Move tasks -> rakelib
This commit is contained in:
1 parent
0244bf13b3
commit
7ac37a54f0
7 files changed
-2
No files matched your search
@@ -0,0 +1,34 @@
|
||||
require "rubygems/package_task"
|
||||
|
||||
namespace :gem do
|
||||
|
||||
desc "Build the gem"
|
||||
task :build do
|
||||
system "gem build signet.gemspec"
|
||||
end
|
||||
|
||||
desc "Install the gem"
|
||||
task :install => ["clobber", "gem:package"] do
|
||||
sh "#{SUDO} gem install --local pkg/#{GEM_SPEC.full_name}"
|
||||
end
|
||||
|
||||
desc "Uninstall the gem"
|
||||
task :uninstall do
|
||||
installed_list = Gem.source_index.find_name(PKG_NAME)
|
||||
if installed_list &&
|
||||
(installed_list.collect { |s| s.version.to_s}.include?(PKG_VERSION))
|
||||
sh(
|
||||
"#{SUDO} gem uninstall --version '#{PKG_VERSION}' " +
|
||||
"--ignore-dependencies --executables #{PKG_NAME}"
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
desc "Reinstall the gem"
|
||||
task :reinstall => [:uninstall, :install]
|
||||
end
|
||||
|
||||
desc "Alias to gem:package"
|
||||
task "gem" => "gem:package"
|
||||
|
||||
task "clobber" => ["gem:clobber_package"]
|
||||
@@ -0,0 +1,45 @@
|
||||
namespace :git do
|
||||
namespace :tag do
|
||||
desc 'List tags from the Git repository'
|
||||
task :list do
|
||||
tags = `git tag -l`
|
||||
tags.gsub!("\r", '')
|
||||
tags = tags.split("\n").sort {|a, b| b <=> a }
|
||||
puts tags.join("\n")
|
||||
end
|
||||
|
||||
desc 'Create a new tag in the Git repository'
|
||||
task :create do
|
||||
changelog = File.open('CHANGELOG.md', 'r') { |file| file.read }
|
||||
puts '-' * 80
|
||||
puts changelog
|
||||
puts '-' * 80
|
||||
puts
|
||||
|
||||
v = ENV['VERSION'] or abort 'Must supply VERSION=x.y.z'
|
||||
abort "Versions don't match #{v} vs #{PKG_VERSION}" if v != PKG_VERSION
|
||||
|
||||
git_status = `git status`
|
||||
if git_status !~ /nothing to commit \(working directory clean\)/
|
||||
abort "Working directory isn't clean."
|
||||
end
|
||||
|
||||
tag = "#{PKG_NAME}-#{PKG_VERSION}"
|
||||
msg = "Release #{PKG_NAME}-#{PKG_VERSION}"
|
||||
|
||||
existing_tags = `git tag -l #{PKG_NAME}-*`.split('\n')
|
||||
if existing_tags.include?(tag)
|
||||
warn('Tag already exists, deleting...')
|
||||
unless system "git tag -d #{tag}"
|
||||
abort 'Tag deletion failed.'
|
||||
end
|
||||
end
|
||||
puts "Creating git tag '#{tag}'..."
|
||||
unless system "git tag -a -m \"#{msg}\" #{tag}"
|
||||
abort 'Tag creation failed.'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
task 'gem:release' => 'git:tag:create'
|
||||
@@ -0,0 +1,22 @@
|
||||
namespace :metrics do
|
||||
task :lines do
|
||||
lines, codelines, total_lines, total_codelines = 0, 0, 0, 0
|
||||
for file_name in FileList['lib/**/*.rb']
|
||||
f = File.open(file_name)
|
||||
while line = f.gets
|
||||
lines += 1
|
||||
next if line =~ /^\s*$/
|
||||
next if line =~ /^\s*#/
|
||||
codelines += 1
|
||||
end
|
||||
puts "L: #{sprintf('%4d', lines)}, " +
|
||||
"LOC #{sprintf('%4d', codelines)} | #{file_name}"
|
||||
total_lines += lines
|
||||
total_codelines += codelines
|
||||
|
||||
lines, codelines = 0, 0
|
||||
end
|
||||
|
||||
puts "Total: Lines #{total_lines}, LOC #{total_codelines}"
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,22 @@
|
||||
require 'rake/clean'
|
||||
require 'rspec/core/rake_task'
|
||||
|
||||
CLOBBER.include('coverage', 'specdoc')
|
||||
|
||||
namespace :spec do
|
||||
RSpec::Core::RakeTask.new(:all) do |t|
|
||||
t.pattern = FileList['spec/**/*_spec.rb']
|
||||
t.rspec_opts = ['--color', '--format', 'documentation']
|
||||
end
|
||||
|
||||
desc 'Generate HTML Specdocs for all specs.'
|
||||
RSpec::Core::RakeTask.new(:specdoc) do |t|
|
||||
specdoc_path = File.expand_path('../../specdoc', __FILE__)
|
||||
|
||||
t.rspec_opts = %W( --format html --out #{File.join(specdoc_path, 'index.html')} )
|
||||
t.fail_on_error = false
|
||||
end
|
||||
end
|
||||
|
||||
desc 'Alias to spec:all'
|
||||
task 'spec' => 'spec:all'
|
||||
@@ -0,0 +1,82 @@
|
||||
require 'rake'
|
||||
require 'rake/clean'
|
||||
|
||||
CLOBBER.include('wiki')
|
||||
|
||||
CACHE_PREFIX =
|
||||
"http://www.gmodules.com/gadgets/proxy/container=default&debug=0&nocache=0/"
|
||||
|
||||
namespace :wiki do
|
||||
desc 'Autogenerate wiki pages'
|
||||
task :supported_apis do
|
||||
output = <<-WIKI
|
||||
#summary The list of supported APIs
|
||||
|
||||
The Google API Client for Ruby is a small flexible client library for accessing
|
||||
the following Google APIs.
|
||||
|
||||
WIKI
|
||||
preferred_apis = {}
|
||||
require 'google/api_client'
|
||||
client = Google::APIClient.new
|
||||
for api in client.discovered_apis
|
||||
if !preferred_apis.has_key?(api.name)
|
||||
preferred_apis[api.name] = api
|
||||
elsif api.preferred
|
||||
preferred_apis[api.name] = api
|
||||
end
|
||||
end
|
||||
for api_name, api in preferred_apis
|
||||
if api.documentation.to_s != "" && api.title != ""
|
||||
output += (
|
||||
"||#{CACHE_PREFIX}#{api['icons']['x16']}||" +
|
||||
"[#{api.documentation} #{api.title}]||" +
|
||||
"#{api.description}||\n"
|
||||
)
|
||||
end
|
||||
end
|
||||
output.gsub!(/-32\./, "-16.")
|
||||
wiki_path = File.expand_path(
|
||||
File.join(File.dirname(__FILE__), '../wiki/'))
|
||||
Dir.mkdir(wiki_path) if !File.exist?(wiki_path)
|
||||
File.open(File.join(wiki_path, 'SupportedAPIs.wiki'), 'w') do |file|
|
||||
file.write(output)
|
||||
end
|
||||
end
|
||||
|
||||
task 'generate' => ['wiki:supported_apis']
|
||||
end
|
||||
|
||||
begin
|
||||
$LOAD_PATH.unshift(
|
||||
File.expand_path(File.join(File.dirname(__FILE__), '../yard/lib'))
|
||||
)
|
||||
$LOAD_PATH.unshift(File.expand_path('.'))
|
||||
$LOAD_PATH.uniq!
|
||||
|
||||
require 'yard'
|
||||
require 'yard/rake/wikidoc_task'
|
||||
|
||||
namespace :wiki do
|
||||
desc 'Generate Wiki Documentation with YARD'
|
||||
YARD::Rake::WikidocTask.new do |yardoc|
|
||||
yardoc.name = 'reference'
|
||||
yardoc.options = [
|
||||
'--verbose',
|
||||
'--markup', 'markdown',
|
||||
'-e', 'yard/lib/yard-google-code.rb',
|
||||
'-p', 'yard/templates',
|
||||
'-f', 'wiki',
|
||||
'-o', 'wiki'
|
||||
]
|
||||
yardoc.files = [
|
||||
'lib/**/*.rb', 'ext/**/*.c', '-', 'README.md', 'CHANGELOG.md'
|
||||
]
|
||||
end
|
||||
|
||||
task 'generate' => ['wiki:reference', 'wiki:supported_apis']
|
||||
end
|
||||
rescue LoadError
|
||||
# If yard isn't available, it's not the end of the world
|
||||
warn('YARD unavailable. Cannot fully generate wiki.')
|
||||
end
|
||||
@@ -0,0 +1,29 @@
|
||||
require 'rake'
|
||||
require 'rake/clean'
|
||||
|
||||
CLOBBER.include('doc', '.yardoc')
|
||||
CLOBBER.uniq!
|
||||
|
||||
begin
|
||||
require 'yard'
|
||||
require 'yard/rake/yardoc_task'
|
||||
|
||||
namespace :doc do
|
||||
desc 'Generate Yardoc documentation'
|
||||
YARD::Rake::YardocTask.new do |yardoc|
|
||||
yardoc.name = 'yard'
|
||||
yardoc.options = ['--verbose', '--markup', 'markdown']
|
||||
yardoc.files = [
|
||||
'lib/**/*.rb', 'ext/**/*.c', '-',
|
||||
'README.md', 'CONTRIB.md', 'CHANGELOG.md', 'LICENSE'
|
||||
]
|
||||
end
|
||||
end
|
||||
|
||||
desc 'Alias to doc:yard'
|
||||
task 'doc' => 'doc:yard'
|
||||
rescue LoadError
|
||||
# If yard isn't available, it's not the end of the world
|
||||
desc 'Alias to doc:rdoc'
|
||||
task 'doc' => 'doc:rdoc'
|
||||
end
|
||||
Reference in new issue
Block a user