Class: Fastlane::Helper::Providers::BaseProvider
- Inherits:
-
Object
- Object
- Fastlane::Helper::Providers::BaseProvider
- Defined in:
- lib/fastlane/plugin/translate_gpt_release_notes/helper/providers/base_provider.rb
Overview
Abstract base class for all translation providers. Subclasses must implement all abstract methods to provide provider-specific translation functionality.
Direct Known Subclasses
AnthropicProvider, DeepLProvider, GeminiProvider, OpenAIProvider
Constant Summary collapse
- ANDROID_CHAR_LIMIT =
Maximum character length for Google Play release notes
500
Instance Attribute Summary collapse
-
#config_errors ⇒ Object
readonly
Returns the value of attribute config_errors.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Class Method Summary collapse
-
.display_name ⇒ String
Returns the human-readable display name for the provider.
-
.optional_params ⇒ Hash
Returns a hash of optional parameter definitions for this provider.
-
.provider_name ⇒ String
Returns the provider identifier string.
-
.required_credentials ⇒ Array<Symbol>
Returns the list of required credential symbols for this provider.
Instance Method Summary collapse
-
#initialize(params) ⇒ BaseProvider
constructor
Initializes the provider with configuration parameters.
-
#translate(text, source_locale, target_locale, glossary_terms: {}) ⇒ String?
Translates text from source locale to target locale.
-
#valid? ⇒ Boolean
Checks if the provider configuration is valid.
-
#validate_config! ⇒ void
Validates provider-specific configuration.
Constructor Details
#initialize(params) ⇒ BaseProvider
Initializes the provider with configuration parameters. Automatically validates the configuration.
17 18 19 20 21 |
# File 'lib/fastlane/plugin/translate_gpt_release_notes/helper/providers/base_provider.rb', line 17 def initialize(params) @params = params @config_errors = [] validate_config! end |
Instance Attribute Details
#config_errors ⇒ Object (readonly)
Returns the value of attribute config_errors.
11 12 13 |
# File 'lib/fastlane/plugin/translate_gpt_release_notes/helper/providers/base_provider.rb', line 11 def config_errors @config_errors end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
11 12 13 |
# File 'lib/fastlane/plugin/translate_gpt_release_notes/helper/providers/base_provider.rb', line 11 def params @params end |
Class Method Details
.display_name ⇒ String
Returns the human-readable display name for the provider. Must be implemented by subclasses.
56 57 58 |
# File 'lib/fastlane/plugin/translate_gpt_release_notes/helper/providers/base_provider.rb', line 56 def self.display_name raise NotImplementedError, "#{name} must implement .display_name" end |
.optional_params ⇒ Hash
Returns a hash of optional parameter definitions for this provider. Keys are parameter names, values are hashes with :default and :description. Must be implemented by subclasses.
73 74 75 |
# File 'lib/fastlane/plugin/translate_gpt_release_notes/helper/providers/base_provider.rb', line 73 def self.optional_params raise NotImplementedError, "#{name} must implement .optional_params" end |
.provider_name ⇒ String
Returns the provider identifier string. Must be implemented by subclasses.
48 49 50 |
# File 'lib/fastlane/plugin/translate_gpt_release_notes/helper/providers/base_provider.rb', line 48 def self.provider_name raise NotImplementedError, "#{name} must implement .provider_name" end |
.required_credentials ⇒ Array<Symbol>
Returns the list of required credential symbols for this provider. Must be implemented by subclasses.
64 65 66 |
# File 'lib/fastlane/plugin/translate_gpt_release_notes/helper/providers/base_provider.rb', line 64 def self.required_credentials raise NotImplementedError, "#{name} must implement .required_credentials" end |
Instance Method Details
#translate(text, source_locale, target_locale, glossary_terms: {}) ⇒ String?
Translates text from source locale to target locale. Must be implemented by subclasses.
31 32 33 |
# File 'lib/fastlane/plugin/translate_gpt_release_notes/helper/providers/base_provider.rb', line 31 def translate(text, source_locale, target_locale, glossary_terms: {}) raise NotImplementedError, "#{self.class.name} must implement #translate" end |
#valid? ⇒ Boolean
Checks if the provider configuration is valid.
80 81 82 |
# File 'lib/fastlane/plugin/translate_gpt_release_notes/helper/providers/base_provider.rb', line 80 def valid? @config_errors.empty? end |
#validate_config! ⇒ void
This method returns an undefined value.
Validates provider-specific configuration. Should populate @config_errors with any validation failures. Must be implemented by subclasses.
40 41 42 |
# File 'lib/fastlane/plugin/translate_gpt_release_notes/helper/providers/base_provider.rb', line 40 def validate_config! raise NotImplementedError, "#{self.class.name} must implement #validate_config!" end |