Class: GitPusshuTen::Configuration
- Inherits:
-
Object
- Object
- GitPusshuTen::Configuration
- Defined in:
- lib/gitpusshuten/configuration.rb
Instance Attribute Summary collapse
-
#additional_modules ⇒ Object
Contains a list of modules.
-
#application ⇒ Object
Contains the Application’s name which is extracted from the selected configuration in the configuration file.
-
#environment ⇒ Object
Contains the environment on the remote server name which is extracted from the selected configuration in the configuration file.
-
#force_parse ⇒ Object
A flag to force the parsing.
-
#found ⇒ Object
(also: #found?)
Returns true if the configuration has been found.
-
#ip ⇒ Object
Contains the user, password, passphrase, ssh key, ip and port for connecting and authorizing the user to the remote server.
-
#passphrase ⇒ Object
Contains the user, password, passphrase, ssh key, ip and port for connecting and authorizing the user to the remote server.
-
#password ⇒ Object
Contains the user, password, passphrase, ssh key, ip and port for connecting and authorizing the user to the remote server.
-
#path ⇒ Object
Contains the path to where the application should be pushed.
-
#port ⇒ Object
Contains the user, password, passphrase, ssh key, ip and port for connecting and authorizing the user to the remote server.
-
#ssh_key ⇒ Object
Contains the user, password, passphrase, ssh key, ip and port for connecting and authorizing the user to the remote server.
-
#user ⇒ Object
Contains the user, password, passphrase, ssh key, ip and port for connecting and authorizing the user to the remote server.
Instance Method Summary collapse
-
#add(module_object) ⇒ Object
Modules - Add Helper method for the Modules helper to add modules to the array.
-
#configure {|_self| ... } ⇒ Object
Configure helper method for the pusshuten configuration method.
-
#initialize(environment) ⇒ Configuration
constructor
Initializes a new configuration object takes the absolute path to the configuration file.
-
#modules {|_self| ... } ⇒ Object
Modules Helper method for adding modules.
-
#parse!(configuration_file) ⇒ Object
Parses the configuration file and loads all the configuration values into the GitPusshuTen::Configuration instance.
-
#pusshuten(application, *environment, &block) ⇒ Object
Pusshuten Helper method used to configure the configuration file.
-
#sanitized_app_name ⇒ Object
Returns a (simple) sanitized version of the application name.
Constructor Details
#initialize(environment) ⇒ Configuration
Initializes a new configuration object takes the absolute path to the configuration file
80 81 82 83 84 85 86 |
# File 'lib/gitpusshuten/configuration.rb', line 80 def initialize(environment) @environment = environment @found = false @force_parse = false @additional_modules = [] end |
Instance Attribute Details
#additional_modules ⇒ Object
Contains a list of modules
30 31 32 |
# File 'lib/gitpusshuten/configuration.rb', line 30 def additional_modules @additional_modules end |
#application ⇒ Object
Contains the Application’s name which is extracted from the selected configuration in the configuration file
7 8 9 |
# File 'lib/gitpusshuten/configuration.rb', line 7 def application @application end |
#environment ⇒ Object
Contains the environment on the remote server name which is extracted from the selected configuration in the configuration file
12 13 14 |
# File 'lib/gitpusshuten/configuration.rb', line 12 def environment @environment end |
#force_parse ⇒ Object
A flag to force the parsing
34 35 36 |
# File 'lib/gitpusshuten/configuration.rb', line 34 def force_parse @force_parse end |
#found ⇒ Object Also known as: found?
Returns true if the configuration has been found
16 17 18 |
# File 'lib/gitpusshuten/configuration.rb', line 16 def found @found end |
#ip ⇒ Object
Contains the user, password, passphrase, ssh key, ip and port for connecting and authorizing the user to the remote server
22 23 24 |
# File 'lib/gitpusshuten/configuration.rb', line 22 def ip @ip end |
#passphrase ⇒ Object
Contains the user, password, passphrase, ssh key, ip and port for connecting and authorizing the user to the remote server
22 23 24 |
# File 'lib/gitpusshuten/configuration.rb', line 22 def passphrase @passphrase end |
#password ⇒ Object
Contains the user, password, passphrase, ssh key, ip and port for connecting and authorizing the user to the remote server
22 23 24 |
# File 'lib/gitpusshuten/configuration.rb', line 22 def password @password end |
#path ⇒ Object
Contains the path to where the application should be pushed
26 27 28 |
# File 'lib/gitpusshuten/configuration.rb', line 26 def path @path end |
#port ⇒ Object
Contains the user, password, passphrase, ssh key, ip and port for connecting and authorizing the user to the remote server
22 23 24 |
# File 'lib/gitpusshuten/configuration.rb', line 22 def port @port end |
#ssh_key ⇒ Object
Contains the user, password, passphrase, ssh key, ip and port for connecting and authorizing the user to the remote server
22 23 24 |
# File 'lib/gitpusshuten/configuration.rb', line 22 def ssh_key @ssh_key end |
#user ⇒ Object
Contains the user, password, passphrase, ssh key, ip and port for connecting and authorizing the user to the remote server
22 23 24 |
# File 'lib/gitpusshuten/configuration.rb', line 22 def user @user end |
Instance Method Details
#add(module_object) ⇒ Object
Modules - Add Helper method for the Modules helper to add modules to the array
53 54 55 |
# File 'lib/gitpusshuten/configuration.rb', line 53 def add(module_object) @additional_modules << module_object end |
#configure {|_self| ... } ⇒ Object
Configure helper method for the pusshuten configuration method
39 40 41 |
# File 'lib/gitpusshuten/configuration.rb', line 39 def configure yield self end |
#modules {|_self| ... } ⇒ Object
Modules Helper method for adding modules
46 47 48 |
# File 'lib/gitpusshuten/configuration.rb', line 46 def modules yield self end |
#parse!(configuration_file) ⇒ Object
Parses the configuration file and loads all the configuration values into the GitPusshuTen::Configuration instance
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/gitpusshuten/configuration.rb', line 91 def parse!(configuration_file) instance_eval(File.read(configuration_file)) ## # If no configuration is found by environment then # it will re-parse it in a forced manner, meaning it won't # care about the environment and it will just parse everything it finds. # This is done because we can then extract all set "modules" from the configuration # file and display them in the "Help" screen so users can look up information/examples on them. # # This will only occur if no environment is found/specified. So when doing anything # environment specific, it will never force the parsing. if not found? and environment.nil? @force_parse = true instance_eval(File.read(configuration_file)) @additional_modules.uniq! end if not found? and not environment.nil? GitPusshuTen::Log.error "Could not find any configuration for #{environment.to_s.color(:yellow)}." exit end ## # Default to port 22 if no port is specified @port ||= '22' self end |
#pusshuten(application, *environment, &block) ⇒ Object
Pusshuten Helper method used to configure the configuration file
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/gitpusshuten/configuration.rb', line 60 def pusshuten(application, *environment, &block) environment.flatten! environment.each do |env| unless env.is_a?(Symbol) GitPusshuTen::Log.error 'Please use symbols as environment name.' exit end end if environment.include?(@environment) or force_parse @application = application @found = true block.call end end |
#sanitized_app_name ⇒ Object
Returns a (simple) sanitized version of the application name
123 124 125 |
# File 'lib/gitpusshuten/configuration.rb', line 123 def sanitized_app_name application.gsub(' ', '_').downcase end |