bootstrap-components-helpers 1.0.0 → 1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2734ad7dd81e1376ac75763d523b3fd8b6028630
4
- data.tar.gz: 95ceb75c26ae05b3ae5eef6c4b6b004f86c1ea75
3
+ metadata.gz: ddca8897fedae09d9dd9c114757067c6cf907608
4
+ data.tar.gz: 7084fc3df6df67e9b9e9ea345cbf8ef408b624c8
5
5
  SHA512:
6
- metadata.gz: 0f76352adbd8694b06f9336aad12a749c9c341226807379a037631214e3b0eec7fd94b20468c30bf9a2cceed7c6559de9ceedc2478bb89579dbb61609738ece8
7
- data.tar.gz: 212b596e5dd26d31816e9f0af892ce145c9b0765232a559b6026491ca6135e6192cd524fbf2ddaf40d886d47bfec849a0d6d96778177e72eab14707f09ae35c1
6
+ metadata.gz: c5feeac3fc920cf9e0591b2a6a33bfe6f262f3dcecdbea15df9b3181df45bd6a32dd10fdd33d535c8be4421530e055e2a571107f17349ab05988e3981f800cd7
7
+ data.tar.gz: 23101270f15962f8e978489e11170e5049d464404fa9551ff832e1a7603c5a8165012f353af9870a1c73d76d6455a37d46e5c090e160418206fe8b293a7a1a5d
@@ -1,3 +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'
3
+ require 'bootstrap-components-helpers/modal_helper'
@@ -5,15 +5,14 @@ module BootstrapComponentsHelpers
5
5
  builder = AccordionBuilder.new opts, self
6
6
  css_class = ['panel-group']
7
7
  css_class << opts[:class] if opts[:class].present?
8
- content_tag :div, :class => css_class, :id => opts[:accordion_id] do
8
+ content_tag :div, class: css_class, id: opts[:accordion_id] do
9
9
  yield builder
10
10
  end
11
11
  end
12
12
 
13
13
  class AccordionBuilder
14
-
15
14
  attr_reader :parent
16
- delegate :capture, :content_tag, :link_to, :to => :parent
15
+ delegate :capture, :content_tag, :link_to, to: :parent
17
16
 
18
17
  def initialize opts, parent
19
18
  @parent = parent
@@ -22,15 +21,14 @@ module BootstrapComponentsHelpers
22
21
 
23
22
  def pane title, options = {}, &block
24
23
  css_class = options[:open] ? 'in' : ''
25
- content_tag :div, :class => 'panel panel-default' do
26
- heading = content_tag :div, :class => 'panel-heading' do
27
- content_tag :h4, :class => 'panel-title' do
28
- link_to title, "##{title.parameterize}_pane", :'data-toggle' => 'collapse',
29
- :'data-parent' => "##{@opts[:accordion_id]}"
24
+ content_tag :div, class: 'panel panel-default' do
25
+ heading = content_tag :div, class: 'panel-heading' do
26
+ content_tag :h4, class: 'panel-title' do
27
+ link_to title, "##{title.parameterize}_pane", 'data-toggle': 'collapse', 'data-parent': "##{@opts[:accordion_id]}"
30
28
  end
31
29
  end
32
- body = content_tag :div, :class => "panel-collapse collapse #{css_class}", :id => "#{title.parameterize}_pane" do
33
- content_tag :div, :class => 'panel-body' do
30
+ body = content_tag :div, class: "panel-collapse collapse #{css_class}", id: "#{title.parameterize}_pane" do
31
+ content_tag :div, class: 'panel-body' do
34
32
  capture(&block)
35
33
  end
36
34
  end
@@ -2,11 +2,10 @@
2
2
 
3
3
  module BootstrapComponentsHelpers
4
4
  module ModalHelper
5
-
6
5
  def modal title, options = {}
7
6
  builder = ModalBuilder.new self
8
7
  yield builder
9
- content_tag :div, class: 'modal fade', id: options[:id] do
8
+ content_tag :div, class: 'modal fade', tabindex: -1, id: options[:id] do
10
9
  content_tag :div, class: 'modal-dialog' do
11
10
  content_tag :div, class: 'modal-content' do
