HotCocoa / hotcocoa

MacRuby HotCocoa UI library
120 stars 8 forks source link

Allow application config/specification in Ruby #10

Closed isaac closed 13 years ago

isaac commented 13 years ago

It would be good if you could write the app specification in Ruby as well as YAML, like in rubygems. For example:

HotCocoa::Application.new 'app.appspec' # or
app_spec = HotCocoa::ApplicationSpecification.new { |config| config.name = "App" }
HotCocoa::Application.new app_spec

If you could use Ruby in the specification/config it may not be necessary to complicate the build.yml with syntax like this:

https://github.com/ferrous26/hotcocoa/commit/f9ce962594b6641c7aa7ad60fca58459d0698ece

ferrous26 commented 13 years ago

It took me a while to get started on it, but the progress can now be tracked in the appspec branch.

isaac commented 13 years ago

When I was porting the YAML config files to specifications there were I few things that I was not sure how to deal with:

  1. https://github.com/ferrous26/hotcocoa/blob/master/test/fixtures/calculator.yml#L2 - I'm not sure if this load attribute is ever used in the hotcocoa codebase - is this something we want to port across to the ruby specifications or should it work by convention like rubygems?
  2. Arbitrary attributes like this: https://github.com/ferrous26/hotcocoa/blob/master/test/fixtures/calculator.yml#L3 - is there any place for these in the specification (maybe they could go in the plist) or should they be completely separate?
ferrous26 commented 13 years ago

Hmm,

I'm not sure where the load attribute came from, and it is not used during application building.

I'm trying to support arbitrary plist values with the plist attribute, any other arbitrary metadata would have to be stored elsewhere. Though I'm not sure what types of arbitrary things someone would want to stick in their app spec, so I do not think that behaviour should be supported right now (or ever).

ferrous26 commented 13 years ago

Actually, looks like the load attribute came from the app template. I'm guessing it is just some forgotten about option that may have been used to specify which file to load from main.m; but the application loading process is different now and that option is obsolete.

ferrous26 commented 13 years ago

I rebased the branch so that it could include the recent fix for bindings. I also updated the template, and it can build apps using an app spec.

One thing I am not sure about is if the app spec should be kept in the Rakefile or if it should be put in its own file. I have no strong feelings either way. @isaac, what do you think?

isaac commented 13 years ago

I think that by default it should be in its own file. Unless there is a good reason not to I think we should follow the same convention as rubygems. When browsing gems on GitHub one of the first things I look for is the gemspec to check dependencies - its good to know its (almost) always there in the root project directory. I guess there is nothing to stop someone from moving it into their Rakefile if that is their preference though.

ferrous26 commented 13 years ago

I'm thinking we should change Specification#initialize to #instance_eval the block instead of yielding self.

ferrous26 commented 13 years ago

Ok, so the new builder can build an deploy apps, so it is almost ready enough to be merged into master.

It still needs more tests, especially in the application builder, and some more documentation, but I'll be chipping away at tests and documentation forever anyways...

So tonight I'll check everything over one more time and merge it.