formotion 0.5 → 0.5.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/CHANGELOG.md CHANGED
@@ -1,10 +1,20 @@
1
- ### 0.5.0 - ?, 2012
1
+ ## 0.5.1 - July 19, 2012
2
2
 
3
3
  ### Improvements
4
4
 
5
- - Add new row type for images
6
- - Add new row type for UISegmentedControl
7
- - Add new row type for UISlider
8
- - Add new row type for multiline text
9
- - Add new row types for dates
5
+ - Add new row type for UIPickerView (:picker)
6
+
7
+ ### Bug Fixes
8
+
9
+ - Bump required bubble-wrap version to 1.1.2 to fix a `lib` path issue.
10
+
11
+ ## 0.5.0 - July 18, 2012
12
+
13
+ ### Improvements
14
+
15
+ - Add new row type for images (:image)
16
+ - Add new row type for UISegmentedControl (:options)
17
+ - Add new row type for UISlider (:slider)
18
+ - Add new row type for multiline text (:text)
19
+ - Add new row types for dates (:date)
10
20
  - Big code refactoring
data/Formotion.gemspec CHANGED
@@ -14,6 +14,6 @@ Gem::Specification.new do |s|
14
14
  s.test_files = s.files.grep(%r{^(test|spec|features)/})
15
15
  s.require_paths = ["lib"]
16
16
 
17
- s.add_dependency "bubble-wrap"
17
+ s.add_dependency "bubble-wrap", ">= 1.1.2"
18
18
  s.add_development_dependency 'rake'
19
19
  end
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem 'bubble-wrap', ">=1.1.0"
3
+ gem 'bubble-wrap', ">=1.1.2"
4
4
 
5
5
  # Specify your gem's dependencies in motion-settings.gemspec
6
6
  gemspec
data/app/app_delegate.rb CHANGED
@@ -9,6 +9,12 @@ class AppDelegate
9
9
  title: "Photo",
10
10
  key: :photo,
11
11
  type: :image
