forked from manveru/ramaze
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Rakefile
153 lines (132 loc) · 3.79 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
begin
require 'rubygems'
rescue LoadError
end
require 'rake'
require 'rake/clean'
require 'rake/packagetask'
require 'rake/gempackagetask'
require 'rake/rdoctask'
require 'fileutils'
require 'time'
require 'pp'
include FileUtils
$:.unshift File.join(File.dirname(__FILE__), "lib")
require 'ramaze/version'
load 'rake_tasks/conf.rake'
load 'rake_tasks/gem.rake'
load 'rake_tasks/maintenance.rake'
load 'rake_tasks/spec.rake'
load 'rake_tasks/coverage.rake'
load 'rake_tasks/git.rake'
task :default => ['spec']
task :test => ['spec']
task :package => ['jquery']
desc 'download latest jquery and put in /lib/proto/public/js/jquery.js'
task :jquery do
require 'open-uri'
$stdout.sync = true
File.open('lib/proto/public/js/jquery.js', 'w+') do |jquery|
remote = open('http://code.jquery.com/jquery-latest.js')
print "openend remote side, copying..."
while chunk = remote.read(4096)
print '.'
jquery.write(chunk)
end
puts " done."
end
end
task :rcov_dir do
mkdir_p 'doc/output/tools/rcov/'
end
desc "Generate HTML coverage report"
task :rcov_summary => :rcov_dir do
`rcov --version`
raise LoadError, "Please `gem install rcov` first" if $?.exitstatus == 127
raise "Run `rake coverage` to generate coverage data first" unless File.exists? 'coverage.data'
sh "rcov --aggregate coverage.data -o doc/output/tools/rcov/"
end
desc "generate rdoc"
task :rdoc => [:clean, :readme2html] do
sh "rdoc #{(RDOC_OPTS + RDOC_FILES).join(' ')}"
end
desc "generate improved allison-rdoc"
task :allison => :clean do
opts = RDOC_OPTS
path = `allison --path`.strip
raise LoadError, "Please `gem install allison` first" if $?.exitstatus == 127
opts << %W[--template '#{path}']
sh "rdoc #{(RDOC_OPTS + RDOC_FILES).join(' ')}"
end
desc "create bzip2 and tarball"
task :distribute => :gem do
sh "rm -rf pkg/ramaze-#{VERS}"
sh "mkdir -p pkg/ramaze-#{VERS}"
sh "cp -r {bin,doc,lib,examples,spec,Rakefile,README.markdown,rake_tasks} pkg/ramaze-#{VERS}/"
Dir.chdir('pkg') do |pwd|
sh "tar -zcvf ramaze-#{VERS}.tar.gz ramaze-#{VERS}"
sh "tar -jcvf ramaze-#{VERS}.tar.bz2 ramaze-#{VERS}"
end
sh "rm -rf pkg/ramaze-#{VERS}"
end
desc "show a todolist from all the TODO tags in the source"
task :todo do
files = Dir[File.join(BASEDIR, '{lib,spec}', '**/*.rb')]
files.each do |file|
lastline = todo = comment = long_comment = false
File.readlines(file).each_with_index do |line, lineno|
lineno += 1
comment = line =~ /^\s*?#.*?$/
long_comment = line =~ /^=begin/
long_comment = line =~ /^=end/
todo = true if line =~ /TODO/ and (long_comment or comment)
todo = false if line.gsub('#', '').strip.empty?
todo = false unless comment or long_comment
if todo
unless lastline and lastline + 1 == lineno
puts
puts "vim #{file} +#{lineno}"
end
l = line.strip.gsub(/^#\s*/, '')
print ' ' unless l =~ /^-/
puts l
lastline = lineno
end
end
end
end
desc "opens a simple readline that makes making requests easier"
task 'request' do
ARGV.clear
require 'open-uri'
require 'pp'
loop do
print 'do request? [enter] '
gets
begin
pp open('http://localhost:7000/xxx').read
rescue Object => ex
puts ex
end
end
end
desc 'listing of available traits per class/module'
task 'traits' do
nodes = Hash.new{|h,k| h[k] = []}
Dir['lib/**/*.rb'].each do |file|
content = File.read(file)
traits = content.grep(/^\s*trait\s*:/)
traits.each do |trait|
space = content[0..content.index(trait)].scan(/^\s*(?:class|module)\s+(.*)$/)
space = space.flatten.join('::')
nodes[space] << trait.strip
end
end
nodes.each do |space, traits|
puts space
traits.each do |trait|
print ' ', trait, "\n"
end
puts
end
end