Class: IntercityCLI::Configuration
- Inherits:
-
Object
- Object
- IntercityCLI::Configuration
- Defined in:
- lib/intercity/cli.rb
Instance Method Summary collapse
- #active_server ⇒ Object
- #active_server! ⇒ Object
- #active_server=(server) ⇒ Object
- #config_directory ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #nodes_directory ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
45 46 47 48 49 50 51 52 53 |
# File 'lib/intercity/cli.rb', line 45 def initialize() if !Dir.exists?(config_directory) FileUtils.mkdir_p(nodes_directory) end if !Dir.exists?(config_directory) FileUtils.mkdir_p(nodes_directory) end end |
Instance Method Details
#active_server ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/intercity/cli.rb', line 63 def active_server if !@active_server current_server_path = File.("~/.intercity/active_server") if File.exists?(current_server_path) @active_server = File.open(current_server_path, "r") do |f| f.read end end end return @active_server end |
#active_server! ⇒ Object
75 76 77 78 79 80 81 82 |
# File 'lib/intercity/cli.rb', line 75 def active_server! if !active_server puts 'No active server yet. Use the "switch" command or pass a server with --server' exist else return active_server end end |
#active_server=(server) ⇒ Object
84 85 86 87 88 89 |
# File 'lib/intercity/cli.rb', line 84 def active_server=(server) current_server_path = File.("~/.intercity/active_server") File.open(current_server_path, "w+") do |f| f.write(server) end end |
#config_directory ⇒ Object
55 56 57 |
# File 'lib/intercity/cli.rb', line 55 def config_directory File.("~/.intercity") end |
#nodes_directory ⇒ Object
59 60 61 |
# File 'lib/intercity/cli.rb', line 59 def nodes_directory File.("~/.intercity/nodes") end |