fluent-plugin-obsolete-plugins 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 64c35dab27cb19ba6b8f33edd023c6dbcc100256b0f372e7f51f8d4dc99a3197
4
- data.tar.gz: aedff69e17e8d8ce189920ee3249e5385b3dbde50157b8b83630e40e276ad8cf
3
+ metadata.gz: 50b50f43386e9dcb8aec6b15127b1668429fc78eb56e497e0af46aec844e822f
4
+ data.tar.gz: ceb7b18fb122429a2d54a90250665a8e56e2a3f10d05b798b8382232fde16b4f
5
5
  SHA512:
6
- metadata.gz: '028c5a09fc99fac1c8be4a36c4ab1d2bdbd7c88178336771696d6e6e22393b6e2de14d42c7cfc2509a1e12b01b2204845ab1b342f0007badd75e46b96c7cd1b2'
7
- data.tar.gz: 1440e86c8bc39de6bcd6a68624254a624d4d2d235460430c22dc0ae1ded7cf54eb985b1662101f3ab7ebd25b0faf3ffd9e101de8909ef1df8ec1f79784a7ad2d
6
+ metadata.gz: '0299c8d42343ab0215ff8f08007d54c736380bc3a83c4a4ac8a4d7009d0e61924cf23c55913e1b28d5c9e5305a45eed5bbdb65fcd24b01ccba7051111c3d7515'
7
+ data.tar.gz: 7e36f322f52ee97c08c5f88eab26d765695fae89e8bf9e754ab4012f48dd5ff6edc3161d01728d1c2043c00f04d20db517db6495ea25985879edc78e057a6a1c
@@ -3,7 +3,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
 
4
4
  Gem::Specification.new do |spec|
5
5
  spec.name = "fluent-plugin-obsolete-plugins"
6
- spec.version = "0.2.0"
6
+ spec.version = "0.2.1"
7
7
  spec.authors = ["okkez"]
8
8
  spec.email = ["okkez000@gmail.com"]
9
9
 
@@ -28,8 +28,12 @@ class Fluent::Plugin::ObsoletePluginsUtils
28
28
  end
29
29
  end
30
30
 
31
+ def self.installed_plugins
32
+ Gem::Specification.find_all.select { |x| x.name =~ /^fluent(d|-(plugin|mixin)-.*)$/ }.map(&:name)
33
+ end
34
+
31
35
  def self.notify(logger, obsolete_plugins, raise_error: false)
32
- plugins = Gem.loaded_specs.keys & obsolete_plugins.keys
36
+ plugins = Fluent::Plugin::ObsoletePluginsUtils.installed_plugins & obsolete_plugins.keys
33
37
  plugins.each do |name|
34
38
  logger.warn("#{name} is obsolete: #{obsolete_plugins[name].chomp}")
35
39
  end
@@ -20,6 +20,10 @@ class ObsoletePluginsFilterTest < Test::Unit::TestCase
20
20
  ]
21
21
 
22
22
  test "no obsolete plugins" do
23
+ stub(Fluent::Plugin::ObsoletePluginsUtils).installed_plugins do
24
+ []
25
+ end
26
+
23
27
  d = create_driver(CONFIG_YAML)
24
28
  d.run(default_tag: "test") do
25
29
  d.feed({ message: "This is test message." })
@@ -32,12 +36,10 @@ class ObsoletePluginsFilterTest < Test::Unit::TestCase
32
36
  end
33
37
 
34
38
  test "obsolete plugins" do
35
- mock(Gem).loaded_specs do
36
- {
37
- "fluent-plugin-tail-multiline" => nil,
38
- "fluent-plugin-hostname" => nil
39
- }
39
+ stub(Fluent::Plugin::ObsoletePluginsUtils).installed_plugins do
40
+ ["fluent-plugin-tail-multiline", "fluent-plugin-hostname"]
40
41
  end
42
+
41
43
  d = create_driver(CONFIG_YAML)
42
44
  d.run(default_tag: "test") do
43
45
  d.feed({ message: "This is test message." })
@@ -52,11 +54,8 @@ class ObsoletePluginsFilterTest < Test::Unit::TestCase
52
54
  end
53
55
 
54
56
  test "raise error when detect obsolete plugins" do
