Class: RubyConfig::ProfileConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_config/profile_config.rb

Instance Method Summary collapse

Constructor Details

#initialize(bash_profile_path) ⇒ ProfileConfig

Returns a new instance of ProfileConfig.



5
6
7
# File 'lib/ruby_config/profile_config.rb', line 5

def initialize(bash_profile_path)
  @bash_profile_path = bash_profile_path
end

Instance Method Details

#apply_changesObject



9
10
11
# File 'lib/ruby_config/profile_config.rb', line 9

def apply_changes
  File.open(@bash_profile_path, 'a') { |file| file.write content_for_existing_script }
end

#create_new_fileObject



21
22
23
# File 'lib/ruby_config/profile_config.rb', line 21

def create_new_file
  File.open(@bash_profile_path, 'w') { |file| file.write content_for_new_script }
end

#exists?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/ruby_config/profile_config.rb', line 13

def exists?
  File.open(@bash_profile_path, "r")  { |file| file.read  }.include?(export_variables_string)
end

#export_variables_stringObject



25
26
27
28
29
30
31
# File 'lib/ruby_config/profile_config.rb', line 25

def export_variables_string
  str = ""
  [ruby_home, gem_home, gem_path, path].each do |line|
    str << export_line(line)
  end
  str
end

#file_exists?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/ruby_config/profile_config.rb', line 17

def file_exists?
  File.exists?(@bash_profile_path)
end