-
Notifications
You must be signed in to change notification settings - Fork 6
/
Rakefile
233 lines (194 loc) · 6.36 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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
libdir = File.expand_path("../lib", __FILE__)
$LOAD_PATH.unshift(libdir) unless $LOAD_PATH.include?(libdir)
require 'rubygems'
require 'rake'
require 'rake/testtask'
require 'sass'
require 'hyla/configuration'
require 'rake/minify'
require 'fileutils'
#############################################################################
#
# Helper functions
#
#############################################################################
def name
@name ||= Dir['*.gemspec'].first.split('.').first
end
def version
line = File.read("lib/#{name}/project.rb")[/^\s*VERSION\s*=\s*.*/]
line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1]
end
def date
Date.today.to_s
end
def gemspec_file
"#{name}.gemspec"
end
def gem_file
"#{name}-#{version}.gem"
end
def sass_assets
Hyla::Configuration.assets
end
def revealjs_redhat_css_theme_assets
[Hyla::Configuration.assets, 'revealjs-redhat', 'lib', 'css'] * '/'
end
def revealjs_css_theme_assets
[Hyla::Configuration.assets, 'revealjs', 'css', 'theme'] * '/'
end
def revealjs_css_vendor_assets
[Hyla::Configuration.assets, 'revealjs', 'lib', 'css'] * '/'
end
def default_compilation_style
'compressed'
end
def copy_sources()
source = [Hyla::Configuration.assets, 'sass'] * '/'
dest = [Hyla::Configuration.assets, 'revealjs-redhat', 'lib', 'sass'] * '/'
p source
p dest
FileUtils.cp_r source, dest
end
#
# Compass Style Values to generate the CSS file : nested, expanded, compact, compressed
#
style = ENV["STYLE"] || "nested"
tag_release = ENV["TAG_RELEASE"] || "#{name}-#{version}"
#############################################################################
#
# Standard tasks
#
#############################################################################
Rake::TestTask.new do |t|
t.libs << 'test'
end
# Simple Test case
task :test do
ruby "test/my_test.rb"
end
desc "Run tests"
task :default => :test
desc "Generate CSS files"
task :compass, [:mode] do |t, args|
mode = args.mode || 'development'
if mode == "development"
output_style = 'expanded'
else
output_style = 'compact'
end
puts "\n## Compiling Sass"
# path = Gem.loaded_specs['font-awesome-sass'].full_gem_path + "/assets/stylesheets"
# Go to the compass project directory
Dir.chdir File.join(sass_assets, "sass") do |dir|
puts "Sass dir : #{dir}"
# -s #{style} -I #{path}
# To generate the sourcemap --> --sourcemap
p "compass compile --fonts-dir 'fonts' --css-dir 'styles' --sass-dir '.' -e #{mode} --output-style=#{output_style} --force"
system "compass compile --fonts-dir 'fonts' --css-dir 'styles' --sass-dir '.' -e #{mode} --output-style=#{output_style} --force"
# Copy scss files to lib/sass dir
copy_sources()
# Copy css to RevealJS theme
# p revealjs_css_assets
sh "cp styles/old-gpe.css #{revealjs_css_theme_assets}"
sh "cp styles/font-awesome.css #{revealjs_css_vendor_assets}/font-awesome-4.3.0.css"
sh "cp styles/new-gpe.css #{revealjs_redhat_css_theme_assets}/gpe.css"
sh "cp styles/conference.css #{revealjs_redhat_css_theme_assets}/conference.css"
sh "cp styles/conference-blue.css #{revealjs_redhat_css_theme_assets}/conference-blue.css"
sh "cp styles/conference-redhat.css #{revealjs_redhat_css_theme_assets}/conference-redhat.css"
sh "cp styles/theme-v2-liberation.css #{revealjs_redhat_css_theme_assets}/theme-v2-liberation.css"
sh "cp styles/theme-v2-overpass.css #{revealjs_redhat_css_theme_assets}/theme-v2-overpass.css"
sh "cp styles/theme-output.css #{revealjs_redhat_css_theme_assets}/theme-output.css"
sh "cp styles/font-awesome.css #{revealjs_redhat_css_theme_assets}/font-awesome-4.3.0.css"
end
end
desc "Build the Gem"
task :build do
system "gem build #{gemspec_file}"
end
desc "Build the Gem & deploy it locally"
task :install => :build do
system "gem install #{gem_file} -l"
end
desc "Build the Gem, install it locally & push it"
task :deploy => :install do
system "gem push #{gem_file}"
end
desc "Tag Hyla release to github repo"
task :tag_release do
system "git tag -a #{name}-#{version} -m 'Release of hyla #{version}'"
system "git push origin #{name}-#{version}"
end
desc "Delete the git tag"
task :tag_delete, [:version] do |t, args|
version = args.version or
fail "version is mandatory"
p "Tag to be removed: #{version}"
sh "git tag -d #{version}"
sh "git push origin :#{version}"
end
desc "Build the Gem and move it under the pkg directory"
task :build_pkg do
sh "mkdir -p pkg"
sh "gem build #{gemspec_file}"
sh "mv #{gem_file} pkg"
end
#
# Generate doc for gh-pages
#
desc "Commit the local site to the gh-pages branch and publish to GitHub Pages"
task :publish do
# Ensure the gh-pages dir exists so we can generate into it.
puts "Checking for gh-pages dir..."
unless File.exist?("./gh-pages")
puts "Creating gh-pages dir..."
sh "git clone [email protected]:cmoulliard/hyla.git gh-pages"
end
# Ensure latest gh-pages branch history.
Dir.chdir('gh-pages') do
sh "git checkout gh-pages"
sh "git pull origin gh-pages"
end
# Proceed to purge all files in case we removed a file in this release.
puts "Cleaning gh-pages directory..."
purge_exclude = %w[
gh-pages/.
gh-pages/..
gh-pages/.git
gh-pages/.gitignore
]
FileList["gh-pages/{*,.*}"].exclude(*purge_exclude).each do |path|
sh "rm -rf #{path}"
end
# Copy site to gh-pages dir.
puts "Building site into gh-pages branch..."
# Generate HTML site using hyla
sh "hyla generate -c config.yaml"
# Commit and push.
puts "Committing and pushing to GitHub Pages..."
sha = `git rev-parse HEAD`.strip
Dir.chdir('gh-pages') do
sh "git add ."
sh "git commit --allow-empty -m 'Updating to #{sha}.'"
sh "git push origin gh-pages"
end
puts 'Done.'
end
Rake::Minify.new(:minifyjs) do
dir("lib/resources/assets/revealjs/js/debug") do
add("lib/resources/assets/revealjs/js/reveal.min.js", "reveal.js")
end
dir("lib/resources/assets/revealjs-redhat/lib/js/debug") do
add("lib/resources/assets/revealjs-redhat/lib/js/reveal.min.js", "reveal.js")
add("lib/resources/assets/revealjs-redhat/lib/js/head.min.js", "head.js")
add("lib/resources/assets/revealjs-redhat/lib/js/gpe.min.js", "gpe.js")
end
end
# desc 'Say Hello'
# task :hello, [:msg1, :msg2] do |t, args|
# msg1 = args.msg1 or
# fail "Msg1 is mandatory"
# msg2 = args[:msg2] || "Man"
# puts msg1.upcase + '!'
# puts msg2.downcase + '!'
# end