commonbase 0.2.1.1 → 0.2.2.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2f5d677e7683684a69c2367a0618278c3002b2357e55d78903a3d373cda436c1
4
- data.tar.gz: 84833dc2bff19cc0d52fa98a90aff34894fdee0cf3f4f6fdb37868c21ba71db3
3
+ metadata.gz: 739c8005df020b95dcf792727970e80d95ad7c3481a7117f421639d84407e653
4
+ data.tar.gz: 4c8502104ef432482e435151734aa472f703b1f5f45efc89de2b584dd69b8669
5
5
  SHA512:
6
- metadata.gz: '03933eaec86f59e555ed08f3d5d5c293c92f735751f5cb170c90f7fbf3aa067e78fdc02eb030bf7f0436ce5c9189623447c8100b4d3747db419379310b86ae2f'
7
- data.tar.gz: 128507a1cbeac1ae5349aaa439a7c2ff454fff72f0500488554271ce136960c6bdd6676f029d3309039f39950b7729b2ed8fde50276ba0baf49c0efd2488aad6
6
+ metadata.gz: e4b8fce6b2f444e26e354742b704341da8fb6bf0c2237a74816634896465b45eba185eb0075631f7163d7cde835bc981175a02939817abbfb4195284ecd95d5d
7
+ data.tar.gz: 4e0e77e8a6e0649fb0c5945c56640bef4e14f50e80a15660a84b861c5b41934fa0076a58fe78602d2bed2600e7eb85abafcc833b121cbb68220104dc38bbdd36
data/Rakefile CHANGED
@@ -1,5 +1,8 @@
1
1
  require "bundler/setup"
2
2
 
3
+ APP_RAKEFILE = File.expand_path("spec/dummy/Rakefile", __dir__)
4
+ load "rails/tasks/engine.rake"
5
+
3
6
  load "rails/tasks/statistics.rake"
4
7
 
5
8
  require "bundler/gem_tasks"
@@ -0,0 +1,4 @@
1
+ module Commonbase
2
+ class ApplicationController < ActionController::Base
3
+ end
4
+ end
@@ -0,0 +1,5 @@
1
+ module Commonbase
2
+ class ApplicationRecord < ActiveRecord::Base
3
+ self.abstract_class = true
4
+ end
5
+ end
@@ -1,6 +1,5 @@
1
1
  module Commonbase
2
2
  class Engine < ::Rails::Engine
3
3
  isolate_namespace Commonbase
4
-
5
4
  end
6
5
  end
@@ -1,10 +1,28 @@
1
1
  module Commonbase
2
2
  module Utils
3
+ def self.boolean_to_yes_no(value)
4
+ if value == true
5
+ "YES"
6
+ elsif value == false
7
+ "NO"
8
+ else
9
+ ""
10
+ end
11
+ end
12
+
13
+ def self.yes_no_to_boolean(value)
14
+ return false unless value.present?
15
+ return ["YES", "Y"].include?(value.upcase)
16
+ end
17
+
3
18
  def self.parse_date(str, format = nil)
4
19
  return nil unless str.present?
5
- return format.present? ? Date.strptime(str, format) : Date.strptime(str)
6
- rescue ArgumentError
7
- nil
20
+
21
+ if format.present?
22
+ return Date.strptime(str, format) rescue nil
23
+ end
24
+
25
+ return Date.strptime(str) rescue nil
8
26
  end
9
27
  end
10
28
  end
@@ -1,3 +1,3 @@
1
- module Commonbase
2
- VERSION = "0.2.1.1"
3
- end
1
+ module Commonbase
2
+ VERSION = "0.2.2.1"
3
+ end
data/lib/commonbase.rb CHANGED
@@ -1,9 +1,9 @@
1
- require "commonbase/version"
2
- require "commonbase/engine"
3
- require "commonbase/concerns/ransack_searchable"
4
- require "commonbase/concerns/date_validations"
5
- require "commonbase/helpers/log_helpers"
6
-
7
- module Commonbase
8
- # Your code goes here...
9
- end
1
+ require "commonbase/version"
2
+ require "commonbase/engine"
3
+
4
+ require "commonbase/helpers/log_helpers"
5
+ require "commonbase/helpers/utils"
6
+
7
+ module Commonbase
8
+ # Your code goes here...
9
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: commonbase
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1.1
4
+ version: 0.2.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-02-24 00:00:00.000000000 Z
11
+ date: 2025-03-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -16,15 +16,71 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '7.2'
19
+ version: '7.0'
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: '7.2'
27
- description: Commonbase module for other modules.
26
+ version: '7.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec-rails
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: shoulda-matchers
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: factory_bot_rails
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: byebug
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: Commonbase module for other modules
28
84
  email:
