bowline 0.5.8 → 0.6.0

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 (46) hide show
  1. data/README.txt +2 -2
  2. data/Rakefile +3 -2
  3. data/TODO +2 -0
  4. data/VERSION +1 -1
  5. data/assets/bowline.js +131 -68
  6. data/assets/bowline.test.js +86 -0
  7. data/bowline.gemspec +15 -17
  8. data/examples/tweet.rb +3 -1
  9. data/lib/bowline.rb +9 -5
  10. data/lib/bowline/app_config.rb +41 -0
  11. data/lib/bowline/binders.rb +70 -101
  12. data/lib/bowline/binders/collection.rb +37 -0
  13. data/lib/bowline/binders/observer.rb +30 -0
  14. data/lib/bowline/binders/singleton.rb +43 -0
  15. data/lib/bowline/commands/run.rb +1 -0
  16. data/lib/bowline/desktop/bridge.rb +4 -4
  17. data/lib/bowline/desktop/js.rb +7 -3
  18. data/lib/bowline/desktop/runtime.rb +29 -0
  19. data/lib/bowline/desktop/window.rb +9 -1
  20. data/lib/bowline/desktop/window_methods.rb +1 -1
  21. data/lib/bowline/generators/application.rb +1 -0
  22. data/lib/bowline/generators/binder.rb +7 -2
  23. data/lib/bowline/generators/model.rb +1 -1
  24. data/lib/bowline/helpers.rb +2 -0
  25. data/lib/bowline/initializer.rb +39 -87
  26. data/lib/bowline/library.rb +1 -7
  27. data/lib/bowline/tasks/app.rake +1 -53
  28. data/lib/bowline/tasks/libs.rake +4 -17
  29. data/lib/bowline/version.rb +2 -2
  30. data/lib/bowline/watcher.rb +50 -23
  31. data/templates/Gemfile +10 -0
  32. data/templates/config/boot.rb +11 -8
  33. data/templates/main_window.rb +1 -0
  34. metadata +20 -15
  35. data/lib/bowline/dependencies/FAQ.markdown +0 -6
  36. data/lib/bowline/dependencies/MIT-LICENSE +0 -20
  37. data/lib/bowline/dependencies/README.markdown +0 -51
  38. data/lib/bowline/dependencies/TODO.markdown +0 -4
  39. data/lib/bowline/dependencies/lib/dependencies.rb +0 -6
  40. data/lib/bowline/dependencies/lib/dependencies/dependency.rb +0 -12
  41. data/lib/bowline/dependencies/lib/dependencies/repository.rb +0 -64
  42. data/lib/bowline/dependencies/lib/ext/rubygems.rb +0 -116
  43. data/lib/bowline/ext/class.rb +0 -51
  44. data/lib/bowline/ext/string.rb +0 -9
  45. data/lib/bowline/local_model.rb +0 -142
  46. data/lib/bowline/tasks/gems.rake +0 -36
@@ -1,8 +1,8 @@
1
1
  module Bowline
2
2
  module Version #:nodoc:
3
3
  MAJOR = 0
4
- MINOR = 5
5
- TINY = 8
4
+ MINOR = 6
5
+ TINY = 0
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
 
@@ -19,39 +19,66 @@ module Bowline
19
19
  # MyClass.on_update { puts 'update' }
20
20
  # MyClass.new.on_create { puts 'create' }
21
21
  module Base
