agilibox 1.0.9 → 1.0.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +11 -0
  3. data/app/controllers/agilibox/small_data/filters_controller.rb +3 -3
  4. data/app/controllers/concerns/agilibox/api_controller_concern.rb +52 -0
  5. data/app/controllers/concerns/agilibox/back_url_concern.rb +2 -2
  6. data/app/filters/agilibox/small_data/filter.rb +5 -1
  7. data/app/filters/agilibox/small_data/filter_strategy.rb +1 -1
  8. data/app/filters/agilibox/small_data/filter_strategy_by_date_begin.rb +1 -1
  9. data/app/filters/agilibox/small_data/filter_strategy_by_date_end.rb +1 -1
  10. data/app/filters/agilibox/small_data/filter_strategy_by_tags.rb +1 -1
  11. data/app/filters/agilibox/small_data/filter_strategy_by_time_period.rb +1 -1
  12. data/app/helpers/agilibox/bootstrap_helper.rb +2 -2
  13. data/app/helpers/agilibox/button_helper.rb +3 -3
  14. data/app/helpers/agilibox/filters_helper.rb +1 -2
  15. data/app/helpers/agilibox/form_helper.rb +7 -8
  16. data/app/helpers/agilibox/link_helper.rb +1 -1
  17. data/app/helpers/agilibox/pagination_helper.rb +1 -1
  18. data/app/helpers/agilibox/routes_helper.rb +1 -1
  19. data/app/helpers/agilibox/text_helper.rb +10 -11
  20. data/app/helpers/h.rb +3 -0
  21. data/app/libs/agilibox/mini_model_serializer/serialize.rb +30 -0
  22. data/app/libs/agilibox/mini_model_serializer/serializer.rb +23 -0
  23. data/app/libs/agilibox/phone_number_sanitizer.rb +16 -0
  24. data/app/libs/agilibox/token_generator.rb +37 -0
  25. data/app/models/concerns/agilibox/default_values_concern.rb +3 -2
  26. data/app/models/concerns/agilibox/model_i18n.rb +1 -2
  27. data/app/models/concerns/agilibox/polymorphic_id.rb +5 -2
  28. data/app/models/concerns/agilibox/search.rb +6 -6
  29. data/app/models/concerns/agilibox/timestamp_helpers.rb +17 -0
  30. data/app/serializers/agilibox/serializers/base.rb +1 -1
  31. data/config/locales/errors.en.yml +5 -0
  32. data/config/locales/errors.fr.yml +5 -0
  33. data/lib/agilibox/active_record_comma_type_cast.rb +1 -1
  34. data/lib/agilibox/engine.rb +3 -0
  35. data/lib/agilibox/engine_file.rb +10 -0
  36. data/lib/agilibox/version.rb +1 -1
  37. metadata +12 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 20fcca2b5201c53d3f802a6f7f15ffca3f7608cb
4
- data.tar.gz: 0a702db94cc91ee87ace2ccad257bf06515e51d7
3
+ metadata.gz: 2b31fd30195ec42898a2556ac6db48c97d1f05a7
4
+ data.tar.gz: 2582452bd5ec90baa46667ae2949e1e8d307dd69
5
5
  SHA512:
6
- metadata.gz: b18adbe0b470c0bc4eb45e19f1f3d913ef803d8fc739f0165dc14c32f3e3396713f3d8fda68321c9b15267b56f42a828eec4e52681894b8822bfc94662fa1238
7
- data.tar.gz: '09c491b370d5d5355b98f74cd4eea1ea2be2255b5fe14803eba1c0cd574152a812edb4c38a3438bb443c60d54c0f5ce727d015af37c924a0f02c000fce681d36'
6
+ metadata.gz: 0a521adc5a377d13ecf9a08c5d5f6f5bab1d2b2daceee2b43d6684fa3f185b46bc20f4f94e32e18e058ff0edc5cb6f57d360c0772fa0ac543c58461d8ea06b69
7
+ data.tar.gz: 94c11ba528b4e77db6fecfe49bb81a77d398a67ad29dcb68f4a43890ab73b3cd8efada3d1ae660878d1049c5c5782dfd0f18f2eab80a541e52ba554702688c48
data/CHANGELOG.md CHANGED
@@ -2,6 +2,17 @@
2
2
 
