@@ -64,6 +64,16 @@ task :default => [:compile, :test]
64
64
desc 'Init the build workspace'
65
65
task :init do
66
66
FileUtils . mkdir ( BUILD_DIR ) unless File . directory? ( BUILD_DIR )
67
+
68
+ v = YAML ::load ( File . open ( 'version.yaml' ) )
69
+ match = v [ 'version' ] . match ( /^([^-]*)(-snapshot)?$/ )
70
+
71
+ NG_VERSION = Struct . new ( :full , :major , :minor , :dot , :codename ) .
72
+ new ( match [ 1 ] + ( match [ 2 ] ? ( '-' + %x(git rev-parse HEAD) [ 0 ..7 ] ) : '' ) ,
73
+ match [ 1 ] . split ( '.' ) [ 0 ] ,
74
+ match [ 1 ] . split ( '.' ) [ 1 ] ,
75
+ match [ 1 ] . split ( '.' ) [ 2 ] ,
76
+ v [ 'codename' ] )
67
77
end
68
78
69
79
@@ -188,9 +198,17 @@ task :compile => [:init, :compile_scenario, :compile_jstd_scenario_adapter, :gen
188
198
189
199
File . open ( path_to ( 'angular.js' ) , 'w' ) do |f |
190
200
concat = 'cat ' + deps . flatten . join ( ' ' )
191
- f . write ( %x{#{ concat } } .
201
+
202
+ content = %x{#{ concat } } .
203
+ gsub ( '"NG_VERSION_FULL"' , NG_VERSION . full ) .
204
+ gsub ( '"NG_VERSION_MAJOR"' , NG_VERSION . major ) .
205
+ gsub ( '"NG_VERSION_MINOR"' , NG_VERSION . minor ) .
206
+ gsub ( '"NG_VERSION_DOT"' , NG_VERSION . dot ) .
207
+ gsub ( '"NG_VERSION_CODENAME"' , NG_VERSION . codename ) .
192
208
gsub ( /^\s *['"]use strict['"];?\s *$/ , '' ) . # remove all file-specific strict mode flags
193
- gsub ( /'USE STRICT'/ , "'use strict'" ) ) # rename the placeholder in angular.prefix
209
+ gsub ( /'USE STRICT'/ , "'use strict'" ) # rename the placeholder in angular.prefix
210
+
211
+ f . write ( content )
194
212
f . write ( gen_css ( 'css/angular.css' , true ) )
195
213
end
196
214
210
228
211
229
desc 'Create angular distribution'
212
230
task :package => [ :clean , :compile , :docs ] do
213
- v = YAML ::load ( File . open ( 'version.yaml' ) ) [ 'version' ]
214
- match = v . match ( /^([^-]*)(-snapshot)?$/ )
215
- version = match [ 1 ] + ( match [ 2 ] ? ( '-' + %x(git rev-parse HEAD) [ 0 ..7 ] ) : '' )
216
-
217
- tarball = "angular-#{ version } .tgz"
231
+ tarball = "angular-#{ NG_VERSION . full } .tgz"
218
232
219
- pkg_dir = path_to ( "pkg/angular-#{ version } " )
233
+ pkg_dir = path_to ( "pkg/angular-#{ NG_VERSION . full } " )
220
234
FileUtils . rm_r ( path_to ( 'pkg' ) , :force => true )
221
235
FileUtils . mkdir_p ( pkg_dir )
222
236
@@ -228,35 +242,36 @@ task :package => [:clean, :compile, :docs] do
228
242
path_to ( 'jstd-scenario-adapter.js' ) ,
229
243
path_to ( 'jstd-scenario-adapter-config.js' ) ,
230
244
] . each do |src |
231
- dest = src . gsub ( /^[^\/ ]+\/ / , '' ) . gsub ( /((\. min)?\. js)$/ , "-#{ version } \\ 1" )
245
+ dest = src . gsub ( /^[^\/ ]+\/ / , '' ) . gsub ( /((\. min)?\. js)$/ , "-#{ NG_VERSION . full } \\ 1" )
232
246
FileUtils . cp ( src , pkg_dir + '/' + dest )
233
247
end
234
248
235
- FileUtils . cp_r path_to ( 'docs' ) , "#{ pkg_dir } /docs-#{ version } "
249
+ FileUtils . cp_r path_to ( 'docs' ) , "#{ pkg_dir } /docs-#{ NG_VERSION . full } "
236
250
237
- File . open ( "#{ pkg_dir } /docs-#{ version } /index.html" , File ::RDWR ) do |f |
251
+ File . open ( "#{ pkg_dir } /docs-#{ NG_VERSION . full } /index.html" , File ::RDWR ) do |f |
238
252
text = f . read
239
253
f . rewind
240
- f . write text . sub ( 'angular.min.js' , "angular-#{ version } .min.js" )
254
+ f . write text . sub ( 'angular.min.js' , "angular-#{ NG_VERSION . full } .min.js" )
241
255
end
242
256
243
- File . open ( "#{ pkg_dir } /docs-#{ version } /docs-scenario.html" , File ::RDWR ) do |f |
257
+ File . open ( "#{ pkg_dir } /docs-#{ NG_VERSION . full } /docs-scenario.html" , File ::RDWR ) do |f |
244
258
text = f . read
245
259
f . rewind
246
- f . write text . sub ( 'angular-scenario.js' , "angular-scenario-#{ version } .js" )
260
+ f . write text . sub ( 'angular-scenario.js' , "angular-scenario-#{ NG_VERSION . full } .js" )
247
261
end
248
262
249
- File . open ( "#{ pkg_dir } /docs-#{ version } /appcache.manifest" , File ::RDWR ) do |f |
263
+ File . open ( "#{ pkg_dir } /docs-#{ NG_VERSION . full } /appcache.manifest" , File ::RDWR ) do |f |
264
+
250
265
text = f . read
251
266
f . rewind
252
- f . write text . sub ( 'angular.min.js' , "angular-#{ version } .min.js" )
267
+ f . write text . sub ( 'angular.min.js' , "angular-#{ NG_VERSION . full } .min.js" )
253
268
end
254
269
255
270
256
271
%x(tar -czf #{ path_to ( tarball ) } -C #{ path_to ( 'pkg' ) } .)
257
272
258
273
FileUtils . cp path_to ( tarball ) , pkg_dir
259
- FileUtils . mv pkg_dir , path_to ( [ 'pkg' , version ] )
274
+ FileUtils . mv pkg_dir , path_to ( [ 'pkg' , NG_VERSION . full ] )
260
275
261
276
puts "Package created: #{ path_to ( tarball ) } "
262
277
end
0 commit comments