forked from house9/jquery-iframe-auto-height
-
Notifications
You must be signed in to change notification settings - Fork 0
/
releaser.rb
44 lines (35 loc) · 1.6 KB
/
releaser.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
require 'rubygems'
require 'uglifier'
require './version'
puts " "
puts "Release for #{Version::JQUERY_IFRAME_AUTO_HEIGHT_VERSION}"
source_file_name = "demo_on_rails/app/assets/javascripts/src/jquery.iframe-auto-height.plugin.js"
output_file_name_minified = "release/jquery.iframe-auto-height.plugin.#{Version::JQUERY_IFRAME_AUTO_HEIGHT_VERSION}.min.js"
output_file_name_full = "release/jquery.iframe-auto-height.plugin.#{Version::JQUERY_IFRAME_AUTO_HEIGHT_VERSION}.js"
output_file_name_no_version = "release/jquery.iframe-auto-height.js"
def update_content(content)
Version::TOKENS_AND_VALUES.each { |item| content.gsub!(item[:token], item[:value]) }
content.gsub!(Version::AUTHOR_TOKEN, Version::AUTHORS.join("\n "))
end
# read source file
input = File.read(source_file_name)
# ********************
# full release
update_content(input)
File.open(output_file_name_full, 'w') { |f| f.write(input) }
puts " created #{output_file_name_full}"
File.open(output_file_name_no_version, 'w') { |f| f.write(input) }
puts " created #{output_file_name_no_version}"
# ********************
# minified, uglifier will rip out comments, so we put back some of them
minified_intro = "/*\n #{Version::TOKENS_AND_VALUES.map {|item| item[:value]}.join("\n ").chomp!} \n*/"
uglified = Uglifier.new({:copyright => false}).compile(input)
File.open(output_file_name_minified, 'w') { |f| f.write("#{minified_intro}\n#{uglified}; ") }
puts " created #{output_file_name_minified}"
puts "Done"
puts " "
puts " => update README.markdown; version number and if author list has changed"
Version::AUTHORS.each do |author|
puts author
end
puts " "