bowline 0.4.6 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. data/Rakefile +1 -0
  2. data/TODO +11 -0
  3. data/VERSION +1 -1
  4. data/assets/bowline.js +194 -0
  5. data/assets/json2.js +479 -0
  6. data/assets/osx/Info.plist.erb +45 -0
  7. data/assets/osx/bowline.png +0 -0
  8. data/assets/osx/makeicns +0 -0
  9. data/bowline.gemspec +47 -11
  10. data/lib/bowline.rb +35 -15
  11. data/lib/bowline/binders.rb +168 -131
  12. data/lib/bowline/commands/build.rb +3 -0
  13. data/lib/bowline/commands/generate.rb +3 -1
  14. data/lib/bowline/commands/run.rb +7 -4
  15. data/lib/bowline/desktop.rb +26 -0
  16. data/lib/bowline/desktop/app.rb +9 -0
  17. data/lib/bowline/desktop/bridge.rb +97 -0
  18. data/lib/bowline/desktop/clipboard.rb +9 -0
  19. data/lib/bowline/desktop/dialog.rb +28 -0
  20. data/lib/bowline/desktop/dock.rb +9 -0
  21. data/lib/bowline/desktop/host.rb +10 -0
  22. data/lib/bowline/desktop/js.rb +92 -0
  23. data/lib/bowline/desktop/misc.rb +9 -0
  24. data/lib/bowline/desktop/network.rb +7 -0
  25. data/lib/bowline/desktop/proxy.rb +94 -0
  26. data/lib/bowline/desktop/sound.rb +8 -0
  27. data/lib/bowline/desktop/window.rb +31 -0
  28. data/lib/bowline/desktop/window_manager.rb +72 -0
  29. data/lib/bowline/desktop/window_methods.rb +70 -0
  30. data/lib/bowline/generators.rb +3 -2
  31. data/lib/bowline/generators/application.rb +8 -5
  32. data/lib/bowline/generators/binder.rb +10 -6
  33. data/lib/bowline/generators/model.rb +9 -0
  34. data/lib/bowline/generators/window.rb +28 -0
  35. data/lib/bowline/helpers.rb +0 -3
  36. data/lib/bowline/initializer.rb +65 -11
  37. data/lib/bowline/library.rb +31 -0
  38. data/lib/bowline/local_model.rb +116 -0
  39. data/lib/bowline/logging.rb +23 -0
  40. data/lib/bowline/platform.rb +73 -0
  41. data/lib/bowline/tasks/app.rake +80 -148
  42. data/lib/bowline/tasks/libs.rake +59 -0
  43. data/lib/bowline/version.rb +2 -2
  44. data/lib/bowline/watcher.rb +91 -0
  45. data/templates/binder.rb +2 -8
  46. data/templates/config/environment.rb +3 -2
  47. data/templates/main_window.rb +7 -0
  48. data/templates/model.rb +1 -1
  49. data/templates/public/index.html +2 -1
  50. data/templates/script/build +3 -0
  51. data/templates/script/generate +3 -0
  52. data/templates/script/init +0 -16
  53. data/templates/window.rb +3 -0
  54. data/vendor/pathname.rb +1099 -0
  55. data/vendor/progressbar.rb +236 -0
  56. metadata +48 -9
  57. data/assets/jquery.bowline.js +0 -156
  58. data/lib/bowline/async.rb +0 -29
  59. data/lib/bowline/binders/collection.rb +0 -59
  60. data/lib/bowline/binders/singleton.rb +0 -31
  61. data/lib/bowline/jquery.rb +0 -31
  62. data/lib/bowline/observer.rb +0 -66
  63. data/lib/bowline/window.rb +0 -19
