Class: CreateNewGem::Templates::Gemspec

Inherits:
Object
  • Object
show all
Defined in:
lib/create_new_gem/templates.rb

Instance Method Summary collapse

Constructor Details

#initialize(gemname:, gemclass:, summary:, description:, authors:, email:, require_path: "['lib']", dependencies:, homepage:, license:) ⇒ Gemspec

Returns a new instance of Gemspec.



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/create_new_gem/templates.rb', line 4

def initialize(gemname:,gemclass:,summary:,description:,authors:,email:,require_path:"['lib']",dependencies:,homepage:,license:)
  added_runtime_dependencies = []
  dependencies.each do |dep|
    added_runtime_dependencies << "#{gemname}.add_runtime_dependency '#{dep[0]}', '#{dep[1]}'"
  end

  @template = File.read("#{File.dirname __FILE__}/templates/gemspec.rb.template")
    .gsub("<<!gemname!>>", gemname)
    .gsub("<<!gemclass!>>", gemclass)
    .gsub("<<!summary!>>", summary)
    .gsub("<<!description!>>", description)
    .gsub("<<!authors!>>", authors.to_s)
    .gsub("<<!email!>>", email)
    .gsub("<<!require_paths!>>", require_path.to_s)
    .gsub("<<!homepage!>>", homepage)
    .gsub("<<!license!>>", license)
    .gsub("<<!runtime_dependencies!>>", added_runtime_dependencies.join("\n"))
end

Instance Method Details

#to_sObject



23
24
25
# File 'lib/create_new_gem/templates.rb', line 23

def to_s
  return @template
end