bootstrap-components-helpers 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b028db3bad4df8cc997fa5c90a8203187a6f874d
4
- data.tar.gz: 752062ab69339fbf750208476882f305dd46e60f
3
+ metadata.gz: db49713492eb25a79ee18c60733245342ecb6c63
4
+ data.tar.gz: ed57c2bf6460d42f0bd7a3948e3d017a9315451f
5
5
  SHA512:
6
- metadata.gz: 59a458a90718331863dbaab5b8fb615d603a90281ee26c2c43bb844ed5aef67553ef11083c64863845759f46b870db208a6d2735fec0231cb30a7a822a8d7ee4
7
- data.tar.gz: a3cfd138b77e8ca08926e659a6ffff59f5e6fd90942d3a4ef85e523706508367f7c33e918007fd89c8e23992b12f23141b895e8dc305efb4cbb2045a689f5b7f
6
+ metadata.gz: 7d43cbe8c8f1f0ba73bec02042b245703941efbae77a478cfe11a5e7f38a7b80a6a61f8ba58c5440264baa4128315d77e0165b64aa568f61b8924a2a750fd0d3
7
+ data.tar.gz: e24a08485707b6fb367a0347ccb75b757e1327c034ba8acb79e65eeae1bb9519e61785ca7981cfdf9e417edf2fa00fd3213e25a8b4f56b6e0d684b4bdef8d78c
data/README.markdown CHANGED
@@ -40,6 +40,12 @@ In your Gemfile:
40
40
 
41
41
  - `:active` : when you want that pane to be active on load.
42
42
 
43
+ ### Modal helper:
44
+
45
+ = modal 'My modal title' do |modal|
46
+ - modal.body do
47
+ Inside the modal
48
+
43
49
  ### Contributors
44
50
 
45
51
  - Graham Torn
@@ -1,2 +1,3 @@
1
1
  require 'bootstrap-components-helpers/accordion_helper'
2
2
  require 'bootstrap-components-helpers/tabs_helper'
3
+ require 'bootstrap-components-helpers/modal_helper'
@@ -0,0 +1,41 @@
1
+ module BootstrapComponentsHelpers
2
+ module ModalHelper
3
+
4
+ def modal title, options = {}
5
+ builder = ModalBuilder.new self
6
+ yield builder
7
+ content_tag :div, class: 'modal fade hide', id: options[:id] do
8
+ header = content_tag :div, class: 'modal-header' do
9
+ content_tag(:a, '×', class: 'close', data: {dismiss: 'modal'}) + content_tag(:h3, title)
10
+ end
11
+ body = content_tag(:div, class: 'modal-body') {builder.body_content}
12
+ footer = content_tag(:div, class: 'modal-footer') do
13
+ builder.footer_content || content_tag(:a, 'Cancel', class: 'btn pull-right', data: {dismiss: 'modal'})
14
+ end
15
+ header + body + footer
16
+ end
17
+ end
18
+
19
+ class ModalBuilder
20
+
21
+ attr_reader :parent, :body_content, :footer_content
22
+ delegate :capture, to: :parent
23
+
24
+ def initialize parent
25
+ @parent = parent
26
+ end
27
+
28
+ def body &block
29
+ @body_content = capture(&block)
30
+ end
31
+
32
+ def footer &block
33
+ @footer_content = capture(&block)
34
+ end
35
+
36
+ end
37
+
38
+ end
39
+ end
40
+
41
+ ActionView::Base.send :include, BootstrapComponentsHelpers::ModalHelper
@@ -4,12 +4,13 @@ class AccordionHelperTest < ActionView::TestCase
4
4
 
5
5
  include BootstrapComponentsHelpers::AccordionHelper
6
6
 
7
- test "calling accordion method" do
8
- accordion do |accordion|
7
+ test "accordion method" do
8
+ html = accordion do |accordion|
9
9
  accordion.pane 'My pane' do
10
- 'inside the panee'
10
+ 'inside the pane'
11
11
  end
12
12
  end
13
+ assert_helper_output 'accordion', html
13
14
  end
14
15
 
15
16
  end
data/test/test_helper.rb CHANGED
@@ -2,3 +2,11 @@ require 'test/unit'
2
2
  require 'action_view'
3
3
  require 'action_view/template'
4
4
  require 'bootstrap-components-helpers'
5
+
6
+ class ActionView::TestCase
7
+
8
+ def assert_helper_output fixture_name, actual_output
9
+ assert_equal File.read("#{File.dirname __FILE__}/fixtures/#{fixture_name}.html"), actual_output
10
+ end
11
+
12
+ end
@@ -0,0 +1,16 @@
1
+ require 'test_helper'
2
+
3
+ class ModalHelperTest < ActionView::TestCase
4
+
5
+ include BootstrapComponentsHelpers::ModalHelper
6
+
7
+ test "modal method" do
8
+ html = modal 'My modal title' do |modal|
9
+ modal.body do
10
+ 'inside the modal body'
11
+ end
12
+ end
13
+ assert_helper_output 'modal', html
14
+ end
15
+
16
+ end
@@ -5,11 +5,12 @@ class TabsHelperTest < ActionView::TestCase
5
5
  include BootstrapComponentsHelpers::TabsHelper
6
6
 
7
7
  test "calling tabs method" do
8
- tabs do |tabs|
8
+ html = tabs do |tabs|
9
9
  tabs.pane 'My first pane' do
10
10
  'inside the pane'
11
11
  end
12
12
  end
13
+ assert_helper_output 'tabs', html
13
14
  end
14
15
 
15
16
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bootstrap-components-helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Schneider
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-26 00:00:00.000000000 Z
11
+ date: 2013-09-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack
@@ -33,10 +33,12 @@ extra_rdoc_files: []
33
33
  files:
34
34
  - README.markdown
35
35
  - lib/bootstrap-components-helpers/accordion_helper.rb
36
+ - lib/bootstrap-components-helpers/modal_helper.rb
36
37
  - lib/bootstrap-components-helpers/tabs_helper.rb
37
38
  - lib/bootstrap-components-helpers.rb
38
39
  - test/test_accordion_helper.rb
39
40
  - test/test_helper.rb
41
+ - test/test_modal_helper.rb
40
42
  - test/test_tabs_helper.rb
41
43
  homepage: https://github.com/isc/bootstrap-components-helpers
42
44
  licenses:
@@ -65,4 +67,5 @@ summary: View helpers for Twitter Bootstrap components
65
67
  test_files:
66
68
  - test/test_accordion_helper.rb
67
69
  - test/test_helper.rb
70
+ - test/test_modal_helper.rb
68
71
  - test/test_tabs_helper.rb