module DtcRake

Constants

VERSION

Public Class Methods

check_bundler!() click to toggle source

Checks Bundler version. Bundler 1.16 is not supported by Warbler 1.4. But since uuCloudg01C3, uuCloudg01OperationRegistry and uuLogStoreg01 are implemented according tu uuApps 2.1 standard, they need to depend on Warbler 1.4. Therefore Bundler version needs to be lower than 1.16.

@see ues:UU-BT:UU.CLOUD/20171106_0001 @see plus4u.net/ues/sesm?SessFree=ues%3A%5B78462435%5D%3A%5B44191589544372490%5D%3A%3F

# File lib/dtc_rake/util.rb, line 40
def check_bundler!
  string = `bundler -v`
  if string =~ /\d+\.\d+.\d+/
    version = string.match(/\d+\.\d+.\d+/).to_s
    version_parts = version.split('.')
    if version_parts[1].to_i > 15
      error("Unable to build war files with bundler #{version}.\nBundler version must be lower than 1.16.x.")
    end
  else
    warning(
      "Unknown version of bundler.\n" \
      "Your bundler is not working correctly or dtc_rake isn't able to check version on your platform.\n" \
      "`bundler -v` returned: #{string}"
    )
  end
end
check_jruby!() click to toggle source

Checks if JRuby is being used. This check is important when building .war files - gems with native extensions (like json, bson) must be added to the output .war file for Java platform. Otherwise certain gems (e.g. uu_os_persistence) cannot be loaded when deployed on servlet container (Tomcat).

# File lib/dtc_rake/util.rb, line 28
def check_jruby!
  error(".war files must be built using JRuby!") unless RUBY_PLATFORM == "java"
end
configure() { |config| ... } click to toggle source
# File lib/dtc_rake/config.rb, line 5
def configure(&block)
  config = Config.instance
  yield config
  config.validate!
end
mv_to_output_dir(src_dir, src_file) click to toggle source
# File lib/dtc_rake/util.rb, line 12
def mv_to_output_dir(src_dir, src_file)
  output_dir = DtcRake::Config.instance.output_dir
  output_dir_name = File.basename(output_dir) # get just the last path element (e.g. "target")
  FileUtils.mkpath output_dir
  src_file_path = File.join(src_dir, output_dir_name, src_file)
  dest_file = File.join(output_dir, src_file)
  FileUtils.mv src_file_path, dest_file
  success "#{dest_file} created"
end
upload_pack(attrs) click to toggle source
# File lib/dtc_rake/util.rb, line 58
def upload_pack(attrs)
  file = attrs[:file]
  artifact_uri = attrs[:appbox_uri] || DtcRake::Product.instance.appbox_uri
  attachment_code = attrs[:attachment_code]
  credentials = attrs[:credentials]

  abort "Specify login credentials" unless credentials
  UU::OS::Security::Session.login(credentials)

  attch_uri = UU::OS::UESURIBuilder.parse_uesuri(artifact_uri).set_object_code(attachment_code).to_uesuri

  if UU::OS::Search.exists(attch_uri)
    File.open(file, "rb") do |f|
      UU::OS::Attachment.check_in(attch_uri, data: UU::OS::REST::BinaryValue.new(f))
    end
  else
    File.open(file, "rb") do |f|
      attch_uri = UU::OS::Attachment.create(artifact_uri, code: attachment_code,
          data: UU::OS::REST::BinaryValue.new(f)
      )
    end
  end

  attch_uri
end

Private Instance Methods

check_bundler!() click to toggle source

Checks Bundler version. Bundler 1.16 is not supported by Warbler 1.4. But since uuCloudg01C3, uuCloudg01OperationRegistry and uuLogStoreg01 are implemented according tu uuApps 2.1 standard, they need to depend on Warbler 1.4. Therefore Bundler version needs to be lower than 1.16.

@see ues:UU-BT:UU.CLOUD/20171106_0001 @see plus4u.net/ues/sesm?SessFree=ues%3A%5B78462435%5D%3A%5B44191589544372490%5D%3A%3F

# File lib/dtc_rake/util.rb, line 40
def check_bundler!
  string = `bundler -v`
  if string =~ /\d+\.\d+.\d+/
    version = string.match(/\d+\.\d+.\d+/).to_s
    version_parts = version.split('.')
    if version_parts[1].to_i > 15
      error("Unable to build war files with bundler #{version}.\nBundler version must be lower than 1.16.x.")
    end
  else
    warning(
      "Unknown version of bundler.\n" \
      "Your bundler is not working correctly or dtc_rake isn't able to check version on your platform.\n" \
      "`bundler -v` returned: #{string}"
    )
  end
end
check_jruby!() click to toggle source

Checks if JRuby is being used. This check is important when building .war files - gems with native extensions (like json, bson) must be added to the output .war file for Java platform. Otherwise certain gems (e.g. uu_os_persistence) cannot be loaded when deployed on servlet container (Tomcat).

# File lib/dtc_rake/util.rb, line 28
def check_jruby!
  error(".war files must be built using JRuby!") unless RUBY_PLATFORM == "java"
end
configure() { |config| ... } click to toggle source
# File lib/dtc_rake/config.rb, line 5
def configure(&block)
  config = Config.instance
  yield config
  config.validate!
end
mv_to_output_dir(src_dir, src_file) click to toggle source
# File lib/dtc_rake/util.rb, line 12
def mv_to_output_dir(src_dir, src_file)
  output_dir = DtcRake::Config.instance.output_dir
  output_dir_name = File.basename(output_dir) # get just the last path element (e.g. "target")
  FileUtils.mkpath output_dir
  src_file_path = File.join(src_dir, output_dir_name, src_file)
  dest_file = File.join(output_dir, src_file)
  FileUtils.mv src_file_path, dest_file
  success "#{dest_file} created"
end
upload_pack(attrs) click to toggle source
# File lib/dtc_rake/util.rb, line 58
def upload_pack(attrs)
  file = attrs[:file]
  artifact_uri = attrs[:appbox_uri] || DtcRake::Product.instance.appbox_uri
  attachment_code = attrs[:attachment_code]
  credentials = attrs[:credentials]

  abort "Specify login credentials" unless credentials
  UU::OS::Security::Session.login(credentials)

  attch_uri = UU::OS::UESURIBuilder.parse_uesuri(artifact_uri).set_object_code(attachment_code).to_uesuri

  if UU::OS::Search.exists(attch_uri)
    File.open(file, "rb") do |f|
      UU::OS::Attachment.check_in(attch_uri, data: UU::OS::REST::BinaryValue.new(f))
    end
  else
    File.open(file, "rb") do |f|
      attch_uri = UU::OS::Attachment.create(artifact_uri, code: attachment_code,
          data: UU::OS::REST::BinaryValue.new(f)
      )
    end
  end

  attch_uri
end