formotion 0.0.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/.gitignore +10 -0
- data/Formotion.gemspec +19 -0
- data/README.md +168 -0
- data/Rakefile +11 -0
- data/app/app_delegate.rb +68 -0
- data/examples/KitchenSink/.gitignore +5 -0
- data/examples/KitchenSink/README.md +5 -0
- data/examples/KitchenSink/Rakefile +9 -0
- data/examples/KitchenSink/app/app_delegate.rb +101 -0
- data/examples/KitchenSink/spec/main_spec.rb +9 -0
- data/lib/formotion.rb +6 -0
- data/lib/formotion/base.rb +44 -0
- data/lib/formotion/exceptions.rb +20 -0
- data/lib/formotion/form.rb +173 -0
- data/lib/formotion/form_controller.rb +102 -0
- data/lib/formotion/form_delegate.rb +87 -0
- data/lib/formotion/patch/ui_text_field.rb +158 -0
- data/lib/formotion/row.rb +211 -0
- data/lib/formotion/row_cell_builder.rb +168 -0
- data/lib/formotion/row_type.rb +33 -0
- data/lib/formotion/section.rb +108 -0
- data/lib/formotion/version.rb +3 -0
- data/spec/form_spec.rb +106 -0
- data/spec/row_spec.rb +25 -0
- data/spec/section_spec.rb +20 -0
- metadata +105 -0
data/spec/form_spec.rb
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
describe "Forms" do
|
2
|
+
it "assigning invalid sections doesnt work" do
|
3
|
+
f = Formotion::Form.new
|
4
|
+
|
5
|
+
should.not.raise(Formotion::InvalidClassError) {
|
6
|
+
f.sections = [
|
7
|
+
Formotion::Section.new
|
8
|
+
]
|
9
|
+
}
|
10
|
+
|
11
|
+
should.raise(Formotion::InvalidClassError) {
|
12
|
+
f.sections = [
|
13
|
+
"Hello"
|
14
|
+
]
|
15
|
+
}
|
16
|
+
end
|
17
|
+
|
18
|
+
it "archiving works" do
|
19
|
+
f = Formotion::Form.new
|
20
|
+
section = f.build_section do |section|
|
21
|
+
section.title = "HELLO"
|
22
|
+
|
23
|
+
section.build_row do |row|
|
24
|
+
row.title = "Label"
|
25
|
+
row.subtitle = "Placeholder"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
result = NSKeyedUnarchiver.unarchiveObjectWithData(NSKeyedArchiver.archivedDataWithRootObject(f))
|
30
|
+
|
31
|
+
result.sections.count.should == 1
|
32
|
+
result.sections[0].title.should == "HELLO"
|
33
|
+
result.sections[0].rows.count.should == 1
|
34
|
+
result.sections[0].rows[0].title.should == "Label"
|
35
|
+
end
|
36
|
+
|
37
|
+
it "section builder works" do
|
38
|
+
f = Formotion::Form.new
|
39
|
+
section = f.build_section do |section|
|
40
|
+
section.title = "HELLO"
|
41
|
+
|
42
|
+
section.build_row do |row|
|
43
|
+
row.title = "Label"
|
44
|
+
row.subtitle = "Placeholder"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
section.title.should == "HELLO"
|
49
|
+
section.rows.count.should == 1
|
50
|
+
|
51
|
+
row = section.rows[0]
|
52
|
+
row.title.should == "Label"
|
53
|
+
row.subtitle.should == "Placeholder"
|
54
|
+
end
|
55
|
+
|
56
|
+
it "render works correctly" do
|
57
|
+
@form = Formotion::Form.new(sections: [{
|
58
|
+
rows: [{
|
59
|
+
key: :email,
|
60
|
+
editable: true,
|
61
|
+
title: 'Email'
|
62
|
+
}]}])
|
63
|
+
|
64
|
+
row = @form.sections[0].rows[0]
|
65
|
+
row.value = 'something@email.com'
|
66
|
+
|
67
|
+
@form.render[:email].should == 'something@email.com'
|
68
|
+
end
|
69
|
+
|
70
|
+
it "hashifying should be same as input" do
|
71
|
+
h = {
|
72
|
+
sections: [{
|
73
|
+
title: "Login",
|
74
|
+
rows: [{
|
75
|
+
title: "Email",
|
76
|
+
placeholder: "me@mail.com",
|
77
|
+
type: Formotion::RowType::EMAIL,
|
78
|
+
auto_correction: UITextAutocorrectionTypeNo,
|
79
|
+
auto_capitalization: UITextAutocapitalizationTypeNone
|
80
|
+
}, {
|
81
|
+
title: "Password",
|
82
|
+
placeholder: "required",
|
83
|
+
type: Formotion::RowType::STRING,
|
84
|
+
secure: true
|
85
|
+
}, {
|
86
|
+
title: "Remember me?",
|
87
|
+
}, {
|
88
|
+
title: "Check me?",
|
89
|
+
}]
|
90
|
+
}, {
|
91
|
+
title: "Options",
|
92
|
+
select_one: true,
|
93
|
+
rows: [{
|
94
|
+
title: "Check me?",
|
95
|
+
}, {
|
96
|
+
title: "Check me 2?",
|
97
|
+
}, {
|
98
|
+
title: "Check me 3?",
|
99
|
+
}]
|
100
|
+
}]
|
101
|
+
}
|
102
|
+
form = Formotion::Form.new(h)
|
103
|
+
|
104
|
+
form.to_hash.should == h
|
105
|
+
end
|
106
|
+
end
|
data/spec/row_spec.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
describe "Rows" do
|
2
|
+
it "method_missing should work" do
|
3
|
+
r = Formotion::Row.new
|
4
|
+
r.title = "LABEL"
|
5
|
+
r.title.should == "LABEL"
|
6
|
+
|
7
|
+
r.title = "LABEL2"
|
8
|
+
r.title.should == "LABEL2"
|
9
|
+
end
|
10
|
+
|
11
|
+
it "from hash should work" do
|
12
|
+
hash = {title: "TITLE", subtitle: "SUBTITLE"}
|
13
|
+
r = Formotion::Row.new(hash)
|
14
|
+
r.title.should == "TITLE"
|
15
|
+
r.subtitle.should == "SUBTITLE"
|
16
|
+
end
|
17
|
+
|
18
|
+
it "the question mark methods should work" do
|
19
|
+
r = Formotion::Row.new({secure: true, title: "Not Boolean"})
|
20
|
+
r.secure?.should == true
|
21
|
+
should.raise(NoMethodError) {
|
22
|
+
r.title?.should == true
|
23
|
+
}
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
describe "Sections" do
|
2
|
+
it "section title setter works" do
|
3
|
+
section = Formotion::Section.new
|
4
|
+
section.title = "HELLO"
|
5
|
+
section.title.should == "HELLO"
|
6
|
+
end
|
7
|
+
|
8
|
+
it "from hash should work" do
|
9
|
+
hash = {title: "TITLE", rows: [{
|
10
|
+
title: "FIRST TITLE"
|
11
|
+
}, {
|
12
|
+
title: "SECOND TITLE"
|
13
|
+
}]}
|
14
|
+
f = Formotion::Section.new(hash)
|
15
|
+
f.title.should == "TITLE"
|
16
|
+
f.rows.count.should == 2
|
17
|
+
f.rows[0].title.should == "FIRST TITLE"
|
18
|
+
f.rows[1].title.should == "SECOND TITLE"
|
19
|
+
end
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: formotion
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Clay Allsopp
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-06-25 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bubble-wrap
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rake
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
description: Making iOS Forms insanely great with RubyMotion
|
47
|
+
email:
|
48
|
+
- clay.allsopp@gmail.com
|
49
|
+
executables: []
|
50
|
+
extensions: []
|
51
|
+
extra_rdoc_files: []
|
52
|
+
files:
|
53
|
+
- .gitignore
|
54
|
+
- Formotion.gemspec
|
55
|
+
- README.md
|
56
|
+
- Rakefile
|
57
|
+
- app/app_delegate.rb
|
58
|
+
- examples/KitchenSink/.gitignore
|
59
|
+
- examples/KitchenSink/README.md
|
60
|
+
- examples/KitchenSink/Rakefile
|
61
|
+
- examples/KitchenSink/app/app_delegate.rb
|
62
|
+
- examples/KitchenSink/spec/main_spec.rb
|
63
|
+
- lib/formotion.rb
|
64
|
+
- lib/formotion/base.rb
|
65
|
+
- lib/formotion/exceptions.rb
|
66
|
+
- lib/formotion/form.rb
|
67
|
+
- lib/formotion/form_controller.rb
|
68
|
+
- lib/formotion/form_delegate.rb
|
69
|
+
- lib/formotion/patch/ui_text_field.rb
|
70
|
+
- lib/formotion/row.rb
|
71
|
+
- lib/formotion/row_cell_builder.rb
|
72
|
+
- lib/formotion/row_type.rb
|
73
|
+
- lib/formotion/section.rb
|
74
|
+
- lib/formotion/version.rb
|
75
|
+
- spec/form_spec.rb
|
76
|
+
- spec/row_spec.rb
|
77
|
+
- spec/section_spec.rb
|
78
|
+
homepage: https://github.com/clayallsopp/Formotion
|
79
|
+
licenses: []
|
80
|
+
post_install_message:
|
81
|
+
rdoc_options: []
|
82
|
+
require_paths:
|
83
|
+
- lib
|
84
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
85
|
+
none: false
|
86
|
+
requirements:
|
87
|
+
- - ! '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
|
+
none: false
|
92
|
+
requirements:
|
93
|
+
- - ! '>='
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
requirements: []
|
97
|
+
rubyforge_project:
|
98
|
+
rubygems_version: 1.8.24
|
99
|
+
signing_key:
|
100
|
+
specification_version: 3
|
101
|
+
summary: Making iOS Forms insanely great with RubyMotion
|
102
|
+
test_files:
|
103
|
+
- spec/form_spec.rb
|
104
|
+
- spec/row_spec.rb
|
105
|
+
- spec/section_spec.rb
|