Class: Jenkins::Plugin::CLI::New

Inherits:
Thor::Group
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/jenkins/plugin/cli/new.rb

Instance Method Summary collapse

Instance Method Details

#create_gemfileObject



22
23
24
# File 'lib/jenkins/plugin/cli/new.rb', line 22

def create_gemfile
  template('templates/Gemfile.tt', "#{repository_name}/Gemfile")
end

#create_pluginspecObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/jenkins/plugin/cli/new.rb', line 26

def create_pluginspec
  git_name = %x[git config user.name].chomp
  git_email = %x[git config user.email].chomp

  developer_id = git_email.split('@', 2).first || ''

  # Fallback values.
  git_name = 'TODO: Put your realname here' if git_name.empty?
  git_email = '[email protected]' if git_email.empty?

  display_name_components = repository_name.split(/[-_]/).collect { |w| w.capitalize }

  opts = {
    :developer_id => developer_id.empty? ? 'TODO: Put your jenkins-ci.org username here.' : developer_id,
    :developer_name => "#{git_name} <#{git_email}>",
    :display_name => display_name_components.join(' ')
  }

  template('templates/pluginspec.tt', "#{repository_name}/#{name}.pluginspec", opts)
end

#nameObject



14
15
16
# File 'lib/jenkins/plugin/cli/new.rb', line 14

def name
  @name.gsub(/\s+/, '-').sub(/[_-]plugin$/, '')
end

#repository_nameObject



18
19
20
# File 'lib/jenkins/plugin/cli/new.rb', line 18

def repository_name
  name + '-plugin'
end