motion_bindable 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +6 -5
- data/lib/motion_bindable/version.rb +1 -1
- data/spec/helpers/apply.rb +1 -0
- data/spec/helpers/fake_model.rb +8 -0
- data/spec/strategies/proc_spec.rb +0 -13
- data/spec/strategies/ui_label_spec.rb +0 -14
- data/spec/strategies/ui_label_x_ui_text_field_spec.rb +74 -0
- data/spec/strategies/ui_text_field_spec.rb +0 -16
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3e3237a0dad5569ddc2cb3d1e6837d3c03ce003d
|
4
|
+
data.tar.gz: 5a0371d71ae7ea0f4e0f2bc47647055e570d8c2f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 30e5198ad5b05b8c07d81b75c41d91df7f94f46f7f446af8d8683f3e531c2469a7aa7a0f4733be3bf5e42852279bcc5845d50c176d95d8a87d6f3d91a0a34086
|
7
|
+
data.tar.gz: 95d8af588526663ecd785e45763f54e61d58d7350dea424a6b9e78aa3be1ee0acd152fb9ba124dadbdc039ff15849718f62e95d98048442b4c479c6def498c45
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -97,12 +97,13 @@ the available defaults. You can implement your own strategies by extending
|
|
97
97
|
### Default Strategies
|
98
98
|
|
99
99
|
The following strategies come with motion-bindable and are setup when
|
100
|
-
`MotionBindable::Strategies.
|
100
|
+
`MotionBindable::Strategies.apply` is called.
|
101
101
|
|
102
|
-
| Name | Object Candidates | Direction
|
103
|
-
| ----------------------------------------- | ----------------- |
|
104
|
-
| `MotionBindable::Strategies::UITextField` | Any `UITextField` |
|
105
|
-
| `MotionBindable::Strategies::Proc` | Any `Proc` |
|
102
|
+
| Name | Object Candidates | Direction |
|
103
|
+
| ----------------------------------------- | ----------------- | ------------------- |
|
104
|
+
| `MotionBindable::Strategies::UITextField` | Any `UITextField` | Bound >-< Attribute |
|
105
|
+
| `MotionBindable::Strategies::Proc` | Any `Proc` | Bound >-- Attribute |
|
106
|
+
| `MotionBindable::Strategies::UILabel` | Any `UILabel` | Bound --< Attribute |
|
106
107
|
|
107
108
|
## Contributing
|
108
109
|
|
@@ -0,0 +1 @@
|
|
1
|
+
MotionBindable::Strategies.apply
|
@@ -2,21 +2,8 @@ class FakeBound
|
|
2
2
|
attr_accessor :attribute
|
3
3
|
end
|
4
4
|
|
5
|
-
class FakeModel
|
6
|
-
include MotionBindable::Bindable
|
7
|
-
attr_accessor :attribute
|
8
|
-
attr_accessor :nested
|
9
|
-
end
|
10
|
-
|
11
5
|
describe 'MotionBindable::Strategies::Proc' do
|
12
6
|
|
13
|
-
before do
|
14
|
-
MotionBindable::Strategy.register_strategy(
|
15
|
-
MotionBindable::Strategies::Proc,
|
16
|
-
Proc
|
17
|
-
)
|
18
|
-
end
|
19
|
-
|
20
7
|
context 'nested model' do
|
21
8
|
|
22
9
|
before do
|
@@ -1,20 +1,6 @@
|
|
1
|
-
class FakeModel
|
2
|
-
include MotionBindable::Bindable
|
3
|
-
attr_accessor :nested
|
4
|
-
attr_accessor :attribute
|
5
|
-
def attribute
|
6
|
-
@attribute
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
1
|
describe 'MotionBindable::Strategies::UILabel' do
|
11
2
|
|
12
3
|
before do
|
13
|
-
MotionBindable::Strategy.register_strategy(
|
14
|
-
MotionBindable::Strategies::UILabel,
|
15
|
-
UILabel
|
16
|
-
)
|
17
|
-
|
18
4
|
@label = UILabel.alloc.initWithFrame [[110, 60], [100, 26]]
|
19
5
|
@label2 = UILabel.alloc.initWithFrame [[110, 60], [100, 26]]
|
20
6
|
@object = FakeModel.new
|
@@ -0,0 +1,74 @@
|
|
1
|
+
describe 'UITextField + UILabel' do
|
2
|
+
|
3
|
+
before do
|
4
|
+
@text_field = UITextField.alloc.initWithFrame [[110, 60], [100, 26]]
|
5
|
+
@label = UILabel.alloc.initWithFrame [[110, 60], [100, 26]]
|
6
|
+
@object = FakeModel.new
|
7
|
+
end
|
8
|
+
|
9
|
+
context 'attribute not set yet' do
|
10
|
+
|
11
|
+
before do
|
12
|
+
@object.bind_attributes attribute: [@text_field, @label]
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should update the bound when attribute is updated' do
|
16
|
+
@object.attribute = 'Hello'
|
17
|
+
@text_field.text.should.equal 'Hello'
|
18
|
+
@label.text.should.equal 'Hello'
|
19
|
+
end
|
20
|
+
|
21
|
+
describe 'updating the text' do
|
22
|
+
|
23
|
+
before do
|
24
|
+
@text_field.text = 'Superman'
|
25
|
+
NSNotificationCenter.defaultCenter.postNotificationName(
|
26
|
+
UITextFieldTextDidChangeNotification, object: @text_field
|
27
|
+
)
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should update the attribute when the text field is updated' do
|
31
|
+
@object.attribute.should.equal 'Superman'
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'should update the label when the text field is updated' do
|
35
|
+
@label.text.should.equal 'Superman'
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
context 'attribute set first' do
|
43
|
+
|
44
|
+
before do
|
45
|
+
@object.attribute = 'Testing'
|
46
|
+
@object.bind_attributes attribute: [@text_field, @label]
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'should set the field and label' do
|
50
|
+
@text_field.text.should.equal 'Testing'
|
51
|
+
@label.text.should.equal 'Testing'
|
52
|
+
end
|
53
|
+
|
54
|
+
describe 'updating the text' do
|
55
|
+
|
56
|
+
before do
|
57
|
+
@text_field.text = 'Superman'
|
58
|
+
NSNotificationCenter.defaultCenter.postNotificationName(
|
59
|
+
UITextFieldTextDidChangeNotification, object: @text_field
|
60
|
+
)
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'should update the attribute when the text field is updated' do
|
64
|
+
@object.attribute.should.equal 'Superman'
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'should update the label when the text field is updated' do
|
68
|
+
@label.text.should.equal 'Superman'
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
@@ -1,20 +1,6 @@
|
|
1
|
-
class FakeModel
|
2
|
-
include MotionBindable::Bindable
|
3
|
-
attr_accessor :nested
|
4
|
-
attr_accessor :attribute
|
5
|
-
def attribute
|
6
|
-
@attribute
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
1
|
describe 'MotionBindable::Strategies::UITextField' do
|
11
2
|
|
12
3
|
before do
|
13
|
-
MotionBindable::Strategy.register_strategy(
|
14
|
-
MotionBindable::Strategies::UITextField,
|
15
|
-
UITextField
|
16
|
-
)
|
17
|
-
|
18
4
|
@text_field = UITextField.alloc.initWithFrame [[110, 60], [100, 26]]
|
19
5
|
@text_field2 = UITextField.alloc.initWithFrame [[110, 60], [100, 26]]
|
20
6
|
end
|
@@ -70,8 +56,6 @@ describe 'MotionBindable::Strategies::UITextField' do
|
|
70
56
|
NSNotificationCenter.defaultCenter.postNotificationName(
|
71
57
|
UITextFieldTextDidChangeNotification, object: @text_field
|
72
58
|
)
|
73
|
-
# BW puts observer cb's into this queue
|
74
|
-
NSOperationQueue.mainQueue.waitUntilAllOperationsAreFinished
|
75
59
|
end
|
76
60
|
|
77
61
|
it 'should update the root attribute' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: motion_bindable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Kot
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-12-
|
11
|
+
date: 2013-12-27 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A simple data binding library for RubyMotion.
|
14
14
|
email:
|
@@ -37,10 +37,13 @@ files:
|
|
37
37
|
- motion_bindable.gemspec
|
38
38
|
- resources/Default-568h@2x.png
|
39
39
|
- spec/bindable_spec.rb
|
40
|
+
- spec/helpers/apply.rb
|
40
41
|
- spec/helpers/facon.rb
|
42
|
+
- spec/helpers/fake_model.rb
|
41
43
|
- spec/strategies/proc_spec.rb
|
42
44
|
- spec/strategies/strategy_spec.rb
|
43
45
|
- spec/strategies/ui_label_spec.rb
|
46
|
+
- spec/strategies/ui_label_x_ui_text_field_spec.rb
|
44
47
|
- spec/strategies/ui_text_field_spec.rb
|
45
48
|
homepage: https://github.com/nathankot/motion-bindable
|
46
49
|
licenses:
|
@@ -68,8 +71,11 @@ specification_version: 4
|
|
68
71
|
summary: Inspired by RivetsJS
|
69
72
|
test_files:
|
70
73
|
- spec/bindable_spec.rb
|
74
|
+
- spec/helpers/apply.rb
|
71
75
|
- spec/helpers/facon.rb
|
76
|
+
- spec/helpers/fake_model.rb
|
72
77
|
- spec/strategies/proc_spec.rb
|
73
78
|
- spec/strategies/strategy_spec.rb
|
74
79
|
- spec/strategies/ui_label_spec.rb
|
80
|
+
- spec/strategies/ui_label_x_ui_text_field_spec.rb
|
75
81
|
- spec/strategies/ui_text_field_spec.rb
|