12
11
  header = content_tag :div, class: 'modal-header' do
@@ -23,26 +22,23 @@ module BootstrapComponentsHelpers
23
22
  end
24
23
  end
25
24
  end
26
-
25
+
27
26
  class ModalBuilder
28
-
29
27
  attr_reader :parent, :body_content, :footer_content
30
28
  delegate :capture, to: :parent
31
-
29
+
32
30
  def initialize parent
33
31
  @parent = parent
34
32
  end
35
-
33
+
36
34
  def body &block
37
35
  @body_content = capture(&block)
38
36
  end
39
-
37
+
40
38
  def footer &block
41
39
  @footer_content = capture(&block)
42
40
  end
43
-
44
41
  end
45
-
46
42
  end
47
43
  end
48
44
 
@@ -6,8 +6,8 @@ module BootstrapComponentsHelpers
6
6
  yield builder
7
7
  pane_handles_html = builder.pane_handles_html
8
8
  return unless pane_handles_html
9
- tabs = content_tag(:ul, builder.pane_handles_html, :class => "nav nav-#{opts[:style]}")
10
- contents = content_tag(:div, builder.pane_contents_html, :class => 'tab-content')
9
+ tabs = content_tag(:ul, builder.pane_handles_html, class: "nav nav-#{opts[:style]}")
10
+ contents = content_tag(:div, builder.pane_contents_html, class: 'tab-content')
11
11
  content_tag :div do
12
12
  tabs + contents
13
13
  end
@@ -17,7 +17,7 @@ module BootstrapComponentsHelpers
17
17
  include ActionView::Helpers::OutputSafetyHelper
18
18
 
19
19
  attr_reader :parent, :pane_contents, :pane_handles
20
- delegate :capture, :content_tag, :to => :parent
20
+ delegate :capture, :content_tag, to: :parent
21
21
 
22
22
  def initialize parent
23
23
  @parent = parent
@@ -28,9 +28,9 @@ module BootstrapComponentsHelpers
28
28
  def pane title, options = {}, &block
29
29
  css_class = options[:active] ? 'active' : ''
30
30
  tab_id = options[:id] || default_tab_id(title)
31
- link = content_tag(:a, :'data-toggle' => 'tab', :href => "##{tab_id}") do
31
+ link = content_tag(:a, 'data-toggle': 'tab', href: "##{tab_id}") do
32
32
  if options[:icon]
33
- title = raw(content_tag(:i, '', class: "#{options[:icon]}") + ' ' + title)
33
+ title = raw(content_tag(:i, '', class: options[:icon].to_s) + ' ' + title)
34
34
  end
35
35
  title
36
36
  end
@@ -46,7 +46,7 @@ module BootstrapComponentsHelpers
46
46
  return if pane_handles.empty?
47
47
  pane_handles.first[1] = 'active' unless pane_handles.detect {|ph| ph[1] == 'active'}
48
48
  pane_handles.map do |link, css_class|
49
- content_tag(:li, link, :class => css_class)
49
+ content_tag(:li, link, class: css_class)
50
50
  end.join("\n").html_safe
51
51
  end
52
52
 
@@ -56,7 +56,7 @@ module BootstrapComponentsHelpers
56
56
  pane_contents.map do |css_class, title, tab_id, content|
57
57
  css_class << 'in' if css_class.include?('active') && css_class.include?('fade')
58
58
  css_class = css_class.join(' ').strip
59
- content_tag :div, content, :class => "tab-pane #{css_class}", :id => "#{tab_id}"
59
+ content_tag :div, content, class: "tab-pane #{css_class}", id: tab_id.to_s
60
60
  end.join("\n").html_safe
61
61
  end
62
62
 
@@ -65,9 +65,7 @@ module BootstrapComponentsHelpers
65
65
  def default_tab_id(title)
66
66
  title.parameterize + '_tab'
67
67
  end
68
-
69
68
  end
70
-
71
69
  end
72
70
  end
73
71
 
@@ -1,10 +1,9 @@
1
1
  require 'test_helper'
2
2
 
3
3
  class AccordionHelperTest < ActionView::TestCase
4
-
5
4
  include BootstrapComponentsHelpers::AccordionHelper
6
5
 
