Module: Pik::ScriptFileEditor
Instance Attribute Summary collapse
-
#script ⇒ Object
readonly
Returns the value of attribute script.
Instance Method Summary collapse
- #echo_ruby_version(path, verb = '') ⇒ Object
- #initialize(args = ARGV, config = nil) ⇒ Object
- #set(items) ⇒ Object
- #switch_gem_home_to(gem_home) ⇒ Object
- #switch_path_to(other) ⇒ Object
Instance Attribute Details
#script ⇒ Object (readonly)
Returns the value of attribute script.
5 6 7 |
# File 'lib/pik/commands/script_file_editor.rb', line 5 def script @script end |
Instance Method Details
#echo_ruby_version(path, verb = '') ⇒ Object
40 41 42 43 |
# File 'lib/pik/commands/script_file_editor.rb', line 40 def echo_ruby_version(path, verb='') rb = Which::Ruby.exe(path).basename @script.call "#{rb} -v" end |
#initialize(args = ARGV, config = nil) ⇒ Object
7 8 9 10 11 |
# File 'lib/pik/commands/script_file_editor.rb', line 7 def initialize(args=ARGV,config=nil) super @script = SCRIPT_FILE editors << @script end |
#set(items) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/pik/commands/script_file_editor.rb', line 13 def set(items) items.each do |k, v| @script.set(k => v) WindowsEnv.user.set(k => v) if global end end |
#switch_gem_home_to(gem_home) ⇒ Object
34 35 36 37 38 |
# File 'lib/pik/commands/script_file_editor.rb', line 34 def switch_gem_home_to(gem_home) gem_home = Pathname(gem_home).to_windows rescue nil @script.set('GEM_PATH' => gem_home ) @script.set('GEM_HOME' => gem_home ) end |
#switch_path_to(other) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/pik/commands/script_file_editor.rb', line 20 def switch_path_to(other) current = Which::Ruby.find new_path = SearchPath.new(ENV['PATH']) new_path.replace_or_add(current, other[:path]) # if there is currently a GEM_HOME, remove it's bin dir from the path new_path.remove(Pathname.new(ENV['GEM_HOME']) + 'bin') if ENV['GEM_HOME'] # if the new version has a GEM_HOME, add it's bin dir to the path new_path.add(Pathname.new(other[:gem_home]) + 'bin') if other[:gem_home] @script.set('PATH' => new_path ) end |