team_fastlane-config_client_sequel 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.adoc +32 -0
- data/README.adoc +7 -0
- data/app/models/c_custcomppara.rb +4 -0
- data/app/models/c_feature_toggle.rb +7 -0
- data/app/models/s_key.rb +28 -0
- data/config/initializers/customer_company_configs.rb +20 -0
- data/lib/team_fastlane/config_client_sequel/customer_company.rb +14 -0
- data/lib/team_fastlane/config_client_sequel/version.rb +7 -0
- data/lib/team_fastlane/config_client_sequel.rb +11 -0
- metadata +54 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2c5f9caf8451caf6ad714f5fcb64ad2c699a57c7bbc09b86313fae4f44a16e3c
|
4
|
+
data.tar.gz: abc1bb03e374d7784a53f95a335220769ac3ae39933ec8e94ce6566532b5ba99
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8267ef6fb09e5fb64e80b8b37240cf6e0643e701628eb6ffc5701685d5fa14603246712c7329bc8bbe9d31fa558f6ee40ad23b63ddfa78afc1b4f84884e149eb
|
7
|
+
data.tar.gz: d3d591e7adf94df896363075397119bf20c4f8fef6c6d618c215106e6bb3f67725ce40edf317dfe923394e9373b5c6a6ad0fc5f689e683de509985d3cbd990b3
|
data/CHANGELOG.adoc
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
= Changelog
|
2
|
+
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
|
+
|
5
|
+
The format is based on https://keepachangelog.com[Keep a Changelog],
|
6
|
+
and this project adheres to https://semver.org[Semantic Versioning].
|
7
|
+
|
8
|
+
== Unreleased
|
9
|
+
|
10
|
+
== [1.0.0] - 2023-08-01
|
11
|
+
=== Changed
|
12
|
+
Renamed and restructured for release on rubygems
|
13
|
+
|
14
|
+
== [0.0.5] - 2022-01-04
|
15
|
+
=== Changed
|
16
|
+
- Rails 7 support
|
17
|
+
|
18
|
+
== [0.0.4] - 2022-01-03
|
19
|
+
=== Changed
|
20
|
+
- Small refactoring to comply to rubocop
|
21
|
+
|
22
|
+
== [0.0.3] - 2020-07-21
|
23
|
+
=== Added
|
24
|
+
- Allows to load SKeys by topic only. Results are grouped by subtopic then.
|
25
|
+
|
26
|
+
== [0.0.2] - 2020-07-14
|
27
|
+
=== Added
|
28
|
+
- Makes SKey loading more robust by allowing symbols and strings.
|
29
|
+
|
30
|
+
== [0.0.1] - 2020-07-14
|
31
|
+
=== Added
|
32
|
+
- Initial gem version based on the config_client.
|
data/README.adoc
ADDED
data/app/models/s_key.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class SKey < Sequel::Model(:s_key)
|
4
|
+
def self.load_key!(topic, subtopic, keyword)
|
5
|
+
first(s_topic: topic.to_s, s_subtopic: subtopic.to_s, s_keyword: keyword.to_s.upcase)&.value
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.load_multiple_keys(topic, subtopic = nil)
|
9
|
+
return load_multiple_keys_with_subtopic(topic) if subtopic.blank?
|
10
|
+
|
11
|
+
where(s_topic: topic.to_s, s_subtopic: subtopic.to_s).to_h do |s_key|
|
12
|
+
[s_key.s_keyword.underscore.to_sym, s_key.value]
|
13
|
+
end.freeze
|
14
|
+
end
|
15
|
+
|
16
|
+
def value
|
17
|
+
c_type.casecmp('C').zero? ? c_value : i_value
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.load_multiple_keys_with_subtopic(topic)
|
21
|
+
keys_by_subtopic = {}
|
22
|
+
where(s_topic: topic.to_s).map do |s_key|
|
23
|
+
keys_by_subtopic[s_key.s_subtopic.to_sym] = [] if keys_by_subtopic[s_key.s_subtopic.to_sym].blank?
|
24
|
+
keys_by_subtopic[s_key.s_subtopic.to_sym] << [s_key.s_keyword.underscore.to_sym, s_key.value]
|
25
|
+
end
|
26
|
+
keys_by_subtopic.transform_values { |keys| keys.to_h.freeze }.freeze
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class CustomerCompanyConfigs < Hash
|
4
|
+
def [](customer_company)
|
5
|
+
super(customer_company.to_i)
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
Rails.application.config.to_prepare do
|
10
|
+
Object.send(:remove_const, :CUSTOMER_COMPANY_CONFIGS) if Object.const_defined? :CUSTOMER_COMPANY_CONFIGS
|
11
|
+
CUSTOMER_COMPANY_CONFIGS = CustomerCompanyConfigs.new # rubocop:disable Lint/ConstantDefinitionInBlock
|
12
|
+
|
13
|
+
unless Rails.env.test?
|
14
|
+
CCustcomppara.pluck(:i_cust_company).each do |customer_company_id|
|
15
|
+
CUSTOMER_COMPANY_CONFIGS[customer_company_id] =
|
16
|
+
TeamFastlane::ConfigClientSequel::CustomerCompany.new(id: customer_company_id, company_id: 1)
|
17
|
+
end
|
18
|
+
CUSTOMER_COMPANY_CONFIGS.freeze
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# TODO: not safe for multi company environment
|
4
|
+
module TeamFastlane
|
5
|
+
module ConfigClientSequel
|
6
|
+
CustomerCompany = Struct.new(:id, :language, keyword_init: true) do
|
7
|
+
def initialize(company_id:, **args)
|
8
|
+
super(args)
|
9
|
+
c_custcomppara = CCustcomppara.first(i_company: company_id, i_cust_company: id)
|
10
|
+
self.language = c_custcomppara&.s_language&.downcase
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
metadata
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: team_fastlane-config_client_sequel
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Team Fastlane
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-08-02 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description:
|
14
|
+
email:
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files:
|
18
|
+
- README.adoc
|
19
|
+
- CHANGELOG.adoc
|
20
|
+
files:
|
21
|
+
- CHANGELOG.adoc
|
22
|
+
- README.adoc
|
23
|
+
- app/models/c_custcomppara.rb
|
24
|
+
- app/models/c_feature_toggle.rb
|
25
|
+
- app/models/s_key.rb
|
26
|
+
- config/initializers/customer_company_configs.rb
|
27
|
+
- lib/team_fastlane/config_client_sequel.rb
|
28
|
+
- lib/team_fastlane/config_client_sequel/customer_company.rb
|
29
|
+
- lib/team_fastlane/config_client_sequel/version.rb
|
30
|
+
homepage:
|
31
|
+
licenses:
|
32
|
+
- MIT
|
33
|
+
metadata:
|
34
|
+
rubygems_mfa_required: 'true'
|
35
|
+
post_install_message:
|
36
|
+
rdoc_options: []
|
37
|
+
require_paths:
|
38
|
+
- lib
|
39
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '2.7'
|
44
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
requirements: []
|
50
|
+
rubygems_version: 3.4.10
|
51
|
+
signing_key:
|
52
|
+
specification_version: 4
|
53
|
+
summary: Gem for an internal project
|
54
|
+
test_files: []
|