data/lib/bowline/async.rb DELETED
@@ -1,29 +0,0 @@
1
- module Bowline
2
- module Async
3
- def self.included(base)
4
- base.extend Methods
5
- base.send :include, Methods
6
- class << base
7
- extend Methods
8
- end
9
- end
10
-
11
- module Methods
12
- def async(*methods)
13
- methods.each {|meth|
14
- define_method("#{meth}_with_async") {|*args|
15
- callback = nil
16
- if(args.last.is_a?(::RubyKMethod))
17
- callback = args.pop
18
- end
19
- Thread.new do
20
- res = send("#{meth}_without_async", *args)
21
- callback.call(res) if callback
22
- end
23
- }
24
- alias_method_chain meth, :async
25
- }
26
- end
27
- end
28
- end
29
- end
@@ -1,59 +0,0 @@
1
- module Bowline
2
- module Binders
3
- class Collection < Base
4
- class ItemsProxy
5
- def initialize(&block)
6
- @callback = block
7
- @items = []
8
- end
9
-
10
- def real
11
- @items
12
- end
13
-
14
- def method_missing(*args, &block)
15
- diff = @items.hash
16
- res = @items.send(*args, &block)
17
- if diff != @items.hash
18
- @callback.call
19
- end
20
- res
21
- end
22
- end
23
-
24
- class << self
25
- def items=(args)
26
- if args
27
- items.replace(args)
28
- else
29
- items.clear
30
- end
31
- end
32
-
33
- def items
34
- @items ||= ItemsProxy.new {
35
- self.item_sync!
36
- }
37
- end
38
-
39
- def item_sync!
40
- return unless @items && @elements
41
- value = @items.real.map {|item|
42
- hash = item.to_js
43
- hash.merge!({:_id => item.__id__})
44
- hash.stringify_keys
45
- }
46
- @elements.each {|i|
47
- i.updateCollection(value)
48
- }
49
- end
50
-
51
- def find(id)
52
- @items.real.find {|item|
53
- item.__id__ == id
54
- }
55
- end
56
- end
57
- end
58
- end
59
- end
@@ -1,31 +0,0 @@
1
- module Bowline
2
- module Binders
3
- class Singleton < Base
4
- class << self
5
- def item
6
- @item
7
- end
8
-
9
- def item=(arg)
10
- @item = arg
11
- self.item_sync!
12
- end
13
-
14
- def item_sync!
15
- return unless @item && @elements
16
- value = @item.to_js
17
- value.merge!({:_id => @item.__id__})
18
- value.stringify_keys!
19
- # Call the chain.js function 'item' on elements
20
- @elements.each {|i|
21
- i.updateSingleton(value)
22
- }
23
- end
24
-
25
- def find(*a)
26
- @item
27
- end
28
- end
29
- end
30
- end
31
- end
@@ -1,31 +0,0 @@
1
- module Bowline
2
- class JQuery
3
- # Equivalent to: $.foo()
4
- def method_missing(sym, args)
5
- self.class.dollar.send(sym, *args)
6
- end
7
-
8
- class << self
9
- # Equivalent to: $('#item_id')
10
- def for_element(el)
11
- Bowline::js.send("jQuery", el)
12
- end
13
-
14
- # For binding global events
15
- # Equivalent to: $('body').bind()
16
- def bind(event, fun, data)
17
- for_element("body").bind(event, data, fun)
18
- end
19
-
20
- # Equivalent to: $
21
- def dollar
22
- Bowline::js.send("jQuery")
23
- end
24
-
25
- # Equivalent to: $.bowline
26
- def bowline
27
- dollar.bowline
28
- end
29
- end
30
- end
31
- end
@@ -1,66 +0,0 @@
1
- # o = Observable.new
2
- # o.append('greet') {
3
- # puts 'hi'
4
- # }
5
- # o.call('greet')
6
- #
7
- # def greet(who)
8
- # puts "Hi #{who}"
9
- # end
10
- # event = o.append('greet', method(:greet), 'Alex')
11
- # o.call('greet')
12
- # event.remove
13
-
14
- module Bowline
15
- class Observable
16
- class Event
17
- attr_reader :type, :callback
18
- def initialize(observable, type, callback = nil)
19
- @observable = observable
20
- @type = type
21
- @callback = callback
22
- end
23
-
24
- def call(*args)
25
- @callback.call(*args)
26
- end
27
-
28
- def remove
29
- @observable.remove(self)
30
- end
31
- end
32
-
33
- def initialize
34
- @listeners = {}
35
- end
36
-
37
- def append(event, method = nil, &block)
38
- event = Event.new(self, event, method||block)
39
- (@listeners[event] ||= []) << event
40
- event
41
- end
42
-
43
- def call(event, *args)
44
- return unless @listeners[event]
45
- @listeners[event].each do |callback|
46
- callback.call(*args)
47
- end
48
- end
49
-
50
- def remove(event, value=nil)
51
- return unless @listeners[event]
52
- if value
53
- @listeners[event].delete(value)
54
- if @listeners[event].empty?
55
- @listeners.delete(event)
56
- end
57
- else
58
- @listeners.delete(event)
59
- end
60
- end
61
-
62
- def clear
63
- @listeners = {}
64
- end
65
- end
66
- end
@@ -1,19 +0,0 @@
1
- module Bowline
2
- class Window
3
- def self.window
4
- defined?(Titanium) && Titanium.UI.mainWindow.window
5
- end
6
-
7
- def initialize(obj = self.class.window)
8
- @object = obj
9
- end
10
-
11
- def method_missing(*args)
12
- Bowline.logger.info "Sending to Window: #{args.inspect}"
13
- if defined?(Titanium)
14
- @object = @object.send(*args)
15
- end
16
- self
17
- end
18
- end
19
- end