12
+ },{
13
+ title: "Picker",
14
+ key: :pick,
15
+ type: :picker,
16
+ items: ["Ruby", "Motion", "Rocks"],
17
+ value: "Motion"
12
18
  },{
13
19
  title: "Email",
14
20
  key: :email,
@@ -0,0 +1,50 @@
1
+ # currently supports only one component
2
+
3
+ module Formotion
4
+ module RowType
5
+ class PickerRow < StringRow
6
+
7
+ def after_build(cell)
8
+ self.row.text_field.inputView = self.picker
9
+ end
10
+
11
+ def picker
12
+ @picker ||= begin
13
+ picker = UIPickerView.alloc.initWithFrame(CGRectZero)
14
+ picker.showsSelectionIndicator = true
15
+ picker.hidden = false
16
+ picker.dataSource = self
17
+ picker.delegate = self
18
+
19
+ if self.row.value
20
+ picker_row = self.row.items.index(row.value)
21
+ picker.selectRow(picker_row, inComponent:0, animated:false)
22
+ end
23
+
24
+ picker
25
+ end
26
+ end
27
+
28
+ def numberOfComponentsInPickerView(pickerView)
29
+ 1
30
+ end
31
+
32
+ def pickerView(pickerView, numberOfRowsInComponent:component)
33
+ self.row.items.size
34
+ end
35
+
36
+ def pickerView(pickerView, titleForRow:index, forComponent:component)
37
+ self.row.items[index]
38
+ end
39
+
40
+ def pickerView(pickerView, didSelectRow:index, inComponent:component)
41
+ update_row(self.row.items[index])
42
+ end
43
+
44
+ def update_row(value)
45
+ self.row.text_field && self.row.text_field.text = value
46
+ end
47
+
48
+ end
49
+ end
50
+ end
@@ -1,3 +1,3 @@
1
1
  module Formotion
2
- VERSION = "0.5"
2
+ VERSION = "0.5.1"
3
3
  end
@@ -0,0 +1,61 @@
1
+ describe "FormController/PickerRow" do
2
+ tests Formotion::FormController
3
+
4
+ # By default, `tests` uses @controller.init
5
+ # this isn't ideal for our case, so override.
6
+ def controller
7
+ row_settings = {
8
+ title: "Picker",
9
+ key: :picker,
10
+ type: :picker,
11
+ items: ["Ruby", "Motion"],
12
+ value: "Motion"
13
+ }
14
+ @form ||= Formotion::Form.new(
15
+ sections: [{
16
+ rows:[row_settings]
17
+ }])
18
+
19
+ @controller ||= Formotion::FormController.alloc.initWithForm(@form)
20
+ end
21
+
22
+ def picker_row
23
+ @form.sections.first.rows.first
24
+ end
25
+
26
+ def picker
27
+ picker_row.object.picker
28
+ end
29
+
30
+ after do
31
+ picker_row.text_field.resignFirstResponder
32
+ wait 0.5 do
33
+ end
34
+ end
35
+
36
+ it "should open a the picker when tapped" do
37
+ notif = App.notification_center.observe UIKeyboardDidShowNotification do |notification|
38
+ @did_show = true
39
+ end
40
+
41
+ picker.superview.should == nil
42
+ tap("Picker")
43
+ picker.superview.should.not == nil
44
+
45
+ wait 0.5 do
46
+ @did_show.should == true
47
+ end
48
+ end
49
+
50
+ it "should change row value when picked" do
51
+ tap("Picker")
52
+
53
+ wait 0.5 do
54
+ picker.selectRow(0, inComponent: 0, animated: true)
55
+ picker_row.object.pickerView(picker, didSelectRow:0, inComponent:0)
56
+ wait 0.5 do
57
+ picker_row.value.should == "Ruby"
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,35 @@
1
+ describe "Picker Row" do
2
+ before do
3
+ row_settings = {
4
+ title: "Picker",
5
+ key: :picker,
6
+ type: :picker,
7
+ items: ["Ruby", "Motion"],
8
+ value: "Motion"
9
+ }
10
+ @row = Formotion::Row.new(row_settings)
11
+ @row.reuse_identifier = 'test'
12
+ end
13
+
14
+ it "should initialize with correct settings" do
15
+ @row.object.class.should == Formotion::RowType::PickerRow
16
+ end
17
+
18
+ it "should build cell with picker as input view of text_field" do
19
+ cell = @row.make_cell
20
+
21
+ @row.text_field.inputView.class.should == UIPickerView
22
+ end
23
+
24
+ it "should start ui picker at custom value" do
25
+ cell = @row.make_cell
26
+
27
+ @row.text_field.inputView.selectedRowInComponent(0).should == 1
28
+ end
29
+
30
+ it "should have text field the custom value" do
31
+ cell = @row.make_cell
32
+
33
+ @row.text_field.text.should == "Motion"
34
+ end
35
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: formotion
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.5'
4
+ version: 0.5.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-16 00:00:00.000000000 Z
12
+ date: 2012-07-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bubble-wrap
@@ -18,7 +18,7 @@ dependencies:
18
18
  requirements:
19
19
  - - ! '>='
20
20
  - !ruby/object:Gem::Version
21
- version: '0'
21
+ version: 1.1.2
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - ! '>='
28
28
  - !ruby/object:Gem::Version
29
- version: '0'
29
+ version: 1.1.2
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: rake
32
32
  requirement: !ruby/object:Gem::Requirement
@@ -92,6 +92,7 @@ files:
92
92
  - lib/formotion/row_type/number_row.rb
93
93
  - lib/formotion/row_type/options_row.rb
94
94
  - lib/formotion/row_type/phone_row.rb
95
+ - lib/formotion/row_type/picker_row.rb
95
96
  - lib/formotion/row_type/row_type.rb
96
97
  - lib/formotion/row_type/slider_row.rb
97
98
  - lib/formotion/row_type/static_row.rb
@@ -107,6 +108,7 @@ files:
107
108
  - spec/functional/date_row_spec.rb
108
109
  - spec/functional/image_row_spec.rb
109
110
  - spec/functional/options_row_spec.rb
111
+ - spec/functional/picker_row_spec.rb
110
112
  - spec/functional/slider_row_spec.rb
111
113
  - spec/functional/submit_row_spec.rb
112
114
  - spec/functional/switch_row_spec.rb
@@ -119,6 +121,7 @@ files:
119
121
  - spec/row_type/number_spec.rb
120
122
  - spec/row_type/options_spec.rb
121
123
  - spec/row_type/phone_spec.rb
124
+ - spec/row_type/picker_spec.rb
122
125
  - spec/row_type/slider_spec.rb
123
126
  - spec/row_type/static_spec.rb
124
127
  - spec/row_type/string_spec.rb
@@ -141,7 +144,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
141
144
  version: '0'
142
145
  segments:
143
146
  - 0
144
- hash: -3547767700420537743
147
+ hash: -3180843362770153593
145
148
  required_rubygems_version: !ruby/object:Gem::Requirement
146
149
  none: false
147
150
  requirements:
@@ -150,7 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
150
153
  version: '0'
151
154
  segments:
152
155
  - 0
153
- hash: -3547767700420537743
156
+ hash: -3180843362770153593
154
157
  requirements: []
155
158
  rubyforge_project:
156
159
  rubygems_version: 1.8.24
@@ -164,6 +167,7 @@ test_files:
164
167
  - spec/functional/date_row_spec.rb
165
168
  - spec/functional/image_row_spec.rb
166
169
  - spec/functional/options_row_spec.rb
170
+ - spec/functional/picker_row_spec.rb
167
171
  - spec/functional/slider_row_spec.rb
168
172
  - spec/functional/submit_row_spec.rb
169
173
  - spec/functional/switch_row_spec.rb
@@ -176,6 +180,7 @@ test_files:
176
180
  - spec/row_type/number_spec.rb
177
181
  - spec/row_type/options_spec.rb
178
182
  - spec/row_type/phone_spec.rb
183
+ - spec/row_type/picker_spec.rb
179
184
  - spec/row_type/slider_spec.rb
180
185
  - spec/row_type/static_spec.rb
181
186
  - spec/row_type/string_spec.rb