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



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

def source_root
  File.expand_path("generator_files", __dir__)
end

Instance Method Details

#create_appx_assetsObject



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

def create_appx_assets
  return unless options[:appx_assets]

  copy_file(resource_path("appx/AppxManifest.xml.erb"), "#{target}/resources/#{name}/appx/AppxManifest.xml.erb")
  copy_file(resource_path("appx/assets/clear.png"), "#{target}/resources/#{name}/appx/assets/clear.png")
end

#create_bff_assetsObject



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

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



125
126
127
128
129
130
131
# File 'lib/omnibus/generator.rb', line 125

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



133
134
135
136
137
138
# File 'lib/omnibus/generator.rb', line 133

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



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

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

#create_kitchen_filesObject



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

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



140
141
142
143
144
145
146
147
148
149
150
151
152
153
# File 'lib/omnibus/generator.rb', line 140

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



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

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



155
156
157
158
159
160
161
162
# File 'lib/omnibus/generator.rb', line 155

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



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

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

#create_project_filesObject



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

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



164
165
166
167
168
169
170
# File 'lib/omnibus/generator.rb', line 164

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