Module
The DSL class is the heart of Syckle, it provides all the convenece methods that make Syckle services so convenient to write.
TODO: Better name?
# File lib/syckle/script.rb, line 30 def initialize(options={}) extend self @project = POM::Project.new(:lookup=>true) #, :load=>true) options.each do |k, v| send("#{k}=", v) if respond_to?("#{k}=") end @cli ||= CLI.new @io ||= IO.new(@cli) path = @project.root || Dir.pwd # TODO: error or pwd ? mode = { :noop => @cli.trial?, :verbose => @cli.trace? || (@cli.trial? && !@cli.quiet?), :quiet => @cli.quiet? } @shell = Shell.new(path, mode) end
# File lib/syckle/script.rb, line 146 def apply_naming_policy(name, ext) naming_policy.each do |policy| case policy.to_s when /^low/, /^down/ name = name.downcase when /^up/ name = name.upcase when /^cap/ name = name.capitalize when /^ext/ name = name + ".#{ext}" end end name end
Load configuration data from a file. Results are cached and and empty Hash is returned if the file is not found.
Since they are YAML files, they can optionally end with ‘.yaml’ or ‘.yml’.
# File lib/syckle/script.rb, line 103 def configuration(file) @configuration ||= {} @configuration[file] ||= ( begin configuration!(file) rescue LoadError Hash.new{ |h,k| h[k] = {} } end ) end
Load configuration data from a file. The “bang” version will raise an error if file is not found. It also does not cache the results.
Since they are YAML files, they can optionally end with ‘.yaml’ or ‘.yml’.
# File lib/syckle/script.rb, line 121 def configuration!(file) @configuration ||= {} patt = file + "{.yml,.yaml,}" path = Dir.glob(patt, File::FNM_CASEFOLD).find{ |f| File.file?(f) } if path # The || {} is in case the file is empty. data = YAML::load(File.open(path)) || {} @configuration[file] = data else raise LoadError, "Missing file -- #{path}" end end
Current platform.
# File lib/syckle/script.rb, line 80 def current_platform Platform.local.to_s end
Email function to easily send out an email.
Settings:
subject Subject of email message. from Message FROM address [email]. to Email address to send announcemnt. server Email server to route message. port Email server's port. domain Email server's domain name. account Email account name if needed. password Password for login.. login Login type: plain, cram_md5 or login [plain]. secure Uses TLS security, true or false? [false] message Mesage to send -or- file File that contains message.
# File lib/syckle/script.rb, line 179 def email(options) emailer = Emailer.new(options.rekey) success = emailer.email if Exception === success puts "Email failed: #{success.message}." else puts "Email sent successfully to #{success.join(';')}." end end
POM::Metadata object, derived from Project.
# File lib/syckle/script.rb, line 75 def metadata project.metadata end
Delegate to Shell.
# File lib/syckle/script.rb, line 85 def method_missing(s, *a, &b) if @shell.respond_to?(s) @shell.__send__(s, *a, &b) else if @io.respond_to?(s) @io.__send__(s, *a, &b) else super end end end
Generated with the Darkfish Rdoc Generator 2.