Module: Bosh::PluginGenerator::Helpers

Extended by:
Forwardable
Includes:
Versions::Helpers
Included in:
Cli::Command::PluginGenerator
Defined in:
lib/bosh/plugin_generator/helpers.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#bosh_versionObject

Returns the value of attribute bosh_version.



8
9
10
# File 'lib/bosh/plugin_generator/helpers.rb', line 8

def bosh_version
  @bosh_version
end

#commands_folderObject

Returns the value of attribute commands_folder.



8
9
10
# File 'lib/bosh/plugin_generator/helpers.rb', line 8

def commands_folder
  @commands_folder
end

#helpers_folderObject

Returns the value of attribute helpers_folder.



8
9
10
# File 'lib/bosh/plugin_generator/helpers.rb', line 8

def helpers_folder
  @helpers_folder
end

#lib_folderObject

Returns the value of attribute lib_folder.



8
9
10
# File 'lib/bosh/plugin_generator/helpers.rb', line 8

def lib_folder
  @lib_folder
end

#plugin_folderObject

Returns the value of attribute plugin_folder.



8
9
10
# File 'lib/bosh/plugin_generator/helpers.rb', line 8

def plugin_folder
  @plugin_folder
end

#plugin_nameObject

Returns the value of attribute plugin_name.



8
9
10
# File 'lib/bosh/plugin_generator/helpers.rb', line 8

def plugin_name
  @plugin_name
end

Instance Method Details

#extract_options(plugin_name) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/bosh/plugin_generator/helpers.rb', line 15

def extract_options(plugin_name)
  @plugin_name     = plugin_name
  @plugin_folder   = plugin_name
  @bosh_version    = bosh_gem_latest_version
  @license_type    = options[:license]
  @lib_folder      = File.join(plugin_name, 'lib', 'bosh')
  @spec_folder     = File.join(plugin_name, 'spec')
  @helpers_folder  = File.join(lib_folder, short_plugin_name)
  @commands_folder = File.join(lib_folder, 'cli', 'commands')

  default_context = {
    email: Git.global_config["user.email"],
    author: Git.global_config["user.name"],
    description: "Short description.",
    license: nil,
    full_plugin_name: full_plugin_name,
    short_plugin_name: short_plugin_name,
    class_name: short_plugin_name.split('_').collect(&:capitalize).join,
    bosh_version: bosh_version
  }
  context = default_context.merge(options)
  raise "You need to specify email and author" if context[:email].nil? || context[:author].nil?
  templates_folder = File.expand_path("../../../../templates", __FILE__)
  @generator = Bosh::TemplateGenerator::Generator.new(context, source_folder: templates_folder)
end

#generate_filesObject



41
42
43
44
45
46
47
48
49
# File 'lib/bosh/plugin_generator/helpers.rb', line 41

def generate_files
  generate_command_class
  generate_helpers
  generate_version
  generate_gemspec
  generate_readme
  generate_license if license?
  generate_developer_environment
end