forked from 10xSebastian/yard-rest-plugin
-
Notifications
You must be signed in to change notification settings - Fork 21
/
Rakefile
68 lines (63 loc) · 2.09 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
require 'rubygems'
require 'rake'
begin
require 'jeweler'
Jeweler::Tasks.new do |gem|
gem.name = "yard-restful"
gem.summary = %Q{Yardoc plugin for Restful web services}
gem.description = %Q{A customized plugin for Yardoc that produces API documentation for Restful web services}
gem.email = ''
gem.homepage = "https://github.com/kraft001/yard-restful"
gem.authors = ['Konstantin Rafalsky']
gem.licenses = ['MIT']
gem.add_dependency("yard", '~>0.8.3')
gem.files = Dir.glob("{lib,templates}/**/*").concat(["Rakefile"])
gem.extra_rdoc_files = ['VERSION', 'README.markdown']
end
Jeweler::GemcutterTasks.new
rescue LoadError
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
end
desc "Rebuild the gem from the gemspec"
task :rebuild do
gemfilename = 'yard-restful-' + IO.read('VERSION').strip + '.gem'
`rm yard-restful-*.gem`
`gem uninstall yard-restful && \
gem build yard-restful.gemspec && \
gem install #{gemfilename}`
end
namespace :example do
desc "Generate example docs"
task :generate do
unless gem_available?('yard-restful')
puts 'Gem yard-restful is not installed. Trying to build from local version.'
Rake::Task["rebuild"].execute
puts 'Gem yard-restful should be installed.'
end
unless gem_available?('redcarpet')
puts 'Warning: gem redcarpet is not installed. Some texts may look ugly.'
end
puts `yardoc -e ./lib/yard-restful.rb --title "Example Books API" --readme ./example/API_README.md --markup markdown ./example/*.rb`
# `x-www-browser ./doc/index.html`
puts 'On success open ./doc/index.html or ./doc/frames.html in your preferred browser'
end
desc "Clean example docs"
task :clean do
`rm -R doc`
`rm -R .yardoc`
puts 'Done!'
end
end
def gem_available?(name, requirements = nil)
Gem::Specification.find_by_name(name, requirements)
true
rescue Gem::LoadError
false
rescue
Gem.available?(name)
# Gem.source_index.find_name(name, requirements).empty?
# gem name.to_s, requirements
# return true
#rescue GEM::LoadError
# return false
end