bmc 1.1.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/app/helpers/bmc/bootstrap_helper.rb +1 -1
- data/app/helpers/bmc/button_helper.rb +1 -1
- data/app/helpers/bmc/font_awesome_helper.rb +14 -53
- data/app/helpers/bmc/form_helper.rb +1 -1
- data/app/helpers/bmc/link_helper.rb +1 -1
- data/app/helpers/bmc/text_helper.rb +3 -3
- data/app/views/bmc/search/_form_bs3.html.slim +2 -2
- data/app/views/bmc/search/_form_bs4.html.slim +2 -2
- data/app/views/bmc/search/_form_bs5.html.slim +2 -2
- data/lib/bmc/engine.rb +0 -1
- data/lib/bmc/version.rb +1 -1
- metadata +4 -6
- data/app/libs/bmc/fcm/notifier.rb +0 -32
- data/app/libs/bmc/fcm/request.rb +0 -54
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8059c6df5d1948303e20ec0771f1d379880a9c9a771d7c92b27432bce595f4c6
|
4
|
+
data.tar.gz: 6497a08bed10f80364780ee870aafe69e6bbc4ff8cff232ac74da63715d7c99c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf4d0096587ce7ebaefbead1b4c1fbd527cd4a97ae9c36f7d9db90d9042e9142932b7e090234d2184387c6d6ed2dd9a8df731a7f638090720f101b813b05c412
|
7
|
+
data.tar.gz: 2955d4e545a15c05216d45cfed14be03a209288abb80ec3798cbf5218e3f76a81ef7a4e34fe1b17a4dd85e14d8049cbb1ecb8620b19dc3fdb60d658ee42432b6
|
data/CHANGELOG.md
CHANGED
@@ -26,7 +26,7 @@ module BMC::ButtonHelper
|
|
26
26
|
)
|
27
27
|
text = ta(action) if text.nil? && action
|
28
28
|
|
29
|
-
content =
|
29
|
+
content = fa_s(icon).concat(" ").concat(tag.span(text, class: "text"))
|
30
30
|
|
31
31
|
if method != :get
|
32
32
|
options[:method] = method
|
@@ -1,15 +1,23 @@
|
|
1
1
|
module BMC::FontAwesomeHelper
|
2
|
-
def
|
3
|
-
id
|
2
|
+
def fa_s(id, **options)
|
3
|
+
_bmc_fa_icon(id, fa_style: "fas", **options)
|
4
|
+
end
|
4
5
|
|
5
|
-
|
6
|
-
|
7
|
-
|
6
|
+
def fa_r(id, **options)
|
7
|
+
_bmc_fa_icon(id, fa_style: "far", **options)
|
8
|
+
end
|
9
|
+
|
10
|
+
def fa_b(id, **options)
|
11
|
+
_bmc_fa_icon(id, fa_style: "fab", **options)
|
12
|
+
end
|
13
|
+
|
14
|
+
def _bmc_fa_icon(id, fa_style: nil, size: nil, spin: false, **options)
|
15
|
+
id = id.to_s.tr("_", "-").to_sym
|
8
16
|
|
9
17
|
css_classes = options.delete(:class).to_s.split
|
10
18
|
css_classes << "icon"
|
11
19
|
css_classes << "fa-#{id}"
|
12
|
-
css_classes <<
|
20
|
+
css_classes << fa_style
|
13
21
|
css_classes << "fa-#{size}" if size
|
14
22
|
css_classes << "fa-spin" if spin
|
15
23
|
|
@@ -17,51 +25,4 @@ module BMC::FontAwesomeHelper
|
|
17
25
|
|
18
26
|
tag.span(**attributes)
|
19
27
|
end
|
20
|
-
|
21
|
-
class << self
|
22
|
-
def database
|
23
|
-
@database ||= YAML.safe_load(database_yml).deep_symbolize_keys
|
24
|
-
end
|
25
|
-
|
26
|
-
def database_path
|
27
|
-
Rails.root.join("tmp", "fa_database_#{version}.yml")
|
28
|
-
end
|
29
|
-
|
30
|
-
def database_yml
|
31
|
-
download_database! unless File.size?(database_path)
|
32
|
-
File.read(database_path)
|
33
|
-
end
|
34
|
-
|
35
|
-
def database_url
|
36
|
-
short_version = version.split(".")[0, 3].join(".") # 1.20.14.2 => 1.20.14
|
37
|
-
url = "https://raw.githubusercontent.com/FortAwesome/Font-Awesome/#{short_version}/metadata/icons.yml"
|
38
|
-
|
39
|
-
if Gem::Version.new(short_version) < Gem::Version.new("5.6.0")
|
40
|
-
url = url.gsub("/metadata", "/advanced-options/metadata")
|
41
|
-
end
|
42
|
-
|
43
|
-
url
|
44
|
-
end
|
45
|
-
|
46
|
-
def download_database!
|
47
|
-
require "open-uri"
|
48
|
-
data = URI.parse(database_url).open.read
|
49
|
-
File.write(database_path, data)
|
50
|
-
end
|
51
|
-
|
52
|
-
def version
|
53
|
-
require "font_awesome/sass/version"
|
54
|
-
FontAwesome::Sass::VERSION
|
55
|
-
end
|
56
|
-
|
57
|
-
def default_fa_style_for_id(id)
|
58
|
-
return if version.start_with?("4")
|
59
|
-
|
60
|
-
if version.start_with?("5")
|
61
|
-
return BMC::FontAwesomeHelper.database.dig(id, :styles).to_a.first
|
62
|
-
end
|
63
|
-
|
64
|
-
raise "invalid font-awesome-sass version"
|
65
|
-
end
|
66
|
-
end # class << self
|
67
28
|
end
|
@@ -54,8 +54,8 @@ module BMC::TextHelper
|
|
54
54
|
def boolean_icon(bool)
|
55
55
|
return if bool.nil?
|
56
56
|
|
57
|
-
return
|
58
|
-
return
|
57
|
+
return fa_s(:check, style: "color: green") if bool == true
|
58
|
+
return fa_s(:times, style: "color: red") if bool == false
|
59
59
|
|
60
60
|
raise "#{bool} is not a boolean"
|
61
61
|
end
|
@@ -102,7 +102,7 @@ module BMC::TextHelper
|
|
102
102
|
container_css_class = ["info", ("blank" if value.blank?)]
|
103
103
|
|
104
104
|
content_tag(tag, class: container_css_class) do
|
105
|
-
[html_label, separator_html, html_value].sum
|
105
|
+
[html_label, separator_html, html_value].sum("".html_safe)
|
106
106
|
end
|
107
107
|
end # def info
|
108
108
|
|
@@ -5,5 +5,5 @@ form.search.bs4 method="get" action=action
|
|
5
5
|
.input-group.search
|
6
6
|
input.form-control.form-control-sm type="text" name="q" placeholder=ta(:search) value=params[:q]
|
7
7
|
span.input-group-append
|
8
|
-
button.btn.btn-sm.bg-light.border.search-reset.reset type="submit" =
|
9
|
-
button.btn.btn-sm.bg-light.border.search-submit type="submit" =
|
8
|
+
button.btn.btn-sm.bg-light.border.search-reset.reset type="submit" = fa_s(:times)
|
9
|
+
button.btn.btn-sm.bg-light.border.search-submit type="submit" = fa_s(:search)
|
@@ -4,5 +4,5 @@ form.search.bs5.mb-3 method="get" action=action
|
|
4
4
|
|
5
5
|
.input-group.search
|
6
6
|
input.form-control.form-control-sm type="text" name="q" placeholder=ta(:search) value=params[:q]
|
7
|
-
button.btn.btn-sm.bg-light.border.search-reset.reset type="submit" =
|
8
|
-
button.btn.btn-sm.bg-light.border.search-submit type="submit" =
|
7
|
+
button.btn.btn-sm.bg-light.border.search-reset.reset type="submit" = fa_s(:times)
|
8
|
+
button.btn.btn-sm.bg-light.border.search-submit type="submit" = fa_s(:search)
|
data/lib/bmc/engine.rb
CHANGED
data/lib/bmc/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bmc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- Benoit MARTIN-CHAVE
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-03-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails-i18n
|
@@ -150,8 +150,6 @@ files:
|
|
150
150
|
- app/jobs/bmc/application_job.rb
|
151
151
|
- app/jobs/concerns/bmc/setup_job_concern.rb
|
152
152
|
- app/libs/bmc/collection_update.rb
|
153
|
-
- app/libs/bmc/fcm/notifier.rb
|
154
|
-
- app/libs/bmc/fcm/request.rb
|
155
153
|
- app/libs/bmc/mini_model_serializer/serialize.rb
|
156
154
|
- app/libs/bmc/mini_model_serializer/serializer.rb
|
157
155
|
- app/libs/bmc/monkey.rb
|
@@ -230,7 +228,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
230
228
|
- !ruby/object:Gem::Version
|
231
229
|
version: '0'
|
232
230
|
requirements: []
|
233
|
-
rubygems_version: 3.
|
231
|
+
rubygems_version: 3.3.7
|
234
232
|
signing_key:
|
235
233
|
specification_version: 4
|
236
234
|
summary: BMC
|
@@ -1,32 +0,0 @@
|
|
1
|
-
class BMC::FCM::Notifier
|
2
|
-
attr_reader :to, :title, :body, :badge, :sound, :data
|
3
|
-
|
4
|
-
# rubocop:disable Metrics/ParameterLists
|
5
|
-
def initialize(to:, title: nil, body:, badge: 0, sound: "default", data: {})
|
6
|
-
super()
|
7
|
-
@to = to
|
8
|
-
@title = title
|
9
|
-
@body = body
|
10
|
-
@badge = badge
|
11
|
-
@sound = sound
|
12
|
-
@data = data
|
13
|
-
end
|
14
|
-
# rubocop:enable Metrics/ParameterLists
|
15
|
-
|
16
|
-
def call
|
17
|
-
BMC::FCM::Request.call(
|
18
|
-
:to => to,
|
19
|
-
:notification => {
|
20
|
-
:title => title,
|
21
|
-
:body => body,
|
22
|
-
:badge => badge,
|
23
|
-
:sound => sound,
|
24
|
-
},
|
25
|
-
:data => data,
|
26
|
-
)
|
27
|
-
end
|
28
|
-
|
29
|
-
def self.call(...)
|
30
|
-
new(...).call
|
31
|
-
end
|
32
|
-
end
|
data/app/libs/bmc/fcm/request.rb
DELETED
@@ -1,54 +0,0 @@
|
|
1
|
-
class BMC::FCM::Request
|
2
|
-
extend AttrExtras.mixin
|
3
|
-
|
4
|
-
URL = "https://fcm.googleapis.com/fcm/send"
|
5
|
-
|
6
|
-
class << self
|
7
|
-
attr_writer :api_key
|
8
|
-
|
9
|
-
def api_key
|
10
|
-
@api_key ||= ENV["FCM_API_KEY"]
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
attr_reader_initialize :request_body
|
15
|
-
|
16
|
-
attr_reader :response_json
|
17
|
-
|
18
|
-
def self.call(...)
|
19
|
-
new(...).call
|
20
|
-
end
|
21
|
-
|
22
|
-
def call
|
23
|
-
response_body = HTTParty.post(URL,
|
24
|
-
:body => request_body.to_json,
|
25
|
-
:headers => {
|
26
|
-
"Content-Type" => "application/json",
|
27
|
-
"Authorization" => "key=#{self.class.api_key}",
|
28
|
-
},
|
29
|
-
).body
|
30
|
-
|
31
|
-
@response_json = JSON.parse(response_body).deep_symbolize_keys
|
32
|
-
|
33
|
-
self
|
34
|
-
rescue JSON::ParserError
|
35
|
-
@response_json = {success: 0, failure: 1, results: [{:error => "InvalidJsonResponse"}]}
|
36
|
-
self
|
37
|
-
end
|
38
|
-
|
39
|
-
def ok?
|
40
|
-
response_json[:success].positive? && response_json[:failure].zero?
|
41
|
-
end
|
42
|
-
|
43
|
-
def error?
|
44
|
-
!ok?
|
45
|
-
end
|
46
|
-
|
47
|
-
def errors
|
48
|
-
response_json[:results].pluck(:error).compact
|
49
|
-
end
|
50
|
-
|
51
|
-
def invalid_token?
|
52
|
-
errors.include?("NotRegistered") || errors.include?("InvalidRegistration")
|
53
|
-
end
|
54
|
-
end
|