Class: Autoterm::OSAScript
- Inherits:
-
Object
- Object
- Autoterm::OSAScript
- Defined in:
- lib/autoterm/osascript.rb
Defined Under Namespace
Classes: RenderContext
Constant Summary collapse
- TEMPLATE_PATH =
File.( "../assets/applescript.erb", __FILE__ ).freeze
Instance Attribute Summary collapse
-
#project ⇒ Object
readonly
Returns the value of attribute project.
Instance Method Summary collapse
-
#initialize(project) ⇒ OSAScript
constructor
A new instance of OSAScript.
- #render ⇒ Object
- #run ⇒ Object
Constructor Details
#initialize(project) ⇒ OSAScript
Returns a new instance of OSAScript.
13 14 15 |
# File 'lib/autoterm/osascript.rb', line 13 def initialize(project) @project = project end |
Instance Attribute Details
#project ⇒ Object (readonly)
Returns the value of attribute project.
7 8 9 |
# File 'lib/autoterm/osascript.rb', line 7 def project @project end |
Instance Method Details
#render ⇒ Object
17 18 19 |
# File 'lib/autoterm/osascript.rb', line 17 def render ERB.new(template, nil, "-").result(RenderContext.for(project)) end |
#run ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/autoterm/osascript.rb', line 21 def run _stdout, stderr, status = Open3.capture3( "osascript -", stdin_data: render ) raise ExecutionError.new(stderr) unless status.success? end |