3
3
  ## Next version
4
4
 
5
+ ## 1.0.10
6
+
7
+ - Add TokenGenerator
8
+ - Add PhoneNumberSanitizer
9
+ - Add engine_file helper to Kernel
10
+ - Syntax improvements and refactors
11
+ - Add H alias of Agilibox::AllHelpers
12
+ - Add TimestampHelpers
13
+ - Add MiniModelSerializer
14
+ - Add ApiControllerConcern
15
+
5
16
  ## 1.0.9
6
17
 
7
18
  - Fix Model#tv
@@ -23,8 +23,9 @@ class Agilibox::SmallData::FiltersController < ::Agilibox::ApplicationController
23
23
  url = [
24
24
  params[:form_url],
25
25
  request.referer,
26
- (main_app.root_path rescue "/"),
27
- ].select(&:present?).first
26
+ main_app.try(:root_path),
27
+ "/",
28
+ ].find(&:present?)
28
29
 
29
30
  # Delete page param
30
31
  base, query_string = url.split("?")
@@ -32,5 +33,4 @@ class Agilibox::SmallData::FiltersController < ::Agilibox::ApplicationController
32
33
  query_string = "?#{query_string}" if query_string.present?
33
34
  base + query_string
34
35
  end
35
-
36
36
  end
@@ -0,0 +1,52 @@
1
+ module Agilibox::ApiControllerConcern
2
+ extend ActiveSupport::Concern
3
+
4
+ private
5
+
6
+ def render_json(json = {}, options = {})
7
+ json.reverse_merge!(current_user: current_user)
8
+ options.reverse_merge!(current_user: current_user)
9
+
10
+ json = Agilibox::MiniModelSerializer::Serialize.call(json, options)
11
+
12
+ render options.merge(json: json)
13
+ end
14
+
15
+ def render_json_error(message_or_object, options = {})
16
+ if message_or_object.is_a?(ActiveRecord::Base)
17
+ message = message_or_object.errors.full_messages.join(", ")
18
+ else
19
+ message = message_or_object
20
+ end
21
+
22
+ options[:status] ||= :unprocessable_entity
23
+
24
+ render_json({error: message}, options)
25
+ end
26
+
27
+ def render_not_found
28
+ render_json_error t("errors.not_found"), status: :not_found
29
+ end
30
+
31
+ def render_forbidden
32
+ render_json_error t("errors.forbidden"), status: :forbidden
33
+ end
34
+
35
+ def render_unauthorized
36
+ render_json_error t("errors.unauthorized"), status: :unauthorized
37
+ end
38
+
39
+ def render_forbidden_or_unauthorized
40
+ current_user ? render_unauthorized : render_forbidden
41
+ end
42
+
43
+ included do |controller|
44
+ if controller < ActionController::Rescue
45
+ if defined?(Pundit::NotAuthorizedError)
46
+ rescue_from Pundit::NotAuthorizedError, with: :render_forbidden_or_unauthorized
47
+ end
48
+
49
+ rescue_from ActiveRecord::RecordNotFound, with: :render_not_found
50
+ end
51
+ end
52
+ end
@@ -3,7 +3,8 @@ module Agilibox::BackUrlConcern
3
3
 
4
4
  private
5
5
 
6
- def default_back_url; end
6
+ def default_back_url
7
+ end
7
8
 
8
9
  def back_url
9
10
  [
@@ -14,5 +15,4 @@ module Agilibox::BackUrlConcern
14
15
  "/",
15
16
  ].select(&:present?).first
