Class: Releasy::Project
- Inherits:
-
Object
- Object
- Releasy::Project
- Includes:
- Rake::DSL, Mixins::CanExcludeEncoding, Mixins::HasPackagers, Mixins::Log
- Defined in:
- lib/releasy/project.rb
Overview
A description of the Ruby application that is being build for release and what packages to make from it.
Constant Summary collapse
- DEFAULT_PACKAGE_FOLDER =
"pkg"
Constants included from Mixins::Log
Mixins::Log::DEFAULT_LOG_LEVEL, Mixins::Log::LOG_LEVELS
Instance Attribute Summary collapse
-
#executable ⇒ String
Name of executable to run (defaults to ‘bin/<underscored_name>’).
-
#exposed_files ⇒ Rake::FileList
Files which should always be copied into the archive folder root, so they are always visible to the user.
-
#files ⇒ Rake::FileList
List of files to include in package.
-
#folder_base ⇒ Object
readonly
Base name of folders that will be created, such as “pkg/my_application” or “pkg/my_application_0_1”.
-
#name ⇒ String
Name of the application, such as “My Application”.
-
#output_path ⇒ String
Folder to output to (defaults to ‘pkg/’).
-
#underscored_name ⇒ String
Project name underscored (as used in file names), which will be derived from #name, but can be manually set.
-
#underscored_version ⇒ String
Version number, underscored so it can be used in file names, which will be derived from #version, but can be manually set.
-
#version ⇒ String
Version number as a string (for example, “1.2.0”).
Instance Method Summary collapse
-
#add_build(type, &block) ⇒ Project
Add a type of build to produce.
-
#add_deploy(type, &block) ⇒ Project
Add a deployment method for archived packages.
-
#add_link(url, title) ⇒ Project
Add a link file to be included in the win32 releases.
-
#create_md5s ⇒ nil
Create MD5 hashes for created archives.
-
#description ⇒ Object
Full name of the project, including the version name E.g.
-
#generate_tasks ⇒ Project
Generates all tasks required by the user.
-
#initialize(&block) ⇒ Project
constructor
Can be used with or without a block to generate building and packaging tasks.
-
#silent ⇒ nil
Make the tasks give no output at all.
- #to_s ⇒ String
-
#underscored_description ⇒ Object
Full underscored name of the project.
-
#verbose ⇒ nil
Make the tasks give more detailed output.
Methods included from Mixins::Log
Methods included from Mixins::CanExcludeEncoding
Methods included from Mixins::HasPackagers
Constructor Details
#initialize { ... } ⇒ Project #initialize {|project| ... } ⇒ Project #initialize ⇒ Project
Can be used with or without a block to generate building and packaging tasks.
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 |
# File 'lib/releasy/project.rb', line 172 def initialize(&block) super() @builders = [] @deployers = [] @links = {} @files = Rake::FileList.new @exposed_files = Rake::FileList.new @output_path = DEFAULT_PACKAGE_FOLDER @create_md5s = false @name = @underscored_name = @underscored_version = nil @version = @executable = nil setup if block_given? if block.arity <= 0 DSLWrapper.new(self, &block) else yield self end generate_tasks end end |
Instance Attribute Details
#executable ⇒ String
Name of executable to run (defaults to ‘bin/<underscored_name>’)
61 62 63 |
# File 'lib/releasy/project.rb', line 61 def executable @executable end |
#exposed_files ⇒ Rake::FileList
Files which should always be copied into the archive folder root, so they are always visible to the user. e.g readme, change-log and/or license files.
61 62 63 |
# File 'lib/releasy/project.rb', line 61 def exposed_files @exposed_files end |
#files ⇒ Rake::FileList
List of files to include in package.
61 62 63 |
# File 'lib/releasy/project.rb', line 61 def files @files end |
#folder_base ⇒ Object (readonly)
Base name of folders that will be created, such as “pkg/my_application” or “pkg/my_application_0_1”
61 62 63 |
# File 'lib/releasy/project.rb', line 61 def folder_base @folder_base end |
#name ⇒ String
Returns Name of the application, such as “My Application”.
72 73 74 |
# File 'lib/releasy/project.rb', line 72 def name @name end |
#output_path ⇒ String
Returns Folder to output to (defaults to ‘pkg/’).
76 77 78 |
# File 'lib/releasy/project.rb', line 76 def output_path @output_path end |
#underscored_name ⇒ String
Project name underscored (as used in file names), which will be derived from #name, but can be manually set.
61 62 63 |
# File 'lib/releasy/project.rb', line 61 def underscored_name @underscored_name end |
#underscored_version ⇒ String
Version number, underscored so it can be used in file names, which will be derived from #version, but can be manually set.
61 62 63 |
# File 'lib/releasy/project.rb', line 61 def underscored_version @underscored_version end |
#version ⇒ String
Returns Version number as a string (for example, “1.2.0”).
74 75 76 |
# File 'lib/releasy/project.rb', line 74 def version @version end |
Instance Method Details
#add_build(type, &block) ⇒ Project
Add a type of build to produce. Must define at least one of these.
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 |
# File 'lib/releasy/project.rb', line 202 def add_build(type, &block) raise ArgumentError, "Unsupported output type #{type}" unless Builders.has_type? type raise ArgumentError, "Already have output #{type.inspect}" if @builders.any? {|b| b.type == type } builder = Builders[type].new(self) @builders << builder if block_given? if block.arity <= 0 DSLWrapper.new(builder, &block) else yield builder end end builder end |
#add_deploy(type, &block) ⇒ Project
Add a deployment method for archived packages.
224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 |
# File 'lib/releasy/project.rb', line 224 def add_deploy(type, &block) raise ArgumentError, "Unsupported deploy type #{type}" unless Deployers.has_type? type raise ArgumentError, "Already have deploy #{type.inspect}" if @deployers.any? {|b| b.type == type } deployer = Deployers[type].new(self) @deployers << deployer if block_given? if block.arity <= 0 DSLWrapper.new(deployer, &block) else yield deployer end end deployer end |
#add_link(url, title) ⇒ Project
Add a link file to be included in the win32 releases. Will create the file title.url for you.
247 248 249 250 251 |
# File 'lib/releasy/project.rb', line 247 def add_link(url, title) @links[url] = title self end |
#create_md5s ⇒ nil
Create MD5 hashes for created archives.
87 |
# File 'lib/releasy/project.rb', line 87 def create_md5s; @create_md5s = true; nil; end |
#description ⇒ Object
Full name of the project, including the version name E.g. “My Application” or “My Application 0.1”
291 |
# File 'lib/releasy/project.rb', line 291 def description; name ? "#{name}#{version ? " #{version}" : ""}" : nil; end |
#generate_tasks ⇒ Project
Generates all tasks required by the user. Automatically called at the end of the block, if #initialize is given a block.
255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 |
# File 'lib/releasy/project.rb', line 255 def generate_tasks raise ConfigError, "Must use #add_build at least once before tasks can be generated" if @builders.empty? # Even if there are builders specified, none may work on this platform. return if active_builders.empty? build_outputs = [] build_groups = Hash.new {|h, k| h[k] = [] } active_builders.each do |builder| builder.send :generate_tasks task_name = "build:#{builder.type.to_s.tr("_", ":")}" if builder.type.to_s =~ /_/ task_group = builder.send :task_group build_groups[task_group] << task_name build_outputs << "build:#{task_group}" else build_outputs << task_name end end build_groups.each_pair do |group, tasks| desc "Build all #{group}" task "build:#{group}" => tasks end desc "Build #{description}" task "build" => build_outputs generate_archive_tasks self end |
#silent ⇒ nil
Make the tasks give no output at all.
83 |
# File 'lib/releasy/project.rb', line 83 def silent; Mixins::Log.log_level = :silent; end |
#to_s ⇒ String
98 |
# File 'lib/releasy/project.rb', line 98 def to_s; "<#{self.class}#{name ? " #{name}" : ""}#{version ? " #{version}" : ""}>"; end |
#underscored_description ⇒ Object
Full underscored name of the project. E.g. “my_application” or “my_application_0_1”
293 |
# File 'lib/releasy/project.rb', line 293 def underscored_description; underscored_name ? "#{underscored_name}#{version ? "_#{underscored_version}" : ""}" : nil; end |