bootstrap_builders 0.0.3 → 0.0.4
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 +4 -4
- data/{LICENSE.txt → MIT-LICENSE} +1 -1
- data/README.md +52 -8
- data/Rakefile +17 -44
- data/app/assets/javascripts/bootstrap_builders/application.js +13 -0
- data/app/assets/stylesheets/bootstrap_builders/application.css +15 -0
- data/app/controllers/bootstrap_builders/application_controller.rb +2 -0
- data/app/helpers/bootstrap_builders/application_helper.rb +104 -0
- data/app/views/layouts/bootstrap_builders/application.html.erb +14 -0
- data/config/routes.rb +2 -0
- data/config/spring.rb +1 -0
- data/lib/bootstrap_builders.rb +15 -5
- data/lib/bootstrap_builders/attribute_rows.rb +95 -0
- data/lib/bootstrap_builders/button.rb +90 -22
- data/lib/bootstrap_builders/class_attribute_handler.rb +20 -0
- data/lib/bootstrap_builders/configuration.rb +7 -0
- data/lib/bootstrap_builders/engine.rb +3 -0
- data/lib/bootstrap_builders/is_a_checker.rb +14 -0
- data/lib/bootstrap_builders/panel.rb +88 -0
- data/lib/bootstrap_builders/table.rb +44 -0
- data/lib/bootstrap_builders/version.rb +3 -0
- data/lib/tasks/bootstrap_builders_tasks.rake +4 -0
- metadata +158 -44
- data/.document +0 -5
- data/.rspec +0 -1
- data/.rubocop.yml +0 -60
- data/Gemfile +0 -14
- data/Gemfile.lock +0 -99
- data/VERSION +0 -1
- data/bootstrap_builders.gemspec +0 -76
- data/lib/bootstrap_builders/application_helpers.rb +0 -55
- data/lib/bootstrap_builders/box.rb +0 -66
- data/spec/bootstrap_helpers/box_spec.rb +0 -17
- data/spec/bootstrap_helpers/button_spec.rb +0 -12
- data/spec/spec_helper.rb +0 -12
- data/spec/support/working_helpers.rb +0 -39
data/.document
DELETED
data/.rspec
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
--color
|
data/.rubocop.yml
DELETED
@@ -1,60 +0,0 @@
|
|
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
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
source "http://rubygems.org"
|
2
|
-
|
3
|
-
gem "html_gen", ">= 0.0.11"
|
4
|
-
|
5
|
-
# Add dependencies to develop your gem here.
|
6
|
-
# Include everything needed to run rake, tests, features, etc.
|
7
|
-
group :development do
|
8
|
-
gem "rspec", "~> 3.4.0"
|
9
|
-
gem "rdoc", "~> 3.12"
|
10
|
-
gem "bundler", "~> 1.0"
|
11
|
-
gem "jeweler", "~> 2.0.1"
|
12
|
-
gem "best_practice_project", github: "kaspernj/best_practice_project"
|
13
|
-
gem "rubocop", "0.36.0"
|
14
|
-
end
|
data/Gemfile.lock
DELETED
@@ -1,99 +0,0 @@
|
|
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.11)
|
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
|
-
best_practice_project!
|
91
|
-
bundler (~> 1.0)
|
92
|
-
html_gen (>= 0.0.11)
|
93
|
-
jeweler (~> 2.0.1)
|
94
|
-
rdoc (~> 3.12)
|
95
|
-
rspec (~> 3.4.0)
|
96
|
-
rubocop (= 0.36.0)
|
97
|
-
|
98
|
-
BUNDLED WITH
|
99
|
-
1.11.2
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.0.3
|
data/bootstrap_builders.gemspec
DELETED
@@ -1,76 +0,0 @@
|
|
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.3 ruby lib
|
6
|
-
|
7
|
-
Gem::Specification.new do |s|
|
8
|
-
s.name = "bootstrap_builders"
|
9
|
-
s.version = "0.0.3"
|
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-21"
|
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
|
-
"bootstrap_builders.gemspec",
|
32
|
-
"lib/bootstrap_builders.rb",
|
33
|
-
"lib/bootstrap_builders/application_helpers.rb",
|
34
|
-
"lib/bootstrap_builders/box.rb",
|
35
|
-
"lib/bootstrap_builders/button.rb",
|
36
|
-
"spec/bootstrap_helpers/box_spec.rb",
|
37
|
-
"spec/bootstrap_helpers/button_spec.rb",
|
38
|
-
"spec/spec_helper.rb",
|
39
|
-
"spec/support/working_helpers.rb"
|
40
|
-
]
|
41
|
-
s.homepage = "http://github.com/kaspernj/bootstrap_builders"
|
42
|
-
s.licenses = ["MIT"]
|
43
|
-
s.rubygems_version = "2.4.0"
|
44
|
-
s.summary = "A library to generate Bootstrap HTML for Rails."
|
45
|
-
|
46
|
-
if s.respond_to? :specification_version then
|
47
|
-
s.specification_version = 4
|
48
|
-
|
49
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
50
|
-
s.add_runtime_dependency(%q<html_gen>, [">= 0.0.11"])
|
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.11"])
|
59
|
-
s.add_dependency(%q<rspec>, ["~> 3.4.0"])
|
60
|
-
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
61
|
-
s.add_dependency(%q<bundler>, ["~> 1.0"])
|
62
|
-
s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
|
63
|
-
s.add_dependency(%q<best_practice_project>, [">= 0"])
|
64
|
-
s.add_dependency(%q<rubocop>, ["= 0.36.0"])
|
65
|
-
end
|
66
|
-
else
|
67
|
-
s.add_dependency(%q<html_gen>, [">= 0.0.11"])
|
68
|
-
s.add_dependency(%q<rspec>, ["~> 3.4.0"])
|
69
|
-
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
70
|
-
s.add_dependency(%q<bundler>, ["~> 1.0"])
|
71
|
-
s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
|
72
|
-
s.add_dependency(%q<best_practice_project>, [">= 0"])
|
73
|
-
s.add_dependency(%q<rubocop>, ["= 0.36.0"])
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
@@ -1,55 +0,0 @@
|
|
1
|
-
module ApplicationHelpers
|
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, context: self)).html
|
16
|
-
end
|
17
|
-
|
18
|
-
def bs_edit_button(args)
|
19
|
-
args[:label] = t("edit") unless args.key?(:label)
|
20
|
-
BootstrapBuilders::Button.new(args.merge(icon: "wrench", context: self, can_type: :edit)).html
|
21
|
-
end
|
22
|
-
|
23
|
-
def bs_destroy_button(args)
|
24
|
-
args[:label] = t("delete") unless args.key?(:label)
|
25
|
-
|
26
|
-
args[:data] ||= {}
|
27
|
-
args[:data][:confirm] ||= t("are_you_sure")
|
28
|
-
|
29
|
-
button = BootstrapBuilders::Button.new(args.merge(icon: "remove", context: self, can_type: :destroy, method: :delete))
|
30
|
-
button.classes << "btn-danger"
|
31
|
-
button.html
|
32
|
-
end
|
33
|
-
|
34
|
-
def bs_new_button(args)
|
35
|
-
args[:label] = t("add_new") unless args.key?(:label)
|
36
|
-
BootstrapBuilders::Button.new(args.merge(icon: "pencil", context: self, can_type: :new)).html
|
37
|
-
end
|
38
|
-
|
39
|
-
def bs_show_button(args)
|
40
|
-
args[:label] = t("show") unless args.key?(:label)
|
41
|
-
BootstrapBuilders::Button.new(args.merge(icon: "zoom-in", context: self, can_type: :show)).html
|
42
|
-
end
|
43
|
-
|
44
|
-
def bs_table(args = {}, &blk)
|
45
|
-
classes = ["table", "table-bordered", "table-striped", "table-hover"]
|
46
|
-
|
47
|
-
if args[:class].is_a?(String)
|
48
|
-
classes += args.fetch(:class).split(/\s+/)
|
49
|
-
elsif args[:class].is_a?(Array)
|
50
|
-
classes += args.fetch(:class)
|
51
|
-
end
|
52
|
-
|
53
|
-
content_tag(:table, class: classes, &blk)
|
54
|
-
end
|
55
|
-
end
|
@@ -1,66 +0,0 @@
|
|
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
|
-
@context = args.fetch(:context)
|
9
|
-
@class = args[:class]
|
10
|
-
@data = args[:data]
|
11
|
-
|
12
|
-
if @width.is_a?(Fixnum) || @width.is_a?(Integer)
|
13
|
-
@width = "#{@width}px"
|
14
|
-
else
|
15
|
-
@width = "100%"
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
def html
|
20
|
-
@panel = HtmlGen::Element.new(:div, inden: " ", classes: container_classes, css: {width: @width}, data: @data)
|
21
|
-
|
22
|
-
add_heading if @title || @right
|
23
|
-
|
24
|
-
if @table
|
25
|
-
add_table
|
26
|
-
else
|
27
|
-
add_body
|
28
|
-
end
|
29
|
-
|
30
|
-
html = @panel.html
|
31
|
-
|
32
|
-
if html.respond_to?(:html_safe)
|
33
|
-
html.html_safe
|
34
|
-
else
|
35
|
-
html
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
private
|
40
|
-
|
41
|
-
def add_heading
|
42
|
-
heading = @panel.add_ele(:div, classes: ["panel-heading", "clearfix"])
|
43
|
-
heading.add_ele(:div, classes: ["panel-title", "pull-left"], str: @title)
|
44
|
-
heading.add_ele(:div, classes: ["pull-right"], str_html: @right.to_s) if @right
|
45
|
-
end
|
46
|
-
|
47
|
-
def add_table
|
48
|
-
@panel.add_html(@context.content_tag(:table, nil, class: ["table", "table-striped", "table-hover"], &@block))
|
49
|
-
end
|
50
|
-
|
51
|
-
def add_body
|
52
|
-
@panel.add_html(@context.content_tag(:div, nil, class: ["panel-body"], &@block))
|
53
|
-
end
|
54
|
-
|
55
|
-
def container_classes
|
56
|
-
classes = ["panel", "panel-default"]
|
57
|
-
|
58
|
-
if @class.is_a?(String)
|
59
|
-
classes += @class.split(/\s+/)
|
60
|
-
elsif @class.is_a?(Array)
|
61
|
-
classes += @class
|
62
|
-
end
|
63
|
-
|
64
|
-
classes
|
65
|
-
end
|
66
|
-
end
|
@@ -1,17 +0,0 @@
|
|
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
|
@@ -1,12 +0,0 @@
|
|
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 fa-wrench"
|
11
|
-
end
|
12
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,12 +0,0 @@
|
|
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
|
@@ -1,39 +0,0 @@
|
|
1
|
-
module WorkingHelpers
|
2
|
-
include BootstrapBuilders::ApplicationHelpers
|
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
|