16
17
  end
17
-
18
18
  end
@@ -42,6 +42,10 @@ class Agilibox::SmallData::Filter
42
42
  end
43
43
  end
44
44
 
45
+ def respond_to_missing?(method, *)
46
+ strategies.key?(method.to_s) || strategies.key?(method.to_s.chomp("="))
47
+ end
48
+
45
49
  def read
46
50
  JSON.parse jar["filters"].to_s
47
51
  rescue JSON::ParserError
@@ -61,7 +65,7 @@ class Agilibox::SmallData::Filter
61
65
  end
62
66
 
63
67
  def empty?
64
- ! any?
68
+ !any?
65
69
  end
66
70
 
67
71
  private
@@ -1,5 +1,5 @@
1
1
  class Agilibox::SmallData::FilterStrategy
2
- def apply(query, value)
2
+ def apply(_query, _value)
3
3
  raise NotImplementedError
4
4
  end
5
5
  end
@@ -1,6 +1,6 @@
1
1
  class Agilibox::SmallData::FilterStrategyByDateBegin < ::Agilibox::SmallData::FilterStrategyByKeyValue
2
2
  def apply(query, value)
3
- value = Time.parse(value).beginning_of_day
3
+ value = Time.zone.parse(value).beginning_of_day
4
4
  query.where("#{key} >= ?", value)
5
5
  end
6
6
  end
@@ -1,6 +1,6 @@
1
1
  class Agilibox::SmallData::FilterStrategyByDateEnd < ::Agilibox::SmallData::FilterStrategyByKeyValue
2
2
  def apply(query, value)
3
- value = Time.parse(value).end_of_day
3
+ value = Time.zone.parse(value).end_of_day
4
4
  query.where("#{key} <= ?", value)
5
5
  end
6
6
  end
@@ -1,6 +1,6 @@
1
1
  class Agilibox::SmallData::FilterStrategyByTags < ::Agilibox::SmallData::FilterStrategy
2
2
  def apply(query, value)
3
- value = [*value].flatten.select{ |v| v.present? }
3
+ value = [*value].flatten.select(&:present?)
4
4
 
5
5
  if value.any?
6
6
  query.tagged_with(value)
@@ -1,5 +1,5 @@
1
1
  class Agilibox::SmallData::FilterStrategyByTimePeriod < ::Agilibox::SmallData::FilterStrategyByKeyValue
2
- def apply(query, value)
2
+ def apply(query, value) # rubocop:disable Metrics/MethodLength
3
3
  if value == "today"
4
4
  a = Time.zone.now.beginning_of_day
5
5
  b = Time.zone.now.end_of_day
@@ -1,6 +1,6 @@
1
1
  module Agilibox::BootstrapHelper
2
2
  def icon(id)
3
- id = id.to_s.gsub("_", "-")
4
- content_tag(:span, class: "icon fa fa-#{id}"){}
3
+ id = id.to_s.tr("_", "-")
4
+ content_tag(:span, class: "icon fa fa-#{id}") {}
5
5
  end
6
6
  end
@@ -12,13 +12,13 @@ module Agilibox::ButtonHelper
12
12
  :title => title,
13
13
  }.deep_merge(options)
14
14
 
15
- if confirm = options.delete(:confirm)
15
+ if (confirm = options.delete(:confirm))
16
16
  confirm = t("actions.confirm") if confirm == true
17
17
 
18
18
  options.deep_merge!(
19
19
  :data => {
20
20
  :confirm => confirm,
21
- }
21
+ },
22
22
  )
23
23
  end
24
24
 
@@ -40,7 +40,7 @@ module Agilibox::ButtonHelper
40
40
  options = {
41
41
  :icon => :plus,
42
42
  :action => :create,
43
- :class =>"btn btn-xs btn-success link_create"
43
+ :class =>"btn btn-xs btn-success link_create",
44
44
  }.merge(options)
45
45
 
