checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
---
2
2
SHA256:
3
- metadata.gz: 5c12899fd207f2f1598ba96d7236d4dceabd6dcfba0f250b24c3117121e73e51
4
- data.tar.gz: bb76c0c9eb2fb6d88567349780c828c1bba27630269288457d47e6e3d54a195b
3
+ metadata.gz: 071f0d4d2b5797121ee7f9cd444302a2fbb0e66de5c252815753b35a019c06ac
4
+ data.tar.gz: 7590349f4df19e38946d2a69308cadd067873f495e777c7205ed2fbbc58af342
5
5
SHA512:
6
- metadata.gz: ec464cd8675ceaa72f6072933620158bdf1716e3686ef2cf0a866109e6b5950ba1fd8cd9b94d9329be2c593898256c8e4f9f64a0c55cb4d8c39090a9dd18b339
7
- data.tar.gz: 2e5f10e3f3e40599d48c0762312cebd5303f19f705dcc6a8a7ba600715dcfc294c92e4d1efdd45581474b15bcee235c57709340479ce561aa88d1db60573caad
6
+ metadata.gz: ea78a849edb4043510de9d4e60897991cf9c7dbfdf29a9447e2baca60e92c6e52e870208dc6cf8256543debf1fb55f07fe11fd68f2406c93f925274836df63b7
7
+ data.tar.gz: ce6d6fe0bdd409d1003b9a6cc676ac09a9795a69579d30f7de83adbc6287869db7fe489ee764e3004ef31d42686a06fd10b0c2ef22363d1f64c0f4052913459c
data/CHANGELOG.md CHANGED
@@ -2,6 +2,31 @@
2
2
3
3
## Next version
4
4
5
+ ## 1.6.1
6
+ - Add `SetupJobConcern`
7
+
8
+ ## 1.6.0
9
+ - Remove `GetHTTP`
10
+ - I18n fixes
11
+ - Add `Agilibox::TapMethods`
12
+ - Filters CSS : add flex-wrap
13
+ - Add `bs_card` helper
14
+ - Add `:br` separator to `info` helper
15
+ - TextHelper refactors
16
+ - Update dummy app to Rails 5.2
17
+ - Replace AXLSX by SpreadsheetArchitect
18
+
19
+ ## 1.5.13
20
+ - Fix `info` helper with nested blank value
21
+
22
+ ## 1.5.12
23
+ - Cuprite config improvements
24
+
25
+ ## 1.5.11
26
+ - Add `nbsp` helper
27
+ - Add `PluckDistinct` model concern
28
+ - Add pagination helpers
29
+
5
30
## 1.5.10
6
31
- Cucumber Helpers : add cuprite support
7
32
data/app/assets/stylesheets/agilibox/filters.sass CHANGED
@@ -6,6 +6,7 @@
6
6
padding: 8px
7
7
box-shadow: none
8
8
display: flex
9
+ flex-wrap: wrap
9
10
flex-direction: initial
10
11
background: #F0F0F0
11
12
data/app/helpers/agilibox/bootstrap_helper.rb CHANGED
@@ -1,4 +1,19 @@
1
1
module Agilibox::BootstrapHelper
2
+ class << self
3
+ attr_writer :card_classes
4
+
5
+ # rubocop:disable Rails/HelperInstanceVariable
6
+ def card_classes
7
+ @card_classes ||= {
8
+ :card => "card",
9
+ :header => "card-header",
10
+ :body => "card-body",
11
+ :footer => "card-footer",
12
+ }
13
+ end
14
+ # rubocop:enable Rails/HelperInstanceVariable
15
+ end
16
+
2
17
def bs_progress_bar(percentage)
3
18
content_tag(:div, class: "progress") do
4
19
content_tag(:div, class: "progress-bar", style: "width:#{percentage}%") do
@@ -6,4 +21,47 @@ module Agilibox::BootstrapHelper
6
21
end
7
22
end
8
23
end
24
+
25
+ def bs_card( # rubocop:disable Metrics/ParameterLists
26
+ header: nil,
27
+ body: true,
28
+ footer: nil,
29
+ card_tag: :div,
30
+ header_tag: :div,
31
+ body_tag: :div,
32
+ footer_tag: :div,
33
+ card_class: nil,
34
+ header_class: nil,
35
+ body_class: nil,
36
+ footer_class: nil,
37
+ &block
38
+ )
39
+ global_classes = Agilibox::BootstrapHelper.card_classes
40
+ card_classes = ([global_classes[:card]] + card_class.to_s.split(" ")).compact.sort
41
+ header_classes = ([global_classes[:header]] + header_class.to_s.split(" ")).compact.sort
42
+ body_classes = ([global_classes[:body]] + body_class.to_s.split(" ")).compact.sort
43
+ footer_classes = ([global_classes[:footer]] + footer_class.to_s.split(" ")).compact.sort
44
+
45
+ if header
46
+ header_html = content_tag(header_tag, class: header_classes) { header }
47
+ else
48
+ header_html = "".html_safe
49
+ end
50
+
51
+ if body
52
+ body_html = content_tag(body_tag, class: body_classes) { capture(&block) }
53
+ else
54
+ body_html = capture(&block)
55
+ end
56
+
57
+ if footer
58
+ footer_html = content_tag(footer_tag, class: footer_classes) { footer }
59
+ else
60
+ footer_html = "".html_safe
61
+ end
62
+
63
+ content_tag(card_tag, class: card_classes) do
64
+ header_html + body_html + footer_html
65
+ end
66
+ end
9
67
end
data/app/helpers/agilibox/font_awesome_helper.rb CHANGED
@@ -19,9 +19,11 @@ module Agilibox::FontAwesomeHelper
19
19
end
20
20
21
21
class << self
22
+ # rubocop:disable Rails/HelperInstanceVariable
22
23
def database
23
24
@database ||= YAML.safe_load(database_yml).deep_symbolize_keys
24
25
end
26
+ # rubocop:enable Rails/HelperInstanceVariable
25
27
26
28
def database_path
27
29
Rails.root.join("tmp", "fa_database_#{version}.yml")
data/app/helpers/agilibox/pagination_helper.rb CHANGED
@@ -3,4 +3,12 @@ module Agilibox::PaginationHelper
3
3
options = {theme: "twitter-bootstrap-3"}.merge(options)
4
4
super(objects, options).gsub(/>(\s+)</, "><").html_safe
5
5
end
6
+
7
+ def pagination_infos(collection)
8
+ content_tag(:p, class: "pagination-infos") { page_entries_info(collection) }
9
+ end
10
+
11
+ def pagination_and_infos(collection)
12
+ paginate(collection) + pagination_infos(collection)
13
+ end
6
14
end
data/app/helpers/agilibox/text_helper.rb CHANGED
@@ -3,6 +3,14 @@ module Agilibox::TextHelper
3
3
include ::ActionView::Helpers::SanitizeHelper
4
4
include ::ActionView::Helpers::TextHelper
5
5
6
+ def nbsp(text = :no_argument)
7
+ if text == :no_argument
8
+ "\u00A0"
9
+ else
10
+ text.to_s.gsub(" ", nbsp)
11
+ end
12
+ end
13
+
6
14
def euros(n)
7
15
currency(n, "€")
8
16
end
@@ -13,13 +21,13 @@ module Agilibox::TextHelper
13
21
I18n.t("number.currency.format.format")
14
22
.gsub("%n", number(n))
15
23
.gsub("%u", u)
16
- .tr(" ", "\u00A0")
24
+ .tr(" ", nbsp)
17
25
end
18
26
19
27
def percentage(n)
20
28
return if n.nil?
21
29
22
- (number(n) + " %").tr(" ", "\u00A0")
30
+ number(n) + nbsp + "%"
23
31
end
24
32
25
33
def number(n)
@@ -36,7 +44,7 @@ module Agilibox::TextHelper
36
44
opts[:delimiter] = I18n.t("number.format.delimiter")
37
45
opts[:separator] = I18n.t("number.format.separator")
38
46
39
- number_with_precision(n, opts).tr(" ", "\u00A0")
47
+ number_with_precision(n, opts).tr(" ", nbsp)
40
48
end
41
49
42
50
def date(d, *args)
@@ -93,19 +101,20 @@ module Agilibox::TextHelper
93
101
label = options[:label] || object.t(attribute)
94
102
tag = options[:tag] || :div
95
103
separator = options[:separator] || " : "
104
+ separator = " :<br/>".html_safe if separator == :br
96
105
helper = options[:helper]
97
106
i18n_key = "#{object.class.to_s.tableize.singularize}/#{attribute}"
98
107
nested = I18n.t("activerecord.attributes.#{i18n_key}", default: "").is_a?(Hash)
99
108
klass = object.is_a?(Module) ? object : object.class
100
109
object_type = klass.to_s.split("::").last.underscore
101
110
102
- value = t("yes") if value == true
103
- value = t("no") if value == false
104
- value = object.t("#{attribute}.#{value}") if nested
105
- value = send(helper, value) if helper
106
- value = number(value) if value.is_a?(Numeric)
107
- value = l(value) if value.is_a?(Time)
108
- value = l(value) if value.is_a?(Date)
111
+ value = t("yes") if value == true
112
+ value = t("no") if value == false
113
+ value = object.tv(attribute) if nested
114
+ value = send(helper, value) if helper
115
+ value = number(value) if value.is_a?(Numeric)
116
+ value = l(value) if value.is_a?(Time)
117
+ value = l(value) if value.is_a?(Date)
109
118
value = value.to_s
110
119
111
120
html_label = content_tag(:strong, class: "info-label") { label }
data/app/jobs/concerns/agilibox/setup_job_concern.rb ADDED
@@ -0,0 +1,35 @@
1
+ module Agilibox::SetupJobConcern
2
+ extend ActiveSupport::Concern
3
+
4
+ def perform(*args)
5
+ setup(*args)
6
+ call
7
+ end
8
+
9
+ def call
10
+ raise NotImplementedError
11
+ end
12
+
13
+ class_methods do
14
+ def setup_with(*attrs)
15
+ attr_reader(*attrs)
16
+
17
+ define_method(:setup) do |*args|
18
+ if attrs.length != args.length
19
+ message = "wrong number of arguments (given #{args.length}, expected #{attrs.length})"
20
+ raise ArgumentError, message
21
+ end
22
+
23
+ attrs.length.times do |i|
24
+ instance_variable_set("@#{attrs[i]}", args[i])
25
+ end
26
+ end
27
+ end
28
+
29
+ private :setup_with
30
+
31
+ def setup(*args)
32
+ new.tap { |instance| instance.setup(*args) }
33
+ end
34
+ end # class_methods
35
+ end
data/app/libs/agilibox/get_http.rb DELETED
@@ -1,55 +0,0 @@
1
- class Agilibox::GetHTTP < Agilibox::Service
2
- class Error < StandardError
3
- end
4
-
5
- EXCEPTIONS_TO_RERAISE = [
6
- IOError,
7
- Net::HTTPBadResponse,
8
- Net::HTTPExceptions,
9
- Net::HTTPHeaderSyntaxError,
10
- OpenSSL::SSL::SSLError,
11
- SocketError,
12
- SystemCallError,
13
- Timeout::Error,
14
- Zlib::Error,
15
- ]
16
-
17
- TIMEOUT = 10
18
-
19
- initialize_with :url
20
-
21
- def uri
22
- uri = URI(url.to_s)
23
- raise Error, "invalid URI type : #{uri.class}" unless uri.is_a?(URI::HTTP)
24
- uri
25
- end
26
-
27
- def response
28
- @response ||= fetch_response
29
- end
30
-
31
- def call
32
- response.body
33
- end
34
-
35
- private
36
-
37
- def fetch_response
38
- http_response = Timeout.timeout(TIMEOUT) do
39
- Net::HTTP.get_response(uri)
40
- end
41
-
42
- if http_response.code.start_with?("3")
43
- @url = http_response["Location"]
44
- return fetch_response
45
- end
46
-
47
- unless http_response.code.start_with?("2")
48
- raise Error, "invalid response code : #{http_response.code}"
49
- end
50
-
51
- http_response
52
- rescue *EXCEPTIONS_TO_RERAISE => e
53
- raise Error, e.message
54
- end
55
- end
data/app/models/concerns/agilibox/pluck_distinct.rb ADDED
@@ -0,0 +1,13 @@
1
+ module Agilibox::PluckDistinct
2
+ extend ActiveSupport::Concern
3
+
4
+ class_methods do
5
+ def pluck_distinct(column)
6
+ all
7
+ .reorder(column)
8
+ .select(column)
9
+ .distinct
10
+ .pluck(column)
11
+ end
12
+ end # class_methods
13
+ end
data/app/models/concerns/agilibox/tap_methods.rb ADDED
@@ -0,0 +1,23 @@
1
+ module Agilibox::TapMethods
2
+ extend ActiveSupport::Concern
3
+
4
+ def tap_save!(options = {})
5
+ save!(options)
6
+ self
7
+ end
8
+
9
+ def tap_update!(attributes)
10
+ update!(attributes)
11
+ self
12
+ end
13
+
14
+ def tap_validate(context = nil)
15
+ validate(context)
16
+ self
17
+ end
18
+
19
+ def tap_validate!(context = nil)
20
+ validate!(context)
21
+ self
22
+ end
23
+ end
data/app/serializers/agilibox/serializers/axlsx.rb ADDED
@@ -0,0 +1,21 @@
1
+ class Agilibox::Serializers::AXLSX < Agilibox::Serializers::Base
2
+ def render_inline
3
+ xlsx.to_stream.read.force_encoding("BINARY")
4
+ end
5
+
6
+ def render_file(file_path)
7
+ xlsx.serialize(file_path)
8
+ end
9
+
10
+ def xlsx
11
+ @xlsx ||= Axlsx::Package.new do |p|
12
+ p.workbook.add_worksheet do |sheet|
13
+ formatted_data.each do |line|
14
+ sheet.add_row(line)
15
+ end
16
+ end
17
+
18
+ p.use_shared_strings = true
19
+ end
20
+ end
21
+ end
data/app/serializers/agilibox/serializers/base.rb CHANGED
@@ -6,6 +6,12 @@ class Agilibox::Serializers::Base
6
6
@options = options
7
7
end
8
8
9
+ def formatted_data
10
+ data.map do |line|
11
+ line.map { |value| self.class.format(value) }
12
+ end
13
+ end
14
+
9
15
def render_inline
10
16
raise NotImplementedError
11
17
end
data/app/serializers/agilibox/serializers/xlsx.rb CHANGED
@@ -1,22 +1,11 @@
1
1
class Agilibox::Serializers::XLSX < Agilibox::Serializers::Base
2
2
def render_inline
3
- xlsx.to_stream.read.force_encoding("BINARY")
3
+ SpreadsheetArchitect.to_xlsx(data: formatted_data)
4
4
end
5
5
6
6
def render_file(file_path)
7
- xlsx.serialize(file_path)
8
- end
7
+ File.open(file_path, "w+b") do |f|
8
+ f.write(render_inline)
9
-
10
- def xlsx
11
- @xlsx ||= Axlsx::Package.new do |p|
12
- p.workbook.add_worksheet do |sheet|
13
- data.each do |line|
14
- values = line.map { |value| self.class.format(value) }
15
- sheet.add_row(values)
16
- end
17
- end
18
-
19
- p.use_shared_strings = true
20
9
end
21
10
end
22
11
end
data/app/views/agilibox/_flash.html.slim CHANGED
@@ -5,4 +5,5 @@
5
5
6
6
.alert class="alert-#{type}"
7
7
= message
8
- button.close data-dismiss="alert" aria-label="Fermer" = "×"
8
+ button.close data-dismiss="alert" aria-label=ta(:close) title=ta(:close)
9
+ = "×"
data/lib/agilibox/cucumber_helpers/cuprite.rb CHANGED
@@ -2,7 +2,14 @@ require "capybara/cuprite"
2
2
3
3
Capybara.register_driver :agilibox_cuprite do |app|
4
4
Capybara::Cuprite::Driver.new(app,
5
- :inspector => true,
5
+ :browser_options => {
6
+ :"disable-gpu" => true,
7
+ :"no-sandbox" => nil,
8
+ },
9
+ :headless => (ENV["CHROME_HEADLESS"].to_s != "false"),
10
+ :inspector => true,
11
+ :js_errors => true,
12
+ :process_timeout => 5,
6
13
:window_size => Agilibox::CucumberConfig.window_size,
7
14
)
8
15
end
data/lib/agilibox/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
module Agilibox
2
- VERSION = "1.5.10"
2
+ VERSION = "1.6.1"
3
3
end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
--- !ruby/object:Gem::Specification
2
2
name: agilibox
3
3
version: !ruby/object:Gem::Version
4
- version: 1.5.10
4
+ version: 1.6.1
5
5
platform: ruby
6
6
authors:
7
7
- agilidée
8
8
autorequire:
9
9
bindir: bin
10
10
cert_chain: []
11
- date: 2019-04-17 00:00:00.000000000 Z
11
+ date: 2019-09-11 00:00:00.000000000 Z
12
12
dependencies:
13
13
- !ruby/object:Gem::Dependency
14
14
name: rails-i18n
@@ -112,10 +112,10 @@ files:
112
112
- app/helpers/agilibox/sorting_helper.rb
113
113
- app/helpers/agilibox/text_helper.rb
114
114
- app/helpers/h.rb
115
+ - app/jobs/concerns/agilibox/setup_job_concern.rb
115
116
- app/libs/agilibox/collection_update.rb
116
117
- app/libs/agilibox/fcm/notifier.rb
117
118
- app/libs/agilibox/fcm/request.rb
118
- - app/libs/agilibox/get_http.rb
119
119
- app/libs/agilibox/initialize_with.rb
120
120
- app/libs/agilibox/mini_model_serializer/serialize.rb
121
121
- app/libs/agilibox/mini_model_serializer/serializer.rb
@@ -129,11 +129,14 @@ files:
129
129
- app/models/concerns/agilibox/default_values_concern.rb
130
130
- app/models/concerns/agilibox/model_i18n.rb
131
131
- app/models/concerns/agilibox/model_to_s.rb
132
+ - app/models/concerns/agilibox/pluck_distinct.rb
132
133
- app/models/concerns/agilibox/pluck_to_hash.rb
133
134
- app/models/concerns/agilibox/polymorphic_id.rb
134
135
- app/models/concerns/agilibox/search.rb
136
+ - app/models/concerns/agilibox/tap_methods.rb
135
137
- app/models/concerns/agilibox/timestamp_helpers.rb
136
138
- app/serializers/agilibox/serializers.rb
139
+ - app/serializers/agilibox/serializers/axlsx.rb
137
140
- app/serializers/agilibox/serializers/base.rb
138
141
- app/serializers/agilibox/serializers/xlsx.rb
139
142
- app/services/agilibox/service.rb