29
85
  - juanonsoftware@gmail.com
30
86
  executables: []
@@ -36,24 +92,25 @@ files:
36
92
  - Rakefile
37
93
  - app/assets/config/commonbase_manifest.js
38
94
  - app/assets/stylesheets/commonbase/application.css
95
+ - app/controllers/commonbase/application_controller.rb
39
96
  - app/helpers/commonbase/application_helper.rb
40
97
  - app/jobs/commonbase/application_job.rb
41
98
  - app/mailers/commonbase/application_mailer.rb
99
+ - app/models/commonbase/application_record.rb
100
+ - app/models/concerns/commonbase/ransack_searchable.rb
42
101
  - app/views/layouts/commonbase/application.html.erb
43
102
  - config/routes.rb
44
103
  - lib/commonbase.rb
45
- - lib/commonbase/concerns/date_validations.rb
46
- - lib/commonbase/concerns/ransack_searchable.rb
47
104
  - lib/commonbase/engine.rb
48
105
  - lib/commonbase/helpers/log_helpers.rb
49
106
  - lib/commonbase/helpers/utils.rb
50
107
  - lib/commonbase/version.rb
51
108
  - lib/tasks/commonbase_tasks.rake
52
- homepage: https://abizvn.com
109
+ homepage: https://github.com/abizvncom/commonbase
53
110
  licenses:
54
111
  - MIT
55
112
  metadata:
56
- homepage_uri: https://abizvn.com
113
+ homepage_uri: https://github.com/abizvncom/commonbase
57
114
  source_code_uri: https://github.com/abizvncom/commonbase
58
115
  changelog_uri: https://github.com/abizvncom/commonbase
59
116
  post_install_message:
@@ -74,5 +131,5 @@ requirements: []
74
131
  rubygems_version: 3.4.19
75
132
  signing_key:
76
133
  specification_version: 4
77
- summary: Commonbase module.
134
+ summary: Commonbase module
78
135
  test_files: []
@@ -1,58 +0,0 @@
1
- module Commonbase
2
- module DateValidations
3
- extend ActiveSupport::Concern
4
-
5
- class_methods do
6
- # Validate if a date is in future. By default today is invalid. Set include_today to true to include today.
7
- def validate_future_date(attribute, options = {})
8
- validates_each attribute do |record, attr, value|
9
- next unless value.present?
10
-
11
- include_today = options[:include_today] || false
12
-
13
- if value < Date.today || (value == Date.today && include_today.equal?(false))
14
- record.errors.add(attr, options[:message] || "must be in the future")
15
- end
16
- end
17
- end
18
-
19
- # Validate if a date is in the past. By default today is invalid. Set include_today to true to include today.
20
- def validate_past_date(attribute, options = {})
21
- validates_each attribute do |record, attr, value|
22
- next unless value.present?
23
-
24
- include_today = options[:include_today] || false
25
-
26
- if value > Date.today || (value == Date.today && include_today.equal?(false))
27
- record.errors.add(attr, options[:message] || "must be in the past")
28
- end
29
- end
30
- end
31
-
32
- def validate_date_within_range(attribute, options = {})
33
- validates_each attribute do |record, attr, value|
34
- next unless value.present?
35
-
36
- begin_date = options[:begin].present? ? options[:begin] : nil
37
- end_date = options[:end].present? ? options[:end] : nil
38
-
39
- unless (value.to_date rescue nil).present?
40
- record.errors.add(attr, "must be a valid date")
41
- end
42
-
43
- unless (begin_date.to_date rescue nil).present? || (end_date.to_date rescue nil).present?
44
- record.errors.add(attr, "must have options with a valid date for begin or end")
45
- end
46
-
47
- if begin_date.present? && value < begin_date
48
- record.errors.add(attr, "must be after or equal to #{begin_date.strftime('%Y-%m-%d')}")
49
- end
50
-
51
- if end_date.present? && value > end_date
52
- record.errors.add(attr, "must be before or equal to #{end_date.strftime('%Y-%m-%d')}")
53
- end
54
- end
55
- end
56
- end
57
- end
58
- end