bowline 0.1.6 → 0.3.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. data/README.txt +26 -23
  2. data/Rakefile +18 -23
  3. data/VERSION +1 -0
  4. data/assets/jquery.bowline.js +51 -29
  5. data/assets/jquery.js +2122 -1295
  6. data/bin/bowline-gen +1 -1
  7. data/bowline.gemspec +94 -17
  8. data/examples/twitter.html +18 -18
  9. data/lib/bowline.rb +10 -14
  10. data/lib/bowline/async.rb +29 -0
  11. data/lib/bowline/binders.rb +11 -40
  12. data/lib/bowline/binders/collection.rb +11 -8
  13. data/lib/bowline/binders/singleton.rb +9 -6
  14. data/lib/bowline/commands/run.rb +4 -11
  15. data/lib/bowline/dependencies/FAQ.markdown +6 -0
  16. data/lib/bowline/dependencies/MIT-LICENSE +20 -0
  17. data/lib/bowline/dependencies/README.markdown +51 -0
  18. data/lib/bowline/dependencies/Rakefile +10 -0
  19. data/lib/bowline/dependencies/TODO.markdown +4 -0
  20. data/lib/bowline/dependencies/init.rb +41 -0
  21. data/lib/bowline/dependencies/lib/dependencies.rb +9 -0
  22. data/lib/bowline/dependencies/lib/dependencies/dependency.rb +12 -0
  23. data/lib/bowline/dependencies/lib/dependencies/reader.rb +30 -0
  24. data/lib/bowline/dependencies/lib/dependencies/repository.rb +64 -0
  25. data/lib/bowline/dependencies/lib/ext/rubygems.rb +125 -0
  26. data/lib/bowline/dependencies/lib/template/app_script.rb +31 -0
  27. data/lib/bowline/dependencies/spec/spec.opts +4 -0
  28. data/lib/bowline/dependencies/tasks/dependencies.rake +164 -0
  29. data/lib/bowline/ext/array.rb +1 -1
  30. data/lib/bowline/generators.rb +1 -0
  31. data/lib/bowline/generators/application.rb +7 -2
  32. data/lib/bowline/generators/helper.rb +28 -0
  33. data/lib/bowline/helpers.rb +7 -0
  34. data/lib/bowline/initializer.rb +75 -41
  35. data/lib/bowline/observer.rb +42 -19
  36. data/lib/bowline/tasks/app.rake +143 -77
  37. data/lib/bowline/tasks/gems.rake +34 -0
  38. data/lib/bowline/tasks/{misk.rake → misc.rake} +0 -0
  39. data/lib/bowline/version.rb +11 -0
  40. data/lib/bowline/window.rb +19 -0
  41. data/templates/config/boot.rb +4 -3
  42. data/templates/config/environment.rb +8 -4
  43. data/templates/gitignore +0 -2
  44. data/templates/helper.rb +2 -0
  45. data/templates/public/icon.png +0 -0
  46. data/templates/public/index.html +8 -10
  47. metadata +38 -41
  48. data/Manifest.txt +0 -58
  49. data/lib/bowline/gem_dependency.rb +0 -42
  50. data/templates/config/manifest +0 -18
  51. data/templates/config/tiapp.xml +0 -24
@@ -3,4 +3,4 @@
3
3
  require File.join(File.dirname(__FILE__), *%w[.. lib bowline])
4
4
  require 'bowline/generators'
5
5
 
6
- Bowline::Generators.run_cli(Dir.pwd, 'bowline', Bowline::VERSION, ARGV)
6
+ Bowline::Generators.run_cli(Dir.pwd, 'bowline', Bowline::Version::STRING, ARGV)
@@ -2,24 +2,107 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{bowline}
5
- s.version = "0.1.6"
5
+ s.version = "0.3.9"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Alex MacCaw"]
9
- s.date = %q{2009-04-24}
9
+ s.date = %q{2009-07-15}
10
10
  s.default_executable = %q{bowline-gen}
11
- s.description = %q{Ruby desktop application framework}
12
- s.email = ["info@eribium.org"]
11
+ s.description = %q{Ruby/JS GUI framework}
12
+ s.email = %q{alex@leadthinking.com}
13
13
  s.executables = ["bowline-gen"]