46
46
  bs_button(url, options)
@@ -54,7 +54,7 @@ module Agilibox::FiltersHelper
54
54
  {
55
55
  t("time_periods.all_time") => "",
56
56
  t("time_periods.today") => "today",
57
- t("time_periods.yesterday") => "yesterday" ,
57
+ t("time_periods.yesterday") => "yesterday",
58
58
  t("time_periods.this_week") => "this_week",
59
59
  t("time_periods.last_week") => "last_week",
60
60
  t("time_periods.this_month") => "this_month",
@@ -64,5 +64,4 @@ module Agilibox::FiltersHelper
64
64
  t("time_periods.custom_date") => "custom_date",
65
65
  }
66
66
  end
67
-
68
67
  end
@@ -5,9 +5,9 @@ module Agilibox::FormHelper
5
5
  end
6
6
 
7
7
  def form_buttons(opts = {})
8
- back_url = opts[:back_url]
9
- back_url = url_for(:back).html_safe if back_url.blank?
10
- back_url = URI(back_url).path if back_url.include?("://")
8
+ back_url = opts[:back_url]
9
+ back_url = url_for(:back).html_safe if back_url.blank?
10
+ back_url = URI(back_url).path if back_url.include?("://")
11
11
 
12
12
  if opts[:obj].present?
13
13
  if opts[:obj].new_record?
@@ -25,7 +25,7 @@ module Agilibox::FormHelper
25
25
  end
26
26
 
27
27
  cancel = content_tag("a", href: back_url, class: "btn btn-primary btn-sm") do
28
- content_tag(:span, class: "fa fa-times"){} + " " + t("actions.cancel")
28
+ content_tag(:span, class: "fa fa-times") {} + " " + t("actions.cancel")
29
29
  end
30
30
 
31
31
  cancel = "" if back_url == false
@@ -34,12 +34,12 @@ module Agilibox::FormHelper
34
34
  end
35
35
  end
36
36
 
37
- def horizontal_form_for(obj, opts={}, &block)
37
+ def horizontal_form_for(obj, opts = {}, &block)
38
38
  opts = {
39
39
  :wrapper => "horizontal_form",
40
40
  :html => {
41
- :class => "form-horizontal"
42
- }
41
+ :class => "form-horizontal",
42
+ },
43
43
  }.deep_merge(opts)
44
44
 
45
45
  simple_form_for(obj, opts, &block)
@@ -59,5 +59,4 @@ module Agilibox::FormHelper
59
59
  :label => label,
60
60
  )
61
61
  end
62
-
63
62
  end
@@ -34,7 +34,7 @@ module Agilibox::LinkHelper
34
34
  def tel_link(text, opts = {})
35
35
  return if text.to_s.blank?
36
36
 
37
- value = text.gsub(" ", "")
37
+ value = text.delete(" ")
38
38
  href = "tel:#{value}"
39
39
 
40
40
  link_to(text, href, opts)
@@ -1,6 +1,6 @@
1
1
  module Agilibox::PaginationHelper
2
2
  def paginate(objects, options = {})
3
3
  options = {theme: "twitter-bootstrap-3"}.merge(options)
4
- super(objects, options).gsub(/>(\s+)</, '><').html_safe
4
+ super(objects, options).gsub(/>(\s+)</, "><").html_safe
5
5
  end
6
6
  end
@@ -12,7 +12,7 @@ module Agilibox::RoutesHelper
12
12
  :controller => "/#{obj.class.to_s.tableize}",
13
13
  :action => :show,
14
14
  :id => obj.to_param,
15
- :only_path => true
15
+ :only_path => true,
16
16
  }.merge(opts)
17
17
 
18
18
  routes.url_for(opts)
@@ -13,13 +13,13 @@ module Agilibox::TextHelper
13
13
  I18n.t("number.currency.format.format")
14
14
  .gsub("%n", number(n))
15
15
  .gsub("%u", u)
