Class: HotCocoa::ApplicationBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/hotcocoa/application_builder.rb

Defined Under Namespace

Classes: Configuration

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeApplicationBuilder

Returns a new instance of ApplicationBuilder.



186
187
188
189
190
# File 'lib/hotcocoa/application_builder.rb', line 186

def initialize
  @sources     = []
  @resources   = []
  @data_models = []
end

Instance Attribute Details

#configHotCocoa::ApplicationBuilder::Configuration

The cached app configuration options



151
152
153
# File 'lib/hotcocoa/application_builder.rb', line 151

def config
  @config
end

#data_modelsArray<String>

Returns:

  • (Array<String>)


168
169
170
# File 'lib/hotcocoa/application_builder.rb', line 168

def data_models
  @data_models
end

#deployBoolean Also known as: deploy?

Whether or not to build the app bundle for deployment by calling macruby_deploy on the generated app bundle

Returns:

  • (Boolean)


158
159
160
# File 'lib/hotcocoa/application_builder.rb', line 158

def deploy
  @deploy
end

#resourcesArray<String>

Returns:

  • (Array<String>)


165
166
167
# File 'lib/hotcocoa/application_builder.rb', line 165

def resources
  @resources
end

#sourcesArray<String>

Returns:

  • (Array<String>)


162
163
164
# File 'lib/hotcocoa/application_builder.rb', line 162

def sources
  @sources
end

Class Method Details

.build(config, opts = {}) ⇒ Object



170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
# File 'lib/hotcocoa/application_builder.rb', line 170

def self.build config, opts = {}
  options = { deploy: false }.merge opts

  builder        = new
  builder.config = config
  builder.deploy = options[:deploy]

  config.sources.each   { |source| builder.add_source_path(source) }
  config.resources.each { |resource| builder.add_resource_path(resource) }
  config.data_models.each do |data|
    builder.add_data_model(data) if File.extname(data) == '.xcdatamodel'
  end

  builder.build
end

Instance Method Details

#add_data_model(model) ⇒ Object



215
216
217
218
219
# File 'lib/hotcocoa/application_builder.rb', line 215

def add_data_model model
  Dir.glob(model).each do |data|
    data_models << data
  end
end

#add_resource_path(resource_file_pattern) ⇒ Object



209
210
211
212
213
# File 'lib/hotcocoa/application_builder.rb', line 209

def add_resource_path resource_file_pattern
  Dir.glob(resource_file_pattern).each do |resource_file|
    resources << resource_file
  end
end

#add_source_path(source_file_pattern) ⇒ Object



203
204
205
206
207
# File 'lib/hotcocoa/application_builder.rb', line 203

def add_source_path source_file_pattern
  Dir.glob(source_file_pattern).each do |source_file|
    sources << source_file
  end
end

#buildObject



192
193
194
195
196
197
198
199
200
201
# File 'lib/hotcocoa/application_builder.rb', line 192

def build
  check_for_bundle_root
  build_bundle_structure
  write_bundle_files
  copy_sources
  copy_resources
  compile_data_models
  embed_framework if deploy?
  copy_icon_file if config.icon_exists?
end