Skip to content

Commit

Permalink
Merge pull request #1280 from chef/refresh_plugins
Browse files Browse the repository at this point in the history
Removed unused refresh_plugins method in System class
  • Loading branch information
tas50 authored Oct 30, 2018
2 parents 3042be0 + c33d6fe commit 8872f36
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 84 deletions.
17 changes: 0 additions & 17 deletions lib/ohai/system.rb
Original file line number Diff line number Diff line change
Expand Up @@ -139,23 +139,6 @@ def run_additional_plugins(plugin_path)
freeze_strings!
end

# Re-runs plugins that provide the attributes specified by
# +attribute_filter+. If +attribute_filter+ is not given, re-runs all
# plugins.
#
# Note that dependencies will not be re-run, so you must specify all of the
# attributes you want refreshed in the +attribute_filter+
#
# This method takes a naive approach to v6 plugins: it simply re-runs all
# of them whenever called.
def refresh_plugins(attribute_filter = nil)
Ohai::Hints.refresh_hints
@provides_map.all_plugins(attribute_filter).each do |plugin|
plugin.reset!
end
run_plugins(true, attribute_filter)
end

#
# Serialize this object as a hash
#
Expand Down
67 changes: 0 additions & 67 deletions spec/unit/system_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -305,73 +305,6 @@
end
end

describe "when refreshing plugins" do
when_plugins_directory "contains v7 plugins" do
with_plugin("desired.rb", <<-E)
Ohai.plugin(:DesiredPlugin) do
provides 'desired_attr'
depends 'depended_attr'
collect_data do
desired_attr "hello"
self[:desired_attr_count] ||= 0
self[:desired_attr_count] += 1
end
end
E

with_plugin("depended.rb", <<-E)
Ohai.plugin(:DependedPlugin) do
provides 'depended_attr'
collect_data do
depended_attr "hello"
self[:depended_attr_count] ||= 0
self[:depended_attr_count] += 1
end
end
E

with_plugin("other.rb", <<-E)
Ohai.plugin(:OtherPlugin) do
provides 'other_attr'
collect_data do
other_attr "hello"
self[:other_attr_count] ||= 0
self[:other_attr_count] += 1
end
end
E

before do
Ohai.config[:plugin_path] = [ path_to(".") ]
Ohai::Log.init(STDOUT)
Ohai::Log.level = :debug
ohai.all_plugins
end

it "should rerun the plugin providing the desired attributes" do
expect(ohai.data[:desired_attr_count]).to eq(1)
ohai.refresh_plugins("desired_attr")
expect(ohai.data[:desired_attr_count]).to eq(2)
end

it "should not re-run dependencies of the plugin providing the desired attributes" do
expect(ohai.data[:depended_attr_count]).to eq(1)
ohai.refresh_plugins("desired_attr")
expect(ohai.data[:depended_attr_count]).to eq(1)
end

it "should not re-run plugins unrelated to the plugin providing the desired attributes" do
expect(ohai.data[:other_attr_count]).to eq(1)
ohai.refresh_plugins("desired_attr")
expect(ohai.data[:other_attr_count]).to eq(1)
end

end
end

describe "when running ohai for specific attributes" do
when_plugins_directory "contains v7 plugins" do
with_plugin("languages.rb", <<-E)
Expand Down

0 comments on commit 8872f36

Please sign in to comment.