bootstrap_builders 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.document +5 -0
- data/.rspec +1 -0
- data/.rubocop.yml +60 -0
- data/Gemfile +15 -0
- data/Gemfile.lock +100 -0
- data/LICENSE.txt +20 -0
- data/README.md +46 -0
- data/Rakefile +53 -0
- data/VERSION +1 -0
- data/bootstrap_helpers.gemspec +78 -0
- data/lib/bootstrap_helpers.rb +6 -0
- data/lib/bootstrap_helpers/box.rb +47 -0
- data/lib/bootstrap_helpers/button.rb +41 -0
- data/lib/bootstrap_helpers/helpers.rb +39 -0
- data/spec/bootstrap_helpers/box_spec.rb +17 -0
- data/spec/bootstrap_helpers/button_spec.rb +12 -0
- data/spec/spec_helper.rb +12 -0
- data/spec/support/working_helpers.rb +39 -0
- metadata +175 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: bbcbc8147a3418dade652132f1cde174721cc431
|
4
|
+
data.tar.gz: e4e53315ad98d24c9469cee66ddf8366fb1ef7ac
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 041f03df796090e49b25770b9f7390d129cd48b4023224812d3383693e271dc9b156e14e2b4b9c68b74c45ba01e6383bec9675f78bb69e10b4508e93dba94cbd
|
7
|
+
data.tar.gz: 55c2f14caff539a410d230c98bbf6d2ca9ea6f505e6c5d79a86461e2026975342861e617399e9e7125dd2d8c93e0409d9934ac3f9342ba432346ca26fa820f56
|
data/.document
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
AllCops:
|
2
|
+
DisplayCopNames: true
|
3
|
+
DisplayStyleGuide: true
|
4
|
+
Exclude:
|
5
|
+
- db/schema.rb
|
6
|
+
- spec/dummy/db/schema.rb
|
7
|
+
|
8
|
+
# https://github.com/AtomLinter/linter-rubocop/issues/2
|
9
|
+
Style/FileName:
|
10
|
+
Enabled: false
|
11
|
+
|
12
|
+
Metrics/LineLength:
|
13
|
+
Max: 160
|
14
|
+
|
15
|
+
Metrics/MethodLength:
|
16
|
+
Max: 50
|
17
|
+
|
18
|
+
Metrics/AbcSize:
|
19
|
+
Max: 25
|
20
|
+
|
21
|
+
Metrics/ClassLength:
|
22
|
+
Max: 250
|
23
|
+
|
24
|
+
Style/AccessModifierIndentation:
|
25
|
+
EnforcedStyle: outdent
|
26
|
+
|
27
|
+
Style/ClassAndModuleChildren:
|
28
|
+
EnforcedStyle: compact
|
29
|
+
|
30
|
+
Style/Documentation:
|
31
|
+
Enabled: false
|
32
|
+
|
33
|
+
Style/EmptyLines:
|
34
|
+
Enabled: false
|
35
|
+
|
36
|
+
Style/StringLiterals:
|
37
|
+
EnforcedStyle: double_quotes
|
38
|
+
|
39
|
+
Style/StringLiteralsInInterpolation:
|
40
|
+
Enabled: false
|
41
|
+
|
42
|
+
Style/NilComparison:
|
43
|
+
Enabled: false
|
44
|
+
|
45
|
+
Style/SignalException:
|
46
|
+
EnforcedStyle: only_raise
|
47
|
+
|
48
|
+
Style/MultilineOperationIndentation:
|
49
|
+
EnforcedStyle: indented
|
50
|
+
|
51
|
+
Style/SpaceInsideHashLiteralBraces:
|
52
|
+
EnforcedStyle: no_space
|
53
|
+
|
54
|
+
Style/TrivialAccessors:
|
55
|
+
ExactNameMatch: true
|
56
|
+
Enabled: true
|
57
|
+
|
58
|
+
# Disabled on purpose: https://github.com/bbatsov/rubocop/issues/1758
|
59
|
+
Style/ClosingParenthesisIndentation:
|
60
|
+
Enabled: false
|
data/Gemfile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
|
3
|
+
gem "html_gen", ">= 0.0.6"
|
4
|
+
gem "auto_autoloader", ">= 0.0.4"
|
5
|
+
|
6
|
+
# Add dependencies to develop your gem here.
|
7
|
+
# Include everything needed to run rake, tests, features, etc.
|
8
|
+
group :development do
|
9
|
+
gem "rspec", "~> 3.4.0"
|
10
|
+
gem "rdoc", "~> 3.12"
|
11
|
+
gem "bundler", "~> 1.0"
|
12
|
+
gem "jeweler", "~> 2.0.1"
|
13
|
+
gem "best_practice_project", github: "kaspernj/best_practice_project"
|
14
|
+
gem "rubocop", "0.36.0"
|
15
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
GIT
|
2
|
+
remote: git://github.com/kaspernj/best_practice_project.git
|
3
|
+
revision: 85edcdab3e63de1374de10f01fcf4a621099aae2
|
4
|
+
specs:
|
5
|
+
best_practice_project (0.0.8)
|
6
|
+
auto_autoloader
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: http://rubygems.org/
|
10
|
+
specs:
|
11
|
+
addressable (2.4.0)
|
12
|
+
ast (2.2.0)
|
13
|
+
auto_autoloader (0.0.4)
|
14
|
+
string-cases
|
15
|
+
builder (3.2.2)
|
16
|
+
descendants_tracker (0.0.4)
|
17
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
18
|
+
diff-lcs (1.2.5)
|
19
|
+
faraday (0.9.2)
|
20
|
+
multipart-post (>= 1.2, < 3)
|
21
|
+
git (1.2.9.1)
|
22
|
+
github_api (0.13.1)
|
23
|
+
addressable (~> 2.4.0)
|
24
|
+
descendants_tracker (~> 0.0.4)
|
25
|
+
faraday (~> 0.8, < 0.10)
|
26
|
+
hashie (>= 3.4)
|
27
|
+
multi_json (>= 1.7.5, < 2.0)
|
28
|
+
oauth2
|
29
|
+
hashie (3.4.3)
|
30
|
+
highline (1.7.8)
|
31
|
+
html_gen (0.0.6)
|
32
|
+
string-cases
|
33
|
+
jeweler (2.0.1)
|
34
|
+
builder
|
35
|
+
bundler (>= 1.0)
|
36
|
+
git (>= 1.2.5)
|
37
|
+
github_api
|
38
|
+
highline (>= 1.6.15)
|
39
|
+
nokogiri (>= 1.5.10)
|
40
|
+
rake
|
41
|
+
rdoc
|
42
|
+
json (1.8.3)
|
43
|
+
jwt (1.5.2)
|
44
|
+
mini_portile2 (2.0.0)
|
45
|
+
multi_json (1.11.2)
|
46
|
+
multi_xml (0.5.5)
|
47
|
+
multipart-post (2.0.0)
|
48
|
+
nokogiri (1.6.7.1)
|
49
|
+
mini_portile2 (~> 2.0.0.rc2)
|
50
|
+
oauth2 (1.0.0)
|
51
|
+
faraday (>= 0.8, < 0.10)
|
52
|
+
jwt (~> 1.0)
|
53
|
+
multi_json (~> 1.3)
|
54
|
+
multi_xml (~> 0.5)
|
55
|
+
rack (~> 1.2)
|
56
|
+
parser (2.3.0.1)
|
57
|
+
ast (~> 2.2)
|
58
|
+
powerpack (0.1.1)
|
59
|
+
rack (1.6.4)
|
60
|
+
rainbow (2.0.0)
|
61
|
+
rake (10.5.0)
|
62
|
+
rdoc (3.12.2)
|
63
|
+
json (~> 1.4)
|
64
|
+
rspec (3.4.0)
|
65
|
+
rspec-core (~> 3.4.0)
|
66
|
+
rspec-expectations (~> 3.4.0)
|
67
|
+
rspec-mocks (~> 3.4.0)
|
68
|
+
rspec-core (3.4.1)
|
69
|
+
rspec-support (~> 3.4.0)
|
70
|
+
rspec-expectations (3.4.0)
|
71
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
72
|
+
rspec-support (~> 3.4.0)
|
73
|
+
rspec-mocks (3.4.1)
|
74
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
75
|
+
rspec-support (~> 3.4.0)
|
76
|
+
rspec-support (3.4.1)
|
77
|
+
rubocop (0.36.0)
|
78
|
+
parser (>= 2.3.0.0, < 3.0)
|
79
|
+
powerpack (~> 0.1)
|
80
|
+
rainbow (>= 1.99.1, < 3.0)
|
81
|
+
ruby-progressbar (~> 1.7)
|
82
|
+
ruby-progressbar (1.7.5)
|
83
|
+
string-cases (0.0.4)
|
84
|
+
thread_safe (0.3.5)
|
85
|
+
|
86
|
+
PLATFORMS
|
87
|
+
ruby
|
88
|
+
|
89
|
+
DEPENDENCIES
|
90
|
+
auto_autoloader (>= 0.0.4)
|
91
|
+
best_practice_project!
|
92
|
+
bundler (~> 1.0)
|
93
|
+
html_gen (>= 0.0.6)
|
94
|
+
jeweler (~> 2.0.1)
|
95
|
+
rdoc (~> 3.12)
|
96
|
+
rspec (~> 3.4.0)
|
97
|
+
rubocop (= 0.36.0)
|
98
|
+
|
99
|
+
BUNDLED WITH
|
100
|
+
1.11.2
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2016 kaspernj
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# bootstrap_builders
|
2
|
+
|
3
|
+
## Install
|
4
|
+
|
5
|
+
Add to your Gemfile and bundle:
|
6
|
+
```ruby
|
7
|
+
gem "bootstrap_builders"
|
8
|
+
```
|
9
|
+
|
10
|
+
Then add to your `ApplicationHelper` module:
|
11
|
+
```ruby
|
12
|
+
module ApplicationHelper
|
13
|
+
include BootstrapBuilders::Helpers
|
14
|
+
end
|
15
|
+
```
|
16
|
+
|
17
|
+
## Usage
|
18
|
+
|
19
|
+
### Box
|
20
|
+
```haml
|
21
|
+
= box "Title of box", right: button_content do
|
22
|
+
Content of box
|
23
|
+
```
|
24
|
+
|
25
|
+
### Box with a table
|
26
|
+
```haml
|
27
|
+
= box "Title of box", table: true do
|
28
|
+
%tbody
|
29
|
+
%tr
|
30
|
+
%td= "Test"
|
31
|
+
|
32
|
+
## Contributing to bootstrap_builders
|
33
|
+
|
34
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
35
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
36
|
+
* Fork the project.
|
37
|
+
* Start a feature/bugfix branch.
|
38
|
+
* Commit and push until you are happy with your contribution.
|
39
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
40
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
41
|
+
|
42
|
+
## Copyright
|
43
|
+
|
44
|
+
Copyright (c) 2016 kaspernj. See LICENSE.txt for
|
45
|
+
further details.
|
46
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require "rubygems"
|
4
|
+
require "bundler"
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require "rake"
|
13
|
+
|
14
|
+
require "jeweler"
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://guides.rubygems.org/specification-reference/ for more options
|
17
|
+
gem.name = "bootstrap_builders"
|
18
|
+
gem.homepage = "http://github.com/kaspernj/bootstrap_builders"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %(A library to generate Bootstrap HTML for Rails.)
|
21
|
+
gem.description = %(A library to generate Bootstrap HTML for Rails.)
|
22
|
+
gem.email = "k@spernj.org"
|
23
|
+
gem.authors = ["kaspernj"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require "rspec/core"
|
29
|
+
require "rspec/core/rake_task"
|
30
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
31
|
+
spec.pattern = FileList["spec/**/*_spec.rb"]
|
32
|
+
end
|
33
|
+
|
34
|
+
desc "Code coverage detail"
|
35
|
+
task :simplecov do
|
36
|
+
ENV["COVERAGE"] = "true"
|
37
|
+
Rake::Task["spec"].execute
|
38
|
+
end
|
39
|
+
|
40
|
+
task default: :spec
|
41
|
+
|
42
|
+
require "rdoc/task"
|
43
|
+
Rake::RDocTask.new do |rdoc|
|
44
|
+
version = File.exist?("VERSION") ? File.read("VERSION") : ""
|
45
|
+
|
46
|
+
rdoc.rdoc_dir = "rdoc"
|
47
|
+
rdoc.title = "bootstrap_builders #{version}"
|
48
|
+
rdoc.rdoc_files.include("README*")
|
49
|
+
rdoc.rdoc_files.include("lib/**/*.rb")
|
50
|
+
end
|
51
|
+
|
52
|
+
require "best_practice_project"
|
53
|
+
BestPracticeProject.load_tasks
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.1
|
@@ -0,0 +1,78 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
# stub: bootstrap_builders 0.0.1 ruby lib
|
6
|
+
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.name = "bootstrap_builders"
|
9
|
+
s.version = "0.0.1"
|
10
|
+
|
11
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
|
+
s.require_paths = ["lib"]
|
13
|
+
s.authors = ["kaspernj"]
|
14
|
+
s.date = "2016-01-17"
|
15
|
+
s.description = "A library to generate Bootstrap HTML for Rails."
|
16
|
+
s.email = "k@spernj.org"
|
17
|
+
s.extra_rdoc_files = [
|
18
|
+
"LICENSE.txt",
|
19
|
+
"README.md"
|
20
|
+
]
|
21
|
+
s.files = [
|
22
|
+
".document",
|
23
|
+
".rspec",
|
24
|
+
".rubocop.yml",
|
25
|
+
"Gemfile",
|
26
|
+
"Gemfile.lock",
|
27
|
+
"LICENSE.txt",
|
28
|
+
"README.md",
|
29
|
+
"Rakefile",
|
30
|
+
"VERSION",
|
31
|
+
"lib/bootstrap_builders.rb",
|
32
|
+
"lib/bootstrap_builders/box.rb",
|
33
|
+
"lib/bootstrap_builders/button.rb",
|
34
|
+
"lib/bootstrap_builders/helpers.rb",
|
35
|
+
"spec/bootstrap_builders/box_spec.rb",
|
36
|
+
"spec/bootstrap_builders/button_spec.rb",
|
37
|
+
"spec/spec_helper.rb",
|
38
|
+
"spec/support/working_helpers.rb"
|
39
|
+
]
|
40
|
+
s.homepage = "http://github.com/kaspernj/bootstrap_builders"
|
41
|
+
s.licenses = ["MIT"]
|
42
|
+
s.rubygems_version = "2.2.2"
|
43
|
+
s.summary = "A library to generate Bootstrap HTML for Rails."
|
44
|
+
|
45
|
+
if s.respond_to? :specification_version then
|
46
|
+
s.specification_version = 4
|
47
|
+
|
48
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
49
|
+
s.add_runtime_dependency(%q<html_gen>, [">= 0.0.6"])
|
50
|
+
s.add_runtime_dependency(%q<auto_autoloader>, [">= 0.0.4"])
|
51
|
+
s.add_development_dependency(%q<rspec>, ["~> 3.4.0"])
|
52
|
+
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
53
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0"])
|
54
|
+
s.add_development_dependency(%q<jeweler>, ["~> 2.0.1"])
|
55
|
+
s.add_development_dependency(%q<best_practice_project>, [">= 0"])
|
56
|
+
s.add_development_dependency(%q<rubocop>, ["= 0.36.0"])
|
57
|
+
else
|
58
|
+
s.add_dependency(%q<html_gen>, [">= 0.0.6"])
|
59
|
+
s.add_dependency(%q<auto_autoloader>, [">= 0.0.4"])
|
60
|
+
s.add_dependency(%q<rspec>, ["~> 3.4.0"])
|
61
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
62
|
+
s.add_dependency(%q<bundler>, ["~> 1.0"])
|
63
|
+
s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
|
64
|
+
s.add_dependency(%q<best_practice_project>, [">= 0"])
|
65
|
+
s.add_dependency(%q<rubocop>, ["= 0.36.0"])
|
66
|
+
end
|
67
|
+
else
|
68
|
+
s.add_dependency(%q<html_gen>, [">= 0.0.6"])
|
69
|
+
s.add_dependency(%q<auto_autoloader>, [">= 0.0.4"])
|
70
|
+
s.add_dependency(%q<rspec>, ["~> 3.4.0"])
|
71
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
72
|
+
s.add_dependency(%q<bundler>, ["~> 1.0"])
|
73
|
+
s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
|
74
|
+
s.add_dependency(%q<best_practice_project>, [">= 0"])
|
75
|
+
s.add_dependency(%q<rubocop>, ["= 0.36.0"])
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
@@ -0,0 +1,47 @@
|
|
1
|
+
class BootstrapBuilders::Box
|
2
|
+
def initialize(args)
|
3
|
+
@title = args.fetch(:title)
|
4
|
+
@width = args.fetch(:width)
|
5
|
+
@right = args[:right]
|
6
|
+
@table = args[:table]
|
7
|
+
@block = args.fetch(:block)
|
8
|
+
|
9
|
+
@width = "#{@width}px" if @width.is_a?(Fixnum) || @width.is_a?(Integer)
|
10
|
+
end
|
11
|
+
|
12
|
+
def html
|
13
|
+
@panel = HtmlGen::Element.new(:div, classes: ["panel", "panel-default"], css: {width: @width})
|
14
|
+
|
15
|
+
add_heading if @title || @right
|
16
|
+
|
17
|
+
if @table
|
18
|
+
add_table
|
19
|
+
else
|
20
|
+
add_body
|
21
|
+
end
|
22
|
+
|
23
|
+
html = @panel.html
|
24
|
+
|
25
|
+
if html.respond_to?(:html_safe)
|
26
|
+
html.html_safe
|
27
|
+
else
|
28
|
+
html
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def add_heading
|
35
|
+
heading = @panel.add_ele(:div, classes: ["panel-heading", "clearfix"])
|
36
|
+
title = heading.add_ele(:div, classes: ["panel-title", "pull-left"], str: @title)
|
37
|
+
title.add_ele(:div, classes: ["pull-right"], str_html: @right)
|
38
|
+
end
|
39
|
+
|
40
|
+
def add_table
|
41
|
+
@panel.add_ele(:table, classes: ["table", "table-striped", "table-hover"], str_html: @block.call)
|
42
|
+
end
|
43
|
+
|
44
|
+
def add_body
|
45
|
+
@panel.add_ele(:div, classes: ["panel-body"], str_html: @block.call)
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
class BootstrapBuilders::Button
|
2
|
+
def initialize(args)
|
3
|
+
@title = args.fetch(:title)
|
4
|
+
@mini = args[:mini]
|
5
|
+
@class = args[:class]
|
6
|
+
@url = args.fetch(:url)
|
7
|
+
@args = args
|
8
|
+
@context = args.fetch(:context)
|
9
|
+
@icon = args.fetch(:icon)
|
10
|
+
end
|
11
|
+
|
12
|
+
def html
|
13
|
+
classes = ["btn", "btn-default"]
|
14
|
+
classes << "btn-xs" if @mini
|
15
|
+
|
16
|
+
if @class.is_a?(String)
|
17
|
+
classes += @class.split(/\s+/)
|
18
|
+
elsif @class.is_a?(Array)
|
19
|
+
classes += @class
|
20
|
+
end
|
21
|
+
|
22
|
+
@context.link_to @url, class: classes, data: @args[:data], method: @args[:method], remote: @args[:remote] do
|
23
|
+
html = ""
|
24
|
+
html << @context.content_tag(:i, class: ["fa", "fa-#{@icon}"])
|
25
|
+
html << " #{@title}"
|
26
|
+
html.html_safe
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def model_from_url(url)
|
33
|
+
if url.is_a?(Array) && url.last.is_a?(ActiveRecord::Base)
|
34
|
+
url.last
|
35
|
+
elsif url.is_a?(ActiveRecord::Base)
|
36
|
+
url
|
37
|
+
else
|
38
|
+
return nil
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Helpers
|
2
|
+
def bs_box(*opts, &blk)
|
3
|
+
title = opts.shift unless opts.first.is_a?(Hash)
|
4
|
+
width = opts.shift unless opts.first.is_a?(Hash)
|
5
|
+
|
6
|
+
if opts.length == 1 && opts.first.is_a?(Hash)
|
7
|
+
args = opts.first
|
8
|
+
title = args.fetch(:title) if args.key?(:title)
|
9
|
+
width = args[:width] if args.key?(:width)
|
10
|
+
right = args[:right] if args.key?(:right)
|
11
|
+
else
|
12
|
+
args = {}
|
13
|
+
end
|
14
|
+
|
15
|
+
BootstrapBuilders::Box.new(args.merge(title: title, width: width, right: right, block: blk)).html
|
16
|
+
end
|
17
|
+
|
18
|
+
def bs_edit_button(args)
|
19
|
+
BootstrapBuilders::Button.new(args.merge(title: t("edit"), icon: "wrench", context: self)).html
|
20
|
+
end
|
21
|
+
|
22
|
+
def bs_destroy_button(args)
|
23
|
+
args[:class] ||= []
|
24
|
+
args[:class] << "btn-danger"
|
25
|
+
|
26
|
+
args[:data] ||= {}
|
27
|
+
args[:data][:confirm] ||= t("are_you_sure")
|
28
|
+
|
29
|
+
BootstrapBuilders::Button.new(args.merge(title: t("delete"), icon: "remove", context: self, method: :delete)).html
|
30
|
+
end
|
31
|
+
|
32
|
+
def bs_new_button(args)
|
33
|
+
BootstrapBuilders::Button.new(args.merge(title: t("add_new"), icon: "pencil", context: self)).html
|
34
|
+
end
|
35
|
+
|
36
|
+
def bs_show_button(args)
|
37
|
+
BootstrapBuilders::Button.new(args.merge(title: t("show"), icon: "zoom-in", context: self)).html
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe BootstrapBuilders::Box do
|
4
|
+
include WorkingHelpers
|
5
|
+
|
6
|
+
it "generates a box by using panels" do
|
7
|
+
html = bs_box("Test title", 300, right: "test") { "test" }
|
8
|
+
expect(html).to include "test"
|
9
|
+
expect(html).to include "Test title"
|
10
|
+
expect(html).to include "width: 300px;"
|
11
|
+
end
|
12
|
+
|
13
|
+
it "generates a table" do
|
14
|
+
html = bs_box("Test title", table: true) { "trala" }
|
15
|
+
expect(html).to include "<table "
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe BootstrapBuilders::Button do
|
4
|
+
include WorkingHelpers
|
5
|
+
|
6
|
+
it "generates an edit button" do
|
7
|
+
html = bs_edit_button(url: "/test/url")
|
8
|
+
expect(html).to include "/test/url"
|
9
|
+
expect(html).to include "edit"
|
10
|
+
expect(html).to include "fa-wrench"
|
11
|
+
end
|
12
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
|
4
|
+
require "rspec"
|
5
|
+
require "bootstrap_builders"
|
6
|
+
|
7
|
+
# Requires supporting files with custom matchers and macros, etc,
|
8
|
+
# in ./support/ and its subdirectories.
|
9
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
10
|
+
|
11
|
+
RSpec.configure do |config|
|
12
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module WorkingHelpers
|
2
|
+
include BootstrapBuilders::Helpers
|
3
|
+
|
4
|
+
def t(key)
|
5
|
+
key
|
6
|
+
end
|
7
|
+
|
8
|
+
def link_to(*opts)
|
9
|
+
title = opts.shift if !opts.first.is_a?(Hash) && ((opts.length == 2 && !opts.last.is_a?(Hash)) || (opts.length == 3))
|
10
|
+
url = opts.shift unless opts.first.is_a?(Hash)
|
11
|
+
title ||= yield if block_given?
|
12
|
+
|
13
|
+
attrs = opts.shift || {}
|
14
|
+
attrs[:href] = url
|
15
|
+
|
16
|
+
classes = attrs.delete(:class)
|
17
|
+
|
18
|
+
HtmlGen::Element.new(:a, classes: classes, attr: attrs, str_html: title).html
|
19
|
+
end
|
20
|
+
|
21
|
+
def content_tag(*opts)
|
22
|
+
tag_name = opts.shift
|
23
|
+
|
24
|
+
content = opts.shift if opts.length >= 2
|
25
|
+
content = yield if block_given?
|
26
|
+
|
27
|
+
attrs = opts.shift
|
28
|
+
|
29
|
+
classes = attrs.delete(:class)
|
30
|
+
|
31
|
+
HtmlGen::Element.new(tag_name, classes: classes, attr: attrs, str_html: content).html
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
class String
|
36
|
+
def html_safe
|
37
|
+
self
|
38
|
+
end
|
39
|
+
end
|
metadata
ADDED
@@ -0,0 +1,175 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bootstrap_builders
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- kaspernj
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-01-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: html_gen
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.0.6
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.0.6
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: auto_autoloader
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.0.4
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.0.4
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 3.4.0
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 3.4.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rdoc
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.12'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.12'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: bundler
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: jeweler
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 2.0.1
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 2.0.1
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: best_practice_project
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rubocop
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - '='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 0.36.0
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - '='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 0.36.0
|
125
|
+
description: A library to generate Bootstrap HTML for Rails.
|
126
|
+
email: k@spernj.org
|
127
|
+
executables: []
|
128
|
+
extensions: []
|
129
|
+
extra_rdoc_files:
|
130
|
+
- LICENSE.txt
|
131
|
+
- README.md
|
132
|
+
files:
|
133
|
+
- ".document"
|
134
|
+
- ".rspec"
|
135
|
+
- ".rubocop.yml"
|
136
|
+
- Gemfile
|
137
|
+
- Gemfile.lock
|
138
|
+
- LICENSE.txt
|
139
|
+
- README.md
|
140
|
+
- Rakefile
|
141
|
+
- VERSION
|
142
|
+
- bootstrap_helpers.gemspec
|
143
|
+
- lib/bootstrap_helpers.rb
|
144
|
+
- lib/bootstrap_helpers/box.rb
|
145
|
+
- lib/bootstrap_helpers/button.rb
|
146
|
+
- lib/bootstrap_helpers/helpers.rb
|
147
|
+
- spec/bootstrap_helpers/box_spec.rb
|
148
|
+
- spec/bootstrap_helpers/button_spec.rb
|
149
|
+
- spec/spec_helper.rb
|
150
|
+
- spec/support/working_helpers.rb
|
151
|
+
homepage: http://github.com/kaspernj/bootstrap_builders
|
152
|
+
licenses:
|
153
|
+
- MIT
|
154
|
+
metadata: {}
|
155
|
+
post_install_message:
|
156
|
+
rdoc_options: []
|
157
|
+
require_paths:
|
158
|
+
- lib
|
159
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
160
|
+
requirements:
|
161
|
+
- - ">="
|
162
|
+
- !ruby/object:Gem::Version
|
163
|
+
version: '0'
|
164
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
165
|
+
requirements:
|
166
|
+
- - ">="
|
167
|
+
- !ruby/object:Gem::Version
|
168
|
+
version: '0'
|
169
|
+
requirements: []
|
170
|
+
rubyforge_project:
|
171
|
+
rubygems_version: 2.2.2
|
172
|
+
signing_key:
|
173
|
+
specification_version: 4
|
174
|
+
summary: A library to generate Bootstrap HTML for Rails.
|
175
|
+
test_files: []
|