Class: DevContext::ShellSetup
- Inherits:
-
Object
- Object
- DevContext::ShellSetup
- Defined in:
- lib/dev_context/shell_setup.rb
Constant Summary collapse
- DEFAULT_PATH =
File.("~/.dx.sh").freeze
- MANAGED_MARKER =
"DevContext shell integration generated by `dx init`".freeze
- VERSION_MARKER_PREFIX =
"DX Shell Version:".freeze
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
-
#initialize(path: ENV.fetch("DX_SHELL_PATH", DEFAULT_PATH)) ⇒ ShellSetup
constructor
A new instance of ShellSetup.
-
#install! ⇒ Object
Returns :created, :updated, or :unchanged.
Constructor Details
#initialize(path: ENV.fetch("DX_SHELL_PATH", DEFAULT_PATH)) ⇒ ShellSetup
Returns a new instance of ShellSetup.
11 12 13 |
# File 'lib/dev_context/shell_setup.rb', line 11 def initialize(path: ENV.fetch("DX_SHELL_PATH", DEFAULT_PATH)) @path = path end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
9 10 11 |
# File 'lib/dev_context/shell_setup.rb', line 9 def path @path end |
Instance Method Details
#install! ⇒ Object
Returns :created, :updated, or :unchanged.
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/dev_context/shell_setup.rb', line 16 def install! unless File.exist?(path) File.write(path, shell_script) return :created end current = File.read(path) return :unchanged if current == shell_script return :unchanged unless managed_file?(current) File.write(path, shell_script) :updated end |