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.
- data/README.txt +2 -2
- data/Rakefile +3 -2
- data/TODO +2 -0
- data/VERSION +1 -1
- data/assets/bowline.js +131 -68
- data/assets/bowline.test.js +86 -0
- data/bowline.gemspec +15 -17
- data/examples/tweet.rb +3 -1
- data/lib/bowline.rb +9 -5
- data/lib/bowline/app_config.rb +41 -0
- data/lib/bowline/binders.rb +70 -101
- data/lib/bowline/binders/collection.rb +37 -0
- data/lib/bowline/binders/observer.rb +30 -0
- data/lib/bowline/binders/singleton.rb +43 -0
- data/lib/bowline/commands/run.rb +1 -0
- data/lib/bowline/desktop/bridge.rb +4 -4
- data/lib/bowline/desktop/js.rb +7 -3
- data/lib/bowline/desktop/runtime.rb +29 -0
- data/lib/bowline/desktop/window.rb +9 -1
- data/lib/bowline/desktop/window_methods.rb +1 -1
- data/lib/bowline/generators/application.rb +1 -0
- data/lib/bowline/generators/binder.rb +7 -2
- data/lib/bowline/generators/model.rb +1 -1
- data/lib/bowline/helpers.rb +2 -0
- data/lib/bowline/initializer.rb +39 -87
- data/lib/bowline/library.rb +1 -7
- data/lib/bowline/tasks/app.rake +1 -53
- data/lib/bowline/tasks/libs.rake +4 -17
- data/lib/bowline/version.rb +2 -2
- data/lib/bowline/watcher.rb +50 -23
- data/templates/Gemfile +10 -0
- data/templates/config/boot.rb +11 -8
- data/templates/main_window.rb +1 -0
- metadata +20 -15
- data/lib/bowline/dependencies/FAQ.markdown +0 -6
- data/lib/bowline/dependencies/MIT-LICENSE +0 -20
- data/lib/bowline/dependencies/README.markdown +0 -51
- data/lib/bowline/dependencies/TODO.markdown +0 -4
- data/lib/bowline/dependencies/lib/dependencies.rb +0 -6
- data/lib/bowline/dependencies/lib/dependencies/dependency.rb +0 -12
- data/lib/bowline/dependencies/lib/dependencies/repository.rb +0 -64
- data/lib/bowline/dependencies/lib/ext/rubygems.rb +0 -116
- data/lib/bowline/ext/class.rb +0 -51
- data/lib/bowline/ext/string.rb +0 -9
- data/lib/bowline/local_model.rb +0 -142
- data/lib/bowline/tasks/gems.rake +0 -36
@@ -0,0 +1,29 @@
|
|
1
|
+
module Bowline
|
2
|
+
module Desktop
|
3
|
+
module Runtime
|
4
|
+
def setup
|
5
|
+
Desktop.on_tick(method(:poll))
|
6
|
+
end
|
7
|
+
module_function :setup
|
8
|
+
|
9
|
+
def run_in_main_thread(method = nil, &block)
|
10
|
+
procs << method||block
|
11
|
+
end
|
12
|
+
module_function :run_in_main_thread
|
13
|
+
|
14
|
+
private
|
15
|
+
def poll
|
16
|
+
while proc = procs.shift
|
17
|
+
proc.call
|
18
|
+
end
|
19
|
+
end
|
20
|
+
module_function :poll
|
21
|
+
|
22
|
+
# TODO - thread safety, needs mutex
|
23
|
+
def procs
|
24
|
+
Thread.main[:procs] ||= []
|
25
|
+
end
|
26
|
+
module_function :procs
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -37,6 +37,10 @@ module Bowline
|
|
37
37
|
# :singleton-method: enable
|
38
38
|
# Enable user input to the window.
|
39
39
|
|
40
|
+
##
|
41
|
+
# :singleton-method: enable_developer
|
42
|
+
# Enable developer menu.
|
43
|
+
|
40
44
|
##
|
41
45
|
# :singleton-method: chome=(bool)
|
42
46
|
# Enable/disable window's chrome,
|
@@ -90,6 +94,10 @@ module Bowline
|
|
90
94
|
# :singleton-method: raise
|
91
95
|
# Raise this window above all other ones.
|
92
96
|
|
97
|
+
##
|
98
|
+
# :singleton-method: refresh
|
99
|
+
# Refresh window.
|
100
|
+
|
93
101
|
##
|
94
102
|
# :singleton-method: show
|
95
103
|
# Show this window. By default, windows are hidden.
|
@@ -155,7 +163,7 @@ module Bowline
|
|
155
163
|
|
156
164
|
##
|
157
165
|
# :singleton-method: show_inspector(console = false)
|
158
|
-
# Show WebInspector
|
166
|
+
# Show WebInspector.
|
159
167
|
end
|
160
168
|
|
161
169
|
class MainWindow #:nodoc:
|
@@ -6,19 +6,24 @@ module Bowline::Generators
|
|
6
6
|
|
7
7
|
alias :plain_class_name :class_name
|
8
8
|
def class_name
|
9
|
-
super + "Binder < Bowline::Binders
|
9
|
+
super + "Binder < Bowline::Binders::#{bind_type.capitalize}"
|
10
10
|
end
|
11
11
|
|
12
12
|
def bind_name
|
13
13
|
plain_class_name.singularize
|
14
14
|
end
|
15
15
|
|
16
|
+
def bind_type
|
17
|
+
"Collection"
|
18
|
+
end
|
19
|
+
|
16
20
|
def file_name
|
17
21
|
super + "_binder"
|
18
22
|
end
|
19
23
|
|
20
24
|
first_argument :name, :required => true, :desc => "binder name"
|
21
|
-
|
25
|
+
second_argument :bind_type, :default => "collection", :desc => "binder type (singleton/collection)"
|
26
|
+
|
22
27
|
template :binder do |template|
|
23
28
|
template.source = "binder.rb"
|
24
29
|
template.destination = "app/binders/#{file_name}.rb"
|
data/lib/bowline/helpers.rb
CHANGED
data/lib/bowline/initializer.rb
CHANGED
@@ -71,6 +71,17 @@ module Bowline
|
|
71
71
|
$LOAD_PATH.uniq!
|
72
72
|
end
|
73
73
|
|
74
|
+
def load_gems
|
75
|
+
if defined?(Bundler)
|
76
|
+
# API changed between 0.8 and 0.9
|
77
|
+
if defined?(Bundler.require_env)
|
78
|
+
Bundler.require_env
|
79
|
+
else
|
80
|
+
Bundler.require
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
74
85
|
# Set the paths from which Bowline will automatically load source files, and
|
75
86
|
# the load_once paths.
|
76
87
|
def set_autoload_paths
|
@@ -183,30 +194,7 @@ module Bowline
|
|
183
194
|
ActiveSupport.send("#{setting}=", value)
|
184
195
|
end
|
185
196
|
end
|
186
|
-
|
187
|
-
def initialize_gems
|
188
|
-
require "rubygems"
|
189
|
-
Gem.clear_paths
|
190
|
-
Gem.path.unshift(configuration.gem_path)
|
191
|
-
end
|
192
|
-
|
193
|
-
def load_gems
|
194
|
-
configuration.gems.each do |dep|
|
195
|
-
options = {
|
196
|
-
:lib => dep.name
|
197
|
-
}.merge(dep.options)
|
198
197
|
|
199
|
-
next unless options[:lib]
|
200
|
-
begin
|
201
|
-
gem(dep.name, *dep.versions)
|
202
|
-
require(options[:lib])
|
203
|
-
rescue LoadError => e
|
204
|
-
puts "was unable to require #{dep.name} as '#{options[:lib]}'
|
205
|
-
Reason: #{e.class.name} error raised with message: #{e.message}"
|
206
|
-
end
|
207
|
-
end
|
208
|
-
end
|
209
|
-
|
210
198
|
def load_plugins
|
211
199
|
Dir.glob(File.join(configuration.plugin_glob, 'init.rb')).sort.each do |path|
|
212
200
|
config = configuration # Need local config variable
|
@@ -264,14 +252,7 @@ module Bowline
|
|
264
252
|
# Creates a class called AppConfig from configuration
|
265
253
|
# variables found in config/application.yml
|
266
254
|
def load_app_config
|
267
|
-
|
268
|
-
return unless app_config
|
269
|
-
Object.const_set("AppConfig", Class.new {
|
270
|
-
app_config.keys.each do |key|
|
271
|
-
cattr_accessor key
|
272
|
-
send("#{key}=", app_config[key])
|
273
|
-
end
|
274
|
-
})
|
255
|
+
Object.const_set("AppConfig", AppConfig.new(configuration.app_config_file))
|
275
256
|
end
|
276
257
|
|
277
258
|
def initialize_js
|
@@ -283,14 +264,28 @@ module Bowline
|
|
283
264
|
return unless Bowline::Desktop.enabled?
|
284
265
|
MainWindow.setup
|
285
266
|
MainWindow.name = configuration.name
|
286
|
-
|
267
|
+
end
|
268
|
+
|
269
|
+
def initialize_trap
|
270
|
+
return unless Bowline::Desktop.enabled?
|
271
|
+
trap("INT") {
|
272
|
+
Bowline::Desktop::App.exit
|
273
|
+
}
|
274
|
+
end
|
275
|
+
|
276
|
+
def initialize_marshal
|
277
|
+
return unless defined?(SuperModel)
|
278
|
+
SuperModel::Marshal.path = configuration.marshal_path
|
279
|
+
SuperModel::Marshal.load
|
280
|
+
at_exit {
|
281
|
+
SuperModel::Marshal.dump
|
282
|
+
}
|
287
283
|
end
|
288
284
|
|
289
285
|
def process
|
290
286
|
Bowline.configuration = configuration
|
291
287
|
|
292
288
|
set_load_path
|
293
|
-
initialize_gems
|
294
289
|
load_gems
|
295
290
|
|
296
291
|
require_frameworks
|
@@ -324,6 +319,9 @@ module Bowline
|
|
324
319
|
|
325
320
|
initialize_js
|
326
321
|
initialize_windows
|
322
|
+
initialize_trap
|
323
|
+
|
324
|
+
initialize_marshal
|
327
325
|
|
328
326
|
Bowline.initialized = true
|
329
327
|
end
|
@@ -362,6 +360,8 @@ module Bowline
|
|
362
360
|
|
363
361
|
attr_accessor :binder_paths
|
364
362
|
|
363
|
+
attr_accessor :marshal_path
|
364
|
+
|
365
365
|
# The path to the database configuration file to use. (Defaults to
|
366
366
|
# <tt>config/database.yml</tt>.)
|
367
367
|
attr_accessor :database_configuration_file
|
@@ -403,14 +403,6 @@ module Bowline
|
|
403
403
|
def reload_plugins?
|
404
404
|
!!@reload_plugins
|
405
405
|
end
|
406
|
-
|
407
|
-
# An array of gems that this Bowline application depends on. Bowline will automatically load
|
408
|
-
# these gems during installation, and allow you to install any missing gems with:
|
409
|
-
#
|
410
|
-
# rake gems:sync
|
411
|
-
#
|
412
|
-
# You can add gems with the #gem method.
|
413
|
-
attr_accessor :gems
|
414
406
|
|
415
407
|
attr_accessor :dependency_loading
|
416
408
|
|
@@ -418,23 +410,6 @@ module Bowline
|
|
418
410
|
self.cache_classes = true
|
419
411
|
self.dependency_loading = false
|
420
412
|
end
|
421
|
-
|
422
|
-
# Adds a single Gem dependency to the Bowline application. By default, it will require
|
423
|
-
# the library with the same name as the gem. Use :lib to specify a different name.
|
424
|
-
#
|
425
|
-
# # gem 'aws-s3', '>= 0.4.0'
|
426
|
-
# # require 'aws/s3'
|
427
|
-
# config.gem 'aws-s3', :lib => 'aws/s3', :version => '>= 0.4.0', \
|
428
|
-
# :source => "http://code.whytheluckystiff.net"
|
429
|
-
#
|
430
|
-
# To require a library be installed, but not attempt to load it, pass :lib => false
|
431
|
-
#
|
432
|
-
# config.gem 'qrp', :version => '0.4.1', :lib => false
|
433
|
-
def gem(*args)
|
434
|
-
@gems << Dependencies::Dependency.new(*args)
|
435
|
-
end
|
436
|
-
|
437
|
-
attr_accessor :gem_path
|
438
413
|
|
439
414
|
# Sets the default +time_zone+. Setting this will enable +time_zone+
|
440
415
|
# awareness for Active Record models and set the Active Record default
|
@@ -446,11 +421,7 @@ module Bowline
|
|
446
421
|
attr_accessor :helper_glob
|
447
422
|
|
448
423
|
attr_accessor :initializer_glob
|
449
|
-
|
450
|
-
# Set the path that MainWindow will load
|
451
|
-
# when the application starts.
|
452
|
-
attr_accessor :index_path
|
453
|
-
|
424
|
+
|
454
425
|
# Set the application's name.
|
455
426
|
# This is required.
|
456
427
|
attr_accessor :name
|
@@ -492,16 +463,14 @@ module Bowline
|
|
492
463
|
self.log_path = default_log_path
|
493
464
|
self.log_level = default_log_level
|
494
465
|
self.binder_paths = default_binder_paths
|
466
|
+
self.marshal_path = default_marshal_path
|
495
467
|
self.cache_classes = default_cache_classes
|
496
468
|
self.whiny_nils = default_whiny_nils
|
497
469
|
self.database_configuration_file = default_database_configuration_file
|
498
470
|
self.app_config_file = default_app_config_file
|
499
|
-
self.gems = default_gems
|
500
|
-
self.gem_path = default_gem_path
|
501
471
|
self.plugin_glob = default_plugin_glob
|
502
472
|
self.helper_glob = default_helper_glob
|
503
473
|
self.initializer_glob = default_initalizer_glob
|
504
|
-
self.index_path = default_index_path
|
505
474
|
self.publisher = default_publisher
|
506
475
|
self.copyright = default_copyright
|
507
476
|
|
@@ -530,11 +499,6 @@ module Bowline
|
|
530
499
|
::APP_ROOT.replace @root_path
|
531
500
|
end
|
532
501
|
|
533
|
-
def app_config
|
534
|
-
require 'erb'
|
535
|
-
YAML::load(ERB.new(IO.read(app_config_file)).result) if File.exists?(app_config_file)
|
536
|
-
end
|
537
|
-
|
538
502
|
# Loads and returns the contents of the #database_configuration_file. The
|
539
503
|
# contents of the file are processed via ERB before being sent through
|
540
504
|
# YAML::load.
|
@@ -621,6 +585,10 @@ module Bowline
|
|
621
585
|
def default_binder_paths
|
622
586
|
File.join(root_path, 'app', 'binders')
|
623
587
|
end
|
588
|
+
|
589
|
+
def default_marshal_path
|
590
|
+
File.join(root_path, 'db', 'marshal.db')
|
591
|
+
end
|
624
592
|
|
625
593
|
def default_cache_classes
|
626
594
|
true
|
@@ -630,18 +598,6 @@ module Bowline
|
|
630
598
|
false
|
631
599
|
end
|
632
600
|
|
633
|
-
def default_gems
|
634
|
-
gems = []
|
635
|
-
gems << Dependencies::Dependency.new(
|
636
|
-
"activesupport", :lib => "active_support"
|
637
|
-
)
|
638
|
-
gems
|
639
|
-
end
|
640
|
-
|
641
|
-
def default_gem_path
|
642
|
-
File.join(root_path, *%w{ vendor gems })
|
643
|
-
end
|
644
|
-
|
645
601
|
def default_plugin_glob
|
646
602
|
File.join(root_path, *%w{ vendor plugins * })
|
647
603
|
end
|
@@ -653,10 +609,6 @@ module Bowline
|
|
653
609
|
def default_initalizer_glob
|
654
610
|
File.join(root_path, *%w{ config initializers **/*.rb })
|
655
611
|
end
|
656
|
-
|
657
|
-
def default_index_path
|
658
|
-
File.join(root_path, *%w{ public index.html })
|
659
|
-
end
|
660
612
|
|
661
613
|
def default_publisher
|
662
614
|
"Bowline"
|
data/lib/bowline/library.rb
CHANGED
@@ -25,11 +25,6 @@ module Bowline
|
|
25
25
|
end
|
26
26
|
module_function :libs_path
|
27
27
|
|
28
|
-
def local_bowline_path
|
29
|
-
File.join(APP_ROOT, "vendor", "bowline")
|
30
|
-
end
|
31
|
-
module_function :local_bowline_path
|
32
|
-
|
33
28
|
def local_build_path
|
34
29
|
File.join(APP_ROOT, "build")
|
35
30
|
end
|
@@ -38,8 +33,7 @@ module Bowline
|
|
38
33
|
# Returns true if all required libraries exist.
|
39
34
|
def ready?
|
40
35
|
File.exist?(desktop_path) &&
|
41
|
-
File.directory?(libs_path)
|
42
|
-
File.directory?(local_bowline_path)
|
36
|
+
File.directory?(libs_path)
|
43
37
|
end
|
44
38
|
module_function :ready?
|
45
39
|
|
data/lib/bowline/tasks/app.rake
CHANGED
@@ -3,45 +3,7 @@ require 'erb'
|
|
3
3
|
require 'rbconfig'
|
4
4
|
|
5
5
|
namespace :app do
|
6
|
-
namespace :build do
|
7
|
-
namespace :osx do
|
8
|
-
desc "Copy WebKit into app's Frameworks"
|
9
|
-
task :webkit_framework => :environment do
|
10
|
-
config = Bowline.configuration
|
11
|
-
build_path = Bowline::Library.local_build_path
|
12
|
-
app_path = File.join(build_path, "#{config.name}.app")
|
13
|
-
contents_path = File.join(app_path, "Contents")
|
14
|
-
|
15
|
-
webkit_path = ENV["WEBKIT_PATH"] || "/Applications/WebKit.app/Contents/Frameworks/10.5"
|
16
|
-
unless File.directory?(webkit_path)
|
17
|
-
raise "Install the WebKit nightly: http://nightly.webkit.org/"
|
18
|
-
end
|
19
|
-
frameworks = ["WebKit", "JavaScriptGlue", "WebCore", "JavaScriptCore"]
|
20
|
-
|
21
|
-
FileUtils.cd(contents_path) do
|
22
|
-
FileUtils.mkdir("Frameworks")
|
23
|
-
|
24
|
-
frameworks.each {|name|
|
25
|
-
name = "#{name}.framework"
|
26
|
-
FileUtils.cp_r(
|
27
|
-
File.join(webkit_path, name),
|
28
|
-
"Frameworks"
|
29
|
-
)
|
30
|
-
}
|
31
|
-
|
32
|
-
`install_name_tool -change \
|
33
|
-
/Volumes/Data/WebKit/52531/10.5/WebKit.framework/Versions/A/WebKit \
|
34
|
-
@executable_path/../Frameworks/WebKit.framework/Versions/A/WebKit \
|
35
|
-
MacOS/#{config.name}`
|
36
|
-
|
37
|
-
`install_name_tool -change \
|
38
|
-
/Volumes/Data/WebKit/52531/10.5/WebCore.framework/Versions/A/WebCore \
|
39
|
-
@executable_path/../Frameworks/WebCore.framework/Versions/A/WebCore \
|
40
|
-
MacOS/#{config.name}`
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
6
|
+
namespace :build do
|
45
7
|
task :osx => :environment do
|
46
8
|
unless Bowline::Library.ready?
|
47
9
|
Rake::Task["libs:setup"].invoke
|
@@ -86,20 +48,6 @@ namespace :app do
|
|
86
48
|
dirs.delete(File.join(APP_ROOT, 'db', 'migrate'))
|
87
49
|
dirs.delete_if {|i| i =~ /\.svn|\.DS_Store/ }
|
88
50
|
FileUtils.cp_r(dirs, '.')
|
89
|
-
|
90
|
-
FileUtils.mkdir_p("vendor")
|
91
|
-
FileUtils.cd("vendor") do
|
92
|
-
# Copy Bowline lib
|
93
|
-
bowline_path = "bowline"
|
94
|
-
FileUtils.rm_rf(bowline_path)
|
95
|
-
FileUtils.cp_r(
|
96
|
-
Pathname.new(Bowline.lib_path).realpath,
|
97
|
-
bowline_path
|
98
|
-
)
|
99
|
-
%w{assets pkg examples bin templates .git}.each do |unused|
|
100
|
-
FileUtils.rm_rf(File.join(bowline_path, unused))
|
101
|
-
end
|
102
|
-
end
|
103
51
|
end
|
104
52
|
|
105
53
|
# Copy Bowline binary & libs
|
data/lib/bowline/tasks/libs.rake
CHANGED
@@ -5,14 +5,14 @@ require 'progressbar'
|
|
5
5
|
require 'zip/zip'
|
6
6
|
|
7
7
|
def download(url)
|
8
|
-
puts "Retrieving
|
8
|
+
puts "Retrieving #{url}"
|
9
9
|
name = url.split("/").last
|
10
10
|
file = Tempfile.new("download_#{name}")
|
11
11
|
url = URI.parse(url)
|
12
12
|
req = Net::HTTP::Get.new(url.path)
|
13
13
|
res = Net::HTTP.start(url.host, url.port) {|http|
|
14
14
|
http.request(req) {|resp|
|
15
|
-
pbar = ProgressBar.new("
|
15
|
+
pbar = ProgressBar.new("", resp.content_length || 0)
|
16
16
|
resp.read_body {|seg|
|
17
17
|
pbar.inc(seg.length)
|
18
18
|
file.write(seg)
|
@@ -43,19 +43,6 @@ def sym_or_copy(from, to)
|
|
43
43
|
end
|
44
44
|
|
45
45
|
namespace :libs do
|
46
|
-
task :unpack => :environment do
|
47
|
-
# Lots of people are using Ruby 1.8 with Bowline.
|
48
|
-
# When bowline-desktop loads, it doesn't know where the
|
49
|
-
# Bowline gem is if it's an 1.8 gem dir. So, we just symlink
|
50
|
-
# it to vendor/bowline. One caveat though, is that you have to
|
51
|
-
# re-run this task when you update the gem.
|
52
|
-
local_bowline_path = Bowline::Library.local_bowline_path
|
53
|
-
sym_or_copy(
|
54
|
-
Bowline.lib_path,
|
55
|
-
local_bowline_path
|
56
|
-
) unless File.directory?(local_bowline_path)
|
57
|
-
end
|
58
|
-
|
59
46
|
desc "Download Bowline's binary and pre-compiled libs"
|
60
47
|
task :download => :environment do
|
61
48
|
FileUtils.mkdir_p(Bowline::Library.path)
|
@@ -73,12 +60,12 @@ namespace :libs do
|
|
73
60
|
unless File.directory?(libs_path)
|
74
61
|
libs_tmp = download(Bowline::Library::LIBS_URL)
|
75
62
|
libs_tmp.close
|
76
|
-
puts "Extracting libs.zip
|
63
|
+
puts "Extracting libs.zip"
|
77
64
|
unzip(libs_tmp.path, Bowline::Library.path)
|
78
65
|
end
|
79
66
|
end
|
80
67
|
|
81
|
-
task :setup => [:environment, "
|
68
|
+
task :setup => [:environment, "libs:download", "libs:unpack"]
|
82
69
|
|
83
70
|
desc "Update Bowline's binary and pre-compiled libs"
|
84
71
|
task :update => :environment do
|