-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
190 lines (160 loc) · 8.83 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
require "bundler/gem_tasks"
task :default => :spec
# path to your application root.
GEM_ROOT = Pathname.new File.expand_path('../', __FILE__)
ASSETS_PATH = Pathname.new File.expand_path('vendor/assets/', GEM_ROOT)
desc "Update all assets"
task :update => %w(update:underscore update:backbone update:marionette)
namespace :update do
desc "Update underscore assets"
task :underscore do
version = Yano::Backbone::Rails::UNDERSCORE_VERSION
Dir.chdir ASSETS_PATH do
puts "Cleaning temp folder"
["rm -rf ", "mkdir -p "].each do |cmd|
puts "#{cmd} ./javascripts/underscore"
puts `#{cmd} ./javascripts/underscore`
end
puts "Downloading underscore.js"
puts "curl -o ./javascripts/underscore/underscore.js https://raw.githubusercontent.com/jashkenas/underscore/#{version}/underscore.js"
puts `curl -o ./javascripts/underscore/underscore.js https://raw.githubusercontent.com/jashkenas/underscore/#{version}/underscore.js`
puts "Downloading underscore.min.js"
puts "curl -o ./javascripts/underscore/underscore.min.js https://raw.githubusercontent.com/jashkenas/underscore/#{version}/underscore-min.js"
puts `curl -o ./javascripts/underscore/underscore.min.js https://raw.githubusercontent.com/jashkenas/underscore/#{version}/underscore-min.js`
File.open('./javascripts/underscore/underscore.min.js', 'r') do |file|
File.open("./javascripts/underscore/underscore.min.js.erb", 'w') do |new_file|
while (line = file.gets)
if line =~ /sourceMappingURL/
line = line.gsub("underscore-min.map", "<%= asset_path 'underscore.min.map' %>")
end
new_file.puts line
end
end
end
puts "rm -f ./javascripts/underscore/underscore.min.js"
puts `rm -f ./javascripts/underscore/underscore.min.js`
puts "Downloading underscore.min.map"
puts "mkdir -p ./source_maps"
puts `mkdir -p ./source_maps`
puts "curl -o ./source_maps/underscore.min.map https://raw.githubusercontent.com/jashkenas/underscore/#{version}/underscore-min.map"
puts `curl -o ./source_maps/underscore.min.map https://raw.githubusercontent.com/jashkenas/underscore/#{version}/underscore-min.map`
end
puts "\e[32mDone!\e[0m"
end
desc "Update backbone assets"
task :backbone do
version = Yano::Backbone::Rails::BACKBONE_VERSION
Dir.chdir ASSETS_PATH do
puts "Cleaning temp folder"
["rm -rf ", "mkdir -p "].each do |cmd|
puts "#{cmd} ./javascripts/backbone"
puts `#{cmd} ./javascripts/backbone`
end
puts "Downloading backbone.js"
puts "curl -o ./javascripts/backbone/backbone.js https://raw.githubusercontent.com/jashkenas/backbone/#{version}/backbone.js"
puts `curl -o ./javascripts/backbone/backbone.js https://raw.githubusercontent.com/jashkenas/backbone/#{version}/backbone.js`
puts "Downloading backbone.min.js"
puts "curl -o ./javascripts/backbone/backbone.min.js https://raw.githubusercontent.com/jashkenas/backbone/#{version}/backbone-min.js"
puts `curl -o ./javascripts/backbone/backbone.min.js https://raw.githubusercontent.com/jashkenas/backbone/#{version}/backbone-min.js`
File.open('./javascripts/backbone/backbone.min.js', 'r') do |file|
File.open("./javascripts/backbone/backbone.min.js.erb", 'w') do |new_file|
while (line = file.gets)
if line =~ /sourceMappingURL/
line = line.gsub("backbone-min.map", "<%= asset_path 'backbone.min.map' %>")
end
new_file.puts line
end
end
end
puts "rm -f ./javascripts/backbone/backbone.min.js"
puts `rm -f ./javascripts/backbone/backbone.min.js`
puts "Downloading backbone.min.map"
puts "mkdir -p ./source_maps"
puts `mkdir -p ./source_maps`
puts "curl -o ./source_maps/backbone.min.map https://raw.githubusercontent.com/jashkenas/backbone/#{version}/backbone-min.map"
puts `curl -o ./source_maps/backbone.min.map https://raw.githubusercontent.com/jashkenas/backbone/#{version}/backbone-min.map`
end
puts "\e[32mDone!\e[0m"
end
desc "Update Backbone marionette assets and dependencies"
task :marionette => %w(marionette:clear marionette:radio marionette:adapters) do
Dir.chdir ASSETS_PATH do
version = Yano::Backbone::Rails::MARIONETTE_VERSION
puts "Downloading marionette.js"
puts "curl -o ./javascripts/marionette/backbone.marionette.js https://raw.githubusercontent.com/marionettejs/backbone.marionette/v#{version}/lib/backbone.marionette.js"
puts `curl -o ./javascripts/marionette/backbone.marionette.js https://raw.githubusercontent.com/marionettejs/backbone.marionette/v#{version}/lib/backbone.marionette.js`
puts "Downloading marionette.min.js"
puts "curl -o ./javascripts/marionette/backbone.marionette.min.js https://raw.githubusercontent.com/marionettejs/backbone.marionette/v#{version}/lib/backbone.marionette.min.js"
puts `curl -o ./javascripts/marionette/backbone.marionette.min.js https://raw.githubusercontent.com/marionettejs/backbone.marionette/v#{version}/lib/backbone.marionette.min.js`
File.open('./javascripts/marionette/backbone.marionette.min.js', 'r') do |file|
File.open("./javascripts/marionette/backbone.marionette.min.js.erb", 'w') do |new_file|
while (line = file.gets)
if line =~ /sourceMappingURL/
line = line.gsub("backbone.marionette.min.js.map", "<%= asset_path 'backbone.marionette.min.js.map' %>")
end
new_file.puts line
end
end
end
puts "rm -f ./javascripts/marionette/backbone.marionette.min.js"
puts `rm -f ./javascripts/marionette/backbone.marionette.min.js`
puts "Downloading backbone.min.map"
puts "mkdir -p ./source_maps"
puts `mkdir -p ./source_maps`
puts "curl -o ./source_maps/backbone.marionette.min.js.map https://raw.githubusercontent.com/marionettejs/backbone.marionette/v#{version}/lib/backbone.marionette.min.js.map"
puts `curl -o ./source_maps/backbone.marionette.min.js.map https://raw.githubusercontent.com/marionettejs/backbone.marionette/v#{version}/lib/backbone.marionette.min.js.map`
end
puts "\e[32mDone!\e[0m"
end
namespace :marionette do
task :clear do
Dir.chdir ASSETS_PATH do
puts "Cleaning temp folder"
["rm -rf ", "mkdir -p "].each do |cmd|
puts "#{cmd} ./javascripts/marionette"
puts `#{cmd} ./javascripts/marionette`
end
puts "touch javascripts/marionette/.keep"
puts `touch javascripts/marionette/.keep`
puts "touch source_maps/.keep"
puts `touch source_maps/.keep`
end
end
task :radio do
Dir.chdir ASSETS_PATH do
version = Yano::Backbone::Rails::RADIO_VERSION
["", ".min"].each do |type|
filename = "backbone.radio#{type}.js"
puts "Downloading #{filename}"
puts "curl -o ./javascripts/marionette/#{filename} https://raw.githubusercontent.com/marionettejs/backbone.radio/v#{version}/build/#{filename}"
puts `curl -o ./javascripts/marionette/#{filename} https://raw.githubusercontent.com/marionettejs/backbone.radio/v#{version}/build/#{filename}`
File.open("./javascripts/marionette/#{filename}", 'r') do |file|
File.open("./javascripts/marionette/#{filename}.erb", 'w') do |new_file|
while (line = file.gets)
if line =~ /sourceMappingURL/
line = line.gsub("#{filename}.map", "<%= asset_path '#{filename}.map' %>")
line = line.gsub("./", "")
end
new_file.puts line
end
end
end
puts "rm -f ./javascripts/marionette/#{filename}"
puts `rm -f ./javascripts/marionette/#{filename}`
puts "Downloading #{filename}.map"
puts "mkdir -p ./source_maps"
puts `mkdir -p ./source_maps`
puts "curl -o ./source_maps/#{filename}.map https://raw.githubusercontent.com/marionettejs/backbone.radio/v#{version}/build/#{filename}.map"
puts `curl -o ./source_maps/#{filename}.map https://raw.githubusercontent.com/marionettejs/backbone.radio/v#{version}/build/#{filename}.map`
end
end
end
task :adapters do
Dir.chdir ASSETS_PATH do
puts "Downloading backbone.handlebars.adapter.js"
puts "curl -o ./javascripts/marionette/backbone.handlebars.adapter.js https://gist.githubusercontent.com/jonathanccalixto/a3223950577e9de3d3e00acc1f3ee5f2/raw/ea88cccbe3bcbb8c3a0bdb17a6683e4d58a353c4/backbone.handlebars.adapter.js"
puts `curl -o ./javascripts/marionette/backbone.handlebars.adapter.js https://gist.githubusercontent.com/jonathanccalixto/a3223950577e9de3d3e00acc1f3ee5f2/raw/ea88cccbe3bcbb8c3a0bdb17a6683e4d58a353c4/backbone.handlebars.adapter.js`
end
end
end
end