bowline 0.5.3 → 0.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. data/.gitignore +1 -0
  2. data/README.txt +62 -62
  3. data/Rakefile +10 -0
  4. data/TODO +3 -1
  5. data/VERSION +1 -1
  6. data/assets/bowline.js +118 -3
  7. data/bowline.gemspec +6 -6
  8. data/examples/example.js +2 -15
  9. data/examples/tweet.rb +35 -0
  10. data/examples/tweets_binder.rb +6 -0
  11. data/examples/twitter.html +6 -8
  12. data/examples/users.rb +8 -14
  13. data/lib/bowline/binders.rb +130 -42
  14. data/lib/bowline/dependencies/lib/dependencies.rb +2 -1
  15. data/lib/bowline/dependencies/lib/ext/rubygems.rb +4 -4
  16. data/lib/bowline/desktop.rb +11 -2
  17. data/lib/bowline/desktop/app.rb +7 -3
  18. data/lib/bowline/desktop/bridge.rb +8 -9
  19. data/lib/bowline/desktop/clipboard.rb +11 -2
  20. data/lib/bowline/desktop/dialog.rb +19 -0
  21. data/lib/bowline/desktop/dock.rb +14 -3
  22. data/lib/bowline/desktop/host.rb +13 -4
  23. data/lib/bowline/desktop/js.rb +2 -2
  24. data/lib/bowline/desktop/misc.rb +7 -3
  25. data/lib/bowline/desktop/network.rb +1 -1
  26. data/lib/bowline/desktop/proxy.rb +28 -30
  27. data/lib/bowline/desktop/sound.rb +3 -2
  28. data/lib/bowline/desktop/window.rb +147 -21
  29. data/lib/bowline/desktop/window_manager.rb +53 -5
  30. data/lib/bowline/desktop/window_methods.rb +2 -2
  31. data/lib/bowline/ext/object.rb +1 -1
  32. data/lib/bowline/generators.rb +1 -1
  33. data/lib/bowline/generators/binder.rb +1 -1
  34. data/lib/bowline/helpers.rb +1 -1
  35. data/lib/bowline/initializer.rb +37 -4
  36. data/lib/bowline/library.rb +11 -0
  37. data/lib/bowline/local_model.rb +45 -19
  38. data/lib/bowline/logging.rb +1 -1
  39. data/lib/bowline/platform.rb +8 -6
  40. data/lib/bowline/tasks/app.rake +4 -3
  41. data/lib/bowline/version.rb +1 -1
  42. data/lib/bowline/watcher.rb +18 -8
  43. data/templates/binder.rb +1 -1
  44. data/vendor/pathname.rb +0 -4
  45. metadata +6 -6
  46. data/examples/account.rb +0 -31
  47. data/examples/tweets.rb +0 -28
@@ -1,9 +1,13 @@
1
1
  module Bowline
2
2
  module Desktop
3
3
  module App
4
- # Methods:
5
- # busy()
6
- # exit()
4
+ ##
5
+ # :singleton-method: busy(bool = true)
6
+ # Shows a busy cursor (hourglass) on all windows.
7
+
8
+ ##
9
+ # :singleton-method: exit
10
+ # Exits the application.
7
11
  end
8
12
  end
9
13
  end
@@ -2,12 +2,11 @@ module Bowline
2
2
  module Desktop
3
3
  module Bridge
4
4
  module ClassMethods
5
- # Extend you own classes with this
6
- # module, and then call js_expose
7
- # to expose your classes' class
8
- # variables to JavaScript.
5
+ ##
6
+ # Extend you own classes with this module, and then call js_expose
7
+ # to expose your classes' class variables to JavaScript.
9
8
  #
10
- # Ruby Class:
9
+ # Example:
11
10
  # class FooClass
12
11
  # extend Bowline::Desktop::Bridge::ClassMethods
13
12
  # js_expose
@@ -17,7 +16,7 @@ module Bowline
17
16
  # end
18
17
  # end
19
18
  #
20
- # JavaScript:
19
+ # JavaScript Example:
21
20
  # Bowline.invoke("FooClass", "foo", function(res){
22
21
  # console.log(res);
23
22
  # })
@@ -36,7 +35,7 @@ module Bowline
36
35
  end
37
36
  end
38
37
 
39
- class Message
38
+ class Message #:nodoc:
40
39
  include Bowline::Logging
41
40
 
42
41
  def self.from_array(window, arr)
@@ -75,12 +74,12 @@ module Bowline
75
74
  end
76
75
  end
77
76
 
