bootstrap_builders 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/Gemfile.lock +2 -2
- data/VERSION +1 -1
- data/{bootstrap_helpers.gemspec → bootstrap_builders.gemspec} +9 -8
- data/lib/{bootstrap_helpers.rb → bootstrap_builders.rb} +0 -0
- data/lib/{bootstrap_helpers/helpers.rb → bootstrap_builders/application_helpers.rb} +8 -9
- data/lib/{bootstrap_helpers → bootstrap_builders}/box.rb +10 -5
- data/lib/bootstrap_builders/button.rb +63 -0
- data/spec/bootstrap_helpers/button_spec.rb +1 -1
- data/spec/support/working_helpers.rb +1 -1
- metadata +8 -8
- data/lib/bootstrap_helpers/button.rb +0 -41
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1576e39d9ed78b4073ffe113990c3cefd7194f26
|
4
|
+
data.tar.gz: f0797a630cac750ce9ff5d3f272b98fc560fe4e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 09840ce0caaba4c24fd594442e2a07af223eae29f88faf969f188b804b2e68be2faf6b7e37436dc36f07807c7787ffbff8c8a8e55a9fd5429ed06334826b44f8
|
7
|
+
data.tar.gz: e018461fbad769c278cd78f2455d470591c639439d63c99607eddf0937eb61c32f7d42dba154f233f6f416f224f558dee408eb48240d012d5cf8ccc54cbc4318
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -28,7 +28,7 @@ GEM
|
|
28
28
|
oauth2
|
29
29
|
hashie (3.4.3)
|
30
30
|
highline (1.7.8)
|
31
|
-
html_gen (0.0.
|
31
|
+
html_gen (0.0.7)
|
32
32
|
string-cases
|
33
33
|
jeweler (2.0.1)
|
34
34
|
builder
|
@@ -90,7 +90,7 @@ DEPENDENCIES
|
|
90
90
|
auto_autoloader (>= 0.0.4)
|
91
91
|
best_practice_project!
|
92
92
|
bundler (~> 1.0)
|
93
|
-
html_gen (>= 0.0.
|
93
|
+
html_gen (>= 0.0.7)
|
94
94
|
jeweler (~> 2.0.1)
|
95
95
|
rdoc (~> 3.12)
|
96
96
|
rspec (~> 3.4.0)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.2
|
@@ -2,11 +2,11 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: bootstrap_builders 0.0.
|
5
|
+
# stub: bootstrap_builders 0.0.2 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "bootstrap_builders"
|
9
|
-
s.version = "0.0.
|
9
|
+
s.version = "0.0.2"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
@@ -28,12 +28,13 @@ Gem::Specification.new do |s|
|
|
28
28
|
"README.md",
|
29
29
|
"Rakefile",
|
30
30
|
"VERSION",
|
31
|
+
"bootstrap_builders.gemspec",
|
31
32
|
"lib/bootstrap_builders.rb",
|
33
|
+
"lib/bootstrap_builders/application_helpers.rb",
|
32
34
|
"lib/bootstrap_builders/box.rb",
|
33
35
|
"lib/bootstrap_builders/button.rb",
|
34
|
-
"
|
35
|
-
"spec/
|
36
|
-
"spec/bootstrap_builders/button_spec.rb",
|
36
|
+
"spec/bootstrap_helpers/box_spec.rb",
|
37
|
+
"spec/bootstrap_helpers/button_spec.rb",
|
37
38
|
"spec/spec_helper.rb",
|
38
39
|
"spec/support/working_helpers.rb"
|
39
40
|
]
|
@@ -46,7 +47,7 @@ Gem::Specification.new do |s|
|
|
46
47
|
s.specification_version = 4
|
47
48
|
|
48
49
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
49
|
-
s.add_runtime_dependency(%q<html_gen>, [">= 0.0.
|
50
|
+
s.add_runtime_dependency(%q<html_gen>, [">= 0.0.7"])
|
50
51
|
s.add_runtime_dependency(%q<auto_autoloader>, [">= 0.0.4"])
|
51
52
|
s.add_development_dependency(%q<rspec>, ["~> 3.4.0"])
|
52
53
|
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
@@ -55,7 +56,7 @@ Gem::Specification.new do |s|
|
|
55
56
|
s.add_development_dependency(%q<best_practice_project>, [">= 0"])
|
56
57
|
s.add_development_dependency(%q<rubocop>, ["= 0.36.0"])
|
57
58
|
else
|
58
|
-
s.add_dependency(%q<html_gen>, [">= 0.0.
|
59
|
+
s.add_dependency(%q<html_gen>, [">= 0.0.7"])
|
59
60
|
s.add_dependency(%q<auto_autoloader>, [">= 0.0.4"])
|
60
61
|
s.add_dependency(%q<rspec>, ["~> 3.4.0"])
|
61
62
|
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
@@ -65,7 +66,7 @@ Gem::Specification.new do |s|
|
|
65
66
|
s.add_dependency(%q<rubocop>, ["= 0.36.0"])
|
66
67
|
end
|
67
68
|
else
|
68
|
-
s.add_dependency(%q<html_gen>, [">= 0.0.
|
69
|
+
s.add_dependency(%q<html_gen>, [">= 0.0.7"])
|
69
70
|
s.add_dependency(%q<auto_autoloader>, [">= 0.0.4"])
|
70
71
|
s.add_dependency(%q<rspec>, ["~> 3.4.0"])
|
71
72
|
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
File without changes
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module
|
1
|
+
module ApplicationHelpers
|
2
2
|
def bs_box(*opts, &blk)
|
3
3
|
title = opts.shift unless opts.first.is_a?(Hash)
|
4
4
|
width = opts.shift unless opts.first.is_a?(Hash)
|
@@ -12,28 +12,27 @@ module Helpers
|
|
12
12
|
args = {}
|
13
13
|
end
|
14
14
|
|
15
|
-
BootstrapBuilders::Box.new(args.merge(title: title, width: width, right: right, block: blk)).html
|
15
|
+
BootstrapBuilders::Box.new(args.merge(title: title, width: width, right: right, block: blk, context: self)).html
|
16
16
|
end
|
17
17
|
|
18
18
|
def bs_edit_button(args)
|
19
|
-
BootstrapBuilders::Button.new(args.merge(title: t("edit"), icon: "wrench", context: self)).html
|
19
|
+
BootstrapBuilders::Button.new(args.merge(title: t("edit"), icon: "wrench", context: self, can_type: :edit)).html
|
20
20
|
end
|
21
21
|
|
22
22
|
def bs_destroy_button(args)
|
23
|
-
args[:class] ||= []
|
24
|
-
args[:class] << "btn-danger"
|
25
|
-
|
26
23
|
args[:data] ||= {}
|
27
24
|
args[:data][:confirm] ||= t("are_you_sure")
|
28
25
|
|
29
|
-
BootstrapBuilders::Button.new(args.merge(title: t("delete"), icon: "remove", context: self, method: :delete))
|
26
|
+
button = BootstrapBuilders::Button.new(args.merge(title: t("delete"), icon: "remove", context: self, can_type: :destroy, method: :delete))
|
27
|
+
button.classes << "btn-danger"
|
28
|
+
button.html
|
30
29
|
end
|
31
30
|
|
32
31
|
def bs_new_button(args)
|
33
|
-
BootstrapBuilders::Button.new(args.merge(title: t("add_new"), icon: "pencil", context: self)).html
|
32
|
+
BootstrapBuilders::Button.new(args.merge(title: t("add_new"), icon: "pencil", context: self, can_type: :new)).html
|
34
33
|
end
|
35
34
|
|
36
35
|
def bs_show_button(args)
|
37
|
-
BootstrapBuilders::Button.new(args.merge(title: t("show"), icon: "zoom-in", context: self)).html
|
36
|
+
BootstrapBuilders::Button.new(args.merge(title: t("show"), icon: "zoom-in", context: self, can_type: :show)).html
|
38
37
|
end
|
39
38
|
end
|
@@ -5,12 +5,17 @@ class BootstrapBuilders::Box
|
|
5
5
|
@right = args[:right]
|
6
6
|
@table = args[:table]
|
7
7
|
@block = args.fetch(:block)
|
8
|
+
@context = args.fetch(:context)
|
8
9
|
|
9
|
-
|
10
|
+
if @width.is_a?(Fixnum) || @width.is_a?(Integer)
|
11
|
+
@width = "#{@width}px"
|
12
|
+
else
|
13
|
+
@width = "100%"
|
14
|
+
end
|
10
15
|
end
|
11
16
|
|
12
17
|
def html
|
13
|
-
@panel = HtmlGen::Element.new(:div, classes: ["panel", "panel-default"], css: {width: @width})
|
18
|
+
@panel = HtmlGen::Element.new(:div, inden: " ", classes: ["panel", "panel-default"], css: {width: @width})
|
14
19
|
|
15
20
|
add_heading if @title || @right
|
16
21
|
|
@@ -34,14 +39,14 @@ private
|
|
34
39
|
def add_heading
|
35
40
|
heading = @panel.add_ele(:div, classes: ["panel-heading", "clearfix"])
|
36
41
|
title = heading.add_ele(:div, classes: ["panel-title", "pull-left"], str: @title)
|
37
|
-
|
42
|
+
heading.add_ele(:div, classes: ["pull-right"], str_html: @right.to_s) if @right
|
38
43
|
end
|
39
44
|
|
40
45
|
def add_table
|
41
|
-
@panel.
|
46
|
+
@panel.add_html(@context.content_tag(:table, nil, class: ["table", "table-striped", "table-hover"], &@block))
|
42
47
|
end
|
43
48
|
|
44
49
|
def add_body
|
45
|
-
@panel.
|
50
|
+
@panel.add_html(@context.content_tag(:div, nil, class: ["panel-body"], &@block))
|
46
51
|
end
|
47
52
|
end
|
@@ -0,0 +1,63 @@
|
|
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
|
+
can = args[:can]
|
11
|
+
end
|
12
|
+
|
13
|
+
def classes
|
14
|
+
unless @classes
|
15
|
+
@classes = ["btn", "btn-default"]
|
16
|
+
@classes << "btn-xs" if @mini
|
17
|
+
|
18
|
+
if @class.is_a?(String)
|
19
|
+
@classes += @class.split(/\s+/)
|
20
|
+
elsif @class.is_a?(Array)
|
21
|
+
@classes += @class
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
@classes
|
26
|
+
end
|
27
|
+
|
28
|
+
def html
|
29
|
+
return unless can?
|
30
|
+
|
31
|
+
@context.link_to @url, class: classes, data: @args[:data], method: @args[:method], remote: @args[:remote] do
|
32
|
+
html = ""
|
33
|
+
html << @context.content_tag(:i, nil, class: ["fa", "fa-#{@icon}"])
|
34
|
+
html << " #{@title}"
|
35
|
+
html.html_safe
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def model_from_url(url)
|
42
|
+
if url.is_a?(Array) && url.last.is_a?(ActiveRecord::Base)
|
43
|
+
url.last
|
44
|
+
elsif url.is_a?(ActiveRecord::Base)
|
45
|
+
url
|
46
|
+
else
|
47
|
+
return nil
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def can?
|
52
|
+
return true if !can_object || !@args[:can_type]
|
53
|
+
@context.can? @args.fetch(:can_type), can_object
|
54
|
+
end
|
55
|
+
|
56
|
+
def can_object
|
57
|
+
if @args[:can]
|
58
|
+
@args[:can]
|
59
|
+
elsif @args[:url].is_a?(Array) && @args[:url].last.is_a?(ActiveRecord::Base)
|
60
|
+
@args[:url].last
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bootstrap_builders
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kaspernj
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.0.
|
19
|
+
version: 0.0.7
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.0.
|
26
|
+
version: 0.0.7
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: auto_autoloader
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -139,11 +139,11 @@ files:
|
|
139
139
|
- README.md
|
140
140
|
- Rakefile
|
141
141
|
- VERSION
|
142
|
-
-
|
143
|
-
- lib/
|
144
|
-
- lib/
|
145
|
-
- lib/
|
146
|
-
- lib/
|
142
|
+
- bootstrap_builders.gemspec
|
143
|
+
- lib/bootstrap_builders.rb
|
144
|
+
- lib/bootstrap_builders/application_helpers.rb
|
145
|
+
- lib/bootstrap_builders/box.rb
|
146
|
+
- lib/bootstrap_builders/button.rb
|
147
147
|
- spec/bootstrap_helpers/box_spec.rb
|
148
148
|
- spec/bootstrap_helpers/button_spec.rb
|
149
149
|
- spec/spec_helper.rb
|
@@ -1,41 +0,0 @@
|
|
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
|