Class: KCommercial::Resources::Generator
- Inherits:
-
Object
- Object
- KCommercial::Resources::Generator
- Defined in:
- lib/KCommercialPipeline/core/resource/i18n/generator.rb,
lib/KCommercialPipeline/core/resource/code_generator/resources_status.rb
Defined Under Namespace
Classes: ResourcesStatus, SupportLanguage
Instance Attribute Summary collapse
-
#auto_push ⇒ Object
readonly
Returns the value of attribute auto_push.
-
#component ⇒ CocoaDepot::Component
readonly
The component for generate the resources.
-
#language ⇒ Object
readonly
Returns the value of attribute language.
-
#source ⇒ CocoaDepot::Resources::GitSource
readonly
The source for this generator.
Instance Method Summary collapse
-
#auto_assets_path ⇒ Pathname
The path for auto generated resources.
-
#auto_classes_path ⇒ Pathname
The path for auto generated classes.
-
#auto_path ⇒ Pathname
The path for auto generated files.
- #check_local_file_status ⇒ Object
-
#generate! ⇒ Object
Do the generate process, it will generate the code and get the remote resources.
-
#initialize(component, source, options = {}) ⇒ Generator
constructor
Create a new Generator.
Constructor Details
#initialize(component, source, options = {}) ⇒ Generator
Create a new Generator
60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/KCommercialPipeline/core/resource/i18n/generator.rb', line 60 def initialize(component, source, = {}) @component = component @super_module = .delete(:super_module) { 'MKResources' } @language = .delete(:language) || component.main_language @source = source @resources_status = ResourcesStatus.new @language = SupportLanguage::OC if @language == 'oc' unless SupportLanguage.values.include?(@language) raise "You set unsupported language #{@language}, please check!" end raise "Unsupported options: #{}" if .count.positive? end |
Instance Attribute Details
#auto_push ⇒ Object (readonly)
Returns the value of attribute auto_push.
58 59 60 |
# File 'lib/KCommercialPipeline/core/resource/i18n/generator.rb', line 58 def auto_push @auto_push end |
#component ⇒ CocoaDepot::Component (readonly)
The component for generate the resources
50 51 52 |
# File 'lib/KCommercialPipeline/core/resource/i18n/generator.rb', line 50 def component @component end |
#language ⇒ Object (readonly)
Returns the value of attribute language.
56 57 58 |
# File 'lib/KCommercialPipeline/core/resource/i18n/generator.rb', line 56 def language @language end |
#source ⇒ CocoaDepot::Resources::GitSource (readonly)
The source for this generator
54 55 56 |
# File 'lib/KCommercialPipeline/core/resource/i18n/generator.rb', line 54 def source @source end |
Instance Method Details
#auto_assets_path ⇒ Pathname
The path for auto generated resources
81 82 83 |
# File 'lib/KCommercialPipeline/core/resource/i18n/generator.rb', line 81 def auto_assets_path auto_path.join('Assets') end |
#auto_classes_path ⇒ Pathname
The path for auto generated classes
87 88 89 |
# File 'lib/KCommercialPipeline/core/resource/i18n/generator.rb', line 87 def auto_classes_path auto_path.join('Classes') end |
#auto_path ⇒ Pathname
The path for auto generated files
75 76 77 |
# File 'lib/KCommercialPipeline/core/resource/i18n/generator.rb', line 75 def auto_path component.path.join('Auto') end |
#check_local_file_status ⇒ Object
91 92 93 |
# File 'lib/KCommercialPipeline/core/resource/i18n/generator.rb', line 91 def check_local_file_status @auto_push = ResourcesUpdate.can_auto_push? end |
#generate! ⇒ Object
Do the generate process, it will generate the code and get the remote resources
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/KCommercialPipeline/core/resource/i18n/generator.rb', line 95 def generate! check_local_file_status update_source write_colors write_files write_fonts write_i18ns write_images case language when SupportLanguage::SWIFT write_swift_code 'Resources.swift', resources_class_contents when SupportLanguage::OC write_oc_key_defines OCFileModel.main_model, [] write_oc_key_defines OCFileModel.public_model, [] end auto_compoment_list = component.auto_compoment_list component.check_auto_compoment! component.check_auto_codes! auto_publish_components(auto_compoment_list || []) push_resource_to_remote end |