Class: Ironment::CL
- Inherits:
-
Object
- Object
- Ironment::CL
- Defined in:
- lib/ironment/cl.rb,
lib/ironment/cl/prompter.rb
Defined Under Namespace
Classes: Prompter
Instance Method Summary collapse
- #exec_with_environment(command, *args) ⇒ Object
-
#initialize(options = {}) ⇒ CL
constructor
A new instance of CL.
- #trust(file) ⇒ Object
- #untrust(file) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ CL
Returns a new instance of CL.
3 4 5 6 7 8 |
# File 'lib/ironment/cl.rb', line 3 def initialize( = {}) @ironment = [:ironment] || Ironment.new @prompter = [:prompter] || Prompter.new @truster = [:truster] || Truster.new @stderr = [:stderr] || $stderr end |
Instance Method Details
#exec_with_environment(command, *args) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/ironment/cl.rb', line 10 def exec_with_environment(command, *args) @ironment.exec_with_environment command, *args rescue Truster::NotTrusted => e if @prompter.not_trusted e.runcom exec_with_environment command, *args end rescue Truster::Modified => e if @prompter.modified e.runcom exec_with_environment command, *args end end |
#trust(file) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/ironment/cl.rb', line 22 def trust(file) @truster.trust Runcom.new(file) true rescue Errno::EACCES @stderr.puts "ironment: Permission denied" false rescue Errno::ENOENT @stderr.puts "ironment: No such file or directory" false rescue Errno::EISDIR @stderr.puts "ironment: Is a directory" false end |
#untrust(file) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/ironment/cl.rb', line 40 def untrust(file) @truster.untrust Runcom.new(file) true rescue Errno::EACCES @stderr.puts "ironment: Permission denied" false rescue Errno::ENOENT @stderr.puts "ironment: No such file or directory" false rescue Errno::EISDIR @stderr.puts "ironment: Is a directory" false end |