Skip to content

Commit

Permalink
Merge pull request #3305 from kenhys/update-newgem
Browse files Browse the repository at this point in the history
Follow depended gem version by fluent-plugin-generate
  • Loading branch information
ashie committed Mar 31, 2021
2 parents 98600df + 40691ae commit d19b706
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
30 changes: 30 additions & 0 deletions lib/fluent/command/plugin_generator.rb
Expand Up @@ -151,6 +151,36 @@ def plugin_name
underscore_name
end

def gem_file_path
File.expand_path(File.join(File.dirname(__FILE__),
"../../../",
"Gemfile"))
end

def lock_file_path
File.expand_path(File.join(File.dirname(__FILE__),
"../../../",
"Gemfile.lock"))
end

def locked_gem_version(gem_name)
d = Bundler::Definition.build(gem_file_path, lock_file_path, false)
d.locked_gems.dependencies[gem_name].requirement.requirements.first.last.version
end

def rake_version
locked_gem_version("rake")
end

def test_unit_version
locked_gem_version("test-unit")
end

def bundler_version
d = Bundler::Definition.build(gem_file_path, lock_file_path, false)
d.locked_gems.bundler_version.version
end

def class_name
"#{capitalized_name}#{type.capitalize}"
end
Expand Down
6 changes: 3 additions & 3 deletions templates/new_gem/fluent-plugin.gemspec.erb
Expand Up @@ -20,8 +20,8 @@ Gem::Specification.new do |spec|
spec.test_files = test_files
spec.require_paths = ["lib"]

spec.add_development_dependency "bundler", "~> 1.14"
spec.add_development_dependency "rake", "~> 12.0"
spec.add_development_dependency "test-unit", "~> 3.0"
spec.add_development_dependency "bundler", "~> <%= bundler_version %>"
spec.add_development_dependency "rake", "~> <%= rake_version %>"
spec.add_development_dependency "test-unit", "~> <%= test_unit_version %>"
spec.add_runtime_dependency "fluentd", [">= 0.14.10", "< 2"]
end

0 comments on commit d19b706

Please sign in to comment.