remote-I18n-extension-hcc 1.0.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: c4a338512aeedd7365f3a242889e32be1adaa60f691992d502ca0ab439c05f0d
4
+ data.tar.gz: 7014e16f97361cf85546799619f2dc8b928423984db8f8fc747ee920781ee161
5
+ SHA512:
6
+ metadata.gz: 79022619af5a2c95f56df231334615438b5abcebc8afe0006c9bf130ccd5a456fe8f234c1b1d5d58fd07e888540f82340b7b72d48326b346852cb79f5ae175cb
7
+ data.tar.gz: 1a88e35b3e1646c060020d54f7f9cc2ca1190cb2197ebe0d52c3b5dc13e017b6f9eb2a8f3a7222f69a8ef416408fba6dee54198763490998286f956b8f0c1021
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ # Changelog
2
+
3
+ ## 1.0.0 (06-May-23)
4
+
5
+ * Initial release
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gemspec
data/README.md ADDED
@@ -0,0 +1,9 @@
1
+ # Remote-I18n-Extension-Hcc
2
+
3
+ This gem provides an extension to the exsiting url(https://github.com/ruby-i18n/i18n)[I18n] gem by providing the ability to fetch locales from remote files
4
+
5
+
6
+ # Getting Started
7
+
8
+ # Requirements
9
+ This gem requires `ruby 3.1.3` and `Rails 7.0.4.3`
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ require 'rake'
2
+ require 'rubocop/rake_task'
3
+
4
+ RuboCop::RakeTask.new do |task|
5
+ task.requires << 'rubocop-performance'
6
+ task.requires << 'rubocop-rspec'
7
+ end
@@ -0,0 +1,43 @@
1
+ require 'open-uri'
2
+
3
+ module RemoteI18nExtensionHcc
4
+ module Backend
5
+ class Remote < I18n::Backend::Simple
6
+ protected
7
+
8
+ # Overrides load_yml method in Simple backend to load translation from
9
+ # the provided remote host otherwise return hash to suppress any error and
10
+ # fallback to Simple backend fetching translations from locale files.
11
+ def load_yml(filename)
12
+ YAML.load(load_remote_locales(filename))
13
+ rescue TypeError, ScriptError, StandardError
14
+ {}
15
+ end
16
+
17
+ # Overrides load_json method in Simple backend to load translation from
18
+ # the provided remote host otherwise return hash to suppress any error and
19
+ # fallback to Simple backend fetching translations from locale files.
20
+ def load_json(filename)
21
+ JSON.parse(load_remote_locales(filename))
22
+ rescue TypeError, StandardError
23
+ {}
24
+ end
25
+
26
+ # Overrides load_rb method in Simple backend to load translation from
27
+ # the provided remote host otherwise return hash to suppress any error and
28
+ # fallback to Simple backend fetching translations from locale files.
29
+ def load_rb(filename)
30
+ eval(load_remote_locales(filename), binding, filename)
31
+ rescue StandardError
32
+ {}
33
+ end
34
+
35
+ private
36
+
37
+ def load_remote_locales(filename)
38
+ remote_host = RemoteI18nExtensionHcc.remote_host
39
+ URI.parse("#{remote_host}/#{filename}").read
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,3 @@
1
+ module RemoteI18nExtensionHcc
2
+ VERSION = '1.0.0'.freeze
3
+ end
@@ -0,0 +1,23 @@
1
+ require 'i18n'
2
+ module RemoteI18nExtensionHcc
3
+ class << self
4
+ attr_reader :load_path, :available_locales, :locale
5
+ attr_accessor :remote_host
6
+
7
+ def config
8
+ yield self
9
+ end
10
+
11
+ def locale=(locale)
12
+ I18n.locale = locale || :en
13
+ end
14
+
15
+ def load_path=(paths_array)
16
+ I18n.load_path += paths_array
17
+ end
18
+
19
+ def available_locales=(locales_array)
20
+ I18n.available_locales = locales_array ? locales_array : [:en]
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,25 @@
1
+ require File.expand_path('lib/remote-I18n-extension-hcc/version', __dir__)
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = 'remote-I18n-extension-hcc'
5
+ spec.version = RemoteI18nExtensionHcc::VERSION
6
+ spec.authors = ['Hassan Ahmed']
7
+ spec.email = ['hassan91ahmed@gmail.com']
8
+ spec.summary = 'Support remote fetching of locales'
9
+ spec.description = 'Support remote fetching of locales'
10
+ spec.homepage = 'https://github.com/Gooner91/remoteI18nExtensionHcc'
11
+ spec.license = 'MIT'
12
+ spec.platform = Gem::Platform::RUBY
13
+ spec.required_ruby_version = '>=3.1.3'
14
+ spec.files = Dir['README.md', 'LICENSE',
15
+ 'CHANGELOG.md', 'lib/**/*.rb',
16
+ 'lib/**/*.rake',
17
+ 'remote-I18n-extension-hcc.gemspec', '.github/*.md',
18
+ 'Gemfile', 'Rakefile']
19
+ spec.add_dependency 'i18n', '~> 1.13.0'
20
+ spec.add_dependency 'rubocop-performance', '~> 1.17.1'
21
+ spec.add_dependency 'rubocop-rails', '~> 2.19.1'
22
+ spec.add_dependency 'rubocop-rspec', '~> 2.21.0'
23
+ spec.add_dependency 'rspec-rails', '~> 6.0.2'
24
+ spec.metadata['rubygems_mfa_required'] = 'true'
25
+ end
metadata ADDED
@@ -0,0 +1,122 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: remote-I18n-extension-hcc
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Hassan Ahmed
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2023-05-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: i18n
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 1.13.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 1.13.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: rubocop-performance
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 1.17.1
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 1.17.1
41
+ - !ruby/object:Gem::Dependency
42
+ name: rubocop-rails
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 2.19.1
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 2.19.1
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop-rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 2.21.0
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 2.21.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec-rails
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 6.0.2
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 6.0.2
83
+ description: Support remote fetching of locales
84
+ email:
85
+ - hassan91ahmed@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - CHANGELOG.md
91
+ - Gemfile
92
+ - README.md
93
+ - Rakefile
94
+ - lib/remote-I18n-extension-hcc.rb
95
+ - lib/remote-I18n-extension-hcc/backend/remote.rb
96
+ - lib/remote-I18n-extension-hcc/version.rb
97
+ - remote-I18n-extension-hcc.gemspec
98
+ homepage: https://github.com/Gooner91/remoteI18nExtensionHcc
99
+ licenses:
100
+ - MIT
101
+ metadata:
102
+ rubygems_mfa_required: 'true'
103
+ post_install_message:
104
+ rdoc_options: []
105
+ require_paths:
106
+ - lib
107
+ required_ruby_version: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: 3.1.3
112
+ required_rubygems_version: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ requirements: []
118
+ rubygems_version: 3.4.12
119
+ signing_key:
120
+ specification_version: 4
121
+ summary: Support remote fetching of locales
122
+ test_files: []