summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsersut <serdar@opscode.com>2013-12-12 11:39:17 -0800
committersersut <serdar@opscode.com>2013-12-12 11:39:17 -0800
commit1cf787963d8d94b55aae8eedab404e3e2fbdc32e (patch)
treee1afa1e3222995a117403a187f9c1f93de6a1283
parent94302c37409227f8f70ab2661d4b54daf325deec (diff)
downloadohai-1cf787963d8d94b55aae8eedab404e3e2fbdc32e.tar.gz
Move VersionVI and VersionVII plugin classes into their own files.
-rw-r--r--lib/ohai/dsl.rb22
-rw-r--r--lib/ohai/dsl/plugin.rb115
-rw-r--r--lib/ohai/dsl/plugin/versionvi.rb55
-rw-r--r--lib/ohai/dsl/plugin/versionvii.rb100
-rw-r--r--lib/ohai/loader.rb2
-rw-r--r--lib/ohai/provides_map.rb2
-rw-r--r--lib/ohai/runner.rb2
-rw-r--r--lib/ohai/system.rb2
8 files changed, 181 insertions, 119 deletions
diff --git a/lib/ohai/dsl.rb b/lib/ohai/dsl.rb
new file mode 100644
index 00000000..8ebde9de
--- /dev/null
+++ b/lib/ohai/dsl.rb
@@ -0,0 +1,22 @@
+#
+# Author:: Serdar Sutay (<serdar@opscode.com>)
+# Copyright:: Copyright (c) 2013 Opscode, Inc.
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+require 'ohai/dsl/plugin'
+require 'ohai/dsl/plugin/versionvi'
+require 'ohai/dsl/plugin/versionvii'
diff --git a/lib/ohai/dsl/plugin.rb b/lib/ohai/dsl/plugin.rb
index 2b15cae3..574399c7 100644
--- a/lib/ohai/dsl/plugin.rb
+++ b/lib/ohai/dsl/plugin.rb
@@ -127,121 +127,6 @@ module Ohai
@has_run
end
- #=====================================================
- # version 7 plugin class
- #=====================================================
- class VersionVII < Plugin
- attr_reader :version
-
- def initialize(controller, source)
- super(controller, source)
- @version = :version7
- end
-
- def name
- self.class.name.split("Ohai::NamedPlugin::")[1]
- end
-
- def self.version
- :version7
- end
-
- def self.provides_attrs
- @provides_attrs ||= []
- end
-
- def self.depends_attrs
- @depends_attrs ||= []
- end
-
- def self.data_collector
- @data_collector ||= Mash.new
- end
-
- def self.provides(*attrs)
- attrs.each do |attr|
- provides_attrs << attr
- end
- end
-
- def self.depends(*attrs)
- attrs.each do |attr|
- depends_attrs << attr
- end
- end
-
- def self.collect_data(platform = :default, *other_platforms, &block)
- [platform, other_platforms].flatten.each do |plat|
- if data_collector.has_key?(plat)
- raise Ohai::Exceptions::IllegalPluginDefinition, "collect_data already defined on platform #{plat}"
- else
- data_collector[plat] = block
- end
- end
- end
-
- def dependencies
- self.class.depends_attrs
- end
-
- def run_plugin
- collector = self.class.data_collector
- platform = collect_os
-
- if collector.has_key?(platform)
- self.instance_eval(&collector[platform])
- elsif collector.has_key?(:default)
- self.instance_eval(&collector[:default])
- else
- Ohai::Log.debug("No data to collect for plugin #{self.name}. Continuing...")
- end
- end
-
- def provides(*paths)
- Ohai::Log.warn("[UNSUPPORTED OPERATION] \'provides\' is no longer supported in a \'collect_data\' context. Please specify \'provides\' before collecting plugin data. Ignoring command \'provides #{paths.join(", ")}")
- end
-
- def require_plugin(*args)
- Ohai::Log.warn("[UNSUPPORTED OPERATION] \'require_plugin\' is no longer supported. Please use \'depends\' instead.\nIgnoring plugin(s) #{args.join(", ")}")
- end
- end
-
- #=====================================================
- # version 6 plugin class
- #=====================================================
- class VersionVI < Plugin
- attr_reader :version
-
- def initialize(controller, source)
- super(controller, source)
- @version = :version6
- end
-
- def name
- self.class.name.split("Ohai::NamedPlugin::")[1]
- end
-
- def self.version
- :version6
- end
-
- def self.collect_contents(contents)
- define_method(:run_plugin) { self.instance_eval(contents) }
- end
-
- def provides(*paths)
- provides_map.set_providers_for(self, paths)
- end
-
- def require_plugin(*args)
- @controller.require_plugin(*args)
- end
-
- end
-
- #=====================================================
- # plugin DSL methods
- #=====================================================
def hints
@controller.hints
end
diff --git a/lib/ohai/dsl/plugin/versionvi.rb b/lib/ohai/dsl/plugin/versionvi.rb
new file mode 100644
index 00000000..45796b90
--- /dev/null
+++ b/lib/ohai/dsl/plugin/versionvi.rb
@@ -0,0 +1,55 @@
+#
+# Author:: Serdar Sutay (<serdar@opscode.com>)
+# Copyright:: Copyright (c) 2013 Opscode, Inc.
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+module Ohai
+ module DSL
+ class Plugin
+ class VersionVI < Plugin
+ attr_reader :version
+
+ def initialize(controller, source)
+ super(controller, source)
+ @version = :version6
+ end
+
+ def name
+ self.class.name.split("Ohai::NamedPlugin::")[1]
+ end
+
+ def self.version
+ :version6
+ end
+
+ def self.collect_contents(contents)
+ define_method(:run_plugin) { self.instance_eval(contents) }
+ end
+
+ def provides(*paths)
+ provides_map.set_providers_for(self, paths)
+ end
+
+ def require_plugin(*args)
+ @controller.require_plugin(*args)
+ end
+
+ end
+ end
+ end
+end
+
diff --git a/lib/ohai/dsl/plugin/versionvii.rb b/lib/ohai/dsl/plugin/versionvii.rb
new file mode 100644
index 00000000..2680a1a8
--- /dev/null
+++ b/lib/ohai/dsl/plugin/versionvii.rb
@@ -0,0 +1,100 @@
+#
+# Author:: Serdar Sutay (<serdar@opscode.com>)
+# Copyright:: Copyright (c) 2013 Opscode, Inc.
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+module Ohai
+ module DSL
+ class Plugin
+ class VersionVII < Plugin
+ attr_reader :version
+
+ def initialize(controller, source)
+ super(controller, source)
+ @version = :version7
+ end
+
+ def name
+ self.class.name.split("Ohai::NamedPlugin::")[1]
+ end
+
+ def self.version
+ :version7
+ end
+
+ def self.provides_attrs
+ @provides_attrs ||= []
+ end
+
+ def self.depends_attrs
+ @depends_attrs ||= []
+ end
+
+ def self.data_collector
+ @data_collector ||= Mash.new
+ end
+
+ def self.provides(*attrs)
+ attrs.each do |attr|
+ provides_attrs << attr
+ end
+ end
+
+ def self.depends(*attrs)
+ attrs.each do |attr|
+ depends_attrs << attr
+ end
+ end
+
+ def self.collect_data(platform = :default, *other_platforms, &block)
+ [platform, other_platforms].flatten.each do |plat|
+ if data_collector.has_key?(plat)
+ raise Ohai::Exceptions::IllegalPluginDefinition, "collect_data already defined on platform #{plat}"
+ else
+ data_collector[plat] = block
+ end
+ end
+ end
+
+ def dependencies
+ self.class.depends_attrs
+ end
+
+ def run_plugin
+ collector = self.class.data_collector
+ platform = collect_os
+
+ if collector.has_key?(platform)
+ self.instance_eval(&collector[platform])
+ elsif collector.has_key?(:default)
+ self.instance_eval(&collector[:default])
+ else
+ Ohai::Log.debug("No data to collect for plugin #{self.name}. Continuing...")
+ end
+ end
+
+ def provides(*paths)
+ Ohai::Log.warn("[UNSUPPORTED OPERATION] \'provides\' is no longer supported in a \'collect_data\' context. Please specify \'provides\' before collecting plugin data. Ignoring command \'provides #{paths.join(", ")}")
+ end
+
+ def require_plugin(*args)
+ Ohai::Log.warn("[UNSUPPORTED OPERATION] \'require_plugin\' is no longer supported. Please use \'depends\' instead.\nIgnoring plugin(s) #{args.join(", ")}")
+ end
+ end
+ end
+ end
+end
diff --git a/lib/ohai/loader.rb b/lib/ohai/loader.rb
index bd698fcc..61abb3b2 100644
--- a/lib/ohai/loader.rb
+++ b/lib/ohai/loader.rb
@@ -18,7 +18,7 @@
require 'ohai/log'
require 'ohai/mash'
-require 'ohai/dsl/plugin'
+require 'ohai/dsl'
module Ohai
class Loader
diff --git a/lib/ohai/provides_map.rb b/lib/ohai/provides_map.rb
index 2f61f550..d251e7dd 100644
--- a/lib/ohai/provides_map.rb
+++ b/lib/ohai/provides_map.rb
@@ -20,7 +20,7 @@
require 'ohai/mash'
require 'ohai/exception'
require 'ohai/mixin/os'
-require 'ohai/dsl/plugin'
+require 'ohai/dsl'
module Ohai
class ProvidesMap
diff --git a/lib/ohai/runner.rb b/lib/ohai/runner.rb
index 0ead9718..e4650319 100644
--- a/lib/ohai/runner.rb
+++ b/lib/ohai/runner.rb
@@ -17,7 +17,7 @@
# limitations under the License
#
-require 'ohai/dsl/plugin'
+require 'ohai/dsl'
module Ohai
class Runner
diff --git a/lib/ohai/system.rb b/lib/ohai/system.rb
index a5029c29..93c23f25 100644
--- a/lib/ohai/system.rb
+++ b/lib/ohai/system.rb
@@ -20,7 +20,7 @@ require 'ohai/loader'
require 'ohai/log'
require 'ohai/mash'
require 'ohai/runner'
-require 'ohai/dsl/plugin'
+require 'ohai/dsl'
require 'ohai/mixin/from_file'
require 'ohai/mixin/command'
require 'ohai/mixin/os'