78
- def setup
77
+ def setup #:nodoc:
79
78
  Desktop.on_tick(method(:poll))
80
79
  end
81
80
  module_function :setup
82
81
 
83
- def poll
82
+ def poll #:nodoc:
84
83
  WindowManager.allocated_windows.each do |window|
85
84
  result = window.run_script("try {Bowline.pollJS()} catch(e) {false}")
86
85
  next if result.blank? || result == "false"
@@ -1,8 +1,17 @@
1
1
  module Bowline
2
2
  module Desktop
3
+ # The Clipboard module gives you cross-platform access to
4
+ # the systems native clipboard. At the moment, you can only
5
+ # read/write strings. We're planning to extend this to images.
3
6
  module Clipboard
4
- # Methods:
5
- # write(str)
7
+ ##
8
+ # :singleton-method: write(str)
9
+ # Write a string to the Clipboard.
10
+ # write("some text")
11
+
12
+ ##
13
+ # :singleton-method: write(str)
14
+ # Read a string from the Clipboard.
6
15
  # read #=> str
7
16
  end
8
17
  end
@@ -1,6 +1,25 @@
1
1
  module Bowline
2
2
  module Desktop
3
3
  module Dialog
4
+ # Display a dialog box from the main window.
5
+ # You can ask for a confirmation, or just display some information.
6
+ #
7
+ # Supported options are:
8
+ # :yes_no - Puts Yes and No buttons on the message box *
9
+ # :ok - Puts an Ok button on the message box *
10
+ # :cancel - Puts a Cancel button on the message box
11
+ # :icon_exclamation - Displays an exclamation mark symbol
12
+ # :icon_error - Displays an error symbol
13
+ # :question - Displays a question mark symbol
14
+ # :information - Displays an information symbol
15
+ # :caption - Title for the message box
16
+ # * may be combined with :cancel
17
+ #
18
+ # Return values are:
19
+ # :yes - User clicked yes
20
+ # :no - User clicked no
21
+ # :ok - User clicked ok
22
+ # :cancel - User clicked cancel, or closed the box
4
23
  def message(msg, options = {})
5
24
  style = 0
6
25
  style |= YES_NO if options[:yes_no]
@@ -1,9 +1,20 @@
1
1
  module Bowline
2
2
  module Desktop
3
+ # The Dock module gives you a few methods to control
4
+ # the Mac OSX dock. It's platform specific, and on platforms
5
+ # other than OSX calling the methods won't do anything.
3
6
  module Dock
4
- # Methods:
5
- # badge=(str)
6
- # clear_badge
7
+ # Set the badge number. This is the little numbered red star above
8
+ # the App's Dock icon. A good example of this is Mail.app incrementing
9
+ # its icon's star whenever a new mail is received.
10
+ def badge=(number)
11
+ self._badge = number.to_s
12
+ end
13
+ module_function :badge=
14
+
15
+ ##
16
+ # :singleton-method: clear_badge
17
+ # Clear the Icon's badge number
7
18
  end
8
19
  end
9
20
  end
@@ -1,10 +1,19 @@
1
1
  module Bowline
2
2
  module Desktop
3
3
  module Host
4
- # Methods
5
- # ip()
6
- # public_ip()
7
- # host_name()
4
+ ##
5
+ # :singleton-method: ip
6
+ # Returns the computer's local IP address
7
+
8
+ ##
9
+ # :singleton-method: public_ip
10
+ # Returns the computer's network IP address.
11
+ # This method doesn't return the computer's Internet IP,
12
+ # for that you need a remote server.
13
+
14
+ ##
15
+ # :singleton-method: host_name
16
+ # Returns the computer's host name
8
17
  end
9
18
  end
10
19
  end
@@ -1,6 +1,6 @@
1
1
  module Bowline
2
2
  module Desktop
3
- module JS
3
+ module JS #:nodoc:
4
4
  class Script
5
5
  include Bowline::Logging
6
6
 
@@ -31,7 +31,7 @@ module Bowline
31
31
  result
32
32
  else
33
33
  trace "Pseudo JS eval on #{window}: #{script}"
34
- prok.call(nil)
34
+ prok.call(nil) if prok
35
35
  end
36
36
  end
37
37
 
@@ -1,9 +1,13 @@
1
1
  module Bowline
2
2
  module Desktop
3
3
  module Misc
4
- # Methods:
5
- # launch_browser(url)
6
- # bell()
4
+ ##
5
+ # :singleton-method: launch_browser(url)
6
+ # Launch the computer's default browser
7
+
8
+ ##
9
+ # :singleton-method: bell
10
+ # Call the system bell
7
11
  end
