forked from danlucraft/redcar
/
Rakefile
157 lines (128 loc) · 4.42 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
154
155
156
157
require 'rubygems'
require 'fileutils'
require 'spec/rake/spectask'
require 'cucumber/rake/task'
require "rake/gempackagetask"
require "rake/rdoctask"
if RUBY_PLATFORM =~ /mswin/
begin
require 'win32console'
rescue LoadError
ARGV << "--nocolour"
end
end
### DOCUMENTATION
begin
require 'yard'
YARD::Rake::YardocTask.new do |t|
t.files = [
'lib/*.rb',
'lib/*/*.rb',
'plugins/*/lib/*.rb',
'plugins/*/lib/**/*.rb'
]
t.options = ['--markup', 'markdown']
end
rescue LoadError
end
### TESTS
desc "Run all specs and features"
task :default => ["specs", "cucumber"]
task :specs do
files = Dir['plugins/*/spec/*/*_spec.rb'] + Dir['plugins/*/spec/*/*/*_spec.rb'] + Dir['plugins/*/spec/*/*/*/*_spec.rb']
case Config::CONFIG["host_os"]
when "darwin"
sh("jruby -J-XstartOnFirstThread -S spec -c #{files.join(" ")} && echo 'done'")
else
sh("jruby -S spec -c #{files.join(" ")} && echo 'done'")
end
end
desc "Run features"
task :cucumber do
case Config::CONFIG["host_os"]
when "darwin"
sh("jruby -J-XstartOnFirstThread bin/cucumber -cf progress plugins/*/features && echo 'done'")
else
sh("jruby bin/cucumber -cf progress plugins/*/features && echo 'done'")
end
end
### BUILD AND RELEASE
desc "Build"
task :build do
sh("ant jar -f vendor/java-mateview/build.xml")
cp("vendor/java-mateview/lib/java-mateview.rb", "plugins/edit_view_swt/vendor/")
cp("vendor/java-mateview/release/java-mateview.jar", "plugins/edit_view_swt/vendor/")
end
def remove_gitignored_files(filelist)
ignores = File.readlines(".gitignore")
ignores = ignores.select {|ignore| ignore.chomp.strip != ""}
ignores = ignores.map {|ignore| Regexp.new(ignore.chomp.gsub(".", "\\.").gsub("*", ".*"))}
r = filelist.select {|fn| not ignores.any? {|ignore| fn =~ ignore }}
r.select {|fn| fn !~ /\.jar$/}
end
spec = Gem::Specification.new do |s|
# Change these as appropriate
s.name = "redcar"
s.version = "0.3.2"
s.summary = "A JRuby text editor."
s.author = "Daniel Lucraft"
s.email = "dan@fluentradical.com"
s.homepage = "http://redcareditor.com"
s.has_rdoc = true
s.extra_rdoc_files = %w(README.md)
s.rdoc_options = %w(--main README.md)
# s.platform =
# Add any extra files to include in the gem
s.files = %w(CHANGES LICENSE Rakefile README.md ROADMAP.md) +
Dir.glob("bin/redcar") +
Dir.glob("config/**/*") +
remove_gitignored_files(Dir.glob("lib/**/*")) +
remove_gitignored_files(Dir.glob("plugins/**/*")) +
Dir.glob("textmate/Bundles/*.tmbundle/Syntaxes/**/*") +
Dir.glob("textmate/Themes/*.tmTheme")
s.executables = FileList["bin/redcar"].map { |f| File.basename(f) }
s.require_paths = ["lib"]
# If you want to depend on other gems, add them here, along with any
# relevant versions
# s.add_dependency("logging", "> 1.0.0")
# If your tests use any gems, include them here
s.add_development_dependency("cucumber")
s.add_development_dependency("rspec")
s.post_install_message = <<TEXT
------------------------------------------------------------------------------------
Please now run:
$ redcar install
to complete the installation.
(If you installed the gem with 'sudo', you will need to run 'sudo redcar install').
------------------------------------------------------------------------------------
TEXT
end
Rake::GemPackageTask.new(spec) do |pkg|
pkg.gem_spec = spec
end
desc 'Clean up the Textmate files for packaging'
task :clean_textmate do
# rename files to be x-platform safe
Dir["textmate/Bundles/*.tmbundle/{Syntaxes,Snippets,Templates}/**/*"].each do |fn|
if File.file?(fn)
bits = fn.split("/").last.split(".")[0..-2].join("_")
new_basename = bits.gsub(" ", "_").gsub(/[^\w_]/, "__") + File.extname(fn)
new_fn = File.join(File.dirname(fn), new_basename)
# p [fn,new_fn]
next if new_fn == fn
if File.exist?(new_fn)
puts "already exists #{new_fn}"
new_fn = File.join(File.dirname(fn), "next_" + new_basename)
unless File.exist?(new_fn)
FileUtils.mv(fn, new_fn)
end
else
begin
FileUtils.mv(fn, new_fn)
rescue => e
puts e
end
end
end
end
end