Module: DTAS::EditClient
- Defined in:
- lib/dtas/edit_client.rb
Overview
common code between dtas-sourceedit and dtas-sinkedit
Instance Method Summary collapse
- #client_socket ⇒ Object
-
#editor ⇒ Object
:nodoc:.
- #tmpyaml ⇒ Object
- #update_cmd_env(cmd, orig, updated) ⇒ Object
Instance Method Details
#client_socket ⇒ Object
19 20 21 22 23 24 |
# File 'lib/dtas/edit_client.rb', line 19 def client_socket DTAS::UNIXClient.new rescue e = "DTAS_PLAYER_SOCK=#{DTAS::UNIXClient.default_path}" abort "dtas-player not running on #{e}" end |
#editor ⇒ Object
:nodoc:
10 11 12 13 14 15 16 17 |
# File 'lib/dtas/edit_client.rb', line 10 def editor %w(VISUAL EDITOR).each do |key| v = ENV[key] or next v.empty? and next return v end "vi" end |
#tmpyaml ⇒ Object
26 27 28 29 30 31 |
# File 'lib/dtas/edit_client.rb', line 26 def tmpyaml tmp = Tempfile.new(%W(#{File.basename($0)} .yml)) tmp.sync = true tmp.binmode tmp end |
#update_cmd_env(cmd, orig, updated) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/dtas/edit_client.rb', line 33 def update_cmd_env(cmd, orig, updated) if env = updated["env"] env.each do |k,v| cmd << (v.nil? ? "env##{k}" : "env.#{k}=#{v}") end end # remove deleted env if orig_env = orig["env"] env ||= {} deleted_keys = orig_env.keys - env.keys deleted_keys.each { |k| cmd << "env##{k}" } end end |