8
12
  end
9
13
  end
@@ -1,6 +1,6 @@
1
1
  module Bowline
2
2
  module Desktop
3
- class Network
3
+ class Network #:nodoc:
4
4
  # Implement address polling to see if we're online
5
5
  end
6
6
  end
@@ -1,35 +1,33 @@
1
1
  module Bowline
2
2
  module Desktop
3
- class Proxy
4
- # Use to call out to JavaScript.
5
- #
6
- # Use the method 'call' if you want
7
- # to call a function, or the method 'res' if you want
8
- # the result of a variable evaluation.
9
- #
10
- # You can pass a block as the last argument which will
11
- # be called with the result of the evaluation.
12
- #
13
- # All arguments are serialized by JSON, so you can only pass
14
- # the following objects:
15
- # * Hash
16
- # * Array
17
- # * String
18
- # * Integer
19
- #
20
- # Usage:
21
- # proxy.FooObject.messages = [1,2,3] #=> "FooObject.messages = [1,2,3]"
22
- # proxy.FooObject.hi.call #=> "FooObject.hi()"
23
- # proxy.FooObject.hi(1,2,3).bye.call #=> "FooObject.hi(1,2,3).bye()"
24
- # proxy.FooObject.messages.res #=> "FooObject.messages"
25
- # proxy.FooObject.messages.res {|result|
26
- # puts "Messages are: #{result}"
27
- # }
28
- #
29
- # Reasoning behind this class:
30
- # * JavaScript needs to be called all at once
31
- # * We don't know if it's a method call, or a variable
32
-
3
+ # Use to call out to JavaScript.
4
+ #
5
+ # Use the method 'call' if you want to call a function,
6
+ # or the method 'res' if you want the result of a variable evaluation.
7
+ #
8
+ # You can pass a block as the last argument which will
9
+ # be called with the result of the evaluation.
10
+ #
11
+ # All arguments are serialized by JSON, so you can only pass
12
+ # the following objects:
13
+ # * Hash
14
+ # * Array
15
+ # * String
16
+ # * Integer
17
+ #
18
+ # Examples:
19
+ # proxy.FooObject.messages = [1,2,3] #=> "FooObject.messages = [1,2,3]"
20
+ # proxy.FooObject.hi.call #=> "FooObject.hi()"
21
+ # proxy.FooObject.hi(1,2,3).bye.call #=> "FooObject.hi(1,2,3).bye()"
22
+ # proxy.FooObject.messages.res #=> "FooObject.messages"
23
+ # proxy.FooObject.messages.res {|result|
24
+ # puts "Messages are: #{result}"
25
+ # }
26
+ #
27
+ # Reasoning behind this class's call/res API:
28
+ # * JavaScript needs to be called all at once
29
+ # * We don't know if it's a method call, or a variable
30
+ class Proxy
33
31
  def initialize(win)
34
32
  @window = win
35
33
  @crumbs = []
@@ -1,8 +1,9 @@
1
1
  module Bowline
2
2
  module Desktop
3
3
  module Sound
4
- # Methods:
5
- # play(wav_file_path)
4
+ ##
5
+ # :singleton-method: play(path)
6
+ # Play a wav file
6
7
  end
7
8
  end
8
9
  end
@@ -1,30 +1,156 @@
1
1
  module Bowline
2
2
  module Desktop
3
+ # Use the Window class to create new windows that your
4
+ # users can interact with.
5
+ #
6
+ # Usually, this class isn't instantiated directly, but rather
7
+ # used in conjunction with the WindowManager class.
8
+ # We recommend this approach, otherwise your window won't be
9
+ # able to call out to Ruby, or use Bowline's binding API.
10
+ #
11
+ # At the moment, these methods need to be called in the main thread.
12
+ # This is a restriction we're hoping to remove soon.
3
13
  class Window
4
14
  include WindowMethods