22
- # Create a helper method to easily add new callbacks.
23
- # Example:
24
- # watch :on_load
25
- # on_load { puts "Loaded!" }
26
- def watch(*names)
27
- names.each do |name|
28
- # Because define_method only takes a block,
29
- # which doesn't accept multiple arguments
30
- script = <<-RUBY
31
- def #{name}(*args, &block)
32
- watcher.append(:#{name}, *args, &block)
33
- end
34
- RUBY
35
- instance_eval script
36
- class_eval script
37
- end
22
+ def self.extended(base)
23
+ base.send :extend, ClassMethods
24
+ end
25
+
26
+ def self.included(base)
27
+ base.send :extend, InstanceMethods
38
28
  end
39
29
 
40
30
  def watcher
41
31
  @watcher ||= Watcher.new
42
32
  end
33
+
34
+ module ClassMethods
35
+ # Create a helper method to easily add new callbacks.
36
+ # Example:
37
+ # watch :on_load
38
+ # on_load { puts "Loaded!" }
39
+ def watch(*names)
40
+ names.each do |name|
41
+ # Because define_method only takes a block,
42
+ # which doesn't accept multiple arguments
43
+ script = <<-RUBY
44
+ def #{name}(*args, &block)
45
+ watcher.append(:#{name}, *args, &block)
46
+ end
47
+ RUBY
48
+ instance_eval script
49
+ end
50
+ end
51
+ end
52
+
53
+ module InstanceMethods #:nodoc:
54
+ def watch(*names)
55
+ names.each do |name|
56
+ script = <<-RUBY
57
+ def #{name}(*args, &block)
58
+ watcher.append(:#{name}, *args, &block)
59
+ end
60
+ RUBY
61
+ class_eval script
62
+ end
63
+ end
64
+ end
43
65
  end
44
66
 
45
67
  class Callback
46
- attr_reader :event, :prok
47
-
48
- def initialize(watcher, event, prok)
49
- @watcher, @event, @prok = watcher, event, prok
68
+
69
+ attr_reader :event, :prok, :oneshot
70
+
71
+ def initialize(watcher, event, prok, oneshot = false)
72
+ @watcher = watcher
73
+ @event = event
74
+ @prok = prok
75
+ @oneshot = oneshot
50
76
  end
51
77
 
52
78
  # Execute callback
53
79
  def call(*args)
54
- @prok.call(*args)
80
+ prok.call(*args)
81
+ remove if oneshot
55
82
  end
56
83
 
57
84
  # Remove callback from watcher
@@ -65,8 +92,8 @@ module Bowline
65
92
  end
66
93
 
67
94
  # Add new method/proc to a specific event.
68
- def append(event, method = nil, &block)
69
- callback = Callback.new(self, event, method||block)
95
+ def append(event, method = nil, oneshot = false, &block)
96
+ callback = Callback.new(self, event, method||block, oneshot)
70
97
  (@listeners[event] ||= []) << callback
71
98
  callback
72
99
  end
@@ -0,0 +1,10 @@
1
+ # Edit this Gemfile to bundle your application's dependencies.
2
+
3
+ gem "rubygems-update"
4
+ gem "bundler", "=0.8.1"
5
+ gem "bowline"
6
+
7
+ ## Bundle the gems you use:
8
+ # gem "bj"
9
+ # gem "hpricot", "0.6"
10
+ # gem "sqlite3-ruby", :require_as => "sqlite3"
@@ -1,12 +1,15 @@
1
- # Don't change this file!
2
- # Configure your app in config/environment.rb
3
-
4
1
  APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), "..")) unless defined?(APP_ROOT)
5
- local_path = File.join(APP_ROOT, *%w{vendor bowline lib bowline.rb})
6
2
 
7
- if File.exist?(local_path)
8
- require local_path
3
+ # Use Bundler (preferred)
4
+ environment = File.expand_path("../../vendor/gems/environment", __FILE__)
5
+ if File.exist?("#{environment}.rb")
6
+ require environment
7
+
8
+ # Use RubyGems
9
9
  else
10
10
  require "rubygems"
11
- require "bowline"
12
- end
11
+ require "bundler"
12
+ Bundler.setup
13
+ end
14
+
15
+ require "bowline"
@@ -1,5 +1,6 @@
1
1
  class MainWindow < Bowline::Desktop::WindowManager
2
2
  setup
3
+ self.file = :index
3
4
  self.width = 300
4
5
  self.height = 400
5
6
  center
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bowline
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.8
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex MacCaw
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-01-19 00:00:00 +00:00
12
+ date: 2010-02-10 00:00:00 +00:00
13
13
  default_executable: bowline-gen
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -30,7 +30,7 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 2.3.2
33
+ version: 3.0.0.beta
34
34
  version:
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: rubyzip2
@@ -42,6 +42,16 @@ dependencies:
42
42
  - !ruby/object:Gem::Version
43
43
  version: 2.0.1
44
44
  version:
45
+ - !ruby/object:Gem::Dependency
46
+ name: supermodel
47
+ type: :runtime
48
+ version_requirement:
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: "0"
54
+ version:
45
55
  description: Ruby/JS GUI framework
