hotcocoa 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
data/.yardopts CHANGED
@@ -6,9 +6,10 @@
6
6
  --readme README.markdown
7
7
  lib/**/*.rb
8
8
  -
9
- History.txt
9
+ History.markdown
10
+ docs/Tutorial.markdown
10
11
  docs/Contributors.markdown
12
+ docs/Mappings.markdown
11
13
  docs/Overview.markdown
12
14
  docs/Resources.markdown
13
- docs/Tutorial.markdown
14
- docs/Mappings.markdown
15
+ docs/Troubleshooting.markdown
data/History.markdown ADDED
@@ -0,0 +1,45 @@
1
+ # Release History
2
+
3
+ ## 0.6.1 2011-12-4
4
+
5
+ * Enhancements:
6
+ * Bridgesupport embedding now enabled by default for new projects
7
+ * Ensure that the short version is set in an app bundles Info.plist
8
+ * Begin overhauling the documentation
9
+ * Better error handling for the DelegateBuilder
10
+ * Document and refactor layout manager internals
11
+
12
+ * Fixes:
13
+ * Fixed some UI glitches with the Demo app
14
+ * The application builder now sets the copyright string in an app bundles Info.plist
15
+ * DelegateBuilder no longer crashes when parameters were given as Symbols
16
+
17
+ ## 0.6.0 2011-10-14
18
+
19
+ * 10 enhancements:
20
+ + New application builder to work with MacRuby 0.11
21
+ + Old application builder is deprecated
22
+ + New application templates now use an appspec, similar to a gemspec
23
+ + config.yml is now deprecated
24
+ + Lazier loading for mappings (may break custom mappings!)
25
+ + API documention (~67% coverage so far)
26
+ + Regression tests (< 67% coverage so far)
27
+ + Updating and porting of the tutorial documentation (~40% complete)
28
+ + HotCocoa now works when compiled (HotCocoa will boot ~2.5 faster)
29
+ + HotCocoa is now leaner
30
+ + Various bug fixes
31
+
32
+ * 4 new mappings:
33
+ + bonjour_service => NSNetService
34
+ + bonjour_browser => NSNetServiceBrowser
35
+ + line => NSBezierPath
36
+ + tracking_area => NSTrackingArea
37
+
38
+ * 2 graphics improvements:
39
+ + Image class works with more image types
40
+ + Image class can save images
41
+
42
+ ## 0.0.1 2009-11-07
43
+
44
+ * 1 major enhancement:
45
+ + Initial release
data/README.markdown CHANGED
@@ -1,63 +1,63 @@
1
- # hotcocoa
2
-
3
- * [http://github.com/ferrous26/hotcocoa](http://github.com/ferrous26/hotcocoa)
4
- * [Documentation](http://rdoc.info/github/ferrous26/hotcocoa/master/frames)
5
-
6
- ## Description
1
+ # HotCocoa
7
2
 
8
3
  HotCocoa is a thin, idiomatic Ruby layer that sits above Cocoa and
9
4
  other frameworks. The goal of the project is to simplify the process of creating
10
- and configuring Cocoa objects used when building native Mac apps. To get more
11
- information on HotCocoa (including tutorials) see
12
- [http://macruby.org](http://macruby.org).
13
-
14
- ## Note
15
-
16
- HotCocoa has ambitious goals that are difficult to accomplish with the input of
17
- only a few people. Feedback is the easiest way to contribute and goes a long way
18
- to making sure HotCocoa is on the right path to accomplishing those goals.
19
-
20
- There are still some APIs that need documentation, regression tests that need to
21
- be written, and tutorials to be updated; but new features and improved performance
22
- will also be coming in the not too distant future. If you find issues with
23
- HotCocoa, don't hesitate to open tickets on Github (or try to fix it yourself and
24
- send in the patch :)).
5
+ and configuring Cocoa objects used when building native Mac apps.
25
6
 
26
- There are a list of
27
- [gotchas](https://github.com/ferrous26/hotcocoa/wiki/Gotchas) in the
28
- wiki.
7
+ ## Using
29
8
 
30
- ## Install
9
+ ### Installation
31
10
 
32
11
  From rubygems:
33
12
 
34
- sudo macgem install hotcocoa --pre
13
+ $ sudo macgem install hotcocoa
14
+
15
+ Or to get the bleeding edge, you can clone the repository on Github and install from there:
35
16
 
36
- You need to add the `--pre` flag since HotCocoa 0.6 is not officially released yet.
37
- Or you can clone the repository on Github and install from there:
17
+ $ git clone git://github.com/ferrous26/hotcocoa
18
+ $ cd hotcocoa
19
+ $ sudo macrake install
38
20
 
39
- git clone git://github.com/ferrous26/hotcocoa
40
- cd hotcocoa
41
- sudo macrake install
21
+ __Note__: You will need the Mac OS X developer tools in order
22
+ to build apps. Xcode is not required, but the compiler toolchain is
23
+ needed.
42
24
 
43
- __Note__: If you are on Snow Leopard, you will also need the
25
+ __Note 2__: If you are on Snow Leopard, you will also need the
44
26
  [Bridge Support Preview](http://www.macruby.org/files/BridgeSupport%20Preview%203.zip)
45
27
  in order to run HotCocoa. Read about it on the
46
28
  [MacRuby Blog](http://www.macruby.org/blog/2010/10/08/bridgesupport-preview.html).
47
29
 
48
- __Note 2__: You will also need the Mac OS X developer tools in order
49
- to build apps. Xcode is not required, but the compiler toolchain is
50
- needed.
30
+ ### Documentation
31
+
32
+ The documentation can be found on [rdoc.info](http://rdoc.info/github/ferrous26/hotcocoa/master/frames).
33
+
34
+ The most important pages are:
35
+
36
+ * [the overview](http://rubydoc.info/github/ferrous26/hotcocoa/master/file/docs/Overview.markdown)
37
+ * [a guide to the mappings](http://rubydoc.info/github/ferrous26/hotcocoa/master/file/docs/Mappings.markdown)
38
+ * [troubleshooting](http://rubydoc.info/github/ferrous26/hotcocoa/master/file/docs/Troubleshooting.markdown)
39
+
40
+ The documentation currently does not cover the shipped mappings right now due to the
41
+ way that mappings are implemented; a YARD plug-in or new YARD features
42
+ will be needed (stay tuned).
43
+
44
+ ### Examples
45
+
46
+ Have a look in the [examples folder](https://github.com/ferrous26/hotcocoa/tree/master/examples) to see some sample apps which use HotCocoa.
51
47
 
52
- ## Documentation
48
+ ## Contributing
53
49
 
54
- Documentation is a work in progress; some of the documentation is
55
- being ported from the MacRuby website and you can still view it there.
50
+ HotCocoa has ambitious goals that are difficult to accomplish with the input of
51
+ only a few people. Feedback is the easiest way to contribute and goes a long way
52
+ to making sure HotCocoa is on the right path to accomplishing those goals.
56
53
 
57
- The documentation currently does not include the mappings right now due to the
58
- way that mappings are implemented; a YARD plug-in will be needed for thatv
54
+ There are still some APIs that need documentation, regression tests that need to
55
+ be written, and tutorials to be updated; but new features and improved performance
56
+ will also be coming in the not too distant future. If you find issues with
57
+ HotCocoa, don't hesitate to open tickets on Github (or try to fix it yourself and
58
+ send in the patch :)).
59
59
 
60
- ## Contributing to HotCocoa
60
+ ### Submitting patches
61
61
 
62
62
  * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
63
63
  * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
@@ -0,0 +1,189 @@
1
+ Originally written by Dan Sinclair, this tutorial has been updated for
2
+ newer HotCocoa features.
3
+
4
+ I've had my eye on giving HotCocoa a test run for a while now. Other
5
+ things have conspired to come up over the last few months so I haven't
6
+ had a chance to give it a spin. That is, until now. I started poking
7
+ at it the other day, a few things still confuse me, but I'm getting
8
+ there.
9
+
10
+ I figured I'd write stuff down as I plow my way through the code and
11
+ create a simple little application. The application is nothing fancy,
12
+ I'm going to query [PostRank](http://www.postrank.com) and pull back
13
+ engagement information on a feed entered into a text box. This will be
14
+ a multi-part tutorial.
15
+
16
+ In the usual fashion, let's start at the start. What is HotCocoa?
17
+ Well, HotCocoa is a layer of Ruby code that sits on top of the Mac OS
18
+ X frameworks including
19
+ [Cocoa](http://developer.apple.com/cocoa/). HotCocoa is part of the
20
+ [MacRuby](http://www.macruby.org) distribution which will ship with
21
+ figure versions of OS X. MacRuby is a port of Ruby 1.9 to run on top
22
+ of Objective-C.
23
+
24
+ I'm going to assume you have MacRuby installed for this tutorial.
25
+
26
+ The HotCocoa developers make life easy to get started developing your
27
+ application. There is a `hotcocoa` command that is installed when you
28
+ install MacRuby. This will create the basic application structure and
29
+ Rakefile to get you up and running.
30
+
31
+ titania:Development dj2$ hotcocoa Postie
32
+
33
+ We can then execute our application by changing into the `Postie`
34
+ directory and executing `macrake`. *Note*, this uses `mac`rake and not
35
+ regular rake. MacRuby installs alongside the normal Ruby runtime on OS
36
+ X. You'll need to make sure you use `macrake`, `macirb`, `macgem` and
37
+ `macruby` to work with the MacRuby versions. You should see a `Hello
38
+ from HotCooca` window if everything worked correctly.
39
+
40
+ ![Hello from HotCocoa](images/hello_from_hotcocoa.png)
41
+
42
+ You'll notice that you now have a Postie.app in your root
43
+ directory. This application can be executed by double clicking like
44
+ any other Mac application, although, you'll need MacRuby installed for
45
+ it to execute. You can also execute `macruby lib/application.rb` to
46
+ execute the application. This allows passing flags to `macruby` for
47
+ things like enabling debug mode.
48
+
49
+ Let's take a quick look at the files generated by the `hotcocoa`
50
+ command.
51
+
52
+ ```sh
53
+ ./Rakefile
54
+ ./config/build.yml
55
+ ./resources/HotCocoa.icns
56
+ ./lib/application.rb
57
+ ./lib/menu.rb
58
+ ```
59
+
60
+ The `build.yml` file contains information used by `hotcocoa` to build
61
+ your application. This includes things like the name, version, icon
62
+ and source files. The icon, by default, is `HotCocoa.icns`. The main
63
+ files we're interested in are `application.rb` and `menu.rb`.
64
+
65
+ ```ruby
66
+ module HotCocoa
67
+ def application_menu
68
+ menu do |main|
69
+ main.submenu :apple do |apple|
70
+ apple.item :about, :title => "About #{NSApp.name}"
71
+ apple.separator
72
+ apple.item :preferences, :key => ","
73
+ apple.separator
74
+ apple.submenu :services
75
+ apple.separator
76
+ apple.item :hide, :title => "Hide #{NSApp.name}", :key => "h"
77
+ apple.item :hide_others, :title => "Hide Others", :key => "h", :modifiers => [:command, :alt]
78
+ apple.item :show_all, :title => "Show All"
79
+ apple.separator
80
+ apple.item :quit, :title => "Quit #{NSApp.name}", :key => "q"
81
+ end
82
+ main.submenu :file do |file|
83
+ file.item :new, :key => "n"
84
+ file.item :open, :key => "o"
85
+ end
86
+ main.submenu :window do |win|
87
+ win.item :minimize, :key => "m"
88
+ win.item :zoom
89
+ win.separator
90
+ win.item :bring_all_to_front, :title => "Bring All to Front", :key => "o"
91
+ end
92
+ main.submenu :help do |help|
93
+ help.item :help, :title => "#{NSApp.name} Help"
94
+ end
95
+ end
96
+ end
97
+ end
98
+ ```
99
+
100
+ The `menu.rb` file contains information about the menu for our
101
+ applcation. This includes the menu names, hot keys, modifiers and
102
+ general layout.
103
+
104
+ The `:apple` submenu is special and will appear with a menu title
105
+ based on your application name, as is typical for OS X
106
+ applications. For the other submenus, by default, the menu title will
107
+ be the capitalized version of the symbol name converted to a
108
+ string. You can also provide a `:title => 'foo'` option to specify a
109
+ different name. `menu.submenu :postrank, :title => 'PostRank'`.
110
+
111
+ The symbol provided to each submenu `item`, e.g. `file.item :new` will
112
+ be used to form the name of the method invoked in your application
113
+ delegate. The methods are named `on_<key>`. For our `:new` item the
114
+ `on_new` menu item will be invoked. If there is no `on_<key>` method
115
+ the menu item will be disabled. As you can see above you can also
116
+ specify `:modifiers` and `:key` equivalents for your items.
117
+
118
+ As with the menu titles, the items names will be formed from
119
+ capitalizing the symbol provided unless a `:title` is provided.
120
+
121
+ In the case of `Postie` I've erased everything but the `:apple`
122
+ submenu for now. I don't need any extra menu items at the moment. This
123
+ also means all of the `on_*` methods can be removed from
124
+ `application.rb`.
125
+
126
+ The default `application.rb` provided by the `hotcocoa` command is
127
+ pretty short.
128
+
129
+ ```ruby
130
+ require 'hotcocoa'
131
+
132
+ class Application
133
+ include HotCocoa
134
+
135
+ def start
136
+ application(:name => "Postie") do |app|
137
+ app.delegate = self
138
+ window(:frame => [100, 100, 500, 500], :title => "Postie") do |win|
139
+ win << label(:text => "Hello from HotCocoa", :layout => {:start => false})
140
+ win.will_close { exit }
141
+ end
142
+ end
143
+ end
144
+ end
145
+
146
+ Application.new.start
147
+ ```
148
+
149
+ Let's take a quick look and see if we can figure out what's going
150
+ on. We need to `require hotcocoa'` to get access to the needed
151
+ HotCocoa classes. We then `include HotCocoa` into our `Application`
152
+ class to make everything shorter. Feel free to rename `Application`
153
+ just do it in the class definition and at the bottom of the file.
154
+
155
+ Jumping to the bottom, you can see we're calling
156
+ `Application.new.start` so the `Application#start` method will be
157
+ invoked. It's worth noting, the application will not return from
158
+ `Application#start`.
159
+
160
+ Going back to `Application#start` we call `application` to create our
161
+ application, setting the title as desired. We then set ourselves as
162
+ the application delegate. This means that our class will receive all
163
+ of the callbacks that are called on the Cocoa application. This
164
+ includes the menu `on_*`callbacks we talked about earlier.
165
+
166
+ We then proceed to create a `window`. We're setting a `:frame` on the
167
+ window to position it at X 100, Y 100 (from the bottom left) with a
168
+ width of 500 and height of 500. We `:title` the window as `Postie`.
169
+ If you don't want to specify the entire frame of the window you can
170
+ specify just the `:size => [500, 500]` of the window. You can also
171
+ specify `:center => true` to center the window on the desktop. If you
172
+ look at the Objective-C documentation for NSWindow the options
173
+ available in Obj-C are available in the HotCocoa layer.
174
+
175
+ Once the window is created we add a `label` to the window and set the
176
+ `will_close` handler to `exit` when executed.
177
+
178
+ The `will_close` callback is the HotCocoa name for the Cocoa
179
+ `windowWillClose:`. Many of the Cocoa callbacks have been remapped to
180
+ make the names more Ruby like. You can view all the HotCocoa mappings
181
+ for windows at the bottom of the
182
+ [NSWindow mapping file](https://github.com/ferrous26/hotcocoa/blob/master/lib/hotcocoa/mappings/appkit/window.rb).
183
+
184
+ That's it for part I. We've now setup with our basic application
185
+ structure and have an idea of what we're working with. In the next
186
+ installment, we'll work on getting our application views setup as we
187
+ want.
188
+
189
+ [Read the next article: “Application Layout”](https://github.com/ferrous26/hotcocoa/wiki/Application-Layout)
@@ -1,4 +1,4 @@
1
- ## Introduction
1
+ ## Introduction to HotCocoa's Mappings
2
2
 
3
3
  A HotCocoa mapping defines a structure that sits on top of a
4
4
  particular Objective-C class and simplifies its usage in MacRuby.
@@ -4,12 +4,18 @@ This page is an informal index to HotCocoa resources.
4
4
 
5
5
  ## Articles
6
6
 
7
- * Isaac Kearse
7
+ * Gary Weaver (articles from Feb, Mar 2010)
8
+ + [HotCocoa App to track Time on Tasks](http://stufftohelpyouout.blogspot.com/2010/02/hotcocoa-app-to-track-time-on-tasks.html)
9
+ + [Create a Custom Icon for Your HotCocoa App](http://stufftohelpyouout.blogspot.com/2010/02/create-custom-icon-of-your-hotcocoa-app.html)
10
+ + [Create a MacRuby HotCocoa App](http://stufftohelpyouout.blogspot.com/2010/02/create-macruby-hotcocoa-app.html)
11
+ + [HotCocoa/MacRuby Links](http://stufftohelpyouout.blogspot.com/2010/03/hotcocoamacruby-links.html)
12
+
13
+ * [Isaac Kearse](https://github.com/isaac) (articles from Jan, Feb 2010)
8
14
  + [Stopwatch - A HotCocoa Status Bar Timer](http://isaac.kearse.co.nz/2010/01/31/stopwatch/)
9
15
  + [Packaging A HotCocoa Application](http://isaac.kearse.co.nz/2010/02/01/packaging-hotcocoa/)
10
16
  + [SafariRSS - HotCocoa Safari RSS Handler](http://isaac.kearse.co.nz/2010/02/07/safarirss/)
11
17
 
12
- * Dan Sinclair
18
+ * [Dan Sinclair](https://github.com/dj2) (articles from May, June 2009)
13
19
  + [Heating up with HotCocoa Part I](http://everburning.com/news/heating-up-with-hotcocoa-part-i/)
14
20
  + [Heating up with HotCocoa Part II](http://everburning.com/news/heating-up-with-hotcocoa-part-ii/)
15
21
  + [Heating up with HotCocoa Part III](http://everburning.com/news/heating-up-with-hotcocoa-part-iii/)
@@ -17,9 +23,3 @@ This page is an informal index to HotCocoa resources.
17
23
  + [Download and XML parsing with HotCocoa](http://everburning.com/news/download-and-xml-parsing-with-hotcocoa/)
18
24
  + [Toolbars with HotCocoa](http://everburning.com/news/toolbars-with-hotcocoa/)
19
25
  + [HotCocoa and Core Data](http://everburning.com/news/hotcocoa-and-core-data/)
20
-
21
- * Gary Weaver
22
- + [HotCocoa App to track Time on Tasks](http://stufftohelpyouout.blogspot.com/2010/02/hotcocoa-app-to-track-time-on-tasks.html)
23
- + [Create a Custom Icon for Your HotCocoa App](http://stufftohelpyouout.blogspot.com/2010/02/create-custom-icon-of-your-hotcocoa-app.html)
24
- + [Create a MacRuby HotCocoa App](http://stufftohelpyouout.blogspot.com/2010/02/create-macruby-hotcocoa-app.html)
25
- + [HotCocoa/MacRuby Links](http://stufftohelpyouout.blogspot.com/2010/03/hotcocoamacruby-links.html)
@@ -0,0 +1,15 @@
1
+ #Troubleshooting
2
+
3
+ ## App crashes upon start up
4
+
5
+ If the app crashes with the following error:
6
+
7
+ LSOpenURLsWithRole() failed with error -10810 for the file ...
8
+
9
+ This is a very general error and can be caused by a number of things. Known root causes are:
10
+
11
+ 1. Missing [bridge support](http://macruby.org/blog/2010/10/08/bridgesupport-preview.html) files (for Snow Leopard users)
12
+ 2. Bug in the app you are launching
13
+ 3. Bug in HotCocoa
14
+
15
+ Sometimes debug information will be available in the Console (/Applications/Utilities/Console.app), so you should check in there first. Failing that, you will need to rely on your general debugging skills to find the reason.
@@ -1,3 +1,3 @@
1
1
  # HotCocoa Tutorial
2
2
 
3
- This still needs to be ported from the wiki on Github.
3
+ Coming soon!
@@ -83,7 +83,7 @@ module Application
83
83
  def deploy_options
84
84
  options = []
85
85
  spec.gems.each { |g| options << "--gem #{g}" }
86
- options << '--bs' if spec.embed_bs?
86
+ options << '--bs' if spec.embed_bridgesupport?
87
87
  options << '--compile' if spec.compile?
88
88
  options << '--no-stdlib' unless spec.stdlib
89
89
  if spec.stdlib.respond_to? :each
@@ -187,6 +187,8 @@ module Application
187
187
  }
188
188
  info[:CFBundleIconFile] = File.basename(spec.icon) if spec.icon_exists?
189
189
  info[:CFBundleDocumentTypes] = spec.doc_types.map(&:info_plist_representation) unless spec.doc_types.empty?
190
+ info[:CFBundleShortVersionString] = spec.short_version unless spec.short_version.nil?
191
+ info[:NSHumanReadableCopyright] = spec.copyright unless spec.copyright.nil?
190
192
  info.merge! spec.plist # should always be done last
191
193
  info.to_plist
192
194
  end
@@ -260,8 +260,9 @@ module Application
260
260
  # OS X 10.6.
261
261
  #
262
262
  # @return [Boolean]
263
- attr_accessor :embed_bs
264
- alias_method :embed_bs?, :embed_bs
263
+ attr_accessor :embed_bridgesupport
264
+ alias_method :embed_bridgesupport?, :embed_bridgesupport
265
+ alias_method :embed_bs=, :embed_bridgesupport=
265
266
 
266
267
  ##
267
268
  # Whether or not to always make a clean build of the app.
@@ -324,7 +325,7 @@ module Application
324
325
  agent: false,
325
326
  compile: true,
326
327
  overwrite: false,
327
- embed_bs: false
328
+ embed_bridgesupport: true
328
329
  }
329
330
  end
330
331