trenni-formatters 2.0.0 → 2.1.0
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.
- checksums.yaml +4 -4
- data/.travis.yml +2 -2
- data/lib/trenni/formatters/html/radio_select.rb +2 -11
- data/lib/trenni/formatters/version.rb +1 -1
- data/spec/trenni/formatters/html/option_select_spec.rb +35 -12
- data/spec/trenni/formatters/html/radio_select_spec.rb +4 -2
- data/trenni-formatters.gemspec +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3e9682ac41303a62dc948ed52b7d1bd597fb4c00
|
4
|
+
data.tar.gz: 63cd6ecbc0b9ec56d552facc8db44658976af2c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b293ddb4c76c73718f2a47a0450743dc12c2dfa75694e29076334489c79669f92e78e1caa1926c54c61481225aded63f7aea531f76923ccade6d582a2002eea
|
7
|
+
data.tar.gz: 72987bad7488aa7c351cc83ed5577879b933d6178f27ac02e6648b15840fad41c02364909586063d0ad8be4cea4ecf6a688a5d89e07b2bd62c86f2ba51fbf780
|
data/.travis.yml
CHANGED
@@ -62,7 +62,7 @@ module Trenni
|
|
62
62
|
end
|
63
63
|
|
64
64
|
def item(options = {}, &block)
|
65
|
-
|
65
|
+
Builder.fragment do |builder|
|
66
66
|
builder.tag :tr do
|
67
67
|
builder.inline(:td, :class => :handle) do
|
68
68
|
builder.tag :input, radio_attributes_for(options)
|
@@ -76,16 +76,7 @@ module Trenni
|
|
76
76
|
end
|
77
77
|
end
|
78
78
|
end
|
79
|
-
end
|
80
|
-
|
81
|
-
if block_given?
|
82
|
-
buffer = Trenni::buffer(block.binding)
|
83
|
-
buffer << fragment
|
84
|
-
|
85
|
-
return nil
|
86
|
-
else
|
87
|
-
return fragment
|
88
|
-
end
|
79
|
+
end >> block
|
89
80
|
end
|
90
81
|
|
91
82
|
def call(options = {}, &block)
|
@@ -31,54 +31,75 @@ module Trenni::Formatters::HTML::OptionSelectSpec
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
+
def capture(&block)
|
35
|
+
_out = ""
|
36
|
+
|
37
|
+
Trenni::Template.capture do
|
38
|
+
formatter.select :field => :bar do |select|
|
39
|
+
_out << select.item(:title => "A", :value => 0)
|
40
|
+
_out << select.item(:title => "B", :value => 10)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
34
45
|
describe Trenni::Formatters::HTML::OptionSelect do
|
35
46
|
let(:formatter) {FormFormatter.new(:object => double(:bar => 10))}
|
36
47
|
|
37
48
|
it "should list items" do
|
38
|
-
_out =
|
49
|
+
_out = ""
|
50
|
+
|
51
|
+
captured = Trenni::Template.capture do
|
39
52
|
formatter.select :field => :bar do |select|
|
40
53
|
_out << select.item(:title => "A", :value => 0)
|
41
54
|
_out << select.item(:title => "B", :value => 10)
|
42
55
|
end
|
43
56
|
end
|
44
57
|
|
45
|
-
expect(
|
58
|
+
expect(captured).to be == "<dt>Bar</dt>\n<dd>\n\t<select name=\"bar\">\n\t\t<option value=\"0\">A</option><option value=\"10\" selected>B</option>\n\t</select>\n</dd>"
|
46
59
|
end
|
47
60
|
|
48
61
|
it "should list items with data attributes" do
|
49
|
-
_out =
|
62
|
+
_out = ""
|
63
|
+
|
64
|
+
captured = Trenni::Template.capture do
|
50
65
|
formatter.select :field => :bar do |select|
|
51
66
|
_out << select.item(:title => "A", :value => 0, :data => {foo: 'bar'})
|
52
67
|
end
|
53
68
|
end
|
54
69
|
|
55
|
-
expect(
|
70
|
+
expect(captured).to be == "<dt>Bar</dt>\n<dd>\n\t<select name=\"bar\">\n\t\t<option value=\"0\" data-foo=\"bar\">A</option>\n\t</select>\n</dd>"
|
56
71
|
end
|
57
72
|
|
58
73
|
it "should list items for multiple selection" do
|
59
|
-
_out =
|
74
|
+
_out = ""
|
75
|
+
|
76
|
+
captured = Trenni::Template.capture do
|
60
77
|
formatter.select :field => :bar, multiple: true do |select|
|
61
78
|
_out << select.item(:title => "A", :value => 0)
|
62
79
|
_out << select.item(:title => "B", :value => 10)
|
63
80
|
end
|
64
81
|
end
|
65
82
|
|
66
|
-
expect(
|
83
|
+
expect(captured).to be == "<dt>Bar</dt>\n<dd>\n\t<select name=\"bar[]\" multiple>\n\t\t<option value=\"0\">A</option><option value=\"10\" selected>B</option>\n\t</select>\n</dd>"
|
67
84
|
end
|
68
85
|
|
69
86
|
it "should add optional item" do
|
70
|
-
_out =
|
87
|
+
_out = ""
|
88
|
+
|
89
|
+
captured = Trenni::Template.capture do
|
71
90
|
formatter.select :field => :bar, optional: true do |select|
|
72
91
|
_out << select.item(:title => "A", :value => 0)
|
73
92
|
_out << select.item(:title => "B", :value => 10)
|
74
93
|
end
|
75
94
|
end
|
76
95
|
|
77
|
-
expect(
|
96
|
+
expect(captured).to be == "<dt>Bar</dt>\n<dd>\n\t<select name=\"bar\">\n\t\t<option value=\"\"></option>\t\t<option value=\"0\">A</option><option value=\"10\" selected>B</option>\n\t</select>\n</dd>"
|
78
97
|
end
|
79
98
|
|
80
99
|
it "should add optional item in group" do
|
81
|
-
_out =
|
100
|
+
_out = ""
|
101
|
+
|
102
|
+
captured = Trenni::Template.capture do
|
82
103
|
formatter.select :field => :bar do |select|
|
83
104
|
select.group(title: 'group', optional: true) do
|
84
105
|
_out << select.item(:title => "A", :value => 0)
|
@@ -87,11 +108,13 @@ module Trenni::Formatters::HTML::OptionSelectSpec
|
|
87
108
|
end
|
88
109
|
end
|
89
110
|
|
90
|
-
expect(
|
111
|
+
expect(captured).to be == "<dt>Bar</dt>\n<dd>\n\t<select name=\"bar\">\n\t\t<optgroup label=\"group\">\n\t\t\t<option value=\"\"></option>\t\t\t<option value=\"0\">A</option>\n\t\t</optgroup>\t\t<option value=\"10\" selected>B</option>\n\t</select>\n</dd>"
|
91
112
|
end
|
92
113
|
|
93
114
|
it "should add a group" do
|
94
|
-
_out =
|
115
|
+
_out = ""
|
116
|
+
|
117
|
+
captured = Trenni::Template.capture do
|
95
118
|
formatter.select :field => :bar do |select|
|
96
119
|
select.group(title: 'group') do
|
97
120
|
_out << select.item(:title => "A", :value => 0)
|
@@ -100,7 +123,7 @@ module Trenni::Formatters::HTML::OptionSelectSpec
|
|
100
123
|
end
|
101
124
|
end
|
102
125
|
|
103
|
-
expect(
|
126
|
+
expect(captured).to be == "<dt>Bar</dt>\n<dd>\n\t<select name=\"bar\">\n\t\t<optgroup label=\"group\">\n\t\t\t<option value=\"0\">A</option>\n\t\t</optgroup>\t\t<option value=\"10\" selected>B</option>\n\t</select>\n</dd>"
|
104
127
|
end
|
105
128
|
end
|
106
129
|
end
|
@@ -34,14 +34,16 @@ module Trenni::Formatters::HTML::RadioSelectSpec
|
|
34
34
|
let(:formatter) {FormFormatter.new(:object => double(:bar => 10))}
|
35
35
|
|
36
36
|
it "should list items" do
|
37
|
-
_out =
|
37
|
+
_out = ""
|
38
|
+
|
39
|
+
captured = Trenni::Template.capture do
|
38
40
|
formatter.select :field => :bar do |select|
|
39
41
|
_out << select.item(:title => "A", :value => 0)
|
40
42
|
_out << select.item(:title => "B", :value => 10)
|
41
43
|
end
|
42
44
|
end
|
43
45
|
|
44
|
-
expect(
|
46
|
+
expect(captured).to be == %Q{<dt>Bar</dt>\n<dd>\n\t<table>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td class="handle"><input type="radio" name="bar" value="0"/></td>\n\t\t\t\t<td class="item">A</td>\n\t\t\t</tr><tr>\n\t\t\t\t<td class="handle"><input type="radio" name="bar" value="10"/></td>\n\t\t\t\t<td class="item">B</td>\n\t\t\t</tr>\n\t\t</tbody>\n\t</table>\n</dd>}
|
45
47
|
end
|
46
48
|
end
|
47
49
|
end
|
data/trenni-formatters.gemspec
CHANGED
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
25
25
|
spec.require_paths = ["lib"]
|
26
26
|
|
27
|
-
spec.add_dependency "trenni", "~> 2.
|
27
|
+
spec.add_dependency "trenni", "~> 2.1"
|
28
28
|
spec.add_dependency "mapping", "~> 1.0"
|
29
29
|
|
30
30
|
spec.add_development_dependency "bundler", "~> 1.3"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trenni-formatters
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: trenni
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '2.
|
19
|
+
version: '2.1'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '2.
|
26
|
+
version: '2.1'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: mapping
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -131,7 +131,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
131
131
|
version: '0'
|
132
132
|
requirements: []
|
133
133
|
rubyforge_project:
|
134
|
-
rubygems_version: 2.5.
|
134
|
+
rubygems_version: 2.5.2
|
135
135
|
signing_key:
|
136
136
|
specification_version: 4
|
137
137
|
summary: Formatters for Trenni, to assist with typical views and form based interfaces.
|