twitter-bootstrap-markup-rails 0.1.0
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.
- data/.gitignore +5 -0
- data/.travis.yml +8 -0
- data/Gemfile +4 -0
- data/Guardfile +7 -0
- data/README.md +98 -0
- data/Rakefile +26 -0
- data/lib/twitter-bootstrap-markup-rails.rb +17 -0
- data/lib/twitter-bootstrap-markup-rails/components.rb +8 -0
- data/lib/twitter-bootstrap-markup-rails/components/alert.rb +63 -0
- data/lib/twitter-bootstrap-markup-rails/components/base.rb +18 -0
- data/lib/twitter-bootstrap-markup-rails/components/inline_label.rb +30 -0
- data/lib/twitter-bootstrap-markup-rails/engine.rb +13 -0
- data/lib/twitter-bootstrap-markup-rails/helpers.rb +7 -0
- data/lib/twitter-bootstrap-markup-rails/helpers/alert_helpers.rb +41 -0
- data/lib/twitter-bootstrap-markup-rails/helpers/inline_label_helpers.rb +32 -0
- data/lib/twitter-bootstrap-markup-rails/version.rb +9 -0
- data/log/development.log +0 -0
- data/spec/helpers/alert_helpers_spec.rb +86 -0
- data/spec/helpers/inline_label_helpers_spec.rb +45 -0
- data/spec/integration/action_view_spec.rb +15 -0
- data/spec/spec_helper.rb +75 -0
- data/spec/support/test_environment.rb +23 -0
- data/twitter-bootstrap-markup-rails.gemspec +29 -0
- metadata +173 -0
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Guardfile
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
guard 'rspec', :version => 2 do
|
2
|
+
watch(%r{^spec/.+_spec\.rb$})
|
3
|
+
watch(%r{^lib/.*(helpers|components)/(.+)\.rb$}) { |m| "spec/#{m[1]}/#{m[2]}_spec.rb" }
|
4
|
+
watch('spec/spec_helper.rb') { "spec" }
|
5
|
+
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
|
6
|
+
watch(%r{^lib/(.+)\.rb$}) { "spec" }
|
7
|
+
end
|
data/README.md
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
Twitter Bootstrap 2.0 Markup for Rails [](http://travis-ci.org/pusewicz/twitter-bootstrap-markup-rails) [](https://gemnasium.com/pusewicz/twitter-bootstrap-markup-rails)
|
2
|
+
===
|
3
|
+
|
4
|
+
This gem focuses on making it easier to use Twitter's Bootstrap 2.0. It's a collection of helpers which should make it faster to use all the components provided by Twitter Bootstrap.
|
5
|
+
|
6
|
+
|
7
|
+
Installation
|
8
|
+
---
|
9
|
+
|
10
|
+
Add to your `Gemfile`:
|
11
|
+
|
12
|
+
gem "twitter-bootstrap-markup-rails", :git => "git://github.com/pusewicz/twitter-bootstrap-markup-rails.git"
|
13
|
+
|
14
|
+
Currently Supported
|
15
|
+
---
|
16
|
+
|
17
|
+
* Alert messages
|
18
|
+
* Inline labels
|
19
|
+
|
20
|
+
Documentation
|
21
|
+
---
|
22
|
+
|
23
|
+
Documentation is available on [RubyDoc](http://rubydoc.info/github/pusewicz/twitter-bootstrap-markup-rails).
|
24
|
+
|
25
|
+
Examples
|
26
|
+
---
|
27
|
+
|
28
|
+
Render Alert in your view:
|
29
|
+
|
30
|
+
bootstrap_alert_tag("Hello!")
|
31
|
+
# => '<div class="alert"><a class="close">×</a>Hello!</div>'
|
32
|
+
|
33
|
+
Render Info Block Alert in your view:
|
34
|
+
|
35
|
+
bootstrap_alert_info_block_tag("Hello!")
|
36
|
+
# => '<div class="alert alert-block alert-info"><a class="close">×</a>Hello!</div>'
|
37
|
+
|
38
|
+
Same with basic helper:
|
39
|
+
|
40
|
+
bootstrap_alert_tag("Hello!", :block => true, :type => "info")
|
41
|
+
# => '<div class="alert alert-block alert-info"><a class="close">×</a>Hello!</div>'
|
42
|
+
|
43
|
+
Add Alert heading:
|
44
|
+
|
45
|
+
bootstrap_alert_tag("Hello!", :heading => "Hola!")
|
46
|
+
# => '<div class="alert"><a class="close">×</a><strong>Hola!</strong>Hello!</div>'
|
47
|
+
|
48
|
+
Notice Inline Label:
|
49
|
+
|
50
|
+
bootstrap_inline_label_notice_tag("Info")
|
51
|
+
# => '<span class="label notice">Info</span>'
|
52
|
+
|
53
|
+
Contributing
|
54
|
+
---
|
55
|
+
|
56
|
+
In the spirit of free software, everyone is encouraged to help improve this project.
|
57
|
+
|
58
|
+
Here are some ways you can contribute:
|
59
|
+
|
60
|
+
* by using alpha, beta, and prerelease versions
|
61
|
+
* by reporting bugs
|
62
|
+
* by suggesting new features
|
63
|
+
* by writing or editing documentation
|
64
|
+
* by writing specifications
|
65
|
+
* by writing code (no patch is too small: fix typos, add comments, clean up inconsistent whitespace)
|
66
|
+
* by refactoring code
|
67
|
+
* by closing [issues](https://github.com/pusewicz/twitter-bootstrap-markup-rails/issues)
|
68
|
+
* by reviewing patches
|
69
|
+
|
70
|
+
Submitting an Issue
|
71
|
+
---
|
72
|
+
|
73
|
+
We use the [GitHub issue tracker](https://github.com/pusewicz/twitter-bootstrap-markup-rails/issues) to track bugs and features. Before submitting a bug report or feature request, check to make sure it hasn't already been submitted. You can indicate support for an existing issue by voting it up. When submitting a bug report, please include a [gist](https://gist.github.com/) that includes a stack trace and any details that may be necessary to reproduce the bug, including your gem version, Ruby version, and operating system. Ideally, a bug report should include a pull request with failing specs.
|
74
|
+
|
75
|
+
Submitting a Pull Request
|
76
|
+
---
|
77
|
+
|
78
|
+
1. Fork the project.
|
79
|
+
2. Create a topic branch.
|
80
|
+
3. Implement your feature or bug fix.
|
81
|
+
4. Add documentation for your feature or bug fix.
|
82
|
+
5. Run `bundle exec rake yard`. If your changes are not 100% documented, go back to step 4.
|
83
|
+
6. Add specs for your feature or bug fix.
|
84
|
+
7. Run `bundle exec rake spec`. If your changes are not 100% covered, go back to step 6.
|
85
|
+
8. Commit and push your changes.
|
86
|
+
9. Submit a pull request. Please do not include changes to the gemspec, version, or history file. (If you want to create your own version for some reason, please do so in a separate commit.)
|
87
|
+
|
88
|
+
Supported Ruby Versions
|
89
|
+
---
|
90
|
+
|
91
|
+
This library aims to support and is [tested against](http://travis-ci.org/pusewicz/twitter-bootstrap-markup-rails) the following Ruby implementations:
|
92
|
+
|
93
|
+
* Ruby 1.8.7
|
94
|
+
* Ruby 1.9.2
|
95
|
+
* Ruby 1.9.3
|
96
|
+
* Ruby Enterprise Edition
|
97
|
+
* Rubinius
|
98
|
+
* JRuby
|
data/Rakefile
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
require "bundler/gem_tasks"
|
3
|
+
require 'rspec/core/rake_task'
|
4
|
+
require 'rake/testtask'
|
5
|
+
require 'yard'
|
6
|
+
require 'yard/rake/yardoc_task'
|
7
|
+
|
8
|
+
task :default => :spec
|
9
|
+
|
10
|
+
Rake::TestTask.new do |t|
|
11
|
+
t.libs << "test"
|
12
|
+
t.test_files = FileList['test/*_test.rb']
|
13
|
+
t.verbose = true
|
14
|
+
end
|
15
|
+
|
16
|
+
desc 'Test the plugin.'
|
17
|
+
RSpec::Core::RakeTask.new('spec') do |t|
|
18
|
+
t.pattern = FileList['spec/**/*_spec.rb']
|
19
|
+
end
|
20
|
+
|
21
|
+
desc 'Generate docs'
|
22
|
+
YARD::Rake::YardocTask.new do |t|
|
23
|
+
t.files = ['lib/**/*.rb']
|
24
|
+
#t.options = ['--plugin', 'yard-tomdoc']
|
25
|
+
end
|
26
|
+
|
@@ -0,0 +1,17 @@
|
|
1
|
+
$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__))
|
2
|
+
|
3
|
+
module Twitter
|
4
|
+
module Bootstrap
|
5
|
+
module Markup
|
6
|
+
module Rails
|
7
|
+
require "twitter-bootstrap-markup-rails/version"
|
8
|
+
|
9
|
+
autoload :Helpers, "twitter-bootstrap-markup-rails/helpers"
|
10
|
+
autoload :Components, "twitter-bootstrap-markup-rails/components"
|
11
|
+
|
12
|
+
require "twitter-bootstrap-markup-rails/engine" if defined?(::Rails)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
@@ -0,0 +1,8 @@
|
|
1
|
+
module Twitter::Bootstrap::Markup::Rails
|
2
|
+
module Components
|
3
|
+
autoload :Base, 'twitter-bootstrap-markup-rails/components/base'
|
4
|
+
autoload :Alert, 'twitter-bootstrap-markup-rails/components/alert'
|
5
|
+
autoload :InlineLabel, 'twitter-bootstrap-markup-rails/components/inline_label'
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
@@ -0,0 +1,63 @@
|
|
1
|
+
module Twitter::Bootstrap::Markup::Rails::Components
|
2
|
+
class Alert < Base
|
3
|
+
attr_reader :message
|
4
|
+
|
5
|
+
def initialize(message, options = {})
|
6
|
+
super
|
7
|
+
@message = message
|
8
|
+
end
|
9
|
+
|
10
|
+
def to_s
|
11
|
+
output_buffer << content_tag(:div, :class => build_class) do
|
12
|
+
html = ""
|
13
|
+
html << build_close_tag.html_safe if options[:close]
|
14
|
+
html << build_heading_tag.html_safe if options[:heading]
|
15
|
+
html << message
|
16
|
+
html.html_safe
|
17
|
+
end.html_safe
|
18
|
+
super
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
def default_options
|
23
|
+
{
|
24
|
+
:class => "alert",
|
25
|
+
:block => false,
|
26
|
+
:close => true,
|
27
|
+
:heading => nil,
|
28
|
+
:dismiss => true,
|
29
|
+
:type => nil,
|
30
|
+
}
|
31
|
+
end
|
32
|
+
|
33
|
+
def build_close_tag
|
34
|
+
content_tag(:a, "×".html_safe, close_tag_options)
|
35
|
+
end
|
36
|
+
|
37
|
+
def build_heading_tag
|
38
|
+
options[:block] ? build_block_heading : build_inline_heading
|
39
|
+
end
|
40
|
+
|
41
|
+
def build_block_heading
|
42
|
+
content_tag(:h4, options[:heading], :class => 'alert-heading')
|
43
|
+
end
|
44
|
+
|
45
|
+
def build_inline_heading
|
46
|
+
content_tag(:strong, options[:heading])
|
47
|
+
end
|
48
|
+
|
49
|
+
def close_tag_options
|
50
|
+
opts = { :class => "close" }
|
51
|
+
opts["data-dismiss"] = "alert" if options[:dismiss]
|
52
|
+
opts
|
53
|
+
end
|
54
|
+
|
55
|
+
def build_class
|
56
|
+
classes = %w(alert)
|
57
|
+
classes << "alert-block" if options[:block]
|
58
|
+
classes << "alert-#{options[:type]}" if options[:type]
|
59
|
+
classes.join(" ")
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
module Twitter::Bootstrap::Markup::Rails::Components
|
3
|
+
class Base
|
4
|
+
include ActionView::Helpers::TagHelper
|
5
|
+
|
6
|
+
attr_accessor :output_buffer, :options, :default_options
|
7
|
+
|
8
|
+
def initialize(*args)
|
9
|
+
@output_buffer = ""
|
10
|
+
@options = args.extract_options!.reverse_merge(default_options)
|
11
|
+
end
|
12
|
+
|
13
|
+
def to_s
|
14
|
+
@output_buffer.to_s.html_safe
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Twitter::Bootstrap::Markup::Rails::Components
|
2
|
+
class InlineLabel < Base
|
3
|
+
attr_reader :message
|
4
|
+
|
5
|
+
def initialize(message, options = {})
|
6
|
+
super
|
7
|
+
@message = message
|
8
|
+
end
|
9
|
+
|
10
|
+
def to_s
|
11
|
+
output_buffer << content_tag(:span, message, :class => build_class).html_safe
|
12
|
+
super
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
def default_options
|
17
|
+
{
|
18
|
+
:class => "label",
|
19
|
+
:type => nil
|
20
|
+
}
|
21
|
+
end
|
22
|
+
|
23
|
+
def build_class
|
24
|
+
classes = [options[:class]]
|
25
|
+
classes << options[:type] if options[:type]
|
26
|
+
classes.join(" ")
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'rails'
|
2
|
+
|
3
|
+
module Twitter::Bootstrap::Markup::Rails
|
4
|
+
class Engine < ::Rails::Engine
|
5
|
+
initializer 'twitter.bootstrap.markup.rails.initialize' do
|
6
|
+
ActiveSupport.on_load(:action_view) do
|
7
|
+
include Twitter::Bootstrap::Markup::Rails::Helpers::AlertHelpers
|
8
|
+
include Twitter::Bootstrap::Markup::Rails::Helpers::InlineLabelHelpers
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Twitter::Bootstrap::Markup::Rails::Helpers
|
4
|
+
module AlertHelpers
|
5
|
+
# Renders alert message
|
6
|
+
#
|
7
|
+
# @param [String] message message to be displayed
|
8
|
+
# @param [Hash] options hash containing options (default: {}):
|
9
|
+
# :block - The Boolean whether to display as a block (optional)
|
10
|
+
# :close - The Boolean whether to render close button
|
11
|
+
# :heading - The String heading message to render
|
12
|
+
# :dismiss - The Boolean whether to add dismiss attribute
|
13
|
+
# :type - The String type of alert to display: error, success or info
|
14
|
+
#
|
15
|
+
# Examples
|
16
|
+
#
|
17
|
+
# bootstrap_alert("Hello!")
|
18
|
+
# # => '<div class="alert"><a class="close">×</a>Hello!</div>'
|
19
|
+
#
|
20
|
+
# Returns HTML String for the alert
|
21
|
+
def bootstrap_alert_tag(message, options = {})
|
22
|
+
Twitter::Bootstrap::Markup::Rails::Components::Alert.new(
|
23
|
+
message,
|
24
|
+
options
|
25
|
+
).to_s
|
26
|
+
end
|
27
|
+
|
28
|
+
%w(error success info).each do |type|
|
29
|
+
module_eval <<-EOF
|
30
|
+
def bootstrap_alert_#{type}_tag(message, options = {})
|
31
|
+
bootstrap_alert_tag(message, options.merge({ :type => "#{type}" }))
|
32
|
+
end
|
33
|
+
|
34
|
+
def bootstrap_alert_#{type}_block_tag(message, options = {})
|
35
|
+
bootstrap_alert_tag(message, options.merge({ :type => "#{type}", :block => true }))
|
36
|
+
end
|
37
|
+
EOF
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
module Twitter::Bootstrap::Markup::Rails::Helpers
|
3
|
+
module InlineLabelHelpers
|
4
|
+
# Renders inline label
|
5
|
+
#
|
6
|
+
# @param [String] message message to be displayed
|
7
|
+
# @param [Hash] options hash containing options (default: {}):
|
8
|
+
# :type - The String type of alert to display: success warning important notice
|
9
|
+
#
|
10
|
+
# Examples
|
11
|
+
#
|
12
|
+
# bootstrap_inline_label("Hello!")
|
13
|
+
# # => '<span class="label">Hello!</span>'
|
14
|
+
#
|
15
|
+
# Returns HTML String for the label
|
16
|
+
def bootstrap_inline_label_tag(message, options = {})
|
17
|
+
Twitter::Bootstrap::Markup::Rails::Components::InlineLabel.new(
|
18
|
+
message,
|
19
|
+
options
|
20
|
+
).to_s
|
21
|
+
end
|
22
|
+
|
23
|
+
%w(success warning important notice).each do |type|
|
24
|
+
module_eval <<-EOF
|
25
|
+
def bootstrap_inline_label_#{type}_tag(message, options = {})
|
26
|
+
bootstrap_inline_label_tag(message, options.merge({ :type => "#{type}" }))
|
27
|
+
end
|
28
|
+
EOF
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
data/log/development.log
ADDED
File without changes
|
@@ -0,0 +1,86 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe Twitter::Bootstrap::Markup::Rails::Helpers::AlertHelpers do
|
5
|
+
include BootstrapSpecHelper
|
6
|
+
|
7
|
+
%w(error success info).each do |type|
|
8
|
+
describe "#bootstrap_alert_#{type}_block_tag" do
|
9
|
+
before do
|
10
|
+
@output_buffer = ''
|
11
|
+
end
|
12
|
+
|
13
|
+
it "has alert class" do
|
14
|
+
concat send("bootstrap_alert_#{type}_block_tag", "Message")
|
15
|
+
output_buffer.should have_tag("div.alert")
|
16
|
+
end
|
17
|
+
|
18
|
+
it "has alert-block class" do
|
19
|
+
concat send("bootstrap_alert_#{type}_block_tag", "Message")
|
20
|
+
output_buffer.should have_tag("div.alert-block")
|
21
|
+
end
|
22
|
+
|
23
|
+
it "has alert-#{type} class" do
|
24
|
+
concat send("bootstrap_alert_#{type}_block_tag", "Message")
|
25
|
+
output_buffer.should have_tag("div.alert-#{type}")
|
26
|
+
end
|
27
|
+
|
28
|
+
it "has a message" do
|
29
|
+
concat send("bootstrap_alert_#{type}_block_tag", "Message")
|
30
|
+
output_buffer.should have_tag('div', /Message/)
|
31
|
+
end
|
32
|
+
|
33
|
+
it "has close button" do
|
34
|
+
concat send("bootstrap_alert_#{type}_block_tag", "Message")
|
35
|
+
output_buffer.should have_tag('div a.close', /×/)
|
36
|
+
end
|
37
|
+
|
38
|
+
it "has dismiss tag" do
|
39
|
+
concat send("bootstrap_alert_#{type}_block_tag", "Message")
|
40
|
+
output_buffer.should have_tag('div a[data-dismiss="alert"]')
|
41
|
+
end
|
42
|
+
|
43
|
+
it "has a heading" do
|
44
|
+
concat send("bootstrap_alert_#{type}_block_tag", "Message", :heading => "Heading1")
|
45
|
+
output_buffer.should have_tag('div h4.alert-heading', /Heading1/)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe "#bootstrap_alert_#{type}_tag" do
|
50
|
+
before do
|
51
|
+
@output_buffer = ''
|
52
|
+
end
|
53
|
+
|
54
|
+
it "has alert class" do
|
55
|
+
concat send("bootstrap_alert_#{type}_tag", "Message")
|
56
|
+
output_buffer.should have_tag("div.alert")
|
57
|
+
end
|
58
|
+
|
59
|
+
it "has alert-#{type} class" do
|
60
|
+
concat send("bootstrap_alert_#{type}_tag", "Message")
|
61
|
+
output_buffer.should have_tag("div.alert-#{type}")
|
62
|
+
end
|
63
|
+
|
64
|
+
it "has a message" do
|
65
|
+
concat send("bootstrap_alert_#{type}_tag", "Message")
|
66
|
+
output_buffer.should have_tag('div', /Message/)
|
67
|
+
end
|
68
|
+
|
69
|
+
it "has close button" do
|
70
|
+
concat send("bootstrap_alert_#{type}_tag", "Message")
|
71
|
+
output_buffer.should have_tag('div a.close', /×/)
|
72
|
+
end
|
73
|
+
|
74
|
+
it "has dismiss tag" do
|
75
|
+
concat send("bootstrap_alert_#{type}_tag", "Message")
|
76
|
+
output_buffer.should have_tag('div a[data-dismiss="alert"]')
|
77
|
+
end
|
78
|
+
|
79
|
+
it "has a heading" do
|
80
|
+
concat send("bootstrap_alert_#{type}_tag", "Message", :heading => "Heading1")
|
81
|
+
output_buffer.should have_tag('div strong', /Heading1/)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Twitter::Bootstrap::Markup::Rails::Helpers::InlineLabelHelpers do
|
4
|
+
include BootstrapSpecHelper
|
5
|
+
|
6
|
+
describe "#inline_label_tag" do
|
7
|
+
before do
|
8
|
+
@output_buffer = ''
|
9
|
+
end
|
10
|
+
|
11
|
+
it "has label class" do
|
12
|
+
concat bootstrap_inline_label_tag("Hi There")
|
13
|
+
output_buffer.should have_tag("span.label")
|
14
|
+
end
|
15
|
+
|
16
|
+
it "has a message" do
|
17
|
+
concat bootstrap_inline_label_tag("Hi There")
|
18
|
+
output_buffer.should have_tag("span", "Hi There")
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
%w(success warning important notice).each do |type|
|
23
|
+
describe "#inline_label_#{type}_tag" do
|
24
|
+
before do
|
25
|
+
@output_buffer = ''
|
26
|
+
end
|
27
|
+
|
28
|
+
it "has label class" do
|
29
|
+
concat send("bootstrap_inline_label_#{type}_tag", "Message")
|
30
|
+
output_buffer.should have_tag("span.label")
|
31
|
+
end
|
32
|
+
|
33
|
+
it "has #{type} class" do
|
34
|
+
concat send("bootstrap_inline_label_#{type}_tag", "Message")
|
35
|
+
output_buffer.should have_tag("span.#{type}")
|
36
|
+
end
|
37
|
+
|
38
|
+
it "has a message" do
|
39
|
+
concat send("bootstrap_inline_label_#{type}_tag", "Message")
|
40
|
+
output_buffer.should have_tag('span', /Message/)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ActionView::Base do
|
4
|
+
before do
|
5
|
+
@view = ActionView::Base
|
6
|
+
end
|
7
|
+
|
8
|
+
it "includes alert helpers" do
|
9
|
+
@view.ancestors.should include(Twitter::Bootstrap::Markup::Rails::Helpers::AlertHelpers)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "includes inline label helpers" do
|
13
|
+
@view.ancestors.should include(Twitter::Bootstrap::Markup::Rails::Helpers::InlineLabelHelpers)
|
14
|
+
end
|
15
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'bundler/setup'
|
3
|
+
|
4
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '../lib/twitter-bootstrap-markup-rails'))
|
5
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '../lib/twitter-bootstrap-markup-rails/engine'))
|
6
|
+
|
7
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].sort.each {|f| require f}
|
8
|
+
|
9
|
+
require 'active_support'
|
10
|
+
require 'action_pack'
|
11
|
+
require 'action_view'
|
12
|
+
require 'action_controller'
|
13
|
+
require 'action_dispatch'
|
14
|
+
|
15
|
+
module FakeHelpersModule
|
16
|
+
end
|
17
|
+
|
18
|
+
module BootstrapSpecHelper
|
19
|
+
include ActionPack
|
20
|
+
include ActionView::Context if defined?(ActionView::Context)
|
21
|
+
include ActionController::RecordIdentifier
|
22
|
+
include ActionView::Helpers::FormHelper
|
23
|
+
include ActionView::Helpers::FormTagHelper
|
24
|
+
include ActionView::Helpers::FormOptionsHelper
|
25
|
+
include ActionView::Helpers::UrlHelper
|
26
|
+
include ActionView::Helpers::TagHelper
|
27
|
+
include ActionView::Helpers::TextHelper
|
28
|
+
include ActionView::Helpers::ActiveRecordHelper if defined?(ActionView::Helpers::ActiveRecordHelper)
|
29
|
+
include ActionView::Helpers::ActiveModelHelper if defined?(ActionView::Helpers::ActiveModelHelper)
|
30
|
+
include ActionView::Helpers::DateHelper
|
31
|
+
include ActionView::Helpers::CaptureHelper
|
32
|
+
include ActionView::Helpers::AssetTagHelper
|
33
|
+
include ActiveSupport
|
34
|
+
include ActionController::PolymorphicRoutes if defined?(ActionController::PolymorphicRoutes)
|
35
|
+
|
36
|
+
def _routes
|
37
|
+
url_helpers = mock('url_helpers')
|
38
|
+
url_helpers.stub!(:hash_for_posts_path).and_return({})
|
39
|
+
url_helpers.stub!(:hash_for_post_path).and_return({})
|
40
|
+
url_helpers.stub!(:hash_for_post_models_path).and_return({})
|
41
|
+
url_helpers.stub!(:hash_for_authors_path).and_return({})
|
42
|
+
|
43
|
+
mock('_routes',
|
44
|
+
:url_helpers => url_helpers,
|
45
|
+
:url_for => "/mock/path"
|
46
|
+
)
|
47
|
+
end
|
48
|
+
|
49
|
+
def controller
|
50
|
+
env = mock('env', :[] => nil)
|
51
|
+
request = mock('request', :env => env)
|
52
|
+
mock('controller', :controller_path= => '', :params => {}, :request => request)
|
53
|
+
end
|
54
|
+
|
55
|
+
def default_url_options
|
56
|
+
{}
|
57
|
+
end
|
58
|
+
|
59
|
+
def self.included(base)
|
60
|
+
base.class_eval do
|
61
|
+
|
62
|
+
attr_accessor :output_buffer
|
63
|
+
|
64
|
+
def protect_against_forgery?
|
65
|
+
false
|
66
|
+
end
|
67
|
+
|
68
|
+
def _helpers
|
69
|
+
FakeHelpersModule
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rspec'
|
4
|
+
require 'rspec_tag_matchers'
|
5
|
+
|
6
|
+
RSpec.configure do |config|
|
7
|
+
config.include RspecTagMatchers
|
8
|
+
config.mock_with :rspec
|
9
|
+
end
|
10
|
+
|
11
|
+
require "action_controller/railtie"
|
12
|
+
|
13
|
+
# Create a simple rails application for use in testing the viewhelper
|
14
|
+
module BootstrapTest
|
15
|
+
class Application < Rails::Application
|
16
|
+
# Configure the default encoding used in templates for Ruby 1.9.
|
17
|
+
config.encoding = "utf-8"
|
18
|
+
config.active_support.deprecation = :stderr
|
19
|
+
end
|
20
|
+
end
|
21
|
+
BootstrapTest::Application.initialize!
|
22
|
+
|
23
|
+
require 'rspec/rails'
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/twitter-bootstrap-markup-rails/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Piotr Usewicz"]
|
6
|
+
gem.email = ["piotr@layer22.com"]
|
7
|
+
gem.description = %q{Ruby on Rails helpers for HTML, CSS, and JS toolkit from Twitter}
|
8
|
+
gem.summary = %q{Ruby on Rails helpers for HTML, CSS, and JS toolkit from Twitter}
|
9
|
+
gem.homepage = "https://github.com/pusewicz/twitter-bootstrap-markup-rails"
|
10
|
+
|
11
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
12
|
+
gem.files = `git ls-files`.split("\n")
|
13
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
14
|
+
gem.name = "twitter-bootstrap-markup-rails"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = Twitter::Bootstrap::Markup::Rails::VERSION
|
17
|
+
gem.platform = Gem::Platform::RUBY
|
18
|
+
|
19
|
+
gem.add_dependency "railties", "~> 3.0"
|
20
|
+
gem.add_development_dependency "rails", "~> 3.0"
|
21
|
+
gem.add_development_dependency "rspec-rails", "~> 2.8"
|
22
|
+
gem.add_development_dependency "guard", "~> 0.10"
|
23
|
+
gem.add_development_dependency "guard-rspec", "~> 0.6"
|
24
|
+
gem.add_development_dependency "rspec_tag_matchers", ">= 1.0.0"
|
25
|
+
gem.add_development_dependency "rake"
|
26
|
+
gem.add_development_dependency 'yard'
|
27
|
+
gem.add_development_dependency 'yard-tomdoc'
|
28
|
+
end
|
29
|
+
|
metadata
ADDED
@@ -0,0 +1,173 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: twitter-bootstrap-markup-rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Piotr Usewicz
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-01-21 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: railties
|
16
|
+
requirement: &70188163703920 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '3.0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70188163703920
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rails
|
27
|
+
requirement: &70188163703080 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ~>
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '3.0'
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70188163703080
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rspec-rails
|
38
|
+
requirement: &70188163702600 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '2.8'
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70188163702600
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: guard
|
49
|
+
requirement: &70188163701960 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.10'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *70188163701960
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: guard-rspec
|
60
|
+
requirement: &70188163701260 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ~>
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0.6'
|
66
|
+
type: :development
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *70188163701260
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec_tag_matchers
|
71
|
+
requirement: &70188163717020 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 1.0.0
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: *70188163717020
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: rake
|
82
|
+
requirement: &70188163716640 !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ! '>='
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
type: :development
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: *70188163716640
|
91
|
+
- !ruby/object:Gem::Dependency
|
92
|
+
name: yard
|
93
|
+
requirement: &70188163716100 !ruby/object:Gem::Requirement
|
94
|
+
none: false
|
95
|
+
requirements:
|
96
|
+
- - ! '>='
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
type: :development
|
100
|
+
prerelease: false
|
101
|
+
version_requirements: *70188163716100
|
102
|
+
- !ruby/object:Gem::Dependency
|
103
|
+
name: yard-tomdoc
|
104
|
+
requirement: &70188163715580 !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
type: :development
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: *70188163715580
|
113
|
+
description: Ruby on Rails helpers for HTML, CSS, and JS toolkit from Twitter
|
114
|
+
email:
|
115
|
+
- piotr@layer22.com
|
116
|
+
executables: []
|
117
|
+
extensions: []
|
118
|
+
extra_rdoc_files: []
|
119
|
+
files:
|
120
|
+
- .gitignore
|
121
|
+
- .travis.yml
|
122
|
+
- Gemfile
|
123
|
+
- Guardfile
|
124
|
+
- README.md
|
125
|
+
- Rakefile
|
126
|
+
- lib/twitter-bootstrap-markup-rails.rb
|
127
|
+
- lib/twitter-bootstrap-markup-rails/components.rb
|
128
|
+
- lib/twitter-bootstrap-markup-rails/components/alert.rb
|
129
|
+
- lib/twitter-bootstrap-markup-rails/components/base.rb
|
130
|
+
- lib/twitter-bootstrap-markup-rails/components/inline_label.rb
|
131
|
+
- lib/twitter-bootstrap-markup-rails/engine.rb
|
132
|
+
- lib/twitter-bootstrap-markup-rails/helpers.rb
|
133
|
+
- lib/twitter-bootstrap-markup-rails/helpers/alert_helpers.rb
|
134
|
+
- lib/twitter-bootstrap-markup-rails/helpers/inline_label_helpers.rb
|
135
|
+
- lib/twitter-bootstrap-markup-rails/version.rb
|
136
|
+
- log/development.log
|
137
|
+
- spec/helpers/alert_helpers_spec.rb
|
138
|
+
- spec/helpers/inline_label_helpers_spec.rb
|
139
|
+
- spec/integration/action_view_spec.rb
|
140
|
+
- spec/spec_helper.rb
|
141
|
+
- spec/support/test_environment.rb
|
142
|
+
- twitter-bootstrap-markup-rails.gemspec
|
143
|
+
homepage: https://github.com/pusewicz/twitter-bootstrap-markup-rails
|
144
|
+
licenses: []
|
145
|
+
post_install_message:
|
146
|
+
rdoc_options: []
|
147
|
+
require_paths:
|
148
|
+
- lib
|
149
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
150
|
+
none: false
|
151
|
+
requirements:
|
152
|
+
- - ! '>='
|
153
|
+
- !ruby/object:Gem::Version
|
154
|
+
version: '0'
|
155
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
156
|
+
none: false
|
157
|
+
requirements:
|
158
|
+
- - ! '>='
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: '0'
|
161
|
+
requirements: []
|
162
|
+
rubyforge_project:
|
163
|
+
rubygems_version: 1.8.13
|
164
|
+
signing_key:
|
165
|
+
specification_version: 3
|
166
|
+
summary: Ruby on Rails helpers for HTML, CSS, and JS toolkit from Twitter
|
167
|
+
test_files:
|
168
|
+
- spec/helpers/alert_helpers_spec.rb
|
169
|
+
- spec/helpers/inline_label_helpers_spec.rb
|
170
|
+
- spec/integration/action_view_spec.rb
|
171
|
+
- spec/spec_helper.rb
|
172
|
+
- spec/support/test_environment.rb
|
173
|
+
has_rdoc:
|