celerity 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/History.txt +14 -0
- data/Manifest.txt +127 -151
- data/README.txt +15 -20
- data/lib/celerity.rb +13 -5
- data/lib/celerity/browser.rb +296 -0
- data/lib/celerity/clickable_element.rb +1 -0
- data/lib/celerity/collections.rb +4 -0
- data/lib/celerity/container.rb +69 -2
- data/lib/celerity/disabled_element.rb +1 -0
- data/lib/celerity/element.rb +103 -38
- data/lib/celerity/element_collections.rb +14 -8
- data/lib/celerity/element_locator.rb +61 -50
- data/lib/celerity/element_map.rb +51 -0
- data/lib/celerity/elements/button.rb +1 -0
- data/lib/celerity/elements/file_field.rb +3 -2
- data/lib/celerity/elements/form.rb +1 -0
- data/lib/celerity/elements/frame.rb +16 -1
- data/lib/celerity/elements/image.rb +15 -13
- data/lib/celerity/elements/link.rb +4 -1
- data/lib/celerity/elements/option.rb +1 -0
- data/lib/celerity/elements/radio_check.rb +19 -7
- data/lib/celerity/elements/select_list.rb +17 -2
- data/lib/celerity/elements/table.rb +34 -20
- data/lib/celerity/elements/table_body.rb +2 -2
- data/lib/celerity/elements/table_cell.rb +3 -1
- data/lib/celerity/elements/table_footer.rb +2 -2
- data/lib/celerity/elements/table_header.rb +2 -2
- data/lib/celerity/elements/table_row.rb +4 -2
- data/lib/celerity/elements/text_field.rb +20 -9
- data/lib/celerity/exception.rb +11 -18
- data/lib/celerity/extra/method_generator.rb +13 -8
- data/lib/celerity/htmlunit/download.sh +23 -0
- data/lib/celerity/htmlunit/htmlunit-2.2.jar +0 -0
- data/lib/celerity/htmlunit/htmlunit-core-js-2.2.jar +0 -0
- data/lib/celerity/htmlunit/{nekohtml-1.9.7.jar → nekohtml-1.9.8.jar} +0 -0
- data/lib/celerity/input_element.rb +1 -1
- data/lib/celerity/version.rb +1 -1
- data/lib/celerity/watir_compatibility.rb +37 -23
- data/spec/area_spec.rb +19 -4
- data/spec/areas_spec.rb +2 -3
- data/spec/{ie_spec.rb → browser_spec.rb} +66 -15
- data/spec/button_spec.rb +36 -3
- data/spec/buttons_spec.rb +2 -3
- data/spec/checkbox_spec.rb +43 -8
- data/spec/checkboxes_spec.rb +2 -3
- data/spec/div_spec.rb +31 -4
- data/spec/divs_spec.rb +2 -3
- data/spec/element_spec.rb +36 -6
- data/spec/filefield_spec.rb +28 -13
- data/spec/filefields_spec.rb +2 -3
- data/spec/form_spec.rb +6 -3
- data/spec/forms_spec.rb +2 -3
- data/spec/frame_spec.rb +14 -5
- data/spec/frames_spec.rb +71 -0
- data/spec/hidden_spec.rb +21 -3
- data/spec/hiddens_spec.rb +2 -3
- data/spec/hn_spec.rb +30 -12
- data/spec/hns_spec.rb +14 -10
- data/spec/html/form_js_bug.html +11 -0
- data/spec/html/forms_with_input_elements.html +2 -1
- data/spec/html/invalid_js.html +11 -0
- data/spec/html/latin1_text.html +1 -0
- data/spec/html/non_control_elements.html +8 -4
- data/spec/html/simple_ajax.html +22 -0
- data/spec/htmlunit_spec.rb +4 -5
- data/spec/image_spec.rb +33 -3
- data/spec/images_spec.rb +2 -3
- data/spec/label_spec.rb +16 -3
- data/spec/labels_spec.rb +2 -3
- data/spec/li_spec.rb +25 -3
- data/spec/link_spec.rb +35 -3
- data/spec/links_spec.rb +2 -3
- data/spec/lis_spec.rb +2 -3
- data/spec/map_spec.rb +19 -3
- data/spec/maps_spec.rb +2 -3
- data/spec/meta_spec.rb +3 -1
- data/spec/ol_spec.rb +17 -3
- data/spec/ols_spec.rb +2 -3
- data/spec/option_spec.rb +28 -3
- data/spec/p_spec.rb +30 -2
- data/spec/pre_spec.rb +25 -3
- data/spec/pres_spec.rb +2 -3
- data/spec/ps_spec.rb +2 -3
- data/spec/radio_spec.rb +47 -3
- data/spec/radios_spec.rb +2 -3
- data/spec/select_list_spec.rb +42 -3
- data/spec/select_lists_spec.rb +2 -3
- data/spec/span_spec.rb +32 -7
- data/spec/spans_spec.rb +2 -4
- data/spec/spec_helper.rb +5 -25
- data/spec/table_bodies_spec.rb +7 -5
- data/spec/table_body_spec.rb +11 -4
- data/spec/table_cell_spec.rb +15 -4
- data/spec/table_cells_spec.rb +3 -4
- data/spec/table_footer_spec.rb +11 -4
- data/spec/table_footers_spec.rb +7 -5
- data/spec/table_header_spec.rb +11 -4
- data/spec/table_headers_spec.rb +7 -5
- data/spec/table_row_spec.rb +31 -7
- data/spec/table_rows_spec.rb +5 -4
- data/spec/table_spec.rb +36 -7
- data/spec/tables_spec.rb +2 -3
- data/spec/text_field_spec.rb +51 -13
- data/spec/text_fields_spec.rb +2 -3
- data/spec/ul_spec.rb +18 -3
- data/spec/uls_spec.rb +2 -3
- data/spec/{watir_compatability_spec.rb → watir_compatibility_spec.rb} +42 -35
- data/support/spec_server.rb +9 -0
- metadata +167 -161
- metadata.gz.sig +0 -0
- data/benchmark/bm_2000_spans.rb +0 -48
- data/benchmark/bm_digg.rb +0 -26
- data/benchmark/bm_google_images.rb +0 -36
- data/benchmark/bm_input_locator.rb +0 -69
- data/benchmark/loader.rb +0 -9
- data/config/hoe.rb +0 -68
- data/config/requirements.rb +0 -15
- data/lib/celerity/htmlunit/htmlunit-2.2-SNAPSHOT.jar +0 -0
- data/lib/celerity/htmlunit/js-1.7R1.jar +0 -0
- data/lib/celerity/ie.rb +0 -195
- data/setup.rb +0 -1583
- data/support/celerity_viewer/rubycocoa/CelerityViewer.icns +0 -0
- data/support/celerity_viewer/rubycocoa/English.lproj/Main.nib/classes.nib +0 -37
- data/support/celerity_viewer/rubycocoa/English.lproj/Main.nib/info.nib +0 -19
- data/support/celerity_viewer/rubycocoa/English.lproj/Main.nib/keyedobjects.nib +0 -0
- data/support/celerity_viewer/rubycocoa/Info.plist.erb +0 -28
- data/support/celerity_viewer/rubycocoa/MainController.rb +0 -23
- data/support/celerity_viewer/rubycocoa/README +0 -94
- data/support/celerity_viewer/rubycocoa/Rakefile +0 -100
- data/support/celerity_viewer/rubycocoa/distributed_viewer.rb +0 -86
- data/support/celerity_viewer/rubycocoa/main.m +0 -7
- data/support/celerity_viewer/rubycocoa/main.rb +0 -27
- data/tasks/benchmark.rake +0 -4
- data/tasks/environment.rake +0 -7
- data/tasks/simple_ci.rake +0 -94
Binary file
|
@@ -1,37 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
3
|
-
<plist version="1.0">
|
4
|
-
<dict>
|
5
|
-
<key>IBClasses</key>
|
6
|
-
<array>
|
7
|
-
<dict>
|
8
|
-
<key>CLASS</key>
|
9
|
-
<string>FirstResponder</string>
|
10
|
-
<key>LANGUAGE</key>
|
11
|
-
<string>ObjC</string>
|
12
|
-
<key>SUPERCLASS</key>
|
13
|
-
<string>NSObject</string>
|
14
|
-
</dict>
|
15
|
-
<dict>
|
16
|
-
<key>ACTIONS</key>
|
17
|
-
<dict>
|
18
|
-
<key>load_url</key>
|
19
|
-
<string>id</string>
|
20
|
-
</dict>
|
21
|
-
<key>CLASS</key>
|
22
|
-
<string>MainController</string>
|
23
|
-
<key>LANGUAGE</key>
|
24
|
-
<string>ObjC</string>
|
25
|
-
<key>OUTLETS</key>
|
26
|
-
<dict>
|
27
|
-
<key>text_field</key>
|
28
|
-
<string>id</string>
|
29
|
-
<key>web_view</key>
|
30
|
-
<string>id</string>
|
31
|
-
</dict>
|
32
|
-
</dict>
|
33
|
-
</array>
|
34
|
-
<key>IBVersion</key>
|
35
|
-
<string>1</string>
|
36
|
-
</dict>
|
37
|
-
</plist>
|
@@ -1,19 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
3
|
-
<plist version="1.0">
|
4
|
-
<dict>
|
5
|
-
<key>IBFramework Version</key>
|
6
|
-
<string>644</string>
|
7
|
-
<key>IBOldestOS</key>
|
8
|
-
<integer>5</integer>
|
9
|
-
<key>IBOpenObjects</key>
|
10
|
-
<array>
|
11
|
-
<integer>81</integer>
|
12
|
-
<integer>21</integer>
|
13
|
-
</array>
|
14
|
-
<key>IBSystem Version</key>
|
15
|
-
<string>9C7010</string>
|
16
|
-
<key>targetFramework</key>
|
17
|
-
<string>IBCocoaFramework</string>
|
18
|
-
</dict>
|
19
|
-
</plist>
|
Binary file
|
@@ -1,28 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
|
3
|
-
<plist version="0.9">
|
4
|
-
<dict>
|
5
|
-
<key>CFBundleExecutable</key>
|
6
|
-
<string><%=APPNAME%></string>
|
7
|
-
<key>CFBundleIdentifier</key>
|
8
|
-
<string><%=BUNDLEID%></string>
|
9
|
-
<key>CFBundlePackageType</key>
|
10
|
-
<string>APPL</string>
|
11
|
-
<key>CFBundleSignature</key>
|
12
|
-
<string>????</string>
|
13
|
-
<key>NSHumanReadableCopyright</key>
|
14
|
-
<string><%=COPYRIGHT%></string>
|
15
|
-
<key>CFBundleIconFile</key>
|
16
|
-
<string>CelerityViewer</string>
|
17
|
-
|
18
|
-
<key>NSMainNibFile</key>
|
19
|
-
<string>Main</string>
|
20
|
-
<key>NSPrincipalClass</key>
|
21
|
-
<string>NSApplication</string>
|
22
|
-
|
23
|
-
<!-- Not Show in Dock
|
24
|
-
<key>LSUIElement</key>
|
25
|
-
<string>1</string>
|
26
|
-
-->
|
27
|
-
</dict>
|
28
|
-
</plist>
|
@@ -1,23 +0,0 @@
|
|
1
|
-
require 'osx/cocoa'
|
2
|
-
require "distributed_viewer"
|
3
|
-
include OSX
|
4
|
-
require_framework 'WebKit'
|
5
|
-
|
6
|
-
class MainController < NSObject
|
7
|
-
ib_outlets :web_view, :text_field
|
8
|
-
|
9
|
-
def awakeFromNib
|
10
|
-
@web_view.preferences.setShouldPrintBackgrounds(true)
|
11
|
-
NSUserDefaults.standardUserDefaults.setObject_forKey('YES', 'WebKitDeveloperExtras')
|
12
|
-
DRb.start_service("druby://127.0.0.1:1337", DistributedViewer.new(@web_view, @text_field))
|
13
|
-
end
|
14
|
-
|
15
|
-
def load_url(sender)
|
16
|
-
str = sender.stringValue
|
17
|
-
url = NSURL.URLWithString(str.to_ruby =~ /^https?/ ? str : "http://#{str}" )
|
18
|
-
@web_view.mainFrame.loadRequest(OSX::NSURLRequest.requestWithURL(url))
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|
22
|
-
|
23
|
-
|
@@ -1,94 +0,0 @@
|
|
1
|
-
require 'osx/cocoa' # dummy
|
2
|
-
require 'rubygems'
|
3
|
-
require 'rake'
|
4
|
-
require 'rake/clean'
|
5
|
-
require 'rake/testtask'
|
6
|
-
require 'erb'
|
7
|
-
require 'pathname'
|
8
|
-
|
9
|
-
# Application own Settings
|
10
|
-
APPNAME = "Celerity_viewer"
|
11
|
-
TARGET = "#{APPNAME}.app"
|
12
|
-
VERSION = "rev#{`svn info`[/Revision: (\d+)/, 1]}"
|
13
|
-
RESOURCES = ['*.rb', '*.lproj', 'Credits.*', '*.icns']
|
14
|
-
PKGINC = [TARGET, 'README', 'html', 'client']
|
15
|
-
LOCALENIB = [] #['Japanese.lproj/Main.nib']
|
16
|
-
PUBLISH = 'yourname@yourhost:path'
|
17
|
-
|
18
|
-
BUNDLEID = "rubyapp.#{APPNAME}"
|
19
|
-
|
20
|
-
CLEAN.include ['**/.*.sw?', '*.dmg', TARGET, 'image', 'a.out']
|
21
|
-
|
22
|
-
# Tasks
|
23
|
-
task :default => [:test]
|
24
|
-
|
25
|
-
desc 'Create Application Budle and Run it.'
|
26
|
-
task :test => [TARGET] do
|
27
|
-
sh %{open '#{TARGET}'}
|
28
|
-
end
|
29
|
-
|
30
|
-
desc 'Create .dmg file for Publish'
|
31
|
-
task :package => [:clean, 'pkg', TARGET] do
|
32
|
-
name = "#{APPNAME}.#{VERSION}"
|
33
|
-
sh %{
|
34
|
-
mkdir image
|
35
|
-
cp -r #{PKGINC.join(' ')} image
|
36
|
-
ln -s html/index.html image/index.html
|
37
|
-
}
|
38
|
-
puts 'Creating Image...'
|
39
|
-
sh %{
|
40
|
-
hdiutil create -volname #{name} -srcfolder image #{name}.dmg
|
41
|
-
rm -rf image
|
42
|
-
mv #{name}.dmg pkg
|
43
|
-
}
|
44
|
-
end
|
45
|
-
|
46
|
-
desc 'Publish .dmg file to specific server.'
|
47
|
-
task :publish => [:package] do
|
48
|
-
sh %{
|
49
|
-
svn log > CHANGES
|
50
|
-
}
|
51
|
-
_, host, path = */^([^\s]+):(.+)$/.match(PUBLISH)
|
52
|
-
path = Pathname.new path
|
53
|
-
puts "Publish: Host: %s, Path: %s" % [host, path]
|
54
|
-
sh %{
|
55
|
-
scp pkg/IIrcv.#{VERSION}.dmg #{PUBLISH}/pkg
|
56
|
-
scp CHANGES #{PUBLISH}/pkg
|
57
|
-
scp -r html/* #{PUBLISH}
|
58
|
-
}
|
59
|
-
end
|
60
|
-
|
61
|
-
desc 'Make Localized nib from English.lproj and Lang.lproj/nib.strings'
|
62
|
-
rule(/.nib$/ => [proc {|tn| File.dirname(tn) + '/nib.strings' }]) do |t|
|
63
|
-
p t.name
|
64
|
-
lproj = File.dirname(t.name)
|
65
|
-
target = File.basename(t.name)
|
66
|
-
sh %{
|
67
|
-
rm -rf #{t.name}
|
68
|
-
nibtool -d #{lproj}/nib.strings -w #{t.name} English.lproj/#{target}
|
69
|
-
}
|
70
|
-
end
|
71
|
-
|
72
|
-
# File tasks
|
73
|
-
desc 'Make executable Application Bundle'
|
74
|
-
file TARGET => [:clean, APPNAME] + LOCALENIB do
|
75
|
-
sh %{
|
76
|
-
mkdir -p "#{APPNAME}.app/Contents/MacOS"
|
77
|
-
mkdir "#{APPNAME}.app/Contents/Resources"
|
78
|
-
cp -rp #{RESOURCES.join(' ')} "#{APPNAME}.app/Contents/Resources"
|
79
|
-
cp '#{APPNAME}' "#{APPNAME}.app/Contents/MacOS"
|
80
|
-
echo -n "APPL????" > "#{APPNAME}.app/Contents/PkgInfo"
|
81
|
-
echo -n #{VERSION} > "#{APPNAME}.app/Contents/Resources/VERSION"
|
82
|
-
}
|
83
|
-
File.open("#{APPNAME}.app/Contents/Info.plist", "w") do |f|
|
84
|
-
f.puts ERB.new(File.read("Info.plist.erb")).result
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
file APPNAME => ['main.m'] do
|
89
|
-
# Universal Binary
|
90
|
-
sh %{gcc -arch ppc -arch i386 -Wall -lobjc -framework RubyCocoa main.m -o '#{APPNAME}'}
|
91
|
-
end
|
92
|
-
|
93
|
-
directory 'pkg'
|
94
|
-
|
@@ -1,100 +0,0 @@
|
|
1
|
-
require 'osx/cocoa' # dummy
|
2
|
-
require 'rubygems'
|
3
|
-
require 'rake'
|
4
|
-
require 'rake/clean'
|
5
|
-
require 'rake/testtask'
|
6
|
-
require 'erb'
|
7
|
-
require 'pathname'
|
8
|
-
|
9
|
-
# Application own Settings
|
10
|
-
APPNAME = "CelerityViewer"
|
11
|
-
TARGET = "#{APPNAME}.app"
|
12
|
-
v = "rev#{`svn info`[/Revision: (\d+)/, 1]}"
|
13
|
-
APP_VERSION = (v == 'rev' ? "rev#{`git-svn info`[/Revision: (\d+)/, 1]}" : v)
|
14
|
-
RESOURCES = ['*.rb', '*.lproj', 'Credits.*', '*.icns']
|
15
|
-
PKGINC = [TARGET, 'README', 'html', 'client']
|
16
|
-
LOCALENIB = [] #['Japanese.lproj/Main.nib']
|
17
|
-
COPYRIGHT = "Copyright © 2008 FinnTech AS"
|
18
|
-
#PUBLISH = 'yourname@yourhost:path'
|
19
|
-
BUNDLEID = "no.finntech.#{APPNAME.downcase}"
|
20
|
-
|
21
|
-
|
22
|
-
CLEAN.include ['**/.*.sw?', '*.dmg', TARGET, 'image', 'a.out']
|
23
|
-
|
24
|
-
# Tasks
|
25
|
-
task :default => [:test]
|
26
|
-
|
27
|
-
desc 'Create Application Budle and Run it.'
|
28
|
-
task :test => [TARGET] do
|
29
|
-
sh %{open '#{TARGET}'}
|
30
|
-
end
|
31
|
-
|
32
|
-
desc 'Create .dmg file for Publish'
|
33
|
-
task :package => [:clean, 'pkg', TARGET] do
|
34
|
-
name = "#{APPNAME}.#{APP_VERSION}"
|
35
|
-
sh %{
|
36
|
-
mkdir image
|
37
|
-
cp -r #{PKGINC.join(' ')} image
|
38
|
-
ln -s html/index.html image/index.html
|
39
|
-
}
|
40
|
-
puts 'Creating Image...'
|
41
|
-
sh %{
|
42
|
-
hdiutil create -volname #{name} -srcfolder image #{name}.dmg
|
43
|
-
rm -rf image
|
44
|
-
mv #{name}.dmg pkg
|
45
|
-
}
|
46
|
-
end
|
47
|
-
|
48
|
-
desc 'Publish .dmg file to specific server.'
|
49
|
-
task :publish => [:package] do
|
50
|
-
sh %{
|
51
|
-
svn log > CHANGES
|
52
|
-
}
|
53
|
-
_, host, path = */^([^\s]+):(.+)$/.match(PUBLISH)
|
54
|
-
path = Pathname.new path
|
55
|
-
puts "Publish: Host: %s, Path: %s" % [host, path]
|
56
|
-
sh %{
|
57
|
-
scp pkg/IIrcv.#{APP_VERSION}.dmg #{PUBLISH}/pkg
|
58
|
-
scp CHANGES #{PUBLISH}/pkg
|
59
|
-
scp -r html/* #{PUBLISH}
|
60
|
-
}
|
61
|
-
end
|
62
|
-
|
63
|
-
desc 'Make Localized nib from English.lproj and Lang.lproj/nib.strings'
|
64
|
-
rule(/.nib$/ => [proc {|tn| File.dirname(tn) + '/nib.strings' }]) do |t|
|
65
|
-
p t.name
|
66
|
-
lproj = File.dirname(t.name)
|
67
|
-
target = File.basename(t.name)
|
68
|
-
sh %{
|
69
|
-
rm -rf #{t.name}
|
70
|
-
nibtool -d #{lproj}/nib.strings -w #{t.name} English.lproj/#{target}
|
71
|
-
}
|
72
|
-
end
|
73
|
-
|
74
|
-
# File tasks
|
75
|
-
desc 'Make executable Application Bundle'
|
76
|
-
file TARGET => [:clean, APPNAME] + LOCALENIB do
|
77
|
-
sh %{
|
78
|
-
mkdir -p "#{APPNAME}.app/Contents/MacOS"
|
79
|
-
mkdir "#{APPNAME}.app/Contents/Resources"
|
80
|
-
cp -rp #{RESOURCES.join(' ')} "#{APPNAME}.app/Contents/Resources"
|
81
|
-
cp '#{APPNAME}' "#{APPNAME}.app/Contents/MacOS"
|
82
|
-
echo -n "APPL????" > "#{APPNAME}.app/Contents/PkgInfo"
|
83
|
-
echo #{APP_VERSION} > "#{APPNAME}.app/Contents/Resources/VERSION"
|
84
|
-
}
|
85
|
-
File.open("#{APPNAME}.app/Contents/Info.plist", "w") do |f|
|
86
|
-
f.puts ERB.new(File.read("Info.plist.erb")).result
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
file APPNAME => ['main.m'] do
|
91
|
-
# Universal Binary
|
92
|
-
sh %{gcc -arch ppc -arch i386 -Wall -lobjc -framework RubyCocoa main.m -o '#{APPNAME}'}
|
93
|
-
end
|
94
|
-
|
95
|
-
desc 'Install the application bundle in /Applications'
|
96
|
-
task :install => [TARGET] do
|
97
|
-
sh "cp -R #{APPNAME}.app /Applications", :verbose => true
|
98
|
-
end
|
99
|
-
directory 'pkg'
|
100
|
-
|
@@ -1,86 +0,0 @@
|
|
1
|
-
require "drb"
|
2
|
-
require "drb/acl"
|
3
|
-
require "uri"
|
4
|
-
|
5
|
-
DRb.install_acl(ACL.new(%w{deny all allow 127.0.0.1}))
|
6
|
-
|
7
|
-
class DistributedViewer
|
8
|
-
attr_reader :web_view
|
9
|
-
|
10
|
-
def initialize(web_view, url_field)
|
11
|
-
@web_view = web_view
|
12
|
-
@url_field = url_field
|
13
|
-
end
|
14
|
-
|
15
|
-
def render_html(html, url = nil)
|
16
|
-
begin
|
17
|
-
if url
|
18
|
-
uri = URI.parse(url)
|
19
|
-
base_url = "#{uri.scheme}://#{uri.host}"
|
20
|
-
@url_field.setStringValue(url)
|
21
|
-
url = NSURL.URLWithString(base_url)
|
22
|
-
end
|
23
|
-
@web_view.mainFrame.loadHTMLString_baseURL(html, url)
|
24
|
-
rescue => e
|
25
|
-
log(e)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def print(path = nil)
|
30
|
-
if path
|
31
|
-
# TODO: fix printing
|
32
|
-
|
33
|
-
# =========
|
34
|
-
# = Alt I =
|
35
|
-
# =========
|
36
|
-
# rect = @web_view.mainFrame.frameView.documentView.bounds
|
37
|
-
# view = @web_view.mainFrame.frameView.documentView
|
38
|
-
# print_operation = NSPrintOperation.PDFOperationWithView_insideRect_toPath_printInfo(view,
|
39
|
-
# rect,
|
40
|
-
# path,
|
41
|
-
# NSPrintInfo.sharedPrintInfo)
|
42
|
-
# print_operation.runOperation
|
43
|
-
|
44
|
-
# ======================================================================
|
45
|
-
# = Alt II : http://www.cocoadev.com/index.pl?GettingViewContentAsImage =
|
46
|
-
# ======================================================================
|
47
|
-
print_info = NSPrintInfo.sharedPrintInfo
|
48
|
-
print_info.setJobDisposition(NSPrintSaveJob)
|
49
|
-
print_info.dictionary.setObject_forKey(path, NSPrintSavePath)
|
50
|
-
print_info.dictionary.setObject_forKey(1, NSPrintFirstPage)
|
51
|
-
print_info.dictionary.setObject_forKey(1, NSPrintLastPage)
|
52
|
-
print_info.dictionary.setObject_forKey("Letter", NSPrintPaperName)
|
53
|
-
print_info.setBottomMargin(0.0)
|
54
|
-
print_info.setTopMargin(0.0)
|
55
|
-
print_info.setLeftMargin(0.0)
|
56
|
-
print_info.setRightMargin(0.0)
|
57
|
-
|
58
|
-
operation = NSPrintOperation.printOperationWithView_printInfo(@web_view.mainFrame.frameView.documentView, print_info)
|
59
|
-
operation.setShowPanels(false)
|
60
|
-
operation.runOperation
|
61
|
-
|
62
|
-
# ===============================================================
|
63
|
-
# = Alt III : /Developer/Examples/RubyCocoa/Scripts/darkroom.rb =
|
64
|
-
# ===============================================================
|
65
|
-
# viewport = @web_view.mainFrame.frameView.documentView
|
66
|
-
# log(1)
|
67
|
-
# # viewport.window.orderFront(nil)
|
68
|
-
# viewport.window.display
|
69
|
-
# log(2)
|
70
|
-
# # viewport.window.setContentSize(viewport.bounds)
|
71
|
-
# viewport.setFrame(viewport.bounds)
|
72
|
-
# log(3)
|
73
|
-
# viewport.lockFocus
|
74
|
-
# log(4)
|
75
|
-
# bitmap = NSBitmapImageRep.alloc.initWithFocusedViewRect(viewport.bounds)
|
76
|
-
# viewport.unLockFocus
|
77
|
-
# log(5)
|
78
|
-
# log(bitmap)
|
79
|
-
# bitmap.representationUsingType_properties(NSPNGFileType, nil).writeToFile_atomically(path, true)
|
80
|
-
# log(6)
|
81
|
-
else
|
82
|
-
@web_view.print(nil)
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
|
2
|
-
begin
|
3
|
-
require 'rubygems'
|
4
|
-
rescue LoadError
|
5
|
-
end
|
6
|
-
require 'osx/cocoa'
|
7
|
-
require 'pathname'
|
8
|
-
|
9
|
-
def log(*args)
|
10
|
-
args.each do |m|
|
11
|
-
OSX.NSLog m.inspect
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
def _(key)
|
16
|
-
NSLocalizedString(key, '').to_s
|
17
|
-
end
|
18
|
-
|
19
|
-
path = Pathname.new OSX::NSBundle.mainBundle.resourcePath.fileSystemRepresentation
|
20
|
-
Pathname.glob(path + '*.rb') do |file|
|
21
|
-
next if file.to_s == __FILE__
|
22
|
-
require(file)
|
23
|
-
end
|
24
|
-
OSX::NSApplication.sharedApplication
|
25
|
-
OSX.NSApplicationMain(0, nil)
|
26
|
-
|
27
|
-
|
data/tasks/benchmark.rake
DELETED