twitter_bootstrap_markup 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (116) hide show
  1. data/.gitignore +5 -0
  2. data/Gemfile +4 -0
  3. data/README.md +29 -0
  4. data/Rakefile +1 -0
  5. data/lib/twitter_bootstrap_markup.rb +45 -0
  6. data/lib/twitter_bootstrap_markup/add_on.rb +9 -0
  7. data/lib/twitter_bootstrap_markup/alert.rb +35 -0
  8. data/lib/twitter_bootstrap_markup/badge.rb +4 -0
  9. data/lib/twitter_bootstrap_markup/brand.rb +9 -0
  10. data/lib/twitter_bootstrap_markup/breadcrumb.rb +21 -0
  11. data/lib/twitter_bootstrap_markup/button.rb +16 -0
  12. data/lib/twitter_bootstrap_markup/button_base.rb +41 -0
  13. data/lib/twitter_bootstrap_markup/control_group.rb +26 -0
  14. data/lib/twitter_bootstrap_markup/divider.rb +30 -0
  15. data/lib/twitter_bootstrap_markup/dropdown_button.rb +59 -0
  16. data/lib/twitter_bootstrap_markup/extended_input.rb +11 -0
  17. data/lib/twitter_bootstrap_markup/extension/hash.rb +11 -0
  18. data/lib/twitter_bootstrap_markup/fieldset.rb +18 -0
  19. data/lib/twitter_bootstrap_markup/form.rb +27 -0
  20. data/lib/twitter_bootstrap_markup/grid_column.rb +14 -0
  21. data/lib/twitter_bootstrap_markup/grid_row.rb +9 -0
  22. data/lib/twitter_bootstrap_markup/help.rb +24 -0
  23. data/lib/twitter_bootstrap_markup/icon.rb +18 -0
  24. data/lib/twitter_bootstrap_markup/input.rb +31 -0
  25. data/lib/twitter_bootstrap_markup/label.rb +4 -0
  26. data/lib/twitter_bootstrap_markup/label_base.rb +29 -0
  27. data/lib/twitter_bootstrap_markup/link.rb +17 -0
  28. data/lib/twitter_bootstrap_markup/link_button.rb +17 -0
  29. data/lib/twitter_bootstrap_markup/nav_bar.rb +32 -0
  30. data/lib/twitter_bootstrap_markup/nav_container.rb +10 -0
  31. data/lib/twitter_bootstrap_markup/nav_header.rb +9 -0
  32. data/lib/twitter_bootstrap_markup/nav_list.rb +11 -0
  33. data/lib/twitter_bootstrap_markup/nav_list_container.rb +10 -0
  34. data/lib/twitter_bootstrap_markup/nav_tab.rb +10 -0
  35. data/lib/twitter_bootstrap_markup/nav_tab_container.rb +13 -0
  36. data/lib/twitter_bootstrap_markup/page_header.rb +17 -0
  37. data/lib/twitter_bootstrap_markup/pagination.rb +29 -0
  38. data/lib/twitter_bootstrap_markup/popover.rb +20 -0
  39. data/lib/twitter_bootstrap_markup/progress_bar.rb +43 -0
  40. data/lib/twitter_bootstrap_markup/select.rb +67 -0
  41. data/lib/twitter_bootstrap_markup/side_position.rb +15 -0
  42. data/lib/twitter_bootstrap_markup/submit.rb +10 -0
  43. data/lib/twitter_bootstrap_markup/tab.rb +14 -0
  44. data/lib/twitter_bootstrap_markup/tab_content.rb +29 -0
  45. data/lib/twitter_bootstrap_markup/table.rb +28 -0
  46. data/lib/twitter_bootstrap_markup/tag.rb +51 -0
  47. data/lib/twitter_bootstrap_markup/tooltip.rb +19 -0
  48. data/lib/twitter_bootstrap_markup/ul_container.rb +21 -0
  49. data/lib/twitter_bootstrap_markup/version.rb +3 -0
  50. data/lib/twitter_bootstrap_markup/well.rb +27 -0
  51. data/markup/alerts.html +75 -0
  52. data/markup/badges.html +65 -0
  53. data/markup/breadcrumbs.html +59 -0
  54. data/markup/buttons.html +95 -0
  55. data/markup/control_groups.html +77 -0
  56. data/markup/css/bootstrap-responsive.css +815 -0
  57. data/markup/css/bootstrap-responsive.min.css +9 -0
  58. data/markup/css/bootstrap.css +4983 -0
  59. data/markup/css/bootstrap.min.css +9 -0
  60. data/markup/dropdown_buttons.html +248 -0
  61. data/markup/form_fields.html +88 -0
  62. data/markup/forms.html +81 -0
  63. data/markup/grid_system.html +87 -0
  64. data/markup/img/glyphicons-halflings-white.png +0 -0
  65. data/markup/img/glyphicons-halflings.png +0 -0
  66. data/markup/index.html +37 -0
  67. data/markup/js/bootstrap.js +1825 -0
  68. data/markup/js/bootstrap.min.js +6 -0
  69. data/markup/js/jquery-1.7.2.js +9402 -0
  70. data/markup/labels.html +65 -0
  71. data/markup/link_buttons.html +95 -0
  72. data/markup/nav_bars.html +104 -0
  73. data/markup/nav_lists.html +54 -0
  74. data/markup/paginations.html +68 -0
  75. data/markup/popovers.html +56 -0
  76. data/markup/progress_bars.html +93 -0
  77. data/markup/selects.html +124 -0
  78. data/markup/tabs.html +46 -0
  79. data/markup/textboxes.html +95 -0
  80. data/markup/tooltips.html +56 -0
  81. data/spec/add_on_spec.rb +10 -0
  82. data/spec/alert_spec.rb +77 -0
  83. data/spec/badge_spec.rb +29 -0
  84. data/spec/brand_spec.rb +10 -0
  85. data/spec/breadcrumb_spec.rb +32 -0
  86. data/spec/button_spec.rb +52 -0
  87. data/spec/control_group_spec.rb +29 -0
  88. data/spec/divider_spec.rb +17 -0
  89. data/spec/dropdown_button_spec.rb +101 -0
  90. data/spec/fieldset_spec.rb +22 -0
  91. data/spec/form_fields_spec.rb +71 -0
  92. data/spec/form_spec.rb +35 -0
  93. data/spec/grid_system_spec.rb +69 -0
  94. data/spec/help_spec.rb +13 -0
  95. data/spec/icon_spec.rb +18 -0
  96. data/spec/input_spec.rb +11 -0
  97. data/spec/label_spec.rb +29 -0
  98. data/spec/link_button_spec.rb +52 -0
  99. data/spec/link_spec.rb +29 -0
  100. data/spec/nav_bar_spec.rb +27 -0
  101. data/spec/nav_list_spec.rb +27 -0
  102. data/spec/page_header_spec.rb +13 -0
  103. data/spec/pagination_spec.rb +18 -0
  104. data/spec/popover_spec.rb +15 -0
  105. data/spec/progress_bar_spec.rb +53 -0
  106. data/spec/select_spec.rb +61 -0
  107. data/spec/spec_helper.rb +12 -0
  108. data/spec/support/helpers/html_helper.rb +11 -0
  109. data/spec/table_spec.rb +29 -0
  110. data/spec/tabs_spec.rb +22 -0
  111. data/spec/tag_spec.rb +40 -0
  112. data/spec/textbox_spec.rb +60 -0
  113. data/spec/tooltip_spec.rb +15 -0
  114. data/spec/well_spec.rb +17 -0
  115. data/twitter_bootstrap_markup.gemspec +23 -0
  116. metadata +182 -0