46
56
  email: alex@leadthinking.com
47
57
  executables:
@@ -63,6 +73,7 @@ files:
63
73
  - assets/bowline.js
64
74
  - assets/bowline.menu.js
65
75
  - assets/bowline.state.js
76
+ - assets/bowline.test.js
66
77
  - assets/bowline.view.js
67
78
  - assets/jquery.chain.js
68
79
  - assets/jquery.dataset.js
@@ -79,19 +90,15 @@ files:
79
90
  - examples/twitter.html
80
91
  - examples/users.rb
81
92
  - lib/bowline.rb
93
+ - lib/bowline/app_config.rb
82
94
  - lib/bowline/binders.rb
95
+ - lib/bowline/binders/collection.rb
96
+ - lib/bowline/binders/observer.rb
97
+ - lib/bowline/binders/singleton.rb
83
98
  - lib/bowline/commands/build.rb
84
99
  - lib/bowline/commands/console.rb
85
100
  - lib/bowline/commands/generate.rb
86
101
  - lib/bowline/commands/run.rb
87
- - lib/bowline/dependencies/FAQ.markdown
88
- - lib/bowline/dependencies/MIT-LICENSE
89
- - lib/bowline/dependencies/README.markdown
90
- - lib/bowline/dependencies/TODO.markdown
91
- - lib/bowline/dependencies/lib/dependencies.rb
92
- - lib/bowline/dependencies/lib/dependencies/dependency.rb
93
- - lib/bowline/dependencies/lib/dependencies/repository.rb
94
- - lib/bowline/dependencies/lib/ext/rubygems.rb
95
102
  - lib/bowline/desktop.rb
96
103
  - lib/bowline/desktop/app.rb
97
104
  - lib/bowline/desktop/bridge.rb
@@ -103,14 +110,13 @@ files:
103
110
  - lib/bowline/desktop/misc.rb
104
111
  - lib/bowline/desktop/network.rb
105
112
  - lib/bowline/desktop/proxy.rb
113
+ - lib/bowline/desktop/runtime.rb
106
114
  - lib/bowline/desktop/sound.rb
107
115
  - lib/bowline/desktop/window.rb
108
116
  - lib/bowline/desktop/window_manager.rb
109
117
  - lib/bowline/desktop/window_methods.rb
110
118
  - lib/bowline/ext/array.rb
111
- - lib/bowline/ext/class.rb
112
119
  - lib/bowline/ext/object.rb
113
- - lib/bowline/ext/string.rb
114
120
  - lib/bowline/generators.rb
115
121
  - lib/bowline/generators/application.rb
116
122
  - lib/bowline/generators/binder.rb
@@ -121,18 +127,17 @@ files:
121
127
  - lib/bowline/helpers.rb
122
128
  - lib/bowline/initializer.rb
123
129
  - lib/bowline/library.rb
124
- - lib/bowline/local_model.rb
125
130
  - lib/bowline/logging.rb
126
131
  - lib/bowline/platform.rb
127
132
  - lib/bowline/tasks/app.rake
128
133
  - lib/bowline/tasks/bowline.rb
129
134
  - lib/bowline/tasks/database.rake
130
- - lib/bowline/tasks/gems.rake
131
135
  - lib/bowline/tasks/libs.rake
132
136
  - lib/bowline/tasks/log.rake
133
137
  - lib/bowline/tasks/misc.rake
134
138
  - lib/bowline/version.rb
135
139
  - lib/bowline/watcher.rb
140
+ - templates/Gemfile
136
141
  - templates/Rakefile
137
142
  - templates/binder.rb
138
143
  - templates/config/application.yml
