Class: Application::Specification
- Inherits:
-
Object
- Object
- 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)
-
- (Boolean) agent
Whether the app is an daemon with UI or a regular app.
-
- (Object) copyright
The copyright string.
-
- (Array<Hash>) doc_types
The list of document types supported by the application (for document-based applications only).
-
- (String) icon
Path to the icon file.
-
- (String) identifier
The app's unique identifier, in reverse DNS form.
-
- (String) name
Name of the app.
-
- (Hash) plist
Any additional plist values that an application could have.
-
- (String) short_version
The short version for the app.
-
- (String) signature
Four letter code that acts as a signature for the bundle.
-
- (String) type
Four letter code identifying the bundle type.
-
- (String) version
The version of the app, usually including the build number.
App Layout (collapse)
-
- (Array<String>) data_models
Path to any Core Data
.xcdatamodeldirectories that need to be compiled and added to the app bundle. -
- (Array<String>) resources
List of resources that will be copied to the
Contents/Resourcesdirectory inside the app bundle. -
- (Array<String>) sources
List of source code files that will be copied to the app bundle.
Deployment Options (collapse)
-
- (Boolean) compile
(also: #compile?)
Whether or not to compile ruby source files when embedding.
-
- (Boolean) embed_bridgesupport
(also: #embed_bridgesupport?)
Whether or not to embed BridgeSupport files when embedding the MacRuby framework during deployment.
-
- (Array<Gem::Requirement>) gems
Array of gem names to embed in the app bundle during deployment.
-
- (Boolean) overwrite
(also: #overwrite?)
Whether or not to always make a clean build of the app.
-
- (Boolean, Array<String>) stdlib
Whether to include the Ruby stdlib in the app when embedding MacRuby.
Deployment Options (collapse)
-
- (Object) add_runtime_dependency(dependency, *requirements)
(also: #add_dependency)
Declares a runtime dependency on a gem, with any given version requirements.
-
- (Object) declare_doc_type(&block)
Declares a document type for your document-driven application.
Class Method Summary (collapse)
-
+ (Application::Specification) load(file)
Read an app spec from file and return what is evaluated.
Instance Method Summary (collapse)
-
- (Boolean) icon_exists?
Whether or not the icon exists for this spec.
-
- (Specification) initialize {|_self| ... }
constructor
A new instance of Specification.
- - (Object) verify!
Constructor Details
- (Specification) initialize {|_self| ... }
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
- (Boolean) agent
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 |
- (Boolean) compile 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 |
- (Object) copyright
The copyright string. Recommended.
76 77 78 |
# File 'lib/hotcocoa/application/specification.rb', line 76 def copyright @copyright end |
- (Array<String>) data_models
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 |
- (Array<Hash>) doc_types
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 |
- (Boolean) embed_bridgesupport 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 |
- (Array<Gem::Requirement>) gems
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 |
- (String) icon
Path to the icon file. Recommended.
83 84 85 |
# File 'lib/hotcocoa/application/specification.rb', line 83 def icon @icon end |
- (String) identifier
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 |
- (String) name
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 |
- (Boolean) overwrite 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 |
- (Hash) plist
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 |
- (Array<String>) resources
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 |
- (String) short_version
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 |
- (String) signature
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 |
- (Array<String>) sources
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 |
- (Boolean, Array<String>) stdlib
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 |
- (String) type
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 |
- (String) version
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
+ (Application::Specification) load(file)
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
- (Object) add_runtime_dependency(dependency, *requirements) 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 |
- (Object) declare_doc_type(&block)
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 |
- (Boolean) icon_exists?
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 |
- (Object) verify!
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 |