Class: Vanagon::Project::DSL
- Inherits:
-
Object
- Object
- Vanagon::Project::DSL
- Defined in:
- lib/vanagon/project/dsl.rb
Instance Method Summary collapse
-
#_project ⇒ Vanagon::Project
Accessor for the project.
-
#bill_of_materials(target) ⇒ Object
This method will write the project’s bill-of-materials to a designated directory during package creation.
-
#cleanup_during_build ⇒ Object
Toggle to apply additional cleanup during the build for space constrained systems.
-
#component(name) ⇒ Object
Adds a component to the project.
-
#description(descr) ⇒ Object
Sets the description of the project.
-
#directory(dir, mode: nil, owner: nil, group: nil) ⇒ Object
Adds a directory to the list of directories provided by the project, to be included in any packages of the project.
-
#homepage(page) ⇒ Object
Sets the homepage for the project.
-
#identifier(ident) ⇒ Object
Sets the identifier for the project.
-
#initialize(name, platform, include_components = []) ⇒ Vanagon::Project::DSL
constructor
Constructor for the DSL object.
-
#license(lic) ⇒ Object
Sets the license for the project.
-
#method_missing(method, *args) ⇒ Object
Project attributes and DSL methods defined below.
-
#name(the_name) ⇒ Object
Resets the name of the project.
-
#noarch ⇒ Object
Sets the project to be architecture independent, or noarch.
-
#project(name, &block) ⇒ Object
Primary way of interacting with the DSL.
-
#provides(provide, version = nil) ⇒ Object
Indicates that this component provides a system level package.
-
#register_rewrite_rule(protocol, rule) ⇒ Object
Sets up a rewrite rule for component sources for a given protocol.
-
#release(rel) ⇒ Object
Sets the release for the project.
-
#replaces(replacement, version = nil) ⇒ Object
Indicates that this component replaces a system level package.
-
#requires(req) ⇒ Object
Sets the run time requirements for the project.
-
#setting(name, value) ⇒ Object
Sets a key value pair on the settings hash of the project.
-
#target_repo(repo) ⇒ Object
Adds a target repo for the project.
-
#user(name, group: nil, shell: nil, is_system: false, homedir: nil) ⇒ Object
Add a user to the project.
-
#vendor(vend) ⇒ Object
Sets the vendor for the project.
-
#version(ver) ⇒ Object
Sets the version for the project.
-
#version_from_git ⇒ Object
Sets the version for the project based on a git describe of the directory that holds the configs.
-
#write_version_file(target) ⇒ Object
This method will write the project’s version to a designated file during package creation.
Constructor Details
#initialize(name, platform, include_components = []) ⇒ Vanagon::Project::DSL
Constructor for the DSL object
15 16 17 18 19 |
# File 'lib/vanagon/project/dsl.rb', line 15 def initialize(name, platform, include_components = []) @name = name @project = Vanagon::Project.new(@name, platform) @include_components = include_components.to_set end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
Project attributes and DSL methods defined below
All purpose getter. This object, which is passed to the project block, won’t have easy access to the attributes of the @project, so we make a getter for each attribute.
We only magically handle get_ methods, any other methods just get the standard method_missing treatment.
47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/vanagon/project/dsl.rb', line 47 def method_missing(method, *args) attribute_match = method.to_s.match(/get_(.*)/) if attribute_match attribute = attribute_match.captures.first @project.send(attribute) elsif @project.settings.has_key?(method) return @project.settings[method] else super end end |
Instance Method Details
#_project ⇒ Vanagon::Project
Accessor for the project.
32 33 34 |
# File 'lib/vanagon/project/dsl.rb', line 32 def _project @project end |
#bill_of_materials(target) ⇒ Object
This method will write the project’s bill-of-materials to a designated directory during package creation.
219 220 221 |
# File 'lib/vanagon/project/dsl.rb', line 219 def bill_of_materials(target) @project.bill_of_materials = Vanagon::Common::Pathname.new(target) end |
#cleanup_during_build ⇒ Object
Toggle to apply additional cleanup during the build for space constrained systems
207 208 209 |
# File 'lib/vanagon/project/dsl.rb', line 207 def cleanup_during_build @project.cleanup = true end |
#component(name) ⇒ Object
Adds a component to the project
178 179 180 181 182 183 184 |
# File 'lib/vanagon/project/dsl.rb', line 178 def component(name) puts "Loading #{name}" if @include_components.empty? or @include_components.include?(name) component = Vanagon::Component.load_component(name, File.join(Vanagon::Driver.configdir, "components"), @project.settings, @project.platform) @project.components << component end end |
#description(descr) ⇒ Object
Sets the description of the project. Mainly for use in packaging.
70 71 72 |
# File 'lib/vanagon/project/dsl.rb', line 70 def description(descr) @project.description = descr end |
#directory(dir, mode: nil, owner: nil, group: nil) ⇒ Object
Adds a directory to the list of directories provided by the project, to be included in any packages of the project
146 147 148 |
# File 'lib/vanagon/project/dsl.rb', line 146 def directory(dir, mode: nil, owner: nil, group: nil) @project.directories << Vanagon::Common::Pathname.new(dir, mode: mode, owner: owner, group: group) end |
#homepage(page) ⇒ Object
Sets the homepage for the project. Mainly for use in packaging.
84 85 86 |
# File 'lib/vanagon/project/dsl.rb', line 84 def homepage(page) @project.homepage = page end |
#identifier(ident) ⇒ Object
Sets the identifier for the project. Mainly for use in OSX packaging.
171 172 173 |
# File 'lib/vanagon/project/dsl.rb', line 171 def identifier(ident) @project.identifier = ident end |
#license(lic) ⇒ Object
Sets the license for the project. Mainly for use in packaging.
164 165 166 |
# File 'lib/vanagon/project/dsl.rb', line 164 def license(lic) @project.license = lic end |
#name(the_name) ⇒ Object
Resets the name of the project. Is useful for dynamically changing the project name.
77 78 79 |
# File 'lib/vanagon/project/dsl.rb', line 77 def name(the_name) @project.name = the_name end |
#noarch ⇒ Object
Sets the project to be architecture independent, or noarch
194 195 196 |
# File 'lib/vanagon/project/dsl.rb', line 194 def noarch @project.noarch = true end |
#project(name, &block) ⇒ Object
Primary way of interacting with the DSL
25 26 27 |
# File 'lib/vanagon/project/dsl.rb', line 25 def project(name, &block) block.call(self) end |
#provides(provide, version = nil) ⇒ Object
Indicates that this component provides a system level package. Provides can be collected and used by the project and package.
107 108 109 |
# File 'lib/vanagon/project/dsl.rb', line 107 def provides(provide, version = nil) @project.provides << OpenStruct.new(:provide => provide, :version => version) end |
#register_rewrite_rule(protocol, rule) ⇒ Object
Sets up a rewrite rule for component sources for a given protocol
202 203 204 |
# File 'lib/vanagon/project/dsl.rb', line 202 def register_rewrite_rule(protocol, rule) Vanagon::Component::Source.register_rewrite_rule(protocol, rule) end |
#release(rel) ⇒ Object
Sets the release for the project. Mainly for use in packaging.
121 122 123 |
# File 'lib/vanagon/project/dsl.rb', line 121 def release(rel) @project.release = rel end |
#replaces(replacement, version = nil) ⇒ Object
Indicates that this component replaces a system level package. Replaces can be collected and used by the project and package.
99 100 101 |
# File 'lib/vanagon/project/dsl.rb', line 99 def replaces(replacement, version = nil) @project.replaces << OpenStruct.new(:replacement => replacement, :version => version) end |
#requires(req) ⇒ Object
Sets the run time requirements for the project. Mainly for use in packaging.
91 92 93 |
# File 'lib/vanagon/project/dsl.rb', line 91 def requires(req) @project.requires << req end |
#setting(name, value) ⇒ Object
Sets a key value pair on the settings hash of the project
63 64 65 |
# File 'lib/vanagon/project/dsl.rb', line 63 def setting(name, value) @project.settings[name] = value end |
#target_repo(repo) ⇒ Object
Adds a target repo for the project
189 190 191 |
# File 'lib/vanagon/project/dsl.rb', line 189 def target_repo(repo) @project.repo = repo end |
#user(name, group: nil, shell: nil, is_system: false, homedir: nil) ⇒ Object
Add a user to the project
157 158 159 |
# File 'lib/vanagon/project/dsl.rb', line 157 def user(name, group: nil, shell: nil, is_system: false, homedir: nil) @project.user = Vanagon::Common::User.new(name, group, shell, is_system, homedir) end |
#vendor(vend) ⇒ Object
Sets the vendor for the project. Used in packaging artifacts.
136 137 138 |
# File 'lib/vanagon/project/dsl.rb', line 136 def vendor(vend) @project.vendor = vend end |
#version(ver) ⇒ Object
Sets the version for the project. Mainly for use in packaging.
114 115 116 |
# File 'lib/vanagon/project/dsl.rb', line 114 def version(ver) @project.version = ver.gsub('-', '.') end |
#version_from_git ⇒ Object
Sets the version for the project based on a git describe of the directory that holds the configs. Requires that a git tag be present and reachable from the current commit in that repository.
129 130 131 |
# File 'lib/vanagon/project/dsl.rb', line 129 def version_from_git @project.version = Vanagon::Utilities.git_version(File.("..", Vanagon::Driver.configdir)).gsub('-', '.') end |