From 93123466e50e24d1bbef9e819a45518981361d5d Mon Sep 17 00:00:00 2001 From: elijah Date: Sun, 2 Jun 2013 23:32:21 -0700 Subject: now we require a leap_platform/platform.rb config file. --- lib/leap/platform.rb | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 lib/leap/platform.rb (limited to 'lib/leap/platform.rb') diff --git a/lib/leap/platform.rb b/lib/leap/platform.rb new file mode 100644 index 0000000..298e480 --- /dev/null +++ b/lib/leap/platform.rb @@ -0,0 +1,51 @@ +require 'versionomy' + +module Leap + + class Platform + class << self + # + # configuration + # + + attr_reader :version + attr_reader :compatible_cli + attr_accessor :facts + attr_accessor :paths + attr_accessor :node_files + + def define(&block) + self.instance_eval(&block) + end + + def version=(version) + @version = Versionomy.parse(version) + end + + def compatible_cli=(range) + @compatible_cli = range + @minimum_cli_version = Versionomy.parse(range.first) + @maximum_cli_version = Versionomy.parse(range.last) + end + + # + # return true if the cli_version is compatible with this platform. + # + def compatible_with_cli?(cli_version) + cli_version = Versionomy.parse(cli_version) + cli_version >= @minimum_cli_version && cli_version <= @maximum_cli_version + end + + # + # return true if the platform version is within the specified range. + # + def version_in_range?(range) + minimum_platform_version = Versionomy.parse(range.first) + maximum_platform_version = Versionomy.parse(range.last) + @version >= minimum_platform_version && @version <= maximum_platform_version + end + end + + end + +end \ No newline at end of file -- cgit v1.2.3