hotcocoa 0.6.0 → 0.6.1
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/.yardopts +4 -3
- data/History.markdown +45 -0
- data/README.markdown +41 -41
- data/docs/HeatingUpWithHotCocoa-part1.markdown +189 -0
- data/docs/Mappings.markdown +1 -1
- data/docs/Resources.markdown +8 -8
- data/docs/Troubleshooting.markdown +15 -0
- data/docs/Tutorial.markdown +1 -1
- data/lib/hotcocoa/application/builder.rb +3 -1
- data/lib/hotcocoa/application/specification.rb +4 -3
- data/lib/hotcocoa/delegate_builder.rb +128 -99
- data/lib/hotcocoa/layout_view.rb +173 -107
- data/lib/hotcocoa/version.rb +1 -1
- data/template/__APPLICATION_NAME__.appspec +7 -4
- data/test/application/test_builder.rb +19 -6
- data/test/application/test_specification.rb +11 -6
- data/test/core_extensions/test_range.rb +9 -9
- data/test/test_delegate_builder.rb +64 -0
- metadata +14 -8
- data/History.txt +0 -29
@@ -27,7 +27,7 @@ class TestApplicationBuilder < TestApplicationModule
|
|
27
27
|
refute_includes hotconsole.send(:deploy_options), '--compile'
|
28
28
|
end
|
29
29
|
|
30
|
-
def
|
30
|
+
def test_deploy_option_embed_bridgesupport
|
31
31
|
refute_includes stopwatch.send(:deploy_options), '--bs'
|
32
32
|
assert_includes hotconsole.send(:deploy_options), '--bs'
|
33
33
|
end
|
@@ -51,8 +51,7 @@ class TestApplicationBuilder < TestApplicationModule
|
|
51
51
|
|
52
52
|
spec = hotconsole_spec.dup
|
53
53
|
spec.icon = '/Applications/Calculator.app/Contents/Resources/Calculator.icns'
|
54
|
-
|
55
|
-
assert_includes plist, :CFBundleIconFile
|
54
|
+
assert_includes plist_for(spec), :CFBundleIconFile
|
56
55
|
end
|
57
56
|
|
58
57
|
def test_plist_hash_from_spec_overrides_all
|
@@ -61,7 +60,7 @@ class TestApplicationBuilder < TestApplicationModule
|
|
61
60
|
spec.plist[:NSPrincipleClass] = 'Foo'
|
62
61
|
spec.plist[:CFBundleName] = 'Cake'
|
63
62
|
|
64
|
-
plist =
|
63
|
+
plist = plist_for(spec)
|
65
64
|
assert_equal true, plist[:MyKey ]
|
66
65
|
assert_equal 'Foo', plist[:NSPrincipleClass ]
|
67
66
|
assert_equal 'Cake', plist[:CFBundleName ]
|
@@ -78,7 +77,21 @@ class TestApplicationBuilder < TestApplicationModule
|
|
78
77
|
doc_type.class = "MyDocument"
|
79
78
|
end
|
80
79
|
end
|
81
|
-
|
82
|
-
|
80
|
+
assert_equal 1, plist_for(spec)[:CFBundleDocumentTypes].size
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_plist_short_string_generated_if_present
|
84
|
+
spec = minimal_spec {|s| s.short_version = "12345"}
|
85
|
+
assert_equal "12345", plist_for(spec)[:CFBundleShortVersionString]
|
86
|
+
end
|
87
|
+
|
88
|
+
def test_plist_copyright_generated_if_present
|
89
|
+
spec = minimal_spec {|s| s.copyright = "© 2011, Your Company"}
|
90
|
+
assert_equal "© 2011, Your Company", plist_for(spec)[:NSHumanReadableCopyright]
|
91
|
+
end
|
92
|
+
|
93
|
+
protected
|
94
|
+
def plist_for(spec)
|
95
|
+
load_plist(Builder.new(spec).send(:info_plist))
|
83
96
|
end
|
84
97
|
end
|
@@ -215,14 +215,19 @@ class TestApplicationSpecification < TestApplicationModule
|
|
215
215
|
Gem::Dependency.new('Salut', '>= 0', '< 2.0.0', :runtime)
|
216
216
|
end
|
217
217
|
|
218
|
-
def
|
218
|
+
def test_embed_bridgesupport_has_a_default
|
219
219
|
spec = minimal_spec
|
220
|
-
|
221
|
-
|
220
|
+
assert spec.embed_bridgesupport?
|
221
|
+
assert spec.embed_bridgesupport
|
222
222
|
|
223
|
-
spec = minimal_spec { |s| s.
|
224
|
-
|
225
|
-
|
223
|
+
spec = minimal_spec { |s| s.embed_bridgesupport = false }
|
224
|
+
refute spec.embed_bridgesupport?
|
225
|
+
refute spec.embed_bridgesupport
|
226
|
+
end
|
227
|
+
|
228
|
+
def test_there_exists_an_embed_bs_alias_so_that_old_specs_continue_working
|
229
|
+
spec = minimal_spec { |s| s.embed_bs = false }
|
230
|
+
refute spec.embed_bridgesupport?
|
226
231
|
end
|
227
232
|
|
228
233
|
def test_overwrite_attribute_is_false_by_default
|
@@ -10,19 +10,19 @@ class TestRangeToNSRange < MiniTest::Unit::TestCase
|
|
10
10
|
@@array ||= (0..10).to_a
|
11
11
|
end
|
12
12
|
|
13
|
-
def
|
13
|
+
def range_test range, *arg
|
14
14
|
assert_equal array.slice(range), array.subarrayWithRange(range.to_NSRange(*arg)), range
|
15
15
|
end
|
16
16
|
|
17
17
|
def test_cases
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
#
|
18
|
+
range_test 0..10
|
19
|
+
range_test 1..10
|
20
|
+
range_test 2..-1, array.size
|
21
|
+
range_test 3..-2, array.size
|
22
|
+
range_test 4...-1, array.size
|
23
|
+
range_test -3...-1, array.size
|
24
|
+
range_test -5..-1, array.size
|
25
|
+
# range_test -1..-2, array.size # returns an empty array, is a fucked up case to begin with
|
26
26
|
end
|
27
27
|
|
28
28
|
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'hotcocoa/delegate_builder'
|
2
|
+
|
3
|
+
class TestControl
|
4
|
+
attr_accessor :delegate
|
5
|
+
end
|
6
|
+
|
7
|
+
class TestDelegateBuilder < MiniTest::Unit::TestCase
|
8
|
+
def test_that_delegate_is_set_on_control
|
9
|
+
control = TestControl.new
|
10
|
+
proc = Proc.new { true }
|
11
|
+
delegate_builder = HotCocoa::DelegateBuilder.new(control, [])
|
12
|
+
delegate_builder.add_delegated_method(proc, "abc")
|
13
|
+
|
14
|
+
assert_equal delegate_builder.delegate, control.delegate
|
15
|
+
assert control.delegate.respond_to?(:abc)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
class TestDelegateMethodBuilder < MiniTest::Unit::TestCase
|
20
|
+
def setup
|
21
|
+
@target = Object.new
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_that_delegate_implements_delegate_method_with_string_parameters
|
25
|
+
proc = Proc.new {|param1, param2| param1.even? ? param1 : param2 }
|
26
|
+
delegate_builder = HotCocoa::DelegateMethodBuilder.new(@target)
|
27
|
+
delegate_builder.add_delegated_method(proc, "abc:param1:param2:", "param1", "param2")
|
28
|
+
|
29
|
+
assert_equal 2, @target.abc(nil, param1: 2, param2: 0)
|
30
|
+
assert_equal 0, @target.abc(nil, param1: 1, param2: 0)
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_that_delegate_implements_delegate_method_with_symbol_parameters
|
34
|
+
proc = Proc.new {|param1, param2| param1.even? ? param1 : param2 }
|
35
|
+
delegate_builder = HotCocoa::DelegateMethodBuilder.new(@target)
|
36
|
+
delegate_builder.add_delegated_method(proc, "abc:param1:param2:", :param1, :param2)
|
37
|
+
|
38
|
+
assert_equal 2, @target.abc(nil, param1: 2, param2: 0)
|
39
|
+
assert_equal 0, @target.abc(nil, param1: 1, param2: 0)
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_that_trying_to_define_delegate_method_with_invalid_parameters_yields_a_sensible_error
|
43
|
+
begin
|
44
|
+
HotCocoa::DelegateMethodBuilder.new(@target).add_delegated_method(nil, "abc:param1:param2:", :another_param)
|
45
|
+
rescue RuntimeError => e
|
46
|
+
assert_match /'another_param' is not a valid parameter of method 'abc:param1:param2:'/, e.message
|
47
|
+
return
|
48
|
+
end
|
49
|
+
flunk "no error thrown!"
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_parameterize_selector_name
|
53
|
+
delegate_builder = HotCocoa::DelegateMethodBuilder.new(nil)
|
54
|
+
assert_equal "myDelegateMethod", delegate_builder.parameterize_selector_name("myDelegateMethod")
|
55
|
+
assert_equal "myDelegateMethod p1,withArgument:p2", delegate_builder.parameterize_selector_name("myDelegateMethod:withArgument:")
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_parameter_values_for_mapping
|
59
|
+
delegate_builder = HotCocoa::DelegateMethodBuilder.new(nil)
|
60
|
+
assert delegate_builder.parameter_values_for_mapping("myDelegateMethod", []).nil?
|
61
|
+
assert_equal "p2, p3", delegate_builder.parameter_values_for_mapping("myDelegateMethod:p1:p2:", ["p1", "p2"])
|
62
|
+
assert_equal "p1.userInfo['NSExposedRect']", delegate_builder.parameter_values_for_mapping("windowDidExpose:", ["windowDidExpose.userInfo['NSExposedRect']"])
|
63
|
+
end
|
64
|
+
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: hotcocoa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.6.
|
5
|
+
version: 0.6.1
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Richard Kilmer
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2011-
|
13
|
+
date: 2011-12-04 00:00:00 -05:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -21,14 +21,14 @@ dependencies:
|
|
21
21
|
requirements:
|
22
22
|
- - ~>
|
23
23
|
- !ruby/object:Gem::Version
|
24
|
-
version: "2.
|
24
|
+
version: "2.8"
|
25
25
|
type: :development
|
26
26
|
version_requirements: !ruby/object:Gem::Requirement
|
27
27
|
none: false
|
28
28
|
requirements:
|
29
29
|
- - ~>
|
30
30
|
- !ruby/object:Gem::Version
|
31
|
-
version: "2.
|
31
|
+
version: "2.8"
|
32
32
|
- !ruby/object:Gem::Dependency
|
33
33
|
name: yard
|
34
34
|
prerelease: false
|
@@ -37,14 +37,14 @@ dependencies:
|
|
37
37
|
requirements:
|
38
38
|
- - ~>
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.7.
|
40
|
+
version: 0.7.4
|
41
41
|
type: :development
|
42
42
|
version_requirements: !ruby/object:Gem::Requirement
|
43
43
|
none: false
|
44
44
|
requirements:
|
45
45
|
- - ~>
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.7.
|
47
|
+
version: 0.7.4
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: redcarpet
|
50
50
|
prerelease: false
|
@@ -71,12 +71,14 @@ executables:
|
|
71
71
|
extensions: []
|
72
72
|
extra_rdoc_files:
|
73
73
|
- README.markdown
|
74
|
-
- History.
|
74
|
+
- History.markdown
|
75
75
|
- docs/Contributors.markdown
|
76
|
+
- docs/HeatingUpWithHotCocoa-part1.markdown
|
76
77
|
- docs/Mappings.markdown
|
77
78
|
- docs/MappingsExplained.markdown
|
78
79
|
- docs/Overview.markdown
|
79
80
|
- docs/Resources.markdown
|
81
|
+
- docs/Troubleshooting.markdown
|
80
82
|
- docs/Tutorial.markdown
|
81
83
|
files:
|
82
84
|
- Rakefile
|
@@ -201,18 +203,21 @@ files:
|
|
201
203
|
- test/test_attributed_string_helpers.rb
|
202
204
|
- test/test_behaviours.rb
|
203
205
|
- test/test_bin.rb
|
206
|
+
- test/test_delegate_builder.rb
|
204
207
|
- test/test_mapper.rb
|
205
208
|
- test/test_mapping_methods.rb
|
206
209
|
- test/test_mappings.rb
|
207
210
|
- test/test_notification_listener.rb
|
208
211
|
- test/test_template.rb
|
209
212
|
- README.markdown
|
210
|
-
- History.
|
213
|
+
- History.markdown
|
211
214
|
- docs/Contributors.markdown
|
215
|
+
- docs/HeatingUpWithHotCocoa-part1.markdown
|
212
216
|
- docs/Mappings.markdown
|
213
217
|
- docs/MappingsExplained.markdown
|
214
218
|
- docs/Overview.markdown
|
215
219
|
- docs/Resources.markdown
|
220
|
+
- docs/Troubleshooting.markdown
|
216
221
|
- docs/Tutorial.markdown
|
217
222
|
has_rdoc: true
|
218
223
|
homepage: http://github.com/ferrous26/hotcocoa
|
@@ -262,6 +267,7 @@ test_files:
|
|
262
267
|
- test/test_attributed_string_helpers.rb
|
263
268
|
- test/test_behaviours.rb
|
264
269
|
- test/test_bin.rb
|
270
|
+
- test/test_delegate_builder.rb
|
265
271
|
- test/test_mapper.rb
|
266
272
|
- test/test_mapping_methods.rb
|
267
273
|
- test/test_mappings.rb
|
data/History.txt
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
=== 0.6.0 2011-10-14
|
2
|
-
|
3
|
-
* 10 enhancements:
|
4
|
-
* New application builder to work with MacRuby 0.11
|
5
|
-
* Old application builder is deprecated
|
6
|
-
* New application templates now use an appspec, similar to a gemspec
|
7
|
-
* config.yml is now deprecated
|
8
|
-
* Lazier loading for mappings (may break custom mappings!)
|
9
|
-
* API documention (~67% coverage so far)
|
10
|
-
* Regression tests (< 67% coverage so far)
|
11
|
-
* Updating and porting of the tutorial documentation (~40% complete)
|
12
|
-
* HotCocoa now works when compiled (HotCocoa will boot ~2.5 faster)
|
13
|
-
* HotCocoa is now leaner
|
14
|
-
* Various bug fixes
|
15
|
-
|
16
|
-
* 4 new mappings:
|
17
|
-
* bonjour_service => NSNetService
|
18
|
-
* bonjour_browser => NSNetServiceBrowser
|
19
|
-
* line => NSBezierPath
|
20
|
-
* tracking_area => NSTrackingArea
|
21
|
-
|
22
|
-
* 2 graphics improvements:
|
23
|
-
* Image class works with more image types
|
24
|
-
* Image class can save images
|
25
|
-
|
26
|
-
=== 0.0.1 2009-11-07
|
27
|
-
|
28
|
-
* 1 major enhancement:
|
29
|
-
* Initial release
|