forked from watir/watir-classic
/
Rakefile.rb
134 lines (128 loc) · 4.64 KB
/
Rakefile.rb
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
base = File.dirname(__FILE__)
['vapir-common','vapir-ie','vapir-firefox'].each do |lib|
libdir = File.join(base, lib, 'lib')
if File.directory?(libdir) && !$LOAD_PATH.any?{|lp| File.expand_path(lp) == File.expand_path(libdir) }
$LOAD_PATH.unshift(libdir)
end
end
require 'vapir-common/external/core_extensions.rb'
def rdoc(hash)
default_stuff = {:format => 'html', :"tab-width" => 2, :"show-hash" => nil, :"inline-source" => nil, :template => 'hanna', :charset => 'UTF-8'}
hash = default_stuff.merge(hash)
# STDOUT.puts hash.inspect
options = (hash.keys-[:files]).inject([]) do |list, key|
value = hash[key]
ddkey="--#{key}"
list + case value
when nil
[ddkey]
when Array
value.inject([]){|vlist, value_part| vlist+[ddkey, value_part.to_s]}
else
[ddkey, value.to_s]
end
end
options+=(hash[:files] || [])
# STDOUT.puts options.inspect
if hash[:op] && File.exists?(hash[:op])
require 'fileutils'
FileUtils.rm_r(hash[:op])
end
gem 'hanna'
require 'hanna/version'
Hanna::require_rdoc
require 'rdoc/rdoc'
RDoc::RDoc.new.document(options)
end
def common_files
@common_files ||= begin
load 'vapir-common/vapir-common.gemspec'
Vapir::Common::GemSpec.files.map{|f| File.join('vapir-common', f)}
end
end
def ie_files
@ie_files ||= begin
load 'vapir-ie/vapir-ie.gemspec'
Vapir::IE::GemSpec.files.map{|f| File.join('vapir-ie', f)}
end
end
def ff_files
@ff_files ||= begin
load 'vapir-firefox/vapir-firefox.gemspec'
Vapir::Firefox::GemSpec.files.map{|f| File.join('vapir-firefox', f)}
end
end
def exclude
@exclude ||= %w(
vapir-firefox/lib/vapir-firefox/javascript_object.rb
vapir-firefox/lib/vapir-firefox/firefox_extension
vapir-ie/lib/vapir-ie/win32ole/win32ole.c
)
end
desc 'Build all rdoc'
task :rdoc => [:vapir_rdoc, :vapir_ie_rdoc, :vapir_ff_rdoc, :socket_rdoc]
desc 'Build Vapir rdoc'
task :vapir_rdoc do
require 'vapir-common/version'
rdoc(:op => 'vapir_rdoc', :title => "Vapir #{Vapir::Common::VERSION}", :files => (common_files + ie_files + ff_files).select{|file| file =~ /\.rb$/ } - exclude, :exclude => exclude)
end
desc 'Build Vapir-IE rdoc'
task :vapir_ie_rdoc do
require 'vapir-ie/version'
rdoc(:op => 'vapir_ie_rdoc', :title => "Vapir-IE #{Vapir::IE::VERSION}", :files => (common_files + ie_files).select{|file| file =~ /\.rb$/ } - exclude, :exclude => exclude)
end
desc 'Build Vapir-Firefox rdoc'
task :vapir_ff_rdoc do
require 'vapir-firefox/version'
rdoc(:op => 'vapir_ff_rdoc', :title => "Vapir-Firefox #{Vapir::Firefox::VERSION}", :files => (common_files + ff_files).select{|file| file =~ /\.rb$/ } - exclude, :exclude => exclude)
end
desc 'Build JavascriptObject, FirefoxSocket rdoc'
task :socket_rdoc do
rdoc(:op => 'socket_rdoc', :title => 'JavascriptObject & FirefoxSocket', :main => 'JavascriptObject', :files => ['vapir-firefox/lib/vapir-firefox/javascript_object.rb', 'vapir-firefox/lib/vapir-firefox/firefox_socket/base.rb', 'vapir-firefox/lib/vapir-firefox/firefox_socket/mozrepl.rb', 'vapir-firefox/lib/vapir-firefox/firefox_socket/jssh.rb'])
end
desc "check files for things that appear wrong: not in a gemfile; contains a carriage return; or wrong mode"
task :checkfiles do
should_be_gemfiles = Dir['vapir-*/lib/**/*']-Dir['vapir-ie/lib/vapir-ie/IEDialog/*'].select(&File.method(:file?))
are_gemfiles = common_files + ff_files + ie_files
are_gemfiles.reject{|gf| File.exists?(gf) }.each do |missing|
STDOUT.puts "missing gemfile: #{missing.inspect}"
end
ycomb do |recurse|
proc do |dir|
(Dir.entries(dir || '.')-['.', '..', '.git']).each do |entry|
file=dir ? File.join(dir, entry) : entry
if File.directory?(file)
recurse.call file
elsif File.file?(file)
if entry !~ /(\.gif|\.jpg|\.dll|\.so|\.png)$/i && File.read(file).include?("\r")
STDOUT.puts "\\r in #{file}"
end
if should_be_gemfiles.include?(file) && !are_gemfiles.include?(file)
STDOUT.puts "not in gemspec: #{file}"
end
if File.stat(file).mode & 0700 != 0600
STDOUT.puts "wrong mode: #{file}"
end
end
end
end
end.call(nil)
end
desc "Find carriage returns in the current directory"
task :findcr do
ycomb do |recurse|
proc do |dir|
(Dir.entries(dir)-['.', '..', '.git']).each do |entry|
next if entry =~ /(_rdoc|\.gif|\.jpg|\.dll|\.so|\.png)$/i
file=File.join(dir, entry)
if File.directory?(file)
recurse.call file
elsif File.file?(file)
if File.read(file).include?("\r")
puts "\\r in #{file}"
end
end
end
end
end.call('.')
end