summaryrefslogtreecommitdiff
path: root/lib/leap
diff options
context:
space:
mode:
Diffstat (limited to 'lib/leap')
-rw-r--r--lib/leap/platform.rb51
1 files changed, 51 insertions, 0 deletions
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