Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Remove references to hotcocoa from the MacRuby sources

Move as much of it as possible to hotcocoa itself.
  • Loading branch information...
commit 72e46f09b60963cefe2ce0170c5650ad6a85b185 1 parent 67828ba
@ferrous26 ferrous26 authored
View
4 instruby.rb
@@ -304,12 +304,12 @@ def with_destdir(dir)
bname = File.basename(src)
name = case bname
- when 'hotcocoa', 'rb_nibtool'
+ when 'rb_nibtool'
bname
else
ruby_install_name.sub(/ruby/, bname)
end
-
+
shebang = ''
body = ''
open(src, "rb") do |f|
View
4 rakelib/builder/options.rb
@@ -65,14 +65,14 @@ def self.option(name, default)
# Everything below this comment should *not* be modified.
if ENV['build_as_embeddable']
- $stderr.puts "The 'build_as_embeddable' build configuration has been removed because it is no longer necessary. To package a full version of MacRuby inside your application, please use `macrake deploy` for HotCocoa apps and the `Embed MacRuby` target for Xcode apps."
+ $stderr.puts "The 'build_as_embeddable' build configuration has been removed because it is no longer necessary. To package a full version of MacRuby inside your application, please use the `Embed MacRuby' target for Xcode apps or `macruby_deploy` in a script."
exit 1
end
verbose(true)
if `sw_vers -productVersion`.strip < '10.5.6'
- $stderr.puts "Sorry, your environment is not supported. MacRuby requires Mac OS X 10.5.6 or higher."
+ $stderr.puts "Sorry, your environment is not supported. MacRuby requires Mac OS X 10.5.6 or higher."
exit 1
end
View
4 sample-macruby/README.rdoc
@@ -36,10 +36,6 @@ This directory contains example applications written using MacRuby and using Coc
+YamlTable+:: NSTableView, YAML, NSAlert, Sheet
-The HotCocoa directory contains examples for the MacRuby's HotCocoa
-gem, which aims at making Cocoa development easier for Ruby
-developers.
-
You will also find some standalone scripts in the Scripts directory. These
files are meant to be run from the command line.
View
81 sample-macruby/Scripts/growl/hotcocoa_growl.rb
@@ -1,81 +0,0 @@
-require 'hotcocoa'
-
-class Growl
- include HotCocoa
-
- attr_accessor :delegate
-
- GROWL_IS_READY = 'Lend Me Some Sugar; I Am Your Neighbor!'
- GROWL_NOTIFICATION_CLICKED = 'GrowlClicked!'
- GROWL_NOTIFICATION_TIMED_OUT = 'GrowlTimedOut!'
- GROWL_CLICKED_CONTEXT_KEY = 'ClickedContext'
-
- PRIORITIES = {
- :emergency => 2,
- :high => 1,
- :normal => 0,
- :moderate => -1,
- :very_low => -2,
- }
-
- def register(app_name, notifications, default_notifications=nil, icon=nil)
- @app_name = app_name
- @app_icon = icon || NSApplication.sharedApplication.applicationIconImage
- @notifications = notifications
- @default_notifications = default_notifications || notifications
- register_to_growl!
- end
-
- def notify(name, title, desc, options={})
- dic = {
- :NotificationName => name,
- :NotificationTitle => title,
- :NotificationDescription => desc,
- :NotificationPriority => PRIORITIES[options[:priority]] || options[:priority] || 0,
- :ApplicationName => @app_name,
- :ApplicationPID => pid,
- }
- dic[:NotificationIcon] = options[:icon].TIFFRepresentation if options[:icon]
- dic[:NotificationSticky] = 1 if options[:sticky]
-
- context = {}
- context[:user_click_context] = options[:click_context] if options[:click_context]
- dic[:NotificationClickContext] = context unless context.empty?
-
- notification :distributed => true, :name => :GrowlNotification, :info => dic
- end
-
- private
-
- def pid
- NSProcessInfo.processInfo.processIdentifier
- end
-
- def register_to_growl!
- on_notification(:distributed => true, :named => GROWL_IS_READY) do |n|
- register_to_growl!
- end
-
- on_notification(:distributed => true, :named => "#{@app_name}-#{pid}-#{GROWL_NOTIFICATION_CLICKED}") do |n|
- if @delegate and @delegate.respond_to?('growlNotifierClicked:context:')
- ctx = n.userInfo[GROWL_CLICKED_CONTEXT_KEY][:user_click_context]
- @delegate.growlNotifierClicked(self, context:ctx)
- end
- end
-
- on_notification(:distributed => true, :named => "#{@app_name}-#{pid}-#{GROWL_NOTIFICATION_TIMED_OUT}") do |n|
- if @delegate and @delegate.respond_to?('growlNotifierTimedOut:context:')
- ctx = n.userInfo[GROWL_CLICKED_CONTEXT_KEY][:user_click_context]
- @delegate.growlNotifierTimedOut(self, context:ctx)
- end
- end
-
- dic = {
- :ApplicationName => @app_name,
- :ApplicationIcon => @app_icon.TIFFRepresentation,
- :AllNotifications => @notifications,
- :DefaultNotifications => @default_notifications,
- }
- notification :distributed => true, :name => :GrowlApplicationRegistrationNotification, :info => dic
- end
-end
View
35 sample-macruby/Scripts/growl/hotcocoa_sample.rb
@@ -1,35 +0,0 @@
-require 'hotcocoa_growl'
-
-class GrowlController
- HELLO_TYPE = 'Hello message received'
-
- def init
- if super
- @g = Growl.alloc.init
- @g.delegate = self
- @g.register('GrowlSample', [HELLO_TYPE])
- @g.notify(HELLO_TYPE, 'Sticky', 'Hello world', :sticky => true, :click_context => Time.now.to_s)
- @g.notify(HELLO_TYPE, 'Timed out', 'Hello world', :click_context => Time.now.to_s)
- @count = 2
- self
- end
- end
-
- def growlNotifierClicked(sender, context:context)
- puts "Clicked: #{context}"
- checkCount
- end
-
- def growlNotifierTimedOut(sender, context:context)
- puts "Timed out: #{context}"
- checkCount
- end
-
- def checkCount
- @count -= 1
- NSApp.terminate(nil) if @count == 0
- end
-end
-
-g = GrowlController.new
-NSApp.run
View
63 test-macruby/cases/hotcocoa/mapper_test.rb
@@ -1,63 +0,0 @@
-#!/usr/bin/env macruby
-
-require File.expand_path('../../../test_helper', __FILE__)
-require 'hotcocoa'
-
-class SampleClass
-end
-
-class TestMapper < Test::Unit::TestCase
-
- include HotCocoa::Mappings
-
- it "should have two hash attributes named #bindings and #delegate" do
- assert Mapper.bindings_modules.is_a?(Hash)
- assert Mapper.delegate_modules.is_a?(Hash)
- end
-
- [ :control_class, :builder_method, :control_module,
- :map_bindings, :map_bindings= ].each do |method|
-
- it "should have a #{method} attribute" do
- assert_respond_to(sample_mapper, method)
- end
-
- end
-
- it "should set it's control class on initialization" do
- assert_equal(sample_mapper(true).control_class, SampleClass)
- end
-
- it "should convert from camelcase to underscore" do
- assert sample_mapper.underscore("SampleCamelCasedWord"), 'sample_camel_cased_word'
- end
-
- def test_include_in_class
- m = sample_mapper(true)
- m.include_in_class
-
- assert_equal m.instance_variable_get('@extension_method'), :include
-
- flunk 'Pending.'
- end
-
- def test_each_control_ancestor
- flunk 'Pending.'
- end
-
- def test_map_class
- flunk 'Pending.'
- end
-
- def test_map_instances_of
- flunk 'Pending.'
- end
-
- private
-
- def sample_mapper(flush = false)
- @mapper = nil if flush
- @mapper || Mapper.new(SampleClass)
- end
-
-end
View
128 test-macruby/cases/hotcocoa/mappings_test.rb
@@ -1,128 +0,0 @@
-#!/usr/bin/env macruby
-
-require File.expand_path('../../../test_helper', __FILE__)
-require 'hotcocoa'
-
-class SampleClass
-end
-
-class Mock
- def call!
- @called = true
- end
-
- def called?
- @called
- end
-end
-
-class TestMappings < Test::Unit::TestCase
-
- include HotCocoa
-
- after do
- Mappings.mappings[:klass] = nil
- Mappings.frameworks["theframework"] = nil
- Mappings.loaded_frameworks.delete('theframework')
- end
-
- it "should have two Hash attributes named #mappings and #frameworks" do
- assert Mappings.mappings.is_a?(Hash)
- assert Mappings.frameworks.is_a?(Hash)
- end
-
- it "should create a mapping to a class with a Class instance given to #map" do
- Mappings.map(:klass => SampleClass) {}
- assert_equal SampleClass, Mappings.mappings[:klass].control_class
- end
-
- it "should create a mapping to a class with a string name of the class given to #map" do
- Mappings.map(:klass => 'SampleClass') {}
- assert_equal SampleClass, Mappings.mappings[:klass].control_class
- end
-
- it "should create a mapping to a class with a symbol name of the class given to #map" do
- Mappings.map(:klass => :SampleClass) {}
- assert_equal SampleClass, Mappings.mappings[:klass].control_class
- end
-
- it "should register the key, in the options given to #map, as the builder_method" do
- Mappings.map(:klass => SampleClass) {}
- assert_equal Mappings.mappings[:klass].builder_method, :klass
- end
-
- it "should use the block given to #map as the control_module body" do
- Mappings.map(:klass => SampleClass) do
- def a_control_module_instance_method; end
- end
-
- assert Mappings.mappings[:klass].control_module.
- instance_methods.include?(:a_control_module_instance_method)
- end
-
- it "should create a mapping to a class in a framework with #map" do
- mock = Mock.new
-
- Mappings.map(:klass => 'SampleClass', :framework => 'TheFramework') do
- mock.call!
- end
- Mappings.frameworks["theframework"].last.call
-
- assert mock.called?
- end
-
- it "should execute the framework's callbacks when #framework_loaded is called" do
- mocks = Array.new(2) { Mock.new }
-
- mocks.each do |mock|
- Mappings.on_framework('TheFramework') { mock.call! }
- end
- Mappings.framework_loaded('TheFramework')
-
- mocks.each { |mock| assert mock.called? }
- end
-
- it "should do nothing if the framework passed to #framework_loaded isn't registered" do
- assert_nothing_raised do
- Mappings.framework_loaded('FrameworkDoesNotExist')
- end
- end
-
- it "should resolve a constant when a framework, that's registered with #map, is loaded" do
- assert_nothing_raised(NameError) do
- Mappings.map(:klass => 'ClassFromFramework', :framework => 'TheFramework') {}
- end
-
- # The mapping should not yet exist
- assert_nil Mappings.mappings[:klass]
-
- # now we actually define the class and fake the loading of the framework
- eval "class ::ClassFromFramework; end"
- Mappings.framework_loaded('TheFramework')
-
- # It should be loaded by now
- assert_equal ClassFromFramework, Mappings.mappings[:klass].control_class
- end
-
- it "should keep a unique list of loaded_frameworks" do
- assert_difference("Mappings.loaded_frameworks.length", +1) do
- Mappings.framework_loaded('TheFramework')
- Mappings.framework_loaded('TheFramework')
- end
-
- assert Mappings.loaded_frameworks.include?('theframework')
- end
-
- it "should return whether or not a framework has been loaded yet" do
- Mappings.framework_loaded('TheFramework')
- assert Mappings.loaded_framework?('TheFramework')
-
- assert !Mappings.loaded_framework?('IHasNotBeenLoaded')
- assert !Mappings.loaded_framework?(nil)
- assert !Mappings.loaded_framework?('')
- end
-
- def test_reload
- flunk 'Pending.'
- end
-end
View
32 test-macruby/cases/hotcocoa/object_ext_test.rb
@@ -1,32 +0,0 @@
-#!/usr/bin/env macruby
-
-require File.expand_path('../../../test_helper', __FILE__)
-require 'hotcocoa'
-
-module TestNamespaceForConstLookup
- def self.const_missing(const)
- @missing_const = const
- end
-
- def self.missing_const
- @missing_const
- end
-end
-
-class TestObjectExt < Test::Unit::TestCase
- it 'should return a constant by FQ name _in_ receiver namespace' do
- assert_equal HotCocoa, Object.full_const_get("HotCocoa")
- assert_equal HotCocoa::Mappings, Object.full_const_get("HotCocoa::Mappings")
- end
-
- it "should call ::const_missing on the namespace which _does_ exist" do
- Object.full_const_get('TestNamespaceForConstLookup::DoesNotExist')
- assert_equal 'DoesNotExist', TestNamespaceForConstLookup.missing_const
- end
-
- it "should normally raise a NameError if a const cannot be found" do
- assert_raise(NameError) do
- Object.full_const_get('DoesNotExist::ForSure')
- end
- end
-end
View
31 test-macruby/cases/hotcocoa/plist_test.rb
@@ -1,31 +0,0 @@
-#!/usr/bin/env macruby
-
-require File.expand_path('../../../test_helper', __FILE__)
-require 'hotcocoa'
-
-class TestPlist < Test::Unit::TestCase
- include HotCocoa
-
- def test_to_plist
- assert_plist(123) # fails because atm a Numeric is not based on NSNumber
- assert_plist(true)
- assert_plist(false)
- assert_plist('foo')
- assert_plist('aiueo'.transform('latin-hiragana'))
- assert_plist(:foo, 'foo')
- assert_plist([1,2,3])
- assert_plist({'un' => 1, 'deux' => 2})
- end
-
- def test_to_plist_with_invalid_objects
- assert_plist(nil, nil)
- assert_plist(Object.new, nil)
- assert_plist(/foo/, nil)
- end
-
- private
-
- def assert_plist(val, expected=val)
- assert_equal(expected, read_plist(val.to_plist))
- end
-end
Please sign in to comment.
Something went wrong with that request. Please try again.