data/spec/help_spec.rb ADDED
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+
3
+ describe Help do
4
+
5
+ it 'inline' do
6
+ Help.inline('Shown to the right of the field').to_s.should eq '<span class="help-inline">Shown to the right of the field</span>'
7
+ end
8
+
9
+ it 'block' do
10
+ Help.block('Shown below the field').to_s.should eq '<p class="help-block">Shown below the field</p>'
11
+ end
12
+
13
+ end
data/spec/icon_spec.rb ADDED
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ describe Icon do
4
+
5
+ it 'simple' do
6
+ Icon.new('search').to_s.should eq '<i class="icon-search"></i>'
7
+ Icon.new('file').to_s.should eq '<i class="icon-file"></i>'
8
+ end
9
+
10
+ it 'white' do
11
+ Icon.new('search').white.to_s.should eq '<i class="icon-search icon-white"></i>'
12
+ end
13
+
14
+ it 'white constructor' do
15
+ Icon.white('search').to_s.should eq Icon.new('search').white.to_s
16
+ end
17
+
18
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe Input do
4
+
5
+ Input::TYPES.each do |type|
6
+ it type do
7
+ Input.send(type, :id => 'input_1').to_s.should eq "<input type=\"#{type}\" id=\"input_1\">"
8
+ end
9
+ end
10
+
11
+ end
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+
3
+ describe Label do
4
+
5
+ context 'Types' do
6
+
7
+ it 'default' do
8
+ Label.new('Default').to_s.should eq HtmlHelper.html_for('labels', "#default span")
9
+ end
10
+
11
+ LabelBase::TYPES.each do |type|
12
+ it type do
13
+ Label.new(type.to_s.capitalize).send(type).to_s.should eq HtmlHelper.html_for('labels', "##{type} span")
14
+ end
15
+ end
16
+
17
+ end
18
+
19
+ context 'Constructors' do
20
+
21
+ LabelBase::TYPES.each do |type|
22
+ it type do
23
+ Label.send(type, type.to_s.capitalize).to_s.should eq Label.new(type.to_s.capitalize).send(type).to_s
24
+ end
25
+ end
26
+
27
+ end
28
+
29
+ end
@@ -0,0 +1,52 @@
1
+ require 'spec_helper'
2
+
3
+ describe LinkButton do
4
+
5
+ context 'Types' do
6
+ it 'default' do
7
+ LinkButton.new('Click me', '#').to_s.should eq HtmlHelper.html_for('link_buttons', "#default a")
8
+ end
9
+
10
+ LinkButton::TYPES.each do |type|
11
+ it type do
12
+ LinkButton.new('Click me', '#').send(type).to_s.should eq HtmlHelper.html_for('link_buttons', "##{type} a")
13
+ end
14
+ end
15
+ end
16
+
17
+ context 'Sizes' do
18
+ LinkButton::SIZES.each do |size|
19
+ it size do
20
+ LinkButton.new('Click me', '#').send(size).to_s.should eq HtmlHelper.html_for('link_buttons', "##{size} a")
21
+ end
22
+ end
23
+ end
24
+
25
+ it 'Mixed' do
26
+ LinkButton.new('Click me', '#').primary.large.to_s.should eq HtmlHelper.html_for('link_buttons', "#mixed a")
27
+ end
28
+
29
+ context 'Constructors' do
30
+
31
+ LinkButton::TYPES.each do |type|
32
+ it type do
33
+ LinkButton.send(type, 'Click me', '#').to_s.should eq LinkButton.new('Click me', '#').send(type).to_s
34
+ end
35
+ end
36
+
37
+ LinkButton::SIZES.each do |size|
38
+ it size do
39
+ LinkButton.send(size, 'Click me', '#').to_s.should eq LinkButton.new('Click me', '#').send(size).to_s
40
+ end
41
+ end
42
+
43
+ LinkButton::TYPES.each do |type|
44
+ LinkButton::SIZES.each do |size|
45
+ it "#{type}_#{size}" do
46
+ LinkButton.send("#{type}_#{size}", 'Click me', '#').to_s.should eq LinkButton.new('Click me', '#').send(type).send(size).to_s
47
+ end
48
+ end
49
+ end
50
+ end
51
+
52
+ end
data/spec/link_spec.rb ADDED
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+
3
+ describe Link do
4
+
5
+ it 'text and url' do
6
+ Link.new('text', 'url').to_s.should eq '<a href="url">text</a>'
7
+ end
8
+
9
+ it 'text and url with aditional attributes' do
10
+ Link.new('text', 'url', :title => 'link').to_s.should eq '<a href="url" title="link">text</a>'
11
+ end
12
+
13
+ it 'url and block' do
14
+ Link.new('url') { append Tag.block(:strong) { append 'text' } }.to_s.should eq '<a href="url"><strong>text</strong></a>'
15
+ end
16
+
17
+ it 'url and block with aditional attributes' do
18
+ Link.new('url', :title => 'link') { append Tag.block(:strong) { append 'text' } }.to_s.should eq '<a href="url" title="link"><strong>text</strong></a>'
19
+ end
20
+
21
+ it 'url, image and text' do
22
+ tag = Link.new('url') do
23
+ append Icon.new('search')
24
+ append 'Search'
25
+ end
26
+ tag.to_s.should eq '<a href="url"><i class="icon-search"></i>Search</a>'
27
+ end
28
+
29
+ end
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+
3
+ describe NavBar do
4
+
5
+ [:default, :top, :bottom].each do |type|
6
+ it type do
7
+ tag = NavBar.send(type == :default ? :new : type) do
8
+ append Brand.new 'Brand', '#'
9
+ append do
10
+ NavContainer.new do
11
+ append Divider.vertical
12
+ append Link.new('Link 1', '#'), :active
13
+ append Link.new('Link 2', '#')
14
+ end
15
+ end
16
+ append do
17
+ NavContainer.new do
18
+ append Link.new('#') { append Icon.white('off', :title => 'logout') }
19
+ end.pull_right
20
+ end
21
+ end
22
+
23
+ tag.to_s.should eq HtmlHelper.html_for('nav_bars', "##{type} .navbar")
24
+ end
25
+ end
26
+
27
+ end
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+
3
+ describe NavList do
4
+
5
+ it 'default' do
6
+ tag = NavList.new do
7
+ append NavHeader.new 'Title'
8
+ append do
9
+ Link.new('#') do
10
+ append Icon.new('search')
11
+ append 'Search'
12
+ end
13
+ end
14
+ append do
15
+ Link.new('#') do
16
+ append Icon.new('file')
17
+ append 'New'
18
+ end
19
+ end
20
+ append Divider.horizontal
21
+ append 'Help'
22
+ end
23
+
24
+ tag.to_s.should eq HtmlHelper.html_for('nav_lists', "#default div")
25
+ end
26
+
27
+ end
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+
3
+ describe PageHeader do
4
+
5
+ it 'title' do
6
+ PageHeader.new('Page Title').to_s.should eq '<div class="page-header"><h1>Page Title</h1></div>'
7
+ end
8
+
9
+ it 'title and subtitle' do
10
+ PageHeader.new('Page Title', 'Subtitle').to_s.should eq '<div class="page-header"><h1>Page Title<small>Subtitle</small></h1></div>'
11
+ end
12
+
13
+ end
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ describe Pagination do
4
+
5
+ [:default, :centered, :right].each do |position|
6
+ it position do
7
+ tag = Pagination.send(position == :default ? :new : position) do
8
+ append Tag.new(:a) { append 'Prev' }, :active
9
+ append Tag.new(:a) { append 1 }, :active
10
+ append Link.new(2, '#')
11
+ append Link.new('Next', '#')
12
+ end
13
+
14
+ tag.to_s.should eq HtmlHelper.html_for('paginations', "##{position} .pagination")
15
+ end
16
+ end
17
+
18
+ end
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ describe Popover do
4
+
5
+ it 'default' do
6
+ Link.new('advanced', '#').popover('Title popover', 'This is a full explanation').to_s.should eq HtmlHelper.html_for('popovers', "#default a")
7
+ end
8
+
9
+ Tooltip::POSITIONS.reject { |p| p ==:right }.each do |position|
10
+ it position do
11
+ Link.new('advanced', '#').send("popover_#{position}", 'Title popover', 'This is a full explanation').to_s.should eq HtmlHelper.html_for('popovers', "##{position} a")
12
+ end
13
+ end
14
+
15
+ end
@@ -0,0 +1,53 @@
1
+ require 'spec_helper'
2
+
3
+ describe ProgressBar do
4
+
5
+ context 'Types' do
6
+
7
+ it 'default' do
8
+ ProgressBar.new(30).to_s.should eq HtmlHelper.html_for('progress_bars', "#default .progress")
9
+ end
10
+
11
+ ProgressBar::TYPES.each do |type|
12
+ it type do
13
+ ProgressBar.new(60).send(type).to_s.should eq HtmlHelper.html_for('progress_bars', "##{type} .progress")
14
+ end
15
+ end
16
+
17
+ end
18
+
19
+ context 'Display' do
20
+
21
+ it 'striped' do
22
+ ProgressBar.new(60).striped.to_s.should eq HtmlHelper.html_for('progress_bars', "#striped .progress")
23
+ end
24
+
25
+ it 'striped animated' do
26
+ ProgressBar.new(60).striped_animated.to_s.should eq HtmlHelper.html_for('progress_bars', "#animated .progress")
27
+ end
28
+
29
+ it 'mixed' do
30
+ ProgressBar.info(60).striped.to_s.should eq HtmlHelper.html_for('progress_bars', "#mixed .progress")
31
+ end
32
+
33
+ end
34
+
35
+ context 'Constructors' do
36
+
37
+ ProgressBar::TYPES.each do |type|
38
+ it type do
39
+ ProgressBar.send(type, 60).to_s.should eq ProgressBar.new(60).send(type).to_s
40
+ end
41
+
42
+ it "#{type}_striped" do
43
+ ProgressBar.send("#{type}_striped", 60).to_s.should eq ProgressBar.new(60).send(type).striped.to_s
44
+ end
45
+
46
+ it "#{type}_striped_animated" do
47
+ ProgressBar.send("#{type}_striped_animated", 60).to_s.should eq ProgressBar.new(60).send(type).striped_animated.to_s
48
+ end
49
+ end
50
+
51
+ end
52
+
53
+ end
@@ -0,0 +1,61 @@
1
+ require 'spec_helper'
2
+
3
+ describe Select do
4
+
5
+ context 'Options' do
6
+
7
+ it 'empty' do
8
+ Select.new([], :id => 'empty_select').to_s.should eq HtmlHelper.html_for('selects', "#empty select")
9
+ end
10
+
11
+ it 'array options' do
12
+ Select.new([1, 2], :id => 'array_select').to_s.should eq HtmlHelper.html_for('selects', "#array select")
13
+ end
14
+
15
+ it 'hash options' do
16
+ Select.new({:option1 => 1, :option2 => 2}, :id => 'hash_select').to_s.should eq HtmlHelper.html_for('selects', "#hash select")
17
+ end
18
+
19
+ it 'hash options group' do
20
+ options = {
21
+ :group1 => [1, 2],
22
+ :group2 => {
23
+ :optionA => 'A',
24
+ :optionB => 'B'
25
+ }
26
+ }
27
+ puts Select.new(options, :id => 'group_select').to_s
28
+ Select.new(options, :id => 'group_select').to_s.should eq HtmlHelper.html_for('selects', "#group select")
29
+ end
30
+
31
+ it 'selected value' do
32
+ Select.new([1, 2, 3], :selected_value => 2, :id => 'selected_select').to_s.should eq HtmlHelper.html_for('selects', "#selected select")
33
+ end
34
+
35
+ it 'prompt' do
36
+ Select.new([1, 2], :prompt => '[Select option]', :id => 'prompt_select').to_s.should eq HtmlHelper.html_for('selects', "#prompt select")
37
+ end
38
+
39
+ end
40
+
41
+ context 'Sizes' do
42
+
43
+ Select::SIZES.each do |size|
44
+ it size do
45
+ Select.new.send(size).to_s.should eq HtmlHelper.html_for('selects', "##{size} select")
46
+ end
47
+ end
48
+
49
+ end
50
+
51
+ context 'Constructors' do
52
+
53
+ Select::SIZES.each do |size|
54
+ it size do
55
+ Select.send(size).to_s.should eq Select.new.send(size).to_s
56
+ end
57
+ end
58
+
59
+ end
60
+
61
+ end
@@ -0,0 +1,12 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+ require 'twitter_bootstrap_markup'
4
+ require 'nokogiri'
5
+
6
+ include TwitterBootstrapMarkup
7
+
8
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
9
+
10
+ RSpec.configure do |config|
11
+
12
+ end
@@ -0,0 +1,11 @@
1
+ class HtmlHelper
2
+ def self.load(file_name)
3
+ Nokogiri::HTML(File.open("../markup/#{file_name}.html", 'r'){|f| f.readlines.join("\n")})
4
+ end
5
+
6
+ def self.html_for(file_name, css_path)
7
+ load(file_name).css(css_path).to_s.split(/\n/).inject do |result, line|
8
+ (result || '') << line.lstrip
9
+ end.gsub('&amp;', '&')
10
+ end
11
+ end
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+
3
+ describe Table do
4
+
5
+ context 'Types' do
6
+
7
+ it 'default' do
8
+ Table.new.to_s.should eq '<table class="table"></table>'
9
+ end
10
+
11
+ Table::TYPES.each do |type|
12
+ it type do
13
+ Table.new.send(type).to_s.should eq "<table class=\"table table-#{type}\"></table>"
14
+ end
15
+ end
16
+
17
+ end
18
+
19
+ context 'Constructors' do
20
+
21
+ Table::TYPES.each do |type|
22
+ it type do
23
+ Table.send(type).to_s.should eq Table.new.send(type).to_s
24
+ end
25
+ end
26
+
27
+ end
28
+
29
+ end