55
- mock(Gem).loaded_specs do
56
- {
57
- "fluent-plugin-tail-multiline" => nil,
58
- "fluent-plugin-hostname" => nil
59
- }
57
+ stub(Fluent::Plugin::ObsoletePluginsUtils).installed_plugins do
58
+ ["fluent-plugin-tail-multiline", "fluent-plugin-hostname"]
60
59
  end
61
60
 
62
61
  ex = assert_raise(Fluent::ConfigError) do
@@ -72,6 +71,10 @@ class ObsoletePluginsFilterTest < Test::Unit::TestCase
72
71
  ]
73
72
 
74
73
  test "no obsolete plugins" do
74
+ stub(Fluent::Plugin::ObsoletePluginsUtils).installed_plugins do
75
+ []
76
+ end
77
+
75
78
  d = create_driver(CONFIG_JSON)
76
79
  d.run(default_tag: "test") do
77
80
  d.feed({ message: "This is test message." })
@@ -81,12 +84,10 @@ class ObsoletePluginsFilterTest < Test::Unit::TestCase
81
84
  end
82
85
 
83
86
  test "obsolete plugins" do
84
- mock(Gem).loaded_specs do
85
- {
86
- "fluent-plugin-tail-multiline" => nil,
87
- "fluent-plugin-hostname" => nil
88
- }
87
+ stub(Fluent::Plugin::ObsoletePluginsUtils).installed_plugins do
88
+ ["fluent-plugin-tail-multiline", "fluent-plugin-hostname"]
89
89
  end
90
+
90
91
  d = create_driver(CONFIG_JSON)
91
92
  d.run(default_tag: "test") do
92
93
  d.feed({ message: "This is test message." })
@@ -100,11 +101,8 @@ class ObsoletePluginsFilterTest < Test::Unit::TestCase
100
101
  end
101
102
 
102
103
  test "raise error when detect obsolete plugins" do
103
- mock(Gem).loaded_specs do
104
- {
105
- "fluent-plugin-tail-multiline" => nil,
106
- "fluent-plugin-hostname" => nil
107
- }
104
+ stub(Fluent::Plugin::ObsoletePluginsUtils).installed_plugins do
105
+ ["fluent-plugin-tail-multiline", "fluent-plugin-hostname"]
108
106
  end
109
107
 
110
108
  ex = assert_raise(Fluent::ConfigError) do
@@ -21,6 +21,10 @@ class ObsoletePluginsInputTest < Test::Unit::TestCase
21
21
  ]
22
22
 
23
23
  test "no obsolete plugins" do
24
+ stub(Fluent::Plugin::ObsoletePluginsUtils).installed_plugins do
25
+ []
26
+ end
27
+
24
28
  d = create_driver(CONFIG_JSON)
25
29
  d.run
26
30
  assert_equal([], d.events)
@@ -28,12 +32,10 @@ class ObsoletePluginsInputTest < Test::Unit::TestCase
28
32
  end
29
33
 
30
34
  test "obsolete plugins" do
31
- stub(Gem).loaded_specs do
32
- {
33
- "fluent-plugin-tail-multiline" => nil,
34
- "fluent-plugin-hostname" => nil
35
- }
35
+ stub(Fluent::Plugin::ObsoletePluginsUtils).installed_plugins do
36
+ ["fluent-plugin-tail-multiline", "fluent-plugin-hostname"]
36
37
  end
38
+
37
39
  d = create_driver(CONFIG_JSON)
38
40
  d.run
39
41
  assert_equal([], d.events)
@@ -45,11 +47,8 @@ class ObsoletePluginsInputTest < Test::Unit::TestCase
45
47
  end
46
48
 
47
49
  test "raise error when detect obsolete plugins" do
48
- stub(Gem).loaded_specs do
49
- {
50
- "fluent-plugin-tail-multiline" => nil,
51
- "fluent-plugin-hostname" => nil
52
- }
50
+ stub(Fluent::Plugin::ObsoletePluginsUtils).installed_plugins do
51
+ ["fluent-plugin-tail-multiline", "fluent-plugin-hostname"]
53
52
  end
54
53
 
55
54
  ex = assert_raise(Fluent::ConfigError) do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-obsolete-plugins
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - okkez