@@ -1,6 +0,0 @@
1
- FAQ
2
- ===
3
-
4
- 1. gem install or uninstall fails with gem >= 0 message
5
- > gems/gems/ directory is likely dirty, remove any specifications, cache, doc, gems, or bin folders beneath it.
6
-
@@ -1,20 +0,0 @@
1
- Copyright (c) 2009 [name of plugin creator]
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,51 +0,0 @@
1
- Dependencies
2
- ============
3
-
4
- A port of Merb's dependency system to a Rails plugin.
5
-
6
- Usage
7
- =====
8
-
9
- 1. Install the plugin
10
-
11
- script/plugin install git://github.com/ddollar/dependencies.git
12
-
13
- 2. Add the following line to your config/environment.rb
14
-
15
- config.plugins = [:dependencies, :all]
16
-
17
- 3. Add the following line to your .gitignore
18
-
19
- gems
20
-
21
- 4. Create a config/dependencies.rb file that looks like:
22
-
23
- dependency 'gem'
24
- dependency 'gem', '1.0.1'
25
- dependency 'gem', :require_as => 'Gem'
26
- dependency 'gem', :only => %w(test staging)
27
- dependency 'gem', :except => 'production'
28
-
29
- with_options(:only => 'test') do |test|
30
- test.dependency 'tester-gem'
31
- end
32
-
33
- 5. Remove or comment out any config.gem lines from config/environment.rb or config/environments/*.rb
34
-
35
- 6. Install the gems into your project and keep them up to date using:
36
-
37
- rake dependencies:sync
38
-
39
- 7. Alternatively you can use the following rake task to read your existing config.gem declarations and output a file suitable for this plugin. This task will appropriately handle any gems that you are currently loading on a per-environment basis as well.
40
-
41
- rake dependencies:import
42
-
43
-
44
- About
45
- =====
46
-
47
- Initial idea and Rubygems extension code from [Merb](http://merbivore.com/)
48
-
49
- Rewritten for Rails by [David Dollar](http://daviddollar.org) ([@ddollar](http://twitter.com/ddollar))
50
-
51
- Documentation, testing, ideas by Steven Soroka ([@ssoroka](http://twitter.com/ssoroka))
@@ -1,4 +0,0 @@
1
- To Do
2
- =====
3
-
4
- * Better handling of gems that depend on Rails to load.
@@ -1,6 +0,0 @@
1
- module Dependencies #:nodoc: all
2
- end
3
-
4
- Dir[File.join(File.dirname(__FILE__), 'dependencies', '*.rb')].each do |file|
5
- require file
6
- end
@@ -1,12 +0,0 @@
1
- class Dependencies::Dependency
2
- attr_accessor :name, :versions, :options
3
-
4
- def initialize(name, *options)
5
- opts = options.last.is_a?(Hash) ? options.pop : {}
6
- vers = options
7
-
8
- @name = name
9
- @versions = vers
10
- @options = opts
11
- end
12
- end
@@ -1,64 +0,0 @@
1
- class Dependencies::Repository
2
-
3
- def initialize(base)
4
- @paths = {
5
- :gems => File.join(base),
6
- :bin => File.join(base, 'bin'),
7
- :specs => File.join(base, 'specifications')
8
- }
9
- end
10
-
11
- def index
12
- @index ||= reload_index!
13
- end
14
-
15
- def reload_index!
16
- @index = ::Gem::SourceIndex.new.load_gems_in(@paths[:specs])
17
- end
18
-
19
- def gem(name, versions=[])
20
- ::Gem::Dependency.new(name, versions)
21
- end
22
-
23
- def search(gem)
24
- index.search(gem)
25
- end
26
-
27
- def install(gem)
28
- reload_index!
29
- return if index.search(gem).last
30
-
31
- installer = ::Gem::DependencyInstaller.new(
32
- :bin_dir => @paths[:bin],
33
- :install_dir => @paths[:gems],
34
- :user_install => false)
35
-
36
- begin
37
- installer.install gem.name, gem.version_requirements
38
- rescue ::Gem::GemNotFoundException => e
39
- puts "Cannot find #{gem.name} #{gem.version_requirements}"
40
- rescue ::Gem::RemoteFetcher::FetchError => e
41
- puts "Problem with fetch, retrying..."
42
- retry
43
- end
44
- end
45
-
46
- def uninstall(name, version)
47
- uninstaller = ::Gem::Uninstaller.new(name,
48
- :version => version,
49
- :bin_dir => @paths[:bin],
50
- :install_dir => @paths[:gems],
51
- :ignore => true,
52
- :executables => true
53
- )
54
- uninstaller.uninstall
55
- end
56
-
57
- def installed
58
- Dir[File.join(@paths[:gems], 'gems', '*')].map! { |n| File.basename(n) }
59
- end
60
-
61
- def gems
62
- end
63
-
64
- end
@@ -1,116 +0,0 @@
1
- require 'erb'
2
- require 'rubygems'
3
- require 'rubygems/uninstaller'
4
- require 'rubygems/dependency_installer'
5
-
6
- # We only require this in 'rake gems:sync' since
7
- # it contains some advanced Gem features that aren't
8
- # available in earlier versions, such as pre_install_hooks
9
-
10
- Gem.pre_install_hooks.push(proc do |installer|
11
- name = installer.spec.name
12
-
13
- puts "+ #{name}"
14
-
15
- if $GEMS && versions = ($GEMS.assoc(name) || [])[1]
16
- dep = Gem::Dependency.new(name, versions)
17
- unless dep.version_requirements.satisfied_by?(installer.spec.version)
18
- raise "Cannot install #{installer.spec.full_name} " \
19
- "for #{$INSTALLING}; " \
20
- "you required #{dep}"
21
- end
22
- end
23
- end)
24
-
25
- class ::Gem::Uninstaller #:nodoc:
26
- def self._with_silent_ui
27
-
28
- ui = Gem::DefaultUserInteraction.ui
29
- def ui.say(str)
30
- puts "- #{str}"
31
- end
32
-
33
- yield
34
-
35
- class << Gem::DefaultUserInteraction.ui
36
- remove_method :say
37
- end
38
- end
39
-
40
- def self._uninstall(source_index, name, op, version)
41
- unless source_index.find_name(name, "#{op} #{version}").empty?
42
- uninstaller = Gem::Uninstaller.new(
43
- name,
44
- :version => "#{op} #{version}",
45
- :install_dir => File.join(Dir.pwd, "vendor", "gems"),
46
- :all => true,
47
- :ignore => true,
48
- :executables => true
49
- )
50
- _with_silent_ui { uninstaller.uninstall }
51
- end
52
- end
53
-
54
- def self._uninstall_others(source_index, name, version)
55
- _uninstall(source_index, name, "<", version)
56
- _uninstall(source_index, name, ">", version)
57
- end
58
- end
59
-
60
- Gem.post_install_hooks.push(proc do |installer|
61
- source_index = installer.instance_variable_get("@source_index")
62
- ::Gem::Uninstaller._uninstall_others(
63
- source_index, installer.spec.name, installer.spec.version
64
- )
65
- end)
66
-
67
- class ::Gem::DependencyInstaller #:nodoc:
68
- alias old_fg find_gems_with_sources
69
-
70
- def find_gems_with_sources(dep)
71
- if @source_index.any? { |_, installed_spec|
72
- installed_spec.satisfies_requirement?(dep)
73
- }
74
- return []
75
- end
76
-
77
- old_fg(dep)
78
- end
79
- end
80
-
81
- class ::Gem::SpecFetcher #:nodoc:
82
- alias old_fetch fetch
83
- def fetch(*args) # in rubygems 1.3.2 fetch takes 4 parameters
84
- dependency, all, matching_platform, prerelease = *args
85
- idx = Gem::SourceIndex.from_installed_gems
86
-
87
- reqs = dependency.version_requirements.requirements
88
-
89
- if reqs.size == 1 && reqs[0][0] == "="
90
- dep = idx.search(dependency).sort.last
91
- end
92
-
93
- if dep
94
- file = dep.loaded_from.dup
95
- file.gsub!(/specifications/, "cache")
96
- file.gsub!(/gemspec$/, "gem")
97
- spec = ::Gem::Format.from_file_by_path(file).spec
98
- [[spec, file]]
99
- else
100
- old_fetch(*args)
101
- end
102
- end
103
- end
104
-
105
- class ::Gem::Specification #:nodoc:
106
- def recursive_dependencies(from, index = Gem.source_index)
107
- specs = self.runtime_dependencies.map do |dep|
108
- spec = index.search(dep).last
109
- unless spec
110
- raise "Needed #{dep} for #{from}, but could not find it"
111
- end
112
- spec
113
- end
114
- specs + specs.map {|s| s.recursive_dependencies(self, index)}.flatten.uniq
115
- end
116
- end