Class: Girdle::Specification
- Inherits:
-
Object
- Object
- Girdle::Specification
- Defined in:
- lib/girdle/specification.rb
Instance Attribute Summary collapse
-
#depends_on ⇒ Object
Returns the value of attribute depends_on.
-
#name ⇒ Object
Returns the value of attribute name.
-
#notification_email ⇒ Object
Returns the value of attribute notification_email.
-
#tasks ⇒ Object
Returns the value of attribute tasks.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Specification
constructor
A new instance of Specification.
- #to_plist ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Specification
Returns a new instance of Specification.
7 8 9 10 11 12 13 |
# File 'lib/girdle/specification.rb', line 7 def initialize( = {}) @name = [:name] @notification_email = [:notification_email] @tasks = [:tasks] || [] @depends_on = ([:depends_on] || []). map {|d| d.respond_to?(:name) ? d.name : d} end |
Instance Attribute Details
#depends_on ⇒ Object
Returns the value of attribute depends_on.
5 6 7 |
# File 'lib/girdle/specification.rb', line 5 def depends_on @depends_on end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/girdle/specification.rb', line 5 def name @name end |
#notification_email ⇒ Object
Returns the value of attribute notification_email.
5 6 7 |
# File 'lib/girdle/specification.rb', line 5 def notification_email @notification_email end |
#tasks ⇒ Object
Returns the value of attribute tasks.
5 6 7 |
# File 'lib/girdle/specification.rb', line 5 def tasks @tasks end |
Instance Method Details
#to_plist ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/girdle/specification.rb', line 15 def to_plist Nokogiri::XML::Builder.new do |xml| xml.doc.create_internal_subset( 'plist', '-//Apple Computer//DTD PLIST 1.0//EN', 'http://www.apple.com/DTDs/PropertyList-1.0.dtd' ) xml.plist(:version => '1.0') do xml.array do xml.dict do xml.key 'name' xml.string name xml.key 'notificationEmail' xml.string notification_email xml.key 'schedulerParameters' xml.dict do xml.key 'dependsOnJobs' xml.array do depends_on.each do |dependency| xml.string dependency end end end xml.key 'taskSpecifications' xml.dict do tasks.each do |task| xml.key task.name xml.dict do xml.key 'arguments' xml.array do task.arguments.each do |argument| xml.string argument end end xml.key 'command' xml.string task.command xml.key 'environment' xml.dict do task.environment.each do |k,v| xml.key k xml.string v end end xml.key 'dependsOnTasks' xml.array do task.depends_on.each do |dependency| xml.string dependency end end end end end end end end end.to_xml end |