bootstrap_help 0.0.19 → 0.0.20
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/README.md +2 -2
- data/lib/bootstrap_help/button_helpers.rb +30 -0
- data/lib/bootstrap_help/railtie.rb +1 -0
- data/lib/bootstrap_help/table_helpers.rb +3 -4
- data/lib/bootstrap_help/version.rb +1 -1
- data/lib/bootstrap_help.rb +1 -0
- data/spec/bootstrap_helper/button_helper_spec.rb +23 -0
- data/spec/bootstrap_helper/table_helper_spec.rb +24 -6
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ab8ca9ac63efa5968577162a9237d6f615539bd5
|
4
|
+
data.tar.gz: 2efaa82aafd1b9724542d5aa6e8628a0f56e6c2b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 221088289c45ff250deac9cef403d44621fa8d3704dc4485cd2628d449dab95aeb3ccb054a2c6e4dbb5dc50bf6335beab641a3f44b044c87d03ddcac5a12c15d
|
7
|
+
data.tar.gz: 4ee4902c91795ce3433c204c8d1fd823805dba646bc2c9e403b21e8397600adaa7f1b1a7b6e0d397fcf5620147eac953b93f24e796122bff596632f2c015a58b
|
data/README.md
CHANGED
@@ -41,8 +41,8 @@ The Table Helper helps you quickly build Bootstrap tables with collections of in
|
|
41
41
|
|
42
42
|
```haml
|
43
43
|
= table_for(@apples) do
|
44
|
-
= column
|
45
|
-
- color.to_hex
|
44
|
+
= column "Hex Color" do |apple|
|
45
|
+
- apple.color.to_hex
|
46
46
|
= column 'Type of Apple', :type
|
47
47
|
```
|
48
48
|
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module BootstrapHelp
|
2
|
+
module ButtonHelpers
|
3
|
+
include ActionView::Helpers::TagHelper
|
4
|
+
include ActionView::Helpers::TextHelper
|
5
|
+
include ActionView::Helpers::UrlHelper
|
6
|
+
include ActionView::Context
|
7
|
+
|
8
|
+
def button_toolbar(&block)
|
9
|
+
@buttons = []
|
10
|
+
block.call
|
11
|
+
content_tag :div, class: "btn-toolbar" do
|
12
|
+
@buttons.each do |button|
|
13
|
+
concat(draw_button(button[:icon_suffix], button[:options]))
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def button(icon_suffix, options)
|
19
|
+
@buttons << {icon_suffix: icon_suffix, options: options}
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def draw_button(icon_suffix, options)
|
25
|
+
link_to options, class: "btn" do
|
26
|
+
content_tag :i, nil, class: "icon-#{icon_suffix}"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -5,7 +5,7 @@ module BootstrapHelp
|
|
5
5
|
include ActionView::Helpers::UrlHelper
|
6
6
|
include ActionView::Context
|
7
7
|
|
8
|
-
def table_for(collection, &block)
|
8
|
+
def table_for(collection, args={}, &block)
|
9
9
|
@columns = []
|
10
10
|
block.call
|
11
11
|
content_tag :table, class: "table table-striped table-bordered" do
|
@@ -56,11 +56,10 @@ module BootstrapHelp
|
|
56
56
|
end
|
57
57
|
|
58
58
|
def parse_column(column, item)
|
59
|
-
attribute = item.send(column.fetch(:value))
|
60
59
|
if column[:block].present?
|
61
|
-
output = column[:block].call(
|
60
|
+
output = column[:block].call(item)
|
62
61
|
else
|
63
|
-
output =
|
62
|
+
output = item.send(column.fetch(:value))
|
64
63
|
end
|
65
64
|
concat(draw_column { concat(output) })
|
66
65
|
end
|
data/lib/bootstrap_help.rb
CHANGED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe BootstrapHelp::ButtonHelpers do
|
4
|
+
let(:helpers) do
|
5
|
+
class HelpersClass
|
6
|
+
include BootstrapHelp::ButtonHelpers
|
7
|
+
end
|
8
|
+
HelpersClass.new
|
9
|
+
end
|
10
|
+
|
11
|
+
describe '#table_for' do
|
12
|
+
it 'returns a bootstrap table for a given collection' do
|
13
|
+
expected_result = "<div class=\"btn-toolbar\"><a class=\"btn\" href=\"/test\"><i class=\"icon-edit\"></i></a><a class=\"btn\" href=\"/test-again\"><i class=\"icon-new\"></i></a></div>"
|
14
|
+
|
15
|
+
block = Proc.new {
|
16
|
+
helpers.button 'edit', "/test"
|
17
|
+
helpers.button 'new', "/test-again"
|
18
|
+
}
|
19
|
+
|
20
|
+
expect(helpers.button_toolbar(&block)).to eq(expected_result)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -8,22 +8,40 @@ describe BootstrapHelp::TableHelpers do
|
|
8
8
|
HelpersClass.new
|
9
9
|
end
|
10
10
|
|
11
|
+
collection = []
|
12
|
+
Customer = Struct.new(:name, :address)
|
13
|
+
collection << Customer.new('Josh', '111')
|
14
|
+
collection << Customer.new('Dave', '222')
|
15
|
+
|
11
16
|
describe '#table_for' do
|
12
17
|
it 'returns a bootstrap table for a given collection' do
|
13
|
-
collection = []
|
14
|
-
Customer = Struct.new(:name, :address)
|
15
|
-
collection << Customer.new('Josh', '111')
|
16
|
-
collection << Customer.new('Dave', '222')
|
17
18
|
expected_result = "<table class=\"table table-striped table-bordered\"><thead><tr><th>Name</th><th>Address</th></tr></thead><tbody><tr><td>JOSH</td><td>111</td></tr><tr><td>DAVE</td><td>222</td></tr></tbody></table>"
|
18
19
|
|
19
20
|
block = Proc.new {
|
20
|
-
helpers.column 'name' do |
|
21
|
-
|
21
|
+
helpers.column 'name' do |customer|
|
22
|
+
customer.name.upcase
|
23
|
+
end
|
24
|
+
helpers.column 'address'
|
25
|
+
}
|
26
|
+
|
27
|
+
expect(helpers.table_for(collection, &block)).to eq(expected_result)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "has the ability to add manageable links to the end of the table" do
|
31
|
+
expected_result = "<table class=\"table table-striped table-bordered\"><thead><tr><th>Name</th><th>Address</th><th>Any Old Name</th></tr></thead><tbody><tr><td>JOSH</td><td>111</td><td>hello</td></tr><tr><td>DAVE</td><td>222</td><td>hello</td></tr></tbody></table>"
|
32
|
+
|
33
|
+
block = Proc.new {
|
34
|
+
helpers.column 'name' do |customer|
|
35
|
+
customer.name.upcase
|
22
36
|
end
|
23
37
|
helpers.column 'address'
|
38
|
+
helpers.column 'Any Old Name' do |customer|
|
39
|
+
"hello"
|
40
|
+
end
|
24
41
|
}
|
25
42
|
|
26
43
|
expect(helpers.table_for(collection, &block)).to eq(expected_result)
|
44
|
+
|
27
45
|
end
|
28
46
|
end
|
29
47
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bootstrap_help
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.20
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh Klina
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-09-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -94,10 +94,12 @@ files:
|
|
94
94
|
- Rakefile
|
95
95
|
- bootstrap_help.gemspec
|
96
96
|
- lib/bootstrap_help.rb
|
97
|
+
- lib/bootstrap_help/button_helpers.rb
|
97
98
|
- lib/bootstrap_help/nav_helpers.rb
|
98
99
|
- lib/bootstrap_help/railtie.rb
|
99
100
|
- lib/bootstrap_help/table_helpers.rb
|
100
101
|
- lib/bootstrap_help/version.rb
|
102
|
+
- spec/bootstrap_helper/button_helper_spec.rb
|
101
103
|
- spec/bootstrap_helper/nav_helper_spec.rb
|
102
104
|
- spec/bootstrap_helper/table_helper_spec.rb
|
103
105
|
- spec/spec_helper.rb
|
@@ -126,6 +128,7 @@ signing_key:
|
|
126
128
|
specification_version: 4
|
127
129
|
summary: Twitter Bootstrap makeup generators
|
128
130
|
test_files:
|
131
|
+
- spec/bootstrap_helper/button_helper_spec.rb
|
129
132
|
- spec/bootstrap_helper/nav_helper_spec.rb
|
130
133
|
- spec/bootstrap_helper/table_helper_spec.rb
|
131
134
|
- spec/spec_helper.rb
|