forked from chrisledet/bootstrap-wysihtml5-rails
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
85 lines (64 loc) · 3.1 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
#!/usr/bin/env rake
require File.expand_path('../lib/bootstrap-wysihtml5-rails/version', __FILE__)
ORIGIN_LIB_PATH = "bootstrap-wysihtml5/lib"
ORIGIN_SRC_PATH = "bootstrap-wysihtml5/src"
DEST_JAVASCRIPT_PATH = "vendor/assets/javascripts/bootstrap-wysihtml5"
DEST_CSS_PATH = "vendor/assets/stylesheets/bootstrap-wysihtml5"
def b2
system("cd bootstrap-wysihtml5 && git checkout master")
system("cp #{ORIGIN_SRC_PATH}/bootstrap-wysihtml5.css #{DEST_CSS_PATH}/core.css")
core_file = File.read("#{ORIGIN_SRC_PATH}/bootstrap-wysihtml5.js")
original_string = /stylesheets: \[".\/lib\/css\/wysiwyg-color.css"\]/
objective_string = "stylesheets: [\"<%= stylesheet_path('bootstrap-wysihtml5/wysiwyg-color.css') %>\"]"
replaced = core_file.gsub(original_string, objective_string)
File.open("#{DEST_JAVASCRIPT_PATH}/core.js.erb", "w") { |file| file.puts replaced }
end
def b3
system("cd bootstrap-wysihtml5 && git checkout tb3")
system("cp #{ORIGIN_SRC_PATH}/bootstrap-wysihtml5.css #{DEST_CSS_PATH}/core-b3.css")
core_file = File.read("#{ORIGIN_SRC_PATH}/bootstrap-wysihtml5.js")
original_string = /stylesheets: \[".\/lib\/css\/wysiwyg-color.css"\]/
objective_string = "stylesheets: [\"<%= stylesheet_path('bootstrap-wysihtml5/wysiwyg-color.css') %>\"]"
replaced = core_file.gsub(original_string, objective_string)
File.open("#{DEST_JAVASCRIPT_PATH}/core-b3.js.erb", "w") { |file| file.puts replaced }
end
desc "Update assets"
task 'update' do
if Dir.exist?('bootstrap-wysihtml5')
system("cd bootstrap-wysihtml5 && git pull && cd ..")
else
system("git clone git://github.com/jhollingworth/bootstrap-wysihtml5.git bootstrap-wysihtml5")
# system("cd bootstrap-wysihtml5 && git remote add b3 [email protected]:artillery/bootstrap-wysihtml5.git")
# system("cd bootstrap-wysihtml5 && git fetch b3")
# system("cd bootstrap-wysihtml5 && git checkout -b tb3 b3/master")
end
Dir.foreach("bootstrap-wysihtml5/src/locales") do |file|
unless file == '.' || file == '..'
abbreviated_file_name = file.gsub('bootstrap-wysihtml5.', '')
system("cp #{ORIGIN_SRC_PATH}/locales/#{file} #{DEST_JAVASCRIPT_PATH}/locales/#{abbreviated_file_name}")
end
end
system("cp #{ORIGIN_LIB_PATH}/js/wysihtml5-0.3.0.js #{DEST_JAVASCRIPT_PATH}/wysihtml5.js")
system("cp #{ORIGIN_LIB_PATH}/css/wysiwyg-color.css #{DEST_CSS_PATH}/wysiwyg-color.css")
b2
# b3
# ["#{DEST_JAVASCRIPT_PATH}/core.js.erb", "#{DEST_JAVASCRIPT_PATH}/core-b3.js.erb"].each do |file|
["#{DEST_JAVASCRIPT_PATH}/core.js.erb"].each do |file|
initial = File.read(file)
initial = "//= depend_on_asset \"bootstrap-wysihtml5/wysiwyg-color.css\"\n\n" + initial
File.write(file, initial)
end
system("git status")
end
desc "Build"
task "build" do
system("gem build bootstrap-wysihtml5-rails.gemspec")
end
desc "Publish a new version"
task :publish => :build do
tags = `git tag`.split
version = BootstrapWysihtml5Rails::Rails::VERSION
system("git tag -a #{version} -m 'Release #{version}' ") unless tags.include?(version)
system("gem push bootstrap-wysihtml5-rails-#{version}.gem")
system("git push --follow-tags")
end