class DtcRake::Config
Attributes
Code of application. Guessed from root_dir
name if not set.
Code of appbox artifact. Guessed from product_code
and appbox_version
if not set.
Code of appbox location (folder or organization unit). Required.
Code of appbox meta artifact. Default value: UU.OS/RUNTIME/APP_BOX.
Code of territory where the appbox artifact is / should be. Required.
Path to uarchive with contents of appbox artifact. Default value: nil. If not set, appbox is created with empty content. Relative path is relative to root_dir.
Appbox version. Read from VERSION file located in the same directory as Rakefile if not set.
Print messages in colors. Default value: true.
Name of folder with build products. Default value: target. Relative path is relative to root_dir.
Code of product the appbox belongs to. Required.
Name of product the appbox belongs to. Required.
Appbox project root folder. Default value: current working directory.
Upload README.md or README.txt to appbox artifact. Default value: false.
Upload uuApp deployment descriptor to appbox artifact. Default value: false.
Path to uuApp deployment descriptor. Default value: uucloud_descriptor.json.
Code of vendor. Guessed from root_dir
name if not set.
List of files (or glob patterns) determining which files get updated by version:* tasks. Default: none.
Public Class Methods
# File lib/dtc_rake/config.rb, line 15 def initialize self.root_dir = Dir.pwd self.output_dir = "target" self.colorize = true self.upload_readme = false self.appbox_meta_artifact_code = "UU.OS/RUNTIME/APP_BOX" self.upload_uucloud_descriptor = false self.version_files = [] guess_vendor_and_app end
Public Instance Methods
# File lib/dtc_rake/config.rb, line 91 def app=(name) @app = name.downcase unless name.nil? end
# File lib/dtc_rake/config.rb, line 108 def appbox_artifact_code=(code) env = ENV["DTC_RAKE_APPBOX_ARTIFACT_CODE"] # environment variable takes precedence @appbox_artifact_code = env.nil? ? code : env @appbox_artifact_code end
# File lib/dtc_rake/config.rb, line 122 def appbox_location_code=(code) env = ENV["DTC_RAKE_APPBOX_LOCATION_CODE"] # environment variable takes precedence @appbox_location_code = env.nil? ? code : env @appbox_location_code end
# File lib/dtc_rake/config.rb, line 136 def appbox_meta_artifact_code=(code) env = ENV["DTC_RAKE_APPBOX_META_ARTIFACT_CODE"] # environment variable takes precedence @appbox_meta_artifact_code = env.nil? ? code : env @appbox_meta_artifact_code end
# File lib/dtc_rake/config.rb, line 150 def appbox_territory_code=(code) env = ENV["DTC_RAKE_APPBOX_TERRITORY_CODE"] # environment variable takes precedence @appbox_territory_code = env.nil? ? code : env @appbox_territory_code end
# File lib/dtc_rake/config.rb, line 164 def appbox_uarchive=(path) env = ENV["DTC_RAKE_APPBOX_UARCHIVE"] # environment variable takes precedence path = env unless env.nil? unless path.nil? # File.expand_path converts path to absolute and expands "~" to real user home path path = File.expand_path(path) if Pathname.new(path).relative? @appbox_uarchive = File.join(root_dir, path) else @appbox_uarchive = path end end end
# File lib/dtc_rake/config.rb, line 196 def appbox_version=(code) env = ENV["DTC_RAKE_APPBOX_VERSION"] # environment variable takes precedence @appbox_version = env.nil? ? code : env @appbox_version end
# File lib/dtc_rake/config.rb, line 213 def colorize=(flag) env = ENV["DTC_RAKE_COLORIZE"] # environment variable takes precedence if env.nil? @colorize = flag else @colorize = to_bool(env) end @colorize end
# File lib/dtc_rake/config.rb, line 231 def output_dir=(path) env = ENV["DTC_RAKE_OUTPUT_DIR"] # environment variable takes precedence path = env unless env.nil? unless path.nil? # File.expand_path converts path to absolute and expands "~" to real user home path path = File.expand_path(path) if Pathname.new(path).relative? @output_dir = File.join(root_dir, path) else @output_dir = path end end end
# File lib/dtc_rake/config.rb, line 255 def product_code=(code) env = ENV["DTC_RAKE_PRODUCT_CODE"] # environment variable takes precedence @product_code = env.nil? ? code : env @product_code end
# File lib/dtc_rake/config.rb, line 269 def product_name=(name) env = ENV["DTC_RAKE_PRODUCT_NAME"] # environment variable takes precedence @product_name = env.nil? ? name : env @product_name end
# File lib/dtc_rake/config.rb, line 285 def root_dir=(path) env = ENV["DTC_RAKE_ROOT_DIR"] # environment variable takes precedence path = env unless env.nil? unless path.nil? # File.expand_path converts path to absolute and expands "~" to real user home path # If the path is relative, it gets evaluated against to current working directory (Dir.pwd) @root_dir = File.expand_path(path) end end
# File lib/dtc_rake/config.rb, line 304 def upload_readme=(flag) env = ENV["DTC_RAKE_UPLOAD_README"] # environment variable takes precedence if env.nil? @upload_readme = flag else @upload_readme = to_bool(env) end @upload_readme end
# File lib/dtc_rake/config.rb, line 322 def upload_uucloud_descriptor=(flag) env = ENV["DTC_RAKE_UPLOAD_UUCLOUD_DESCRIPTOR"] # environment variable takes precedence if env.nil? @upload_uucloud_descriptor = flag else @upload_uucloud_descriptor = to_bool(env) end @upload_uucloud_descriptor end
# File lib/dtc_rake/config.rb, line 83 def validate! %w(appbox_location_code appbox_territory_code product_code product_name).each do |param| if instance_variable_get("@#{param}").nil? _error "Required parameter #{param} is not set. Set it within DtcRake.configure in your Rakefile." end end end
# File lib/dtc_rake/config.rb, line 357 def vendor=(name) @vendor = name.downcase unless name.nil? end
# File lib/dtc_rake/config.rb, line 361 def version_files=(list) if list.nil? @version_files = [] elsif list.is_a?(Array) @version_files = list else _error "Invalid version_files value - #{list} (#{list})." \ " Use an array of strings (representing file names or glob patterns)." end end
Private Instance Methods
# File lib/dtc_rake/config.rb, line 398 def _error(msg) # this avoids cycle between dtc_rake/config and dtc_rake/ui require "dtc_rake/ui" self.class.send(:include, DtcRake::UI) unless self.class.include?(DtcRake::UI) error(msg) end
# File lib/dtc_rake/config.rb, line 378 def guess_vendor_and_app env_vendor = ENV["DTC_RAKE_VENDOR"] env_app = ENV["DTC_RAKE_APP"] if env_vendor.nil? || env_app.nil? base_name = File.basename(root_dir) if /([^_]+)_([^-]+)-appbox/ =~ base_name @vendor = env_vendor.nil? ? $1 : env_vendor @app = env_app.nil? ? $2 : env_app else _error "Appbox root folder (#{base_name}) does not match naming convention <vendor>_<app>-appbox." \ " Either change the folder name or configure 'vendor' and 'app' within DtcRake.configure in Rakefile." \ " Or you can set DTC_RAKE_VENDOR and DTC_RAKE_APP environment variables to specify those." end else @vendor = env_vendor @app = env_app end end
# File lib/dtc_rake/config.rb, line 374 def to_bool(value) (value =~ /^true|1|yes$/i) == 0 end