14
- s.extra_rdoc_files = ["History.txt", "Manifest.txt", "README.txt"]
15
- s.files = [".gitignore", "History.txt", "MIT-LICENSE", "Manifest.txt", "README.txt", "Rakefile", "assets/jquery.bowline.js", "assets/jquery.chain.js", "assets/jquery.js", "bin/bowline-gen", "bowline.gemspec", "examples/account.rb", "examples/example.js", "examples/twitter.html", "examples/tweets.rb", "examples/users.rb", "lib/bowline.rb", "lib/bowline/binders.rb", "lib/bowline/binders/collection.rb", "lib/bowline/binders/singleton.rb", "lib/bowline/commands/console.rb", "lib/bowline/commands/generate.rb", "lib/bowline/commands/run.rb", "lib/bowline/ext/array.rb", "lib/bowline/ext/class.rb", "lib/bowline/ext/object.rb", "lib/bowline/ext/string.rb", "lib/bowline/gem_dependency.rb", "lib/bowline/generators.rb", "lib/bowline/generators/application.rb", "lib/bowline/generators/binder.rb", "lib/bowline/generators/migration.rb", "lib/bowline/generators/model.rb", "lib/bowline/initializer.rb", "lib/bowline/jquery.rb", "lib/bowline/observer.rb", "lib/bowline/tasks/app.rake", "lib/bowline/tasks/bowline.rb", "lib/bowline/tasks/database.rake", "lib/bowline/tasks/log.rake", "lib/bowline/tasks/misk.rake", "templates/Rakefile", "templates/binder.rb", "templates/config/application.yml", "templates/config/boot.rb", "templates/config/database.yml", "templates/config/environment.rb", "templates/config/manifest", "templates/config/tiapp.xml", "templates/gitignore", "templates/migration.rb", "templates/model.rb", "templates/public/index.html", "templates/public/javascripts/application.js", "templates/public/stylesheets/application.css", "templates/script/console", "templates/script/init", "templates/script/run"]
16
- s.has_rdoc = true
14
+ s.extra_rdoc_files = [
15
+ "README.txt"
16
+ ]
17
+ s.files = [
18
+ ".gitignore",
19
+ "History.txt",
20
+ "MIT-LICENSE",
21
+ "README.txt",
22
+ "Rakefile",
23
+ "VERSION",
24
+ "assets/jquery.bowline.js",
25
+ "assets/jquery.chain.js",
26
+ "assets/jquery.js",
27
+ "bin/bowline-gen",
28
+ "bowline.gemspec",
29
+ "examples/account.rb",
30
+ "examples/example.js",
31
+ "examples/tweets.rb",
32
+ "examples/twitter.html",
33
+ "examples/users.rb",
34
+ "lib/bowline.rb",
35
+ "lib/bowline/async.rb",
36
+ "lib/bowline/binders.rb",
37
+ "lib/bowline/binders/collection.rb",
38
+ "lib/bowline/binders/singleton.rb",
39
+ "lib/bowline/commands/console.rb",
40
+ "lib/bowline/commands/generate.rb",
41
+ "lib/bowline/commands/run.rb",
42
+ "lib/bowline/dependencies/FAQ.markdown",
43
+ "lib/bowline/dependencies/MIT-LICENSE",
44
+ "lib/bowline/dependencies/README.markdown",
45
+ "lib/bowline/dependencies/Rakefile",
46
+ "lib/bowline/dependencies/TODO.markdown",
47
+ "lib/bowline/dependencies/init.rb",
48
+ "lib/bowline/dependencies/lib/dependencies.rb",
49
+ "lib/bowline/dependencies/lib/dependencies/dependency.rb",
50
+ "lib/bowline/dependencies/lib/dependencies/reader.rb",
51
+ "lib/bowline/dependencies/lib/dependencies/repository.rb",
52
+ "lib/bowline/dependencies/lib/ext/rubygems.rb",
53
+ "lib/bowline/dependencies/lib/template/app_script.rb",
54
+ "lib/bowline/dependencies/spec/spec.opts",
55
+ "lib/bowline/dependencies/tasks/dependencies.rake",
56
+ "lib/bowline/ext/array.rb",
57
+ "lib/bowline/ext/class.rb",
58
+ "lib/bowline/ext/object.rb",
59
+ "lib/bowline/ext/string.rb",
60
+ "lib/bowline/generators.rb",
61
+ "lib/bowline/generators/application.rb",
62
+ "lib/bowline/generators/binder.rb",
63
+ "lib/bowline/generators/helper.rb",
64
+ "lib/bowline/generators/migration.rb",
65
+ "lib/bowline/generators/model.rb",
66
+ "lib/bowline/helpers.rb",
67
+ "lib/bowline/initializer.rb",
68
+ "lib/bowline/jquery.rb",
69
+ "lib/bowline/observer.rb",
70
+ "lib/bowline/tasks/app.rake",
71
+ "lib/bowline/tasks/bowline.rb",
72
+ "lib/bowline/tasks/database.rake",
73
+ "lib/bowline/tasks/gems.rake",
74
+ "lib/bowline/tasks/log.rake",
75
+ "lib/bowline/tasks/misc.rake",
76
+ "lib/bowline/version.rb",
77
+ "lib/bowline/window.rb",
78
+ "templates/Rakefile",
79
+ "templates/binder.rb",
80
+ "templates/config/application.yml",
81
+ "templates/config/boot.rb",
82
+ "templates/config/database.yml",
83
+ "templates/config/environment.rb",
84
+ "templates/gitignore",
85
+ "templates/helper.rb",
86
+ "templates/migration.rb",
87
+ "templates/model.rb",
88
+ "templates/public/icon.png",
89
+ "templates/public/index.html",
90
+ "templates/public/javascripts/application.js",
91
+ "templates/public/stylesheets/application.css",
92
+ "templates/script/console",
93
+ "templates/script/init",
94
+ "templates/script/run"
95
+ ]
17
96
  s.homepage = %q{http://github.com/maccman/bowline}
18
- s.rdoc_options = ["--main", "README.txt"]
97
+ s.rdoc_options = ["--charset=UTF-8"]
19
98
  s.require_paths = ["lib"]
20
- s.rubyforge_project = %q{maccman}
21
- s.rubygems_version = %q{1.3.2}
22
- s.summary = %q{Ruby desktop application framework}
99
+ s.rubygems_version = %q{1.3.4}
100
+ s.summary = %q{Bowline GUI framework}
101
+ s.test_files = [
102
+ "examples/account.rb",
103
+ "examples/tweets.rb",
104
+ "examples/users.rb"
105
+ ]
23
106
 
24
107
  if s.respond_to? :specification_version then
25
108
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
@@ -28,18 +111,12 @@ Gem::Specification.new do |s|
28
111
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
29
112
  s.add_runtime_dependency(%q<templater>, [">= 0.3.2"])
30
113
  s.add_runtime_dependency(%q<activesupport>, [">= 2.3.2"])
31
- s.add_development_dependency(%q<newgem>, [">= 1.3.0"])
32
- s.add_development_dependency(%q<hoe>, [">= 1.8.0"])
33
114
  else
34
115
  s.add_dependency(%q<templater>, [">= 0.3.2"])
35
116
  s.add_dependency(%q<activesupport>, [">= 2.3.2"])
36
- s.add_dependency(%q<newgem>, [">= 1.3.0"])
37
- s.add_dependency(%q<hoe>, [">= 1.8.0"])
38
117
  end
39
118
  else
40
119
  s.add_dependency(%q<templater>, [">= 0.3.2"])
41
120
  s.add_dependency(%q<activesupport>, [">= 2.3.2"])
42
- s.add_dependency(%q<newgem>, [">= 1.3.0"])
43
- s.add_dependency(%q<hoe>, [">= 1.8.0"])
44
121
  end
45
122
  end
@@ -1,39 +1,39 @@
1
- <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
2
- "http://www.w3.org/TR/html4/strict.dtd">
3
-
4
- <html lang="en">
1
+ <!DOCTYPE html>
2
+ <html>
5
3
  <head>
6
4
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
7
5
  <title>Twitter</title>
8
- <!--
9
- <script src="http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js" type="text/javascript"></script>
10
- -->
6
+ <link rel="stylesheet" href="stylesheets/application.css" type="text/css" charset="utf-8">
11
7
  <script src="javascripts/jquery.js" type="text/javascript" charset="utf-8"></script>
12
8
  <script src="javascripts/jquery.chain.js" type="text/javascript" charset="utf-8"></script>
13
9
  <script src="javascripts/jquery.bowline.js" type="text/javascript" charset="utf-8"></script>
14
- <script src="../script/init" type="text/ruby" charset="utf-8"></script>
15
10
  <script src="javascripts/application.js" type="text/javascript" charset="utf-8"></script>
16
- <link rel="stylesheet" href="stylesheets/application.css" type="text/css" charset="utf-8">
17
11
  <script type="text/javascript" charset="utf-8">
18
12
  jQuery(function($){
19
- var tweets = $('#tweets').bowline('tweets');
20
- tweets.invoke('index');
13
+ $.bowline.ready(function(){
14
+ var tweets = $('#tweets').bowline('tweets');
15
+ tweets.invoke('index');
21
16
 
22
- $('#updateSubmit').click(function(){
23
- tweets.invoke('update', $('#updateText').val());
24
- return false;
25
- })
17
+ $('#updateSubmit').click(function(){
18
+ tweets.invoke('update', $('#updateText').val());
19
+ return false;
20
+ });
21
+ });
26
22
  });
27
23
  </script>
28
24
  </head>
29
25
  <body>
26
+ <header></header>
27
+
30
28
  <div id="tweets">
31
29
  <div class="item">
32
30
  <span class="text"></span>
33
31
  </div>
34
32
  </div>
35
33
 
36
- <input type="text" id="updateText">
37
- <input type="submit" value="Update &rarr;" id="updateSubmit">
34
+ <footer>
35
+ <input type="text" id="updateText">
36
+ <button id="updateSubmit">Update &rarr;</button>
37
+ </footer>
38
38
  </body>
39
- </html>
39
+ </html>
@@ -1,23 +1,14 @@
1
- module Bowline
2
- VERSION = '0.1.6'
1
+ Thread.abort_on_exception = true
3
2
 
3
+ module Bowline
4
4
  # The raw JavaScript window object
5
5
  def self.js
6
- if defined?($app_window)
7
- $app_window
8
- else
9
- Class.new {
10
- def self.method_missing(*a)
11
- Bowline.logger.info "Sending to Window: #{a.inspect}"
12
- self
13
- end
14
- }
15
- end
6
+ Window.new
16
7
  end
17
8
 
18
9
  # Change which page we're on
19
10
  def self.show_view(name)
20
- js.window.location = "app://public/#{name}.html"
11
+ js.location = "app://public/#{name}.html"
21
12
  end
22
13
 
23
14
  class Base
@@ -26,12 +17,17 @@ end
26
17
 
27
18
  $LOAD_PATH << File.dirname(__FILE__)
28
19
 
20
+ require 'bowline/version'
21
+
29
22
  require 'bowline/ext/object'
30
23
  require 'bowline/ext/array'
31
24
  require 'bowline/ext/class'
32
25
  require 'bowline/ext/string'
33
26
 
34
- require 'bowline/gem_dependency'
27
+ require 'bowline/window'
28
+ require 'bowline/async'
29
+ require 'bowline/helpers'
30
+ require 'bowline/dependencies/lib/dependencies'
35
31
  require 'bowline/initializer'
36
32
 
37
33
  require 'bowline/jquery'
@@ -0,0 +1,29 @@
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,8 +1,6 @@
1
1
  module Bowline
2
2
  module Binders
3
3
  class Base
4
- cattr_accessor :params
5
-
6
4
  class << self
7
5
  # See Bowline::js
8
6
  def js
@@ -16,7 +14,7 @@ module Bowline
16
14
 
17
15
  # See the Observer class
18
16
  def observer
19
- @@observer ||= Observer.new
17
+ @observer ||= Observer.new
20
18
  end
21
19
 
22
20
  # See Bowline::logger
@@ -28,36 +26,37 @@ module Bowline
28
26
  def show_view(*args)
29
27
  Bowline::show_view(*args)
30
28
  end
29
+
30
+ def params
31
+ @params
32
+ end
31
33
 
32
34
  def params=(p)
33
35
  case p
34
36
  when String
35
37
  # Params comes in a string (since it's a
36
38
  # serialized form) - we need to make it into
37
- # a nestled hash.
38
- # Stolen from Ramaze
39
+ # a nestled hash. Stolen from Ramaze
39
40
  m = proc {|_,o,n|o.merge(n,&m)}
40
- @@params = params.inject({}) do |hash, (key, value)|
41
+ @params = params.inject({}) do |hash, (key, value)|
41
42
  parts = key.split(/[\]\[]+/)
42
43
  hash.merge(parts.reverse.inject(value) { |x, i| {i => x} }, &m)
43
44
  end
44
45
  else
45
- @@params = p
46
+ @params = p
46
47
  end
47
48
  end
48
49
 
49
50
  def setup(d)
50
- @@elements ||= []
51
- @@elements << d
51
+ @elements ||= []
52
+ @elements << d
52
53
  self.item_sync!
53
54
  end
54
55
 
55
56
  def instance(el)
56
57
  self.new(el).method(:send)
57
58
  end
58
-
59
- # todo - flash?
60
-
59
+
61
60
  def inherited(child)
62
61
  return if self == Bowline::Binders::Base
63
62
  return if child == Bowline::Binders::Singleton
@@ -73,11 +72,6 @@ module Bowline
73
72
  attr_reader :element
74
73
  attr_reader :item
75
74
 
76
- # Todo
77
- # We want initialize method to take
78
- # no argument, and for every item in items
79
- # to have initialize called on startup,
80
- # so they can set up event handlers etc
81
75
  def self.new(element, *args) #:nodoc:
82
76
  allocate.instance_eval do
83
77
  # jQuery element
@@ -102,29 +96,6 @@ module Bowline
102
96
  self.element.trigger(event, data)
103
97
  end
104
98
 
105
- # Bind event to element:
106
- # bind(:click) { puts "element clicked" }
107
- # todo - two events with the same item/event overwrite each other
108
- # todo - need initalize method on class - so we can set events there
109
- def bind(event, method_name, &block)
110
- event_name = [event, item_id].join(":")
111
- callback = block
112
- callback ||= begin
113
- method_name.is_a?(Method) ?
114
- method_name : method(method_name)
115
- end
116
- self.observer.append(event_name, callback)
117
- self.element.bind(
118
- event.to_s,
119
- event_name,
120
- self.observer.method(:call)
121
- )
122
- end
123
-
124
- def click(method_name = nil, &block)
125
- bind(:click, method, &block)
126
- end
127
-
128
99
  # Raw DOM element
129
100
  def dom
130
101
  self.element[0]
@@ -1,24 +1,27 @@
1
1
  module Bowline
2
2
  module Binders
3
3
  class Collection < Base
4
- cattr_accessor :items
5
4
  class << self
6
5
  def items=(args)
7
- @@items = args
6
+ @items = args
8
7
  self.item_sync!
9
- @@items
8
+ @items
9
+ end
10
+
11
+ def items
12
+ @items ||= []
10
13
  end
11
14
 
12
15
  def item_sync!
13
- return unless @@items && @@elements
14
- @@elements.each {|i|
15
- i.updateCollection(@@items.to_js)
16
+ return unless @items && @elements
17
+ @elements.each {|i|
18
+ i.updateCollection(@items.to_js)
16
19
  }
17
20
  end
18
21
 
19
22
  def find(id)
20
- @@items.find {|item|
21
- item.id == id if item.respond_to?(:id)
23
+ @items.find {|item|
24
+ item.id == id
22
25
  }
23
26
  end
24
27
  end
@@ -1,23 +1,26 @@
1
1
  module Bowline
2
2
  module Binders
3
3
  class Singleton < Base
4
- cattr_accessor :item
5
4
  class << self
5
+ def item
6
+ @item
7
+ end
8
+
6
9
  def item=(arg)
7
- @@item = arg
10
+ @item = arg
8
11
  self.item_sync!
9
12
  end
10
13
 
11
14
  def item_sync!
12
- return unless @@item && @@elements
15
+ return unless @item && @elements
13
16
  # Call the chain.js function 'item' on elements
14
- @@elements.each {|i|
15
- i.updateSingleton(@@item.to_js)
17
+ @elements.each {|i|
18
+ i.updateSingleton(@item.to_js)
16
19
  }
17
20
  end
18
21
 
19
22
  def find(*a)
20
- @@item
23
+ @item
21
24
  end
22
25
  end
23
26
  end