Class: GemspecDepsGen

Inherits:
Object
  • Object
show all
Includes:
FileUtils
Defined in:
lib/gemspec_deps_gen/version.rb,
lib/gemspec_deps_gen/gemspec_deps_gen.rb

Constant Summary collapse

VERSION =
"1.1.2"

Instance Method Summary collapse

Instance Method Details

#bundler_gems(group) ⇒ Object



7
8
9
# File 'lib/gemspec_deps_gen/gemspec_deps_gen.rb', line 7

def bundler_gems group
  Bundler.environment.dependencies.select { |d| d.groups.include?(group) }.collect
end

#generate_dependencies(spec_name, source, target) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/gemspec_deps_gen/gemspec_deps_gen.rb', line 11

def generate_dependencies spec_name, source, target
  project_dependencies = generate_project_dependencies spec_name

  if target
    write_content_to_file(execute_template(source, binding), target)
  else
    puts project_dependencies
  end
end

#generate_project_dependencies(spec_name) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/gemspec_deps_gen/gemspec_deps_gen.rb', line 21

def generate_project_dependencies spec_name
  text = "\n"

  bundler_gems(:default).each do |gem|
    text += "  #{spec_name}.add_runtime_dependency \"#{gem.name}\", #{gem.requirements_list}\n"
  end

  bundler_gems(:development).each do |gem|
    text +="  #{spec_name}.add_development_dependency \"#{gem.name}\", #{gem.requirements_list}\n"
  end

  text
end