Class: LeapCli::Leapfile
Instance Attribute Summary collapse
-
#environment ⇒ Object
readonly
Returns the value of attribute environment.
-
#platform_directory_path ⇒ Object
readonly
Returns the value of attribute platform_directory_path.
-
#provider_directory_path ⇒ Object
readonly
Returns the value of attribute provider_directory_path.
-
#valid ⇒ Object
readonly
Returns the value of attribute valid.
Instance Method Summary collapse
-
#environment_filter ⇒ Object
The way the Leapfile handles pinning of environment (self.environment) is a little tricky.
-
#initialize ⇒ Leapfile
constructor
A new instance of Leapfile.
- #load(search_directory = nil) ⇒ Object
- #set(property, value) ⇒ Object
- #unset(property) ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize ⇒ Leapfile
Returns a new instance of Leapfile.
20 21 |
# File 'lib/leap_cli/leapfile.rb', line 20 def initialize end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object (private)
164 165 166 167 168 169 170 |
# File 'lib/leap_cli/leapfile.rb', line 164 def method_missing(method, *args) if method =~ /=$/ self.instance_variable_set('@' + method.to_s.sub('=',''), args.first) else self.instance_variable_get('@' + method.to_s) end end |
Instance Attribute Details
#environment ⇒ Object (readonly)
Returns the value of attribute environment.
17 18 19 |
# File 'lib/leap_cli/leapfile.rb', line 17 def environment @environment end |
#platform_directory_path ⇒ Object (readonly)
Returns the value of attribute platform_directory_path.
15 16 17 |
# File 'lib/leap_cli/leapfile.rb', line 15 def platform_directory_path @platform_directory_path end |
#provider_directory_path ⇒ Object (readonly)
Returns the value of attribute provider_directory_path.
16 17 18 |
# File 'lib/leap_cli/leapfile.rb', line 16 def provider_directory_path @provider_directory_path end |
#valid ⇒ Object (readonly)
Returns the value of attribute valid.
18 19 20 |
# File 'lib/leap_cli/leapfile.rb', line 18 def valid @valid end |
Instance Method Details
#environment_filter ⇒ Object
The way the Leapfile handles pinning of environment (self.environment) is a little tricky. If self.environment is nil, then there is no pin. If self.environment is ‘default’, then there is a pin to the default environment. The problem is that an environment of nil is used to indicate the default environment in node properties.
This method returns the environment tag as needed when filtering nodes.
31 32 33 34 35 36 37 |
# File 'lib/leap_cli/leapfile.rb', line 31 def environment_filter if self.environment == 'default' nil else self.environment end end |
#load(search_directory = nil) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/leap_cli/leapfile.rb', line 39 def load(search_directory=nil) directory = File.(find_in_directory_tree('Leapfile', search_directory)) if directory == '/' return nil else # # set up paths # @provider_directory_path = directory begin # load leaprc first, so that we can potentially access which environment is pinned in Leapfile # but also load leaprc last, so that it can override what is set in Leapfile. read_settings(leaprc_path) rescue StandardError end read_settings(directory + '/Leapfile') read_settings(leaprc_path) @platform_directory_path = File.(@platform_directory_path || '../leap_platform', @provider_directory_path) # # load the platform # platform_class = "#{@platform_directory_path}/lib/leap/platform" platform_definition = "#{@platform_directory_path}/platform.rb" unless File.exist?(platform_definition) Util.bail! "ERROR: The file `#{platform_file}` does not exist. Please check the value of `@platform_directory_path` in `Leapfile` or `~/.leaprc`." end begin require platform_class require platform_definition rescue LoadError Util.log "The leap_platform at #{platform_directory_path} is not compatible with this version of leap_cli" Util.log "You can either:" do Util.log "Upgrade leap_platform to version " + LeapCli::COMPATIBLE_PLATFORM_VERSION.first Util.log "Or, downgrade leap_cli to version 1.8" end Util.bail! rescue StandardError => exc Util.bail! exc.to_s end begin Leap::Platform.validate!(LeapCli::VERSION, LeapCli::COMPATIBLE_PLATFORM_VERSION, self) rescue StandardError => exc Util.bail! exc.to_s end leapfile_extensions = "#{@platform_directory_path}/lib/leap_cli/leapfile_extensions.rb" if File.exist?(leapfile_extensions) require leapfile_extensions end # # validate # instance_variables.each do |var| var = var.to_s.sub('@', '') if !self.respond_to?(var) LeapCli.log :warning, "the variable `#{var}` is set in .leaprc or Leapfile, but it is not supported." end end @valid = validate return @valid end end |
#set(property, value) ⇒ Object
103 104 105 |
# File 'lib/leap_cli/leapfile.rb', line 103 def set(property, value) edit_leaprc(property, value) end |
#unset(property) ⇒ Object
107 108 109 |
# File 'lib/leap_cli/leapfile.rb', line 107 def unset(property) edit_leaprc(property) end |