require 'bundler/gem_tasks' require 'rake/clean' begin require 'rspec/core/rake_task' RSpec::Core::RakeTask.new(:spec) do |spec| spec_out = ENV['SPEC_OUT'] || '../spec-output/helix_web_services_specs.html' spec.rspec_opts = "--format html --out #{File.absolute_path(spec_out, __FILE__)}" end rescue LoadError end begin require 'yard' YARD::Rake::YardocTask.new do |t| t.files = ['lib/**/*'] t.options = ['-o', File.absolute_path('../doc-output', __FILE__), '-m', 'markdown'] end rescue LoadError end desc 'Create lib/helix_web_services/build_version.rb' task :build_version do is_production = ENV['PRODUCTION'] == 'true' product = 'HWS' arch = 'NOARCH' branch = ENV['BRANCH'] || 'DEV' year_rev_base = '2015.1' year_rev = is_production ? year_rev_base : "#{year_rev_base}.#{branch}" changelist = ENV['P4_CHANGELIST'] # Currently, the Jenkins 'p4' plugin doesn't expose the changelist to the # environment. So use the UTC timestamp. We'll use daily builds for the time # being. if changelist.nil? changelist = Time.now.utc.strftime('%Y%m%d%H%M') end #ruby_version = is_production ? "#{year_rev_base}.#{changelist}" : "#{year_rev_base}.0.#{branch}#{changelist}" product_id = "#{product}/#{arch}/#{year_rev}/#{changelist}" IO.write('lib/helix_web_services/build_version.rb', <<-END.gsub(/^[ ]{4}/, '') module HelixWebServices PRODUCT_ID = '#{product_id}' end END ) end