Class: Omnibus::Generator

Inherits:
Thor::Group
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/omnibus/generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.source_rootObject

Set the source root for Thor


70
71
72
# File 'lib/omnibus/generator.rb', line 70

def source_root
  File.expand_path('../generator_files', __FILE__)
end

Instance Method Details

#create_bff_assetsObject


106
107
108
109
110
# File 'lib/omnibus/generator.rb', line 106

def create_bff_assets
  return unless options[:bff_assets]

  copy_file(resource_path('bff/gen.template.erb'), "#{target}/resources/#{name}/bff/gen.template.erb")
end

#create_deb_assetsObject


112
113
114
115
116
117
118
# File 'lib/omnibus/generator.rb', line 112

def create_deb_assets
  return unless options[:deb_assets]

  copy_file(resource_path('deb/conffiles.erb'), "#{target}/resources/#{name}/deb/conffiles.erb")
  copy_file(resource_path('deb/control.erb'), "#{target}/resources/#{name}/deb/control.erb")
  copy_file(resource_path('deb/md5sums.erb'), "#{target}/resources/#{name}/deb/md5sums.erb")
end

#create_dmg_assetsObject


120
121
122
123
124
125
# File 'lib/omnibus/generator.rb', line 120

def create_dmg_assets
  return unless options[:dmg_assets]

  copy_file(resource_path('dmg/background.png'), "#{target}/resources/#{name}/dmg/background.png")
  copy_file(resource_path('dmg/icon.png'), "#{target}/resources/#{name}/dmg/icon.png")
end

#create_example_software_definitionsObject


86
87
88
# File 'lib/omnibus/generator.rb', line 86

def create_example_software_definitions
  template('config/software/zlib.rb.erb', "#{target}/config/software/#{name}-zlib.rb", template_options)
end

#create_kitchen_filesObject


90
91
92
93
94
# File 'lib/omnibus/generator.rb', line 90

def create_kitchen_files
  template('.kitchen.local.yml.erb', "#{target}/.kitchen.local.yml", template_options)
  template('.kitchen.yml.erb', "#{target}/.kitchen.yml", template_options)
  template('Berksfile.erb', "#{target}/Berksfile", template_options)
end

#create_msi_assetsObject


127
128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/omnibus/generator.rb', line 127

def create_msi_assets
  return unless options[:msi_assets]

  copy_file(resource_path('msi/localization-en-us.wxl.erb'), "#{target}/resources/#{name}/msi/localization-en-us.wxl.erb")
  copy_file(resource_path('msi/parameters.wxi.erb'), "#{target}/resources/#{name}/msi/parameters.wxi.erb")
  copy_file(resource_path('msi/source.wxs.erb'), "#{target}/resources/#{name}/msi/source.wxs.erb")

  copy_file(resource_path('msi/assets/LICENSE.rtf'), "#{target}/resources/#{name}/msi/assets/LICENSE.rtf")
  copy_file(resource_path('msi/assets/banner_background.bmp'), "#{target}/resources/#{name}/msi/assets/banner_background.bmp")
  copy_file(resource_path('msi/assets/dialog_background.bmp'), "#{target}/resources/#{name}/msi/assets/dialog_background.bmp")
  copy_file(resource_path('msi/assets/project.ico'), "#{target}/resources/#{name}/msi/assets/project.ico")
  copy_file(resource_path('msi/assets/project_16x16.ico'), "#{target}/resources/#{name}/msi/assets/project_16x16.ico")
  copy_file(resource_path('msi/assets/project_32x32.ico'), "#{target}/resources/#{name}/msi/assets/project_32x32.ico")
end

#create_package_scriptsObject


96
97
98
99
100
101
102
103
104
# File 'lib/omnibus/generator.rb', line 96

def create_package_scripts
  %w(preinst prerm postinst postrm).each do |package_script|
    script_path = "#{target}/package-scripts/#{name}/#{package_script}"
    template("package_scripts/#{package_script}.erb", script_path, template_options)

    # Ensure the package script is executable
    chmod(script_path, 0755)
  end
end

#create_pkg_assetsObject


142
143
144
145
146
147
148
149
# File 'lib/omnibus/generator.rb', line 142

def create_pkg_assets
  return unless options[:pkg_assets]

  copy_file(resource_path('pkg/background.png'), "#{target}/resources/#{name}/pkg/background.png")
  copy_file(resource_path('pkg/license.html.erb'), "#{target}/resources/#{name}/pkg/license.html.erb")
  copy_file(resource_path('pkg/welcome.html.erb'), "#{target}/resources/#{name}/pkg/welcome.html.erb")
  copy_file(resource_path('pkg/distribution.xml.erb'), "#{target}/resources/#{name}/pkg/distribution.xml.erb")
end

#create_project_definitionObject


82
83
84
# File 'lib/omnibus/generator.rb', line 82

def create_project_definition
  template('config/projects/project.rb.erb', "#{target}/config/projects/#{name}.rb", template_options)
end

#create_project_filesObject


75
76
77
78
79
80
# File 'lib/omnibus/generator.rb', line 75

def create_project_files
  template('Gemfile.erb', "#{target}/Gemfile", template_options)
  template('gitignore.erb', "#{target}/.gitignore", template_options)
  template('README.md.erb', "#{target}/README.md", template_options)
  template('omnibus.rb.erb', "#{target}/omnibus.rb", template_options)
end

#create_rpm_assetsObject


151
152
153
154
155
156
157
# File 'lib/omnibus/generator.rb', line 151

def create_rpm_assets
  return unless options[:rpm_assets]

  copy_file(resource_path('rpm/rpmmacros.erb'), "#{target}/resources/#{name}/rpm/rpmmacros.erb")
  copy_file(resource_path('rpm/signing.erb'), "#{target}/resources/#{name}/rpm/signing.erb")
  copy_file(resource_path('rpm/spec.erb'), "#{target}/resources/#{name}/rpm/spec.erb")
end