twitter_bootstrap_markup 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/twitter_bootstrap_markup/add_on.rb +1 -1
- data/lib/twitter_bootstrap_markup/alert.rb +3 -2
- data/lib/twitter_bootstrap_markup/brand.rb +1 -1
- data/lib/twitter_bootstrap_markup/breadcrumb.rb +5 -4
- data/lib/twitter_bootstrap_markup/button.rb +1 -1
- data/lib/twitter_bootstrap_markup/control_group.rb +1 -1
- data/lib/twitter_bootstrap_markup/divider.rb +1 -1
- data/lib/twitter_bootstrap_markup/dropdown_button.rb +1 -1
- data/lib/twitter_bootstrap_markup/fieldset.rb +1 -1
- data/lib/twitter_bootstrap_markup/help.rb +2 -2
- data/lib/twitter_bootstrap_markup/label_base.rb +1 -1
- data/lib/twitter_bootstrap_markup/link.rb +1 -1
- data/lib/twitter_bootstrap_markup/link_button.rb +1 -1
- data/lib/twitter_bootstrap_markup/nav_header.rb +1 -1
- data/lib/twitter_bootstrap_markup/page_header.rb +1 -1
- data/lib/twitter_bootstrap_markup/select.rb +3 -3
- data/lib/twitter_bootstrap_markup/tab_content.rb +1 -1
- data/lib/twitter_bootstrap_markup/table.rb +2 -1
- data/lib/twitter_bootstrap_markup/tag.rb +9 -7
- data/lib/twitter_bootstrap_markup/ul_container.rb +1 -1
- data/lib/twitter_bootstrap_markup/version.rb +1 -1
- data/lib/twitter_bootstrap_markup/well.rb +3 -2
- data/spec/alert_spec.rb +8 -8
- data/spec/link_spec.rb +2 -2
- data/spec/page_header_spec.rb +1 -1
- data/spec/pagination_spec.rb +2 -2
- data/spec/table_spec.rb +4 -0
- data/spec/tabs_spec.rb +3 -3
- data/spec/tag_spec.rb +1 -1
- data/spec/well_spec.rb +3 -3
- metadata +6 -6
@@ -2,8 +2,9 @@ module TwitterBootstrapMarkup
|
|
2
2
|
class Alert < Tag
|
3
3
|
TYPES = [:warning, :info, :success, :danger]
|
4
4
|
|
5
|
-
def initialize(
|
6
|
-
super(:div,
|
5
|
+
def initialize(*args, &block)
|
6
|
+
super(:div, *args, &block)
|
7
|
+
attributes.prepend!(:class, 'alert')
|
7
8
|
end
|
8
9
|
|
9
10
|
TYPES.each do |type|
|
@@ -2,18 +2,19 @@ module TwitterBootstrapMarkup
|
|
2
2
|
class Breadcrumb < Tag
|
3
3
|
alias :internal_append :append
|
4
4
|
|
5
|
-
def initialize(
|
6
|
-
super(:ul,
|
5
|
+
def initialize(*args, &block)
|
6
|
+
super(:ul, *args, &block)
|
7
|
+
attributes.prepend!(:class, 'breadcrumb')
|
7
8
|
end
|
8
9
|
|
9
10
|
def append(element=nil, &block)
|
10
|
-
internal_append Tag.block(:li
|
11
|
+
internal_append Tag.block(:li, Divider.breadcrumb) unless children.empty?
|
11
12
|
|
12
13
|
element = instance_eval(&block) if block_given?
|
13
14
|
if element.is_a?(Tag) && element.name == :li
|
14
15
|
internal_append element
|
15
16
|
else
|
16
|
-
internal_append Tag.block(:li
|
17
|
+
internal_append Tag.block(:li, element)
|
17
18
|
end
|
18
19
|
end
|
19
20
|
|
@@ -4,7 +4,7 @@ module TwitterBootstrapMarkup
|
|
4
4
|
|
5
5
|
def initialize(label, attributes={}, &block)
|
6
6
|
super(:div, :class => 'control-group') do
|
7
|
-
append Tag.block(:label, attributes.prepend!(:class, 'control-label'))
|
7
|
+
append Tag.block(:label, label, attributes.prepend!(:class, 'control-label'))
|
8
8
|
append Tag.block(:div, :class => 'controls', &block)
|
9
9
|
end
|
10
10
|
end
|
@@ -8,7 +8,7 @@ module TwitterBootstrapMarkup
|
|
8
8
|
when :vertical
|
9
9
|
super(:li, :class => 'divider-vertical') {}
|
10
10
|
when :breadcrumb
|
11
|
-
super(:span, :class => 'divider') {
|
11
|
+
super(:span, '/', :class => 'divider') {}
|
12
12
|
else
|
13
13
|
raise "Invalid divider type [#{type}]"
|
14
14
|
end
|
@@ -4,9 +4,9 @@ module TwitterBootstrapMarkup
|
|
4
4
|
def initialize(type, text)
|
5
5
|
case type
|
6
6
|
when :inline
|
7
|
-
super(:span, :class => 'help-inline') {
|
7
|
+
super(:span, text, :class => 'help-inline') {}
|
8
8
|
when :block
|
9
|
-
super(:p, :class => 'help-block') {
|
9
|
+
super(:p, text, :class => 'help-block') {}
|
10
10
|
else
|
11
11
|
raise "Invalid help type [#{type}]"
|
12
12
|
end
|
@@ -9,7 +9,7 @@ module TwitterBootstrapMarkup
|
|
9
9
|
if block_given?
|
10
10
|
super(:a, attributes.prepend!(:class, 'btn').merge(:href => url), &block)
|
11
11
|
else
|
12
|
-
super(:a, attributes.prepend!(:class, 'btn').merge(:href => url)) {
|
12
|
+
super(:a, text, attributes.prepend!(:class, 'btn').merge(:href => url)) {}
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
@@ -15,7 +15,7 @@ module TwitterBootstrapMarkup
|
|
15
15
|
append_options
|
16
16
|
end
|
17
17
|
|
18
|
-
prepend Tag.new(:option, :value => '') {
|
18
|
+
prepend Tag.new(:option, prompt, :value => '') {} if prompt
|
19
19
|
end
|
20
20
|
|
21
21
|
SIZES.each do |size|
|
@@ -43,7 +43,7 @@ module TwitterBootstrapMarkup
|
|
43
43
|
|
44
44
|
def append_options_array(options, container=self)
|
45
45
|
options.each do |option|
|
46
|
-
o = container.append Tag.block(:option, :value => option) {
|
46
|
+
o = container.append Tag.block(:option, option, :value => option) {}
|
47
47
|
o.attributes[:selected] = nil if option.to_s == @selected_value.to_s
|
48
48
|
end
|
49
49
|
end
|
@@ -57,7 +57,7 @@ module TwitterBootstrapMarkup
|
|
57
57
|
group = append Tag.block(:optgroup, :label => key)
|
58
58
|
append_options_hash(value, group)
|
59
59
|
else
|
60
|
-
o = container.append Tag.block(:option, :value => value) {
|
60
|
+
o = container.append Tag.block(:option, key, :value => value) {}
|
61
61
|
o.attributes[:selected] = nil if value.to_s == @selected_value.to_s
|
62
62
|
end
|
63
63
|
end
|
@@ -22,7 +22,7 @@ module TwitterBootstrapMarkup
|
|
22
22
|
else
|
23
23
|
attributes = {:class => 'tab-pane', :id => id}
|
24
24
|
attributes.append!(:class, :active) if mode == :active
|
25
|
-
internal_append Tag.block(:div, attributes)
|
25
|
+
internal_append Tag.block(:div, element, attributes)
|
26
26
|
end
|
27
27
|
end
|
28
28
|
end
|
@@ -12,19 +12,21 @@ module TwitterBootstrapMarkup
|
|
12
12
|
Tag.new(name, attributes)
|
13
13
|
end
|
14
14
|
|
15
|
-
def self.block(
|
15
|
+
def self.block(*args, &block)
|
16
16
|
if block_given?
|
17
|
-
Tag.new(
|
17
|
+
Tag.new(*args, &block)
|
18
18
|
else
|
19
|
-
Tag.new(
|
19
|
+
Tag.new(*args) {}
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
def initialize(
|
24
|
-
@name =
|
25
|
-
|
23
|
+
def initialize(*args, &block)
|
24
|
+
@name = args.shift
|
25
|
+
content = args.shift unless args.first.is_a?(Hash)
|
26
|
+
@attributes = args.shift || {}
|
26
27
|
@children = []
|
27
|
-
@is_block = block_given?
|
28
|
+
@is_block = content || block_given?
|
29
|
+
append content if content
|
28
30
|
instance_eval &block if block_given?
|
29
31
|
end
|
30
32
|
|
@@ -13,7 +13,7 @@ module TwitterBootstrapMarkup
|
|
13
13
|
internal_append element
|
14
14
|
else
|
15
15
|
attributes = mode == :active ? {:class => 'active'} : {}
|
16
|
-
internal_append Tag.block(:li, attributes)
|
16
|
+
internal_append Tag.block(:li, element, attributes)
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
@@ -1,8 +1,9 @@
|
|
1
1
|
module TwitterBootstrapMarkup
|
2
2
|
class Well < Tag
|
3
3
|
|
4
|
-
def initialize(
|
5
|
-
super(:div,
|
4
|
+
def initialize(*args, &block)
|
5
|
+
super(:div, *args, &block)
|
6
|
+
attributes.prepend!(:class, 'well')
|
6
7
|
end
|
7
8
|
|
8
9
|
def small
|
data/spec/alert_spec.rb
CHANGED
@@ -7,7 +7,7 @@ describe Alert do
|
|
7
7
|
Alert::TYPES.each do |type|
|
8
8
|
it type do
|
9
9
|
tag = Alert.new do
|
10
|
-
append Tag.block
|
10
|
+
append Tag.block :strong, 'Alert!'
|
11
11
|
append 'Message'
|
12
12
|
end
|
13
13
|
|
@@ -17,7 +17,7 @@ describe Alert do
|
|
17
17
|
|
18
18
|
it 'closable' do
|
19
19
|
tag = Alert.new do
|
20
|
-
append Tag.block
|
20
|
+
append Tag.block :strong, 'Alert!'
|
21
21
|
append 'Message'
|
22
22
|
end
|
23
23
|
|
@@ -31,12 +31,12 @@ describe Alert do
|
|
31
31
|
Alert::TYPES.each do |type|
|
32
32
|
it type do
|
33
33
|
tag1 = Alert.send(type) do
|
34
|
-
append Tag.block
|
34
|
+
append Tag.block :strong, 'Alert!'
|
35
35
|
append 'Message'
|
36
36
|
end
|
37
37
|
|
38
38
|
tag2 = Alert.new do
|
39
|
-
append Tag.block
|
39
|
+
append Tag.block :strong, 'Alert!'
|
40
40
|
append 'Message'
|
41
41
|
end
|
42
42
|
|
@@ -45,12 +45,12 @@ describe Alert do
|
|
45
45
|
|
46
46
|
it "#{type}_closable" do
|
47
47
|
tag1 = Alert.send("#{type}_closable") do
|
48
|
-
append Tag.block
|
48
|
+
append Tag.block :strong, 'Alert!'
|
49
49
|
append 'Message'
|
50
50
|
end
|
51
51
|
|
52
52
|
tag2 = Alert.new do
|
53
|
-
append Tag.block
|
53
|
+
append Tag.block :strong, 'Alert!'
|
54
54
|
append 'Message'
|
55
55
|
end
|
56
56
|
|
@@ -60,12 +60,12 @@ describe Alert do
|
|
60
60
|
|
61
61
|
it 'closable' do
|
62
62
|
tag1 = Alert.closable do
|
63
|
-
append Tag.block
|
63
|
+
append Tag.block :strong, 'Alert!'
|
64
64
|
append 'Message'
|
65
65
|
end
|
66
66
|
|
67
67
|
tag2 = Alert.new do
|
68
|
-
append Tag.block
|
68
|
+
append Tag.block :strong, 'Alert!'
|
69
69
|
append 'Message'
|
70
70
|
end
|
71
71
|
|
data/spec/link_spec.rb
CHANGED
@@ -11,11 +11,11 @@ describe Link do
|
|
11
11
|
end
|
12
12
|
|
13
13
|
it 'url and block' do
|
14
|
-
Link.new('url') { append Tag.block(:strong
|
14
|
+
Link.new('url') { append Tag.block(:strong, 'text') }.to_s.should eq '<a href="url"><strong>text</strong></a>'
|
15
15
|
end
|
16
16
|
|
17
17
|
it 'url and block with aditional attributes' do
|
18
|
-
Link.new('url', :title => 'link') { append Tag.block(:strong
|
18
|
+
Link.new('url', :title => 'link') { append Tag.block(:strong, 'text') }.to_s.should eq '<a href="url" title="link"><strong>text</strong></a>'
|
19
19
|
end
|
20
20
|
|
21
21
|
it 'url, image and text' do
|
data/spec/page_header_spec.rb
CHANGED
@@ -7,7 +7,7 @@ describe PageHeader do
|
|
7
7
|
end
|
8
8
|
|
9
9
|
it 'title and subtitle' do
|
10
|
-
PageHeader.new('Page Title', 'Subtitle').to_s.should eq '<div class="page-header"><h1>Page Title<small
|
10
|
+
PageHeader.new('Page Title', 'Subtitle').to_s.should eq '<div class="page-header"><h1>Page Title<small> Subtitle</small></h1></div>'
|
11
11
|
end
|
12
12
|
|
13
13
|
end
|
data/spec/pagination_spec.rb
CHANGED
@@ -5,8 +5,8 @@ describe Pagination do
|
|
5
5
|
[:default, :centered, :right].each do |position|
|
6
6
|
it position do
|
7
7
|
tag = Pagination.send(position == :default ? :new : position) do
|
8
|
-
append Tag.new(:a
|
9
|
-
append Tag.new(:a
|
8
|
+
append Tag.new(:a, 'Prev'), :active
|
9
|
+
append Tag.new(:a, 1), :active
|
10
10
|
append Link.new(2, '#')
|
11
11
|
append Link.new('Next', '#')
|
12
12
|
end
|
data/spec/table_spec.rb
CHANGED
data/spec/tabs_spec.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe Tab do
|
4
4
|
|
5
5
|
it 'default' do
|
6
6
|
tag = Tab.new do
|
@@ -8,11 +8,11 @@ describe 'Tab' do
|
|
8
8
|
nav.append NavTab.new('Tab 2', '#tab2')
|
9
9
|
nav.append NavTab.new('#tab3') { append 'Tab 3' }
|
10
10
|
content.append('tab1', :active) do
|
11
|
-
Tag.block
|
11
|
+
Tag.block :i, 'Content for Tab 1'
|
12
12
|
end
|
13
13
|
content.append 'tab2', 'Content for Tab 2'
|
14
14
|
content.append('tab3') do
|
15
|
-
Tag.block
|
15
|
+
Tag.block :strong, 'Content for Tab 3'
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
data/spec/tag_spec.rb
CHANGED
@@ -26,7 +26,7 @@ describe Tag do
|
|
26
26
|
end
|
27
27
|
|
28
28
|
it 'Create text container tag' do
|
29
|
-
Tag.block(:div, :style => 'width: 100%')
|
29
|
+
Tag.block(:div, 'Title', :style => 'width: 100%').to_s.should eq '<div style="width: 100%">Title</div>'
|
30
30
|
end
|
31
31
|
|
32
32
|
it 'Create tag tree' do
|
data/spec/well_spec.rb
CHANGED
@@ -3,15 +3,15 @@ require 'spec_helper'
|
|
3
3
|
describe Well do
|
4
4
|
|
5
5
|
it 'default' do
|
6
|
-
Well.new
|
6
|
+
Well.new('This is a well').to_s.should eq '<div class="well">This is a well</div>'
|
7
7
|
end
|
8
8
|
|
9
9
|
it 'small' do
|
10
|
-
Well.small
|
10
|
+
Well.small('This is a small well').to_s.should eq '<div class="well well-small">This is a small well</div>'
|
11
11
|
end
|
12
12
|
|
13
13
|
it 'large' do
|
14
|
-
Well.large
|
14
|
+
Well.large('This is a large well').to_s.should eq '<div class="well well-large">This is a large well</div>'
|
15
15
|
end
|
16
16
|
|
17
17
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: twitter_bootstrap_markup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-07-
|
12
|
+
date: 2012-07-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &25752036 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *25752036
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: nokogiri
|
27
|
-
requirement: &
|
27
|
+
requirement: &25751784 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *25751784
|
36
36
|
description: Object Oriented Twitter Bootstrap Markup
|
37
37
|
email:
|
38
38
|
- gabynaiman@gmail.com
|