Class: Application::Specification
- Defined in:
- lib/hotcocoa/application/specification.rb
Overview
Inspired by Gem::Specification that is used by Rubygems, this class represents the configuration for a Mac OS X application bundle.
A specification object is used to build your app bundle and define the Info.plist metadata for the application.
Defined Under Namespace
Classes: Error
App Metadata collapse
-
#agent ⇒ Boolean
Whether the app is an daemon with UI or a regular app.
-
#copyright ⇒ Object
The copyright string.
-
#doc_types ⇒ Array<Hash>
The list of document types supported by the application (for document-based applications only).
-
#icon ⇒ String
Path to the icon file.
-
#identifier ⇒ String
The app's unique identifier, in reverse DNS form.
-
#name ⇒ String
Name of the app.
-
#plist ⇒ Hash
Any additional plist values that an application could have.
-
#short_version ⇒ String
The short version for the app.
-
#signature ⇒ String
Four letter code that acts as a signature for the bundle.
-
#type ⇒ String
Four letter code identifying the bundle type.
-
#version ⇒ String
The version of the app, usually including the build number.
App Layout collapse
-
#data_models ⇒ Array<String>
Path to any Core Data
.xcdatamodel
directories that need to be compiled and added to the app bundle. -
#resources ⇒ Array<String>
List of resources that will be copied to the
Contents/Resources
directory inside the app bundle. -
#sources ⇒ Array<String>
List of source code files that will be copied to the app bundle.
Deployment Options collapse
-
#compile ⇒ Boolean
(also: #compile?)
Whether or not to compile ruby source files when embedding.
-
#embed_bridgesupport ⇒ Boolean
(also: #embed_bridgesupport?)
Whether or not to embed BridgeSupport files when embedding the MacRuby framework during deployment.
-
#gems ⇒ Array<Gem::Requirement>
Array of gem names to embed in the app bundle during deployment.
-
#overwrite ⇒ Boolean
(also: #overwrite?)
Whether or not to always make a clean build of the app.
-
#stdlib ⇒ Boolean, Array<String>
Whether to include the Ruby stdlib in the app when embedding MacRuby.
Deployment Options collapse
-
#add_runtime_dependency(dependency, *requirements) ⇒ Object
(also: #add_dependency)
Declares a runtime dependency on a gem, with any given version requirements.
-
#declare_doc_type(&block) ⇒ Object
Declares a document type for your document-driven application.
Class Method Summary collapse
-
.load(file) ⇒ Application::Specification
Read an app spec from file and return what is evaluated.
Instance Method Summary collapse
-
#icon_exists? ⇒ Boolean
Whether or not the icon exists for this spec.
-
#initialize {|_self| ... } ⇒ Specification
constructor
A new instance of Specification.
- #verify! ⇒ Object
Constructor Details
#initialize {|_self| ... } ⇒ Specification
Returns a new instance of Specification.
278 279 280 281 282 283 284 285 286 287 288 289 |
# File 'lib/hotcocoa/application/specification.rb', line 278 def initialize default_attributes.each { |key, value| send "#{key}=", value } unless block_given? msg = 'You must pass a block at initialization to setup the specification' raise Error, msg end yield self # @todo should we verify at initialization or defer until building? verify! end |
Instance Attribute Details
#agent ⇒ Boolean
Whether the app is an daemon with UI or a regular app. Optional.
You can use this flag to hide the dock icon for the app; the default value is false so that apps will have a dock icon by default.
116 117 118 |
# File 'lib/hotcocoa/application/specification.rb', line 116 def agent @agent end |
#compile ⇒ Boolean Also known as: compile?
If you choose to compile, the original source files will be removed.
Whether or not to compile ruby source files when embedding.
Defaults to true
.
197 198 199 |
# File 'lib/hotcocoa/application/specification.rb', line 197 def compile @compile end |
#copyright ⇒ Object
The copyright string. Recommended.
76 77 78 |
# File 'lib/hotcocoa/application/specification.rb', line 76 def copyright @copyright end |
#data_models ⇒ Array<String>
Path to any Core Data .xcdatamodel
directories that need to be
compiled and added to the app bundle.
158 159 160 |
# File 'lib/hotcocoa/application/specification.rb', line 158 def data_models @data_models end |
#doc_types ⇒ Array<Hash>
The list of document types supported by the application (for document-based applications only). Optional
122 123 124 |
# File 'lib/hotcocoa/application/specification.rb', line 122 def doc_types @doc_types end |
#embed_bridgesupport ⇒ Boolean Also known as: embed_bridgesupport?
Whether or not to embed BridgeSupport files when embedding the MacRuby framework during deployment.
Defaults to false. Useful if you need to deploy the app to OS X 10.6.
263 264 265 |
# File 'lib/hotcocoa/application/specification.rb', line 263 def @embed_bridgesupport end |
#gems ⇒ Array<Gem::Requirement>
HotCocoa will automatically be embedded during deployment and is not added to this list.
Array of gem names to embed in the app bundle during deployment.
207 208 209 |
# File 'lib/hotcocoa/application/specification.rb', line 207 def gems @gems end |
#icon ⇒ String
Path to the icon file. Recommended.
83 84 85 |
# File 'lib/hotcocoa/application/specification.rb', line 83 def icon @icon end |
#identifier ⇒ String
The app's unique identifier, in reverse DNS form. Required.
47 48 49 |
# File 'lib/hotcocoa/application/specification.rb', line 47 def identifier @identifier end |
#name ⇒ String
Name of the app. Required.
This name should be less than 16 characters long.
37 38 39 |
# File 'lib/hotcocoa/application/specification.rb', line 37 def name @name end |
#overwrite ⇒ Boolean Also known as: overwrite?
Whether or not to always make a clean build of the app.
Defaults to false.
273 274 275 |
# File 'lib/hotcocoa/application/specification.rb', line 273 def overwrite @overwrite end |
#plist ⇒ Hash
Any additional plist values that an application could have.
Values here will override attributes set by other plist related attributes.
Empty by default.
133 134 135 |
# File 'lib/hotcocoa/application/specification.rb', line 133 def plist @plist end |
#resources ⇒ Array<String>
List of resources that will be copied to the Contents/Resources
directory inside the app bundle.
145 146 147 |
# File 'lib/hotcocoa/application/specification.rb', line 145 def resources @resources end |
#short_version ⇒ String
The short version for the app. Optional.
The short version for an app should be in the standard
"$MAJOR.$MINOR.$PATCHLEVEL"
format.
67 68 69 |
# File 'lib/hotcocoa/application/specification.rb', line 67 def short_version @short_version end |
#signature ⇒ String
Four letter code that acts as a signature for the bundle. Optional.
Defaults to '????', and most apps never set this value.
107 108 109 |
# File 'lib/hotcocoa/application/specification.rb', line 107 def signature @signature end |
#sources ⇒ Array<String>
List of source code files that will be copied to the app bundle.
151 152 153 |
# File 'lib/hotcocoa/application/specification.rb', line 151 def sources @sources end |
#stdlib ⇒ Boolean, Array<String>
Whether to include the Ruby stdlib in the app when embedding MacRuby. Set this to a Boolean to include/exclude the entire standard library from being embedded.
If you want to embed specific files from the standard library, you can do so by setting this attribute a list of the names of libraries you want.
This attribute corresponds to the --[no]-stdlib
and --stdlib
arguments for macruby_deploy
.
Defaults to true.
186 187 188 |
# File 'lib/hotcocoa/application/specification.rb', line 186 def stdlib @stdlib end |
#type ⇒ String
Four letter code identifying the bundle type. Required.
The default value is 'APPL', which specifies that the bundle is an application.
93 94 95 |
# File 'lib/hotcocoa/application/specification.rb', line 93 def type @type end |
#version ⇒ String
The version of the app, usually including the build number. Recommended.
Defaults to '1.0'
.
57 58 59 |
# File 'lib/hotcocoa/application/specification.rb', line 57 def version @version end |
Class Method Details
.load(file) ⇒ Application::Specification
Read an app spec from file and return what is evaluated.
24 25 26 |
# File 'lib/hotcocoa/application/specification.rb', line 24 def self.load file eval File.read(file) end |
Instance Method Details
#add_runtime_dependency(dependency, *requirements) ⇒ Object Also known as: add_dependency
Declares a runtime dependency on a gem, with any given version requirements. If the embedding is also set, then any dependent gems will also be embedded into the app bundle.
This method was liberally borrowed from RubyGems project and has the same semantics here as it does for a gem specification.
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 |
# File 'lib/hotcocoa/application/specification.rb', line 221 def add_runtime_dependency dependency, *requirements requirements = if requirements.empty? then Gem::Requirement.default else requirements.flatten end unless dependency.respond_to?(:name) && dependency.respond_to?(:version_requirements) dependency = Gem::Dependency.new(dependency, requirements, :runtime) end gems << dependency end |
#declare_doc_type(&block) ⇒ Object
Declares a document type for your document-driven application. (see http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Documents/Tasks/ImplementingDocApp.html)
251 252 253 |
# File 'lib/hotcocoa/application/specification.rb', line 251 def declare_doc_type(&block) @doc_types << DocumentTypeSpecification.new(&block) end |
#icon_exists? ⇒ Boolean
Whether or not the icon exists for this spec.
307 308 309 |
# File 'lib/hotcocoa/application/specification.rb', line 307 def icon_exists? @icon ? File.exist?(@icon) : false end |
#verify! ⇒ Object
291 292 293 294 295 296 297 298 299 300 |
# File 'lib/hotcocoa/application/specification.rb', line 291 def verify! verify_name verify_identifier verify_version verify_short_version verify_copyright verify_type verify_signature verify_agent end |