7
- test "accordion method" do
6
+ test 'accordion method' do
8
7
  html = accordion do |accordion|
9
8
  accordion.pane 'My pane' do
10
9
  'inside the pane'
@@ -12,5 +11,4 @@ class AccordionHelperTest < ActionView::TestCase
12
11
  end
13
12
  assert_helper_output 'accordion', html
14
13
  end
15
-
16
14
  end
@@ -6,9 +6,7 @@ require 'bootstrap-components-helpers'
6
6
  ActiveSupport.test_order = :random
7
7
 
8
8
  class ActionView::TestCase
9
-
10
9
  def assert_helper_output fixture_name, actual_output
11
10
  assert_equal File.read("#{File.dirname __FILE__}/fixtures/#{fixture_name}.html").strip, actual_output
12
11
  end
13
-
14
12
  end
@@ -1,10 +1,9 @@
1
1
  require 'test_helper'
2
2
 
3
3
  class ModalHelperTest < ActionView::TestCase
4
-
5
4
  include BootstrapComponentsHelpers::ModalHelper
6
-
7
- test "modal method" do
5
+
6
+ test 'modal method' do
8
7
  html = modal 'My modal title' do |modal|
9
8
  modal.body do
10
9
  'inside the modal body'
@@ -12,5 +11,4 @@ class ModalHelperTest < ActionView::TestCase
12
11
  end
13
12
  assert_helper_output 'modal', html
14
13
  end
15
-
16
14
  end
@@ -3,7 +3,7 @@ require 'test_helper'
3
3
  class TabsHelperTest < ActionView::TestCase
4
4
  include BootstrapComponentsHelpers::TabsHelper
5
5
 
6
- test "calling tabs method" do
6
+ test 'calling tabs method' do
7
7
  html = tabs do |tabs|
8
8
  tabs.pane 'My first pane' do
9
9
  'inside the pane'
@@ -12,17 +12,17 @@ class TabsHelperTest < ActionView::TestCase
12
12
  assert_helper_output 'tabs', html
13
13
  end
14
14
 
15
- test "extra options" do
15
+ test 'extra options' do
16
16
  html = tabs do |tabs|
17
17
  tabs.pane 'My first pane<br>', id: 'custom_id', icon: 'fa fa-ok', class: 'custom-class' do
18
18
  'inside the pane'
19
19
  end
20
20
  end
21
- assert_match /href="#custom_id"/, html
22
- assert_match /id="custom_id"/, html
23
- assert_match /i class="fa fa-ok"/, html
24
- assert_match /class=".*custom-class.*"/, html
25
- refute_match /<br>/, html
21
+ assert_match(/href="#custom_id"/, html)
22
+ assert_match(/id="custom_id"/, html)
23
+ assert_match(/i class="fa fa-ok"/, html)
24
+ assert_match(/class=".*custom-class.*"/, html)
25
+ refute_match(/<br>/, html)
26
26
  end
27
27
 
28
28
  test "adds 'in' css class to active tab with 'ade effect" do
@@ -31,16 +31,16 @@ class TabsHelperTest < ActionView::TestCase
31
31
  'inside the pane'
32
32
  end
33
33
  end
34
- assert_match /class=".*active.*"/, html
35
- assert_match /class=".*in.*"/, html
34
+ assert_match(/class=".*active.*"/, html)
35
+ assert_match(/class=".*in.*"/, html)
36
36
  end
37
37
 
38
- test "empty pane does not included in html" do
38
+ test 'empty pane does not included in html' do
39
39
  html = tabs do |tabs|
40
40
  tabs.pane 'Empty pane' do
41
41
  ''
42
42
  end
43
43
  end
44
- refute_match /Empty pane/, html
44
+ refute_match(/Empty pane/, html)
45
45
  end
46
46
  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: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Schneider
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-05 00:00:00.000000000 Z
11
+ date: 2016-04-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack
@@ -74,7 +74,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
74
  version: '0'
75
75
  requirements: []
76
76
  rubyforge_project:
77
- rubygems_version: 2.4.5.1
77
+ rubygems_version: 2.5.1
78
78
  signing_key:
79
79
  specification_version: 4
80
80
  summary: View helpers for Twitter Bootstrap components