16
- .gsub(" ", "\u00A0")
16
+ .tr(" ", "\u00A0")
17
17
  end
18
18
 
19
19
  def percentage(n)
20
20
  return if n.nil?
21
21
 
22
- (number(n) + " %").gsub(" ", "\u00A0")
22
+ (number(n) + " %").tr(" ", "\u00A0")
23
23
  end
24
24
 
25
25
  def number(n)
@@ -27,7 +27,7 @@ module Agilibox::TextHelper
27
27
 
28
28
  opts = {}
29
29
 
30
- if n.class.to_s.match(/Float|Decimal/i)
30
+ if n.class.to_s =~ /Float|Decimal/i
31
31
  opts[:precision] = 2
32
32
  else
33
33
  opts[:precision] = 0
@@ -36,7 +36,7 @@ module Agilibox::TextHelper
36
36
  opts[:delimiter] = I18n.t("number.format.delimiter")
37
37
  opts[:separator] = I18n.t("number.format.separator")
38
38
 
39
- number_with_precision(n, opts).gsub(" ", "\u00A0")
39
+ number_with_precision(n, opts).tr(" ", "\u00A0")
40
40
  end
41
41
 
42
42
  def date(d)
@@ -56,16 +56,17 @@ module Agilibox::TextHelper
56
56
  def text2html(str)
57
57
  return if str.to_s.blank?
58
58
 
59
- str = str.gsub("\r", "").strip
59
+ str = str.delete("\r").strip
60
60
  strip_tags(str).gsub("\n", "<br />").html_safe
61
61
  end
62
62
 
63
63
  def lf2br(str)
64
64
  return if str.to_s.blank?
65
65
 
66
- str.gsub("\r", "").gsub("\n", "<br />").html_safe
66
+ str.delete("\r").gsub("\n", "<br />").html_safe
67
67
  end
68
68
 
69
+ # rubocop:disable Metrics/MethodLength
69
70
  def info(object, attribute, value_or_options = nil, options = {})
70
71
  if value_or_options.nil?
71
72
  value = object.public_send(attribute)
@@ -90,8 +91,8 @@ module Agilibox::TextHelper
90
91
  klass = object.is_a?(Module) ? object : object.class
91
92
  object_type = klass.to_s.split("::").last.underscore
92
93
 
93
- value = t("yes") if value === true
94
- value = t("no") if value === false
94
+ value = t("yes") if value == true
95
+ value = t("no") if value == false
95
96
  value = object.t("#{attribute}.#{value}") if nested
96
97
  value = send(helper, value) if helper
97
98
  value = number(value) if value.is_a?(Numeric)
@@ -99,7 +100,6 @@ module Agilibox::TextHelper
99
100
  value = l(value) if value.is_a?(Date)
100
101
  value = value.to_s
101
102
 
102
-
103
103
  html_label = content_tag(:strong, class: "info-label") { label }
104
104
  span_css_class = "info-value #{object_type}-#{attribute}"
105
105
  html_value = content_tag(:span, class: span_css_class) { value }
@@ -120,10 +120,9 @@ module Agilibox::TextHelper
120
120
  return "" if object.tag_list.empty?
121
121
 
