Write out version.rb on dist build

This commit is contained in:
ragaskar
2011-06-23 07:55:04 -04:00
parent 634a7dc402
commit b722f416c7
7 changed files with 22 additions and 15 deletions

View File

@@ -1,4 +1,3 @@
source :rubygems source :rubygems
gem "term-ansicolor", :require => "term/ansicolor" gem "term-ansicolor", :require => "term/ansicolor"
gem "json_pure", ">= 1.4.3"
gemspec gemspec

View File

@@ -2472,6 +2472,6 @@ jasmine.version_= {
"major": 1, "major": 1,
"minor": 1, "minor": 1,
"build": 0, "build": 0,
"revision": 1308618948, "revision": 1308830021,
"release_candidate": 1 "release_candidate": 1
}; };

View File

@@ -1,8 +1,6 @@
module Jasmine module Jasmine
module Core module Core
require 'json' VERSION = "1.1.0.rc1"
VERSION_HASH = JSON.parse(File.new(File.join(File.dirname(__FILE__), "..", "..", "src", "version.json")).read)
VERSION = "#{VERSION_HASH['major']}.#{VERSION_HASH['minor']}.#{VERSION_HASH['build']}"
VERSION << ".rc#{VERSION_HASH['release_candidate']}" if VERSION_HASH['release_candidate']
end end
end end

View File

@@ -0,0 +1,6 @@
module Jasmine
module Core
VERSION = "<%= "#{major}.#{minor}.#{build}" %><%= ".rc#{release_candidate}" if release_candidate %>"
end
end

View File

@@ -2,6 +2,6 @@ jasmine.version_= {
"major": 1, "major": 1,
"minor": 1, "minor": 1,
"build": 0, "build": 0,
"revision": 1308618948, "revision": 1308830021,
"release_candidate": 1 "release_candidate": 1
}; };

View File

@@ -1,11 +1,11 @@
desc "Build core jasmine.js" desc "Build core jasmine.js"
task :build_dist => [:lint, :write_version_file] do task :build_dist => [:lint, :write_version_files] do
puts 'Building Jasmine distribution from source'.cyan puts 'Building Jasmine distribution from source'.cyan
concat_into('lib/jasmine-core/jasmine.js') { core_sources + version_source_file } concat_into('./lib/jasmine-core/jasmine.js') { core_sources + version_source_file }
concat_into('lib/jasmine-core/jasmine-html.js') { html_sources } concat_into('./lib/jasmine-core/jasmine-html.js') { html_sources }
FileUtils.cp('src/html/jasmine.css', 'lib/jasmine-core/jasmine.css') FileUtils.cp('./src/html/jasmine.css', './lib/jasmine-core/jasmine.css')
end end
def concat_into(output_file, &block) def concat_into(output_file, &block)
@@ -25,18 +25,22 @@ end
task :hint => :lint task :hint => :lint
task :write_version_file do task :write_version_files do
template = Tilt.new('src/templates/version.erb')
scope = OpenStruct.new(:major => version_hash["major"], scope = OpenStruct.new(:major => version_hash["major"],
:minor => version_hash["minor"], :minor => version_hash["minor"],
:build => version_hash["build"], :build => version_hash["build"],
:release_candidate => version_hash["release_candidate"], :release_candidate => version_hash["release_candidate"],
:revision => Time.now.to_i) :revision => Time.now.to_i)
File.open('src/version.js', 'w+') do |f| js_template = Tilt.new('./src/templates/version.js.erb')
f << template.render(scope) File.open('./src/version.js', 'w+') do |f|
f << js_template.render(scope)
end end
rb_template = Tilt.new('./src/templates/version.rb.erb')
File.open('./lib/jasmine-core/version.rb', 'w+') do |f|
f << rb_template.render(scope)
end
end end
def version_source_file def version_source_file