rucola 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +628 -0
- data/History.txt +4 -0
- data/License.txt +20 -0
- data/Manifest.txt +106 -0
- data/README.txt +126 -0
- data/Rakefile +32 -0
- data/TODO +28 -0
- data/app_generators/rucola/USAGE +6 -0
- data/app_generators/rucola/rucola_generator.rb +112 -0
- data/app_generators/rucola/templates/Rakefile.erb +12 -0
- data/app_generators/rucola/templates/Rakefile.erb.old +156 -0
- data/app_generators/rucola/templates/app/controllers/application_controller.rb +22 -0
- data/app_generators/rucola/templates/config/Info.plist.erb +28 -0
- data/app_generators/rucola/templates/config/boot.rb +2 -0
- data/app_generators/rucola/templates/config/environment.rb +11 -0
- data/app_generators/rucola/templates/config/environments/debug.rb +3 -0
- data/app_generators/rucola/templates/config/environments/release.rb +3 -0
- data/app_generators/rucola/templates/config/environments/test.rb +3 -0
- data/app_generators/rucola/templates/config/ib_external_class_defs.yml +13 -0
- data/app_generators/rucola/templates/misc/English.lproj/InfoPlist.strings.erb +3 -0
- data/app_generators/rucola/templates/misc/English.lproj/MainMenu.nib/classes.nib +40 -0
- data/app_generators/rucola/templates/misc/English.lproj/MainMenu.nib/info.nib +18 -0
- data/app_generators/rucola/templates/misc/English.lproj/MainMenu.nib/keyedobjects.nib +0 -0
- data/app_generators/rucola/templates/misc/main.m.erb +15 -0
- data/app_generators/rucola/templates/misc/rb_main.rb.erb +13 -0
- data/app_generators/rucola/templates/project.pbxproj.erb +299 -0
- data/app_generators/rucola/templates/script/plugin +84 -0
- data/app_generators/rucola/templates/test/controllers/test_application_controller.rb +10 -0
- data/app_generators/rucola/templates/test/test_helper.rb +10 -0
- data/bin/rucola +12 -0
- data/config/hoe.rb +71 -0
- data/config/requirements.rb +17 -0
- data/lib/rucola.rb +3 -0
- data/lib/rucola/info_plist.rb +37 -0
- data/lib/rucola/initializer.rb +313 -0
- data/lib/rucola/nib.rb +99 -0
- data/lib/rucola/rucola_support.rb +9 -0
- data/lib/rucola/rucola_support/controllers.rb +2 -0
- data/lib/rucola/rucola_support/controllers/rc_controller.rb +7 -0
- data/lib/rucola/rucola_support/controllers/rc_window_controller.rb +12 -0
- data/lib/rucola/rucola_support/core_ext.rb +2 -0
- data/lib/rucola/rucola_support/core_ext/objc.rb +4 -0
- data/lib/rucola/rucola_support/core_ext/objc/nsobject.rb +22 -0
- data/lib/rucola/rucola_support/core_ext/ruby.rb +4 -0
- data/lib/rucola/rucola_support/core_ext/ruby/string.rb +21 -0
- data/lib/rucola/rucola_support/initialize_hooks.rb +21 -0
- data/lib/rucola/rucola_support/models.rb +1 -0
- data/lib/rucola/rucola_support/models/rc_document.rb +10 -0
- data/lib/rucola/rucola_support/notifications.rb +1 -0
- data/lib/rucola/rucola_support/notifications/notifications.rb +146 -0
- data/lib/rucola/rucola_support/rc_app.rb +101 -0
- data/lib/rucola/tasks/freeze.rake +44 -0
- data/lib/rucola/tasks/interface_builder.rake +80 -0
- data/lib/rucola/tasks/main.rake +29 -0
- data/lib/rucola/tasks/xcode.rake +43 -0
- data/lib/rucola/test_helper.rb +57 -0
- data/lib/rucola/version.rb +9 -0
- data/lib/rucola/xcode.rb +148 -0
- data/log/debug.log +0 -0
- data/rucola_generators/controller/USAGE +5 -0
- data/rucola_generators/controller/controller_generator.rb +84 -0
- data/rucola_generators/controller/templates/controller_template.rb.erb +5 -0
- data/rucola_generators/controller/templates/test_controller_template.rb.erb +10 -0
- data/rucola_generators/document_model/USAGE +5 -0
- data/rucola_generators/document_model/document_model_generator.rb +67 -0
- data/rucola_generators/document_model/templates/document_model_template.rb.erb +27 -0
- data/rucola_generators/document_model/templates/test_document_model_template.rb.erb +10 -0
- data/rucola_generators/window_controller/USAGE +6 -0
- data/rucola_generators/window_controller/templates/Window.nib/classes.nib.erb +35 -0
- data/rucola_generators/window_controller/templates/Window.nib/info.nib +16 -0
- data/rucola_generators/window_controller/templates/Window.nib/keyedobjects.nib +0 -0
- data/rucola_generators/window_controller/templates/test_window_controller_template.rb.erb +10 -0
- data/rucola_generators/window_controller/templates/window_controller_template.rb.erb +19 -0
- data/rucola_generators/window_controller/window_controller_generator.rb +74 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/script/txt2html +74 -0
- data/setup.rb +1585 -0
- data/tasks/deployment.rake +27 -0
- data/tasks/environment.rake +7 -0
- data/tasks/website.rake +17 -0
- data/test/fixtures/Info.plist +28 -0
- data/test/fixtures/MainMenu.nib/classes.nib +32 -0
- data/test/fixtures/MainMenu.nib/info.nib +18 -0
- data/test/fixtures/MainMenu.nib/keyedobjects.nib +0 -0
- data/test/test_controller_generator.rb +75 -0
- data/test/test_core_ext.rb +15 -0
- data/test/test_document_model_generator.rb +64 -0
- data/test/test_generator_helper.rb +20 -0
- data/test/test_helper.rb +13 -0
- data/test/test_info_plist.rb +31 -0
- data/test/test_nib.rb +73 -0
- data/test/test_notifications.rb +75 -0
- data/test/test_objc_core_ext.rb +37 -0
- data/test/test_rc_app.rb +63 -0
- data/test/test_rc_document.rb +18 -0
- data/test/test_rc_window_controller.rb +13 -0
- data/test/test_rucola.rb +11 -0
- data/test/test_rucola_generator.rb +87 -0
- data/test/test_window_controller_generator.rb +50 -0
- data/test/test_xcode.rb +128 -0
- data/website/index.html +199 -0
- data/website/index.txt +126 -0
- data/website/javascripts/rounded_corners_lite.inc.js +285 -0
- data/website/stylesheets/screen.css +138 -0
- data/website/template.rhtml +48 -0
- metadata +189 -0
@@ -0,0 +1,27 @@
|
|
1
|
+
desc 'Release the website and new gem version'
|
2
|
+
task :deploy => [:check_version, :website, :release] do
|
3
|
+
puts "Remember to create SVN tag:"
|
4
|
+
puts "svn copy svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/trunk " +
|
5
|
+
"svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/tags/REL-#{VERS} "
|
6
|
+
puts "Suggested comment:"
|
7
|
+
puts "Tagging release #{CHANGES}"
|
8
|
+
end
|
9
|
+
|
10
|
+
desc 'Runs tasks website_generate and install_gem as a local deployment of the gem'
|
11
|
+
task :local_deploy => [:website_generate, :install_gem]
|
12
|
+
|
13
|
+
task :check_version do
|
14
|
+
unless ENV['VERSION']
|
15
|
+
puts 'Must pass a VERSION=x.y.z release version'
|
16
|
+
exit
|
17
|
+
end
|
18
|
+
unless ENV['VERSION'] == VERS
|
19
|
+
puts "Please update your version.rb to match the release version, currently #{VERS}"
|
20
|
+
exit
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
desc 'Install the package as a gem, without generating documentation(ri/rdoc)'
|
25
|
+
task :install_gem_no_doc => [:clean, :package] do
|
26
|
+
sh "#{'sudo ' unless Hoe::WINDOZE }gem install pkg/*.gem --no-rdoc --no-ri"
|
27
|
+
end
|
data/tasks/website.rake
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
desc 'Generate website files'
|
2
|
+
task :website_generate => :ruby_env do
|
3
|
+
(Dir['website/**/*.txt'] - Dir['website/version*.txt']).each do |txt|
|
4
|
+
sh %{ #{RUBY_APP} script/txt2html #{txt} > #{txt.gsub(/txt$/,'html')} }
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
desc 'Upload website files to rubyforge'
|
9
|
+
task :website_upload do
|
10
|
+
host = "#{rubyforge_username}@rubyforge.org"
|
11
|
+
remote_dir = "/var/www/gforge-projects/#{PATH}/"
|
12
|
+
local_dir = 'website'
|
13
|
+
sh %{rsync -aCv #{local_dir}/ #{host}:#{remote_dir}}
|
14
|
+
end
|
15
|
+
|
16
|
+
desc 'Generate and upload website files'
|
17
|
+
task :website => [:website_generate, :website_upload, :publish_docs]
|
@@ -0,0 +1,28 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
3
|
+
<plist version="1.0">
|
4
|
+
<dict>
|
5
|
+
<key>CFBundleDevelopmentRegion</key>
|
6
|
+
<string>English</string>
|
7
|
+
<key>CFBundleExecutable</key>
|
8
|
+
<string>MyApp</string>
|
9
|
+
<key>CFBundleIconFile</key>
|
10
|
+
<string></string>
|
11
|
+
<key>CFBundleInfoDictionaryVersion</key>
|
12
|
+
<string>6.0</string>
|
13
|
+
<key>CFBundlePackageType</key>
|
14
|
+
<string>APPL</string>
|
15
|
+
<key>CFBundleSignature</key>
|
16
|
+
<string>????</string>
|
17
|
+
<key>CFBundleVersion</key>
|
18
|
+
<string>1.0</string>
|
19
|
+
<key>NSMainNibFile</key>
|
20
|
+
<string>MainMenu</string>
|
21
|
+
<key>NSPrincipalClass</key>
|
22
|
+
<string>NSApplication</string>
|
23
|
+
<key>CFBundleIdentifier</key>
|
24
|
+
<string>com.apple.rubycocoa.MyAppApp</string>
|
25
|
+
<key>CFBundleShortVersionString</key>
|
26
|
+
<string>1.0</string>
|
27
|
+
</dict>
|
28
|
+
</plist>
|
@@ -0,0 +1,32 @@
|
|
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>CLASS</key>
|
17
|
+
<string>ApplicationController</string>
|
18
|
+
<key>LANGUAGE</key>
|
19
|
+
<string>ObjC</string>
|
20
|
+
<key>OUTLETS</key>
|
21
|
+
<dict>
|
22
|
+
<key>main_window</key>
|
23
|
+
<string>id</string>
|
24
|
+
</dict>
|
25
|
+
<key>SUPERCLASS</key>
|
26
|
+
<string>NSObject</string>
|
27
|
+
</dict>
|
28
|
+
</array>
|
29
|
+
<key>IBVersion</key>
|
30
|
+
<string>1</string>
|
31
|
+
</dict>
|
32
|
+
</plist>
|
@@ -0,0 +1,18 @@
|
|
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>629</string>
|
7
|
+
<key>IBOldestOS</key>
|
8
|
+
<integer>5</integer>
|
9
|
+
<key>IBOpenObjects</key>
|
10
|
+
<array>
|
11
|
+
<integer>21</integer>
|
12
|
+
</array>
|
13
|
+
<key>IBSystem Version</key>
|
14
|
+
<string>9A581</string>
|
15
|
+
<key>targetFramework</key>
|
16
|
+
<string>IBCocoaFramework</string>
|
17
|
+
</dict>
|
18
|
+
</plist>
|
Binary file
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "test_generator_helper.rb")
|
2
|
+
require File.join(File.dirname(__FILE__), "test_helper.rb")
|
3
|
+
require 'rucola/nib'
|
4
|
+
|
5
|
+
class TestControllerGenerator < Test::Unit::TestCase
|
6
|
+
include RubiGen::GeneratorTestHelper
|
7
|
+
|
8
|
+
def setup
|
9
|
+
bare_setup
|
10
|
+
end
|
11
|
+
|
12
|
+
def teardown
|
13
|
+
bare_teardown
|
14
|
+
end
|
15
|
+
|
16
|
+
# Some generator-related assertions:
|
17
|
+
# assert_generated_file(name, &block) # block passed the file contents
|
18
|
+
# assert_directory_exists(name)
|
19
|
+
# assert_generated_class(name, &block)
|
20
|
+
# assert_generated_module(name, &block)
|
21
|
+
# assert_generated_test_for(name, &block)
|
22
|
+
# The assert_generated_(class|module|test_for) &block is passed the body of the class/module within the file
|
23
|
+
# assert_has_method(body, *methods) # check that the body has a list of methods (methods with parentheses not supported yet)
|
24
|
+
#
|
25
|
+
# Other helper methods are:
|
26
|
+
# app_root_files - put this in teardown to show files generated by the test method (e.g. p app_root_files)
|
27
|
+
# bare_setup - place this in setup method to create the APP_ROOT folder for each test
|
28
|
+
# bare_teardown - place this in teardown method to destroy the TMP_ROOT or APP_ROOT folder after each test
|
29
|
+
|
30
|
+
def test_generator_without_options
|
31
|
+
# say yes to the question if we want to add the controller to the classes in MainMenu.nib
|
32
|
+
Kernel.expects(:gets).returns("Y\n")
|
33
|
+
|
34
|
+
nib_path = File.expand_path('../tmp/myproject/misc/English.lproj/MainMenu.nib/classes.nib', __FILE__)
|
35
|
+
nib_mock = mock_nib(nib_path)
|
36
|
+
|
37
|
+
name = "Articles"
|
38
|
+
run_generator('controller', [name], sources)
|
39
|
+
|
40
|
+
assert_generated_file 'app/controllers/articles_controller.rb'
|
41
|
+
assert_generated_file 'test/controllers/test_articles_controller.rb'
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_generator_with_options_nibs_to_update
|
45
|
+
main_nib_path = File.expand_path('../tmp/myproject/misc/English.lproj/MainMenu.nib/classes.nib', __FILE__)
|
46
|
+
main_nib_mock = mock_nib(main_nib_path)
|
47
|
+
|
48
|
+
foo_nib_path = File.expand_path('../tmp/myproject/app/views/Foo.nib/classes.nib', __FILE__)
|
49
|
+
foo_nib_mock = mock_nib(foo_nib_path)
|
50
|
+
|
51
|
+
name = "Articles"
|
52
|
+
run_generator('controller', [name, 'MainMenu', 'Foo'], sources)
|
53
|
+
|
54
|
+
assert_generated_file 'app/controllers/articles_controller.rb'
|
55
|
+
assert_generated_file 'test/controllers/test_articles_controller.rb'
|
56
|
+
end
|
57
|
+
|
58
|
+
def mock_nib(nib_path)
|
59
|
+
nib_mock = mock('Classes Nib')
|
60
|
+
Rucola::Nib::Classes.expects(:open).with(nib_path).returns(nib_mock)
|
61
|
+
nib_mock.expects(:add_class).with('ArticlesController')
|
62
|
+
nib_mock.expects(:save)
|
63
|
+
nib_mock
|
64
|
+
end
|
65
|
+
|
66
|
+
private
|
67
|
+
def sources
|
68
|
+
[RubiGen::PathSource.new(:test, File.join(File.dirname(__FILE__),"..", generator_path))
|
69
|
+
]
|
70
|
+
end
|
71
|
+
|
72
|
+
def generator_path
|
73
|
+
"rucola_generators"
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
2
|
+
|
3
|
+
describe 'String#camel_case' do
|
4
|
+
it "should return foo_bar as FooBar" do
|
5
|
+
"foo_bar".camel_case.should == 'FooBar'
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should return FooBar as FooBar" do
|
9
|
+
"FooBar".camel_case.should == 'FooBar'
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should return foo as Foo" do
|
13
|
+
'foo'.camel_case.should == 'Foo'
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "test_generator_helper.rb")
|
2
|
+
|
3
|
+
class TestDocumentModelGenerator < Test::Unit::TestCase
|
4
|
+
include RubiGen::GeneratorTestHelper
|
5
|
+
|
6
|
+
def setup
|
7
|
+
bare_setup
|
8
|
+
end
|
9
|
+
|
10
|
+
def teardown
|
11
|
+
bare_teardown
|
12
|
+
end
|
13
|
+
|
14
|
+
# Some generator-related assertions:
|
15
|
+
# assert_generated_file(name, &block) # block passed the file contents
|
16
|
+
# assert_directory_exists(name)
|
17
|
+
# assert_generated_class(name, &block)
|
18
|
+
# assert_generated_module(name, &block)
|
19
|
+
# assert_generated_test_for(name, &block)
|
20
|
+
# The assert_generated_(class|module|test_for) &block is passed the body of the class/module within the file
|
21
|
+
# assert_has_method(body, *methods) # check that the body has a list of methods (methods with parentheses not supported yet)
|
22
|
+
#
|
23
|
+
# Other helper methods are:
|
24
|
+
# app_root_files - put this in teardown to show files generated by the test method (e.g. p app_root_files)
|
25
|
+
# bare_setup - place this in setup method to create the APP_ROOT folder for each test
|
26
|
+
# bare_teardown - place this in teardown method to destroy the TMP_ROOT or APP_ROOT folder after each test
|
27
|
+
|
28
|
+
def test_generator_without_options
|
29
|
+
name = "MyDocument"
|
30
|
+
extension = 'mydocext'
|
31
|
+
|
32
|
+
plist_mock = mock('Info Plist')
|
33
|
+
OSX::NSDictionary.expects(:dictionaryWithContentsOfFile).returns(plist_mock)
|
34
|
+
doc_types = []
|
35
|
+
plist_mock.expects(:[]).with('CFBundleDocumentTypes').returns(doc_types)
|
36
|
+
plist_mock.expects(:writeToFile_atomically)
|
37
|
+
|
38
|
+
run_generator('document_model', [name, extension], sources)
|
39
|
+
|
40
|
+
assert doc_types.length, 1
|
41
|
+
assert doc_types.first['NSDocumentClass'] == name
|
42
|
+
|
43
|
+
assert_generated_file 'app/controllers/my_document_controller.rb'
|
44
|
+
assert_generated_file 'test/controllers/test_my_document_controller.rb'
|
45
|
+
|
46
|
+
assert_generated_file 'app/models/my_document.rb'
|
47
|
+
assert_generated_file 'test/models/test_my_document.rb'
|
48
|
+
|
49
|
+
assert_directory_exists 'app/views/MyDocument.nib'
|
50
|
+
assert_generated_file 'app/views/MyDocument.nib/classes.nib'
|
51
|
+
assert_generated_file 'app/views/MyDocument.nib/info.nib'
|
52
|
+
assert_generated_file 'app/views/MyDocument.nib/keyedobjects.nib'
|
53
|
+
end
|
54
|
+
|
55
|
+
private
|
56
|
+
def sources
|
57
|
+
[RubiGen::PathSource.new(:test, File.join(File.dirname(__FILE__),"..", generator_path))
|
58
|
+
]
|
59
|
+
end
|
60
|
+
|
61
|
+
def generator_path
|
62
|
+
"rucola_generators"
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
2
|
+
require 'fileutils'
|
3
|
+
|
4
|
+
# Must set before requiring generator libs.
|
5
|
+
TMP_ROOT = File.dirname(__FILE__) + "/tmp" unless defined?(TMP_ROOT)
|
6
|
+
PROJECT_NAME = "myproject" unless defined?(PROJECT_NAME)
|
7
|
+
app_root = File.join(TMP_ROOT, PROJECT_NAME)
|
8
|
+
if defined?(APP_ROOT)
|
9
|
+
APP_ROOT.replace(app_root)
|
10
|
+
else
|
11
|
+
APP_ROOT = app_root
|
12
|
+
end
|
13
|
+
|
14
|
+
begin
|
15
|
+
require 'rubigen'
|
16
|
+
rescue LoadError
|
17
|
+
require 'rubygems'
|
18
|
+
require 'rubigen'
|
19
|
+
end
|
20
|
+
require 'rubigen/helpers/generator_test_helper'
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "test/unit"
|
3
|
+
require "test/spec"
|
4
|
+
require "mocha"
|
5
|
+
require 'osx/cocoa'
|
6
|
+
|
7
|
+
$:.unshift File.expand_path('../../lib', __FILE__)
|
8
|
+
|
9
|
+
FIXTURES = File.expand_path('../fixtures/', __FILE__)
|
10
|
+
$TESTING = true
|
11
|
+
|
12
|
+
require 'rucola/rucola_support'
|
13
|
+
require 'rucola/test_helper'
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require File.expand_path('../test_helper', __FILE__)
|
2
|
+
require 'rucola/info_plist'
|
3
|
+
|
4
|
+
describe "Info" do
|
5
|
+
before do
|
6
|
+
@path = FIXTURES + '/Info.plist'
|
7
|
+
@info_plist = Rucola::InfoPlist.open(@path)
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should be able to load an Info.plist file" do
|
11
|
+
@info_plist.data.should.be.an.instance_of OSX::NSCFDictionary
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should be able to add document types" do
|
15
|
+
before = @info_plist.document_types.length
|
16
|
+
@info_plist.add_document_type('MyDocument', 'mydocextension', 'Editor')
|
17
|
+
@info_plist.add_document_type('MyDocument2', 'mydocextension2', 'Editor')
|
18
|
+
|
19
|
+
@info_plist.document_types.length.should.be before + 2
|
20
|
+
|
21
|
+
@info_plist.document_types.to_ruby.should == [
|
22
|
+
{"CFBundleTypeOSTypes"=>["????"], "CFBundleTypeExtensions"=>["mydocextension"], "NSDocumentClass"=>"MyDocument", "CFBundleTypeName"=>"DocumentType", "CFBundleTypeIconFile"=>"????", "CFBundleTypeRole"=>"Editor"},
|
23
|
+
{"CFBundleTypeOSTypes"=>["????"], "CFBundleTypeExtensions"=>["mydocextension2"], "NSDocumentClass"=>"MyDocument2", "CFBundleTypeName"=>"DocumentType", "CFBundleTypeIconFile"=>"????", "CFBundleTypeRole"=>"Editor"}
|
24
|
+
]
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should be able to save the plist" do
|
28
|
+
@info_plist.data.expects(:writeToFile_atomically).with(@path, true)
|
29
|
+
@info_plist.save
|
30
|
+
end
|
31
|
+
end
|
data/test/test_nib.rb
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
require File.expand_path('../test_helper', __FILE__)
|
2
|
+
require 'rucola/nib'
|
3
|
+
|
4
|
+
include Rucola
|
5
|
+
|
6
|
+
describe 'Nib' do
|
7
|
+
it "should be able to backup a nib" do
|
8
|
+
path = '/some/path/MainMenu.nib/classes.nib'
|
9
|
+
backup = "/tmp/MainMenu.nib.bak"
|
10
|
+
File.expects(:exists?).with(backup).returns(true)
|
11
|
+
FileUtils.expects(:rm_rf).with(backup)
|
12
|
+
FileUtils.expects(:cp_r).with(File.dirname(path), backup)
|
13
|
+
Rucola::Nib.backup(path)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe 'Nib::Classes' do
|
18
|
+
before do
|
19
|
+
@path = FIXTURES + '/MainMenu.nib/classes.nib'
|
20
|
+
@nib = Nib::Classes.open(@path)
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should be able to load the classes.nib" do
|
24
|
+
@nib.data.should.be.an.instance_of OSX::NSCFDictionary
|
25
|
+
@nib.classes.should.be.an.instance_of OSX::NSCFArray
|
26
|
+
@nib.classes.last['CLASS'].should == 'ApplicationController'
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should be able to add a subclass of NSObject" do
|
30
|
+
before = @nib.classes.length
|
31
|
+
@nib.add_class('FooController')
|
32
|
+
@nib.classes.length.should.be before + 1
|
33
|
+
|
34
|
+
@nib.classes.last.to_ruby.should == { 'CLASS' => 'FooController', "LANGUAGE"=>"ObjC", "SUPERCLASS"=>"NSObject" }
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should be able to save the classes.nib" do
|
38
|
+
Rucola::Nib.expects(:backup).with(@path)
|
39
|
+
@nib.data.expects(:writeToFile_atomically).with(@path, true)
|
40
|
+
@nib.save
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should be able to check if a class is defined" do
|
44
|
+
@nib.add_class('BarController')
|
45
|
+
@nib.has_class?('BarController').should.be true
|
46
|
+
@nib.has_class?('NotInThere').should.be false
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe 'Nib::KeyedObjects' do
|
51
|
+
before do
|
52
|
+
@path = FIXTURES + '/MainMenu.nib/keyedobjects.nib'
|
53
|
+
@nib = Nib::KeyedObjects.open(@path)
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should be able to load the keyedobjects.nib" do
|
57
|
+
@nib.data.should.be.an.instance_of OSX::NSCFDictionary
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should be able to change the custom class of the File's owner" do
|
61
|
+
@nib.change_files_owner_class('Japie')
|
62
|
+
@nib.files_owner_class.should == 'Japie'
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should be able to save the keyedobjects.nib" do
|
66
|
+
plist_mock = mock('Serialized Plist mock')
|
67
|
+
OSX::NSPropertyListSerialization.expects(:dataFromPropertyList_format_errorDescription).with(@nib.data, OSX::NSPropertyListBinaryFormat_v1_0).returns(plist_mock)
|
68
|
+
Rucola::Nib.expects(:backup).with(@path)
|
69
|
+
File.expects(:exists?).with(File.dirname(@path))
|
70
|
+
plist_mock.expects(:writeToFile_atomically).with(@path, true)
|
71
|
+
@nib.save
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
+
|
3
|
+
class FooNotifiable < Rucola::RCController; end
|
4
|
+
class BarNotifiable < Rucola::RCController; end
|
5
|
+
class BazNotifiable < Rucola::RCController; end
|
6
|
+
class BlaNotifiable < Rucola::RCController; end
|
7
|
+
class FuNotifiable < Rucola::RCController; end
|
8
|
+
class KungNotifiable < Rucola::RCController; end
|
9
|
+
class Person < Rucola::RCController; end
|
10
|
+
|
11
|
+
describe 'Rucola::Notifications' do
|
12
|
+
it "should handle notifications when included" do
|
13
|
+
FooNotifiable.instance_variable_get(:@_registered_notifications).should.be.nil
|
14
|
+
|
15
|
+
FooNotifiable.notify_on 'FooNotification' do |notification|
|
16
|
+
some_instance_method
|
17
|
+
end
|
18
|
+
|
19
|
+
FooNotifiable.instance_variable_get(:@_registered_notifications).length.should.be 1
|
20
|
+
|
21
|
+
instance = FooNotifiable.alloc.init
|
22
|
+
instance.methods.should.include '_handle_foo_notification'
|
23
|
+
|
24
|
+
instance.expects(:some_instance_method)
|
25
|
+
OSX::NSNotificationCenter.defaultCenter.postNotificationName_object('FooNotification', self)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should be able to handle the original string representations of the notifications" do
|
29
|
+
BarNotifiable.notify_on 'NSApplicationDidFinishLaunchingNotification' do |notification|
|
30
|
+
app_finished_launching
|
31
|
+
end
|
32
|
+
|
33
|
+
BarNotifiable.alloc.init.expects(:app_finished_launching)
|
34
|
+
OSX::NSNotificationCenter.defaultCenter.postNotificationName_object(OSX::NSApplicationDidFinishLaunchingNotification, self)
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should also be able to handle the abbreviated symbol representation of a notification" do
|
38
|
+
BazNotifiable.notify_on :application_did_become_active do |notification|
|
39
|
+
app_did_become_active
|
40
|
+
end
|
41
|
+
|
42
|
+
BazNotifiable.alloc.init.expects(:app_did_become_active)
|
43
|
+
OSX::NSNotificationCenter.defaultCenter.postNotificationName_object(OSX::NSApplicationDidBecomeActiveNotification, self)
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should raise a NameError exception if the abbreviated notification wasn't found" do
|
47
|
+
lambda { BlaNotifiable.notify_on :does_not_exist do |notification|; end }.should.raise NameError
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should also allow the user to define shortcuts" do
|
51
|
+
FuNotifiable.notification_prefix :win => :window
|
52
|
+
|
53
|
+
FuNotifiable.notify_on :win_did_become_key do |notification|
|
54
|
+
window_did_become_key
|
55
|
+
end
|
56
|
+
|
57
|
+
FuNotifiable.alloc.init.expects(:window_did_become_key)
|
58
|
+
OSX::NSNotificationCenter.defaultCenter.postNotificationName_object(OSX::NSWindowDidBecomeKeyNotification, self)
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should by default have the shortcut app => application" do
|
62
|
+
KungNotifiable.notify_on :app_will_terminate do |notification|
|
63
|
+
app_will_terminate_called!
|
64
|
+
end
|
65
|
+
|
66
|
+
KungNotifiable.alloc.init.expects(:app_will_terminate_called!)
|
67
|
+
OSX::NSNotificationCenter.defaultCenter.postNotificationName_object(OSX::NSApplicationWillTerminateNotification, self)
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should call a given method when a certain notification is called" do
|
71
|
+
Person.notify :method_to_notify, :when => 'MyNotification'
|
72
|
+
Person.alloc.init.expects(:method_to_notify)
|
73
|
+
OSX::NSNotificationCenter.defaultCenter.postNotificationName_object("MyNotification", nil)
|
74
|
+
end
|
75
|
+
end
|