122
122
  object.tag_list.map { |tag|
123
- content_tag(:span, class: "tag label label-primary"){
123
+ content_tag(:span, class: "tag label label-primary") {
124
124
  "#{icon :tag} #{tag}".html_safe
125
125
  }
126
126
  }.join(" ").html_safe
127
127
  end
128
-
129
128
  end
data/app/helpers/h.rb ADDED
@@ -0,0 +1,3 @@
1
+ # Short alias
2
+ # Example : H.number(123)
3
+ H = Agilibox::AllHelpers
@@ -0,0 +1,30 @@
1
+ class Agilibox::MiniModelSerializer::Serialize
2
+ attr_reader :object, :options
3
+
4
+ def initialize(object, options = {})
5
+ @object = object
6
+ @options = options
7
+ end
8
+
9
+ def call
10
+ if object.is_a?(Hash)
11
+ object.map { |k, v| [k.to_s, serialize(v)] }.to_h
12
+ elsif object.is_a?(Enumerable)
13
+ object.map { |e| serialize(e) }
14
+ elsif (serializer = "#{object.class}Serializer".safe_constantize)
15
+ serializer.call(object, options)
16
+ else
17
+ object.as_json
18
+ end
19
+ end
20
+
21
+ def self.call(*args)
22
+ new(*args).call
23
+ end
24
+
25
+ private
26
+
27
+ def serialize(object)
28
+ Agilibox::MiniModelSerializer::Serialize.call(object, options)
29
+ end
30
+ end
@@ -0,0 +1,23 @@
1
+ class Agilibox::MiniModelSerializer::Serializer < Agilibox::MiniModelSerializer::Serialize
2
+ def attributes
3
+ raise NotImplementedError
4
+ end
5
+
6
+ def call
7
+ serialize attributes.map { |k| [k, send(k)] }.to_h
8
+ end
9
+
10
+ private
11
+
12
+ def method_missing(m, *args)
13
+ if respond_to_missing?(m)
14
+ object.send(m, *args)
15
+ else
16
+ super
17
+ end
18
+ end
19
+
20
+ def respond_to_missing?(m, *)
21
+ object.respond_to?(m, true)
22
+ end
23
+ end
@@ -0,0 +1,16 @@
1
+ class Agilibox::PhoneNumberSanitizer
2
+ attr_reader :phone_number
3
+
4
+ def initialize(phone_number)
5
+ @phone_number = phone_number
6
+ end
7
+
8
+ def call
9
+ sanitized = phone_number.to_s.gsub(/[^0-9\+]+/, "")
10
+ sanitized if sanitized.present?
11
+ end
12
+
13
+ def self.call(*args)
14
+ new(*args).call
15
+ end
16
+ end
@@ -0,0 +1,37 @@
1
+ class Agilibox::TokenGenerator
2
+ attr_reader :options
3
+
4
+ def initialize(options = {})
5
+ @options = options
6
+ end
7
+
8
+ def size
9
+ options[:size] || self.class.default_size
10
+ end
11
+
12
+ def alphabet
13
+ options[:alphabet] || self.class.default_alphabet
14
+ end
15
+
16
+ def call
17
+ (alphabet * size).sample(size).join
18
+ end
19
+
20
+ class << self
21
+ def call(*args)
22
+ new(*args).call
23
+ end
24
+
25
+ attr_writer :default_size
26
+
27
+ def default_size
28
+ @default_size ||= 64
29
+ end
30
+
31
+ attr_writer :default_alphabet
32
+
33
+ def default_alphabet
34
+ @default_alphabet ||= (0..9).to_a + ("a".."z").to_a + ("A".."Z").to_a
35
+ end
36
+ end # class << self
37
+ end
@@ -1,10 +1,11 @@
1
1
  module Agilibox::DefaultValuesConcern
2
2
  extend ActiveSupport::Concern
3
3
 
4
- def assign_default_values; end
4
+ def assign_default_values
5
+ end
5
6
 
6
7
  def assign_default(attribute, value)
7
- self.send("#{attribute}=", value) if self.send(attribute).nil?
8
+ send("#{attribute}=", value) if send(attribute).nil?
8
9
  end
9
10
 
10
11
  included do
@@ -10,9 +10,8 @@ module Agilibox::ModelI18n
10
10
  end
11
11
 
12
12
  def tv(attribute)
13
- key = attribute
14
13
  value = public_send(attribute)
15
- t("#{key}.#{value}") if value.present?
14
+ t("#{attribute}.#{value}") if value.present?
16
15
  end
17
16
 
18
17
  class_methods do
@@ -11,7 +11,7 @@ module Agilibox::PolymorphicId
11
11
  def guid
12
12
  return nil if new_record?
13
13
 
14
- "#{self.class.base_class}-#{self.id}"
14
+ "#{self.class.base_class}-#{id}"
15
15
  end
16
16
  end # included
17
17
  end # module
@@ -26,7 +26,10 @@ Module.new do
26
26
  end
27
27
 
28
28
  def relation_guid=(guid)
29
- return self.relation = nil if guid.blank?
29
+ if guid.blank?
30
+ self.relation = nil
31
+ return
32
+ end
30
33
 
31
34
  type, id = guid.split("-", 2)
32
35
  self.relation = type.constantize.find(id)
@@ -3,7 +3,7 @@ module Agilibox::Search
3
3
 
4
4
  class_methods do
5
5
  def default_search_fields
6
- fields = columns.map do |column|
6
+ columns.map do |column|
7
7
  "#{table_name}.#{column.name}"
8
8
  end
9
9
  end # def default_search_fields
@@ -12,11 +12,11 @@ module Agilibox::Search
12
12
  words = q.to_s.parameterize.split("-")
13
13
  fields = default_search_fields if fields.empty?
14
14
 
15
- sql_query = words.map.with_index do |word, index|
16
- fields.map do |field|
15
+ sql_query = words.map.with_index { |_word, index|
16
+ fields.map { |field|
17
17
  "(UNACCENT(CAST(#{field} AS TEXT)) ILIKE :w#{index})"
18
- end.join(" OR ")
19
- end.map{ |e| "(#{e})" }.join(" AND ")
18
+ }.join(" OR ")
19
+ }.map { |e| "(#{e})" }.join(" AND ")
20
20
 
21
21
  sql_params_a = words.map.with_index do |word, index|
22
22
  ["w#{index}".to_sym, "%#{word}%"]
@@ -24,7 +24,7 @@ module Agilibox::Search
24
24
 
25
25
  sql_params_h = Hash[sql_params_a]
26
26
 
27
- self.where(sql_query, sql_params_h)
27
+ where(sql_query, sql_params_h)
28
28
  end # def search
29
29
  end # class_methods
30
30
  end # class Agilibox::Search
@@ -0,0 +1,17 @@
1
+ module Agilibox::TimestampHelpers
2
+ extend ActiveSupport::Concern
3
+
4
+ class_methods do
5
+ def first_created
6
+ reorder(:created_at, :id).first
7
+ end
8
+
9
+ def last_created
10
+ reorder(:created_at, :id).last
11
+ end
12
+
13
+ def last_updated
14
+ reorder(:updated_at, :id).last
15
+ end
16
+ end
17
+ end
@@ -10,7 +10,7 @@ class Agilibox::Serializers::Base
10
10
  raise NotImplementedError
11
11
  end
12
12
 
13
- def render_file(file_path)
13
+ def render_file(_file_path)
14
14
  raise NotImplementedError
15
15
  end
16
16
 
@@ -0,0 +1,5 @@
1
+ en:
2
+ errors:
3
+ not_found: "Page not found"
4
+ forbidden: "You must log in to access this page"
5
+ unauthorized: "You are not authorized to access this page"
@@ -0,0 +1,5 @@
1
+ fr:
2
+ errors:
3
+ not_found: "Page demandée non trouvée"
4
+ forbidden: "Vous devez être connecté pour accéder à cette page"
5
+ unauthorized: "Vous n'êtes pas authorisé à accéder à cette page"
@@ -1,7 +1,7 @@
1
1
  module Agilibox::ActiveRecordCommaTypeCast
2
2
  def cast_value(value)
3
3
  if value.is_a?(String)
4
- super value.gsub(",", ".").gsub(/[^-0-9\.]/, "")
4
+ super value.tr(",", ".").gsub(/[^-0-9\.]/, "")
5
5
  else
6
6
  super value
7
7
  end
@@ -1,3 +1,5 @@
1
+ require "awesome_print"
2
+ require "pry-rails"
1
3
  require "rails-i18n"
2
4
 
3
5
  module Agilibox
@@ -11,4 +13,5 @@ module Agilibox
11
13
  end
12
14
  end
13
15
 
16
+ require_relative "engine_file"
14
17
  require_relative "core_and_rails_ext"
@@ -0,0 +1,10 @@
1
+ module Kernel
2
+ def engine_file(engine)
3
+ app_file = caller(1..1).first.split(":").first
4
+ app_root = ::Rails.application.root.to_s
5
+ relative_file = app_file.sub(app_root, "")
6
+ engine_root = engine::Engine.root.to_s
7
+
8
+ ::File.join(engine_root, relative_file)
9
+ end
10
+ end
@@ -1,3 +1,3 @@
1
1
  module Agilibox
2
- VERSION = "1.0.9"
2
+ VERSION = "1.0.10"
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.0.9
4
+ version: 1.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - agilidée
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-26 00:00:00.000000000 Z
11
+ date: 2017-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails-i18n
@@ -79,6 +79,7 @@ files:
79
79
  - app/assets/stylesheets/agilibox/print.sass
80
80
  - app/controllers/agilibox/application_controller.rb
81
81
  - app/controllers/agilibox/small_data/filters_controller.rb
82
+ - app/controllers/concerns/agilibox/api_controller_concern.rb
82
83
  - app/controllers/concerns/agilibox/back_url_concern.rb
83
84
  - app/filters/agilibox/small_data/filter.rb
84
85
  - app/filters/agilibox/small_data/filter_strategy.rb
@@ -100,13 +101,19 @@ files:
100
101
  - app/helpers/agilibox/routes_helper.rb
101
102
  - app/helpers/agilibox/sorting_helper.rb
102
103
  - app/helpers/agilibox/text_helper.rb
104
+ - app/helpers/h.rb
105
+ - app/libs/agilibox/mini_model_serializer/serialize.rb
106
+ - app/libs/agilibox/mini_model_serializer/serializer.rb
107
+ - app/libs/agilibox/phone_number_sanitizer.rb
103
108
  - app/libs/agilibox/sortable_uuid_generator.rb
109
+ - app/libs/agilibox/token_generator.rb
104
110
  - app/models/concerns/agilibox/active_record_uuid_concern.rb
105
111
  - app/models/concerns/agilibox/default_values_concern.rb
106
112
  - app/models/concerns/agilibox/model_i18n.rb
107
113
  - app/models/concerns/agilibox/model_to_s.rb
108
114
  - app/models/concerns/agilibox/polymorphic_id.rb
109
115
  - app/models/concerns/agilibox/search.rb
116
+ - app/models/concerns/agilibox/timestamp_helpers.rb
110
117
  - app/serializers/agilibox/serializers.rb
111
118
  - app/serializers/agilibox/serializers/base.rb
112
119
  - app/serializers/agilibox/serializers/xlsx.rb
@@ -121,6 +128,8 @@ files:
121
128
  - config/locales/common.en.yml
122
129
  - config/locales/common.fr.yml
123
130
  - config/locales/dates.fr.yml
131
+ - config/locales/errors.en.yml
132
+ - config/locales/errors.fr.yml
124
133
  - config/routes.rb
125
134
  - db/migrate/20170502143330_enable_unaccent.rb
126
135
  - features/support/ajax.rb
@@ -142,6 +151,7 @@ files:
142
151
  - lib/agilibox/core_and_rails_ext.rb
143
152
  - lib/agilibox/cucumber_config.rb
144
153
  - lib/agilibox/engine.rb
154
+ - lib/agilibox/engine_file.rb
145
155
  - lib/agilibox/form_back_url.rb
146
156
  - lib/agilibox/version.rb
147
157
  - lib/tasks/agilibox_tasks.rake