Class: RubyConfig::ProfileConfig
- Inherits:
-
Object
- Object
- RubyConfig::ProfileConfig
- Defined in:
- lib/ruby_config/profile_config.rb
Instance Method Summary collapse
- #apply_changes ⇒ Object
- #create_new_file ⇒ Object
- #exists? ⇒ Boolean
- #export_variables_string ⇒ Object
- #file_exists? ⇒ Boolean
-
#initialize(bash_profile_path) ⇒ ProfileConfig
constructor
A new instance of ProfileConfig.
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_changes ⇒ Object
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_file ⇒ Object
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
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_string ⇒ Object
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
17 18 19 |
# File 'lib/ruby_config/profile_config.rb', line 17 def file_exists? File.exists?(@bash_profile_path) end |