5
- # Methods:
6
- # new()
7
- # center(direction = :both)
8
- # close
9
- # chrome=
10
- # disable
11
- # enable
12
- # file=
13
- # id
14
- # modal(flag = true)
15
- # name=
16
- # run_script(str) #=> str
17
- # raise
18
- # show
19
- # hide
20
- # set_size(width, height)
21
- # set_position(x, y)
22
- # select_dir(
23
- # )
24
- # shown?
15
+ ##
16
+ # :singleton-method: center(direction = :both)
17
+ # Center the window in a given direction.
18
+ # Supports the following directions:
19
+ # :both - both horizontal and vertical to the app
20
+ # :horizontal - horizontal to the app
21
+ # :vertical - vertical to the app
22
+ # :center - center of the screen
23
+ #
24
+ # :call-seq:
25
+ # my_method(Range)
26
+ # my_method(offset, length)
27
+
28
+ ##
29
+ # :singleton-method: close
30
+ # Close the window.
31
+
32
+ ##
33
+ # :singleton-method: disable
34
+ # Disable user input to the window.
35
+
36
+ ##
37
+ # :singleton-method: enable
38
+ # Enable user input to the window.
39
+
40
+ ##
41
+ # :singleton-method: chome=(bool)
42
+ # Enable/disable window's chrome,
43
+ # i.e. the buttons & frame
44
+
45
+ ##
46
+ # :singleton-method: file=(path)
47
+ # Load HTML file. You can pass an absolute path, a path
48
+ # relative to the apps root, or a symbol, like so:
49
+ # window.file = :about
50
+ # Passing a symbol will load the corrosponding HTML file
51
+ # in the public directory. In this case, it'll load about.html
52
+
53
+ ##
54
+ # :singleton-method: id
55
+ # Internal ID for the window.
56
+
57
+ ##
58
+ # :singleton-method: dealocated?
59
+ # Returns true if the window has been dealocated.
60
+ # Calling methods on dealocated windows has no effect.
61
+ # Instead, you'll need to create a new instance.
62
+
63
+ ##
64
+ # :singleton-method: modal(flag = true)
65
+ # Disable/Enable user interaction with other windows.
66
+
67
+ ##
68
+ # :singleton-method: name=(str)
69
+ # Set windows name (shown in the window's title bar)
70
+
71
+ ##
72
+ # :singleton-method: run_script(str)
73
+ # Run JavaScript in this window.
74
+ #
75
+ # The return result types are very limited,
76
+ # only the following are supported:
77
+ # - Booleans
78
+ # - Integers
79
+ # - Strings
80
+ # These all then get converted into strings.
81
+ #
82
+ # This API is very low level. We recommend you use the abstractions
83
+ # provided by the WindowManager class, such as the 'page' method.
84
+
85
+ ##
86
+ # :singleton-method: raise
87
+ # Raise this window above all other ones.
88
+
89
+ ##
90
+ # :singleton-method: show
91
+ # Show this window. By default, windows are hidden.
92
+
93
+ ##
94
+ # :singleton-method: hide
95
+ # Hide this window.
96
+
97
+ ##
98
+ # :singleton-method: close
99
+ # Close this window. Once a window is closed, either by a user or
100
+ # by calling this method, it has been deallocated and may not be opened again.
101
+ #
102
+ # You'll need to create a new instance of this class for a new window.
103
+ # Calling any methods on a dealocated window won't have any effect.
104
+
105
+ ##
106
+ # :singleton-method: set_size(width, weight)
107
+ # Set the window's width & height in pixels.
108
+
109
+ ##
110
+ # :singleton-method: height=(int)
111
+ # Helper to set the window's height.
112
+
113
+ ##
114
+ # :singleton-method: width=(int)
115
+ # Helper to set the window's width.
116
+
117
+ ##
118
+ # :singleton-method: set_position(x, y)
119
+ # Set the window's position on the screen.
120
+
121
+ ##
122
+ # :singleton-method: select_dir(options = {})
123
+ # Prompt the user to select a folder.
124
+ #
125
+ # Supported options are:
126
+ # :message
127
+ # :default_path
128
+
129
+ ##
130
+ # :singleton-method: select_file(options = {})
131
+ # Prompt the user to select a file.
132
+ #
133
+ # Supported options are:
134
+ # :message
135
+ # :default_path
136
+ # :default_filename
137
+ # :default_extension
138
+ # :wildcard - defaults to *.*
139
+ # :open - show open button
140
+ # :save - show save button
141
+ # :overwrite_prompt - prompt if file already exists
142
+ # :file_must_exist
143
+ #
144
+ # The :wildcard options may be a specification for multiple
145
+ # types of file with a description for each, such as:
146
+ # "BMP files (*.bmp)|*.bmp|GIF files (*.gif)|*.gif"
147
+
148
+ ##
149
+ # :singleton-method: shown?
150
+ # Is this window currently shown?
25
151
  end
26
152
 
27
- class MainWindow
153
+ class MainWindow #:nodoc:
28
154
  include WindowMethods
29
155
  end
30
156
  end