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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 48783cc76b6326eb79d95e38bbd29a318c655a8d
4
- data.tar.gz: 047eb79e60943f892b2d6c6e83d33ed8ec8eca81
3
+ metadata.gz: 3e9682ac41303a62dc948ed52b7d1bd597fb4c00
4
+ data.tar.gz: 63cd6ecbc0b9ec56d552facc8db44658976af2c4
5
5
  SHA512:
6
- metadata.gz: ce7cfa889e071527b9f4ff0ad9e8c0f0273dd850e8250e37c75f8da12a9c5c6ba809d454cb928175d0ffbeff314b23cdba3ffe0542ac2786fd014f2a30d53dd2
7
- data.tar.gz: 5bdd21e6370775cca078afd27b5c4a669a4f5d30a3b738a46bc58bc7815123d84eb21ee6c44182d0c0c534583d632afb8da7515feca0a896353debdd2666d390
6
+ metadata.gz: 4b293ddb4c76c73718f2a47a0450743dc12c2dfa75694e29076334489c79669f92e78e1caa1926c54c61481225aded63f7aea531f76923ccade6d582a2002eea
7
+ data.tar.gz: 72987bad7488aa7c351cc83ed5577879b933d6178f27ac02e6648b15840fad41c02364909586063d0ad8be4cea4ecf6a688a5d89e07b2bd62c86f2ba51fbf780
data/.travis.yml CHANGED
@@ -1,7 +1,6 @@
1
1
  language: ruby
2
2
  sudo: false
3
3
  rvm:
4
- - 2.0.0
5
4
  - 2.1.8
6
5
  - 2.2.4
7
6
  - 2.3.0
@@ -10,4 +9,5 @@ rvm:
10
9
  env: COVERAGE=true
11
10
  matrix:
12
11
  allow_failures:
13
- - rvm: "rbx-2"
12
+ - rvm: "rbx-2"
13
+ - rvm: "ruby-head"
@@ -62,7 +62,7 @@ module Trenni
62
62
  end
63
63
 
64
64
  def item(options = {}, &block)
65
- fragment = Builder.fragment do |builder|
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)
@@ -20,6 +20,6 @@
20
20
 
21
21
  module Trenni
22
22
  module Formatters
23
- VERSION = "2.0.0"
23
+ VERSION = "2.1.0"
24
24
  end
25
25
  end
@@ -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 = Trenni::Template.capture do
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(_out).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>"
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 = Trenni::Template.capture do
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(_out).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>"
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 = Trenni::Template.capture do
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(_out).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>"
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 = Trenni::Template.capture do
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(_out).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>"
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 = Trenni::Template.capture do
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(_out).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>"
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 = Trenni::Template.capture do
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(_out).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>"
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 = Trenni::Template.capture do
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(_out).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>}
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
@@ -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.0"
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.0.0
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: 2016-11-15 00:00:00.000000000 Z
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.0'
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.0'
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.1
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.