Class: EmacsOrgProtocolServer::EmacsClientRunner
- Inherits:
-
Object
- Object
- EmacsOrgProtocolServer::EmacsClientRunner
- Defined in:
- lib/emacs_org_protocol_server/emacs_client_runner.rb
Defined Under Namespace
Classes: NoParameters
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#client ⇒ Object
Returns the value of attribute client.
-
#location ⇒ Object
Returns the value of attribute location.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#title ⇒ Object
Returns the value of attribute title.
Instance Method Summary collapse
-
#initialize(params = {}, client = nil, logger = Logger.new(STDERR)) ⇒ EmacsClientRunner
constructor
A new instance of EmacsClientRunner.
- #run! ⇒ Object
Constructor Details
#initialize(params = {}, client = nil, logger = Logger.new(STDERR)) ⇒ EmacsClientRunner
Returns a new instance of EmacsClientRunner.
12 13 14 15 16 17 18 19 |
# File 'lib/emacs_org_protocol_server/emacs_client_runner.rb', line 12 def initialize(params={}, client=nil, logger=Logger.new(STDERR)) raise NoParameters if params.empty? self.logger = logger self.client = client self.location = params['l'].to_s self.title = params['t'].to_s self.body = params['b'].to_s end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
10 11 12 |
# File 'lib/emacs_org_protocol_server/emacs_client_runner.rb', line 10 def body @body end |
#client ⇒ Object
Returns the value of attribute client.
10 11 12 |
# File 'lib/emacs_org_protocol_server/emacs_client_runner.rb', line 10 def client @client end |
#location ⇒ Object
Returns the value of attribute location.
10 11 12 |
# File 'lib/emacs_org_protocol_server/emacs_client_runner.rb', line 10 def location @location end |
#logger ⇒ Object
Returns the value of attribute logger.
10 11 12 |
# File 'lib/emacs_org_protocol_server/emacs_client_runner.rb', line 10 def logger @logger end |
#title ⇒ Object
Returns the value of attribute title.
10 11 12 |
# File 'lib/emacs_org_protocol_server/emacs_client_runner.rb', line 10 def title @title end |
Instance Method Details
#run! ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/emacs_org_protocol_server/emacs_client_runner.rb', line 21 def run! emacs_target = URI('org-protocol://capture') query_data = { template: 'w', url: location, title: title, body: body } query_string = URI.encode_www_form(query_data).gsub('+','%20') emacs_target.query = query_string cmd = "#{client} -n '#{emacs_target}'" logger.info "emacsclient command: #{cmd}" system(cmd) return ($? == 0) end |